From a0e884cf8bffe1a0394d106375f6a23edd2b60e6 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 15 Jan 2021 16:56:40 +0100 Subject: merge cmplog --- include/afl-fuzz.h | 21 +- include/cmplog.h | 17 +- include/debug.h | 24 +- include/types.h | 43 +- instrumentation/afl-compiler-rt.o.c | 89 +- instrumentation/cmplog-instructions-pass.cc | 586 +++++++++-- src/afl-cc.c | 49 +- src/afl-fuzz-init.c | 38 + src/afl-fuzz-one.c | 81 +- src/afl-fuzz-queue.c | 1 + src/afl-fuzz-redqueen.c | 1437 +++++++++++++++++++++++---- src/afl-fuzz-state.c | 1 + src/afl-fuzz.c | 60 +- 13 files changed, 2055 insertions(+), 392 deletions(-) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 988a907d..8a2122dc 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -145,12 +145,22 @@ extern s16 interesting_16[INTERESTING_8_LEN + INTERESTING_16_LEN]; extern s32 interesting_32[INTERESTING_8_LEN + INTERESTING_16_LEN + INTERESTING_32_LEN]; +struct tainted { + + u32 pos; + u32 len; + struct tainted *next; + struct tainted *prev; + +}; + struct queue_entry { u8 *fname; /* File name for the test case */ u32 len; /* Input length */ - u8 cal_failed; /* Calibration failed? */ + u8 colorized, /* Do not run redqueen stage again */ + cal_failed; /* Calibration failed? */ bool trim_done, /* Trimmed? */ was_fuzzed, /* historical, but needed for MOpt */ passed_det, /* Deterministic stages passed? */ @@ -158,7 +168,6 @@ struct queue_entry { var_behavior, /* Variable behavior? */ favored, /* Currently favored? */ fs_redundant, /* Marked as redundant in the fs? */ - fully_colorized, /* Do not run redqueen stage again */ is_ascii, /* Is the input just ascii text? */ disabled; /* Is disabled from fuzz selection */ @@ -183,7 +192,11 @@ struct queue_entry { u8 *testcase_buf; /* The testcase buffer, if loaded. */ - struct queue_entry *next; /* Next element, if any */ + u8 * cmplog_colorinput; /* the result buf of colorization */ + struct tainted *taint; /* Taint information from CmpLog */ + + struct queue_entry *mother, /* queue entry this based on */ + *next; /* Next element, if any */ }; @@ -636,6 +649,8 @@ typedef struct afl_state { /* cmplog forkserver ids */ s32 cmplog_fsrv_ctl_fd, cmplog_fsrv_st_fd; u32 cmplog_prev_timed_out; + u32 cmplog_max_filesize; + u32 cmplog_lvl; struct afl_pass_stat *pass_stats; struct cmp_map * orig_cmp_map; diff --git a/include/cmplog.h b/include/cmplog.h index bf557785..6392c503 100644 --- a/include/cmplog.h +++ b/include/cmplog.h @@ -30,8 +30,10 @@ #include "config.h" +#define CMPLOG_LVL_MAX 3 + #define CMP_MAP_W 65536 -#define CMP_MAP_H 256 +#define CMP_MAP_H 32 #define CMP_MAP_RTN_H (CMP_MAP_H / 4) #define SHAPE_BYTES(x) (x + 1) @@ -41,13 +43,12 @@ struct cmp_header { - unsigned hits : 20; - - unsigned cnt : 20; - unsigned id : 16; - - unsigned shape : 5; // from 0 to 31 + unsigned hits : 24; + unsigned id : 24; + unsigned shape : 5; unsigned type : 1; + unsigned attribute : 4; + unsigned reserved : 6; } __attribute__((packed)); @@ -55,6 +56,8 @@ struct cmp_operands { u64 v0; u64 v1; + u64 v0_128; + u64 v1_128; }; diff --git a/include/debug.h b/include/debug.h index ef5b195b..fc1f39cb 100644 --- a/include/debug.h +++ b/include/debug.h @@ -295,8 +295,8 @@ static inline const char *colorfilter(const char *x) { \ SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \ "\n[-] PROGRAM ABORT : " cRST x); \ - SAYF(cLRD "\n Location : " cRST "%s(), %s:%d\n\n", __func__, \ - __FILE__, __LINE__); \ + SAYF(cLRD "\n Location : " cRST "%s(), %s:%u\n\n", __func__, \ + __FILE__, (u32)__LINE__); \ exit(1); \ \ } while (0) @@ -308,8 +308,8 @@ static inline const char *colorfilter(const char *x) { \ SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \ "\n[-] PROGRAM ABORT : " cRST x); \ - SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%d\n\n", __func__, \ - __FILE__, __LINE__); \ + SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n\n", __func__, \ + __FILE__, (u32)__LINE__); \ abort(); \ \ } while (0) @@ -322,8 +322,8 @@ static inline const char *colorfilter(const char *x) { fflush(stdout); \ SAYF(bSTOP RESET_G1 CURSOR_SHOW cRST cLRD \ "\n[-] SYSTEM ERROR : " cRST x); \ - SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%d\n", __func__, \ - __FILE__, __LINE__); \ + SAYF(cLRD "\n Stop location : " cRST "%s(), %s:%u\n", __func__, \ + __FILE__, (u32)__LINE__); \ SAYF(cLRD " OS message : " cRST "%s\n", strerror(errno)); \ exit(1); \ \ @@ -344,12 +344,12 @@ static inline const char *colorfilter(const char *x) { /* Show a prefixed debug output. */ -#define DEBUGF(x...) \ - do { \ - \ - SAYF(cMGN "[D] " cBRI "DEBUG: " cRST x); \ - SAYF(cRST ""); \ - \ +#define DEBUGF(x...) \ + do { \ + \ + fprintf(stderr, cMGN "[D] " cBRI "DEBUG: " cRST x); \ + fprintf(stderr, cRST ""); \ + \ } while (0) /* Error-checking versions of read() and write() that call RPFATAL() as diff --git a/include/types.h b/include/types.h index 3e3bc953..d5c31597 100644 --- a/include/types.h +++ b/include/types.h @@ -26,9 +26,11 @@ #include #include -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef unsigned __int128 uint128_t; +typedef uint128_t u128; /* Extended forkserver option values */ @@ -57,10 +59,12 @@ typedef uint32_t u32; typedef unsigned long long u64; -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef int64_t s64; +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; +typedef __int128 int128_t; +typedef int128_t s128; #ifndef MIN #define MIN(a, b) \ @@ -114,6 +118,31 @@ typedef int64_t s64; \ }) +// It is impossible to define 128 bit constants, so ... +#define SWAPN(_x, _l) \ + ({ \ + \ + u128 _res = (_x), _ret; \ + char *d = (char *)&_ret, *s = (char *)&_res; \ + int i; \ + for (i = 0; i < 16; i++) \ + d[15 - i] = s[i]; \ + u32 sr = 128U - ((_l) << 3U); \ + (_ret >>= sr); \ + (u128) _ret; \ + \ + }) + +#define SWAPNN(_x, _y, _l) \ + ({ \ + \ + char *d = (char *)(_x), *s = (char *)(_y); \ + u32 i, l = (_l)-1; \ + for (i = 0; i <= l; i++) \ + d[l - i] = s[i]; \ + \ + }) + #ifdef AFL_LLVM_PASS #if defined(__linux__) || !defined(__ANDROID__) #define AFL_SR(s) (srandom(s)) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index b735d8df..5d75af78 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -161,7 +161,7 @@ void send_forkserver_error(int error) { u32 status; if (!error || error > 0xffff) return; status = (FS_OPT_ERROR | FS_OPT_SET_ERROR(error)); - if (write(FORKSRV_FD + 1, (char *)&status, 4) != 4) return; + if (write(FORKSRV_FD + 1, (char *)&status, 4) != 4) { return; } } @@ -544,11 +544,11 @@ static void __afl_start_snapshots(void) { if (__afl_dictionary_len && __afl_dictionary) status |= FS_OPT_AUTODICT; memcpy(tmp, &status, 4); - if (write(FORKSRV_FD + 1, tmp, 4) != 4) return; + if (write(FORKSRV_FD + 1, tmp, 4) != 4) { return; } if (__afl_sharedmem_fuzzing || (__afl_dictionary_len && __afl_dictionary)) { - if (read(FORKSRV_FD, &was_killed, 4) != 4) _exit(1); + if (read(FORKSRV_FD, &was_killed, 4) != 4) { _exit(1); } if (getenv("AFL_DEBUG")) { @@ -1207,7 +1207,9 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) { ///// CmpLog instrumentation -void __cmplog_ins_hook1(uint8_t arg1, uint8_t arg2) { +void __cmplog_ins_hook1(uint8_t arg1, uint8_t arg2, uint8_t attr) { + + // fprintf(stderr, "hook1 arg0=%02x arg1=%02x attr=%u\n", arg1, arg2, attr); if (unlikely(!__afl_cmp_map)) return; @@ -1216,6 +1218,7 @@ void __cmplog_ins_hook1(uint8_t arg1, uint8_t arg2) { k &= CMP_MAP_W - 1; __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + __afl_cmp_map->headers[k].attribute = attr; u32 hits = __afl_cmp_map->headers[k].hits; __afl_cmp_map->headers[k].hits = hits + 1; @@ -1230,7 +1233,7 @@ void __cmplog_ins_hook1(uint8_t arg1, uint8_t arg2) { } -void __cmplog_ins_hook2(uint16_t arg1, uint16_t arg2) { +void __cmplog_ins_hook2(uint16_t arg1, uint16_t arg2, uint8_t attr) { if (unlikely(!__afl_cmp_map)) return; @@ -1239,6 +1242,7 @@ void __cmplog_ins_hook2(uint16_t arg1, uint16_t arg2) { k &= CMP_MAP_W - 1; __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + __afl_cmp_map->headers[k].attribute = attr; u32 hits = __afl_cmp_map->headers[k].hits; __afl_cmp_map->headers[k].hits = hits + 1; @@ -1251,7 +1255,9 @@ void __cmplog_ins_hook2(uint16_t arg1, uint16_t arg2) { } -void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2) { +void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2, uint8_t attr) { + + // fprintf(stderr, "hook4 arg0=%x arg1=%x attr=%u\n", arg1, arg2, attr); if (unlikely(!__afl_cmp_map)) return; @@ -1260,6 +1266,7 @@ void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2) { k &= CMP_MAP_W - 1; __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + __afl_cmp_map->headers[k].attribute = attr; u32 hits = __afl_cmp_map->headers[k].hits; __afl_cmp_map->headers[k].hits = hits + 1; @@ -1272,7 +1279,9 @@ void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2) { } -void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2) { +void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2, uint8_t attr) { + + // fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); if (unlikely(!__afl_cmp_map)) return; @@ -1281,6 +1290,7 @@ void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2) { k &= CMP_MAP_W - 1; __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + __afl_cmp_map->headers[k].attribute = attr; u32 hits = __afl_cmp_map->headers[k].hits; __afl_cmp_map->headers[k].hits = hits + 1; @@ -1293,16 +1303,77 @@ void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2) { } +// support for u24 to u120 via llvm _ExitInt(). size is in bytes minus 1 +void __cmplog_ins_hookN(uint128_t arg1, uint128_t arg2, uint8_t attr, + uint8_t size) { + + // fprintf(stderr, "hookN arg0=%llx:%llx arg1=%llx:%llx bytes=%u attr=%u\n", + // (u64)(arg1 >> 64), (u64)arg1, (u64)(arg2 >> 64), (u64)arg2, size + 1, + // attr); + + if (unlikely(!__afl_cmp_map)) return; + + uintptr_t k = (uintptr_t)__builtin_return_address(0); + k = (k >> 4) ^ (k << 8); + k &= CMP_MAP_W - 1; + + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + __afl_cmp_map->headers[k].attribute = attr; + + u32 hits = __afl_cmp_map->headers[k].hits; + __afl_cmp_map->headers[k].hits = hits + 1; + + __afl_cmp_map->headers[k].shape = size; + + hits &= CMP_MAP_H - 1; + __afl_cmp_map->log[k][hits].v0 = (u64)arg1; + __afl_cmp_map->log[k][hits].v1 = (u64)arg2; + + if (size > 7) { + + __afl_cmp_map->log[k][hits].v0_128 = (u64)(arg1 >> 64); + __afl_cmp_map->log[k][hits].v1_128 = (u64)(arg2 >> 64); + + } + +} + +void __cmplog_ins_hook16(uint128_t arg1, uint128_t arg2, uint8_t attr) { + + if (unlikely(!__afl_cmp_map)) return; + + uintptr_t k = (uintptr_t)__builtin_return_address(0); + k = (k >> 4) ^ (k << 8); + k &= CMP_MAP_W - 1; + + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + __afl_cmp_map->headers[k].attribute = attr; + + u32 hits = __afl_cmp_map->headers[k].hits; + __afl_cmp_map->headers[k].hits = hits + 1; + + __afl_cmp_map->headers[k].shape = 15; + + hits &= CMP_MAP_H - 1; + __afl_cmp_map->log[k][hits].v0 = (u64)arg1; + __afl_cmp_map->log[k][hits].v1 = (u64)arg2; + __afl_cmp_map->log[k][hits].v0_128 = (u64)(arg1 >> 64); + __afl_cmp_map->log[k][hits].v1_128 = (u64)(arg2 >> 64); + +} + #if defined(__APPLE__) #pragma weak __sanitizer_cov_trace_const_cmp1 = __cmplog_ins_hook1 #pragma weak __sanitizer_cov_trace_const_cmp2 = __cmplog_ins_hook2 #pragma weak __sanitizer_cov_trace_const_cmp4 = __cmplog_ins_hook4 #pragma weak __sanitizer_cov_trace_const_cmp8 = __cmplog_ins_hook8 + #pragma weak __sanitizer_cov_trace_const_cmp16 = __cmplog_ins_hook16 #pragma weak __sanitizer_cov_trace_cmp1 = __cmplog_ins_hook1 #pragma weak __sanitizer_cov_trace_cmp2 = __cmplog_ins_hook2 #pragma weak __sanitizer_cov_trace_cmp4 = __cmplog_ins_hook4 #pragma weak __sanitizer_cov_trace_cmp8 = __cmplog_ins_hook8 + #pragma weak __sanitizer_cov_trace_cmp16 = __cmplog_ins_hook16 #else void __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2) __attribute__((alias("__cmplog_ins_hook1"))); @@ -1312,6 +1383,8 @@ void __sanitizer_cov_trace_const_cmp4(uint32_t arg1, uint32_t arg2) __attribute__((alias("__cmplog_ins_hook4"))); void __sanitizer_cov_trace_const_cmp8(uint64_t arg1, uint64_t arg2) __attribute__((alias("__cmplog_ins_hook8"))); +void __sanitizer_cov_trace_const_cmp16(uint128_t arg1, uint128_t arg2) + __attribute__((alias("__cmplog_ins_hook16"))); void __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) __attribute__((alias("__cmplog_ins_hook1"))); @@ -1321,6 +1394,8 @@ void __sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2) __attribute__((alias("__cmplog_ins_hook4"))); void __sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2) __attribute__((alias("__cmplog_ins_hook8"))); +void __sanitizer_cov_trace_cmp16(uint128_t arg1, uint128_t arg2) + __attribute__((alias("__cmplog_ins_hook16"))); #endif /* defined(__APPLE__) */ void __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) { diff --git a/instrumentation/cmplog-instructions-pass.cc b/instrumentation/cmplog-instructions-pass.cc index 3499ccf0..a74fb6c8 100644 --- a/instrumentation/cmplog-instructions-pass.cc +++ b/instrumentation/cmplog-instructions-pass.cc @@ -85,9 +85,25 @@ class CmpLogInstructions : public ModulePass { char CmpLogInstructions::ID = 0; +template +Iterator Unique(Iterator first, Iterator last) { + + while (first != last) { + + Iterator next(first); + last = std::remove(++next, last, *first); + first = next; + + } + + return last; + +} + bool CmpLogInstructions::hookInstrs(Module &M) { std::vector icomps; + std::vector switches; LLVMContext & C = M.getContext(); Type * VoidTy = Type::getVoidTy(C); @@ -95,13 +111,15 @@ bool CmpLogInstructions::hookInstrs(Module &M) { IntegerType *Int16Ty = IntegerType::getInt16Ty(C); IntegerType *Int32Ty = IntegerType::getInt32Ty(C); IntegerType *Int64Ty = IntegerType::getInt64Ty(C); + IntegerType *Int128Ty = IntegerType::getInt128Ty(C); #if LLVM_VERSION_MAJOR < 9 Constant * #else FunctionCallee #endif - c1 = M.getOrInsertFunction("__cmplog_ins_hook1", VoidTy, Int8Ty, Int8Ty + c1 = M.getOrInsertFunction("__cmplog_ins_hook1", VoidTy, Int8Ty, Int8Ty, + Int8Ty #if LLVM_VERSION_MAJOR < 5 , NULL @@ -118,7 +136,8 @@ bool CmpLogInstructions::hookInstrs(Module &M) { #else FunctionCallee #endif - c2 = M.getOrInsertFunction("__cmplog_ins_hook2", VoidTy, Int16Ty, Int16Ty + c2 = M.getOrInsertFunction("__cmplog_ins_hook2", VoidTy, Int16Ty, Int16Ty, + Int8Ty #if LLVM_VERSION_MAJOR < 5 , NULL @@ -135,7 +154,8 @@ bool CmpLogInstructions::hookInstrs(Module &M) { #else FunctionCallee #endif - c4 = M.getOrInsertFunction("__cmplog_ins_hook4", VoidTy, Int32Ty, Int32Ty + c4 = M.getOrInsertFunction("__cmplog_ins_hook4", VoidTy, Int32Ty, Int32Ty, + Int8Ty #if LLVM_VERSION_MAJOR < 5 , NULL @@ -152,7 +172,8 @@ bool CmpLogInstructions::hookInstrs(Module &M) { #else FunctionCallee #endif - c8 = M.getOrInsertFunction("__cmplog_ins_hook8", VoidTy, Int64Ty, Int64Ty + c8 = M.getOrInsertFunction("__cmplog_ins_hook8", VoidTy, Int64Ty, Int64Ty, + Int8Ty #if LLVM_VERSION_MAJOR < 5 , NULL @@ -164,6 +185,42 @@ bool CmpLogInstructions::hookInstrs(Module &M) { FunctionCallee cmplogHookIns8 = c8; #endif +#if LLVM_VERSION_MAJOR < 9 + Constant * +#else + FunctionCallee +#endif + c16 = M.getOrInsertFunction("__cmplog_ins_hook16", VoidTy, Int128Ty, + Int128Ty, Int8Ty +#if LLVM_VERSION_MAJOR < 5 + , + NULL +#endif + ); +#if LLVM_VERSION_MAJOR < 9 + Function *cmplogHookIns16 = cast(c16); +#else + FunctionCallee cmplogHookIns16 = c16; +#endif + +#if LLVM_VERSION_MAJOR < 9 + Constant * +#else + FunctionCallee +#endif + cN = M.getOrInsertFunction("__cmplog_ins_hookN", VoidTy, Int128Ty, + Int128Ty, Int8Ty, Int8Ty +#if LLVM_VERSION_MAJOR < 5 + , + NULL +#endif + ); +#if LLVM_VERSION_MAJOR < 9 + Function *cmplogHookInsN = cast(cN); +#else + FunctionCallee cmplogHookInsN = cN; +#endif + /* iterate over all functions, bbs and instruction and add suitable calls */ for (auto &F : M) { @@ -174,35 +231,16 @@ bool CmpLogInstructions::hookInstrs(Module &M) { for (auto &IN : BB) { CmpInst *selectcmpInst = nullptr; - if ((selectcmpInst = dyn_cast(&IN))) { - if (selectcmpInst->getPredicate() == CmpInst::ICMP_EQ || - selectcmpInst->getPredicate() == CmpInst::ICMP_NE || - selectcmpInst->getPredicate() == CmpInst::ICMP_UGT || - selectcmpInst->getPredicate() == CmpInst::ICMP_SGT || - selectcmpInst->getPredicate() == CmpInst::ICMP_ULT || - selectcmpInst->getPredicate() == CmpInst::ICMP_SLT || - selectcmpInst->getPredicate() == CmpInst::ICMP_UGE || - selectcmpInst->getPredicate() == CmpInst::ICMP_SGE || - selectcmpInst->getPredicate() == CmpInst::ICMP_ULE || - selectcmpInst->getPredicate() == CmpInst::ICMP_SLE || - selectcmpInst->getPredicate() == CmpInst::FCMP_OGE || - selectcmpInst->getPredicate() == CmpInst::FCMP_UGE || - selectcmpInst->getPredicate() == CmpInst::FCMP_OLE || - selectcmpInst->getPredicate() == CmpInst::FCMP_ULE || - selectcmpInst->getPredicate() == CmpInst::FCMP_OGT || - selectcmpInst->getPredicate() == CmpInst::FCMP_UGT || - selectcmpInst->getPredicate() == CmpInst::FCMP_OLT || - selectcmpInst->getPredicate() == CmpInst::FCMP_ULT || - selectcmpInst->getPredicate() == CmpInst::FCMP_UEQ || - selectcmpInst->getPredicate() == CmpInst::FCMP_OEQ || - selectcmpInst->getPredicate() == CmpInst::FCMP_UNE || - selectcmpInst->getPredicate() == CmpInst::FCMP_ONE) { - - icomps.push_back(selectcmpInst); + icomps.push_back(selectcmpInst); - } + } + + SwitchInst *switchInst = nullptr; + if ((switchInst = dyn_cast(BB.getTerminator()))) { + + if (switchInst->getNumCases() > 1) { switches.push_back(switchInst); } } @@ -212,101 +250,473 @@ bool CmpLogInstructions::hookInstrs(Module &M) { } - if (!icomps.size()) return false; - // if (!be_quiet) errs() << "Hooking " << icomps.size() << " cmp - // instructions\n"; + // unique the collected switches + switches.erase(Unique(switches.begin(), switches.end()), switches.end()); + + // Instrument switch values for cmplog + if (switches.size()) { + + if (!be_quiet) + errs() << "Hooking " << switches.size() << " switch instructions\n"; - for (auto &selectcmpInst : icomps) { + for (auto &SI : switches) { - IRBuilder<> IRB(selectcmpInst->getParent()); - IRB.SetInsertPoint(selectcmpInst); + Value * Val = SI->getCondition(); + unsigned int max_size = Val->getType()->getIntegerBitWidth(), cast_size; + unsigned char do_cast = 0; - auto op0 = selectcmpInst->getOperand(0); - auto op1 = selectcmpInst->getOperand(1); + if (!SI->getNumCases() || max_size <= 8) { - IntegerType * intTyOp0 = NULL; - IntegerType * intTyOp1 = NULL; - unsigned max_size = 0; - std::vector args; + // if (!be_quiet) errs() << "skip trivial switch..\n"; + continue; - if (selectcmpInst->getOpcode() == Instruction::FCmp) { + } + + IRBuilder<> IRB(SI->getParent()); + IRB.SetInsertPoint(SI); + + if (max_size % 8) { + + max_size = (((max_size / 8) + 1) * 8); + do_cast = 1; + + } + + if (max_size > 128) { + + if (!be_quiet) { + + fprintf(stderr, + "Cannot handle this switch bit size: %u (truncating)\n", + max_size); + + } + + max_size = 128; + do_cast = 1; + + } + + // do we need to cast? + switch (max_size) { + + case 8: + case 16: + case 32: + case 64: + case 128: + cast_size = max_size; + break; + default: + cast_size = 128; + do_cast = 1; + + } + + Value *CompareTo = Val; + + if (do_cast) { + + ConstantInt *cint = dyn_cast(Val); + if (cint) { + + uint64_t val = cint->getZExtValue(); + // fprintf(stderr, "ConstantInt: %lu\n", val); + switch (cast_size) { + + case 8: + CompareTo = ConstantInt::get(Int8Ty, val); + break; + case 16: + CompareTo = ConstantInt::get(Int16Ty, val); + break; + case 32: + CompareTo = ConstantInt::get(Int32Ty, val); + break; + case 64: + CompareTo = ConstantInt::get(Int64Ty, val); + break; + case 128: + CompareTo = ConstantInt::get(Int128Ty, val); + break; + + } - auto ty0 = op0->getType(); - if (ty0->isHalfTy() + } else { + + CompareTo = IRB.CreateBitCast(Val, IntegerType::get(C, cast_size)); + + } + + } + + for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e; + ++i) { + +#if LLVM_VERSION_MAJOR < 5 + ConstantInt *cint = i.getCaseValue(); +#else + ConstantInt *cint = i->getCaseValue(); +#endif + + if (cint) { + + std::vector args; + args.push_back(CompareTo); + + Value *new_param = cint; + + if (do_cast) { + + uint64_t val = cint->getZExtValue(); + // fprintf(stderr, "ConstantInt: %lu\n", val); + switch (cast_size) { + + case 8: + new_param = ConstantInt::get(Int8Ty, val); + break; + case 16: + new_param = ConstantInt::get(Int16Ty, val); + break; + case 32: + new_param = ConstantInt::get(Int32Ty, val); + break; + case 64: + new_param = ConstantInt::get(Int64Ty, val); + break; + case 128: + new_param = ConstantInt::get(Int128Ty, val); + break; + + } + + } + + if (new_param) { + + args.push_back(new_param); + ConstantInt *attribute = ConstantInt::get(Int8Ty, 1); + args.push_back(attribute); + if (cast_size != max_size) { + + ConstantInt *bitsize = + ConstantInt::get(Int8Ty, (max_size / 8) - 1); + args.push_back(bitsize); + + } + + switch (cast_size) { + + case 8: + IRB.CreateCall(cmplogHookIns1, args); + break; + case 16: + IRB.CreateCall(cmplogHookIns2, args); + break; + case 32: + IRB.CreateCall(cmplogHookIns4, args); + break; + case 64: + IRB.CreateCall(cmplogHookIns8, args); + break; + case 128: + if (max_size == 128) { + + IRB.CreateCall(cmplogHookIns16, args); + + } else { + + IRB.CreateCall(cmplogHookInsN, args); + + } + + break; + + } + + } + + } + + } + + } + + } + + if (icomps.size()) { + + // if (!be_quiet) errs() << "Hooking " << icomps.size() << + // " cmp instructions\n"; + + for (auto &selectcmpInst : icomps) { + + IRBuilder<> IRB(selectcmpInst->getParent()); + IRB.SetInsertPoint(selectcmpInst); + + Value *op0 = selectcmpInst->getOperand(0); + Value *op1 = selectcmpInst->getOperand(1); + + IntegerType * intTyOp0 = NULL; + IntegerType * intTyOp1 = NULL; + unsigned max_size = 0, cast_size = 0; + unsigned char attr = 0, do_cast = 0; + std::vector args; + + CmpInst *cmpInst = dyn_cast(selectcmpInst); + + if (!cmpInst) { continue; } + + switch (cmpInst->getPredicate()) { + + case CmpInst::ICMP_NE: + case CmpInst::FCMP_UNE: + case CmpInst::FCMP_ONE: + break; + case CmpInst::ICMP_EQ: + case CmpInst::FCMP_UEQ: + case CmpInst::FCMP_OEQ: + attr += 1; + break; + case CmpInst::ICMP_UGT: + case CmpInst::ICMP_SGT: + case CmpInst::FCMP_OGT: + case CmpInst::FCMP_UGT: + attr += 2; + break; + case CmpInst::ICMP_UGE: + case CmpInst::ICMP_SGE: + case CmpInst::FCMP_OGE: + case CmpInst::FCMP_UGE: + attr += 3; + break; + case CmpInst::ICMP_ULT: + case CmpInst::ICMP_SLT: + case CmpInst::FCMP_OLT: + case CmpInst::FCMP_ULT: + attr += 4; + break; + case CmpInst::ICMP_ULE: + case CmpInst::ICMP_SLE: + case CmpInst::FCMP_OLE: + case CmpInst::FCMP_ULE: + attr += 5; + break; + default: + break; + + } + + if (selectcmpInst->getOpcode() == Instruction::FCmp) { + + auto ty0 = op0->getType(); + if (ty0->isHalfTy() #if LLVM_VERSION_MAJOR >= 11 - || ty0->isBFloatTy() + || ty0->isBFloatTy() #endif - ) - max_size = 16; - else if (ty0->isFloatTy()) - max_size = 32; - else if (ty0->isDoubleTy()) - max_size = 64; + ) + max_size = 16; + else if (ty0->isFloatTy()) + max_size = 32; + else if (ty0->isDoubleTy()) + max_size = 64; + else if (ty0->isX86_FP80Ty()) + max_size = 80; + else if (ty0->isFP128Ty() || ty0->isPPC_FP128Ty()) + max_size = 128; + + attr += 8; + do_cast = 1; - if (max_size) { + } else { - Value *V0 = IRB.CreateBitCast(op0, IntegerType::get(C, max_size)); - intTyOp0 = dyn_cast(V0->getType()); - Value *V1 = IRB.CreateBitCast(op1, IntegerType::get(C, max_size)); - intTyOp1 = dyn_cast(V1->getType()); + intTyOp0 = dyn_cast(op0->getType()); + intTyOp1 = dyn_cast(op1->getType()); if (intTyOp0 && intTyOp1) { max_size = intTyOp0->getBitWidth() > intTyOp1->getBitWidth() ? intTyOp0->getBitWidth() : intTyOp1->getBitWidth(); - args.push_back(V0); - args.push_back(V1); - } else { + } + + } + + if (!max_size) { continue; } + + // _ExtInt() with non-8th values + if (max_size % 8) { + + max_size = (((max_size / 8) + 1) * 8); + do_cast = 1; + + } + + if (max_size > 128) { + + if (!be_quiet) { - max_size = 0; + fprintf(stderr, + "Cannot handle this compare bit size: %u (truncating)\n", + max_size); } + max_size = 128; + do_cast = 1; + + } + + // do we need to cast? + switch (max_size) { + + case 8: + case 16: + case 32: + case 64: + case 128: + cast_size = max_size; + break; + default: + cast_size = 128; + do_cast = 1; + } - } else { + if (do_cast) { + + // F*cking LLVM optimized out any kind of bitcasts of ConstantInt values + // creating illegal calls. WTF. So we have to work around this. + + ConstantInt *cint = dyn_cast(op0); + if (cint) { + + uint64_t val = cint->getZExtValue(); + // fprintf(stderr, "ConstantInt: %lu\n", val); + ConstantInt *new_param = NULL; + switch (cast_size) { + + case 8: + new_param = ConstantInt::get(Int8Ty, val); + break; + case 16: + new_param = ConstantInt::get(Int16Ty, val); + break; + case 32: + new_param = ConstantInt::get(Int32Ty, val); + break; + case 64: + new_param = ConstantInt::get(Int64Ty, val); + break; + case 128: + new_param = ConstantInt::get(Int128Ty, val); + break; + + } + + if (!new_param) { continue; } + args.push_back(new_param); + + } else { + + Value *V0 = IRB.CreateBitCast(op0, IntegerType::get(C, cast_size)); + args.push_back(V0); + + } + + cint = dyn_cast(op1); + if (cint) { + + uint64_t val = cint->getZExtValue(); + ConstantInt *new_param = NULL; + switch (cast_size) { + + case 8: + new_param = ConstantInt::get(Int8Ty, val); + break; + case 16: + new_param = ConstantInt::get(Int16Ty, val); + break; + case 32: + new_param = ConstantInt::get(Int32Ty, val); + break; + case 64: + new_param = ConstantInt::get(Int64Ty, val); + break; + case 128: + new_param = ConstantInt::get(Int128Ty, val); + break; + + } + + if (!new_param) { continue; } + args.push_back(new_param); + + } else { + + Value *V1 = IRB.CreateBitCast(op1, IntegerType::get(C, cast_size)); + args.push_back(V1); - intTyOp0 = dyn_cast(op0->getType()); - intTyOp1 = dyn_cast(op1->getType()); + } - if (intTyOp0 && intTyOp1) { + } else { - max_size = intTyOp0->getBitWidth() > intTyOp1->getBitWidth() - ? intTyOp0->getBitWidth() - : intTyOp1->getBitWidth(); args.push_back(op0); args.push_back(op1); } - } + ConstantInt *attribute = ConstantInt::get(Int8Ty, attr); + args.push_back(attribute); + + if (cast_size != max_size) { + + ConstantInt *bitsize = ConstantInt::get(Int8Ty, (max_size / 8) - 1); + args.push_back(bitsize); + + } + + // fprintf(stderr, "_ExtInt(%u) castTo %u with attr %u didcast %u\n", + // max_size, cast_size, attr, do_cast); + + switch (cast_size) { - if (max_size < 8 || max_size > 64 || !intTyOp0 || !intTyOp1) continue; - - switch (max_size) { - - case 8: - IRB.CreateCall(cmplogHookIns1, args); - break; - case 16: - IRB.CreateCall(cmplogHookIns2, args); - break; - case 32: - IRB.CreateCall(cmplogHookIns4, args); - break; - case 64: - IRB.CreateCall(cmplogHookIns8, args); - break; - default: - break; + case 8: + IRB.CreateCall(cmplogHookIns1, args); + break; + case 16: + IRB.CreateCall(cmplogHookIns2, args); + break; + case 32: + IRB.CreateCall(cmplogHookIns4, args); + break; + case 64: + IRB.CreateCall(cmplogHookIns8, args); + break; + case 128: + if (max_size == 128) { + + IRB.CreateCall(cmplogHookIns16, args); + + } else { + + IRB.CreateCall(cmplogHookInsN, args); + + } + + break; + + } } } - return true; + if (switches.size() || icomps.size()) + return true; + else + return false; } diff --git a/src/afl-cc.c b/src/afl-cc.c index 8fb42718..02c9c7c5 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -528,10 +528,10 @@ static void edit_params(u32 argc, char **argv, char **envp) { cc_params[cc_par_cnt++] = alloc_printf( "-Wl,-mllvm=-load=%s/cmplog-routines-pass.so", obj_path); - cc_params[cc_par_cnt++] = alloc_printf( - "-Wl,-mllvm=-load=%s/split-switches-pass.so", obj_path); cc_params[cc_par_cnt++] = alloc_printf( "-Wl,-mllvm=-load=%s/cmplog-instructions-pass.so", obj_path); + cc_params[cc_par_cnt++] = alloc_printf( + "-Wl,-mllvm=-load=%s/split-switches-pass.so", obj_path); } else { @@ -541,18 +541,18 @@ static void edit_params(u32 argc, char **argv, char **envp) { cc_params[cc_par_cnt++] = alloc_printf("%s/cmplog-routines-pass.so", obj_path); - // reuse split switches from laf cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = "-load"; cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = - alloc_printf("%s/split-switches-pass.so", obj_path); + alloc_printf("%s/cmplog-instructions-pass.so", obj_path); + // reuse split switches from laf cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = "-load"; cc_params[cc_par_cnt++] = "-Xclang"; cc_params[cc_par_cnt++] = - alloc_printf("%s/cmplog-instructions-pass.so", obj_path); + alloc_printf("%s/split-switches-pass.so", obj_path); } @@ -792,10 +792,8 @@ static void edit_params(u32 argc, char **argv, char **envp) { } -#if defined(USEMMAP) - #if !defined(__HAIKU__) +#if defined(USEMMAP) && !defined(__HAIKU__) cc_params[cc_par_cnt++] = "-lrt"; - #endif #endif cc_params[cc_par_cnt++] = "-D__AFL_HAVE_MANUAL_CONTROL=1"; @@ -858,6 +856,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_DISCARD()=__afl_coverage_discard()"; cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_ABORT()=__afl_coverage_abort()"; + cc_params[cc_par_cnt++] = "-D__AFL_FUZZ_TESTCASE_BUF=(__afl_fuzz_ptr ? __afl_fuzz_ptr : " "__afl_fuzz_alt_ptr)"; @@ -967,10 +966,8 @@ static void edit_params(u32 argc, char **argv, char **envp) { alloc_printf("-Wl,--dynamic-list=%s/dynamic_list.txt", obj_path); #endif - #if defined(USEMMAP) - #if !defined(__HAIKU__) + #if defined(USEMMAP) && !defined(__HAIKU__) cc_params[cc_par_cnt++] = "-lrt"; - #endif #endif } @@ -1278,7 +1275,6 @@ int main(int argc, char **argv, char **envp) { } - // this is a hidden option if (strncasecmp(ptr2, "llvmnative", strlen("llvmnative")) == 0 || strncasecmp(ptr2, "llvm-native", strlen("llvm-native")) == 0) { @@ -1349,29 +1345,28 @@ int main(int argc, char **argv, char **envp) { if (strncasecmp(ptr2, "ngram", strlen("ngram")) == 0) { - ptr2 += strlen("ngram"); - while (*ptr2 && (*ptr2 < '0' || *ptr2 > '9')) - ptr2++; + u8 *ptr3 = ptr2 + strlen("ngram"); + while (*ptr3 && (*ptr3 < '0' || *ptr3 > '9')) + ptr3++; - if (!*ptr2) { + if (!*ptr3) { - if ((ptr2 = getenv("AFL_LLVM_NGRAM_SIZE")) == NULL) + if ((ptr3 = getenv("AFL_LLVM_NGRAM_SIZE")) == NULL) FATAL( "you must set the NGRAM size with (e.g. for value 2) " "AFL_LLVM_INSTRUMENT=ngram-2"); } - ngram_size = atoi(ptr2); + ngram_size = atoi(ptr3); if (ngram_size < 2 || ngram_size > NGRAM_SIZE_MAX) FATAL( "NGRAM instrumentation option must be between 2 and " - "NGRAM_SIZE_MAX " - "(%u)", + "NGRAM_SIZE_MAX (%u)", NGRAM_SIZE_MAX); instrument_opt_mode |= (INSTRUMENT_OPT_NGRAM); - ptr2 = alloc_printf("%u", ngram_size); - setenv("AFL_LLVM_NGRAM_SIZE", ptr2, 1); + u8 *ptr4 = alloc_printf("%u", ngram_size); + setenv("AFL_LLVM_NGRAM_SIZE", ptr4, 1); } @@ -1507,6 +1502,7 @@ int main(int argc, char **argv, char **envp) { "((instrumentation/README.ngram.md)\n" " INSTRIM: Dominator tree (for LLVM <= 6.0) " "(instrumentation/README.instrim.md)\n\n"); + #undef NATIVE_MSG SAYF( @@ -1641,16 +1637,15 @@ int main(int argc, char **argv, char **envp) { if (have_lto) SAYF("afl-cc LTO with ld=%s %s\n", AFL_REAL_LD, AFL_CLANG_FLTO); if (have_llvm) - SAYF("afl-cc LLVM version %d using binary path \"%s\".\n", LLVM_MAJOR, + SAYF("afl-cc LLVM version %d using the binary path \"%s\".\n", LLVM_MAJOR, LLVM_BINDIR); #endif -#if defined(USEMMAP) +#ifdef USEMMAP #if !defined(__HAIKU__) - cc_params[cc_par_cnt++] = "-lrt"; - SAYF("Compiled with shm_open support (adds -lrt when linking).\n"); - #else SAYF("Compiled with shm_open support.\n"); + #else + SAYF("Compiled with shm_open support (adds -lrt when linking).\n"); #endif #else SAYF("Compiled with shmat support.\n"); diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index dbffa4f9..cbff6d7e 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -729,6 +729,30 @@ void read_testcases(afl_state_t *afl, u8 *directory) { add_to_queue(afl, fn2, st.st_size >= MAX_FILE ? MAX_FILE : st.st_size, passed_det); + if (unlikely(afl->shm.cmplog_mode)) { + + if (afl->cmplog_lvl == 1) { + + if (!afl->cmplog_max_filesize || + afl->cmplog_max_filesize < st.st_size) { + + afl->cmplog_max_filesize = st.st_size; + + } + + } else if (afl->cmplog_lvl == 2) { + + if (!afl->cmplog_max_filesize || + afl->cmplog_max_filesize > st.st_size) { + + afl->cmplog_max_filesize = st.st_size; + + } + + } + + } + if (unlikely(afl->schedule >= FAST && afl->schedule <= RARE)) { u64 cksum = hash64(afl->fsrv.trace_bits, afl->fsrv.map_size, HASH_CONST); @@ -756,6 +780,20 @@ void read_testcases(afl_state_t *afl, u8 *directory) { } + if (unlikely(afl->shm.cmplog_mode)) { + + if (afl->cmplog_max_filesize < 1024) { + + afl->cmplog_max_filesize = 1024; + + } else { + + afl->cmplog_max_filesize = (((afl->cmplog_max_filesize >> 10) + 1) << 10); + + } + + } + afl->last_path_time = 0; afl->queued_at_start = afl->queued_paths; diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c index f9509e86..596bae22 100644 --- a/src/afl-fuzz-one.c +++ b/src/afl-fuzz-one.c @@ -165,7 +165,7 @@ static u8 could_be_arith(u32 old_val, u32 new_val, u8 blen) { /* See if one-byte adjustments to any byte could produce this result. */ - for (i = 0; i < blen; ++i) { + for (i = 0; (u8)i < blen; ++i) { u8 a = old_val >> (8 * i), b = new_val >> (8 * i); @@ -193,7 +193,7 @@ static u8 could_be_arith(u32 old_val, u32 new_val, u8 blen) { diffs = 0; - for (i = 0; i < blen / 2; ++i) { + for (i = 0; (u8)i < blen / 2; ++i) { u16 a = old_val >> (16 * i), b = new_val >> (16 * i); @@ -290,7 +290,7 @@ static u8 could_be_interest(u32 old_val, u32 new_val, u8 blen, u8 check_le) { /* See if two-byte insertions over old_val could give us new_val. */ - for (i = 0; (s32)i < blen - 1; ++i) { + for (i = 0; (u8)i < blen - 1; ++i) { for (j = 0; j < sizeof(interesting_16) / 2; ++j) { @@ -545,14 +545,31 @@ u8 fuzz_one_original(afl_state_t *afl) { else orig_perf = perf_score = calculate_score(afl, afl->queue_cur); - if (unlikely(perf_score == 0)) { goto abandon_entry; } + if (unlikely(perf_score <= 0)) { goto abandon_entry; } - if (unlikely(afl->shm.cmplog_mode && !afl->queue_cur->fully_colorized)) { + if (unlikely(afl->shm.cmplog_mode && + afl->queue_cur->colorized < afl->cmplog_lvl && + (u32)len <= afl->cmplog_max_filesize)) { - if (input_to_state_stage(afl, in_buf, out_buf, len, - afl->queue_cur->exec_cksum)) { + if (unlikely(len < 4)) { - goto abandon_entry; + afl->queue_cur->colorized = 0xff; + + } else { + + if (afl->cmplog_lvl == 3 || + (afl->cmplog_lvl == 2 && afl->queue_cur->tc_ref) || + !(afl->fsrv.total_execs % afl->queued_paths) || + get_cur_time() - afl->last_path_time > 15000) { + + if (input_to_state_stage(afl, in_buf, out_buf, len, + afl->queue_cur->exec_cksum)) { + + goto abandon_entry; + + } + + } } @@ -2796,7 +2813,7 @@ static u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) { } - s32 len, temp_len; + u32 len, temp_len; u32 i; u32 j; u8 *in_buf, *out_buf, *orig_in, *ex_tmp, *eff_map = 0; @@ -2952,14 +2969,31 @@ static u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) { else orig_perf = perf_score = calculate_score(afl, afl->queue_cur); - if (unlikely(perf_score == 0)) { goto abandon_entry; } + if (unlikely(perf_score <= 0)) { goto abandon_entry; } - if (unlikely(afl->shm.cmplog_mode && !afl->queue_cur->fully_colorized)) { + if (unlikely(afl->shm.cmplog_mode && + afl->queue_cur->colorized < afl->cmplog_lvl && + (u32)len <= afl->cmplog_max_filesize)) { - if (input_to_state_stage(afl, in_buf, out_buf, len, - afl->queue_cur->exec_cksum)) { + if (unlikely(len < 4)) { - goto abandon_entry; + afl->queue_cur->colorized = 0xff; + + } else { + + if (afl->cmplog_lvl == 3 || + (afl->cmplog_lvl == 2 && afl->queue_cur->tc_ref) || + !(afl->fsrv.total_execs % afl->queued_paths) || + get_cur_time() - afl->last_path_time > 15000) { + + if (input_to_state_stage(afl, in_buf, out_buf, len, + afl->queue_cur->exec_cksum)) { + + goto abandon_entry; + + } + + } } @@ -3315,7 +3349,7 @@ static u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) { orig_hit_cnt = new_hit_cnt; - for (i = 0; (s32)i < len - 1; ++i) { + for (i = 0; i < len - 1; ++i) { /* Let's consult the effector map... */ @@ -3357,7 +3391,7 @@ static u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) { orig_hit_cnt = new_hit_cnt; - for (i = 0; (s32)i < len - 3; ++i) { + for (i = 0; i < len - 3; ++i) { /* Let's consult the effector map... */ if (!eff_map[EFF_APOS(i)] && !eff_map[EFF_APOS(i + 1)] && @@ -3489,7 +3523,7 @@ skip_bitflip: orig_hit_cnt = new_hit_cnt; - for (i = 0; (s32)i < len - 1; ++i) { + for (i = 0; i < len - 1; ++i) { u16 orig = *(u16 *)(out_buf + i); @@ -3615,7 +3649,7 @@ skip_bitflip: orig_hit_cnt = new_hit_cnt; - for (i = 0; (s32)i < len - 3; ++i) { + for (i = 0; i < len - 3; ++i) { u32 orig = *(u32 *)(out_buf + i); @@ -3805,7 +3839,7 @@ skip_arith: orig_hit_cnt = new_hit_cnt; - for (i = 0; (s32)i < len - 1; ++i) { + for (i = 0; i < len - 1; ++i) { u16 orig = *(u16 *)(out_buf + i); @@ -3891,7 +3925,7 @@ skip_arith: orig_hit_cnt = new_hit_cnt; - for (i = 0; (s32)i < len - 3; ++i) { + for (i = 0; i < len - 3; ++i) { u32 orig = *(u32 *)(out_buf + i); @@ -4120,7 +4154,7 @@ skip_user_extras: /* See the comment in the earlier code; extras are sorted by size. */ - if ((s32)(afl->a_extras[j].len) > (s32)(len - i) || + if ((afl->a_extras[j].len) > (len - i) || !memcmp(afl->a_extras[j].data, out_buf + i, afl->a_extras[j].len) || !memchr(eff_map + EFF_APOS(i), 1, EFF_SPAN_ALEN(i, afl->a_extras[j].len))) { @@ -4837,7 +4871,7 @@ pacemaker_fuzzing: u32 copy_from, copy_to, copy_len; copy_len = choose_block_len(afl, new_len - 1); - if ((s32)copy_len > temp_len) copy_len = temp_len; + if (copy_len > temp_len) copy_len = temp_len; copy_from = rand_below(afl, new_len - copy_len + 1); copy_to = rand_below(afl, temp_len - copy_len + 1); @@ -5033,8 +5067,7 @@ pacemaker_fuzzing: the last differing byte. Bail out if the difference is just a single byte or so. */ - locate_diffs(in_buf, new_buf, MIN(len, (s32)target->len), &f_diff, - &l_diff); + locate_diffs(in_buf, new_buf, MIN(len, target->len), &f_diff, &l_diff); if (f_diff < 0 || l_diff < 2 || f_diff == l_diff) { diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c index 66938635..aec57a6e 100644 --- a/src/afl-fuzz-queue.c +++ b/src/afl-fuzz-queue.c @@ -433,6 +433,7 @@ void add_to_queue(afl_state_t *afl, u8 *fname, u32 len, u8 passed_det) { q->passed_det = passed_det; q->trace_mini = NULL; q->testcase_buf = NULL; + q->mother = afl->queue_cur; #ifdef INTROSPECTION q->bitsmap_size = afl->bitsmap_size; diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 28585afe..955a9232 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -28,6 +28,8 @@ #include "afl-fuzz.h" #include "cmplog.h" +//#define _DEBUG + ///// Colorization struct range { @@ -35,6 +37,8 @@ struct range { u32 start; u32 end; struct range *next; + struct range *prev; + u8 ok; }; @@ -44,6 +48,8 @@ static struct range *add_range(struct range *ranges, u32 start, u32 end) { r->start = start; r->end = end; r->next = ranges; + r->ok = 0; + if (likely(ranges)) ranges->prev = r; return r; } @@ -51,45 +57,61 @@ static struct range *add_range(struct range *ranges, u32 start, u32 end) { static struct range *pop_biggest_range(struct range **ranges) { struct range *r = *ranges; - struct range *prev = NULL; struct range *rmax = NULL; - struct range *prev_rmax = NULL; u32 max_size = 0; while (r) { - u32 s = r->end - r->start; - if (s >= max_size) { + if (!r->ok) { + + u32 s = 1 + r->end - r->start; + + if (s >= max_size) { + + max_size = s; + rmax = r; - max_size = s; - prev_rmax = prev; - rmax = r; + } } - prev = r; r = r->next; } - if (rmax) { + return rmax; - if (prev_rmax) { +} - prev_rmax->next = rmax->next; +#ifdef _DEBUG +// static int logging = 0; +static void dump(char *txt, u8 *buf, u32 len) { - } else { + u32 i; + fprintf(stderr, "DUMP %s %llx ", txt, hash64(buf, len, 0)); + for (i = 0; i < len; i++) + fprintf(stderr, "%02x", buf[i]); + fprintf(stderr, "\n"); - *ranges = rmax->next; +} - } +static void dump_file(char *path, char *name, u32 counter, u8 *buf, u32 len) { - } + char fn[4096]; + if (!path) path = "."; + snprintf(fn, sizeof(fn), "%s/%s%d", path, name, counter); + int fd = open(fn, O_RDWR | O_CREAT | O_TRUNC, 0644); + if (fd >= 0) { - return rmax; + write(fd, buf, len); + close(fd); + + } } +#endif + static u8 get_exec_checksum(afl_state_t *afl, u8 *buf, u32 len, u64 *cksum) { if (unlikely(common_fuzz_stuff(afl, buf, len))) { return 1; } @@ -99,107 +121,270 @@ static u8 get_exec_checksum(afl_state_t *afl, u8 *buf, u32 len, u64 *cksum) { } -static void xor_replace(u8 *buf, u32 len) { +/* replace everything with different values but stay in the same type */ +static void type_replace(afl_state_t *afl, u8 *buf, u32 len) { u32 i; + u8 c; for (i = 0; i < len; ++i) { - buf[i] ^= 0xff; + // wont help for UTF or non-latin charsets + do { + + switch (buf[i]) { + + case 'A' ... 'F': + c = 'A' + rand_below(afl, 1 + 'F' - 'A'); + break; + case 'a' ... 'f': + c = 'a' + rand_below(afl, 1 + 'f' - 'a'); + break; + case '0': + c = '1'; + break; + case '1': + c = '0'; + break; + case '2' ... '9': + c = '2' + rand_below(afl, 1 + '9' - '2'); + break; + case 'G' ... 'Z': + c = 'G' + rand_below(afl, 1 + 'Z' - 'G'); + break; + case 'g' ... 'z': + c = 'g' + rand_below(afl, 1 + 'z' - 'g'); + break; + case '!' ... '*': + c = '!' + rand_below(afl, 1 + '*' - '!'); + break; + case ',' ... '.': + c = ',' + rand_below(afl, 1 + '.' - ','); + break; + case ':' ... '@': + c = ':' + rand_below(afl, 1 + '@' - ':'); + break; + case '[' ... '`': + c = '[' + rand_below(afl, 1 + '`' - '['); + break; + case '{' ... '~': + c = '{' + rand_below(afl, 1 + '~' - '{'); + break; + case '+': + c = '/'; + break; + case '/': + c = '+'; + break; + case ' ': + c = '\t'; + break; + case '\t': + c = ' '; + break; + /* + case '\r': + case '\n': + // nothing ... + break; + */ + default: + c = (buf[i] ^ 0xff); + + } + + } while (c == buf[i]); + + buf[i] = c; } } -static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum) { +static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum, + struct tainted **taints) { - struct range *ranges = add_range(NULL, 0, len); - u8 * backup = ck_alloc_nozero(len); + struct range * ranges = add_range(NULL, 0, len - 1), *rng; + struct tainted *taint = NULL; + u8 * backup = ck_alloc_nozero(len); + u8 * changed = ck_alloc_nozero(len); u64 orig_hit_cnt, new_hit_cnt; orig_hit_cnt = afl->queued_paths + afl->unique_crashes; afl->stage_name = "colorization"; afl->stage_short = "colorization"; - afl->stage_max = 1000; + afl->stage_max = (len << 1); - struct range *rng = NULL; afl->stage_cur = 0; + memcpy(backup, buf, len); + memcpy(changed, buf, len); + type_replace(afl, changed, len); + while ((rng = pop_biggest_range(&ranges)) != NULL && afl->stage_cur < afl->stage_max) { - u32 s = rng->end - rng->start; + u32 s = 1 + rng->end - rng->start; + + memcpy(buf + rng->start, changed + rng->start, s); - if (s != 0) { + u64 cksum; + u64 start_us = get_cur_time_us(); + if (unlikely(get_exec_checksum(afl, buf, len, &cksum))) { - /* Range not empty */ + goto checksum_fail; - memcpy(backup, buf + rng->start, s); - xor_replace(buf + rng->start, s); + } + + u64 stop_us = get_cur_time_us(); + + /* Discard if the mutations change the path or if it is too decremental + in speed - how could the same path have a much different speed + though ...*/ + if (cksum != exec_cksum || + (unlikely(stop_us - start_us > 3 * afl->queue_cur->exec_us) && + likely(!afl->fixed_seed))) { + + memcpy(buf + rng->start, backup + rng->start, s); - u64 cksum; - u64 start_us = get_cur_time_us(); - if (unlikely(get_exec_checksum(afl, buf, len, &cksum))) { + if (s > 1) { // to not add 0 size ranges - goto checksum_fail; + ranges = add_range(ranges, rng->start, rng->start - 1 + s / 2); + ranges = add_range(ranges, rng->start + s / 2, rng->end); } - u64 stop_us = get_cur_time_us(); + if (ranges == rng) { + + ranges = rng->next; + if (ranges) { ranges->prev = NULL; } + + } else if (rng->next) { + + rng->prev->next = rng->next; + rng->next->prev = rng->prev; - /* Discard if the mutations change the paths or if it is too decremental - in speed */ - if (cksum != exec_cksum || - ((stop_us - start_us > 2 * afl->queue_cur->exec_us) && - likely(!afl->fixed_seed))) { + } else { - ranges = add_range(ranges, rng->start, rng->start + s / 2); - ranges = add_range(ranges, rng->start + s / 2 + 1, rng->end); - memcpy(buf + rng->start, backup, s); + if (rng->prev) { rng->prev->next = NULL; } } + free(rng); + + } else { + + rng->ok = 1; + } - ck_free(rng); - rng = NULL; ++afl->stage_cur; } - if (afl->stage_cur < afl->stage_max) { afl->queue_cur->fully_colorized = 1; } + rng = ranges; + while (rng) { - new_hit_cnt = afl->queued_paths + afl->unique_crashes; - afl->stage_finds[STAGE_COLORIZATION] += new_hit_cnt - orig_hit_cnt; - afl->stage_cycles[STAGE_COLORIZATION] += afl->stage_cur; - ck_free(backup); + rng = rng->next; - ck_free(rng); - rng = NULL; + } - while (ranges) { + u32 i = 1; + u32 positions = 0; + while (i) { + restart: + i = 0; + struct range *r = NULL; + u32 pos = (u32)-1; rng = ranges; - ranges = rng->next; - ck_free(rng); - rng = NULL; - } + while (rng) { - return 0; + if (rng->ok == 1 && rng->start < pos) { -checksum_fail: - if (rng) { ck_free(rng); } - ck_free(backup); + if (taint && taint->pos + taint->len == rng->start) { + + taint->len += (1 + rng->end - rng->start); + positions += (1 + rng->end - rng->start); + rng->ok = 2; + goto restart; + + } else { + + r = rng; + pos = rng->start; + + } + + } + + rng = rng->next; + + } + + if (r) { + + struct tainted *t = ck_alloc_nozero(sizeof(struct tainted)); + t->pos = r->start; + t->len = 1 + r->end - r->start; + positions += (1 + r->end - r->start); + if (likely(taint)) { taint->prev = t; } + t->next = taint; + t->prev = NULL; + taint = t; + r->ok = 2; + i = 1; + } + + } + + *taints = taint; + + /* temporary: clean ranges */ while (ranges) { rng = ranges; ranges = rng->next; ck_free(rng); - rng = NULL; } + new_hit_cnt = afl->queued_paths + afl->unique_crashes; + +#ifdef _DEBUG + /* + char fn[4096]; + snprintf(fn, sizeof(fn), "%s/introspection_color.txt", afl->out_dir); + FILE *f = fopen(fn, "a"); + if (f) { + + */ + FILE *f = stderr; + fprintf(f, + "Colorization: fname=%s len=%u result=%u execs=%u found=%llu " + "taint=%u\n", + afl->queue_cur->fname, len, afl->queue_cur->colorized, afl->stage_cur, + new_hit_cnt - orig_hit_cnt, positions); +/* + fclose(f); + + } + +*/ +#endif + + afl->stage_finds[STAGE_COLORIZATION] += new_hit_cnt - orig_hit_cnt; + afl->stage_cycles[STAGE_COLORIZATION] += afl->stage_cur; + ck_free(backup); + ck_free(changed); + + return 0; + +checksum_fail: + ck_free(backup); + ck_free(changed); + return 1; } @@ -212,12 +397,19 @@ static u8 its_fuzz(afl_state_t *afl, u8 *buf, u32 len, u8 *status) { orig_hit_cnt = afl->queued_paths + afl->unique_crashes; +#ifdef _DEBUG + dump("DATA", buf, len); +#endif + if (unlikely(common_fuzz_stuff(afl, buf, len))) { return 1; } new_hit_cnt = afl->queued_paths + afl->unique_crashes; if (unlikely(new_hit_cnt != orig_hit_cnt)) { +#ifdef _DEBUG + fprintf(stderr, "NEW FIND\n"); +#endif *status = 1; } else { @@ -278,11 +470,33 @@ static int strntoull(const char *str, size_t sz, char **end, int base, } static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, - u64 pattern, u64 repl, u64 o_pattern, u32 idx, - u8 *orig_buf, u8 *buf, u32 len, u8 do_reverse, - u8 *status) { - - if (!buf) { FATAL("BUG: buf was NULL. Please report this.\n"); } + u64 pattern, u64 repl, u64 o_pattern, + u64 changed_val, u8 attr, u32 idx, u32 taint_len, + u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, + u8 do_reverse, u8 lvl, u8 *status) { + + // (void)(changed_val); // TODO + // we can use the information in changed_val to see if there is a + // computable i2s transformation. + // if (pattern != o_pattern && repl != changed_val) { + + // u64 in_diff = pattern - o_pattern, out_diff = repl - changed_val; + // if (in_diff != out_diff) { + + // switch(in_diff) { + + // detect uppercase <-> lowercase, base64, hex encoding, etc.: + // repl = reverse_transform(TYPE, pattern); + // } + // } + // } + // not 100% but would have a chance to be detected + + // fprintf(stderr, + // "Encode: %llx->%llx into %llx(<-%llx) at pos=%u " + // "taint_len=%u shape=%u attr=%u\n", + // o_pattern, pattern, repl, changed_val, idx, taint_len, + // h->shape + 1, attr); u64 *buf_64 = (u64 *)&buf[idx]; u32 *buf_32 = (u32 *)&buf[idx]; @@ -293,76 +507,215 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u16 *o_buf_16 = (u16 *)&orig_buf[idx]; u8 * o_buf_8 = &orig_buf[idx]; - u32 its_len = len - idx; - // *status = 0; + u32 its_len = MIN(len - idx, taint_len); u8 * endptr; u8 use_num = 0, use_unum = 0; unsigned long long unum; long long num; - if (afl->queue_cur->is_ascii) { + // reverse atoi()/strnu?toll() is expensive, so we only to it in lvl == 3 + if (lvl & 4) { - endptr = buf_8; - if (strntoll(buf_8, len - idx, (char **)&endptr, 0, &num)) { + if (afl->queue_cur->is_ascii) { - if (!strntoull(buf_8, len - idx, (char **)&endptr, 0, &unum)) - use_unum = 1; + endptr = buf_8; + if (strntoll(buf_8, len - idx, (char **)&endptr, 0, &num)) { - } else + if (!strntoull(buf_8, len - idx, (char **)&endptr, 0, &unum)) + use_unum = 1; - use_num = 1; + } else - } + use_num = 1; - if (use_num && (u64)num == pattern) { + } - size_t old_len = endptr - buf_8; - size_t num_len = snprintf(NULL, 0, "%lld", num); +#ifdef _DEBUG + if (idx == 0) + fprintf(stderr, "ASCII is=%u use_num=%u use_unum=%u idx=%u %llx==%llx\n", + afl->queue_cur->is_ascii, use_num, use_unum, idx, num, pattern); +#endif - u8 *new_buf = afl_realloc((void **)&afl->out_scratch_buf, len + num_len); - if (unlikely(!new_buf)) { PFATAL("alloc"); } - memcpy(new_buf, buf, idx); + // num is likely not pattern as atoi("AAA") will be zero... + if (use_num && ((u64)num == pattern || !num)) { - snprintf(new_buf + idx, num_len, "%lld", num); - memcpy(new_buf + idx + num_len, buf_8 + old_len, len - idx - old_len); + u8 tmp_buf[32]; + size_t num_len = snprintf(tmp_buf, sizeof(tmp_buf), "%lld", repl); + size_t old_len = endptr - buf_8; - if (unlikely(its_fuzz(afl, new_buf, len, status))) { return 1; } + u8 *new_buf = afl_realloc((void **)&afl->out_scratch_buf, len + num_len); + if (unlikely(!new_buf)) { PFATAL("alloc"); } - } else if (use_unum && unum == pattern) { + memcpy(new_buf, buf, idx); + memcpy(new_buf + idx, tmp_buf, num_len); + memcpy(new_buf + idx + num_len, buf_8 + old_len, len - idx - old_len); - size_t old_len = endptr - buf_8; - size_t num_len = snprintf(NULL, 0, "%llu", unum); + if (new_buf[idx + num_len] >= '0' && new_buf[idx + num_len] <= '9') { + + new_buf[idx + num_len] = ' '; + + } - u8 *new_buf = afl_realloc((void **)&afl->out_scratch_buf, len + num_len); - if (unlikely(!new_buf)) { PFATAL("alloc"); } - memcpy(new_buf, buf, idx); + if (unlikely(its_fuzz(afl, new_buf, len, status))) { return 1; } - snprintf(new_buf + idx, num_len, "%llu", unum); - memcpy(new_buf + idx + num_len, buf_8 + old_len, len - idx - old_len); + } else if (use_unum && (unum == pattern || !unum)) { - if (unlikely(its_fuzz(afl, new_buf, len, status))) { return 1; } + u8 tmp_buf[32]; + size_t num_len = snprintf(tmp_buf, sizeof(tmp_buf), "%llu", repl); + size_t old_len = endptr - buf_8; + + u8 *new_buf = afl_realloc((void **)&afl->out_scratch_buf, len + num_len); + if (unlikely(!new_buf)) { PFATAL("alloc"); } + + memcpy(new_buf, buf, idx); + memcpy(new_buf + idx, tmp_buf, num_len); + memcpy(new_buf + idx + num_len, buf_8 + old_len, len - idx - old_len); + + if (new_buf[idx + num_len] >= '0' && new_buf[idx + num_len] <= '9') { + + new_buf[idx + num_len] = ' '; + + } + + if (unlikely(its_fuzz(afl, new_buf, len, status))) { return 1; } + + } } - if (SHAPE_BYTES(h->shape) >= 8 && *status != 1) { + // we only allow this for ascii2integer (above) + if (unlikely(pattern == o_pattern)) { return 0; } - if (its_len >= 8 && *buf_64 == pattern && *o_buf_64 == o_pattern) { + if ((lvl & 1) || ((lvl & 2) && (attr >= 8 && attr <= 15)) || attr >= 16) { - *buf_64 = repl; - if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - *buf_64 = pattern; + if (SHAPE_BYTES(h->shape) >= 8 && *status != 1) { + + // if (its_len >= 8 && (attr == 0 || attr >= 8)) + // fprintf(stderr, + // "TestU64: %u>=4 %x==%llx" + // " %x==%llx (idx=%u attr=%u) <= %llx<-%llx\n", + // its_len, *buf_32, pattern, *o_buf_32, o_pattern, idx, attr, + // repl, changed_val); + + // if this is an fcmp (attr & 8 == 8) then do not compare the patterns - + // due to a bug in llvm dynamic float bitcasts do not work :( + // the value 16 means this is a +- 1.0 test case + if (its_len >= 8 && + ((*buf_64 == pattern && *o_buf_64 == o_pattern) || attr >= 16)) { + + u64 tmp_64 = *buf_64; + *buf_64 = repl; + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + if (*status == 1) { memcpy(cbuf + idx, buf_64, 8); } + *buf_64 = tmp_64; + + // fprintf(stderr, "Status=%u\n", *status); + + } + + // reverse encoding + if (do_reverse && *status != 1) { + + if (unlikely(cmp_extend_encoding(afl, h, SWAP64(pattern), SWAP64(repl), + SWAP64(o_pattern), SWAP64(changed_val), + attr, idx, taint_len, orig_buf, buf, + cbuf, len, 0, lvl, status))) { + + return 1; + + } + + } } - // reverse encoding - if (do_reverse && *status != 1) { + if (SHAPE_BYTES(h->shape) >= 4 && *status != 1) { - if (unlikely(cmp_extend_encoding(afl, h, SWAP64(pattern), SWAP64(repl), - SWAP64(o_pattern), idx, orig_buf, buf, - len, 0, status))) { + // if (its_len >= 4 && (attr <= 1 || attr >= 8)) + // fprintf(stderr, + // "TestU32: %u>=4 %x==%llx" + // " %x==%llx (idx=%u attr=%u) <= %llx<-%llx\n", + // its_len, *buf_32, pattern, *o_buf_32, o_pattern, idx, attr, + // repl, changed_val); - return 1; + if (its_len >= 4 && + ((*buf_32 == (u32)pattern && *o_buf_32 == (u32)o_pattern) || + attr >= 16)) { + + u32 tmp_32 = *buf_32; + *buf_32 = (u32)repl; + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + if (*status == 1) { memcpy(cbuf + idx, buf_32, 4); } + *buf_32 = tmp_32; + + // fprintf(stderr, "Status=%u\n", *status); + + } + + // reverse encoding + if (do_reverse && *status != 1) { + + if (unlikely(cmp_extend_encoding(afl, h, SWAP32(pattern), SWAP32(repl), + SWAP32(o_pattern), SWAP32(changed_val), + attr, idx, taint_len, orig_buf, buf, + cbuf, len, 0, lvl, status))) { + + return 1; + + } + + } + + } + + if (SHAPE_BYTES(h->shape) >= 2 && *status != 1) { + + if (its_len >= 2 && + ((*buf_16 == (u16)pattern && *o_buf_16 == (u16)o_pattern) || + attr >= 16)) { + + u16 tmp_16 = *buf_16; + *buf_16 = (u16)repl; + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + if (*status == 1) { memcpy(cbuf + idx, buf_16, 2); } + *buf_16 = tmp_16; + + } + + // reverse encoding + if (do_reverse && *status != 1) { + + if (unlikely(cmp_extend_encoding(afl, h, SWAP16(pattern), SWAP16(repl), + SWAP16(o_pattern), SWAP16(changed_val), + attr, idx, taint_len, orig_buf, buf, + cbuf, len, 0, lvl, status))) { + + return 1; + + } + + } + + } + + if (*status != 1) { // u8 + + // if (its_len >= 1 && (attr <= 1 || attr >= 8)) + // fprintf(stderr, + // "TestU8: %u>=1 %x==%x %x==%x (idx=%u attr=%u) <= %x<-%x\n", + // its_len, *buf_8, pattern, *o_buf_8, o_pattern, idx, attr, + // repl, changed_val); + + if (its_len >= 1 && + ((*buf_8 == (u8)pattern && *o_buf_8 == (u8)o_pattern) || + attr >= 16)) { + + u8 tmp_8 = *buf_8; + *buf_8 = (u8)repl; + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + if (*status == 1) { cbuf[idx] = *buf_8; } + *buf_8 = tmp_8; } @@ -370,49 +723,205 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - if (SHAPE_BYTES(h->shape) >= 4 && *status != 1) { + // here we add and subract 1 from the value, but only if it is not an + // == or != comparison + // Bits: 1 = Equal, 2 = Greater, 3 = Lesser, 4 = Float - if (its_len >= 4 && *buf_32 == (u32)pattern && - *o_buf_32 == (u32)o_pattern) { + if (lvl < 4) { return 0; } - *buf_32 = (u32)repl; - if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - *buf_32 = pattern; + if (attr >= 8 && attr < 16) { // lesser/greater integer comparison + + u64 repl_new; + if (SHAPE_BYTES(h->shape) == 4 && its_len >= 4) { + + float *f = (float *)&repl; + float g = *f; + g += 1.0; + u32 *r = (u32 *)&g; + repl_new = (u32)*r; + + } else if (SHAPE_BYTES(h->shape) == 8 && its_len >= 8) { + + double *f = (double *)&repl; + double g = *f; + g += 1.0; + + u64 *r = (u64 *)&g; + repl_new = *r; + + } else { + + return 0; } - // reverse encoding - if (do_reverse && *status != 1) { + changed_val = repl_new; + + if (unlikely(cmp_extend_encoding(afl, h, pattern, repl_new, o_pattern, + changed_val, 16, idx, taint_len, orig_buf, + buf, cbuf, len, 1, lvl, status))) { + + return 1; + + } + + if (SHAPE_BYTES(h->shape) == 4) { + + float *f = (float *)&repl; + float g = *f; + g -= 1.0; + u32 *r = (u32 *)&g; + repl_new = (u32)*r; + + } else if (SHAPE_BYTES(h->shape) == 8) { + + double *f = (double *)&repl; + double g = *f; + g -= 1.0; + u64 *r = (u64 *)&g; + repl_new = *r; + + } else { + + return 0; + + } + + changed_val = repl_new; + + if (unlikely(cmp_extend_encoding(afl, h, pattern, repl_new, o_pattern, + changed_val, 16, idx, taint_len, orig_buf, + buf, cbuf, len, 1, lvl, status))) { + + return 1; + + } + + // transform double to float, llvm likes to do that internally ... + if (SHAPE_BYTES(h->shape) == 8 && its_len >= 4) { + + double *f = (double *)&repl; + float g = (float)*f; + repl_new = 0; +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + memcpy((char *)&repl_new, (char *)&g, 4); +#else + memcpy(((char *)&repl_new) + 4, (char *)&g, 4); +#endif + changed_val = repl_new; + h->shape = 3; // modify shape - if (unlikely(cmp_extend_encoding(afl, h, SWAP32(pattern), SWAP32(repl), - SWAP32(o_pattern), idx, orig_buf, buf, - len, 0, status))) { + // fprintf(stderr, "DOUBLE2FLOAT %llx\n", repl_new); + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + + h->shape = 7; return 1; } + h->shape = 7; // recover shape + + } + + } else if (attr > 1 && attr < 8) { // lesser/greater integer comparison + + u64 repl_new; + + repl_new = repl + 1; + changed_val = repl_new; + if (unlikely(cmp_extend_encoding(afl, h, pattern, repl_new, o_pattern, + changed_val, 32, idx, taint_len, orig_buf, + buf, cbuf, len, 1, lvl, status))) { + + return 1; + + } + + repl_new = repl - 1; + changed_val = repl_new; + if (unlikely(cmp_extend_encoding(afl, h, pattern, repl_new, o_pattern, + changed_val, 32, idx, taint_len, orig_buf, + buf, cbuf, len, 1, lvl, status))) { + + return 1; + } } - if (SHAPE_BYTES(h->shape) >= 2 && *status != 1) { + return 0; - if (its_len >= 2 && *buf_16 == (u16)pattern && - *o_buf_16 == (u16)o_pattern) { +} - *buf_16 = (u16)repl; +static u8 cmp_extend_encoding128(afl_state_t *afl, struct cmp_header *h, + u128 pattern, u128 repl, u128 o_pattern, + u128 changed_val, u8 attr, u32 idx, + u32 taint_len, u8 *orig_buf, u8 *buf, u8 *cbuf, + u32 len, u8 do_reverse, u8 lvl, u8 *status) { + + u128 *buf_128 = (u128 *)&buf[idx]; + u64 * buf0 = (u64 *)&buf[idx]; + u64 * buf1 = (u64 *)(buf + idx + 8); + u128 *o_buf_128 = (u128 *)&orig_buf[idx]; + u32 its_len = MIN(len - idx, taint_len); + u64 v10 = (u64)repl; + u64 v11 = (u64)(repl >> 64); + + // if this is an fcmp (attr & 8 == 8) then do not compare the patterns - + // due to a bug in llvm dynamic float bitcasts do not work :( + // the value 16 means this is a +- 1.0 test case + if (its_len >= 16) { + +#ifdef _DEBUG + fprintf(stderr, "TestU128: %u>=16 (idx=%u attr=%u) (%u)\n", its_len, idx, + attr, do_reverse); + u64 v00 = (u64)pattern; + u64 v01 = pattern >> 64; + u64 ov00 = (u64)o_pattern; + u64 ov01 = o_pattern >> 64; + u64 ov10 = (u64)changed_val; + u64 ov11 = changed_val >> 64; + u64 b00 = (u64)*buf_128; + u64 b01 = *buf_128 >> 64; + u64 ob00 = (u64)*o_buf_128; + u64 ob01 = *o_buf_128 >> 64; + fprintf(stderr, + "TestU128: %llx:%llx==%llx:%llx" + " %llx:%llx==%llx:%llx <= %llx:%llx<-%llx:%llx\n", + b01, b00, v01, v00, ob01, ob00, ov01, ov00, v11, v10, ov11, ov10); +#endif + + if (*buf_128 == pattern && *o_buf_128 == o_pattern) { + + u128 tmp_128 = *buf_128; + // *buf_128 = repl; <- this crashes +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + *buf0 = v10; + *buf1 = v11; +#else + *buf1 = v10; + *buf0 = v11; +#endif if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - *buf_16 = (u16)pattern; + if (*status == 1) { memcpy(cbuf + idx, buf_128, 16); } + *buf_128 = tmp_128; + +#ifdef _DEBUG + fprintf(stderr, "Status=%u\n", *status); +#endif } // reverse encoding if (do_reverse && *status != 1) { - if (unlikely(cmp_extend_encoding(afl, h, SWAP16(pattern), SWAP16(repl), - SWAP16(o_pattern), idx, orig_buf, buf, - len, 0, status))) { + if (unlikely(cmp_extend_encoding128( + afl, h, SWAPN(pattern, 128), SWAPN(repl, 128), + SWAPN(o_pattern, 128), SWAPN(changed_val, 128), attr, idx, + taint_len, orig_buf, buf, cbuf, len, 0, lvl, status))) { return 1; @@ -422,14 +931,82 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - /* avoid CodeQL warning on unsigned overflow */ - if (/* SHAPE_BYTES(h->shape) >= 1 && */ *status != 1) { + return 0; - if (its_len >= 1 && *buf_8 == (u8)pattern && *o_buf_8 == (u8)o_pattern) { +} - *buf_8 = (u8)repl; +// uh a pointer read from (long double*) reads 12 bytes, not 10 ... +// so lets make this complicated. +static u8 cmp_extend_encoding_ld(afl_state_t *afl, struct cmp_header *h, + u8 *pattern, u8 *repl, u8 *o_pattern, + u8 *changed_val, u8 attr, u32 idx, + u32 taint_len, u8 *orig_buf, u8 *buf, u8 *cbuf, + u32 len, u8 do_reverse, u8 lvl, u8 *status) { + + u8 *buf_ld = &buf[idx], *o_buf_ld = &orig_buf[idx], backup[10]; + u32 its_len = MIN(len - idx, taint_len); + + if (its_len >= 10) { + +#ifdef _DEBUG + fprintf(stderr, "TestUld: %u>=10 (len=%u idx=%u attr=%u) (%u)\n", its_len, + len, idx, attr, do_reverse); + fprintf(stderr, "TestUld: "); + u32 i; + for (i = 0; i < 10; i++) + fprintf(stderr, "%02x", pattern[i]); + fprintf(stderr, "=="); + for (i = 0; i < 10; i++) + fprintf(stderr, "%02x", buf_ld[i]); + fprintf(stderr, " "); + for (i = 0; i < 10; i++) + fprintf(stderr, "%02x", o_pattern[i]); + fprintf(stderr, "=="); + for (i = 0; i < 10; i++) + fprintf(stderr, "%02x", o_buf_ld[i]); + fprintf(stderr, " <= "); + for (i = 0; i < 10; i++) + fprintf(stderr, "%02x", repl[i]); + fprintf(stderr, "=="); + for (i = 0; i < 10; i++) + fprintf(stderr, "%02x", changed_val[i]); + fprintf(stderr, "\n"); +#endif + + if (!memcmp(pattern, buf_ld, 10) && !memcmp(o_pattern, o_buf_ld, 10)) { + + // if this is an fcmp (attr & 8 == 8) then do not compare the patterns - + // due to a bug in llvm dynamic float bitcasts do not work :( + // the value 16 means this is a +- 1.0 test case + + memcpy(backup, buf_ld, 10); + memcpy(buf_ld, repl, 10); if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - *buf_8 = (u8)pattern; + if (*status == 1) { memcpy(cbuf + idx, repl, 10); } + memcpy(buf_ld, backup, 10); + +#ifdef _DEBUG + fprintf(stderr, "Status=%u\n", *status); +#endif + + } + + } + + // reverse encoding + if (do_reverse && *status != 1) { + + u8 sp[10], sr[10], osp[10], osr[10]; + SWAPNN(sp, pattern, 10); + SWAPNN(sr, repl, 10); + SWAPNN(osp, o_pattern, 10); + SWAPNN(osr, changed_val, 10); + + if (unlikely(cmp_extend_encoding_ld(afl, h, sp, sr, osp, osr, attr, idx, + taint_len, orig_buf, buf, cbuf, len, 0, + lvl, status))) { + + return 1; } @@ -445,10 +1022,6 @@ static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) { u32 k; u8 cons_ff = 0, cons_0 = 0; - - if (shape > sizeof(v)) - FATAL("shape is greater than %zu, please report!", sizeof(v)); - for (k = 0; k < shape; ++k) { if (b[k] == 0) { @@ -457,7 +1030,7 @@ static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) { } else if (b[k] == 0xff) { - ++cons_ff; + ++cons_0; } else { @@ -493,28 +1066,126 @@ static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) { } -static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u32 len) { +static void try_to_add_to_dict128(afl_state_t *afl, u128 v) { - struct cmp_header *h = &afl->shm.cmp_map->headers[key]; - u32 i, j, idx; + u8 *b = (u8 *)&v; - u32 loggeds = h->hits; + u32 k; + u8 cons_ff = 0, cons_0 = 0; + for (k = 0; k < 16; ++k) { + + if (b[k] == 0) { + + ++cons_0; + + } else if (b[k] == 0xff) { + + ++cons_0; + + } else { + + cons_0 = cons_ff = 0; + + } + + // too many uninteresting values? try adding 2 64-bit values + if (cons_0 > 6 || cons_ff > 6) { + + u64 v64 = (u64)v; + try_to_add_to_dict(afl, v64, 8); + v64 = (u64)(v >> 64); + try_to_add_to_dict(afl, v64, 8); + + return; + + } + + } + + maybe_add_auto(afl, (u8 *)&v, 16); + u128 rev = SWAPN(v, 128); + maybe_add_auto(afl, (u8 *)&rev, 16); + +} + +static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) { + + u8 *b = (u8 *)&v; + + u32 k; + u8 cons_ff = 0, cons_0 = 0; +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + for (k = 0; k < size; ++k) { + +#else + for (k = 16 - size; k < 16; ++k) { + +#endif + if (b[k] == 0) { + + ++cons_0; + + } else if (b[k] == 0xff) { + + ++cons_0; + + } else { + + cons_0 = cons_ff = 0; + + } + + } + + maybe_add_auto(afl, (u8 *)&v, size); + u128 rev = SWAPN(v, size); + maybe_add_auto(afl, (u8 *)&rev, size); + +} + +static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, + u32 len, u32 lvl, struct tainted *taint) { + + struct cmp_header *h = &afl->shm.cmp_map->headers[key]; + struct tainted * t; + u32 i, j, idx, taint_len; + u32 have_taint = 1, is_128 = 0, is_n = 0, is_ld = 0; + u32 loggeds = h->hits; if (h->hits > CMP_MAP_H) { loggeds = CMP_MAP_H; } u8 status = 0; - // opt not in the paper - u32 fails; - u8 found_one = 0; + u8 found_one = 0; /* loop cmps are useless, detect and ignore them */ - u64 s_v0, s_v1; - u8 s_v0_fixed = 1, s_v1_fixed = 1; - u8 s_v0_inc = 1, s_v1_inc = 1; - u8 s_v0_dec = 1, s_v1_dec = 1; + u128 s128_v0 = 0, s128_v1 = 0, orig_s128_v0 = 0, orig_s128_v1 = 0; + long double ld0, ld1, o_ld0, o_ld1; + u64 s_v0, s_v1; + u8 s_v0_fixed = 1, s_v1_fixed = 1; + u8 s_v0_inc = 1, s_v1_inc = 1; + u8 s_v0_dec = 1, s_v1_dec = 1; - for (i = 0; i < loggeds; ++i) { + switch (SHAPE_BYTES(h->shape)) { + + case 1: + case 2: + case 4: + case 8: + break; + case 16: + is_128 = 1; + break; + case 10: + if (h->attribute & 8) { is_ld = 1; } + // fall through + default: + is_n = 1; - fails = 0; + } + + // FCmp not in if level 1 only + if ((h->attribute & 8) && lvl < 2) return 0; + + for (i = 0; i < loggeds; ++i) { struct cmp_operands *o = &afl->shm.cmp_map->log[key][i]; @@ -551,55 +1222,242 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u32 len) { } - for (idx = 0; idx < len && fails < 8; ++idx) { +#ifdef _DEBUG + fprintf(stderr, "Handling: %llx->%llx vs %llx->%llx attr=%u shape=%u\n", + orig_o->v0, o->v0, orig_o->v1, o->v1, h->attribute, + SHAPE_BYTES(h->shape)); +#endif + + if (taint) { + + t = taint; + + while (t->next) { + + t = t->next; + + } + + } else { + + have_taint = 0; + t = NULL; + + } + + if (unlikely(is_128 || is_n)) { + + s128_v0 = ((u128)o->v0) + (((u128)o->v0_128) << 64); + s128_v1 = ((u128)o->v1) + (((u128)o->v1_128) << 64); + orig_s128_v0 = ((u128)orig_o->v0) + (((u128)orig_o->v0_128) << 64); + orig_s128_v1 = ((u128)orig_o->v1) + (((u128)orig_o->v1_128) << 64); + + if (is_ld) { + +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + memcpy((char *)&ld0, (char *)&s128_v0, sizeof(long double)); + memcpy((char *)&ld1, (char *)&s128_v1, sizeof(long double)); + memcpy((char *)&o_ld0, (char *)&orig_s128_v0, sizeof(long double)); + memcpy((char *)&o_ld1, (char *)&orig_s128_v1, sizeof(long double)); +#else + memcpy((char *)&ld0, (char *)(&s128_v0) + 6, sizeof(long double)); + memcpy((char *)&ld1, (char *)(&s128_v1) + 6, sizeof(long double)); + memcpy((char *)&o_ld0, (char *)(&orig_s128_v0) + 6, + sizeof(long double)); + memcpy((char *)&o_ld1, (char *)(&orig_s128_v1) + 6, + sizeof(long double)); +#endif + + } + + } + + for (idx = 0; idx < len; ++idx) { + + if (have_taint) { + + if (!t || idx < t->pos) { + + continue; + + } else { + + taint_len = t->pos + t->len - idx; + + if (idx == t->pos + t->len - 1) { t = t->prev; } + + } + + } else { + + taint_len = len - idx; + + } status = 0; - if (unlikely(cmp_extend_encoding(afl, h, o->v0, o->v1, orig_o->v0, idx, - orig_buf, buf, len, 1, &status))) { - return 1; + if (is_ld) { // long double special case + + if (ld0 != o_ld0 && o_ld1 != o_ld0) { + + if (unlikely(cmp_extend_encoding_ld( + afl, h, (u8 *)&ld0, (u8 *)&ld1, (u8 *)&o_ld0, (u8 *)&o_ld1, + h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, + lvl, &status))) { + + return 1; + + } + + } + + if (status == 1) { + + found_one = 1; + break; + + } + + if (ld1 != o_ld1 && o_ld0 != o_ld1) { + + if (unlikely(cmp_extend_encoding_ld( + afl, h, (u8 *)&ld1, (u8 *)&ld0, (u8 *)&o_ld1, (u8 *)&o_ld0, + h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, + lvl, &status))) { + + return 1; + + } + + } + + if (status == 1) { + + found_one = 1; + break; + + } + + } + + if (is_128) { // u128 special case + + if (s128_v0 != orig_s128_v0 && orig_s128_v0 != orig_s128_v1) { + + if (unlikely(cmp_extend_encoding128( + afl, h, s128_v0, s128_v1, orig_s128_v0, orig_s128_v1, + h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, + lvl, &status))) { + + return 1; + + } + + } + + if (status == 1) { + + found_one = 1; + break; + + } + + if (s128_v1 != orig_s128_v1 && orig_s128_v1 != orig_s128_v0) { + + if (unlikely(cmp_extend_encoding128( + afl, h, s128_v1, s128_v0, orig_s128_v1, orig_s128_v0, + h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, + lvl, &status))) { + + return 1; + + } + + } + + if (status == 1) { + + found_one = 1; + break; + + } } - if (status == 2) { + // even for u128 and long double do cmp_extend_encoding() because + // if we got here their own special trials failed and it might just be + // a cast from e.g. u64 to u128 from the input data. - ++fails; + if ((o->v0 != orig_o->v0 || lvl >= 4) && orig_o->v0 != orig_o->v1) { - } else if (status == 1) { + if (unlikely(cmp_extend_encoding( + afl, h, o->v0, o->v1, orig_o->v0, orig_o->v1, h->attribute, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, &status))) { + return 1; + + } + + } + + if (status == 1) { + + found_one = 1; break; } status = 0; - if (unlikely(cmp_extend_encoding(afl, h, o->v1, o->v0, orig_o->v1, idx, - orig_buf, buf, len, 1, &status))) { + if ((o->v1 != orig_o->v1 || lvl >= 4) && orig_o->v0 != orig_o->v1) { - return 1; + if (unlikely(cmp_extend_encoding( + afl, h, o->v1, o->v0, orig_o->v1, orig_o->v0, h->attribute, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, &status))) { - } + return 1; - if (status == 2) { + } - ++fails; + } - } else if (status == 1) { + if (status == 1) { + found_one = 1; break; } } - if (status == 1) { found_one = 1; } +#ifdef _DEBUG + fprintf(stderr, + "END: %llx->%llx vs %llx->%llx attr=%u i=%u found=%u is128=%u " + "isN=%u size=%u\n", + orig_o->v0, o->v0, orig_o->v1, o->v1, h->attribute, i, found_one, + is_128, is_n, SHAPE_BYTES(h->shape)); +#endif // If failed, add to dictionary - if (fails == 8) { + if (!found_one) { if (afl->pass_stats[key].total == 0) { - try_to_add_to_dict(afl, o->v0, SHAPE_BYTES(h->shape)); - try_to_add_to_dict(afl, o->v1, SHAPE_BYTES(h->shape)); + if (unlikely(is_128)) { + + try_to_add_to_dict128(afl, s128_v0); + try_to_add_to_dict128(afl, s128_v1); + + } else if (unlikely(is_n)) { + + try_to_add_to_dictN(afl, s128_v0, SHAPE_BYTES(h->shape)); + try_to_add_to_dictN(afl, s128_v1, SHAPE_BYTES(h->shape)); + + } else { + + try_to_add_to_dict(afl, o->v0, SHAPE_BYTES(h->shape)); + try_to_add_to_dict(afl, o->v1, SHAPE_BYTES(h->shape)); + + } } @@ -630,20 +1488,19 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u32 len) { } static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, - u8 *o_pattern, u32 idx, u8 *orig_buf, u8 *buf, - u32 len, u8 *status) { + u8 *o_pattern, u32 idx, u32 taint_len, + u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, + u8 *status) { u32 i; u32 its_len = MIN((u32)32, len - idx); - + its_len = MIN(its_len, taint_len); u8 save[32]; memcpy(save, &buf[idx], its_len); - *status = 0; - for (i = 0; i < its_len; ++i) { - if (pattern[i] != buf[idx + i] || o_pattern[i] != orig_buf[idx + i] || + if ((pattern[i] != buf[idx + i] && o_pattern[i] != orig_buf[idx + i]) || *status == 1) { break; @@ -654,6 +1511,8 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } + } memcpy(&buf[idx], save, i); @@ -661,23 +1520,21 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } -static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u32 len) { +static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, + u32 len, struct tainted *taint) { + struct tainted * t; struct cmp_header *h = &afl->shm.cmp_map->headers[key]; - u32 i, j, idx; + u32 i, j, idx, have_taint = 1, taint_len; u32 loggeds = h->hits; if (h->hits > CMP_MAP_RTN_H) { loggeds = CMP_MAP_RTN_H; } u8 status = 0; - // opt not in the paper - // u32 fails = 0; u8 found_one = 0; for (i = 0; i < loggeds; ++i) { - u32 fails = 0; - struct cmpfn_operands *o = &((struct cmpfn_operands *)afl->shm.cmp_map->log[key])[i]; @@ -696,50 +1553,84 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u32 len) { } - for (idx = 0; idx < len && fails < 8; ++idx) { + if (taint) { - if (unlikely(rtn_extend_encoding(afl, o->v0, o->v1, orig_o->v0, idx, - orig_buf, buf, len, &status))) { + t = taint; + while (t->next) { - return 1; + t = t->next; } - if (status == 2) { + } else { - ++fails; + have_taint = 0; + t = NULL; - } else if (status == 1) { + } - break; + for (idx = 0; idx < len; ++idx) { + + if (have_taint) { + + if (!t || idx < t->pos) { + + continue; + + } else { + + taint_len = t->pos + t->len - idx; + + if (idx == t->pos + t->len - 1) { t = t->prev; } + + } + + } else { + + taint_len = len - idx; } - if (unlikely(rtn_extend_encoding(afl, o->v1, o->v0, orig_o->v1, idx, - orig_buf, buf, len, &status))) { + status = 0; + + if (unlikely(rtn_extend_encoding(afl, o->v0, o->v1, orig_o->v0, idx, + taint_len, orig_buf, buf, cbuf, len, + &status))) { return 1; } - if (status == 2) { + if (status == 1) { + + found_one = 1; + break; + + } + + status = 0; + + if (unlikely(rtn_extend_encoding(afl, o->v1, o->v0, orig_o->v1, idx, + taint_len, orig_buf, buf, cbuf, len, + &status))) { - ++fails; + return 1; - } else if (status == 1) { + } + if (status == 1) { + + found_one = 1; break; } } - if (status == 1) { found_one = 1; } - // If failed, add to dictionary - if (fails == 8) { + if (!found_one) { - if (afl->pass_stats[key].total == 0) { + if (unlikely(!afl->pass_stats[key].total)) { maybe_add_auto(afl, o->v0, SHAPE_BYTES(h->shape)); maybe_add_auto(afl, o->v1, SHAPE_BYTES(h->shape)); @@ -791,7 +1682,44 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, memcpy(afl->orig_cmp_map, afl->shm.cmp_map, sizeof(struct cmp_map)); - if (unlikely(colorization(afl, buf, len, exec_cksum))) { return 1; } + struct tainted *taint = NULL; + + if (!afl->queue_cur->taint || !afl->queue_cur->cmplog_colorinput) { + + if (unlikely(colorization(afl, buf, len, exec_cksum, &taint))) { return 1; } + + // no taint? still try, create a dummy to prevent again colorization + if (!taint) { + + taint = ck_alloc(sizeof(struct tainted)); + taint->len = len; + + } + + } else { + + buf = afl->queue_cur->cmplog_colorinput; + taint = afl->queue_cur->taint; + // reget the cmplog information + if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) { return 1; } + + } + +#ifdef _DEBUG + dump("ORIG", orig_buf, len); + dump("NEW ", buf, len); +#endif + + struct tainted *t = taint; + + while (t) { + +#ifdef _DEBUG + fprintf(stderr, "T: pos=%u len=%u\n", t->pos, t->len); +#endif + t = t->next; + + } // do it manually, forkserver clear only afl->fsrv.trace_bits memset(afl->shm.cmp_map->headers, 0, sizeof(afl->shm.cmp_map->headers)); @@ -807,15 +1735,38 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, afl->stage_max = 0; afl->stage_cur = 0; + u32 lvl; + u32 cmplog_done = afl->queue_cur->colorized; + u32 cmplog_lvl = afl->cmplog_lvl; + if (!cmplog_done) { + + lvl = 1; + + } else { + + lvl = 0; + + } + + if (cmplog_lvl >= 2 && cmplog_done < 2) { lvl += 2; } + if (cmplog_lvl >= 3 && cmplog_done < 3) { lvl += 4; } + + u8 *cbuf = afl_realloc((void **)&afl->in_scratch_buf, len + 128); + memcpy(cbuf, orig_buf, len); + u8 *virgin_backup = afl_realloc((void **)&afl->ex_buf, afl->shm.map_size); + memcpy(virgin_backup, afl->virgin_bits, afl->shm.map_size); + u32 k; for (k = 0; k < CMP_MAP_W; ++k) { if (!afl->shm.cmp_map->headers[k].hits) { continue; } - if (afl->pass_stats[k].total && - (rand_below(afl, afl->pass_stats[k].total) >= - afl->pass_stats[k].faileds || - afl->pass_stats[k].total == 0xff)) { + if (afl->pass_stats[k].faileds == 0xff || + afl->pass_stats[k].total == 0xff) { + +#ifdef _DEBUG + fprintf(stderr, "DISABLED %u\n", k); +#endif afl->shm.cmp_map->headers[k].hits = 0; // ignore this cmp @@ -841,11 +1792,19 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, if (afl->shm.cmp_map->headers[k].type == CMP_TYPE_INS) { - if (unlikely(cmp_fuzz(afl, k, orig_buf, buf, len))) { goto exit_its; } + if (unlikely(cmp_fuzz(afl, k, orig_buf, buf, cbuf, len, lvl, taint))) { + + goto exit_its; + + } } else { - if (unlikely(rtn_fuzz(afl, k, orig_buf, buf, len))) { goto exit_its; } + if (unlikely(rtn_fuzz(afl, k, orig_buf, buf, cbuf, len, taint))) { + + goto exit_its; + + } } @@ -854,12 +1813,86 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, r = 0; exit_its: + + afl->queue_cur->colorized = afl->cmplog_lvl; + if (afl->cmplog_lvl == CMPLOG_LVL_MAX) { + + ck_free(afl->queue_cur->cmplog_colorinput); + t = taint; + while (taint) { + + t = taint->next; + ck_free(taint); + taint = t; + + } + + afl->queue_cur->taint = NULL; + + } else { + + if (!afl->queue_cur->taint) { afl->queue_cur->taint = taint; } + + if (!afl->queue_cur->cmplog_colorinput) { + + afl->queue_cur->cmplog_colorinput = ck_alloc_nozero(len); + memcpy(afl->queue_cur->cmplog_colorinput, buf, len); + memcpy(buf, orig_buf, len); + + } + + } + + // copy the current virgin bits so we can recover the information + u8 *virgin_save = afl_realloc((void **)&afl->eff_buf, afl->shm.map_size); + memcpy(virgin_save, afl->virgin_bits, afl->shm.map_size); + // reset virgin bits to the backup previous to redqueen + memcpy(afl->virgin_bits, virgin_backup, afl->shm.map_size); + + u8 status = 0; + its_fuzz(afl, cbuf, len, &status); + + // now combine with the saved virgin bits +#ifdef WORD_SIZE_64 + u64 *v = (u64 *)afl->virgin_bits; + u64 *s = (u64 *)virgin_save; + u32 i; + for (i = 0; i < (afl->shm.map_size >> 3); i++) { + + v[i] &= s[i]; + + } + +#else + u32 *v = (u64 *)afl->virgin_bits; + u32 *s = (u64 *)virgin_save; + u32 i; + for (i = 0; i < (afl->shm.map_size >> 2); i++) { + + v[i] &= s[i]; + + } + +#endif + +#ifdef _DEBUG + dump("COMB", cbuf, len); + if (status == 1) { + + fprintf(stderr, "NEW COMBINED\n"); + + } else { + + fprintf(stderr, "NO new combined\n"); + + } + +#endif + new_hit_cnt = afl->queued_paths + afl->unique_crashes; afl->stage_finds[STAGE_ITS] += new_hit_cnt - orig_hit_cnt; afl->stage_cycles[STAGE_ITS] += afl->fsrv.total_execs - orig_execs; - memcpy(buf, orig_buf, len); - return r; } diff --git a/src/afl-fuzz-state.c b/src/afl-fuzz-state.c index 60c9684c..8423a3d1 100644 --- a/src/afl-fuzz-state.c +++ b/src/afl-fuzz-state.c @@ -102,6 +102,7 @@ void afl_state_init(afl_state_t *afl, uint32_t map_size) { afl->stats_update_freq = 1; afl->stats_avg_exec = 0; afl->skip_deterministic = 1; + afl->cmplog_lvl = 1; #ifndef NO_SPLICING afl->use_splicing = 1; #endif diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index bb2674f0..1e914ca6 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -77,13 +77,8 @@ static void at_exit() { } int kill_signal = SIGKILL; - /* AFL_KILL_SIGNAL should already be a valid int at this point */ - if (getenv("AFL_KILL_SIGNAL")) { - - kill_signal = atoi(getenv("AFL_KILL_SIGNAL")); - - } + if ((ptr = getenv("AFL_KILL_SIGNAL"))) { kill_signal = atoi(ptr); } if (pid1 > 0) { kill(pid1, kill_signal); } if (pid2 > 0) { kill(pid2, kill_signal); } @@ -103,13 +98,14 @@ static void usage(u8 *argv0, int more_help) { "Execution control settings:\n" " -p schedule - power schedules compute a seed's performance score:\n" - " -- see docs/power_schedules.md\n" + " fast(default), explore, exploit, seek, rare, mmopt, " + "coe, lin\n" + " quad -- see docs/power_schedules.md\n" " -f file - location read by the fuzzed program (default: stdin " "or @@)\n" " -t msec - timeout for each run (auto-scaled, 50-%u ms)\n" - " -m megs - memory limit for child process (%u MB, 0 = no limit)\n" + " -m megs - memory limit for child process (%u MB, 0 = no limit " + "[default])\n" " -Q - use binary-only instrumentation (QEMU mode)\n" " -U - use unicorn-based instrumentation (Unicorn mode)\n" " -W - use qemu-based instrumentation with Wine (Wine " @@ -125,7 +121,9 @@ static void usage(u8 *argv0, int more_help) { " See docs/README.MOpt.md\n" " -c program - enable CmpLog by specifying a binary compiled for " "it.\n" - " if using QEMU, just use -c 0.\n\n" + " if using QEMU, just use -c 0.\n" + " -l cmplog_level - set the complexity/intensivity of CmpLog.\n" + " Values: 1 (default), 2 (intensive) and 3 (heavy)\n\n" "Fuzzing behavior settings:\n" " -Z - sequential queue selection instead of weighted " @@ -337,7 +335,6 @@ int main(int argc, char **argv_orig, char **envp) { if (get_afl_env("AFL_DEBUG")) { debug = afl->debug = 1; } - // map_size = get_map_size(); afl_state_init(afl, map_size); afl->debug = debug; afl_fsrv_init(&afl->fsrv); @@ -358,7 +355,8 @@ int main(int argc, char **argv_orig, char **envp) { while ((opt = getopt( argc, argv, - "+b:c:i:I:o:f:F:m:t:T:dDnCB:S:M:x:QNUWe:p:s:V:E:L:hRP:Z")) > 0) { + "+b:B:c:CdDe:E:hi:I:f:F:l:L:m:M:nNo:p:P:RQs:S:t:T:UV:Wx:Z")) > + 0) { switch (opt) { @@ -787,6 +785,26 @@ int main(int argc, char **argv_orig, char **envp) { } break; + case 'l': { + + afl->cmplog_lvl = atoi(optarg); + if (afl->cmplog_lvl < 1 || afl->cmplog_lvl > CMPLOG_LVL_MAX) { + + FATAL( + "Bad complog level value, accepted values are 1 (default), 2 and " + "%u.", + CMPLOG_LVL_MAX); + + } + + if (afl->cmplog_lvl == CMPLOG_LVL_MAX) { + + afl->cmplog_max_filesize = MAX_FILE; + + } + + } break; + case 'L': { /* MOpt mode */ if (afl->limit_time_sig) { FATAL("Multiple -L options not supported"); } @@ -1635,6 +1653,14 @@ int main(int argc, char **argv_orig, char **envp) { if (afl->use_splicing) { ++afl->cycles_wo_finds; + + if (unlikely(afl->shm.cmplog_mode && + afl->cmplog_max_filesize < MAX_FILE)) { + + afl->cmplog_max_filesize <<= 4; + + } + switch (afl->expand_havoc) { case 0: @@ -1652,6 +1678,7 @@ int main(int argc, char **argv_orig, char **envp) { } afl->expand_havoc = 2; + if (afl->cmplog_lvl < 2) afl->cmplog_lvl = 2; break; case 2: // if (!have_p) afl->schedule = EXPLOIT; @@ -1665,11 +1692,14 @@ int main(int argc, char **argv_orig, char **envp) { afl->expand_havoc = 4; break; case 4: - // if not in sync mode, enable deterministic mode? - // if (!afl->sync_id) afl->skip_deterministic = 0; afl->expand_havoc = 5; + if (afl->cmplog_lvl < 3) afl->cmplog_lvl = 3; break; case 5: + // if not in sync mode, enable deterministic mode? + if (!afl->sync_id) afl->skip_deterministic = 0; + afl->expand_havoc = 6; + case 6: // nothing else currently break; -- cgit 1.4.1 From c71ce79963ffd3e1203d1078b8a60f91c4ecebf1 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 17 Jan 2021 15:18:20 +0100 Subject: fix colorization --- GNUmakefile | 4 +-- include/afl-fuzz.h | 4 +-- instrumentation/afl-compiler-rt.o.c | 3 +- src/afl-fuzz-one.c | 6 ++-- src/afl-fuzz-redqueen.c | 56 ++++++++++++++++++++++--------------- src/afl-fuzz.c | 2 ++ src/afl-showmap.c | 25 ++++++++++++++--- 7 files changed, 65 insertions(+), 35 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 7b05a1d5..c71a7d47 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -428,8 +428,8 @@ src/afl-sharedmem.o : $(COMM_HDR) src/afl-sharedmem.c include/sharedmem.h afl-fuzz: $(COMM_HDR) include/afl-fuzz.h $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o | test_x86 $(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) $(AFL_FUZZ_FILES) src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(PYFLAGS) $(LDFLAGS) -lm -afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o $(COMM_HDR) | test_x86 - $(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o -o $@ $(LDFLAGS) +afl-showmap: src/afl-showmap.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o $(COMM_HDR) | test_x86 + $(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(LDFLAGS) afl-tmin: src/afl-tmin.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o $(COMM_HDR) | test_x86 $(CC) $(CFLAGS) $(COMPILE_STATIC) $(CFLAGS_FLTO) src/$@.c src/afl-common.o src/afl-sharedmem.o src/afl-forkserver.o src/afl-performance.o -o $@ $(LDFLAGS) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 8a2122dc..621e8745 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -1136,9 +1136,9 @@ void read_foreign_testcases(afl_state_t *, int); u8 common_fuzz_cmplog_stuff(afl_state_t *afl, u8 *out_buf, u32 len); /* RedQueen */ -u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, - u64 exec_cksum); +u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len); +/* our RNG wrapper */ AFL_RAND_RETURN rand_next(afl_state_t *afl); /* probability between 0.0 and 1.0 */ diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 5d75af78..bbec52f9 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1209,7 +1209,8 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) { void __cmplog_ins_hook1(uint8_t arg1, uint8_t arg2, uint8_t attr) { - // fprintf(stderr, "hook1 arg0=%02x arg1=%02x attr=%u\n", arg1, arg2, attr); + // fprintf(stderr, "hook1 arg0=%02x arg1=%02x attr=%u\n", + // (u8) arg1, (u8) arg2, attr); if (unlikely(!__afl_cmp_map)) return; diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c index 596bae22..4ce22c08 100644 --- a/src/afl-fuzz-one.c +++ b/src/afl-fuzz-one.c @@ -562,8 +562,7 @@ u8 fuzz_one_original(afl_state_t *afl) { !(afl->fsrv.total_execs % afl->queued_paths) || get_cur_time() - afl->last_path_time > 15000) { - if (input_to_state_stage(afl, in_buf, out_buf, len, - afl->queue_cur->exec_cksum)) { + if (input_to_state_stage(afl, in_buf, out_buf, len)) { goto abandon_entry; @@ -2986,8 +2985,7 @@ static u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) { !(afl->fsrv.total_execs % afl->queued_paths) || get_cur_time() - afl->last_path_time > 15000) { - if (input_to_state_stage(afl, in_buf, out_buf, len, - afl->queue_cur->exec_cksum)) { + if (input_to_state_stage(afl, in_buf, out_buf, len)) { goto abandon_entry; diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 955a9232..052f59f1 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -88,7 +88,7 @@ static struct range *pop_biggest_range(struct range **ranges) { static void dump(char *txt, u8 *buf, u32 len) { u32 i; - fprintf(stderr, "DUMP %s %llx ", txt, hash64(buf, len, 0)); + fprintf(stderr, "DUMP %s %llx ", txt, hash64(buf, len, HASH_CONST)); for (i = 0; i < len; i++) fprintf(stderr, "%02x", buf[i]); fprintf(stderr, "\n"); @@ -117,6 +117,7 @@ static u8 get_exec_checksum(afl_state_t *afl, u8 *buf, u32 len, u64 *cksum) { if (unlikely(common_fuzz_stuff(afl, buf, len))) { return 1; } *cksum = hash64(afl->fsrv.trace_bits, afl->fsrv.map_size, HASH_CONST); + return 0; } @@ -200,7 +201,7 @@ static void type_replace(afl_state_t *afl, u8 *buf, u32 len) { } -static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum, +static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, struct tainted **taints) { struct range * ranges = add_range(NULL, 0, len - 1), *rng; @@ -208,18 +209,31 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum, u8 * backup = ck_alloc_nozero(len); u8 * changed = ck_alloc_nozero(len); - u64 orig_hit_cnt, new_hit_cnt; + u64 orig_hit_cnt, new_hit_cnt, exec_cksum; orig_hit_cnt = afl->queued_paths + afl->unique_crashes; afl->stage_name = "colorization"; afl->stage_short = "colorization"; afl->stage_max = (len << 1); - afl->stage_cur = 0; + + // in colorization we do not classify counts, hence we have to calculate + // the original checksum! + if (unlikely(get_exec_checksum(afl, buf, len, &exec_cksum))) { + + goto checksum_fail; + + } + memcpy(backup, buf, len); memcpy(changed, buf, len); type_replace(afl, changed, len); +#ifdef _DEBUG + dump("ORIG", buf, len); + dump("CHAN", changed, len); +#endif + while ((rng = pop_biggest_range(&ranges)) != NULL && afl->stage_cur < afl->stage_max) { @@ -227,7 +241,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum, memcpy(buf + rng->start, changed + rng->start, s); - u64 cksum; + u64 cksum = 0; u64 start_us = get_cur_time_us(); if (unlikely(get_exec_checksum(afl, buf, len, &cksum))) { @@ -633,11 +647,11 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (SHAPE_BYTES(h->shape) >= 4 && *status != 1) { // if (its_len >= 4 && (attr <= 1 || attr >= 8)) - // fprintf(stderr, - // "TestU32: %u>=4 %x==%llx" - // " %x==%llx (idx=%u attr=%u) <= %llx<-%llx\n", - // its_len, *buf_32, pattern, *o_buf_32, o_pattern, idx, attr, - // repl, changed_val); + // fprintf(stderr, + // "TestU32: %u>=4 %x==%llx" + // " %x==%llx (idx=%u attr=%u) <= %llx<-%llx\n", + // its_len, *buf_32, pattern, *o_buf_32, o_pattern, idx, attr, + // repl, changed_val); if (its_len >= 4 && ((*buf_32 == (u32)pattern && *o_buf_32 == (u32)o_pattern) || @@ -702,10 +716,10 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (*status != 1) { // u8 // if (its_len >= 1 && (attr <= 1 || attr >= 8)) - // fprintf(stderr, - // "TestU8: %u>=1 %x==%x %x==%x (idx=%u attr=%u) <= %x<-%x\n", - // its_len, *buf_8, pattern, *o_buf_8, o_pattern, idx, attr, - // repl, changed_val); + // fprintf(stderr, + // "TestU8: %u>=1 %x==%x %x==%x (idx=%u attr=%u) <= %x<-%x\n", + // its_len, *buf_8, (u8)pattern, *o_buf_8, (u8)o_pattern, idx, + // attr, (u8)repl, (u8)changed_val); if (its_len >= 1 && ((*buf_8 == (u8)pattern && *o_buf_8 == (u8)o_pattern) || @@ -1659,8 +1673,7 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, ///// Input to State stage // afl->queue_cur->exec_cksum -u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, - u64 exec_cksum) { +u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { u8 r = 1; if (unlikely(!afl->orig_cmp_map)) { @@ -1686,7 +1699,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, if (!afl->queue_cur->taint || !afl->queue_cur->cmplog_colorinput) { - if (unlikely(colorization(afl, buf, len, exec_cksum, &taint))) { return 1; } + if (unlikely(colorization(afl, buf, len, &taint))) { return 1; } // no taint? still try, create a dummy to prevent again colorization if (!taint) { @@ -1696,6 +1709,10 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, } +#ifdef _DEBUG + dump("NEW ", buf, len); +#endif + } else { buf = afl->queue_cur->cmplog_colorinput; @@ -1705,11 +1722,6 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len, } -#ifdef _DEBUG - dump("ORIG", orig_buf, len); - dump("NEW ", buf, len); -#endif - struct tainted *t = taint; while (t) { diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 1e914ca6..88c40ee8 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1094,6 +1094,8 @@ int main(int argc, char **argv_orig, char **envp) { } + if (afl->shm.cmplog_mode) { OKF("CmpLog level: %u", afl->cmplog_lvl); } + /* Dynamically allocate memory for AFLFast schedules */ if (afl->schedule >= FAST && afl->schedule <= RARE) { diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 5c9d38e0..5d98d646 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -42,6 +42,7 @@ #include "sharedmem.h" #include "forkserver.h" #include "common.h" +#include "hash.h" #include #include @@ -86,7 +87,8 @@ static u8 quiet_mode, /* Hide non-essential messages? */ binary_mode, /* Write output as a binary map */ keep_cores, /* Allow coredumps? */ remove_shm = 1, /* remove shmem? */ - collect_coverage; /* collect coverage */ + collect_coverage, /* collect coverage */ + no_classify; /* do not classify counts */ static volatile u8 stop_soon, /* Ctrl-C pressed? */ child_crashed; /* Child crashed? */ @@ -317,7 +319,9 @@ static void showmap_run_target_forkserver(afl_forkserver_t *fsrv, u8 *mem, } - classify_counts(fsrv); + if (fsrv->trace_bits[0] == 1) { fsrv->trace_bits[0] = 0; } + + if (!no_classify) { classify_counts(fsrv); } if (!quiet_mode) { SAYF(cRST "-- Program output ends --\n"); } @@ -490,7 +494,9 @@ static void showmap_run_target(afl_forkserver_t *fsrv, char **argv) { } - classify_counts(fsrv); + if (fsrv->trace_bits[0] == 1) { fsrv->trace_bits[0] = 0; } + + if (!no_classify) { classify_counts(fsrv); } if (!quiet_mode) { SAYF(cRST "-- Program output ends --\n"); } @@ -680,6 +686,7 @@ static void usage(u8 *argv0) { " -q - sink program's output and don't show messages\n" " -e - show edge coverage only, ignore hit counts\n" " -r - show real tuple values instead of AFL filter values\n" + " -s - do not classify the map\n" " -c - allow core dumps\n\n" "This tool displays raw tuple data captured by AFL instrumentation.\n" @@ -729,10 +736,14 @@ int main(int argc, char **argv_orig, char **envp) { if (getenv("AFL_QUIET") != NULL) { be_quiet = 1; } - while ((opt = getopt(argc, argv, "+i:o:f:m:t:A:eqCZQUWbcrh")) > 0) { + while ((opt = getopt(argc, argv, "+i:o:f:m:t:A:eqCZQUWbcrsh")) > 0) { switch (opt) { + case 's': + no_classify = 1; + break; + case 'C': collect_coverage = 1; quiet_mode = 1; @@ -1213,6 +1224,12 @@ int main(int argc, char **argv_orig, char **envp) { showmap_run_target(fsrv, use_argv); tcnt = write_results_to_file(fsrv, out_file); + if (!quiet_mode) { + + OKF("Hash of coverage map: %llx", + hash64(fsrv->trace_bits, fsrv->map_size, HASH_CONST)); + + } } -- cgit 1.4.1 From c8c0983ab84f4f7acf2dd52937a3cf5e41157a6b Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 17 Jan 2021 15:51:38 +0100 Subject: make combined test a define option --- src/afl-fuzz-redqueen.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 052f59f1..daa08f6a 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -29,6 +29,7 @@ #include "cmplog.h" //#define _DEBUG +//#define COMBINE ///// Colorization @@ -621,7 +622,9 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u64 tmp_64 = *buf_64; *buf_64 = repl; if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } +#ifdef COMBINE if (*status == 1) { memcpy(cbuf + idx, buf_64, 8); } +#endif *buf_64 = tmp_64; // fprintf(stderr, "Status=%u\n", *status); @@ -660,7 +663,9 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u32 tmp_32 = *buf_32; *buf_32 = (u32)repl; if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } +#ifdef COMBINE if (*status == 1) { memcpy(cbuf + idx, buf_32, 4); } +#endif *buf_32 = tmp_32; // fprintf(stderr, "Status=%u\n", *status); @@ -692,7 +697,9 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u16 tmp_16 = *buf_16; *buf_16 = (u16)repl; if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } +#ifdef COMBINE if (*status == 1) { memcpy(cbuf + idx, buf_16, 2); } +#endif *buf_16 = tmp_16; } @@ -728,7 +735,9 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u8 tmp_8 = *buf_8; *buf_8 = (u8)repl; if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } +#ifdef COMBINE if (*status == 1) { cbuf[idx] = *buf_8; } +#endif *buf_8 = tmp_8; } @@ -920,7 +929,9 @@ static u8 cmp_extend_encoding128(afl_state_t *afl, struct cmp_header *h, *buf0 = v11; #endif if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } +#ifdef COMBINE if (*status == 1) { memcpy(cbuf + idx, buf_128, 16); } +#endif *buf_128 = tmp_128; #ifdef _DEBUG @@ -996,7 +1007,9 @@ static u8 cmp_extend_encoding_ld(afl_state_t *afl, struct cmp_header *h, memcpy(backup, buf_ld, 10); memcpy(buf_ld, repl, 10); if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } +#ifdef COMBINE if (*status == 1) { memcpy(cbuf + idx, repl, 10); } +#endif memcpy(buf_ld, backup, 10); #ifdef _DEBUG @@ -1506,6 +1519,10 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, u8 *status) { +#ifndef COMBINE + (void)(cbuf); +#endif + u32 i; u32 its_len = MIN((u32)32, len - idx); its_len = MIN(its_len, taint_len); @@ -1525,7 +1542,9 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } +#ifdef COMBINE if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } +#endif } @@ -1763,10 +1782,14 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { if (cmplog_lvl >= 2 && cmplog_done < 2) { lvl += 2; } if (cmplog_lvl >= 3 && cmplog_done < 3) { lvl += 4; } +#ifdef COMBINE u8 *cbuf = afl_realloc((void **)&afl->in_scratch_buf, len + 128); memcpy(cbuf, orig_buf, len); u8 *virgin_backup = afl_realloc((void **)&afl->ex_buf, afl->shm.map_size); memcpy(virgin_backup, afl->virgin_bits, afl->shm.map_size); +#else + u8 *cbuf = NULL; +#endif u32 k; for (k = 0; k < CMP_MAP_W; ++k) { @@ -1855,6 +1878,7 @@ exit_its: } +#ifdef COMBINE // copy the current virgin bits so we can recover the information u8 *virgin_save = afl_realloc((void **)&afl->eff_buf, afl->shm.map_size); memcpy(virgin_save, afl->virgin_bits, afl->shm.map_size); @@ -1865,7 +1889,7 @@ exit_its: its_fuzz(afl, cbuf, len, &status); // now combine with the saved virgin bits -#ifdef WORD_SIZE_64 + #ifdef WORD_SIZE_64 u64 *v = (u64 *)afl->virgin_bits; u64 *s = (u64 *)virgin_save; u32 i; @@ -1875,19 +1899,19 @@ exit_its: } -#else + #else u32 *v = (u64 *)afl->virgin_bits; u32 *s = (u64 *)virgin_save; - u32 i; + u32 i; for (i = 0; i < (afl->shm.map_size >> 2); i++) { v[i] &= s[i]; } -#endif + #endif -#ifdef _DEBUG + #ifdef _DEBUG dump("COMB", cbuf, len); if (status == 1) { @@ -1899,6 +1923,7 @@ exit_its: } + #endif #endif new_hit_cnt = afl->queued_paths + afl->unique_crashes; @@ -1909,3 +1934,7 @@ exit_its: } +#ifdef COMBINE + #undef COMBINE +#endif + -- cgit 1.4.1 From 6b375489ed5dced4d0f55c334382f418a12e825a Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 17 Jan 2021 16:50:10 +0100 Subject: better extint cmplog --- src/afl-fuzz-redqueen.c | 148 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 140 insertions(+), 8 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index daa08f6a..28d34ea6 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -28,7 +28,7 @@ #include "afl-fuzz.h" #include "cmplog.h" -//#define _DEBUG +#define _DEBUG //#define COMBINE ///// Colorization @@ -233,6 +233,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, #ifdef _DEBUG dump("ORIG", buf, len); dump("CHAN", changed, len); + fprintf(stderr, "CKSUM %llx (%u)\n", exec_cksum, afl->fsrv.map_size); #endif while ((rng = pop_biggest_range(&ranges)) != NULL && @@ -722,11 +723,11 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (*status != 1) { // u8 - // if (its_len >= 1 && (attr <= 1 || attr >= 8)) - // fprintf(stderr, - // "TestU8: %u>=1 %x==%x %x==%x (idx=%u attr=%u) <= %x<-%x\n", - // its_len, *buf_8, (u8)pattern, *o_buf_8, (u8)o_pattern, idx, - // attr, (u8)repl, (u8)changed_val); + if (its_len >= 1 && (attr <= 1 || attr >= 8)) + fprintf(stderr, + "TestU8: %u>=1 %x==%x %x==%x (idx=%u attr=%u) <= %x<-%x\n", + its_len, *buf_8, (u8)pattern, *o_buf_8, (u8)o_pattern, idx, + attr, (u8)repl, (u8)changed_val); if (its_len >= 1 && ((*buf_8 == (u8)pattern && *o_buf_8 == (u8)o_pattern) || @@ -960,6 +961,93 @@ static u8 cmp_extend_encoding128(afl_state_t *afl, struct cmp_header *h, } +static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, + u128 pattern, u128 repl, u128 o_pattern, + u128 changed_val, u8 attr, u32 idx, + u32 taint_len, u8 *orig_buf, u8 *buf, u8 *cbuf, + u32 len, u8 do_reverse, u8 lvl, u8 *status) { + + u8 *ptr = (u8 *)&buf[idx]; + u8 *o_ptr = (u8 *)&orig_buf[idx]; + u32 its_len = MIN(len - idx, taint_len); + u32 shape = h->shape + 1; + u8 *p = (u8 *)&pattern; + u8 *o_p = (u8 *)&o_pattern; + u8 *r = (u8 *)&repl; + u8 *o_r = (u8 *)&changed_val; + u8 backup[16]; +#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + size_t off = 0; +#else + size_t off = 16 - shape; +#endif + + if (its_len >= shape) { + +#ifdef _DEBUG + fprintf(stderr, "TestUN: %u>=%u (len=%u idx=%u attr=%u) (%u) ", its_len, + shape, len, idx, attr, do_reverse); + u32 i; + for (i = 0; i < shape; i++) + fprintf(stderr, "%02x", ptr[0]); + fprintf(stderr, "=="); + for (i = 0; i < shape; i++) + fprintf(stderr, "%02x", p[off + 0]); + fprintf(stderr, " "); + for (i = 0; i < shape; i++) + fprintf(stderr, "%02x", o_ptr[0]); + fprintf(stderr, "=="); + for (i = 0; i < shape; i++) + fprintf(stderr, "%02x", o_p[off + 0]); + fprintf(stderr, " <= "); + for (i = 0; i < shape; i++) + fprintf(stderr, "%02x", r[off + 0]); + fprintf(stderr, " ("); + for (i = 0; i < shape; i++) + fprintf(stderr, "%02x", o_r[off + 0]); + fprintf(stderr, ")\n"); +#endif + + if (!memcmp(ptr, p + off, shape) && !memcmp(o_ptr, o_p + off, shape)) { + + memcpy(backup, ptr, shape); + memcpy(ptr, r + off, shape); + + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + +#ifdef COMBINE + if (*status == 1) { memcpy(cbuf + idx, r, shape); } +#endif + + memcpy(ptr, backup, shape); + +#ifdef _DEBUG + fprintf(stderr, "Status=%u\n", *status); +#endif + + } + + // reverse encoding + if (do_reverse && *status != 1) { + + if (unlikely(cmp_extend_encoding128( + afl, h, SWAPN(pattern, (shape << 3)), SWAPN(repl, (shape << 3)), + SWAPN(o_pattern, (shape << 3)), SWAPN(changed_val, (shape << 3)), + attr, idx, taint_len, orig_buf, buf, cbuf, len, 0, lvl, + status))) { + + return 1; + + } + + } + + } + + return 0; + +} + // uh a pointer read from (long double*) reads 12 bytes, not 10 ... // so lets make this complicated. static u8 cmp_extend_encoding_ld(afl_state_t *afl, struct cmp_header *h, @@ -1365,9 +1453,53 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } - } + } else + + if (is_n) { // _ExtInt special case + + if (s128_v0 != orig_s128_v0 && orig_s128_v0 != orig_s128_v1) { + + if (unlikely(cmp_extend_encodingN( + afl, h, s128_v0, s128_v1, orig_s128_v0, orig_s128_v1, + h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, + lvl, &status))) { + + return 1; + + } + + } + + if (status == 1) { + + found_one = 1; + break; + + } + + if (s128_v1 != orig_s128_v1 && orig_s128_v1 != orig_s128_v0) { + + if (unlikely(cmp_extend_encodingN( + afl, h, s128_v1, s128_v0, orig_s128_v1, orig_s128_v0, + h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, + lvl, &status))) { + + return 1; + + } + + } + + if (status == 1) { + + found_one = 1; + break; + + } + + } else - if (is_128) { // u128 special case + if (is_128) { // u128 special case if (s128_v0 != orig_s128_v0 && orig_s128_v0 != orig_s128_v1) { -- cgit 1.4.1 From 8951f906230ee9b7b2c27d92281d9da81302c694 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 17 Jan 2021 17:03:08 +0100 Subject: no cmplog when no taint is found --- src/afl-fuzz-redqueen.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 28d34ea6..2cc578bb 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -1855,8 +1855,11 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { // no taint? still try, create a dummy to prevent again colorization if (!taint) { - taint = ck_alloc(sizeof(struct tainted)); - taint->len = len; +#ifdef _DEBUG + fprintf(stderr, "TAINT FAILED\n"); +#endif + afl->queue_cur->colorized = CMPLOG_LVL_MAX; + return 0; } -- cgit 1.4.1 From 7b97410060f52b33f0c9894bb202690c453c4bcb Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 17 Jan 2021 23:47:04 +0100 Subject: cmplog introspection --- src/afl-fuzz-redqueen.c | 80 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 2cc578bb..56246d6e 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -29,7 +29,8 @@ #include "cmplog.h" #define _DEBUG -//#define COMBINE +#define COMBINE +#define CMPLOG_INTROSPECTION ///// Colorization @@ -210,6 +211,10 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u8 * backup = ck_alloc_nozero(len); u8 * changed = ck_alloc_nozero(len); +#if defined(_DEBUG) || defined(CMPLOG_INTROSPECTION) + u64 start_time = get_cur_time(); +#endif + u64 orig_hit_cnt, new_hit_cnt, exec_cksum; orig_hit_cnt = afl->queued_paths + afl->unique_crashes; @@ -368,26 +373,30 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, new_hit_cnt = afl->queued_paths + afl->unique_crashes; -#ifdef _DEBUG - /* +#if defined(_DEBUG) || defined(CMPLOG_INTROSPECTION) + FILE *f = stderr; + if (afl->not_on_tty) { + char fn[4096]; snprintf(fn, sizeof(fn), "%s/introspection_color.txt", afl->out_dir); - FILE *f = fopen(fn, "a"); - if (f) { + f = fopen(fn, "a"); - */ - FILE *f = stderr; - fprintf(f, - "Colorization: fname=%s len=%u result=%u execs=%u found=%llu " - "taint=%u\n", - afl->queue_cur->fname, len, afl->queue_cur->colorized, afl->stage_cur, - new_hit_cnt - orig_hit_cnt, positions); -/* - fclose(f); + } + + if (f) { + + fprintf( + f, + "Colorization: fname=%s len=%u ms=%llu result=%u execs=%u found=%llu " + "taint=%u\n", + afl->queue_cur->fname, len, get_cur_time() - start_time, + afl->queue_cur->colorized, afl->stage_cur, new_hit_cnt - orig_hit_cnt, + positions); + + if (afl->not_on_tty) { fclose(f); } } -*/ #endif afl->stage_finds[STAGE_COLORIZATION] += new_hit_cnt - orig_hit_cnt; @@ -1863,6 +1872,15 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } +#ifdef _DEBUG + else if (taint->pos == 0 && taint->len == len) { + + fprintf(stderr, "TAINT FULL\n"); + + } + +#endif + #ifdef _DEBUG dump("NEW ", buf, len); #endif @@ -1887,6 +1905,11 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } +#if defined(_DEBUG) || defined(CMPLOG_INTROSPECTION) + u64 start_time = get_cur_time(); + u32 cmp_locations = 0; +#endif + // do it manually, forkserver clear only afl->fsrv.trace_bits memset(afl->shm.cmp_map->headers, 0, sizeof(afl->shm.cmp_map->headers)); @@ -1960,6 +1983,10 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { if (!afl->shm.cmp_map->headers[k].hits) { continue; } +#if defined(_DEBUG) || defined(CMPLOG_INTROSPECTION) + ++cmp_locations; +#endif + if (afl->shm.cmp_map->headers[k].type == CMP_TYPE_INS) { if (unlikely(cmp_fuzz(afl, k, orig_buf, buf, cbuf, len, lvl, taint))) { @@ -2065,6 +2092,29 @@ exit_its: afl->stage_finds[STAGE_ITS] += new_hit_cnt - orig_hit_cnt; afl->stage_cycles[STAGE_ITS] += afl->fsrv.total_execs - orig_execs; +#if defined(_DEBUG) || defined(CMPLOG_INTROSPECTION) + FILE *f = stderr; + if (afl->not_on_tty) { + + char fn[4096]; + snprintf(fn, sizeof(fn), "%s/introspection_color.txt", afl->out_dir); + f = fopen(fn, "a"); + + } + + if (f) { + + fprintf(f, + "Cmplog: fname=%s len=%u ms=%llu result=%u finds=%llu entries=%u\n", + afl->queue_cur->fname, len, get_cur_time() - start_time, r, + new_hit_cnt - orig_hit_cnt, cmp_locations); + + if (afl->not_on_tty) { fclose(f); } + + } + +#endif + return r; } -- cgit 1.4.1 From a8b06291630d5e4b71ab1eb2fee856c1c576bf4b Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 18 Jan 2021 09:26:16 +0100 Subject: introspection, favor extint over long double --- src/afl-cc.c | 3 +- src/afl-fuzz-redqueen.c | 202 +++++++++--------------------------------------- 2 files changed, 38 insertions(+), 167 deletions(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index 02c9c7c5..d44f069a 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -683,6 +683,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (!strncmp(cur, "--afl", 5)) continue; if (lto_mode && !strncmp(cur, "-fuse-ld=", 9)) continue; if (lto_mode && !strncmp(cur, "--ld-path=", 10)) continue; + if (!strncmp(cur, "-fno-unroll", 11)) continue; if (!strcmp(cur, "-Wl,-z,defs") || !strcmp(cur, "-Wl,--no-undefined")) continue; @@ -703,7 +704,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (!strcmp(cur, "-shared")) shared_linking = 1; if (!strncmp(cur, "-O", 2)) have_o = 1; - if (!strncmp(cur, "-f", 2) && strstr(cur, "unroll-loop")) have_unroll = 1; + if (!strncmp(cur, "-funroll-loop", 13)) have_unroll = 1; cc_params[cc_par_cnt++] = cur; diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 56246d6e..3cfe05bc 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -31,6 +31,7 @@ #define _DEBUG #define COMBINE #define CMPLOG_INTROSPECTION +#define ARITHMETIC_LESSER_GREATER ///// Colorization @@ -375,6 +376,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, #if defined(_DEBUG) || defined(CMPLOG_INTROSPECTION) FILE *f = stderr; + #ifndef _DEBUG if (afl->not_on_tty) { char fn[4096]; @@ -383,6 +385,8 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, } + #endif + if (f) { fprintf( @@ -393,7 +397,9 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, afl->queue_cur->colorized, afl->stage_cur, new_hit_cnt - orig_hit_cnt, positions); + #ifndef _DEBUG if (afl->not_on_tty) { fclose(f); } + #endif } @@ -758,11 +764,15 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // here we add and subract 1 from the value, but only if it is not an // == or != comparison - // Bits: 1 = Equal, 2 = Greater, 3 = Lesser, 4 = Float + // Bits: 1 = Equal, 2 = Greater, 4 = Lesser, 8 = Float + // 16 = modified float, 32 = modified integer (modified = wont match + // in original buffer) +#ifdef ARITHMETIC_LESSER_GREATER if (lvl < 4) { return 0; } - if (attr >= 8 && attr < 16) { // lesser/greater integer comparison + // lesser/greater FP comparison + if (!(attr & 1) && (attr & 6) && (attr >= 8 && attr < 16)) { u64 repl_new; if (SHAPE_BYTES(h->shape) == 4 && its_len >= 4) { @@ -836,11 +846,11 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, double *f = (double *)&repl; float g = (float)*f; repl_new = 0; -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) memcpy((char *)&repl_new, (char *)&g, 4); -#else + #else memcpy(((char *)&repl_new) + 4, (char *)&g, 4); -#endif + #endif changed_val = repl_new; h->shape = 3; // modify shape @@ -850,7 +860,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { - h->shape = 7; + h->shape = 7; // recover shape return 1; } @@ -859,7 +869,9 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - } else if (attr > 1 && attr < 8) { // lesser/greater integer comparison + } else if (!(attr & 1) && (attr & 6) && attr < 8) { + + // lesser/greater integer comparison u64 repl_new; @@ -885,6 +897,8 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } +#endif /* ARITHMETIC_LESSER_GREATER */ + return 0; } @@ -1057,89 +1071,6 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, } -// uh a pointer read from (long double*) reads 12 bytes, not 10 ... -// so lets make this complicated. -static u8 cmp_extend_encoding_ld(afl_state_t *afl, struct cmp_header *h, - u8 *pattern, u8 *repl, u8 *o_pattern, - u8 *changed_val, u8 attr, u32 idx, - u32 taint_len, u8 *orig_buf, u8 *buf, u8 *cbuf, - u32 len, u8 do_reverse, u8 lvl, u8 *status) { - - u8 *buf_ld = &buf[idx], *o_buf_ld = &orig_buf[idx], backup[10]; - u32 its_len = MIN(len - idx, taint_len); - - if (its_len >= 10) { - -#ifdef _DEBUG - fprintf(stderr, "TestUld: %u>=10 (len=%u idx=%u attr=%u) (%u)\n", its_len, - len, idx, attr, do_reverse); - fprintf(stderr, "TestUld: "); - u32 i; - for (i = 0; i < 10; i++) - fprintf(stderr, "%02x", pattern[i]); - fprintf(stderr, "=="); - for (i = 0; i < 10; i++) - fprintf(stderr, "%02x", buf_ld[i]); - fprintf(stderr, " "); - for (i = 0; i < 10; i++) - fprintf(stderr, "%02x", o_pattern[i]); - fprintf(stderr, "=="); - for (i = 0; i < 10; i++) - fprintf(stderr, "%02x", o_buf_ld[i]); - fprintf(stderr, " <= "); - for (i = 0; i < 10; i++) - fprintf(stderr, "%02x", repl[i]); - fprintf(stderr, "=="); - for (i = 0; i < 10; i++) - fprintf(stderr, "%02x", changed_val[i]); - fprintf(stderr, "\n"); -#endif - - if (!memcmp(pattern, buf_ld, 10) && !memcmp(o_pattern, o_buf_ld, 10)) { - - // if this is an fcmp (attr & 8 == 8) then do not compare the patterns - - // due to a bug in llvm dynamic float bitcasts do not work :( - // the value 16 means this is a +- 1.0 test case - - memcpy(backup, buf_ld, 10); - memcpy(buf_ld, repl, 10); - if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } -#ifdef COMBINE - if (*status == 1) { memcpy(cbuf + idx, repl, 10); } -#endif - memcpy(buf_ld, backup, 10); - -#ifdef _DEBUG - fprintf(stderr, "Status=%u\n", *status); -#endif - - } - - } - - // reverse encoding - if (do_reverse && *status != 1) { - - u8 sp[10], sr[10], osp[10], osr[10]; - SWAPNN(sp, pattern, 10); - SWAPNN(sr, repl, 10); - SWAPNN(osp, o_pattern, 10); - SWAPNN(osr, changed_val, 10); - - if (unlikely(cmp_extend_encoding_ld(afl, h, sp, sr, osp, osr, attr, idx, - taint_len, orig_buf, buf, cbuf, len, 0, - lvl, status))) { - - return 1; - - } - - } - - return 0; - -} - static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) { u8 *b = (u8 *)&v; @@ -1273,7 +1204,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, struct cmp_header *h = &afl->shm.cmp_map->headers[key]; struct tainted * t; u32 i, j, idx, taint_len; - u32 have_taint = 1, is_128 = 0, is_n = 0, is_ld = 0; + u32 have_taint = 1, is_128 = 0, is_n = 0; u32 loggeds = h->hits; if (h->hits > CMP_MAP_H) { loggeds = CMP_MAP_H; } @@ -1281,12 +1212,11 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u8 found_one = 0; /* loop cmps are useless, detect and ignore them */ - u128 s128_v0 = 0, s128_v1 = 0, orig_s128_v0 = 0, orig_s128_v1 = 0; - long double ld0, ld1, o_ld0, o_ld1; - u64 s_v0, s_v1; - u8 s_v0_fixed = 1, s_v1_fixed = 1; - u8 s_v0_inc = 1, s_v1_inc = 1; - u8 s_v0_dec = 1, s_v1_dec = 1; + u128 s128_v0 = 0, s128_v1 = 0, orig_s128_v0 = 0, orig_s128_v1 = 0; + u64 s_v0, s_v1; + u8 s_v0_fixed = 1, s_v1_fixed = 1; + u8 s_v0_inc = 1, s_v1_inc = 1; + u8 s_v0_dec = 1, s_v1_dec = 1; switch (SHAPE_BYTES(h->shape)) { @@ -1298,9 +1228,6 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, case 16: is_128 = 1; break; - case 10: - if (h->attribute & 8) { is_ld = 1; } - // fall through default: is_n = 1; @@ -1376,24 +1303,6 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, orig_s128_v0 = ((u128)orig_o->v0) + (((u128)orig_o->v0_128) << 64); orig_s128_v1 = ((u128)orig_o->v1) + (((u128)orig_o->v1_128) << 64); - if (is_ld) { - -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - memcpy((char *)&ld0, (char *)&s128_v0, sizeof(long double)); - memcpy((char *)&ld1, (char *)&s128_v1, sizeof(long double)); - memcpy((char *)&o_ld0, (char *)&orig_s128_v0, sizeof(long double)); - memcpy((char *)&o_ld1, (char *)&orig_s128_v1, sizeof(long double)); -#else - memcpy((char *)&ld0, (char *)(&s128_v0) + 6, sizeof(long double)); - memcpy((char *)&ld1, (char *)(&s128_v1) + 6, sizeof(long double)); - memcpy((char *)&o_ld0, (char *)(&orig_s128_v0) + 6, - sizeof(long double)); - memcpy((char *)&o_ld1, (char *)(&orig_s128_v1) + 6, - sizeof(long double)); -#endif - - } - } for (idx = 0; idx < len; ++idx) { @@ -1420,51 +1329,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, status = 0; - if (is_ld) { // long double special case - - if (ld0 != o_ld0 && o_ld1 != o_ld0) { - - if (unlikely(cmp_extend_encoding_ld( - afl, h, (u8 *)&ld0, (u8 *)&ld1, (u8 *)&o_ld0, (u8 *)&o_ld1, - h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, - lvl, &status))) { - - return 1; - - } - - } - - if (status == 1) { - - found_one = 1; - break; - - } - - if (ld1 != o_ld1 && o_ld0 != o_ld1) { - - if (unlikely(cmp_extend_encoding_ld( - afl, h, (u8 *)&ld1, (u8 *)&ld0, (u8 *)&o_ld1, (u8 *)&o_ld0, - h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, - lvl, &status))) { - - return 1; - - } - - } - - if (status == 1) { - - found_one = 1; - break; - - } - - } else - - if (is_n) { // _ExtInt special case + if (is_n) { // _ExtInt special case if (s128_v0 != orig_s128_v0 && orig_s128_v0 != orig_s128_v1) { @@ -1552,7 +1417,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } - // even for u128 and long double do cmp_extend_encoding() because + // even for u128 and _ExtInt we do cmp_extend_encoding() because // if we got here their own special trials failed and it might just be // a cast from e.g. u64 to u128 from the input data. @@ -1995,7 +1860,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } - } else { + } else if (lvl & 1) { if (unlikely(rtn_fuzz(afl, k, orig_buf, buf, cbuf, len, taint))) { @@ -2064,7 +1929,7 @@ exit_its: #else u32 *v = (u64 *)afl->virgin_bits; u32 *s = (u64 *)virgin_save; - u32 i; + u32 i; for (i = 0; i < (afl->shm.map_size >> 2); i++) { v[i] &= s[i]; @@ -2094,6 +1959,7 @@ exit_its: #if defined(_DEBUG) || defined(CMPLOG_INTROSPECTION) FILE *f = stderr; + #ifndef _DEBUG if (afl->not_on_tty) { char fn[4096]; @@ -2102,6 +1968,8 @@ exit_its: } + #endif + if (f) { fprintf(f, @@ -2109,7 +1977,9 @@ exit_its: afl->queue_cur->fname, len, get_cur_time() - start_time, r, new_hit_cnt - orig_hit_cnt, cmp_locations); + #ifndef _DEBUG if (afl->not_on_tty) { fclose(f); } + #endif } -- cgit 1.4.1 From bbfaa6092db55dc49f771a97ad7da7985c343531 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 18 Jan 2021 11:12:20 +0100 Subject: refactoring --- src/afl-fuzz-redqueen.c | 294 +++++++++--------------------------------------- 1 file changed, 51 insertions(+), 243 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 3cfe05bc..94667254 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -28,10 +28,10 @@ #include "afl-fuzz.h" #include "cmplog.h" -#define _DEBUG -#define COMBINE +//#define _DEBUG +//#define COMBINE #define CMPLOG_INTROSPECTION -#define ARITHMETIC_LESSER_GREATER +//#define ARITHMETIC_LESSER_GREATER ///// Colorization @@ -524,7 +524,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // not 100% but would have a chance to be detected // fprintf(stderr, - // "Encode: %llx->%llx into %llx(<-%llx) at pos=%u " + // "Encode: %llx->%llx into %llx(<-%llx) at idx=%u " // "taint_len=%u shape=%u attr=%u\n", // o_pattern, pattern, repl, changed_val, idx, taint_len, // h->shape + 1, attr); @@ -622,12 +622,12 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (SHAPE_BYTES(h->shape) >= 8 && *status != 1) { - // if (its_len >= 8 && (attr == 0 || attr >= 8)) - // fprintf(stderr, - // "TestU64: %u>=4 %x==%llx" - // " %x==%llx (idx=%u attr=%u) <= %llx<-%llx\n", - // its_len, *buf_32, pattern, *o_buf_32, o_pattern, idx, attr, - // repl, changed_val); + // if (its_len >= 8) + // fprintf(stderr, + // "TestU64: %u>=8 (idx=%u attr=%u) %llx==%llx" + // " %llx==%llx <= %llx<-%llx\n", + // its_len, idx, attr, *buf_64, pattern, *o_buf_64, o_pattern, + // repl, changed_val); // if this is an fcmp (attr & 8 == 8) then do not compare the patterns - // due to a bug in llvm dynamic float bitcasts do not work :( @@ -667,10 +667,10 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // if (its_len >= 4 && (attr <= 1 || attr >= 8)) // fprintf(stderr, - // "TestU32: %u>=4 %x==%llx" - // " %x==%llx (idx=%u attr=%u) <= %llx<-%llx\n", - // its_len, *buf_32, pattern, *o_buf_32, o_pattern, idx, attr, - // repl, changed_val); + // "TestU32: %u>=4 (idx=%u attr=%u) %x==%x" + // " %x==%x <= %x<-%x\n", + // its_len, idx, attr, *buf_32, (u32)pattern, *o_buf_32, + // (u32)o_pattern, (u32)repl, (u32)changed_val); if (its_len >= 4 && ((*buf_32 == (u32)pattern && *o_buf_32 == (u32)o_pattern) || @@ -738,11 +738,11 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (*status != 1) { // u8 - if (its_len >= 1 && (attr <= 1 || attr >= 8)) - fprintf(stderr, - "TestU8: %u>=1 %x==%x %x==%x (idx=%u attr=%u) <= %x<-%x\n", - its_len, *buf_8, (u8)pattern, *o_buf_8, (u8)o_pattern, idx, - attr, (u8)repl, (u8)changed_val); + // if (its_len >= 1 && (attr <= 1 || attr >= 8)) + // fprintf(stderr, + // "TestU8: %u>=1 (idx=%u attr=%u) %x==%x %x==%x <= %x<-%x\n", + // its_len, idx, attr, *buf_8, (u8)pattern, *o_buf_8, + // (u8)o_pattern, (u8)repl, (u8)changed_val); if (its_len >= 1 && ((*buf_8 == (u8)pattern && *o_buf_8 == (u8)o_pattern) || @@ -903,87 +903,6 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } -static u8 cmp_extend_encoding128(afl_state_t *afl, struct cmp_header *h, - u128 pattern, u128 repl, u128 o_pattern, - u128 changed_val, u8 attr, u32 idx, - u32 taint_len, u8 *orig_buf, u8 *buf, u8 *cbuf, - u32 len, u8 do_reverse, u8 lvl, u8 *status) { - - u128 *buf_128 = (u128 *)&buf[idx]; - u64 * buf0 = (u64 *)&buf[idx]; - u64 * buf1 = (u64 *)(buf + idx + 8); - u128 *o_buf_128 = (u128 *)&orig_buf[idx]; - u32 its_len = MIN(len - idx, taint_len); - u64 v10 = (u64)repl; - u64 v11 = (u64)(repl >> 64); - - // if this is an fcmp (attr & 8 == 8) then do not compare the patterns - - // due to a bug in llvm dynamic float bitcasts do not work :( - // the value 16 means this is a +- 1.0 test case - if (its_len >= 16) { - -#ifdef _DEBUG - fprintf(stderr, "TestU128: %u>=16 (idx=%u attr=%u) (%u)\n", its_len, idx, - attr, do_reverse); - u64 v00 = (u64)pattern; - u64 v01 = pattern >> 64; - u64 ov00 = (u64)o_pattern; - u64 ov01 = o_pattern >> 64; - u64 ov10 = (u64)changed_val; - u64 ov11 = changed_val >> 64; - u64 b00 = (u64)*buf_128; - u64 b01 = *buf_128 >> 64; - u64 ob00 = (u64)*o_buf_128; - u64 ob01 = *o_buf_128 >> 64; - fprintf(stderr, - "TestU128: %llx:%llx==%llx:%llx" - " %llx:%llx==%llx:%llx <= %llx:%llx<-%llx:%llx\n", - b01, b00, v01, v00, ob01, ob00, ov01, ov00, v11, v10, ov11, ov10); -#endif - - if (*buf_128 == pattern && *o_buf_128 == o_pattern) { - - u128 tmp_128 = *buf_128; - // *buf_128 = repl; <- this crashes -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - *buf0 = v10; - *buf1 = v11; -#else - *buf1 = v10; - *buf0 = v11; -#endif - if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } -#ifdef COMBINE - if (*status == 1) { memcpy(cbuf + idx, buf_128, 16); } -#endif - *buf_128 = tmp_128; - -#ifdef _DEBUG - fprintf(stderr, "Status=%u\n", *status); -#endif - - } - - // reverse encoding - if (do_reverse && *status != 1) { - - if (unlikely(cmp_extend_encoding128( - afl, h, SWAPN(pattern, 128), SWAPN(repl, 128), - SWAPN(o_pattern, 128), SWAPN(changed_val, 128), attr, idx, - taint_len, orig_buf, buf, cbuf, len, 0, lvl, status))) { - - return 1; - - } - - } - - } - - return 0; - -} - static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, u128 pattern, u128 repl, u128 o_pattern, u128 changed_val, u8 attr, u32 idx, @@ -992,13 +911,12 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, u8 *ptr = (u8 *)&buf[idx]; u8 *o_ptr = (u8 *)&orig_buf[idx]; - u32 its_len = MIN(len - idx, taint_len); - u32 shape = h->shape + 1; u8 *p = (u8 *)&pattern; u8 *o_p = (u8 *)&o_pattern; u8 *r = (u8 *)&repl; - u8 *o_r = (u8 *)&changed_val; u8 backup[16]; + u32 its_len = MIN(len - idx, taint_len); + u32 shape = h->shape + 1; #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) size_t off = 0; #else @@ -1008,27 +926,28 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, if (its_len >= shape) { #ifdef _DEBUG - fprintf(stderr, "TestUN: %u>=%u (len=%u idx=%u attr=%u) (%u) ", its_len, - shape, len, idx, attr, do_reverse); + // fprintf(stderr, "TestUN: %u>=%u (len=%u idx=%u attr=%u off=%lu) (%u) ", + // its_len, shape, len, idx, attr, off, do_reverse); u32 i; + u8 *o_r = (u8 *)&changed_val; for (i = 0; i < shape; i++) - fprintf(stderr, "%02x", ptr[0]); + fprintf(stderr, "%02x", ptr[i]); fprintf(stderr, "=="); for (i = 0; i < shape; i++) - fprintf(stderr, "%02x", p[off + 0]); + fprintf(stderr, "%02x", p[off + i]); fprintf(stderr, " "); for (i = 0; i < shape; i++) - fprintf(stderr, "%02x", o_ptr[0]); + fprintf(stderr, "%02x", o_ptr[i]); fprintf(stderr, "=="); for (i = 0; i < shape; i++) - fprintf(stderr, "%02x", o_p[off + 0]); + fprintf(stderr, "%02x", o_p[off + i]); fprintf(stderr, " <= "); for (i = 0; i < shape; i++) - fprintf(stderr, "%02x", r[off + 0]); - fprintf(stderr, " ("); + fprintf(stderr, "%02x", r[off + i]); + fprintf(stderr, "<-"); for (i = 0; i < shape; i++) - fprintf(stderr, "%02x", o_r[off + 0]); - fprintf(stderr, ")\n"); + fprintf(stderr, "%02x", o_r[off + i]); + fprintf(stderr, "\n"); #endif if (!memcmp(ptr, p + off, shape) && !memcmp(o_ptr, o_p + off, shape)) { @@ -1053,7 +972,7 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, // reverse encoding if (do_reverse && *status != 1) { - if (unlikely(cmp_extend_encoding128( + if (unlikely(cmp_extend_encodingN( afl, h, SWAPN(pattern, (shape << 3)), SWAPN(repl, (shape << 3)), SWAPN(o_pattern, (shape << 3)), SWAPN(changed_val, (shape << 3)), attr, idx, taint_len, orig_buf, buf, cbuf, len, 0, lvl, @@ -1121,48 +1040,6 @@ static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) { } -static void try_to_add_to_dict128(afl_state_t *afl, u128 v) { - - u8 *b = (u8 *)&v; - - u32 k; - u8 cons_ff = 0, cons_0 = 0; - for (k = 0; k < 16; ++k) { - - if (b[k] == 0) { - - ++cons_0; - - } else if (b[k] == 0xff) { - - ++cons_0; - - } else { - - cons_0 = cons_ff = 0; - - } - - // too many uninteresting values? try adding 2 64-bit values - if (cons_0 > 6 || cons_ff > 6) { - - u64 v64 = (u64)v; - try_to_add_to_dict(afl, v64, 8); - v64 = (u64)(v >> 64); - try_to_add_to_dict(afl, v64, 8); - - return; - - } - - } - - maybe_add_auto(afl, (u8 *)&v, 16); - u128 rev = SWAPN(v, 128); - maybe_add_auto(afl, (u8 *)&rev, 16); - -} - static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) { u8 *b = (u8 *)&v; @@ -1170,9 +1047,11 @@ static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) { u32 k; u8 cons_ff = 0, cons_0 = 0; #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + u32 off = 0; for (k = 0; k < size; ++k) { #else + u32 off = 16 - size; for (k = 16 - size; k < 16; ++k) { #endif @@ -1192,9 +1071,9 @@ static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) { } - maybe_add_auto(afl, (u8 *)&v, size); + maybe_add_auto(afl, (u8 *)&v + off, size); u128 rev = SWAPN(v, size); - maybe_add_auto(afl, (u8 *)&rev, size); + maybe_add_auto(afl, (u8 *)&rev + off, size); } @@ -1204,7 +1083,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, struct cmp_header *h = &afl->shm.cmp_map->headers[key]; struct tainted * t; u32 i, j, idx, taint_len; - u32 have_taint = 1, is_128 = 0, is_n = 0; + u32 have_taint = 1, is_n = 0; u32 loggeds = h->hits; if (h->hits > CMP_MAP_H) { loggeds = CMP_MAP_H; } @@ -1225,15 +1104,12 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, case 4: case 8: break; - case 16: - is_128 = 1; - break; default: is_n = 1; } - // FCmp not in if level 1 only + // FP handling only from lvl 2 onwards if ((h->attribute & 8) && lvl < 2) return 0; for (i = 0; i < loggeds; ++i) { @@ -1279,24 +1155,14 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, SHAPE_BYTES(h->shape)); #endif - if (taint) { - - t = taint; - - while (t->next) { - - t = t->next; - - } - - } else { + t = taint; + while (t->next) { - have_taint = 0; - t = NULL; + t = t->next; } - if (unlikely(is_128 || is_n)) { + if (unlikely(is_n)) { s128_v0 = ((u128)o->v0) + (((u128)o->v0_128) << 64); s128_v1 = ((u128)o->v1) + (((u128)o->v1_128) << 64); @@ -1329,7 +1195,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, status = 0; - if (is_n) { // _ExtInt special case + if (is_n) { // _ExtInt special case including u128 if (s128_v0 != orig_s128_v0 && orig_s128_v0 != orig_s128_v1) { @@ -1371,50 +1237,6 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } - } else - - if (is_128) { // u128 special case - - if (s128_v0 != orig_s128_v0 && orig_s128_v0 != orig_s128_v1) { - - if (unlikely(cmp_extend_encoding128( - afl, h, s128_v0, s128_v1, orig_s128_v0, orig_s128_v1, - h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, - lvl, &status))) { - - return 1; - - } - - } - - if (status == 1) { - - found_one = 1; - break; - - } - - if (s128_v1 != orig_s128_v1 && orig_s128_v1 != orig_s128_v0) { - - if (unlikely(cmp_extend_encoding128( - afl, h, s128_v1, s128_v0, orig_s128_v1, orig_s128_v0, - h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, - lvl, &status))) { - - return 1; - - } - - } - - if (status == 1) { - - found_one = 1; - break; - - } - } // even for u128 and _ExtInt we do cmp_extend_encoding() because @@ -1464,10 +1286,10 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, #ifdef _DEBUG fprintf(stderr, - "END: %llx->%llx vs %llx->%llx attr=%u i=%u found=%u is128=%u " + "END: %llx->%llx vs %llx->%llx attr=%u i=%u found=%u " "isN=%u size=%u\n", orig_o->v0, o->v0, orig_o->v1, o->v1, h->attribute, i, found_one, - is_128, is_n, SHAPE_BYTES(h->shape)); + is_n, SHAPE_BYTES(h->shape)); #endif // If failed, add to dictionary @@ -1475,12 +1297,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, if (afl->pass_stats[key].total == 0) { - if (unlikely(is_128)) { - - try_to_add_to_dict128(afl, s128_v0); - try_to_add_to_dict128(afl, s128_v1); - - } else if (unlikely(is_n)) { + if (unlikely(is_n)) { try_to_add_to_dictN(afl, s128_v0, SHAPE_BYTES(h->shape)); try_to_add_to_dictN(afl, s128_v1, SHAPE_BYTES(h->shape)); @@ -1592,19 +1409,10 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } - if (taint) { - - t = taint; - while (t->next) { - - t = t->next; - - } - - } else { + t = taint; + while (t->next) { - have_taint = 0; - t = NULL; + t = t->next; } @@ -1764,7 +1572,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { while (t) { #ifdef _DEBUG - fprintf(stderr, "T: pos=%u len=%u\n", t->pos, t->len); + fprintf(stderr, "T: idx=%u len=%u\n", t->pos, t->len); #endif t = t->next; -- cgit 1.4.1 From 0c061186cf873011ca2636a307c9d6dc85ca6880 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 18 Jan 2021 12:13:36 +0100 Subject: less logging --- instrumentation/afl-compiler-rt.o.c | 12 ++++++------ src/afl-fuzz-redqueen.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index bbec52f9..edb635ae 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1212,7 +1212,7 @@ void __cmplog_ins_hook1(uint8_t arg1, uint8_t arg2, uint8_t attr) { // fprintf(stderr, "hook1 arg0=%02x arg1=%02x attr=%u\n", // (u8) arg1, (u8) arg2, attr); - if (unlikely(!__afl_cmp_map)) return; + if (unlikely(!__afl_cmp_map || arg1 == arg2)) return; uintptr_t k = (uintptr_t)__builtin_return_address(0); k = (k >> 4) ^ (k << 8); @@ -1236,7 +1236,7 @@ void __cmplog_ins_hook1(uint8_t arg1, uint8_t arg2, uint8_t attr) { void __cmplog_ins_hook2(uint16_t arg1, uint16_t arg2, uint8_t attr) { - if (unlikely(!__afl_cmp_map)) return; + if (unlikely(!__afl_cmp_map || arg1 == arg2)) return; uintptr_t k = (uintptr_t)__builtin_return_address(0); k = (k >> 4) ^ (k << 8); @@ -1260,7 +1260,7 @@ void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2, uint8_t attr) { // fprintf(stderr, "hook4 arg0=%x arg1=%x attr=%u\n", arg1, arg2, attr); - if (unlikely(!__afl_cmp_map)) return; + if (unlikely(!__afl_cmp_map || arg1 == arg2)) return; uintptr_t k = (uintptr_t)__builtin_return_address(0); k = (k >> 4) ^ (k << 8); @@ -1282,9 +1282,9 @@ void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2, uint8_t attr) { void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2, uint8_t attr) { - // fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); + fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); - if (unlikely(!__afl_cmp_map)) return; + if (unlikely(!__afl_cmp_map || arg1 == arg2)) return; uintptr_t k = (uintptr_t)__builtin_return_address(0); k = (k >> 4) ^ (k << 8); @@ -1312,7 +1312,7 @@ void __cmplog_ins_hookN(uint128_t arg1, uint128_t arg2, uint8_t attr, // (u64)(arg1 >> 64), (u64)arg1, (u64)(arg2 >> 64), (u64)arg2, size + 1, // attr); - if (unlikely(!__afl_cmp_map)) return; + if (unlikely(!__afl_cmp_map || arg1 == arg2)) return; uintptr_t k = (uintptr_t)__builtin_return_address(0); k = (k >> 4) ^ (k << 8); diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 94667254..0c12657d 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -380,7 +380,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, if (afl->not_on_tty) { char fn[4096]; - snprintf(fn, sizeof(fn), "%s/introspection_color.txt", afl->out_dir); + snprintf(fn, sizeof(fn), "%s/introspection_cmplog.txt", afl->out_dir); f = fopen(fn, "a"); } @@ -1771,7 +1771,7 @@ exit_its: if (afl->not_on_tty) { char fn[4096]; - snprintf(fn, sizeof(fn), "%s/introspection_color.txt", afl->out_dir); + snprintf(fn, sizeof(fn), "%s/introspection_cmplog.txt", afl->out_dir); f = fopen(fn, "a"); } -- cgit 1.4.1 From 94a15b8ca790a87d88c7513282250257f32a48c0 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 18 Jan 2021 13:20:40 +0100 Subject: arithmetic also for <= >= --- src/afl-fuzz-redqueen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 0c12657d..fe98f031 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -772,7 +772,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (lvl < 4) { return 0; } // lesser/greater FP comparison - if (!(attr & 1) && (attr & 6) && (attr >= 8 && attr < 16)) { + if ((attr & 6) && (attr >= 8 && attr < 16)) { u64 repl_new; if (SHAPE_BYTES(h->shape) == 4 && its_len >= 4) { @@ -869,7 +869,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - } else if (!(attr & 1) && (attr & 6) && attr < 8) { + } else if ((attr & 6) && attr < 8) { // lesser/greater integer comparison -- cgit 1.4.1 From 0b545aaeb45141e91273f2358ec457293c341c92 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 18 Jan 2021 20:18:18 +0100 Subject: use enums, support cmplog map collisions --- include/cmplog.h | 8 +- include/config.h | 2 - include/types.h | 47 ++++--- instrumentation/afl-compiler-rt.o.c | 201 ++++++++++++++++++++++------ instrumentation/cmplog-instructions-pass.cc | 4 + instrumentation/llvm-ngram-coverage.h | 2 +- src/afl-fuzz-redqueen.c | 129 +++++++++++------- 7 files changed, 276 insertions(+), 117 deletions(-) diff --git a/include/cmplog.h b/include/cmplog.h index 6392c503..878ed60c 100644 --- a/include/cmplog.h +++ b/include/cmplog.h @@ -38,17 +38,17 @@ #define SHAPE_BYTES(x) (x + 1) -#define CMP_TYPE_INS 0 -#define CMP_TYPE_RTN 1 +#define CMP_TYPE_INS 1 +#define CMP_TYPE_RTN 2 struct cmp_header { unsigned hits : 24; unsigned id : 24; unsigned shape : 5; - unsigned type : 1; + unsigned type : 2; unsigned attribute : 4; - unsigned reserved : 6; + unsigned reserved : 5; } __attribute__((packed)); diff --git a/include/config.h b/include/config.h index c0cd0ef1..c9c4a677 100644 --- a/include/config.h +++ b/include/config.h @@ -23,8 +23,6 @@ #ifndef _HAVE_CONFIG_H #define _HAVE_CONFIG_H -#include "types.h" - /* Version string: */ // c = release, d = volatile github dev, e = experimental branch diff --git a/include/types.h b/include/types.h index d5c31597..7b94fb83 100644 --- a/include/types.h +++ b/include/types.h @@ -25,12 +25,15 @@ #include #include +#include "config.h" -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +#ifdef WORD_SIZE_64 typedef unsigned __int128 uint128_t; typedef uint128_t u128; +#endif /* Extended forkserver option values */ @@ -59,12 +62,14 @@ typedef uint128_t u128; typedef unsigned long long u64; -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef int64_t s64; +typedef int8_t s8; +typedef int16_t s16; +typedef int32_t s32; +typedef int64_t s64; +#ifdef WORD_SIZE_64 typedef __int128 int128_t; typedef int128_t s128; +#endif #ifndef MIN #define MIN(a, b) \ @@ -119,19 +124,21 @@ typedef int128_t s128; }) // It is impossible to define 128 bit constants, so ... -#define SWAPN(_x, _l) \ - ({ \ - \ - u128 _res = (_x), _ret; \ - char *d = (char *)&_ret, *s = (char *)&_res; \ - int i; \ - for (i = 0; i < 16; i++) \ - d[15 - i] = s[i]; \ - u32 sr = 128U - ((_l) << 3U); \ - (_ret >>= sr); \ - (u128) _ret; \ - \ - }) +#ifdef WORD_SIZE_64 + #define SWAPN(_x, _l) \ + ({ \ + \ + u128 _res = (_x), _ret; \ + char *d = (char *)&_ret, *s = (char *)&_res; \ + int i; \ + for (i = 0; i < 16; i++) \ + d[15 - i] = s[i]; \ + u32 sr = 128U - ((_l) << 3U); \ + (_ret >>= sr); \ + (u128) _ret; \ + \ + }) +#endif #define SWAPNN(_x, _y, _l) \ ({ \ diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index edb635ae..0ce96673 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1218,15 +1218,22 @@ void __cmplog_ins_hook1(uint8_t arg1, uint8_t arg2, uint8_t attr) { k = (k >> 4) ^ (k << 8); k &= CMP_MAP_W - 1; - __afl_cmp_map->headers[k].type = CMP_TYPE_INS; - __afl_cmp_map->headers[k].attribute = attr; + u32 hits; + + if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { - u32 hits = __afl_cmp_map->headers[k].hits; - __afl_cmp_map->headers[k].hits = hits + 1; - // if (!__afl_cmp_map->headers[k].cnt) - // __afl_cmp_map->headers[k].cnt = __afl_cmp_counter++; + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + hits = 0; + __afl_cmp_map->headers[k].hits = 1; + __afl_cmp_map->headers[k].shape = 0; - __afl_cmp_map->headers[k].shape = 0; + } else { + + hits = __afl_cmp_map->headers[k].hits++; + + } + + __afl_cmp_map->headers[k].attribute = attr; hits &= CMP_MAP_H - 1; __afl_cmp_map->log[k][hits].v0 = arg1; @@ -1242,13 +1249,28 @@ void __cmplog_ins_hook2(uint16_t arg1, uint16_t arg2, uint8_t attr) { k = (k >> 4) ^ (k << 8); k &= CMP_MAP_W - 1; - __afl_cmp_map->headers[k].type = CMP_TYPE_INS; - __afl_cmp_map->headers[k].attribute = attr; + u32 hits; - u32 hits = __afl_cmp_map->headers[k].hits; - __afl_cmp_map->headers[k].hits = hits + 1; + if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { - __afl_cmp_map->headers[k].shape = 1; + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + hits = 0; + __afl_cmp_map->headers[k].hits = 1; + __afl_cmp_map->headers[k].shape = 1; + + } else { + + hits = __afl_cmp_map->headers[k].hits++; + + if (!__afl_cmp_map->headers[k].shape) { + + __afl_cmp_map->headers[k].shape = 1; + + } + + } + + __afl_cmp_map->headers[k].attribute = attr; hits &= CMP_MAP_H - 1; __afl_cmp_map->log[k][hits].v0 = arg1; @@ -1266,13 +1288,28 @@ void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2, uint8_t attr) { k = (k >> 4) ^ (k << 8); k &= CMP_MAP_W - 1; - __afl_cmp_map->headers[k].type = CMP_TYPE_INS; - __afl_cmp_map->headers[k].attribute = attr; + u32 hits; + + if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { + + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + hits = 0; + __afl_cmp_map->headers[k].hits = 1; + __afl_cmp_map->headers[k].shape = 3; + + } else { + + hits = __afl_cmp_map->headers[k].hits++; - u32 hits = __afl_cmp_map->headers[k].hits; - __afl_cmp_map->headers[k].hits = hits + 1; + if (__afl_cmp_map->headers[k].shape < 3) { - __afl_cmp_map->headers[k].shape = 3; + __afl_cmp_map->headers[k].shape = 3; + + } + + } + + __afl_cmp_map->headers[k].attribute = attr; hits &= CMP_MAP_H - 1; __afl_cmp_map->log[k][hits].v0 = arg1; @@ -1282,7 +1319,7 @@ void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2, uint8_t attr) { void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2, uint8_t attr) { - fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); + // fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); if (unlikely(!__afl_cmp_map || arg1 == arg2)) return; @@ -1290,13 +1327,28 @@ void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2, uint8_t attr) { k = (k >> 4) ^ (k << 8); k &= CMP_MAP_W - 1; - __afl_cmp_map->headers[k].type = CMP_TYPE_INS; - __afl_cmp_map->headers[k].attribute = attr; + u32 hits; - u32 hits = __afl_cmp_map->headers[k].hits; - __afl_cmp_map->headers[k].hits = hits + 1; + if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { - __afl_cmp_map->headers[k].shape = 7; + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + hits = 0; + __afl_cmp_map->headers[k].hits = 1; + __afl_cmp_map->headers[k].shape = 7; + + } else { + + hits = __afl_cmp_map->headers[k].hits++; + + if (__afl_cmp_map->headers[k].shape < 7) { + + __afl_cmp_map->headers[k].shape = 7; + + } + + } + + __afl_cmp_map->headers[k].attribute = attr; hits &= CMP_MAP_H - 1; __afl_cmp_map->log[k][hits].v0 = arg1; @@ -1304,6 +1356,7 @@ void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2, uint8_t attr) { } +#ifdef WORD_SIZE_64 // support for u24 to u120 via llvm _ExitInt(). size is in bytes minus 1 void __cmplog_ins_hookN(uint128_t arg1, uint128_t arg2, uint8_t attr, uint8_t size) { @@ -1318,13 +1371,28 @@ void __cmplog_ins_hookN(uint128_t arg1, uint128_t arg2, uint8_t attr, k = (k >> 4) ^ (k << 8); k &= CMP_MAP_W - 1; - __afl_cmp_map->headers[k].type = CMP_TYPE_INS; - __afl_cmp_map->headers[k].attribute = attr; + u32 hits; - u32 hits = __afl_cmp_map->headers[k].hits; - __afl_cmp_map->headers[k].hits = hits + 1; + if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { - __afl_cmp_map->headers[k].shape = size; + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + hits = 0; + __afl_cmp_map->headers[k].hits = 1; + __afl_cmp_map->headers[k].shape = size; + + } else { + + hits = __afl_cmp_map->headers[k].hits++; + + if (__afl_cmp_map->headers[k].shape < size) { + + __afl_cmp_map->headers[k].shape = size; + + } + + } + + __afl_cmp_map->headers[k].attribute = attr; hits &= CMP_MAP_H - 1; __afl_cmp_map->log[k][hits].v0 = (u64)arg1; @@ -1347,13 +1415,28 @@ void __cmplog_ins_hook16(uint128_t arg1, uint128_t arg2, uint8_t attr) { k = (k >> 4) ^ (k << 8); k &= CMP_MAP_W - 1; - __afl_cmp_map->headers[k].type = CMP_TYPE_INS; - __afl_cmp_map->headers[k].attribute = attr; + u32 hits; - u32 hits = __afl_cmp_map->headers[k].hits; - __afl_cmp_map->headers[k].hits = hits + 1; + if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { - __afl_cmp_map->headers[k].shape = 15; + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + hits = 0; + __afl_cmp_map->headers[k].hits = 1; + __afl_cmp_map->headers[k].shape = 15; + + } else { + + hits = __afl_cmp_map->headers[k].hits++; + + if (__afl_cmp_map->headers[k].shape < 15) { + + __afl_cmp_map->headers[k].shape = 15; + + } + + } + + __afl_cmp_map->headers[k].attribute = attr; hits &= CMP_MAP_H - 1; __afl_cmp_map->log[k][hits].v0 = (u64)arg1; @@ -1363,6 +1446,8 @@ void __cmplog_ins_hook16(uint128_t arg1, uint128_t arg2, uint8_t attr) { } +#endif + #if defined(__APPLE__) #pragma weak __sanitizer_cov_trace_const_cmp1 = __cmplog_ins_hook1 #pragma weak __sanitizer_cov_trace_const_cmp2 = __cmplog_ins_hook2 @@ -1384,8 +1469,10 @@ void __sanitizer_cov_trace_const_cmp4(uint32_t arg1, uint32_t arg2) __attribute__((alias("__cmplog_ins_hook4"))); void __sanitizer_cov_trace_const_cmp8(uint64_t arg1, uint64_t arg2) __attribute__((alias("__cmplog_ins_hook8"))); + #ifdef WORD_SIZE_64 void __sanitizer_cov_trace_const_cmp16(uint128_t arg1, uint128_t arg2) __attribute__((alias("__cmplog_ins_hook16"))); + #endif void __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) __attribute__((alias("__cmplog_ins_hook1"))); @@ -1395,8 +1482,10 @@ void __sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2) __attribute__((alias("__cmplog_ins_hook4"))); void __sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2) __attribute__((alias("__cmplog_ins_hook8"))); + #ifdef WORD_SIZE_64 void __sanitizer_cov_trace_cmp16(uint128_t arg1, uint128_t arg2) __attribute__((alias("__cmplog_ins_hook16"))); + #endif #endif /* defined(__APPLE__) */ void __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) { @@ -1409,12 +1498,28 @@ void __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) { k = (k >> 4) ^ (k << 8); k &= CMP_MAP_W - 1; - __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + u32 hits; - u32 hits = __afl_cmp_map->headers[k].hits; - __afl_cmp_map->headers[k].hits = hits + 1; + if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { - __afl_cmp_map->headers[k].shape = 7; + __afl_cmp_map->headers[k].type = CMP_TYPE_INS; + hits = 0; + __afl_cmp_map->headers[k].hits = 1; + __afl_cmp_map->headers[k].shape = 7; + + } else { + + hits = __afl_cmp_map->headers[k].hits++; + + if (__afl_cmp_map->headers[k].shape < 7) { + + __afl_cmp_map->headers[k].shape = 7; + + } + + } + + __afl_cmp_map->headers[k].attribute = 1; hits &= CMP_MAP_H - 1; __afl_cmp_map->log[k][hits].v0 = val; @@ -1448,12 +1553,26 @@ void __cmplog_rtn_hook(u8 *ptr1, u8 *ptr2) { k = (k >> 4) ^ (k << 8); k &= CMP_MAP_W - 1; - __afl_cmp_map->headers[k].type = CMP_TYPE_RTN; + u32 hits; + + if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { + + __afl_cmp_map->headers[k].type = CMP_TYPE_RTN; + hits = 0; + __afl_cmp_map->headers[k].hits = 1; + __afl_cmp_map->headers[k].shape = 31; + + } else { + + hits = __afl_cmp_map->headers[k].hits++; + + if (__afl_cmp_map->headers[k].shape < 31) { - u32 hits = __afl_cmp_map->headers[k].hits; - __afl_cmp_map->headers[k].hits = hits + 1; + __afl_cmp_map->headers[k].shape = 31; - __afl_cmp_map->headers[k].shape = 31; + } + + } hits &= CMP_MAP_RTN_H - 1; __builtin_memcpy(((struct cmpfn_operands *)__afl_cmp_map->log[k])[hits].v0, diff --git a/instrumentation/cmplog-instructions-pass.cc b/instrumentation/cmplog-instructions-pass.cc index a74fb6c8..6ce1832f 100644 --- a/instrumentation/cmplog-instructions-pass.cc +++ b/instrumentation/cmplog-instructions-pass.cc @@ -420,6 +420,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) { IRB.CreateCall(cmplogHookIns8, args); break; case 128: +#ifdef WORD_SIZE_64 if (max_size == 128) { IRB.CreateCall(cmplogHookIns16, args); @@ -430,6 +431,9 @@ bool CmpLogInstructions::hookInstrs(Module &M) { } +#endif + break; + default: break; } diff --git a/instrumentation/llvm-ngram-coverage.h b/instrumentation/llvm-ngram-coverage.h index 12b666e9..666839c8 100644 --- a/instrumentation/llvm-ngram-coverage.h +++ b/instrumentation/llvm-ngram-coverage.h @@ -1,7 +1,7 @@ #ifndef AFL_NGRAM_CONFIG_H #define AFL_NGRAM_CONFIG_H -#include "../config.h" +#include "types.h" #if (MAP_SIZE_POW2 <= 16) typedef u16 PREV_LOC_T; diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index fe98f031..56022fa6 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -33,7 +33,26 @@ #define CMPLOG_INTROSPECTION //#define ARITHMETIC_LESSER_GREATER -///// Colorization +// CMP attribute enum +enum { + + IS_EQUAL = 1, + IS_GREATER = 2, + IS_LESSER = 4, + IS_FP = 8, + IS_FP_MOD = 16, + IS_INT_MOD = 32 + +}; + +// CMPLOG LVL +enum { + + LVL1 = 1, + LVL2 = 2, + LVL3 = 4 + +}; struct range { @@ -545,8 +564,8 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, unsigned long long unum; long long num; - // reverse atoi()/strnu?toll() is expensive, so we only to it in lvl == 3 - if (lvl & 4) { + // reverse atoi()/strnu?toll() is expensive, so we only to it in lvl 3 + if (lvl & LVL3) { if (afl->queue_cur->is_ascii) { @@ -618,7 +637,8 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // we only allow this for ascii2integer (above) if (unlikely(pattern == o_pattern)) { return 0; } - if ((lvl & 1) || ((lvl & 2) && (attr >= 8 && attr <= 15)) || attr >= 16) { + if ((lvl & LVL1) || ((lvl & LVL2) && (attr >= IS_FP && attr < IS_FP_MOD)) || + attr >= IS_FP_MOD) { if (SHAPE_BYTES(h->shape) >= 8 && *status != 1) { @@ -632,8 +652,8 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // if this is an fcmp (attr & 8 == 8) then do not compare the patterns - // due to a bug in llvm dynamic float bitcasts do not work :( // the value 16 means this is a +- 1.0 test case - if (its_len >= 8 && - ((*buf_64 == pattern && *o_buf_64 == o_pattern) || attr >= 16)) { + if (its_len >= 8 && ((*buf_64 == pattern && *o_buf_64 == o_pattern) || + attr >= IS_FP_MOD)) { u64 tmp_64 = *buf_64; *buf_64 = repl; @@ -674,7 +694,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (its_len >= 4 && ((*buf_32 == (u32)pattern && *o_buf_32 == (u32)o_pattern) || - attr >= 16)) { + attr >= IS_FP_MOD)) { u32 tmp_32 = *buf_32; *buf_32 = (u32)repl; @@ -708,7 +728,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (its_len >= 2 && ((*buf_16 == (u16)pattern && *o_buf_16 == (u16)o_pattern) || - attr >= 16)) { + attr >= IS_FP_MOD)) { u16 tmp_16 = *buf_16; *buf_16 = (u16)repl; @@ -738,7 +758,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (*status != 1) { // u8 - // if (its_len >= 1 && (attr <= 1 || attr >= 8)) + // if (its_len >= 1) // fprintf(stderr, // "TestU8: %u>=1 (idx=%u attr=%u) %x==%x %x==%x <= %x<-%x\n", // its_len, idx, attr, *buf_8, (u8)pattern, *o_buf_8, @@ -746,7 +766,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, if (its_len >= 1 && ((*buf_8 == (u8)pattern && *o_buf_8 == (u8)o_pattern) || - attr >= 16)) { + attr >= IS_FP_MOD)) { u8 tmp_8 = *buf_8; *buf_8 = (u8)repl; @@ -769,10 +789,11 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // in original buffer) #ifdef ARITHMETIC_LESSER_GREATER - if (lvl < 4) { return 0; } + if (lvl < LVL3) { return 0; } // lesser/greater FP comparison - if ((attr & 6) && (attr >= 8 && attr < 16)) { + if ((attr & (IS_LESSER + IS_GREATER)) && + (attr >= IS_FP && attr < IS_FP_MOD)) { u64 repl_new; if (SHAPE_BYTES(h->shape) == 4 && its_len >= 4) { @@ -869,7 +890,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - } else if ((attr & 6) && attr < 8) { + } else if ((attr & (IS_LESSER + IS_GREATER)) && attr < IS_FP) { // lesser/greater integer comparison @@ -903,6 +924,8 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } +#ifdef WORD_SIZE_64 + static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, u128 pattern, u128 repl, u128 o_pattern, u128 changed_val, u8 attr, u32 idx, @@ -917,15 +940,15 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, u8 backup[16]; u32 its_len = MIN(len - idx, taint_len); u32 shape = h->shape + 1; -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) size_t off = 0; -#else + #else size_t off = 16 - shape; -#endif + #endif if (its_len >= shape) { -#ifdef _DEBUG + #ifdef _DEBUG // fprintf(stderr, "TestUN: %u>=%u (len=%u idx=%u attr=%u off=%lu) (%u) ", // its_len, shape, len, idx, attr, off, do_reverse); u32 i; @@ -948,7 +971,7 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, for (i = 0; i < shape; i++) fprintf(stderr, "%02x", o_r[off + i]); fprintf(stderr, "\n"); -#endif + #endif if (!memcmp(ptr, p + off, shape) && !memcmp(o_ptr, o_p + off, shape)) { @@ -957,15 +980,15 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } -#ifdef COMBINE + #ifdef COMBINE if (*status == 1) { memcpy(cbuf + idx, r, shape); } -#endif + #endif memcpy(ptr, backup, shape); -#ifdef _DEBUG + #ifdef _DEBUG fprintf(stderr, "Status=%u\n", *status); -#endif + #endif } @@ -990,6 +1013,8 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, } +#endif + static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) { u8 *b = (u8 *)&v; @@ -1040,21 +1065,22 @@ static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) { } +#ifdef WORD_SIZE_64 static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) { u8 *b = (u8 *)&v; u32 k; u8 cons_ff = 0, cons_0 = 0; -#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) + #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) u32 off = 0; for (k = 0; k < size; ++k) { -#else - u32 off = 16 - size; + #else + u32 off = 16 - size; for (k = 16 - size; k < 16; ++k) { -#endif + #endif if (b[k] == 0) { ++cons_0; @@ -1077,6 +1103,8 @@ static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) { } +#endif + static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, u32 lvl, struct tainted *taint) { @@ -1091,11 +1119,13 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u8 found_one = 0; /* loop cmps are useless, detect and ignore them */ +#ifdef WORD_SIZE_64 u128 s128_v0 = 0, s128_v1 = 0, orig_s128_v0 = 0, orig_s128_v1 = 0; - u64 s_v0, s_v1; - u8 s_v0_fixed = 1, s_v1_fixed = 1; - u8 s_v0_inc = 1, s_v1_inc = 1; - u8 s_v0_dec = 1, s_v1_dec = 1; +#endif + u64 s_v0, s_v1; + u8 s_v0_fixed = 1, s_v1_fixed = 1; + u8 s_v0_inc = 1, s_v1_inc = 1; + u8 s_v0_dec = 1, s_v1_dec = 1; switch (SHAPE_BYTES(h->shape)) { @@ -1110,7 +1140,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } // FP handling only from lvl 2 onwards - if ((h->attribute & 8) && lvl < 2) return 0; + if ((h->attribute & IS_FP) && lvl < LVL2) return 0; for (i = 0; i < loggeds; ++i) { @@ -1162,6 +1192,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } +#ifdef WORD_SIZE_64 if (unlikely(is_n)) { s128_v0 = ((u128)o->v0) + (((u128)o->v0_128) << 64); @@ -1171,6 +1202,8 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } +#endif + for (idx = 0; idx < len; ++idx) { if (have_taint) { @@ -1195,6 +1228,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, status = 0; +#ifdef WORD_SIZE_64 if (is_n) { // _ExtInt special case including u128 if (s128_v0 != orig_s128_v0 && orig_s128_v0 != orig_s128_v1) { @@ -1239,11 +1273,13 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } +#endif + // even for u128 and _ExtInt we do cmp_extend_encoding() because // if we got here their own special trials failed and it might just be // a cast from e.g. u64 to u128 from the input data. - if ((o->v0 != orig_o->v0 || lvl >= 4) && orig_o->v0 != orig_o->v1) { + if ((o->v0 != orig_o->v0 || lvl >= LVL3) && orig_o->v0 != orig_o->v1) { if (unlikely(cmp_extend_encoding( afl, h, o->v0, o->v1, orig_o->v0, orig_o->v1, h->attribute, idx, @@ -1263,7 +1299,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } status = 0; - if ((o->v1 != orig_o->v1 || lvl >= 4) && orig_o->v0 != orig_o->v1) { + if ((o->v1 != orig_o->v1 || lvl >= LVL3) && orig_o->v0 != orig_o->v1) { if (unlikely(cmp_extend_encoding( afl, h, o->v1, o->v0, orig_o->v1, orig_o->v0, h->attribute, idx, @@ -1521,13 +1557,6 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } - // do it manually, forkserver clear only afl->fsrv.trace_bits - memset(afl->shm.cmp_map->headers, 0, sizeof(afl->shm.cmp_map->headers)); - - if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) { return 1; } - - memcpy(afl->orig_cmp_map, afl->shm.cmp_map, sizeof(struct cmp_map)); - struct tainted *taint = NULL; if (!afl->queue_cur->taint || !afl->queue_cur->cmplog_colorinput) { @@ -1562,8 +1591,6 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { buf = afl->queue_cur->cmplog_colorinput; taint = afl->queue_cur->taint; - // reget the cmplog information - if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) { return 1; } } @@ -1583,9 +1610,13 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { u32 cmp_locations = 0; #endif - // do it manually, forkserver clear only afl->fsrv.trace_bits - memset(afl->shm.cmp_map->headers, 0, sizeof(afl->shm.cmp_map->headers)); - + // Generate the cmplog data + // manually clear the full cmp_map + memset(afl->shm.cmp_map, 0, sizeof(struct cmp_map)); + if (unlikely(common_fuzz_cmplog_stuff(afl, orig_buf, len))) { return 1; } + memcpy(afl->orig_cmp_map, afl->shm.cmp_map, sizeof(struct cmp_map)); + // manually clear just the headers + memset(afl->shm.cmp_map->headers, 0, sizeof(struct cmp_header)); if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) { return 1; } u64 orig_hit_cnt, new_hit_cnt; @@ -1602,7 +1633,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { u32 cmplog_lvl = afl->cmplog_lvl; if (!cmplog_done) { - lvl = 1; + lvl = LVL1; } else { @@ -1610,8 +1641,8 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } - if (cmplog_lvl >= 2 && cmplog_done < 2) { lvl += 2; } - if (cmplog_lvl >= 3 && cmplog_done < 3) { lvl += 4; } + if (cmplog_lvl >= 2 && cmplog_done < 2) { lvl += LVL2; } + if (cmplog_lvl >= 3 && cmplog_done < 3) { lvl += LVL3; } #ifdef COMBINE u8 *cbuf = afl_realloc((void **)&afl->in_scratch_buf, len + 128); @@ -1668,7 +1699,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } - } else if (lvl & 1) { + } else if (lvl & LVL1) { if (unlikely(rtn_fuzz(afl, k, orig_buf, buf, cbuf, len, taint))) { -- cgit 1.4.1 From e2d9dc16e3d856b416aa7c84bf10242334c860c9 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Mon, 18 Jan 2021 21:36:19 +0100 Subject: fix compiler warning avoid signess difference in comparisons --- include/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/config.h b/include/config.h index c0cd0ef1..973bbcbb 100644 --- a/include/config.h +++ b/include/config.h @@ -194,7 +194,7 @@ /* The same, for the test case minimizer: */ -#define TMIN_MAX_FILE (10 * 1024 * 1024U) +#define TMIN_MAX_FILE (10 * 1024 * 1024) /* Block normalization steps for afl-tmin: */ -- cgit 1.4.1 From a9ebf72a8408f993e6279ba853c49e31310cf73f Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 18 Jan 2021 22:19:04 +0100 Subject: cmp map memset fix --- src/afl-fuzz-redqueen.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 56022fa6..4488d220 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -110,7 +110,7 @@ static struct range *pop_biggest_range(struct range **ranges) { static void dump(char *txt, u8 *buf, u32 len) { u32 i; - fprintf(stderr, "DUMP %s %llx ", txt, hash64(buf, len, HASH_CONST)); + fprintf(stderr, "DUMP %s %016llx ", txt, hash64(buf, len, HASH_CONST)); for (i = 0; i < len; i++) fprintf(stderr, "%02x", buf[i]); fprintf(stderr, "\n"); @@ -255,12 +255,6 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, memcpy(changed, buf, len); type_replace(afl, changed, len); -#ifdef _DEBUG - dump("ORIG", buf, len); - dump("CHAN", changed, len); - fprintf(stderr, "CKSUM %llx (%u)\n", exec_cksum, afl->fsrv.map_size); -#endif - while ((rng = pop_biggest_range(&ranges)) != NULL && afl->stage_cur < afl->stage_max) { @@ -949,8 +943,8 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, if (its_len >= shape) { #ifdef _DEBUG - // fprintf(stderr, "TestUN: %u>=%u (len=%u idx=%u attr=%u off=%lu) (%u) ", - // its_len, shape, len, idx, attr, off, do_reverse); + fprintf(stderr, "TestUN: %u>=%u (len=%u idx=%u attr=%u off=%lu) (%u) ", + its_len, shape, len, idx, attr, off, do_reverse); u32 i; u8 *o_r = (u8 *)&changed_val; for (i = 0; i < shape; i++) @@ -1545,12 +1539,6 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { u8 r = 1; - if (unlikely(!afl->orig_cmp_map)) { - - afl->orig_cmp_map = ck_alloc_nozero(sizeof(struct cmp_map)); - - } - if (unlikely(!afl->pass_stats)) { afl->pass_stats = ck_alloc(sizeof(struct afl_pass_stat) * CMP_MAP_W); @@ -1583,10 +1571,6 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { #endif -#ifdef _DEBUG - dump("NEW ", buf, len); -#endif - } else { buf = afl->queue_cur->cmplog_colorinput; @@ -1611,14 +1595,27 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { #endif // Generate the cmplog data + // manually clear the full cmp_map memset(afl->shm.cmp_map, 0, sizeof(struct cmp_map)); if (unlikely(common_fuzz_cmplog_stuff(afl, orig_buf, len))) { return 1; } + if (unlikely(!afl->orig_cmp_map)) { + + afl->orig_cmp_map = ck_alloc_nozero(sizeof(struct cmp_map)); + + } + memcpy(afl->orig_cmp_map, afl->shm.cmp_map, sizeof(struct cmp_map)); - // manually clear just the headers - memset(afl->shm.cmp_map->headers, 0, sizeof(struct cmp_header)); + memset(afl->shm.cmp_map->headers, 0, sizeof(struct cmp_header) * CMP_MAP_W); if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) { return 1; } +#ifdef _DEBUG + dump("ORIG", orig_buf, len); + dump("NEW ", buf, len); +#endif + + // Start insertion loop + u64 orig_hit_cnt, new_hit_cnt; u64 orig_execs = afl->fsrv.total_execs; orig_hit_cnt = afl->queued_paths + afl->unique_crashes; -- cgit 1.4.1 From ca1eb32552636240acbb85f0b52668e23e4429e4 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 19 Jan 2021 10:16:12 +0100 Subject: fix compiles --- utils/aflpp_driver/aflpp_driver.c | 1 + utils/defork/defork.c | 1 + 2 files changed, 2 insertions(+) diff --git a/utils/aflpp_driver/aflpp_driver.c b/utils/aflpp_driver/aflpp_driver.c index 30e6ebb9..7bb929b2 100644 --- a/utils/aflpp_driver/aflpp_driver.c +++ b/utils/aflpp_driver/aflpp_driver.c @@ -47,6 +47,7 @@ $AFL_HOME/afl-fuzz -i IN -o OUT ./a.out #include #include "config.h" +#include "types.h" #include "cmplog.h" #ifdef _DEBUG diff --git a/utils/defork/defork.c b/utils/defork/defork.c index f50b9a4b..c9be3283 100644 --- a/utils/defork/defork.c +++ b/utils/defork/defork.c @@ -5,6 +5,7 @@ #include #include "../../include/config.h" +#include "../../include/types.h" /* we want to fork once (for the afl++ forkserver), then immediately return as child on subsequent forks. */ -- cgit 1.4.1 From e91f3b0de65376b001d45892cc6bdd2fcafde949 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 19 Jan 2021 10:41:42 +0100 Subject: codeql fix --- docs/Changelog.md | 1 + src/afl-fuzz-run.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index e0f8e9bf..60f09ca5 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -19,6 +19,7 @@ sending a mail to . for reporting) - if determinstic mode is active (-D, or -M without -d) then we sync after every queue entry as this can take very long time otherwise + - better detection if a target needs a large shared map - switched to a faster RNG - added hghwng's patch for faster trace map analysis - afl-cc diff --git a/src/afl-fuzz-run.c b/src/afl-fuzz-run.c index b597488b..17c305ed 100644 --- a/src/afl-fuzz-run.c +++ b/src/afl-fuzz-run.c @@ -424,7 +424,7 @@ u8 calibrate_case(afl_state_t *afl, struct queue_entry *q, u8 *use_mem, if (unlikely(afl->fixed_seed)) { - diff_us = (afl->fsrv.exec_tmout - 1) * afl->stage_max; + diff_us = (u64)(afl->fsrv.exec_tmout - 1) * (u64)afl->stage_max; } else { -- cgit 1.4.1 From 95ee2cdd574dabf39d662cd2a76542b733d374ac Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 19 Jan 2021 13:05:42 +0100 Subject: cleanup --- src/afl-fuzz-redqueen.c | 83 ++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 4488d220..1c5b95f6 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -29,7 +29,7 @@ #include "cmplog.h" //#define _DEBUG -//#define COMBINE +#define COMBINE #define CMPLOG_INTROSPECTION //#define ARITHMETIC_LESSER_GREATER @@ -1103,14 +1103,13 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, u32 lvl, struct tainted *taint) { struct cmp_header *h = &afl->shm.cmp_map->headers[key]; - struct tainted * t; - u32 i, j, idx, taint_len; - u32 have_taint = 1, is_n = 0; - u32 loggeds = h->hits; - if (h->hits > CMP_MAP_H) { loggeds = CMP_MAP_H; } + // FP handling only from lvl 2 onwards + if ((h->attribute & IS_FP) && lvl < LVL2) { return 0; } - u8 status = 0; - u8 found_one = 0; + struct tainted *t; + u32 i, j, idx, taint_len, loggeds; + u32 have_taint = 1, is_n = 0; + u8 status = 0, found_one = 0; /* loop cmps are useless, detect and ignore them */ #ifdef WORD_SIZE_64 @@ -1121,6 +1120,16 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u8 s_v0_inc = 1, s_v1_inc = 1; u8 s_v0_dec = 1, s_v1_dec = 1; + if (h->hits > CMP_MAP_H) { + + loggeds = CMP_MAP_H; + + } else { + + loggeds = h->hits; + + } + switch (SHAPE_BYTES(h->shape)) { case 1: @@ -1133,9 +1142,6 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } - // FP handling only from lvl 2 onwards - if ((h->attribute & IS_FP) && lvl < LVL2) return 0; - for (i = 0; i < loggeds; ++i) { struct cmp_operands *o = &afl->shm.cmp_map->log[key][i]; @@ -1742,51 +1748,56 @@ exit_its: } #ifdef COMBINE - // copy the current virgin bits so we can recover the information - u8 *virgin_save = afl_realloc((void **)&afl->eff_buf, afl->shm.map_size); - memcpy(virgin_save, afl->virgin_bits, afl->shm.map_size); - // reset virgin bits to the backup previous to redqueen - memcpy(afl->virgin_bits, virgin_backup, afl->shm.map_size); + if (afl->queued_paths + afl->unique_crashes > orig_hit_cnt + 1) { - u8 status = 0; - its_fuzz(afl, cbuf, len, &status); + // copy the current virgin bits so we can recover the information + u8 *virgin_save = afl_realloc((void **)&afl->eff_buf, afl->shm.map_size); + memcpy(virgin_save, afl->virgin_bits, afl->shm.map_size); + // reset virgin bits to the backup previous to redqueen + memcpy(afl->virgin_bits, virgin_backup, afl->shm.map_size); + + u8 status = 0; + its_fuzz(afl, cbuf, len, &status); // now combine with the saved virgin bits #ifdef WORD_SIZE_64 - u64 *v = (u64 *)afl->virgin_bits; - u64 *s = (u64 *)virgin_save; - u32 i; - for (i = 0; i < (afl->shm.map_size >> 3); i++) { + u64 *v = (u64 *)afl->virgin_bits; + u64 *s = (u64 *)virgin_save; + u32 i; + for (i = 0; i < (afl->shm.map_size >> 3); i++) { - v[i] &= s[i]; + v[i] &= s[i]; - } + } #else - u32 *v = (u64 *)afl->virgin_bits; - u32 *s = (u64 *)virgin_save; - u32 i; - for (i = 0; i < (afl->shm.map_size >> 2); i++) { + u32 *v = (u64 *)afl->virgin_bits; + u32 *s = (u64 *)virgin_save; + u32 i; + for (i = 0; i < (afl->shm.map_size >> 2); i++) { - v[i] &= s[i]; + v[i] &= s[i]; - } + } #endif #ifdef _DEBUG - dump("COMB", cbuf, len); - if (status == 1) { + dump("COMB", cbuf, len); + if (status == 1) { - fprintf(stderr, "NEW COMBINED\n"); + fprintf(stderr, "NEW COMBINED\n"); - } else { + } else { - fprintf(stderr, "NO new combined\n"); + fprintf(stderr, "NO new combined\n"); - } + } #endif + + } + #endif new_hit_cnt = afl->queued_paths + afl->unique_crashes; -- cgit 1.4.1 From 292f91a55f6af5e06b41b429e55f65b7df4d8d16 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Tue, 19 Jan 2021 13:16:39 +0100 Subject: tiny scan-build nags fixed --- qemu_mode/qemuafl | 2 +- src/afl-fuzz.c | 6 +++--- unicorn_mode/unicornafl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index 5400ce88..21ff3438 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit 5400ce883a751582473665d8fd18f8e8f9d14cde +Subproject commit 21ff34383764a8c6f66509b3b8d5282468c721e1 diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index bb2674f0..e6317f43 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -586,7 +586,7 @@ int main(int argc, char **argv_orig, char **envp) { if (afl->timeout_given) { FATAL("Multiple -t options not supported"); } - if (sscanf(optarg, "%u%c", &afl->fsrv.exec_tmout, &suffix) < 1 || + if (!optarg || sscanf(optarg, "%u%c", &afl->fsrv.exec_tmout, &suffix) < 1 || optarg[0] == '-') { FATAL("Bad syntax used for -t"); @@ -768,7 +768,7 @@ int main(int argc, char **argv_orig, char **envp) { case 'V': { afl->most_time_key = 1; - if (sscanf(optarg, "%llu", &afl->most_time) < 1 || optarg[0] == '-') { + if (!optarg || sscanf(optarg, "%llu", &afl->most_time) < 1 || optarg[0] == '-') { FATAL("Bad syntax used for -V"); @@ -779,7 +779,7 @@ int main(int argc, char **argv_orig, char **envp) { case 'E': { afl->most_execs_key = 1; - if (sscanf(optarg, "%llu", &afl->most_execs) < 1 || optarg[0] == '-') { + if (!optarg || sscanf(optarg, "%llu", &afl->most_execs) < 1 || optarg[0] == '-') { FATAL("Bad syntax used for -E"); diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 8cca4801..1c88501b 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 8cca4801adb767dce7cf72202d7d25bdb420cf7d +Subproject commit 1c88501b435fa10f95c8df0bbe47ccb5313b0428 -- cgit 1.4.1 From 0367f6c72339ba655956d7e17b0b27c92b22d781 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 19 Jan 2021 14:03:10 +0100 Subject: cleanup and rename _DISCARD->_SKIP --- instrumentation/README.instrument_list.md | 2 +- instrumentation/afl-compiler-rt.o.c | 2 +- src/afl-cc.c | 6 +++--- src/afl-fuzz-bitmap.c | 1 - src/afl-fuzz.c | 1 - src/afl-ld-lto.c | 1 - 6 files changed, 5 insertions(+), 8 deletions(-) diff --git a/instrumentation/README.instrument_list.md b/instrumentation/README.instrument_list.md index 83197954..b47b50f6 100644 --- a/instrumentation/README.instrument_list.md +++ b/instrumentation/README.instrument_list.md @@ -41,7 +41,7 @@ in any function where you want: * `__AFL_COVERAGE_ON();` - enable coverage from this point onwards * `__AFL_COVERAGE_OFF();` - disable coverage from this point onwards * `__AFL_COVERAGE_DISCARD();` - reset all coverage gathered until this point - * `__AFL_COVERAGE_ABORT();` - mark this test case as unimportant. Whatever happens, afl-fuzz will ignore it. + * `__AFL_COVERAGE_SKIP();` - mark this test case as unimportant. Whatever happens, afl-fuzz will ignore it. ## 3) Selective instrumenation with AFL_LLVM_ALLOWLIST/AFL_LLVM_DENYLIST diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index b735d8df..e31bff16 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1429,7 +1429,7 @@ void __afl_coverage_discard() { } // discard the testcase -void __afl_coverage_abort() { +void __afl_coverage_skip() { __afl_coverage_discard(); diff --git a/src/afl-cc.c b/src/afl-cc.c index 8fb42718..1379488e 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -835,7 +835,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE()=int __afl_selective_coverage = 1;" "extern \"C\" void __afl_coverage_discard();" - "extern \"C\" void __afl_coverage_abort();" + "extern \"C\" void __afl_coverage_skip();" "extern \"C\" void __afl_coverage_on();" "extern \"C\" void __afl_coverage_off();"; @@ -844,7 +844,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE()=int __afl_selective_coverage = 1;" "void __afl_coverage_discard();" - "void __afl_coverage_abort();" + "void __afl_coverage_skip();" "void __afl_coverage_on();" "void __afl_coverage_off();"; @@ -857,7 +857,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_OFF()=__afl_coverage_off()"; cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_DISCARD()=__afl_coverage_discard()"; - cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_ABORT()=__afl_coverage_abort()"; + cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_SKIP()=__afl_coverage_skip()"; cc_params[cc_par_cnt++] = "-D__AFL_FUZZ_TESTCASE_BUF=(__afl_fuzz_ptr ? __afl_fuzz_ptr : " "__afl_fuzz_alt_ptr)"; diff --git a/src/afl-fuzz-bitmap.c b/src/afl-fuzz-bitmap.c index ed8c2510..586f3990 100644 --- a/src/afl-fuzz-bitmap.c +++ b/src/afl-fuzz-bitmap.c @@ -703,7 +703,6 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) { if (!classified) { classify_counts(&afl->fsrv); - // classified = 1; } diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index e6317f43..7facf261 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -337,7 +337,6 @@ int main(int argc, char **argv_orig, char **envp) { if (get_afl_env("AFL_DEBUG")) { debug = afl->debug = 1; } - // map_size = get_map_size(); afl_state_init(afl, map_size); afl->debug = debug; afl_fsrv_init(&afl->fsrv); diff --git a/src/afl-ld-lto.c b/src/afl-ld-lto.c index 7a4d9132..0671d1c4 100644 --- a/src/afl-ld-lto.c +++ b/src/afl-ld-lto.c @@ -253,7 +253,6 @@ static void edit_params(int argc, char **argv) { int main(int argc, char **argv) { s32 pid, i, status; - // u8 * ptr; char thecwd[PATH_MAX]; if (getenv("AFL_LD_CALLER") != NULL) { -- cgit 1.4.1 From ed9f94c5b90d1785d4c7c8c8ef5c1bf2ba1b9fef Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 19 Jan 2021 14:20:43 +0100 Subject: fix CI --- test/test-basic.sh | 8 ++++---- test/test-gcc-plugin.sh | 4 ++-- test/test-llvm-lto.sh | 2 +- test/test-llvm.sh | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/test-basic.sh b/test/test-basic.sh index 8296b6cc..fcac8ca3 100755 --- a/test/test-basic.sh +++ b/test/test-basic.sh @@ -27,13 +27,13 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc rm -f test-instr.plain.0 test-instr.plain.1 SKIP= TUPLES=`echo 1|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` - test "$TUPLES" -gt 2 -a "$TUPLES" -lt 12 && { + test "$TUPLES" -gt 1 -a "$TUPLES" -lt 12 && { $ECHO "$GREEN[+] ${AFL_GCC} run reported $TUPLES instrumented locations which is fine" } || { $ECHO "$RED[!] ${AFL_GCC} instrumentation produces weird numbers: $TUPLES" CODE=1 } - test "$TUPLES" -lt 4 && SKIP=1 + test "$TUPLES" -lt 3 && SKIP=1 true # this is needed because of the test above } || { $ECHO "$RED[!] ${AFL_GCC} failed" @@ -147,13 +147,13 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc } rm -f test-instr.plain.0 test-instr.plain.1 TUPLES=`echo 1|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` - test "$TUPLES" -gt 2 -a "$TUPLES" -lt 12 && { + test "$TUPLES" -gt 1 -a "$TUPLES" -lt 12 && { $ECHO "$GREEN[+] ${AFL_GCC} run reported $TUPLES instrumented locations which is fine" } || { $ECHO "$RED[!] ${AFL_GCC} instrumentation produces weird numbers: $TUPLES" CODE=1 } - test "$TUPLES" -lt 4 && SKIP=1 + test "$TUPLES" -lt 3 && SKIP=1 true # this is needed because of the test above } || { $ECHO "$RED[!] ${AFL_GCC} failed" diff --git a/test/test-gcc-plugin.sh b/test/test-gcc-plugin.sh index 9fe63ea3..0157d89f 100755 --- a/test/test-gcc-plugin.sh +++ b/test/test-gcc-plugin.sh @@ -19,14 +19,14 @@ test -e ../afl-gcc-fast -a -e ../afl-compiler-rt.o && { } || { $ECHO "$GREEN[+] gcc_plugin instrumentation present and working correctly" TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain.gccpi 2>&1 | grep Captur | awk '{print$3}'` - test "$TUPLES" -gt 3 -a "$TUPLES" -lt 9 && { + test "$TUPLES" -gt 2 -a "$TUPLES" -lt 9 && { $ECHO "$GREEN[+] gcc_plugin run reported $TUPLES instrumented locations which is fine" } || { $ECHO "$RED[!] gcc_plugin instrumentation produces a weird numbers: $TUPLES" $ECHO "$YELLOW[-] this is a known issue in gcc, not afl++. It is not flagged as an error because travis builds would all fail otherwise :-(" #CODE=1 } - test "$TUPLES" -lt 4 && SKIP=1 + test "$TUPLES" -lt 3 && SKIP=1 true } } || { diff --git a/test/test-llvm-lto.sh b/test/test-llvm-lto.sh index d0b8f8fc..a931afb7 100755 --- a/test/test-llvm-lto.sh +++ b/test/test-llvm-lto.sh @@ -25,7 +25,7 @@ test -e ../afl-clang-lto -a -e ../afl-llvm-lto-instrumentation.so && { } || { $ECHO "$GREEN[+] llvm_mode LTO instrumentation present and working correctly" TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` - test "$TUPLES" -gt 3 -a "$TUPLES" -lt 7 && { + test "$TUPLES" -gt 2 -a "$TUPLES" -lt 7 && { $ECHO "$GREEN[+] llvm_mode LTO run reported $TUPLES instrumented locations which is fine" } || { $ECHO "$RED[!] llvm_mode LTO instrumentation produces weird numbers: $TUPLES" diff --git a/test/test-llvm.sh b/test/test-llvm.sh index e5005d72..c968d5a9 100755 --- a/test/test-llvm.sh +++ b/test/test-llvm.sh @@ -25,13 +25,13 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && { } || { $ECHO "$GREEN[+] llvm_mode instrumentation present and working correctly" TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` - test "$TUPLES" -gt 3 -a "$TUPLES" -lt 8 && { + test "$TUPLES" -gt 2 -a "$TUPLES" -lt 8 && { $ECHO "$GREEN[+] llvm_mode run reported $TUPLES instrumented locations which is fine" } || { $ECHO "$RED[!] llvm_mode instrumentation produces weird numbers: $TUPLES" CODE=1 } - test "$TUPLES" -lt 4 && SKIP=1 + test "$TUPLES" -lt 3 && SKIP=1 true } } || { @@ -129,7 +129,7 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && { AFL_LLVM_INSTRUMENT=CFG AFL_LLVM_INSTRIM_LOOPHEAD=1 ../afl-clang-fast -o test-instr.instrim ../test-instr.c > /dev/null 2>test.out test -e test-instr.instrim && { TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.instrim 2>&1 | grep Captur | awk '{print$3}'` - test "$TUPLES" -gt 2 -a "$TUPLES" -lt 5 && { + test "$TUPLES" -gt 1 -a "$TUPLES" -lt 5 && { $ECHO "$GREEN[+] llvm_mode InsTrim reported $TUPLES instrumented locations which is fine" } || { $ECHO "$RED[!] llvm_mode InsTrim instrumentation produces weird numbers: $TUPLES" -- cgit 1.4.1 From 86c567fa3a37e9181b5e692b53b5fae07921cc33 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Tue, 19 Jan 2021 16:49:00 +0100 Subject: update qemuafl + unicorn for include changes --- qemu_mode/QEMUAFL_VERSION | 2 +- unicorn_mode/UNICORNAFL_VERSION | 2 +- unicorn_mode/build_unicorn_support.sh | 5 +++-- unicorn_mode/unicornafl | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index b73ccc52..9d6d7dba 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -5400ce883a +6ea7398ee3 diff --git a/unicorn_mode/UNICORNAFL_VERSION b/unicorn_mode/UNICORNAFL_VERSION index f5537ed8..2dbc30b8 100644 --- a/unicorn_mode/UNICORNAFL_VERSION +++ b/unicorn_mode/UNICORNAFL_VERSION @@ -1 +1 @@ -768e6bb2 +83d1b426 diff --git a/unicorn_mode/build_unicorn_support.sh b/unicorn_mode/build_unicorn_support.sh index 8f6ceab7..c32eb3e1 100755 --- a/unicorn_mode/build_unicorn_support.sh +++ b/unicorn_mode/build_unicorn_support.sh @@ -177,8 +177,9 @@ echo "[*] Checking out $UNICORNAFL_VERSION" sh -c 'git stash && git stash drop' 1>/dev/null 2>/dev/null git checkout "$UNICORNAFL_VERSION" || exit 1 -echo "[*] making sure config.h matches" -cp "../../config.h" "." || exit 1 +echo "[*] making sure afl++ header files match" +cp "../../include/config.h" "." || exit 1 +cp "../../include/types.h" "." || exit 1 echo "[*] Configuring Unicorn build..." diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 8cca4801..83d1b426 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 8cca4801adb767dce7cf72202d7d25bdb420cf7d +Subproject commit 83d1b426be5d373edcc81576f58a10f617df143f -- cgit 1.4.1 From 473b3e5fb0fec84ebca31917bef74d41c5c1655c Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Tue, 19 Jan 2021 19:45:53 +0100 Subject: updated unicornafl qemu versions --- qemu_mode/QEMUAFL_VERSION | 2 +- unicorn_mode/UNICORNAFL_VERSION | 2 +- unicorn_mode/unicornafl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index b73ccc52..9d6d7dba 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -5400ce883a +6ea7398ee3 diff --git a/unicorn_mode/UNICORNAFL_VERSION b/unicorn_mode/UNICORNAFL_VERSION index f5537ed8..2dbc30b8 100644 --- a/unicorn_mode/UNICORNAFL_VERSION +++ b/unicorn_mode/UNICORNAFL_VERSION @@ -1 +1 @@ -768e6bb2 +83d1b426 diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 1c88501b..83d1b426 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 1c88501b435fa10f95c8df0bbe47ccb5313b0428 +Subproject commit 83d1b426be5d373edcc81576f58a10f617df143f -- cgit 1.4.1 From e7b572af3608e2d097aad17408ad4853befdc02c Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 20 Jan 2021 01:49:32 +0100 Subject: bugfix and new transform detection feature --- instrumentation/afl-compiler-rt.o.c | 14 +- src/afl-fuzz-redqueen.c | 430 ++++++++++++++++++++++++++++++++---- src/afl-fuzz.c | 14 ++ 3 files changed, 416 insertions(+), 42 deletions(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 0ce96673..a290f110 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1545,6 +1545,18 @@ static int area_is_mapped(void *ptr, size_t len) { void __cmplog_rtn_hook(u8 *ptr1, u8 *ptr2) { + /* + u32 i; + if (!area_is_mapped(ptr1, 32) || !area_is_mapped(ptr2, 32)) return; + fprintf(stderr, "rtn arg0="); + for (i = 0; i < 8; i++) + fprintf(stderr, "%02x", ptr1[i]); + fprintf(stderr, " arg1="); + for (i = 0; i < 8; i++) + fprintf(stderr, "%02x", ptr2[i]); + fprintf(stderr, "\n"); + */ + if (unlikely(!__afl_cmp_map)) return; if (!area_is_mapped(ptr1, 32) || !area_is_mapped(ptr2, 32)) return; @@ -1555,7 +1567,7 @@ void __cmplog_rtn_hook(u8 *ptr1, u8 *ptr2) { u32 hits; - if (__afl_cmp_map->headers[k].type != CMP_TYPE_INS) { + if (__afl_cmp_map->headers[k].type != CMP_TYPE_RTN) { __afl_cmp_map->headers[k].type = CMP_TYPE_RTN; hits = 0; diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 1c5b95f6..bf41863e 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -30,18 +30,21 @@ //#define _DEBUG #define COMBINE -#define CMPLOG_INTROSPECTION +//#define CMPLOG_INTROSPECTION //#define ARITHMETIC_LESSER_GREATER +//#define TRANSFORM // CMP attribute enum enum { - IS_EQUAL = 1, - IS_GREATER = 2, - IS_LESSER = 4, - IS_FP = 8, - IS_FP_MOD = 16, - IS_INT_MOD = 32 + IS_EQUAL = 1, // arithemtic equal comparison + IS_GREATER = 2, // arithmetic greater comparison + IS_LESSER = 4, // arithmetic lesser comparison + IS_FP = 8, // is a floating point, not an integer + /* --- below are internal settings, not from target cmplog */ + IS_FP_MOD = 16, // arithemtic changed floating point + IS_INT_MOD = 32, // arithmetic changed interger + IS_TRANSFORM = 64 // transformed integer }; @@ -466,6 +469,7 @@ static u8 its_fuzz(afl_state_t *afl, u8 *buf, u32 len, u8 *status) { } +#ifdef TRANSFORM static int strntoll(const char *str, size_t sz, char **end, int base, long long *out) { @@ -513,6 +517,8 @@ static int strntoull(const char *str, size_t sz, char **end, int base, } +#endif + static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u64 pattern, u64 repl, u64 o_pattern, u64 changed_val, u8 attr, u32 idx, u32 taint_len, @@ -553,14 +559,15 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u32 its_len = MIN(len - idx, taint_len); - u8 * endptr; - u8 use_num = 0, use_unum = 0; - unsigned long long unum; - long long num; - +#ifdef TRANSFORM // reverse atoi()/strnu?toll() is expensive, so we only to it in lvl 3 if (lvl & LVL3) { + u8 * endptr; + u8 use_num = 0, use_unum = 0; + unsigned long long unum; + long long num; + if (afl->queue_cur->is_ascii) { endptr = buf_8; @@ -575,11 +582,11 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } -#ifdef _DEBUG + #ifdef _DEBUG if (idx == 0) fprintf(stderr, "ASCII is=%u use_num=%u use_unum=%u idx=%u %llx==%llx\n", afl->queue_cur->is_ascii, use_num, use_unum, idx, num, pattern); -#endif + #endif // num is likely not pattern as atoi("AAA") will be zero... if (use_num && ((u64)num == pattern || !num)) { @@ -626,8 +633,201 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } + // Try to identify transform magic + if (pattern != o_pattern && repl == changed_val && attr <= IS_EQUAL) { + + u64 *ptr = (u64 *)&buf[idx]; + u64 *o_ptr = (u64 *)&orig_buf[idx]; + u64 b_val, o_b_val, mask; + + switch (SHAPE_BYTES(h->shape)) { + + case 0: + case 1: + b_val = (u64)(*ptr % 0x100); + o_b_val = (u64)(*o_ptr % 0x100); + mask = 0xff; + break; + case 2: + case 3: + b_val = (u64)(*ptr % 0x10000); + o_b_val = (u64)(*o_ptr % 0x10000); + mask = 0xffff; + break; + case 4: + case 5: + case 6: + case 7: + b_val = (u64)(*ptr % 0x100000000); + o_b_val = (u64)(*o_ptr % 0x100000000); + mask = 0xffffffff; + break; + default: + b_val = *ptr; + o_b_val = *o_ptr; + mask = 0xffffffffffffffff; + + } + + // test for arithmetic, eg. "if ((user_val - 0x1111) == 0x1234) ..." + s64 diff = pattern - b_val; + s64 o_diff = o_pattern - o_b_val; + /* + fprintf(stderr, "DIFF1 idx=%03u shape=%02u %llx-%llx=%lx\n", idx, + h->shape + 1, o_pattern, o_b_val, o_diff); + fprintf(stderr, "DIFF1 %016llx %llx-%llx=%lx\n", repl, pattern, + b_val, diff);*/ + if (diff == o_diff && diff) { + + // this could be an arithmetic transformation + + u64 new_repl = (u64)((s64)repl - diff); + // fprintf(stderr, "SAME DIFF %llx->%llx\n", repl, new_repl); + + if (unlikely(cmp_extend_encoding( + afl, h, pattern, new_repl, o_pattern, repl, IS_TRANSFORM, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + + return 1; + + } + + if (*status == 1) { fprintf(stderr, "FOUND!\n"); } + + } + + // test for XOR, eg. "if ((user_val ^ 0xabcd) == 0x1234) ..." + if (*status != 1) { + + diff = pattern ^ b_val; + s64 o_diff = o_pattern ^ o_b_val; + + /* fprintf(stderr, "DIFF2 idx=%03u shape=%02u %llx-%llx=%lx\n", + idx, h->shape + 1, o_pattern, o_b_val, o_diff); fprintf(stderr, + "DIFF2 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);*/ + if (diff == o_diff && diff) { + + // this could be a XOR transformation + + u64 new_repl = (u64)((s64)repl ^ diff); + // fprintf(stderr, "SAME DIFF %llx->%llx\n", repl, new_repl); + + if (unlikely(cmp_extend_encoding( + afl, h, pattern, new_repl, o_pattern, repl, IS_TRANSFORM, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + + return 1; + + } + + if (*status == 1) { fprintf(stderr, "FOUND!\n"); } + + } + + } + + // test for to lowercase, eg. "new_val = (user_val | 0x2020) ..." + if (*status != 1) { + + if ((b_val | (0x2020202020202020 & mask)) == (pattern & mask)) { + + diff = 1; + + } else { + + diff = 0; + + } + + if ((o_b_val | (0x2020202020202020 & mask)) == (o_pattern & mask)) { + + o_diff = 1; + + } else { + + diff = 0; + + } + + /* fprintf(stderr, "DIFF3 idx=%03u shape=%02u %llx-%llx=%lx\n", + idx, h->shape + 1, o_pattern, o_b_val, o_diff); fprintf(stderr, + "DIFF3 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);*/ + if (o_diff && diff) { + + // this could be a lower to upper + + u64 new_repl = (repl & (0x5f5f5f5f5f5f5f5f & mask)); + // fprintf(stderr, "SAME DIFF %llx->%llx\n", repl, new_repl); + + if (unlikely(cmp_extend_encoding( + afl, h, pattern, new_repl, o_pattern, repl, IS_TRANSFORM, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + + return 1; + + } + + if (*status == 1) { fprintf(stderr, "FOUND!\n"); } + + } + + } + + // test for to uppercase, eg. "new_val = (user_val | 0x5f5f) ..." + if (*status != 1) { + + if ((b_val & (0x5f5f5f5f5f5f5f5f & mask)) == (pattern & mask)) { + + diff = 1; + + } else { + + diff = 0; + + } + + if ((o_b_val & (0x5f5f5f5f5f5f5f5f & mask)) == (o_pattern & mask)) { + + o_diff = 1; + + } else { + + o_diff = 0; + + } + + /* fprintf(stderr, "DIFF4 idx=%03u shape=%02u %llx-%llx=%lx\n", + idx, h->shape + 1, o_pattern, o_b_val, o_diff); fprintf(stderr, + "DIFF4 %016llx %llx-%llx=%lx\n", repl, pattern, b_val, diff);*/ + if (o_diff && diff) { + + // this could be a lower to upper + + u64 new_repl = (repl | (0x2020202020202020 & mask)); + // fprintf(stderr, "SAME DIFF %llx->%llx\n", repl, new_repl); + + if (unlikely(cmp_extend_encoding( + afl, h, pattern, new_repl, o_pattern, repl, IS_TRANSFORM, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + + return 1; + + } + + if (*status == 1) { fprintf(stderr, "FOUND!\n"); } + + } + + } + + *status = 0; + + } + } +#endif + // we only allow this for ascii2integer (above) if (unlikely(pattern == o_pattern)) { return 0; } @@ -783,7 +983,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // in original buffer) #ifdef ARITHMETIC_LESSER_GREATER - if (lvl < LVL3) { return 0; } + if (lvl < LVL3 || attr == IS_TRANSFORM) { return 0; } // lesser/greater FP comparison if ((attr & (IS_LESSER + IS_GREATER)) && @@ -1374,56 +1574,185 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, - u8 *o_pattern, u32 idx, u32 taint_len, - u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, - u8 *status) { + u8 *o_pattern, u8 *changed_val, u32 idx, + u32 taint_len, u8 *orig_buf, u8 *buf, u8 *cbuf, + u32 len, u8 lvl, u8 *status) { #ifndef COMBINE (void)(cbuf); #endif - u32 i; + u32 i = 0; u32 its_len = MIN((u32)32, len - idx); its_len = MIN(its_len, taint_len); u8 save[32]; memcpy(save, &buf[idx], its_len); - for (i = 0; i < its_len; ++i) { + if (lvl == LVL1) { - if ((pattern[i] != buf[idx + i] && o_pattern[i] != orig_buf[idx + i]) || - *status == 1) { + for (i = 0; i < its_len; ++i) { - break; + if ((pattern[i] != buf[idx + i] && o_pattern[i] != orig_buf[idx + i]) || + *status == 1) { + + break; + + } + + buf[idx + i] = repl[i]; + + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + +#ifdef COMBINE + if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } +#endif } - buf[idx + i] = repl[i]; + } + + if (*status == 1) return 0; + + if (lvl & LVL3) { + + u8 toupper = 0, tolower = 0, xor = 0, arith = 0; + u8 xor_val[32], arith_val[32]; + u32 j; + +#ifdef _DEBUG + fprintf(stderr, "RTN TRANSFORM idx=%u ", idx); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", orig_buf[idx + j]); + fprintf(stderr, " -> "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", o_pattern[j]); + fprintf(stderr, " <= "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", repl[j]); + fprintf(stderr, "\n"); + fprintf(stderr, " "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", buf[idx + j]); + fprintf(stderr, " -> "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", pattern[j]); + fprintf(stderr, " <= "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", changed_val[j]); + fprintf(stderr, "\n"); +#endif + for (i = 0; i < its_len; ++i) { + + xor_val[i] = pattern[i] ^ buf[idx + i]; + arith_val[i] = pattern[i] - buf[idx + i]; + + if ((o_pattern[i] ^ orig_buf[idx + i]) == xor_val[i] && xor_val[i]) { + + ++xor; + + } + + if ((o_pattern[i] - orig_buf[idx + i]) == arith_val[i] && arith_val[i]) { + + ++arith; + + } + + if ((buf[idx + i] | 0x20) == pattern[i] && + (orig_buf[idx + i] | 0x20) == o_pattern[i]) { + + ++tolower; - if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + } + + if ((buf[idx + i] & 0x5a) == pattern[i] && + (orig_buf[idx + i] & 0x5a) == o_pattern[i]) { + + ++toupper; + + } + +#ifdef _DEBUG + fprintf(stderr, "RTN loop=%u %u %u %u %u (%u %u)\n", i, xor, arith, + tolower, toupper, arith_val[i], xor_val[i]); +#endif + + if (xor > i) { + + for (j = 0; j <= i; j++) + buf[idx + j] = repl[j] ^ xor_val[j]; + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + // fprintf(stderr, "RTN ATTEMPT xor %u result %u\n", xor, *status); + + } + + if (arith > i && *status != 1) { + + for (j = 0; j <= i; j++) + buf[idx + j] = repl[j] - arith_val[j]; + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + // fprintf(stderr, "RTN ATTEMPT arith %u result %u\n", arith, *status); + + } + + if (toupper > i && *status != 1) { + + for (j = 0; j <= i; j++) + buf[idx + j] = repl[j] | 0x20; + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + // fprintf(stderr, "RTN ATTEMPT toupper %u result %u\n", toupper, + // *status); + + } + + if (tolower > i && *status != 1) { + + for (j = 0; j <= i; j++) + buf[idx + j] = repl[j] & 0x5f; + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + // fprintf(stderr, "RTN ATTEMPT tolower %u result %u\n", tolower, + // *status); + + } #ifdef COMBINE - if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } + if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } #endif + if ((i >= xor&&i >= arith &&i >= tolower &&i >= toupper) || + repl[i] != changed_val[i] || *status == 1) { + + break; + + } + + } + } memcpy(&buf[idx], save, i); + return 0; } static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, - u32 len, struct tainted *taint) { + u32 len, u8 lvl, struct tainted *taint) { struct tainted * t; struct cmp_header *h = &afl->shm.cmp_map->headers[key]; - u32 i, j, idx, have_taint = 1, taint_len; + u32 i, j, idx, have_taint = 1, taint_len, loggeds; + u8 status = 0, found_one = 0; - u32 loggeds = h->hits; - if (h->hits > CMP_MAP_RTN_H) { loggeds = CMP_MAP_RTN_H; } + if (h->hits > CMP_MAP_RTN_H) { - u8 status = 0; - u8 found_one = 0; + loggeds = CMP_MAP_RTN_H; + + } else { + + loggeds = h->hits; + + } for (i = 0; i < loggeds; ++i) { @@ -1445,6 +1774,20 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } + /* + struct cmp_header *hh = &afl->orig_cmp_map->headers[key]; + fprintf(stderr, "RTN N hits=%u id=%u shape=%u attr=%u v0=", h->hits, h->id, + h->shape, h->attribute); for (j = 0; j < 8; j++) fprintf(stderr, "%02x", + o->v0[j]); fprintf(stderr, " v1="); for (j = 0; j < 8; j++) fprintf(stderr, + "%02x", o->v1[j]); fprintf(stderr, "\nRTN O hits=%u id=%u shape=%u attr=%u + o0=", hh->hits, hh->id, hh->shape, hh->attribute); for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", orig_o->v0[j]); + fprintf(stderr, " o1="); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", orig_o->v1[j]); + fprintf(stderr, "\n"); + */ + t = taint; while (t->next) { @@ -1476,9 +1819,9 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, status = 0; - if (unlikely(rtn_extend_encoding(afl, o->v0, o->v1, orig_o->v0, idx, - taint_len, orig_buf, buf, cbuf, len, - &status))) { + if (unlikely(rtn_extend_encoding(afl, o->v0, o->v1, orig_o->v0, + orig_o->v1, idx, taint_len, orig_buf, + buf, cbuf, len, lvl, &status))) { return 1; @@ -1493,9 +1836,9 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, status = 0; - if (unlikely(rtn_extend_encoding(afl, o->v1, o->v0, orig_o->v1, idx, - taint_len, orig_buf, buf, cbuf, len, - &status))) { + if (unlikely(rtn_extend_encoding(afl, o->v1, o->v0, orig_o->v1, + orig_o->v0, idx, taint_len, orig_buf, + buf, cbuf, len, lvl, &status))) { return 1; @@ -1511,7 +1854,7 @@ static u8 rtn_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, } // If failed, add to dictionary - if (!found_one) { + if (!found_one && (lvl & LVL1)) { if (unlikely(!afl->pass_stats[key].total)) { @@ -1702,9 +2045,14 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } - } else if (lvl & LVL1) { + } else if ((lvl & LVL1) + +#ifdef TRANSFORM + || (lvl & LVL3) +#endif + ) { - if (unlikely(rtn_fuzz(afl, k, orig_buf, buf, cbuf, len, taint))) { + if (unlikely(rtn_fuzz(afl, k, orig_buf, buf, cbuf, len, lvl, taint))) { goto exit_its; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 88c40ee8..0f76e8a3 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1515,7 +1515,21 @@ int main(int argc, char **argv_orig, char **envp) { } + u8 *save_env = NULL; + if (afl->cmplog_binary) { + + save_env = ck_strdup(getenv(CMPLOG_SHM_ENV_VAR)); + unsetenv(CMPLOG_SHM_ENV_VAR); // normal forkserver should not have this + + } + perform_dry_run(afl); + if (save_env) { + + setenv(CMPLOG_SHM_ENV_VAR, save_env, 1); // needed for at_exit() + ck_free(save_env); + + } /* if (!user_set_cache && afl->q_testcase_max_cache_size) { -- cgit 1.4.1 From e3835b4d68fe0055e251c2480ca2080e44ba877d Mon Sep 17 00:00:00 2001 From: vishesh-sharma-123 <77101111+vishesh-sharma-123@users.noreply.github.com> Date: Wed, 20 Jan 2021 09:22:28 +0530 Subject: Update README.md Typo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bea673f9..204eaf92 100644 --- a/README.md +++ b/README.md @@ -27,14 +27,14 @@ ## Major changes in afl++ 3.0 -With afl++ 3.0 we introduced changes that break some previous afl and afl++ +With afl++ 3.0 we introduced changes that breaks some previous afl and afl++ behaviours and defaults: * There are no llvm_mode and gcc_plugin subdirectories anymore and there is only one compiler: afl-cc. All previous compilers now symlink to this. All instrumentation source code is now in the `instrumentation/` folder. * The gcc_plugin was replaced with a new version submitted by AdaCore that - supports more features. thank you! + supports more features. Thank you! * qemu_mode got upgraded to QEMU 5.1, but to be able to build this a current ninja build tool version and python3 setuptools are required. qemu_mode also got new options like snapshotting, instrumenting specific @@ -66,7 +66,7 @@ behaviours and defaults: 2. [How to compile and install afl++](#building-and-installing-afl) 3. [How to fuzz a target](#how-to-fuzz-with-afl) 4. [Fuzzing binary-only targets](#fuzzing-binary-only-targets) - 5. [Good examples and writeups of afl++ usages](#good-examples-and-writeups) + 5. [Good examples and writeups of afl++ usages](#-examples-and-writeups) 6. [Branches](#branches) 7. [Want to help?](#help-wanted) 8. [Detailed help and description of afl++](#challenges-of-guided-fuzzing) -- cgit 1.4.1 From 17e3e65d9617032c7dc1685a57fe82c8afbdbf8a Mon Sep 17 00:00:00 2001 From: "R. Elliott Childre" Date: Wed, 20 Jan 2021 01:02:28 -0500 Subject: LD_PRELOAD in the QEMU environ and enforce arch --- afl-wine-trace | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/afl-wine-trace b/afl-wine-trace index 8853a757..63ff896b 100755 --- a/afl-wine-trace +++ b/afl-wine-trace @@ -28,9 +28,9 @@ if not os.getenv("AFL_INST_LIBS"): os.environ["AFL_CODE_END"] = "0x%x" % (pe.OPTIONAL_HEADER.ImageBase + pe.OPTIONAL_HEADER.BaseOfCode + pe.OPTIONAL_HEADER.SizeOfCode) if pe.FILE_HEADER.Machine == pefile.MACHINE_TYPE["IMAGE_FILE_MACHINE_AMD64"] or pe.FILE_HEADER.Machine == pefile.MACHINE_TYPE["IMAGE_FILE_MACHINE_IA64"]: - os.environ["LD_PRELOAD"] = os.path.join(my_dir, "qemu_mode/unsigaction/unsigaction64.so") + os.environ["QEMU_SET_ENV"] = "LD_PRELOAD=" + os.path.join(my_dir, "qemu_mode/unsigaction/unsigaction64.so") + ",WINEARCH=win64" else: - os.environ["LD_PRELOAD"] = os.path.join(my_dir, "qemu_mode/unsigaction/unsigaction32.so") + os.environ["QEMU_SET_ENV"] = "LD_PRELOAD=" + os.path.join(my_dir, "qemu_mode/unsigaction/unsigaction32.so") + ",WINEARCH=win32" if os.getenv("WINECOV_QEMU_PATH"): qemu_path = os.getenv("WINECOV_QEMU_PATH") -- cgit 1.4.1 From 0306261fec4c9ebc2b1361da1d0fbbe9bade8847 Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Wed, 13 Jan 2021 12:32:36 +0800 Subject: Fix build error for Android - LTO not work yet --- Android.bp | 304 +++++++++++++++++++++++++-- Android.mk | 1 - include/afl-fuzz.h | 4 - include/android-ashmem.h | 113 ++++------ src/afl-analyze.c | 3 - src/afl-fuzz-stats.c | 4 + src/afl-gotcpu.c | 3 - src/afl-showmap.c | 3 - src/afl-tmin.c | 4 - utils/afl_network_proxy/afl-network-server.c | 4 - 10 files changed, 332 insertions(+), 111 deletions(-) delete mode 120000 Android.mk diff --git a/Android.bp b/Android.bp index 2c2114b2..549577db 100644 --- a/Android.bp +++ b/Android.bp @@ -1,5 +1,13 @@ cc_defaults { name: "afl-defaults", + sanitize: { + never: true, + }, + + local_include_dirs: [ + "include", + "instrumentation", + ], cflags: [ "-funroll-loops", @@ -14,12 +22,17 @@ cc_defaults { "-DBIN_PATH=\"out/host/linux-x86/bin\"", "-DDOC_PATH=\"out/host/linux-x86/shared/doc/afl\"", "-D__USE_GNU", + "-D__aarch64__", + "-DDEBUG_BUILD", + "-U_FORTIFY_SOURCE", + "-g", + "-O0", + "-fno-omit-frame-pointer", ], } cc_binary { name: "afl-fuzz", - static_executable: true, host_supported: true, defaults: [ @@ -27,7 +40,11 @@ cc_binary { ], srcs: [ - "afl-fuzz.c", + "src/afl-fuzz*.c", + "src/afl-common.c", + "src/afl-sharedmem.c", + "src/afl-forkserver.c", + "src/afl-performance.c", ], } @@ -41,7 +58,10 @@ cc_binary { ], srcs: [ - "afl-showmap.c", + "src/afl-showmap.c", + "src/afl-common.c", + "src/afl-sharedmem.c", + "src/afl-forkserver.c", ], } @@ -55,7 +75,11 @@ cc_binary { ], srcs: [ - "afl-tmin.c", + "src/afl-tmin.c", + "src/afl-common.c", + "src/afl-sharedmem.c", + "src/afl-forkserver.c", + "src/afl-performance.c", ], } @@ -69,7 +93,10 @@ cc_binary { ], srcs: [ - "afl-analyze.c", + "src/afl-analyze.c", + "src/afl-common.c", + "src/afl-sharedmem.c", + "src/afl-performance.c", ], } @@ -83,12 +110,13 @@ cc_binary { ], srcs: [ - "afl-gotcpu.c", + "src/afl-gotcpu.c", + "src/afl-common.c", ], } cc_binary_host { - name: "afl-clang-fast", + name: "afl-cc", static_executable: true, defaults: [ @@ -98,44 +126,286 @@ cc_binary_host { cflags: [ "-D__ANDROID__", "-DAFL_PATH=\"out/host/linux-x86/lib64\"", + "-DAFL_CLANG_FLTO=\"-flto=full\"", + "-DUSE_BINDIR=1", + "-DLLVM_BINDIR=\"prebuilts/clang/host/linux-x86/clang-r383902b/bin\"", + "-DLLVM_LIBDIR=\"prebuilts/clang/host/linux-x86/clang-r383902b/lib64\"", + "-DCLANGPP_BIN=\"prebuilts/clang/host/linux-x86/clang-r383902b/bin/clang++\"", + "-DAFL_REAL_LD=\"prebuilts/clang/host/linux-x86/clang-r383902b/bin/ld.lld\"", + "-DLLVM_LTO=1", ], srcs: [ "src/afl-cc.c", + "src/afl-common.c", + ], + + symlinks: [ + "afl-clang-fast", + "afl-clang-fast++", + "afl-clang-lto", + "afl-clang-lto++", ], } -cc_binary_host { - name: "afl-clang-fast++", - static_executable: true, +cc_library_static { + name: "afl-llvm-rt", + compile_multilib: "both", + vendor_available: true, + host_supported: true, + recovery_available: true, + sdk_version: "9", + + apex_available: [ + "com.android.adbd", + "com.android.appsearch", + "com.android.art", + "com.android.bluetooth.updatable", + "com.android.cellbroadcast", + "com.android.conscrypt", + "com.android.extservices", + "com.android.cronet", + "com.android.neuralnetworks", + "com.android.media", + "com.android.media.swcodec", + "com.android.mediaprovider", + "com.android.permission", + "com.android.runtime", + "com.android.resolv", + "com.android.tethering", + "com.android.wifi", + "com.android.sdkext", + "com.android.os.statsd", + "//any", + ], defaults: [ "afl-defaults", ], - cflags: [ - "-D__ANDROID__", - "-DAFL_PATH=\"out/host/linux-x86/lib64\"", + srcs: [ + "instrumentation/afl-compiler-rt.o.c", ], +} - srcs: [ - "src/afl-cc.c", +cc_defaults { + name: "afl-defaults-lto", + + include_dirs: [ + "prebuilts/clang/host/linux-x86/clang-r383902b/include", ], } +/*cc_library_host_shared { + name: "afl-llvm-lto-instrumentlist", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/afl-llvm-lto-instrumentlist.so.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "afl-llvm-dict2file", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/afl-llvm-dict2file.so.cc", + "instrumentation/afl-llvm-common.cc", + ], + + shared_libs: [ + "libLLVM-11git", + ], +}*/ + +/*cc_library_host_shared { + name: "cmplog-routines-pass", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/cmplog-routines-pass.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "cmplog-instructions-pass", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/cmplog-instructions-pass.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "split-switches-pass", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/split-switches-pass.so.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "compare-transform-pass", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/compare-transform-pass.so.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "split-compares-pass", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/split-compares-pass.so.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "libLLVMInsTrim", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/LLVMInsTrim.so.cc", + "instrumentation/MarkNodes.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "afl-llvm-pass", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/afl-llvm-pass.so.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "SanitizerCoveragePCGUARD", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/SanitizerCoveragePCGUARD.so.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "SanitizerCoverageLTO", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/SanitizerCoverageLTO.so.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + +/*cc_library_host_shared { + name: "afl-llvm-lto-instrumentation", + + defaults: [ + "afl-defaults", + "afl-defaults-lto", + ], + + srcs: [ + "instrumentation/afl-llvm-lto-instrumentation.so.cc", + "instrumentation/afl-llvm-common.cc", + ], +}*/ + cc_library_static { - name: "afl-llvm-rt", + name: "afl-llvm-rt-lto", compile_multilib: "both", vendor_available: true, host_supported: true, recovery_available: true, sdk_version: "9", + apex_available: [ + "com.android.adbd", + "com.android.appsearch", + "com.android.art", + "com.android.bluetooth.updatable", + "com.android.cellbroadcast", + "com.android.conscrypt", + "com.android.extservices", + "com.android.cronet", + "com.android.neuralnetworks", + "com.android.media", + "com.android.media.swcodec", + "com.android.mediaprovider", + "com.android.permission", + "com.android.runtime", + "com.android.resolv", + "com.android.tethering", + "com.android.wifi", + "com.android.sdkext", + "com.android.os.statsd", + "//any", + ], + defaults: [ "afl-defaults", + "afl-defaults-lto", ], srcs: [ - "instrumentation/afl-llvm-rt.o.c", + "instrumentation/afl-llvm-rt-lto.o.c", ], } diff --git a/Android.mk b/Android.mk deleted file mode 120000 index 33ceb8f0..00000000 --- a/Android.mk +++ /dev/null @@ -1 +0,0 @@ -Makefile \ No newline at end of file diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 988a907d..6342c8b6 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -37,10 +37,6 @@ #define _FILE_OFFSET_BITS 64 #endif -#ifdef __ANDROID__ - #include "android-ashmem.h" -#endif - #include "config.h" #include "types.h" #include "debug.h" diff --git a/include/android-ashmem.h b/include/android-ashmem.h index 41d4d2da..6939e06d 100644 --- a/include/android-ashmem.h +++ b/include/android-ashmem.h @@ -1,112 +1,81 @@ -/* - american fuzzy lop++ - android shared memory compatibility layer - ---------------------------------------------------------------- - - Originally written by Michal Zalewski - - Now maintained by Marc Heuse , - Heiko Eißfeldt , - Andrea Fioraldi , - Dominik Maier - - Copyright 2016, 2017 Google Inc. All rights reserved. - Copyright 2019-2020 AFLplusplus Project. All rights reserved. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at: - - http://www.apache.org/licenses/LICENSE-2.0 - - This header re-defines the shared memory routines used by AFL++ - using the Andoid API. - - */ - +#ifdef __ANDROID__ #ifndef _ANDROID_ASHMEM_H #define _ANDROID_ASHMEM_H -#ifdef __ANDROID__ - - #include - #include - #include - #include - #include - - #if __ANDROID_API__ >= 26 - #define shmat bionic_shmat - #define shmctl bionic_shmctl - #define shmdt bionic_shmdt - #define shmget bionic_shmget - #endif - - #include - #undef shmat - #undef shmctl - #undef shmdt - #undef shmget - #include +#include +#include +#include +#include - #define ASHMEM_DEVICE "/dev/ashmem" +#if __ANDROID_API__ >= 26 +#define shmat bionic_shmat +#define shmctl bionic_shmctl +#define shmdt bionic_shmdt +#define shmget bionic_shmget +#endif +#include +#undef shmat +#undef shmctl +#undef shmdt +#undef shmget +#include -static inline int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf) { +#define ASHMEM_DEVICE "/dev/ashmem" +int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf) { int ret = 0; if (__cmd == IPC_RMID) { - - int length = ioctl(__shmid, ASHMEM_GET_SIZE, NULL); - struct ashmem_pin pin = {0, (unsigned int)length}; + int length = ioctl(__shmid, ASHMEM_GET_SIZE, NULL); + struct ashmem_pin pin = {0, length}; ret = ioctl(__shmid, ASHMEM_UNPIN, &pin); close(__shmid); - } return ret; - } -static inline int shmget(key_t __key, size_t __size, int __shmflg) { - - (void)__shmflg; - int fd, ret; +int shmget(key_t __key, size_t __size, int __shmflg) { + (void) __shmflg; + int fd, ret; char ourkey[11]; fd = open(ASHMEM_DEVICE, O_RDWR); - if (fd < 0) return fd; + if (fd < 0) + return fd; sprintf(ourkey, "%d", __key); ret = ioctl(fd, ASHMEM_SET_NAME, ourkey); - if (ret < 0) goto error; + if (ret < 0) + goto error; ret = ioctl(fd, ASHMEM_SET_SIZE, __size); - if (ret < 0) goto error; + if (ret < 0) + goto error; return fd; error: close(fd); return ret; - } -static inline void *shmat(int __shmid, const void *__shmaddr, int __shmflg) { - - (void)__shmflg; - int size; +void *shmat(int __shmid, const void *__shmaddr, int __shmflg) { + (void) __shmflg; + int size; void *ptr; size = ioctl(__shmid, ASHMEM_GET_SIZE, NULL); - if (size < 0) { return NULL; } + if (size < 0) { + return NULL; + } ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, __shmid, 0); - if (ptr == MAP_FAILED) { return NULL; } + if (ptr == MAP_FAILED) { + return NULL; + } return ptr; - } -#endif /* __ANDROID__ */ - -#endif - +#endif /* !_ANDROID_ASHMEM_H */ +#endif /* !__ANDROID__ */ diff --git a/src/afl-analyze.c b/src/afl-analyze.c index 8fc4434a..0af489fe 100644 --- a/src/afl-analyze.c +++ b/src/afl-analyze.c @@ -26,9 +26,6 @@ #define AFL_MAIN -#ifdef __ANDROID__ - #include "android-ashmem.h" -#endif #include "config.h" #include "types.h" #include "debug.h" diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index e86f2aeb..e67bace9 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -58,7 +58,11 @@ void write_setup_file(afl_state_t *afl, u32 argc, char **argv) { for (i = 0; i < argc; ++i) { if (i) fprintf(f, " "); +#ifdef __ANDROID__ + if (memchr(argv[i], '\'', sizeof(argv[i]))) { +#else if (index(argv[i], '\'')) { +#endif fprintf(f, "'"); for (j = 0; j < strlen(argv[i]); j++) diff --git a/src/afl-gotcpu.c b/src/afl-gotcpu.c index 1aea3e40..ac002a93 100644 --- a/src/afl-gotcpu.c +++ b/src/afl-gotcpu.c @@ -35,9 +35,6 @@ #define _GNU_SOURCE #endif -#ifdef __ANDROID__ - #include "android-ashmem.h" -#endif #include #include #include diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 5c9d38e0..6d95fc1d 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -31,9 +31,6 @@ #define AFL_MAIN -#ifdef __ANDROID__ - #include "android-ashmem.h" -#endif #include "config.h" #include "types.h" #include "debug.h" diff --git a/src/afl-tmin.c b/src/afl-tmin.c index 6e2d7708..5fd60cd2 100644 --- a/src/afl-tmin.c +++ b/src/afl-tmin.c @@ -29,10 +29,6 @@ #define AFL_MAIN -#ifdef __ANDROID__ - #include "android-ashmem.h" -#endif - #include "config.h" #include "types.h" #include "debug.h" diff --git a/utils/afl_network_proxy/afl-network-server.c b/utils/afl_network_proxy/afl-network-server.c index 513dc8f2..fe225416 100644 --- a/utils/afl_network_proxy/afl-network-server.c +++ b/utils/afl_network_proxy/afl-network-server.c @@ -24,10 +24,6 @@ #define AFL_MAIN -#ifdef __ANDROID__ - #include "android-ashmem.h" -#endif - #include "config.h" #include "types.h" #include "debug.h" -- cgit 1.4.1 From 52f1d535bd8a40698e8446786b134d6629700713 Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Thu, 14 Jan 2021 13:40:28 +0800 Subject: android: port afl_frida for arm64 --- Android.bp | 234 +- utils/afl_frida/android/frida-gum-example.c | 130 + utils/afl_frida/android/frida-gum.h | 51342 ++++++++++++++++++++++++++ utils/afl_frida/android/libfrida-gum.a | Bin 0 -> 41417006 bytes 4 files changed, 51512 insertions(+), 194 deletions(-) create mode 100644 utils/afl_frida/android/frida-gum-example.c create mode 100644 utils/afl_frida/android/frida-gum.h create mode 100644 utils/afl_frida/android/libfrida-gum.a diff --git a/Android.bp b/Android.bp index 549577db..1ac9e565 100644 --- a/Android.bp +++ b/Android.bp @@ -10,6 +10,7 @@ cc_defaults { ], cflags: [ + "-flto=full", "-funroll-loops", "-Wno-pointer-sign", "-Wno-pointer-arith", @@ -18,13 +19,14 @@ cc_defaults { "-Wno-unused-function", "-Wno-format", "-Wno-user-defined-warnings", - "-DUSE_TRACE_PC=1", + "-DAFL_LLVM_USE_TRACE_PC=1", "-DBIN_PATH=\"out/host/linux-x86/bin\"", "-DDOC_PATH=\"out/host/linux-x86/shared/doc/afl\"", "-D__USE_GNU", "-D__aarch64__", "-DDEBUG_BUILD", "-U_FORTIFY_SOURCE", + "-ggdb3", "-g", "-O0", "-fno-omit-frame-pointer", @@ -188,224 +190,68 @@ cc_library_static { ], } -cc_defaults { - name: "afl-defaults-lto", - - include_dirs: [ - "prebuilts/clang/host/linux-x86/clang-r383902b/include", - ], -} - -/*cc_library_host_shared { - name: "afl-llvm-lto-instrumentlist", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", - ], - - srcs: [ - "instrumentation/afl-llvm-lto-instrumentlist.so.cc", - "instrumentation/afl-llvm-common.cc", - ], -}*/ - -/*cc_library_host_shared { - name: "afl-llvm-dict2file", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", - ], - - srcs: [ - "instrumentation/afl-llvm-dict2file.so.cc", - "instrumentation/afl-llvm-common.cc", - ], - - shared_libs: [ - "libLLVM-11git", - ], -}*/ - -/*cc_library_host_shared { - name: "cmplog-routines-pass", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", - ], - - srcs: [ - "instrumentation/cmplog-routines-pass.cc", - "instrumentation/afl-llvm-common.cc", - ], -}*/ - -/*cc_library_host_shared { - name: "cmplog-instructions-pass", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", - ], - - srcs: [ - "instrumentation/cmplog-instructions-pass.cc", - "instrumentation/afl-llvm-common.cc", - ], -}*/ - -/*cc_library_host_shared { - name: "split-switches-pass", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", - ], - - srcs: [ - "instrumentation/split-switches-pass.so.cc", - "instrumentation/afl-llvm-common.cc", - ], -}*/ - -/*cc_library_host_shared { - name: "compare-transform-pass", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", - ], +cc_prebuilt_library_static { + name: "libfrida-gum", + compile_multilib: "64", + strip: { + none: true, + }, srcs: [ - "instrumentation/compare-transform-pass.so.cc", - "instrumentation/afl-llvm-common.cc", + "utils/afl_frida/android/libfrida-gum.a", ], -}*/ - -/*cc_library_host_shared { - name: "split-compares-pass", - defaults: [ - "afl-defaults", - "afl-defaults-lto", + export_include_dirs: [ + "utils/afl_frida/android", ], +} - srcs: [ - "instrumentation/split-compares-pass.so.cc", - "instrumentation/afl-llvm-common.cc", - ], -}*/ - -/*cc_library_host_shared { - name: "libLLVMInsTrim", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", - ], +cc_library_shared { + name: "libtestinstr", srcs: [ - "instrumentation/LLVMInsTrim.so.cc", - "instrumentation/MarkNodes.cc", - "instrumentation/afl-llvm-common.cc", - ], -}*/ - -/*cc_library_host_shared { - name: "afl-llvm-pass", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", + "utils/afl_frida/libtestinstr.c", ], - srcs: [ - "instrumentation/afl-llvm-pass.so.cc", - "instrumentation/afl-llvm-common.cc", + cflags: [ + "-O0", + "-fPIC", ], -}*/ +} -/*cc_library_host_shared { - name: "SanitizerCoveragePCGUARD", +cc_binary { + name: "afl-frida", + compile_multilib: "64", defaults: [ "afl-defaults", - "afl-defaults-lto", - ], - - srcs: [ - "instrumentation/SanitizerCoveragePCGUARD.so.cc", - "instrumentation/afl-llvm-common.cc", ], -}*/ -/*cc_library_host_shared { - name: "SanitizerCoverageLTO", - - defaults: [ - "afl-defaults", - "afl-defaults-lto", + cflags: [ + "-g", + "-O0", + "-Wno-format", + "-Wno-pointer-sign", + "-fpermissive", + "-fPIC", ], - srcs: [ - "instrumentation/SanitizerCoverageLTO.so.cc", - "instrumentation/afl-llvm-common.cc", + static_libs: [ + "afl-llvm-rt", + "libfrida-gum", ], -}*/ - -/*cc_library_host_shared { - name: "afl-llvm-lto-instrumentation", - defaults: [ - "afl-defaults", - "afl-defaults-lto", + shared_libs: [ + "libdl", + "liblog", ], srcs: [ - "instrumentation/afl-llvm-lto-instrumentation.so.cc", - "instrumentation/afl-llvm-common.cc", + "utils/afl_frida/afl-frida.c", ], -}*/ -cc_library_static { - name: "afl-llvm-rt-lto", - compile_multilib: "both", - vendor_available: true, - host_supported: true, - recovery_available: true, - sdk_version: "9", - - apex_available: [ - "com.android.adbd", - "com.android.appsearch", - "com.android.art", - "com.android.bluetooth.updatable", - "com.android.cellbroadcast", - "com.android.conscrypt", - "com.android.extservices", - "com.android.cronet", - "com.android.neuralnetworks", - "com.android.media", - "com.android.media.swcodec", - "com.android.mediaprovider", - "com.android.permission", - "com.android.runtime", - "com.android.resolv", - "com.android.tethering", - "com.android.wifi", - "com.android.sdkext", - "com.android.os.statsd", - "//any", - ], - - defaults: [ - "afl-defaults", - "afl-defaults-lto", - ], - - srcs: [ - "instrumentation/afl-llvm-rt-lto.o.c", + local_include_dirs: [ + "utils/afl_frida", + "utils/afl_frida/android", ], } diff --git a/utils/afl_frida/android/frida-gum-example.c b/utils/afl_frida/android/frida-gum-example.c new file mode 100644 index 00000000..14d98248 --- /dev/null +++ b/utils/afl_frida/android/frida-gum-example.c @@ -0,0 +1,130 @@ +/* + * Compile with: + * + * clang -fPIC -DANDROID -ffunction-sections -fdata-sections -Os -pipe -g3 frida-gum-example.c -o frida-gum-example -L. -lfrida-gum -llog -ldl -lm -pthread -Wl,--gc-sections,-z,noexecstack,-z,relro,-z,now -fuse-ld=gold -fuse-ld=gold -Wl,--icf=all + * + * Visit https://frida.re to learn more about Frida. + */ + +#include "frida-gum.h" + +#include +#include + +typedef struct _ExampleListener ExampleListener; +typedef enum _ExampleHookId ExampleHookId; + +struct _ExampleListener +{ + GObject parent; + + guint num_calls; +}; + +enum _ExampleHookId +{ + EXAMPLE_HOOK_OPEN, + EXAMPLE_HOOK_CLOSE +}; + +static void example_listener_iface_init (gpointer g_iface, gpointer iface_data); + +#define EXAMPLE_TYPE_LISTENER (example_listener_get_type ()) +G_DECLARE_FINAL_TYPE (ExampleListener, example_listener, EXAMPLE, LISTENER, GObject) +G_DEFINE_TYPE_EXTENDED (ExampleListener, + example_listener, + G_TYPE_OBJECT, + 0, + G_IMPLEMENT_INTERFACE (GUM_TYPE_INVOCATION_LISTENER, + example_listener_iface_init)) + +int +main (int argc, + char * argv[]) +{ + GumInterceptor * interceptor; + GumInvocationListener * listener; + + gum_init_embedded (); + + interceptor = gum_interceptor_obtain (); + listener = g_object_new (EXAMPLE_TYPE_LISTENER, NULL); + + gum_interceptor_begin_transaction (interceptor); + gum_interceptor_attach (interceptor, + GSIZE_TO_POINTER (gum_module_find_export_by_name (NULL, "open")), + listener, + GSIZE_TO_POINTER (EXAMPLE_HOOK_OPEN)); + gum_interceptor_attach (interceptor, + GSIZE_TO_POINTER (gum_module_find_export_by_name (NULL, "close")), + listener, + GSIZE_TO_POINTER (EXAMPLE_HOOK_CLOSE)); + gum_interceptor_end_transaction (interceptor); + + close (open ("/etc/hosts", O_RDONLY)); + close (open ("/etc/fstab", O_RDONLY)); + + g_print ("[*] listener got %u calls\n", EXAMPLE_LISTENER (listener)->num_calls); + + gum_interceptor_detach (interceptor, listener); + + close (open ("/etc/hosts", O_RDONLY)); + close (open ("/etc/fstab", O_RDONLY)); + + g_print ("[*] listener still has %u calls\n", EXAMPLE_LISTENER (listener)->num_calls); + + g_object_unref (listener); + g_object_unref (interceptor); + + gum_deinit_embedded (); + + return 0; +} + +static void +example_listener_on_enter (GumInvocationListener * listener, + GumInvocationContext * ic) +{ + ExampleListener * self = EXAMPLE_LISTENER (listener); + ExampleHookId hook_id = GUM_IC_GET_FUNC_DATA (ic, ExampleHookId); + + switch (hook_id) + { + case EXAMPLE_HOOK_OPEN: + g_print ("[*] open(\"%s\")\n", (const gchar *) gum_invocation_context_get_nth_argument (ic, 0)); + break; + case EXAMPLE_HOOK_CLOSE: + g_print ("[*] close(%d)\n", GPOINTER_TO_INT (gum_invocation_context_get_nth_argument (ic, 0))); + break; + } + + self->num_calls++; +} + +static void +example_listener_on_leave (GumInvocationListener * listener, + GumInvocationContext * ic) +{ +} + +static void +example_listener_class_init (ExampleListenerClass * klass) +{ + (void) EXAMPLE_IS_LISTENER; + (void) glib_autoptr_cleanup_ExampleListener; +} + +static void +example_listener_iface_init (gpointer g_iface, + gpointer iface_data) +{ + GumInvocationListenerInterface * iface = g_iface; + + iface->on_enter = example_listener_on_enter; + iface->on_leave = example_listener_on_leave; +} + +static void +example_listener_init (ExampleListener * self) +{ +} diff --git a/utils/afl_frida/android/frida-gum.h b/utils/afl_frida/android/frida-gum.h new file mode 100644 index 00000000..52176cbd --- /dev/null +++ b/utils/afl_frida/android/frida-gum.h @@ -0,0 +1,51342 @@ +#ifndef GUM_STATIC +# define GUM_STATIC +#endif + +#ifndef __FRIDA_SYMBOL_MAPPINGS__ +#define __FRIDA_SYMBOL_MAPPINGS__ + +#define cs_close _frida_cs_close +#define cs_disasm _frida_cs_disasm +#define cs_disasm_iter _frida_cs_disasm_iter +#define cs_errno _frida_cs_errno +#define cs_free _frida_cs_free +#define cs_group_name _frida_cs_group_name +#define cs_insn_group _frida_cs_insn_group +#define cs_insn_name _frida_cs_insn_name +#define cs_malloc _frida_cs_malloc +#define cs_mem_calloc _frida_cs_mem_calloc +#define cs_mem_free _frida_cs_mem_free +#define cs_mem_malloc _frida_cs_mem_malloc +#define cs_mem_realloc _frida_cs_mem_realloc +#define cs_op_count _frida_cs_op_count +#define cs_op_index _frida_cs_op_index +#define cs_open _frida_cs_open +#define cs_option _frida_cs_option +#define cs_reg_name _frida_cs_reg_name +#define cs_reg_read _frida_cs_reg_read +#define cs_reg_write _frida_cs_reg_write +#define cs_regs_access _frida_cs_regs_access +#define cs_snprintf _frida_cs_snprintf +#define cs_strdup _frida_cs_strdup +#define cs_strerror _frida_cs_strerror +#define cs_support _frida_cs_support +#define cs_version _frida_cs_version +#define cs_vsnprintf _frida_cs_vsnprintf +#define g__inotify_lock_lock _frida_g__inotify_lock_lock +#define g_access _frida_g_access +#define g_action_activate _frida_g_action_activate +#define g_action_change_state _frida_g_action_change_state +#define g_action_get_enabled _frida_g_action_get_enabled +#define g_action_get_name _frida_g_action_get_name +#define g_action_get_parameter_type _frida_g_action_get_parameter_type +#define g_action_get_state _frida_g_action_get_state +#define g_action_get_state_hint _frida_g_action_get_state_hint +#define g_action_get_state_type _frida_g_action_get_state_type +#define g_action_get_type _frida_g_action_get_type +#define g_action_group_action_added _frida_g_action_group_action_added +#define g_action_group_action_enabled_changed _frida_g_action_group_action_enabled_changed +#define g_action_group_action_removed _frida_g_action_group_action_removed +#define g_action_group_action_state_changed _frida_g_action_group_action_state_changed +#define g_action_group_activate_action _frida_g_action_group_activate_action +#define g_action_group_change_action_state _frida_g_action_group_change_action_state +#define g_action_group_get_action_enabled _frida_g_action_group_get_action_enabled +#define g_action_group_get_action_parameter_type _frida_g_action_group_get_action_parameter_type +#define g_action_group_get_action_state _frida_g_action_group_get_action_state +#define g_action_group_get_action_state_hint _frida_g_action_group_get_action_state_hint +#define g_action_group_get_action_state_type _frida_g_action_group_get_action_state_type +#define g_action_group_get_type _frida_g_action_group_get_type +#define g_action_group_has_action _frida_g_action_group_has_action +#define g_action_group_list_actions _frida_g_action_group_list_actions +#define g_action_group_query_action _frida_g_action_group_query_action +#define g_action_map_add_action _frida_g_action_map_add_action +#define g_action_map_add_action_entries _frida_g_action_map_add_action_entries +#define g_action_map_get_type _frida_g_action_map_get_type +#define g_action_map_lookup_action _frida_g_action_map_lookup_action +#define g_action_map_remove_action _frida_g_action_map_remove_action +#define g_action_name_is_valid _frida_g_action_name_is_valid +#define g_action_parse_detailed_name _frida_g_action_parse_detailed_name +#define g_action_print_detailed_name _frida_g_action_print_detailed_name +#define g_allocator_free _frida_g_allocator_free +#define g_allocator_new _frida_g_allocator_new +#define g_app_info_add_supports_type _frida_g_app_info_add_supports_type +#define g_app_info_can_delete _frida_g_app_info_can_delete +#define g_app_info_can_remove_supports_type _frida_g_app_info_can_remove_supports_type +#define g_app_info_create_flags_get_type _frida_g_app_info_create_flags_get_type +#define g_app_info_create_from_commandline _frida_g_app_info_create_from_commandline +#define g_app_info_delete _frida_g_app_info_delete +#define g_app_info_dup _frida_g_app_info_dup +#define g_app_info_equal _frida_g_app_info_equal +#define g_app_info_get_all _frida_g_app_info_get_all +#define g_app_info_get_all_for_type _frida_g_app_info_get_all_for_type +#define g_app_info_get_commandline _frida_g_app_info_get_commandline +#define g_app_info_get_default_for_type _frida_g_app_info_get_default_for_type +#define g_app_info_get_default_for_uri_scheme _frida_g_app_info_get_default_for_uri_scheme +#define g_app_info_get_description _frida_g_app_info_get_description +#define g_app_info_get_display_name _frida_g_app_info_get_display_name +#define g_app_info_get_executable _frida_g_app_info_get_executable +#define g_app_info_get_fallback_for_type _frida_g_app_info_get_fallback_for_type +#define g_app_info_get_icon _frida_g_app_info_get_icon +#define g_app_info_get_id _frida_g_app_info_get_id +#define g_app_info_get_name _frida_g_app_info_get_name +#define g_app_info_get_recommended_for_type _frida_g_app_info_get_recommended_for_type +#define g_app_info_get_supported_types _frida_g_app_info_get_supported_types +#define g_app_info_get_type _frida_g_app_info_get_type +#define g_app_info_launch _frida_g_app_info_launch +#define g_app_info_launch_default_for_uri _frida_g_app_info_launch_default_for_uri +#define g_app_info_launch_default_for_uri_async _frida_g_app_info_launch_default_for_uri_async +#define g_app_info_launch_default_for_uri_finish _frida_g_app_info_launch_default_for_uri_finish +#define g_app_info_launch_uris _frida_g_app_info_launch_uris +#define g_app_info_launch_uris_async _frida_g_app_info_launch_uris_async +#define g_app_info_launch_uris_finish _frida_g_app_info_launch_uris_finish +#define g_app_info_monitor_fire _frida_g_app_info_monitor_fire +#define g_app_info_monitor_get _frida_g_app_info_monitor_get +#define g_app_info_monitor_get_type _frida_g_app_info_monitor_get_type +#define g_app_info_remove_supports_type _frida_g_app_info_remove_supports_type +#define g_app_info_reset_type_associations _frida_g_app_info_reset_type_associations +#define g_app_info_set_as_default_for_extension _frida_g_app_info_set_as_default_for_extension +#define g_app_info_set_as_default_for_type _frida_g_app_info_set_as_default_for_type +#define g_app_info_set_as_last_used_for_type _frida_g_app_info_set_as_last_used_for_type +#define g_app_info_should_show _frida_g_app_info_should_show +#define g_app_info_supports_files _frida_g_app_info_supports_files +#define g_app_info_supports_uris _frida_g_app_info_supports_uris +#define g_app_launch_context_get_display _frida_g_app_launch_context_get_display +#define g_app_launch_context_get_environment _frida_g_app_launch_context_get_environment +#define g_app_launch_context_get_startup_notify_id _frida_g_app_launch_context_get_startup_notify_id +#define g_app_launch_context_get_type _frida_g_app_launch_context_get_type +#define g_app_launch_context_launch_failed _frida_g_app_launch_context_launch_failed +#define g_app_launch_context_new _frida_g_app_launch_context_new +#define g_app_launch_context_setenv _frida_g_app_launch_context_setenv +#define g_app_launch_context_unsetenv _frida_g_app_launch_context_unsetenv +#define g_application_activate _frida_g_application_activate +#define g_application_add_main_option _frida_g_application_add_main_option +#define g_application_add_main_option_entries _frida_g_application_add_main_option_entries +#define g_application_add_option_group _frida_g_application_add_option_group +#define g_application_bind_busy_property _frida_g_application_bind_busy_property +#define g_application_command_line_create_file_for_arg _frida_g_application_command_line_create_file_for_arg +#define g_application_command_line_get_arguments _frida_g_application_command_line_get_arguments +#define g_application_command_line_get_cwd _frida_g_application_command_line_get_cwd +#define g_application_command_line_get_environ _frida_g_application_command_line_get_environ +#define g_application_command_line_get_exit_status _frida_g_application_command_line_get_exit_status +#define g_application_command_line_get_is_remote _frida_g_application_command_line_get_is_remote +#define g_application_command_line_get_options_dict _frida_g_application_command_line_get_options_dict +#define g_application_command_line_get_platform_data _frida_g_application_command_line_get_platform_data +#define g_application_command_line_get_stdin _frida_g_application_command_line_get_stdin +#define g_application_command_line_get_type _frida_g_application_command_line_get_type +#define g_application_command_line_getenv _frida_g_application_command_line_getenv +#define g_application_command_line_print _frida_g_application_command_line_print +#define g_application_command_line_printerr _frida_g_application_command_line_printerr +#define g_application_command_line_set_exit_status _frida_g_application_command_line_set_exit_status +#define g_application_flags_get_type _frida_g_application_flags_get_type +#define g_application_get_application_id _frida_g_application_get_application_id +#define g_application_get_dbus_connection _frida_g_application_get_dbus_connection +#define g_application_get_dbus_object_path _frida_g_application_get_dbus_object_path +#define g_application_get_default _frida_g_application_get_default +#define g_application_get_flags _frida_g_application_get_flags +#define g_application_get_inactivity_timeout _frida_g_application_get_inactivity_timeout +#define g_application_get_is_busy _frida_g_application_get_is_busy +#define g_application_get_is_registered _frida_g_application_get_is_registered +#define g_application_get_is_remote _frida_g_application_get_is_remote +#define g_application_get_resource_base_path _frida_g_application_get_resource_base_path +#define g_application_get_type _frida_g_application_get_type +#define g_application_hold _frida_g_application_hold +#define g_application_id_is_valid _frida_g_application_id_is_valid +#define g_application_impl_activate _frida_g_application_impl_activate +#define g_application_impl_command_line _frida_g_application_impl_command_line +#define g_application_impl_destroy _frida_g_application_impl_destroy +#define g_application_impl_flush _frida_g_application_impl_flush +#define g_application_impl_get_dbus_connection _frida_g_application_impl_get_dbus_connection +#define g_application_impl_get_dbus_object_path _frida_g_application_impl_get_dbus_object_path +#define g_application_impl_open _frida_g_application_impl_open +#define g_application_impl_register _frida_g_application_impl_register +#define g_application_impl_set_busy_state _frida_g_application_impl_set_busy_state +#define g_application_mark_busy _frida_g_application_mark_busy +#define g_application_new _frida_g_application_new +#define g_application_open _frida_g_application_open +#define g_application_quit _frida_g_application_quit +#define g_application_register _frida_g_application_register +#define g_application_release _frida_g_application_release +#define g_application_run _frida_g_application_run +#define g_application_send_notification _frida_g_application_send_notification +#define g_application_set_action_group _frida_g_application_set_action_group +#define g_application_set_application_id _frida_g_application_set_application_id +#define g_application_set_default _frida_g_application_set_default +#define g_application_set_flags _frida_g_application_set_flags +#define g_application_set_inactivity_timeout _frida_g_application_set_inactivity_timeout +#define g_application_set_option_context_description _frida_g_application_set_option_context_description +#define g_application_set_option_context_parameter_string _frida_g_application_set_option_context_parameter_string +#define g_application_set_option_context_summary _frida_g_application_set_option_context_summary +#define g_application_set_resource_base_path _frida_g_application_set_resource_base_path +#define g_application_unbind_busy_property _frida_g_application_unbind_busy_property +#define g_application_unmark_busy _frida_g_application_unmark_busy +#define g_application_withdraw_notification _frida_g_application_withdraw_notification +#define g_array_append_vals _frida_g_array_append_vals +#define g_array_binary_search _frida_g_array_binary_search +#define g_array_copy _frida_g_array_copy +#define g_array_free _frida_g_array_free +#define g_array_get_element_size _frida_g_array_get_element_size +#define g_array_get_type _frida_g_array_get_type +#define g_array_insert_vals _frida_g_array_insert_vals +#define g_array_new _frida_g_array_new +#define g_array_prepend_vals _frida_g_array_prepend_vals +#define g_array_ref _frida_g_array_ref +#define g_array_remove_index _frida_g_array_remove_index +#define g_array_remove_index_fast _frida_g_array_remove_index_fast +#define g_array_remove_range _frida_g_array_remove_range +#define g_array_set_clear_func _frida_g_array_set_clear_func +#define g_array_set_size _frida_g_array_set_size +#define g_array_sized_new _frida_g_array_sized_new +#define g_array_sort _frida_g_array_sort +#define g_array_sort_with_data _frida_g_array_sort_with_data +#define g_array_steal _frida_g_array_steal +#define g_array_unref _frida_g_array_unref +#define g_ascii_digit_value _frida_g_ascii_digit_value +#define g_ascii_dtostr _frida_g_ascii_dtostr +#define g_ascii_formatd _frida_g_ascii_formatd +#define g_ascii_strcasecmp _frida_g_ascii_strcasecmp +#define g_ascii_strdown _frida_g_ascii_strdown +#define g_ascii_string_to_signed _frida_g_ascii_string_to_signed +#define g_ascii_string_to_unsigned _frida_g_ascii_string_to_unsigned +#define g_ascii_strncasecmp _frida_g_ascii_strncasecmp +#define g_ascii_strtod _frida_g_ascii_strtod +#define g_ascii_strtoll _frida_g_ascii_strtoll +#define g_ascii_strtoull _frida_g_ascii_strtoull +#define g_ascii_strup _frida_g_ascii_strup +#define g_ascii_table _frida_g_ascii_table +#define g_ascii_tolower _frida_g_ascii_tolower +#define g_ascii_toupper _frida_g_ascii_toupper +#define g_ascii_xdigit_value _frida_g_ascii_xdigit_value +#define g_ask_password_flags_get_type _frida_g_ask_password_flags_get_type +#define g_assert_warning _frida_g_assert_warning +#define g_assertion_message _frida_g_assertion_message +#define g_assertion_message_cmpnum _frida_g_assertion_message_cmpnum +#define g_assertion_message_cmpstr _frida_g_assertion_message_cmpstr +#define g_assertion_message_cmpstrv _frida_g_assertion_message_cmpstrv +#define g_assertion_message_error _frida_g_assertion_message_error +#define g_assertion_message_expr _frida_g_assertion_message_expr +#define g_assertion_set_handler _frida_g_assertion_set_handler +#define g_async_initable_get_type _frida_g_async_initable_get_type +#define g_async_initable_init_async _frida_g_async_initable_init_async +#define g_async_initable_init_finish _frida_g_async_initable_init_finish +#define g_async_initable_new_async _frida_g_async_initable_new_async +#define g_async_initable_new_finish _frida_g_async_initable_new_finish +#define g_async_initable_new_valist_async _frida_g_async_initable_new_valist_async +#define g_async_initable_newv_async _frida_g_async_initable_newv_async +#define g_async_queue_length _frida_g_async_queue_length +#define g_async_queue_length_unlocked _frida_g_async_queue_length_unlocked +#define g_async_queue_lock _frida_g_async_queue_lock +#define g_async_queue_new _frida_g_async_queue_new +#define g_async_queue_new_full _frida_g_async_queue_new_full +#define g_async_queue_pop _frida_g_async_queue_pop +#define g_async_queue_pop_unlocked _frida_g_async_queue_pop_unlocked +#define g_async_queue_push _frida_g_async_queue_push +#define g_async_queue_push_front _frida_g_async_queue_push_front +#define g_async_queue_push_front_unlocked _frida_g_async_queue_push_front_unlocked +#define g_async_queue_push_sorted _frida_g_async_queue_push_sorted +#define g_async_queue_push_sorted_unlocked _frida_g_async_queue_push_sorted_unlocked +#define g_async_queue_push_unlocked _frida_g_async_queue_push_unlocked +#define g_async_queue_ref _frida_g_async_queue_ref +#define g_async_queue_ref_unlocked _frida_g_async_queue_ref_unlocked +#define g_async_queue_remove _frida_g_async_queue_remove +#define g_async_queue_remove_unlocked _frida_g_async_queue_remove_unlocked +#define g_async_queue_sort _frida_g_async_queue_sort +#define g_async_queue_sort_unlocked _frida_g_async_queue_sort_unlocked +#define g_async_queue_timed_pop _frida_g_async_queue_timed_pop +#define g_async_queue_timed_pop_unlocked _frida_g_async_queue_timed_pop_unlocked +#define g_async_queue_timeout_pop _frida_g_async_queue_timeout_pop +#define g_async_queue_timeout_pop_unlocked _frida_g_async_queue_timeout_pop_unlocked +#define g_async_queue_try_pop _frida_g_async_queue_try_pop +#define g_async_queue_try_pop_unlocked _frida_g_async_queue_try_pop_unlocked +#define g_async_queue_unlock _frida_g_async_queue_unlock +#define g_async_queue_unref _frida_g_async_queue_unref +#define g_async_queue_unref_and_unlock _frida_g_async_queue_unref_and_unlock +#define g_async_result_get_source_object _frida_g_async_result_get_source_object +#define g_async_result_get_type _frida_g_async_result_get_type +#define g_async_result_get_user_data _frida_g_async_result_get_user_data +#define g_async_result_is_tagged _frida_g_async_result_is_tagged +#define g_async_result_legacy_propagate_error _frida_g_async_result_legacy_propagate_error +#define g_atexit _frida_g_atexit +#define g_atomic_int_add _frida_g_atomic_int_add +#define g_atomic_int_and _frida_g_atomic_int_and +#define g_atomic_int_compare_and_exchange _frida_g_atomic_int_compare_and_exchange +#define g_atomic_int_dec_and_test _frida_g_atomic_int_dec_and_test +#define g_atomic_int_exchange_and_add _frida_g_atomic_int_exchange_and_add +#define g_atomic_int_get _frida_g_atomic_int_get +#define g_atomic_int_inc _frida_g_atomic_int_inc +#define g_atomic_int_or _frida_g_atomic_int_or +#define g_atomic_int_set _frida_g_atomic_int_set +#define g_atomic_int_xor _frida_g_atomic_int_xor +#define g_atomic_pointer_add _frida_g_atomic_pointer_add +#define g_atomic_pointer_and _frida_g_atomic_pointer_and +#define g_atomic_pointer_compare_and_exchange _frida_g_atomic_pointer_compare_and_exchange +#define g_atomic_pointer_get _frida_g_atomic_pointer_get +#define g_atomic_pointer_or _frida_g_atomic_pointer_or +#define g_atomic_pointer_set _frida_g_atomic_pointer_set +#define g_atomic_pointer_xor _frida_g_atomic_pointer_xor +#define g_atomic_rc_box_acquire _frida_g_atomic_rc_box_acquire +#define g_atomic_rc_box_alloc _frida_g_atomic_rc_box_alloc +#define g_atomic_rc_box_alloc0 _frida_g_atomic_rc_box_alloc0 +#define g_atomic_rc_box_dup _frida_g_atomic_rc_box_dup +#define g_atomic_rc_box_get_size _frida_g_atomic_rc_box_get_size +#define g_atomic_rc_box_release _frida_g_atomic_rc_box_release +#define g_atomic_rc_box_release_full _frida_g_atomic_rc_box_release_full +#define g_atomic_ref_count_compare _frida_g_atomic_ref_count_compare +#define g_atomic_ref_count_dec _frida_g_atomic_ref_count_dec +#define g_atomic_ref_count_inc _frida_g_atomic_ref_count_inc +#define g_atomic_ref_count_init _frida_g_atomic_ref_count_init +#define g_base64_decode _frida_g_base64_decode +#define g_base64_decode_inplace _frida_g_base64_decode_inplace +#define g_base64_decode_step _frida_g_base64_decode_step +#define g_base64_encode _frida_g_base64_encode +#define g_base64_encode_close _frida_g_base64_encode_close +#define g_base64_encode_step _frida_g_base64_encode_step +#define g_basename _frida_g_basename +#define g_binding_dup_source _frida_g_binding_dup_source +#define g_binding_dup_target _frida_g_binding_dup_target +#define g_binding_flags_get_type _frida_g_binding_flags_get_type +#define g_binding_get_flags _frida_g_binding_get_flags +#define g_binding_get_source _frida_g_binding_get_source +#define g_binding_get_source_property _frida_g_binding_get_source_property +#define g_binding_get_target _frida_g_binding_get_target +#define g_binding_get_target_property _frida_g_binding_get_target_property +#define g_binding_get_type _frida_g_binding_get_type +#define g_binding_unbind _frida_g_binding_unbind +#define g_bit_lock _frida_g_bit_lock +#define g_bit_nth_lsf _frida_g_bit_nth_lsf +#define g_bit_nth_msf _frida_g_bit_nth_msf +#define g_bit_storage _frida_g_bit_storage +#define g_bit_trylock _frida_g_bit_trylock +#define g_bit_unlock _frida_g_bit_unlock +#define g_blow_chunks _frida_g_blow_chunks +#define g_bookmark_file_add_application _frida_g_bookmark_file_add_application +#define g_bookmark_file_add_group _frida_g_bookmark_file_add_group +#define g_bookmark_file_error_quark _frida_g_bookmark_file_error_quark +#define g_bookmark_file_free _frida_g_bookmark_file_free +#define g_bookmark_file_get_added _frida_g_bookmark_file_get_added +#define g_bookmark_file_get_added_date_time _frida_g_bookmark_file_get_added_date_time +#define g_bookmark_file_get_app_info _frida_g_bookmark_file_get_app_info +#define g_bookmark_file_get_application_info _frida_g_bookmark_file_get_application_info +#define g_bookmark_file_get_applications _frida_g_bookmark_file_get_applications +#define g_bookmark_file_get_description _frida_g_bookmark_file_get_description +#define g_bookmark_file_get_groups _frida_g_bookmark_file_get_groups +#define g_bookmark_file_get_icon _frida_g_bookmark_file_get_icon +#define g_bookmark_file_get_is_private _frida_g_bookmark_file_get_is_private +#define g_bookmark_file_get_mime_type _frida_g_bookmark_file_get_mime_type +#define g_bookmark_file_get_modified _frida_g_bookmark_file_get_modified +#define g_bookmark_file_get_modified_date_time _frida_g_bookmark_file_get_modified_date_time +#define g_bookmark_file_get_size _frida_g_bookmark_file_get_size +#define g_bookmark_file_get_title _frida_g_bookmark_file_get_title +#define g_bookmark_file_get_uris _frida_g_bookmark_file_get_uris +#define g_bookmark_file_get_visited _frida_g_bookmark_file_get_visited +#define g_bookmark_file_get_visited_date_time _frida_g_bookmark_file_get_visited_date_time +#define g_bookmark_file_has_application _frida_g_bookmark_file_has_application +#define g_bookmark_file_has_group _frida_g_bookmark_file_has_group +#define g_bookmark_file_has_item _frida_g_bookmark_file_has_item +#define g_bookmark_file_load_from_data _frida_g_bookmark_file_load_from_data +#define g_bookmark_file_load_from_data_dirs _frida_g_bookmark_file_load_from_data_dirs +#define g_bookmark_file_load_from_file _frida_g_bookmark_file_load_from_file +#define g_bookmark_file_move_item _frida_g_bookmark_file_move_item +#define g_bookmark_file_new _frida_g_bookmark_file_new +#define g_bookmark_file_remove_application _frida_g_bookmark_file_remove_application +#define g_bookmark_file_remove_group _frida_g_bookmark_file_remove_group +#define g_bookmark_file_remove_item _frida_g_bookmark_file_remove_item +#define g_bookmark_file_set_added _frida_g_bookmark_file_set_added +#define g_bookmark_file_set_added_date_time _frida_g_bookmark_file_set_added_date_time +#define g_bookmark_file_set_app_info _frida_g_bookmark_file_set_app_info +#define g_bookmark_file_set_application_info _frida_g_bookmark_file_set_application_info +#define g_bookmark_file_set_description _frida_g_bookmark_file_set_description +#define g_bookmark_file_set_groups _frida_g_bookmark_file_set_groups +#define g_bookmark_file_set_icon _frida_g_bookmark_file_set_icon +#define g_bookmark_file_set_is_private _frida_g_bookmark_file_set_is_private +#define g_bookmark_file_set_mime_type _frida_g_bookmark_file_set_mime_type +#define g_bookmark_file_set_modified _frida_g_bookmark_file_set_modified +#define g_bookmark_file_set_modified_date_time _frida_g_bookmark_file_set_modified_date_time +#define g_bookmark_file_set_title _frida_g_bookmark_file_set_title +#define g_bookmark_file_set_visited _frida_g_bookmark_file_set_visited +#define g_bookmark_file_set_visited_date_time _frida_g_bookmark_file_set_visited_date_time +#define g_bookmark_file_to_data _frida_g_bookmark_file_to_data +#define g_bookmark_file_to_file _frida_g_bookmark_file_to_file +#define g_boxed_copy _frida_g_boxed_copy +#define g_boxed_free _frida_g_boxed_free +#define g_boxed_type_register_static _frida_g_boxed_type_register_static +#define g_buffered_input_stream_fill _frida_g_buffered_input_stream_fill +#define g_buffered_input_stream_fill_async _frida_g_buffered_input_stream_fill_async +#define g_buffered_input_stream_fill_finish _frida_g_buffered_input_stream_fill_finish +#define g_buffered_input_stream_get_available _frida_g_buffered_input_stream_get_available +#define g_buffered_input_stream_get_buffer_size _frida_g_buffered_input_stream_get_buffer_size +#define g_buffered_input_stream_get_type _frida_g_buffered_input_stream_get_type +#define g_buffered_input_stream_new _frida_g_buffered_input_stream_new +#define g_buffered_input_stream_new_sized _frida_g_buffered_input_stream_new_sized +#define g_buffered_input_stream_peek _frida_g_buffered_input_stream_peek +#define g_buffered_input_stream_peek_buffer _frida_g_buffered_input_stream_peek_buffer +#define g_buffered_input_stream_read_byte _frida_g_buffered_input_stream_read_byte +#define g_buffered_input_stream_set_buffer_size _frida_g_buffered_input_stream_set_buffer_size +#define g_buffered_output_stream_get_auto_grow _frida_g_buffered_output_stream_get_auto_grow +#define g_buffered_output_stream_get_buffer_size _frida_g_buffered_output_stream_get_buffer_size +#define g_buffered_output_stream_get_type _frida_g_buffered_output_stream_get_type +#define g_buffered_output_stream_new _frida_g_buffered_output_stream_new +#define g_buffered_output_stream_new_sized _frida_g_buffered_output_stream_new_sized +#define g_buffered_output_stream_set_auto_grow _frida_g_buffered_output_stream_set_auto_grow +#define g_buffered_output_stream_set_buffer_size _frida_g_buffered_output_stream_set_buffer_size +#define g_build_filename _frida_g_build_filename +#define g_build_filename_valist _frida_g_build_filename_valist +#define g_build_filenamev _frida_g_build_filenamev +#define g_build_path _frida_g_build_path +#define g_build_pathv _frida_g_build_pathv +#define g_bus_get _frida_g_bus_get +#define g_bus_get_finish _frida_g_bus_get_finish +#define g_bus_get_sync _frida_g_bus_get_sync +#define g_bus_name_owner_flags_get_type _frida_g_bus_name_owner_flags_get_type +#define g_bus_name_watcher_flags_get_type _frida_g_bus_name_watcher_flags_get_type +#define g_bus_own_name _frida_g_bus_own_name +#define g_bus_own_name_on_connection _frida_g_bus_own_name_on_connection +#define g_bus_own_name_on_connection_with_closures _frida_g_bus_own_name_on_connection_with_closures +#define g_bus_own_name_with_closures _frida_g_bus_own_name_with_closures +#define g_bus_type_get_type _frida_g_bus_type_get_type +#define g_bus_unown_name _frida_g_bus_unown_name +#define g_bus_unwatch_name _frida_g_bus_unwatch_name +#define g_bus_watch_name _frida_g_bus_watch_name +#define g_bus_watch_name_on_connection _frida_g_bus_watch_name_on_connection +#define g_bus_watch_name_on_connection_with_closures _frida_g_bus_watch_name_on_connection_with_closures +#define g_bus_watch_name_with_closures _frida_g_bus_watch_name_with_closures +#define g_byte_array_append _frida_g_byte_array_append +#define g_byte_array_free _frida_g_byte_array_free +#define g_byte_array_free_to_bytes _frida_g_byte_array_free_to_bytes +#define g_byte_array_get_type _frida_g_byte_array_get_type +#define g_byte_array_new _frida_g_byte_array_new +#define g_byte_array_new_take _frida_g_byte_array_new_take +#define g_byte_array_prepend _frida_g_byte_array_prepend +#define g_byte_array_ref _frida_g_byte_array_ref +#define g_byte_array_remove_index _frida_g_byte_array_remove_index +#define g_byte_array_remove_index_fast _frida_g_byte_array_remove_index_fast +#define g_byte_array_remove_range _frida_g_byte_array_remove_range +#define g_byte_array_set_size _frida_g_byte_array_set_size +#define g_byte_array_sized_new _frida_g_byte_array_sized_new +#define g_byte_array_sort _frida_g_byte_array_sort +#define g_byte_array_sort_with_data _frida_g_byte_array_sort_with_data +#define g_byte_array_steal _frida_g_byte_array_steal +#define g_byte_array_unref _frida_g_byte_array_unref +#define g_bytes_compare _frida_g_bytes_compare +#define g_bytes_equal _frida_g_bytes_equal +#define g_bytes_get_data _frida_g_bytes_get_data +#define g_bytes_get_size _frida_g_bytes_get_size +#define g_bytes_get_type _frida_g_bytes_get_type +#define g_bytes_hash _frida_g_bytes_hash +#define g_bytes_icon_get_bytes _frida_g_bytes_icon_get_bytes +#define g_bytes_icon_get_type _frida_g_bytes_icon_get_type +#define g_bytes_icon_new _frida_g_bytes_icon_new +#define g_bytes_new _frida_g_bytes_new +#define g_bytes_new_from_bytes _frida_g_bytes_new_from_bytes +#define g_bytes_new_static _frida_g_bytes_new_static +#define g_bytes_new_take _frida_g_bytes_new_take +#define g_bytes_new_with_free_func _frida_g_bytes_new_with_free_func +#define g_bytes_ref _frida_g_bytes_ref +#define g_bytes_unref _frida_g_bytes_unref +#define g_bytes_unref_to_array _frida_g_bytes_unref_to_array +#define g_bytes_unref_to_data _frida_g_bytes_unref_to_data +#define g_cache_destroy _frida_g_cache_destroy +#define g_cache_insert _frida_g_cache_insert +#define g_cache_key_foreach _frida_g_cache_key_foreach +#define g_cache_new _frida_g_cache_new +#define g_cache_remove _frida_g_cache_remove +#define g_cache_value_foreach _frida_g_cache_value_foreach +#define g_cancellable_cancel _frida_g_cancellable_cancel +#define g_cancellable_connect _frida_g_cancellable_connect +#define g_cancellable_disconnect _frida_g_cancellable_disconnect +#define g_cancellable_get_current _frida_g_cancellable_get_current +#define g_cancellable_get_fd _frida_g_cancellable_get_fd +#define g_cancellable_get_type _frida_g_cancellable_get_type +#define g_cancellable_is_cancelled _frida_g_cancellable_is_cancelled +#define g_cancellable_make_pollfd _frida_g_cancellable_make_pollfd +#define g_cancellable_new _frida_g_cancellable_new +#define g_cancellable_pop_current _frida_g_cancellable_pop_current +#define g_cancellable_push_current _frida_g_cancellable_push_current +#define g_cancellable_release_fd _frida_g_cancellable_release_fd +#define g_cancellable_reset _frida_g_cancellable_reset +#define g_cancellable_set_error_if_cancelled _frida_g_cancellable_set_error_if_cancelled +#define g_cancellable_source_new _frida_g_cancellable_source_new +#define g_canonicalize_filename _frida_g_canonicalize_filename +#define g_cclosure_marshal_BOOLEAN__BOXED_BOXED _frida_g_cclosure_marshal_BOOLEAN__BOXED_BOXED +#define g_cclosure_marshal_BOOLEAN__BOXED_BOXEDv _frida_g_cclosure_marshal_BOOLEAN__BOXED_BOXEDv +#define g_cclosure_marshal_BOOLEAN__FLAGS _frida_g_cclosure_marshal_BOOLEAN__FLAGS +#define g_cclosure_marshal_BOOLEAN__FLAGSv _frida_g_cclosure_marshal_BOOLEAN__FLAGSv +#define g_cclosure_marshal_STRING__OBJECT_POINTER _frida_g_cclosure_marshal_STRING__OBJECT_POINTER +#define g_cclosure_marshal_STRING__OBJECT_POINTERv _frida_g_cclosure_marshal_STRING__OBJECT_POINTERv +#define g_cclosure_marshal_VOID__BOOLEAN _frida_g_cclosure_marshal_VOID__BOOLEAN +#define g_cclosure_marshal_VOID__BOOLEANv _frida_g_cclosure_marshal_VOID__BOOLEANv +#define g_cclosure_marshal_VOID__BOXED _frida_g_cclosure_marshal_VOID__BOXED +#define g_cclosure_marshal_VOID__BOXEDv _frida_g_cclosure_marshal_VOID__BOXEDv +#define g_cclosure_marshal_VOID__CHAR _frida_g_cclosure_marshal_VOID__CHAR +#define g_cclosure_marshal_VOID__CHARv _frida_g_cclosure_marshal_VOID__CHARv +#define g_cclosure_marshal_VOID__DOUBLE _frida_g_cclosure_marshal_VOID__DOUBLE +#define g_cclosure_marshal_VOID__DOUBLEv _frida_g_cclosure_marshal_VOID__DOUBLEv +#define g_cclosure_marshal_VOID__ENUM _frida_g_cclosure_marshal_VOID__ENUM +#define g_cclosure_marshal_VOID__ENUMv _frida_g_cclosure_marshal_VOID__ENUMv +#define g_cclosure_marshal_VOID__FLAGS _frida_g_cclosure_marshal_VOID__FLAGS +#define g_cclosure_marshal_VOID__FLAGSv _frida_g_cclosure_marshal_VOID__FLAGSv +#define g_cclosure_marshal_VOID__FLOAT _frida_g_cclosure_marshal_VOID__FLOAT +#define g_cclosure_marshal_VOID__FLOATv _frida_g_cclosure_marshal_VOID__FLOATv +#define g_cclosure_marshal_VOID__INT _frida_g_cclosure_marshal_VOID__INT +#define g_cclosure_marshal_VOID__INTv _frida_g_cclosure_marshal_VOID__INTv +#define g_cclosure_marshal_VOID__LONG _frida_g_cclosure_marshal_VOID__LONG +#define g_cclosure_marshal_VOID__LONGv _frida_g_cclosure_marshal_VOID__LONGv +#define g_cclosure_marshal_VOID__OBJECT _frida_g_cclosure_marshal_VOID__OBJECT +#define g_cclosure_marshal_VOID__OBJECTv _frida_g_cclosure_marshal_VOID__OBJECTv +#define g_cclosure_marshal_VOID__PARAM _frida_g_cclosure_marshal_VOID__PARAM +#define g_cclosure_marshal_VOID__PARAMv _frida_g_cclosure_marshal_VOID__PARAMv +#define g_cclosure_marshal_VOID__POINTER _frida_g_cclosure_marshal_VOID__POINTER +#define g_cclosure_marshal_VOID__POINTERv _frida_g_cclosure_marshal_VOID__POINTERv +#define g_cclosure_marshal_VOID__STRING _frida_g_cclosure_marshal_VOID__STRING +#define g_cclosure_marshal_VOID__STRINGv _frida_g_cclosure_marshal_VOID__STRINGv +#define g_cclosure_marshal_VOID__UCHAR _frida_g_cclosure_marshal_VOID__UCHAR +#define g_cclosure_marshal_VOID__UCHARv _frida_g_cclosure_marshal_VOID__UCHARv +#define g_cclosure_marshal_VOID__UINT _frida_g_cclosure_marshal_VOID__UINT +#define g_cclosure_marshal_VOID__UINT_POINTER _frida_g_cclosure_marshal_VOID__UINT_POINTER +#define g_cclosure_marshal_VOID__UINT_POINTERv _frida_g_cclosure_marshal_VOID__UINT_POINTERv +#define g_cclosure_marshal_VOID__UINTv _frida_g_cclosure_marshal_VOID__UINTv +#define g_cclosure_marshal_VOID__ULONG _frida_g_cclosure_marshal_VOID__ULONG +#define g_cclosure_marshal_VOID__ULONGv _frida_g_cclosure_marshal_VOID__ULONGv +#define g_cclosure_marshal_VOID__VARIANT _frida_g_cclosure_marshal_VOID__VARIANT +#define g_cclosure_marshal_VOID__VARIANTv _frida_g_cclosure_marshal_VOID__VARIANTv +#define g_cclosure_marshal_VOID__VOID _frida_g_cclosure_marshal_VOID__VOID +#define g_cclosure_marshal_VOID__VOIDv _frida_g_cclosure_marshal_VOID__VOIDv +#define g_cclosure_marshal_generic _frida_g_cclosure_marshal_generic +#define g_cclosure_marshal_generic_va _frida_g_cclosure_marshal_generic_va +#define g_cclosure_new _frida_g_cclosure_new +#define g_cclosure_new_object _frida_g_cclosure_new_object +#define g_cclosure_new_object_swap _frida_g_cclosure_new_object_swap +#define g_cclosure_new_swap _frida_g_cclosure_new_swap +#define g_charset_converter_get_num_fallbacks _frida_g_charset_converter_get_num_fallbacks +#define g_charset_converter_get_type _frida_g_charset_converter_get_type +#define g_charset_converter_get_use_fallback _frida_g_charset_converter_get_use_fallback +#define g_charset_converter_new _frida_g_charset_converter_new +#define g_charset_converter_set_use_fallback _frida_g_charset_converter_set_use_fallback +#define g_chdir _frida_g_chdir +#define g_check_setuid _frida_g_check_setuid +#define g_checksum_copy _frida_g_checksum_copy +#define g_checksum_free _frida_g_checksum_free +#define g_checksum_get_digest _frida_g_checksum_get_digest +#define g_checksum_get_string _frida_g_checksum_get_string +#define g_checksum_get_type _frida_g_checksum_get_type +#define g_checksum_new _frida_g_checksum_new +#define g_checksum_reset _frida_g_checksum_reset +#define g_checksum_type_get_length _frida_g_checksum_type_get_length +#define g_checksum_update _frida_g_checksum_update +#define g_child_watch_add _frida_g_child_watch_add +#define g_child_watch_add_full _frida_g_child_watch_add_full +#define g_child_watch_funcs _frida_g_child_watch_funcs +#define g_child_watch_source_new _frida_g_child_watch_source_new +#define g_chmod _frida_g_chmod +#define g_clear_error _frida_g_clear_error +#define g_clear_handle_id _frida_g_clear_handle_id +#define g_clear_list _frida_g_clear_list +#define g_clear_object _frida_g_clear_object +#define g_clear_pointer _frida_g_clear_pointer +#define g_clear_signal_handler _frida_g_clear_signal_handler +#define g_clear_slist _frida_g_clear_slist +#define g_close _frida_g_close +#define g_closure_add_finalize_notifier _frida_g_closure_add_finalize_notifier +#define g_closure_add_invalidate_notifier _frida_g_closure_add_invalidate_notifier +#define g_closure_add_marshal_guards _frida_g_closure_add_marshal_guards +#define g_closure_get_type _frida_g_closure_get_type +#define g_closure_invalidate _frida_g_closure_invalidate +#define g_closure_invoke _frida_g_closure_invoke +#define g_closure_new_object _frida_g_closure_new_object +#define g_closure_new_simple _frida_g_closure_new_simple +#define g_closure_ref _frida_g_closure_ref +#define g_closure_remove_finalize_notifier _frida_g_closure_remove_finalize_notifier +#define g_closure_remove_invalidate_notifier _frida_g_closure_remove_invalidate_notifier +#define g_closure_set_marshal _frida_g_closure_set_marshal +#define g_closure_set_meta_marshal _frida_g_closure_set_meta_marshal +#define g_closure_sink _frida_g_closure_sink +#define g_closure_unref _frida_g_closure_unref +#define g_completion_add_items _frida_g_completion_add_items +#define g_completion_clear_items _frida_g_completion_clear_items +#define g_completion_complete _frida_g_completion_complete +#define g_completion_complete_utf8 _frida_g_completion_complete_utf8 +#define g_completion_free _frida_g_completion_free +#define g_completion_new _frida_g_completion_new +#define g_completion_remove_items _frida_g_completion_remove_items +#define g_completion_set_compare _frida_g_completion_set_compare +#define g_compute_checksum_for_bytes _frida_g_compute_checksum_for_bytes +#define g_compute_checksum_for_data _frida_g_compute_checksum_for_data +#define g_compute_checksum_for_string _frida_g_compute_checksum_for_string +#define g_compute_hmac_for_bytes _frida_g_compute_hmac_for_bytes +#define g_compute_hmac_for_data _frida_g_compute_hmac_for_data +#define g_compute_hmac_for_string _frida_g_compute_hmac_for_string +#define g_cond_broadcast _frida_g_cond_broadcast +#define g_cond_clear _frida_g_cond_clear +#define g_cond_free _frida_g_cond_free +#define g_cond_init _frida_g_cond_init +#define g_cond_new _frida_g_cond_new +#define g_cond_signal _frida_g_cond_signal +#define g_cond_timed_wait _frida_g_cond_timed_wait +#define g_cond_wait _frida_g_cond_wait +#define g_cond_wait_until _frida_g_cond_wait_until +#define g_content_type_can_be_executable _frida_g_content_type_can_be_executable +#define g_content_type_equals _frida_g_content_type_equals +#define g_content_type_from_mime_type _frida_g_content_type_from_mime_type +#define g_content_type_get_description _frida_g_content_type_get_description +#define g_content_type_get_generic_icon_name _frida_g_content_type_get_generic_icon_name +#define g_content_type_get_icon _frida_g_content_type_get_icon +#define g_content_type_get_mime_dirs _frida_g_content_type_get_mime_dirs +#define g_content_type_get_mime_type _frida_g_content_type_get_mime_type +#define g_content_type_get_symbolic_icon _frida_g_content_type_get_symbolic_icon +#define g_content_type_guess _frida_g_content_type_guess +#define g_content_type_guess_for_tree _frida_g_content_type_guess_for_tree +#define g_content_type_is_a _frida_g_content_type_is_a +#define g_content_type_is_mime_type _frida_g_content_type_is_mime_type +#define g_content_type_is_unknown _frida_g_content_type_is_unknown +#define g_content_type_set_mime_dirs _frida_g_content_type_set_mime_dirs +#define g_content_types_get_registered _frida_g_content_types_get_registered +#define g_context_specific_group_emit _frida_g_context_specific_group_emit +#define g_context_specific_group_get _frida_g_context_specific_group_get +#define g_context_specific_group_remove _frida_g_context_specific_group_remove +#define g_convert _frida_g_convert +#define g_convert_error_quark _frida_g_convert_error_quark +#define g_convert_with_fallback _frida_g_convert_with_fallback +#define g_convert_with_iconv _frida_g_convert_with_iconv +#define g_converter_convert _frida_g_converter_convert +#define g_converter_flags_get_type _frida_g_converter_flags_get_type +#define g_converter_get_type _frida_g_converter_get_type +#define g_converter_input_stream_get_converter _frida_g_converter_input_stream_get_converter +#define g_converter_input_stream_get_type _frida_g_converter_input_stream_get_type +#define g_converter_input_stream_new _frida_g_converter_input_stream_new +#define g_converter_output_stream_get_converter _frida_g_converter_output_stream_get_converter +#define g_converter_output_stream_get_type _frida_g_converter_output_stream_get_type +#define g_converter_output_stream_new _frida_g_converter_output_stream_new +#define g_converter_reset _frida_g_converter_reset +#define g_converter_result_get_type _frida_g_converter_result_get_type +#define g_creat _frida_g_creat +#define g_credentials_get_native _frida_g_credentials_get_native +#define g_credentials_get_type _frida_g_credentials_get_type +#define g_credentials_get_unix_pid _frida_g_credentials_get_unix_pid +#define g_credentials_get_unix_user _frida_g_credentials_get_unix_user +#define g_credentials_is_same_user _frida_g_credentials_is_same_user +#define g_credentials_new _frida_g_credentials_new +#define g_credentials_set_native _frida_g_credentials_set_native +#define g_credentials_set_unix_user _frida_g_credentials_set_unix_user +#define g_credentials_to_string _frida_g_credentials_to_string +#define g_credentials_type_get_type _frida_g_credentials_type_get_type +#define g_data_input_stream_get_byte_order _frida_g_data_input_stream_get_byte_order +#define g_data_input_stream_get_newline_type _frida_g_data_input_stream_get_newline_type +#define g_data_input_stream_get_type _frida_g_data_input_stream_get_type +#define g_data_input_stream_new _frida_g_data_input_stream_new +#define g_data_input_stream_read_byte _frida_g_data_input_stream_read_byte +#define g_data_input_stream_read_int16 _frida_g_data_input_stream_read_int16 +#define g_data_input_stream_read_int32 _frida_g_data_input_stream_read_int32 +#define g_data_input_stream_read_int64 _frida_g_data_input_stream_read_int64 +#define g_data_input_stream_read_line _frida_g_data_input_stream_read_line +#define g_data_input_stream_read_line_async _frida_g_data_input_stream_read_line_async +#define g_data_input_stream_read_line_finish _frida_g_data_input_stream_read_line_finish +#define g_data_input_stream_read_line_finish_utf8 _frida_g_data_input_stream_read_line_finish_utf8 +#define g_data_input_stream_read_line_utf8 _frida_g_data_input_stream_read_line_utf8 +#define g_data_input_stream_read_uint16 _frida_g_data_input_stream_read_uint16 +#define g_data_input_stream_read_uint32 _frida_g_data_input_stream_read_uint32 +#define g_data_input_stream_read_uint64 _frida_g_data_input_stream_read_uint64 +#define g_data_input_stream_read_until _frida_g_data_input_stream_read_until +#define g_data_input_stream_read_until_async _frida_g_data_input_stream_read_until_async +#define g_data_input_stream_read_until_finish _frida_g_data_input_stream_read_until_finish +#define g_data_input_stream_read_upto _frida_g_data_input_stream_read_upto +#define g_data_input_stream_read_upto_async _frida_g_data_input_stream_read_upto_async +#define g_data_input_stream_read_upto_finish _frida_g_data_input_stream_read_upto_finish +#define g_data_input_stream_set_byte_order _frida_g_data_input_stream_set_byte_order +#define g_data_input_stream_set_newline_type _frida_g_data_input_stream_set_newline_type +#define g_data_output_stream_get_byte_order _frida_g_data_output_stream_get_byte_order +#define g_data_output_stream_get_type _frida_g_data_output_stream_get_type +#define g_data_output_stream_new _frida_g_data_output_stream_new +#define g_data_output_stream_put_byte _frida_g_data_output_stream_put_byte +#define g_data_output_stream_put_int16 _frida_g_data_output_stream_put_int16 +#define g_data_output_stream_put_int32 _frida_g_data_output_stream_put_int32 +#define g_data_output_stream_put_int64 _frida_g_data_output_stream_put_int64 +#define g_data_output_stream_put_string _frida_g_data_output_stream_put_string +#define g_data_output_stream_put_uint16 _frida_g_data_output_stream_put_uint16 +#define g_data_output_stream_put_uint32 _frida_g_data_output_stream_put_uint32 +#define g_data_output_stream_put_uint64 _frida_g_data_output_stream_put_uint64 +#define g_data_output_stream_set_byte_order _frida_g_data_output_stream_set_byte_order +#define g_data_stream_byte_order_get_type _frida_g_data_stream_byte_order_get_type +#define g_data_stream_newline_type_get_type _frida_g_data_stream_newline_type_get_type +#define g_datagram_based_condition_check _frida_g_datagram_based_condition_check +#define g_datagram_based_condition_wait _frida_g_datagram_based_condition_wait +#define g_datagram_based_create_source _frida_g_datagram_based_create_source +#define g_datagram_based_get_type _frida_g_datagram_based_get_type +#define g_datagram_based_receive_messages _frida_g_datagram_based_receive_messages +#define g_datagram_based_send_messages _frida_g_datagram_based_send_messages +#define g_datalist_clear _frida_g_datalist_clear +#define g_datalist_foreach _frida_g_datalist_foreach +#define g_datalist_get_data _frida_g_datalist_get_data +#define g_datalist_get_flags _frida_g_datalist_get_flags +#define g_datalist_id_dup_data _frida_g_datalist_id_dup_data +#define g_datalist_id_get_data _frida_g_datalist_id_get_data +#define g_datalist_id_remove_no_notify _frida_g_datalist_id_remove_no_notify +#define g_datalist_id_replace_data _frida_g_datalist_id_replace_data +#define g_datalist_id_set_data_full _frida_g_datalist_id_set_data_full +#define g_datalist_init _frida_g_datalist_init +#define g_datalist_set_flags _frida_g_datalist_set_flags +#define g_datalist_unset_flags _frida_g_datalist_unset_flags +#define g_dataset_destroy _frida_g_dataset_destroy +#define g_dataset_foreach _frida_g_dataset_foreach +#define g_dataset_id_get_data _frida_g_dataset_id_get_data +#define g_dataset_id_remove_no_notify _frida_g_dataset_id_remove_no_notify +#define g_dataset_id_set_data_full _frida_g_dataset_id_set_data_full +#define g_date_add_days _frida_g_date_add_days +#define g_date_add_months _frida_g_date_add_months +#define g_date_add_years _frida_g_date_add_years +#define g_date_clamp _frida_g_date_clamp +#define g_date_clear _frida_g_date_clear +#define g_date_compare _frida_g_date_compare +#define g_date_copy _frida_g_date_copy +#define g_date_days_between _frida_g_date_days_between +#define g_date_free _frida_g_date_free +#define g_date_get_day _frida_g_date_get_day +#define g_date_get_day_of_year _frida_g_date_get_day_of_year +#define g_date_get_days_in_month _frida_g_date_get_days_in_month +#define g_date_get_iso8601_week_of_year _frida_g_date_get_iso8601_week_of_year +#define g_date_get_julian _frida_g_date_get_julian +#define g_date_get_monday_week_of_year _frida_g_date_get_monday_week_of_year +#define g_date_get_monday_weeks_in_year _frida_g_date_get_monday_weeks_in_year +#define g_date_get_month _frida_g_date_get_month +#define g_date_get_sunday_week_of_year _frida_g_date_get_sunday_week_of_year +#define g_date_get_sunday_weeks_in_year _frida_g_date_get_sunday_weeks_in_year +#define g_date_get_type _frida_g_date_get_type +#define g_date_get_weekday _frida_g_date_get_weekday +#define g_date_get_year _frida_g_date_get_year +#define g_date_is_first_of_month _frida_g_date_is_first_of_month +#define g_date_is_last_of_month _frida_g_date_is_last_of_month +#define g_date_is_leap_year _frida_g_date_is_leap_year +#define g_date_new _frida_g_date_new +#define g_date_new_dmy _frida_g_date_new_dmy +#define g_date_new_julian _frida_g_date_new_julian +#define g_date_order _frida_g_date_order +#define g_date_set_day _frida_g_date_set_day +#define g_date_set_dmy _frida_g_date_set_dmy +#define g_date_set_julian _frida_g_date_set_julian +#define g_date_set_month _frida_g_date_set_month +#define g_date_set_parse _frida_g_date_set_parse +#define g_date_set_time _frida_g_date_set_time +#define g_date_set_time_t _frida_g_date_set_time_t +#define g_date_set_time_val _frida_g_date_set_time_val +#define g_date_set_year _frida_g_date_set_year +#define g_date_strftime _frida_g_date_strftime +#define g_date_subtract_days _frida_g_date_subtract_days +#define g_date_subtract_months _frida_g_date_subtract_months +#define g_date_subtract_years _frida_g_date_subtract_years +#define g_date_time_add _frida_g_date_time_add +#define g_date_time_add_days _frida_g_date_time_add_days +#define g_date_time_add_full _frida_g_date_time_add_full +#define g_date_time_add_hours _frida_g_date_time_add_hours +#define g_date_time_add_minutes _frida_g_date_time_add_minutes +#define g_date_time_add_months _frida_g_date_time_add_months +#define g_date_time_add_seconds _frida_g_date_time_add_seconds +#define g_date_time_add_weeks _frida_g_date_time_add_weeks +#define g_date_time_add_years _frida_g_date_time_add_years +#define g_date_time_compare _frida_g_date_time_compare +#define g_date_time_difference _frida_g_date_time_difference +#define g_date_time_equal _frida_g_date_time_equal +#define g_date_time_format _frida_g_date_time_format +#define g_date_time_format_iso8601 _frida_g_date_time_format_iso8601 +#define g_date_time_get_day_of_month _frida_g_date_time_get_day_of_month +#define g_date_time_get_day_of_week _frida_g_date_time_get_day_of_week +#define g_date_time_get_day_of_year _frida_g_date_time_get_day_of_year +#define g_date_time_get_hour _frida_g_date_time_get_hour +#define g_date_time_get_microsecond _frida_g_date_time_get_microsecond +#define g_date_time_get_minute _frida_g_date_time_get_minute +#define g_date_time_get_month _frida_g_date_time_get_month +#define g_date_time_get_second _frida_g_date_time_get_second +#define g_date_time_get_seconds _frida_g_date_time_get_seconds +#define g_date_time_get_timezone _frida_g_date_time_get_timezone +#define g_date_time_get_timezone_abbreviation _frida_g_date_time_get_timezone_abbreviation +#define g_date_time_get_type _frida_g_date_time_get_type +#define g_date_time_get_utc_offset _frida_g_date_time_get_utc_offset +#define g_date_time_get_week_numbering_year _frida_g_date_time_get_week_numbering_year +#define g_date_time_get_week_of_year _frida_g_date_time_get_week_of_year +#define g_date_time_get_year _frida_g_date_time_get_year +#define g_date_time_get_ymd _frida_g_date_time_get_ymd +#define g_date_time_hash _frida_g_date_time_hash +#define g_date_time_is_daylight_savings _frida_g_date_time_is_daylight_savings +#define g_date_time_new _frida_g_date_time_new +#define g_date_time_new_from_iso8601 _frida_g_date_time_new_from_iso8601 +#define g_date_time_new_from_timeval_local _frida_g_date_time_new_from_timeval_local +#define g_date_time_new_from_timeval_utc _frida_g_date_time_new_from_timeval_utc +#define g_date_time_new_from_unix_local _frida_g_date_time_new_from_unix_local +#define g_date_time_new_from_unix_utc _frida_g_date_time_new_from_unix_utc +#define g_date_time_new_local _frida_g_date_time_new_local +#define g_date_time_new_now _frida_g_date_time_new_now +#define g_date_time_new_now_local _frida_g_date_time_new_now_local +#define g_date_time_new_now_utc _frida_g_date_time_new_now_utc +#define g_date_time_new_utc _frida_g_date_time_new_utc +#define g_date_time_ref _frida_g_date_time_ref +#define g_date_time_to_local _frida_g_date_time_to_local +#define g_date_time_to_timeval _frida_g_date_time_to_timeval +#define g_date_time_to_timezone _frida_g_date_time_to_timezone +#define g_date_time_to_unix _frida_g_date_time_to_unix +#define g_date_time_to_utc _frida_g_date_time_to_utc +#define g_date_time_unref _frida_g_date_time_unref +#define g_date_to_struct_tm _frida_g_date_to_struct_tm +#define g_date_valid _frida_g_date_valid +#define g_date_valid_day _frida_g_date_valid_day +#define g_date_valid_dmy _frida_g_date_valid_dmy +#define g_date_valid_julian _frida_g_date_valid_julian +#define g_date_valid_month _frida_g_date_valid_month +#define g_date_valid_weekday _frida_g_date_valid_weekday +#define g_date_valid_year _frida_g_date_valid_year +#define g_dbus_action_group_get _frida_g_dbus_action_group_get +#define g_dbus_action_group_get_type _frida_g_dbus_action_group_get_type +#define g_dbus_action_group_sync _frida_g_dbus_action_group_sync +#define g_dbus_address_escape_value _frida_g_dbus_address_escape_value +#define g_dbus_address_get_for_bus_sync _frida_g_dbus_address_get_for_bus_sync +#define g_dbus_address_get_stream _frida_g_dbus_address_get_stream +#define g_dbus_address_get_stream_finish _frida_g_dbus_address_get_stream_finish +#define g_dbus_address_get_stream_sync _frida_g_dbus_address_get_stream_sync +#define g_dbus_annotation_info_get_type _frida_g_dbus_annotation_info_get_type +#define g_dbus_annotation_info_lookup _frida_g_dbus_annotation_info_lookup +#define g_dbus_annotation_info_ref _frida_g_dbus_annotation_info_ref +#define g_dbus_annotation_info_unref _frida_g_dbus_annotation_info_unref +#define g_dbus_arg_info_get_type _frida_g_dbus_arg_info_get_type +#define g_dbus_arg_info_ref _frida_g_dbus_arg_info_ref +#define g_dbus_arg_info_unref _frida_g_dbus_arg_info_unref +#define g_dbus_auth_observer_allow_mechanism _frida_g_dbus_auth_observer_allow_mechanism +#define g_dbus_auth_observer_authorize_authenticated_peer _frida_g_dbus_auth_observer_authorize_authenticated_peer +#define g_dbus_auth_observer_get_type _frida_g_dbus_auth_observer_get_type +#define g_dbus_auth_observer_new _frida_g_dbus_auth_observer_new +#define g_dbus_call_flags_get_type _frida_g_dbus_call_flags_get_type +#define g_dbus_capability_flags_get_type _frida_g_dbus_capability_flags_get_type +#define g_dbus_connection_add_filter _frida_g_dbus_connection_add_filter +#define g_dbus_connection_call _frida_g_dbus_connection_call +#define g_dbus_connection_call_finish _frida_g_dbus_connection_call_finish +#define g_dbus_connection_call_sync _frida_g_dbus_connection_call_sync +#define g_dbus_connection_call_with_unix_fd_list _frida_g_dbus_connection_call_with_unix_fd_list +#define g_dbus_connection_call_with_unix_fd_list_finish _frida_g_dbus_connection_call_with_unix_fd_list_finish +#define g_dbus_connection_call_with_unix_fd_list_sync _frida_g_dbus_connection_call_with_unix_fd_list_sync +#define g_dbus_connection_close _frida_g_dbus_connection_close +#define g_dbus_connection_close_finish _frida_g_dbus_connection_close_finish +#define g_dbus_connection_close_sync _frida_g_dbus_connection_close_sync +#define g_dbus_connection_emit_signal _frida_g_dbus_connection_emit_signal +#define g_dbus_connection_export_action_group _frida_g_dbus_connection_export_action_group +#define g_dbus_connection_export_menu_model _frida_g_dbus_connection_export_menu_model +#define g_dbus_connection_flags_get_type _frida_g_dbus_connection_flags_get_type +#define g_dbus_connection_flush _frida_g_dbus_connection_flush +#define g_dbus_connection_flush_finish _frida_g_dbus_connection_flush_finish +#define g_dbus_connection_flush_sync _frida_g_dbus_connection_flush_sync +#define g_dbus_connection_get_capabilities _frida_g_dbus_connection_get_capabilities +#define g_dbus_connection_get_exit_on_close _frida_g_dbus_connection_get_exit_on_close +#define g_dbus_connection_get_flags _frida_g_dbus_connection_get_flags +#define g_dbus_connection_get_guid _frida_g_dbus_connection_get_guid +#define g_dbus_connection_get_last_serial _frida_g_dbus_connection_get_last_serial +#define g_dbus_connection_get_peer_credentials _frida_g_dbus_connection_get_peer_credentials +#define g_dbus_connection_get_stream _frida_g_dbus_connection_get_stream +#define g_dbus_connection_get_type _frida_g_dbus_connection_get_type +#define g_dbus_connection_get_unique_name _frida_g_dbus_connection_get_unique_name +#define g_dbus_connection_is_closed _frida_g_dbus_connection_is_closed +#define g_dbus_connection_new _frida_g_dbus_connection_new +#define g_dbus_connection_new_finish _frida_g_dbus_connection_new_finish +#define g_dbus_connection_new_for_address _frida_g_dbus_connection_new_for_address +#define g_dbus_connection_new_for_address_finish _frida_g_dbus_connection_new_for_address_finish +#define g_dbus_connection_new_for_address_sync _frida_g_dbus_connection_new_for_address_sync +#define g_dbus_connection_new_sync _frida_g_dbus_connection_new_sync +#define g_dbus_connection_register_object _frida_g_dbus_connection_register_object +#define g_dbus_connection_register_object_with_closures _frida_g_dbus_connection_register_object_with_closures +#define g_dbus_connection_register_subtree _frida_g_dbus_connection_register_subtree +#define g_dbus_connection_remove_filter _frida_g_dbus_connection_remove_filter +#define g_dbus_connection_send_message _frida_g_dbus_connection_send_message +#define g_dbus_connection_send_message_with_reply _frida_g_dbus_connection_send_message_with_reply +#define g_dbus_connection_send_message_with_reply_finish _frida_g_dbus_connection_send_message_with_reply_finish +#define g_dbus_connection_send_message_with_reply_sync _frida_g_dbus_connection_send_message_with_reply_sync +#define g_dbus_connection_set_exit_on_close _frida_g_dbus_connection_set_exit_on_close +#define g_dbus_connection_signal_subscribe _frida_g_dbus_connection_signal_subscribe +#define g_dbus_connection_signal_unsubscribe _frida_g_dbus_connection_signal_unsubscribe +#define g_dbus_connection_start_message_processing _frida_g_dbus_connection_start_message_processing +#define g_dbus_connection_unexport_action_group _frida_g_dbus_connection_unexport_action_group +#define g_dbus_connection_unexport_menu_model _frida_g_dbus_connection_unexport_menu_model +#define g_dbus_connection_unregister_object _frida_g_dbus_connection_unregister_object +#define g_dbus_connection_unregister_subtree _frida_g_dbus_connection_unregister_subtree +#define g_dbus_error_encode_gerror _frida_g_dbus_error_encode_gerror +#define g_dbus_error_get_remote_error _frida_g_dbus_error_get_remote_error +#define g_dbus_error_get_type _frida_g_dbus_error_get_type +#define g_dbus_error_is_remote_error _frida_g_dbus_error_is_remote_error +#define g_dbus_error_new_for_dbus_error _frida_g_dbus_error_new_for_dbus_error +#define g_dbus_error_quark _frida_g_dbus_error_quark +#define g_dbus_error_register_error _frida_g_dbus_error_register_error +#define g_dbus_error_register_error_domain _frida_g_dbus_error_register_error_domain +#define g_dbus_error_set_dbus_error _frida_g_dbus_error_set_dbus_error +#define g_dbus_error_set_dbus_error_valist _frida_g_dbus_error_set_dbus_error_valist +#define g_dbus_error_strip_remote_error _frida_g_dbus_error_strip_remote_error +#define g_dbus_error_unregister_error _frida_g_dbus_error_unregister_error +#define g_dbus_generate_guid _frida_g_dbus_generate_guid +#define g_dbus_gvalue_to_gvariant _frida_g_dbus_gvalue_to_gvariant +#define g_dbus_gvariant_to_gvalue _frida_g_dbus_gvariant_to_gvalue +#define g_dbus_interface_dup_object _frida_g_dbus_interface_dup_object +#define g_dbus_interface_get_info _frida_g_dbus_interface_get_info +#define g_dbus_interface_get_object _frida_g_dbus_interface_get_object +#define g_dbus_interface_get_type _frida_g_dbus_interface_get_type +#define g_dbus_interface_info_cache_build _frida_g_dbus_interface_info_cache_build +#define g_dbus_interface_info_cache_release _frida_g_dbus_interface_info_cache_release +#define g_dbus_interface_info_generate_xml _frida_g_dbus_interface_info_generate_xml +#define g_dbus_interface_info_get_type _frida_g_dbus_interface_info_get_type +#define g_dbus_interface_info_lookup_method _frida_g_dbus_interface_info_lookup_method +#define g_dbus_interface_info_lookup_property _frida_g_dbus_interface_info_lookup_property +#define g_dbus_interface_info_lookup_signal _frida_g_dbus_interface_info_lookup_signal +#define g_dbus_interface_info_ref _frida_g_dbus_interface_info_ref +#define g_dbus_interface_info_unref _frida_g_dbus_interface_info_unref +#define g_dbus_interface_set_object _frida_g_dbus_interface_set_object +#define g_dbus_interface_skeleton_export _frida_g_dbus_interface_skeleton_export +#define g_dbus_interface_skeleton_flags_get_type _frida_g_dbus_interface_skeleton_flags_get_type +#define g_dbus_interface_skeleton_flush _frida_g_dbus_interface_skeleton_flush +#define g_dbus_interface_skeleton_get_connection _frida_g_dbus_interface_skeleton_get_connection +#define g_dbus_interface_skeleton_get_connections _frida_g_dbus_interface_skeleton_get_connections +#define g_dbus_interface_skeleton_get_flags _frida_g_dbus_interface_skeleton_get_flags +#define g_dbus_interface_skeleton_get_info _frida_g_dbus_interface_skeleton_get_info +#define g_dbus_interface_skeleton_get_object_path _frida_g_dbus_interface_skeleton_get_object_path +#define g_dbus_interface_skeleton_get_properties _frida_g_dbus_interface_skeleton_get_properties +#define g_dbus_interface_skeleton_get_type _frida_g_dbus_interface_skeleton_get_type +#define g_dbus_interface_skeleton_get_vtable _frida_g_dbus_interface_skeleton_get_vtable +#define g_dbus_interface_skeleton_has_connection _frida_g_dbus_interface_skeleton_has_connection +#define g_dbus_interface_skeleton_set_flags _frida_g_dbus_interface_skeleton_set_flags +#define g_dbus_interface_skeleton_unexport _frida_g_dbus_interface_skeleton_unexport +#define g_dbus_interface_skeleton_unexport_from_connection _frida_g_dbus_interface_skeleton_unexport_from_connection +#define g_dbus_is_address _frida_g_dbus_is_address +#define g_dbus_is_guid _frida_g_dbus_is_guid +#define g_dbus_is_interface_name _frida_g_dbus_is_interface_name +#define g_dbus_is_member_name _frida_g_dbus_is_member_name +#define g_dbus_is_name _frida_g_dbus_is_name +#define g_dbus_is_supported_address _frida_g_dbus_is_supported_address +#define g_dbus_is_unique_name _frida_g_dbus_is_unique_name +#define g_dbus_menu_model_get _frida_g_dbus_menu_model_get +#define g_dbus_menu_model_get_type _frida_g_dbus_menu_model_get_type +#define g_dbus_message_byte_order_get_type _frida_g_dbus_message_byte_order_get_type +#define g_dbus_message_bytes_needed _frida_g_dbus_message_bytes_needed +#define g_dbus_message_copy _frida_g_dbus_message_copy +#define g_dbus_message_flags_get_type _frida_g_dbus_message_flags_get_type +#define g_dbus_message_get_arg0 _frida_g_dbus_message_get_arg0 +#define g_dbus_message_get_body _frida_g_dbus_message_get_body +#define g_dbus_message_get_byte_order _frida_g_dbus_message_get_byte_order +#define g_dbus_message_get_destination _frida_g_dbus_message_get_destination +#define g_dbus_message_get_error_name _frida_g_dbus_message_get_error_name +#define g_dbus_message_get_flags _frida_g_dbus_message_get_flags +#define g_dbus_message_get_header _frida_g_dbus_message_get_header +#define g_dbus_message_get_header_fields _frida_g_dbus_message_get_header_fields +#define g_dbus_message_get_interface _frida_g_dbus_message_get_interface +#define g_dbus_message_get_locked _frida_g_dbus_message_get_locked +#define g_dbus_message_get_member _frida_g_dbus_message_get_member +#define g_dbus_message_get_message_type _frida_g_dbus_message_get_message_type +#define g_dbus_message_get_num_unix_fds _frida_g_dbus_message_get_num_unix_fds +#define g_dbus_message_get_path _frida_g_dbus_message_get_path +#define g_dbus_message_get_reply_serial _frida_g_dbus_message_get_reply_serial +#define g_dbus_message_get_sender _frida_g_dbus_message_get_sender +#define g_dbus_message_get_serial _frida_g_dbus_message_get_serial +#define g_dbus_message_get_signature _frida_g_dbus_message_get_signature +#define g_dbus_message_get_type _frida_g_dbus_message_get_type +#define g_dbus_message_get_unix_fd_list _frida_g_dbus_message_get_unix_fd_list +#define g_dbus_message_header_field_get_type _frida_g_dbus_message_header_field_get_type +#define g_dbus_message_lock _frida_g_dbus_message_lock +#define g_dbus_message_new _frida_g_dbus_message_new +#define g_dbus_message_new_from_blob _frida_g_dbus_message_new_from_blob +#define g_dbus_message_new_method_call _frida_g_dbus_message_new_method_call +#define g_dbus_message_new_method_error _frida_g_dbus_message_new_method_error +#define g_dbus_message_new_method_error_literal _frida_g_dbus_message_new_method_error_literal +#define g_dbus_message_new_method_error_valist _frida_g_dbus_message_new_method_error_valist +#define g_dbus_message_new_method_reply _frida_g_dbus_message_new_method_reply +#define g_dbus_message_new_signal _frida_g_dbus_message_new_signal +#define g_dbus_message_print _frida_g_dbus_message_print +#define g_dbus_message_set_body _frida_g_dbus_message_set_body +#define g_dbus_message_set_byte_order _frida_g_dbus_message_set_byte_order +#define g_dbus_message_set_destination _frida_g_dbus_message_set_destination +#define g_dbus_message_set_error_name _frida_g_dbus_message_set_error_name +#define g_dbus_message_set_flags _frida_g_dbus_message_set_flags +#define g_dbus_message_set_header _frida_g_dbus_message_set_header +#define g_dbus_message_set_interface _frida_g_dbus_message_set_interface +#define g_dbus_message_set_member _frida_g_dbus_message_set_member +#define g_dbus_message_set_message_type _frida_g_dbus_message_set_message_type +#define g_dbus_message_set_num_unix_fds _frida_g_dbus_message_set_num_unix_fds +#define g_dbus_message_set_path _frida_g_dbus_message_set_path +#define g_dbus_message_set_reply_serial _frida_g_dbus_message_set_reply_serial +#define g_dbus_message_set_sender _frida_g_dbus_message_set_sender +#define g_dbus_message_set_serial _frida_g_dbus_message_set_serial +#define g_dbus_message_set_signature _frida_g_dbus_message_set_signature +#define g_dbus_message_set_unix_fd_list _frida_g_dbus_message_set_unix_fd_list +#define g_dbus_message_to_blob _frida_g_dbus_message_to_blob +#define g_dbus_message_to_gerror _frida_g_dbus_message_to_gerror +#define g_dbus_message_type_get_type _frida_g_dbus_message_type_get_type +#define g_dbus_method_info_get_type _frida_g_dbus_method_info_get_type +#define g_dbus_method_info_ref _frida_g_dbus_method_info_ref +#define g_dbus_method_info_unref _frida_g_dbus_method_info_unref +#define g_dbus_method_invocation_get_connection _frida_g_dbus_method_invocation_get_connection +#define g_dbus_method_invocation_get_interface_name _frida_g_dbus_method_invocation_get_interface_name +#define g_dbus_method_invocation_get_message _frida_g_dbus_method_invocation_get_message +#define g_dbus_method_invocation_get_method_info _frida_g_dbus_method_invocation_get_method_info +#define g_dbus_method_invocation_get_method_name _frida_g_dbus_method_invocation_get_method_name +#define g_dbus_method_invocation_get_object_path _frida_g_dbus_method_invocation_get_object_path +#define g_dbus_method_invocation_get_parameters _frida_g_dbus_method_invocation_get_parameters +#define g_dbus_method_invocation_get_property_info _frida_g_dbus_method_invocation_get_property_info +#define g_dbus_method_invocation_get_sender _frida_g_dbus_method_invocation_get_sender +#define g_dbus_method_invocation_get_type _frida_g_dbus_method_invocation_get_type +#define g_dbus_method_invocation_get_user_data _frida_g_dbus_method_invocation_get_user_data +#define g_dbus_method_invocation_return_dbus_error _frida_g_dbus_method_invocation_return_dbus_error +#define g_dbus_method_invocation_return_error _frida_g_dbus_method_invocation_return_error +#define g_dbus_method_invocation_return_error_literal _frida_g_dbus_method_invocation_return_error_literal +#define g_dbus_method_invocation_return_error_valist _frida_g_dbus_method_invocation_return_error_valist +#define g_dbus_method_invocation_return_gerror _frida_g_dbus_method_invocation_return_gerror +#define g_dbus_method_invocation_return_value _frida_g_dbus_method_invocation_return_value +#define g_dbus_method_invocation_return_value_with_unix_fd_list _frida_g_dbus_method_invocation_return_value_with_unix_fd_list +#define g_dbus_method_invocation_take_error _frida_g_dbus_method_invocation_take_error +#define g_dbus_node_info_generate_xml _frida_g_dbus_node_info_generate_xml +#define g_dbus_node_info_get_type _frida_g_dbus_node_info_get_type +#define g_dbus_node_info_lookup_interface _frida_g_dbus_node_info_lookup_interface +#define g_dbus_node_info_new_for_xml _frida_g_dbus_node_info_new_for_xml +#define g_dbus_node_info_ref _frida_g_dbus_node_info_ref +#define g_dbus_node_info_unref _frida_g_dbus_node_info_unref +#define g_dbus_object_get_interface _frida_g_dbus_object_get_interface +#define g_dbus_object_get_interfaces _frida_g_dbus_object_get_interfaces +#define g_dbus_object_get_object_path _frida_g_dbus_object_get_object_path +#define g_dbus_object_get_type _frida_g_dbus_object_get_type +#define g_dbus_object_manager_client_flags_get_type _frida_g_dbus_object_manager_client_flags_get_type +#define g_dbus_object_manager_client_get_connection _frida_g_dbus_object_manager_client_get_connection +#define g_dbus_object_manager_client_get_flags _frida_g_dbus_object_manager_client_get_flags +#define g_dbus_object_manager_client_get_name _frida_g_dbus_object_manager_client_get_name +#define g_dbus_object_manager_client_get_name_owner _frida_g_dbus_object_manager_client_get_name_owner +#define g_dbus_object_manager_client_get_type _frida_g_dbus_object_manager_client_get_type +#define g_dbus_object_manager_client_new _frida_g_dbus_object_manager_client_new +#define g_dbus_object_manager_client_new_finish _frida_g_dbus_object_manager_client_new_finish +#define g_dbus_object_manager_client_new_for_bus _frida_g_dbus_object_manager_client_new_for_bus +#define g_dbus_object_manager_client_new_for_bus_finish _frida_g_dbus_object_manager_client_new_for_bus_finish +#define g_dbus_object_manager_client_new_for_bus_sync _frida_g_dbus_object_manager_client_new_for_bus_sync +#define g_dbus_object_manager_client_new_sync _frida_g_dbus_object_manager_client_new_sync +#define g_dbus_object_manager_get_interface _frida_g_dbus_object_manager_get_interface +#define g_dbus_object_manager_get_object _frida_g_dbus_object_manager_get_object +#define g_dbus_object_manager_get_object_path _frida_g_dbus_object_manager_get_object_path +#define g_dbus_object_manager_get_objects _frida_g_dbus_object_manager_get_objects +#define g_dbus_object_manager_get_type _frida_g_dbus_object_manager_get_type +#define g_dbus_object_manager_server_export _frida_g_dbus_object_manager_server_export +#define g_dbus_object_manager_server_export_uniquely _frida_g_dbus_object_manager_server_export_uniquely +#define g_dbus_object_manager_server_get_connection _frida_g_dbus_object_manager_server_get_connection +#define g_dbus_object_manager_server_get_type _frida_g_dbus_object_manager_server_get_type +#define g_dbus_object_manager_server_is_exported _frida_g_dbus_object_manager_server_is_exported +#define g_dbus_object_manager_server_new _frida_g_dbus_object_manager_server_new +#define g_dbus_object_manager_server_set_connection _frida_g_dbus_object_manager_server_set_connection +#define g_dbus_object_manager_server_unexport _frida_g_dbus_object_manager_server_unexport +#define g_dbus_object_proxy_get_connection _frida_g_dbus_object_proxy_get_connection +#define g_dbus_object_proxy_get_type _frida_g_dbus_object_proxy_get_type +#define g_dbus_object_proxy_new _frida_g_dbus_object_proxy_new +#define g_dbus_object_skeleton_add_interface _frida_g_dbus_object_skeleton_add_interface +#define g_dbus_object_skeleton_flush _frida_g_dbus_object_skeleton_flush +#define g_dbus_object_skeleton_get_type _frida_g_dbus_object_skeleton_get_type +#define g_dbus_object_skeleton_new _frida_g_dbus_object_skeleton_new +#define g_dbus_object_skeleton_remove_interface _frida_g_dbus_object_skeleton_remove_interface +#define g_dbus_object_skeleton_remove_interface_by_name _frida_g_dbus_object_skeleton_remove_interface_by_name +#define g_dbus_object_skeleton_set_object_path _frida_g_dbus_object_skeleton_set_object_path +#define g_dbus_property_info_flags_get_type _frida_g_dbus_property_info_flags_get_type +#define g_dbus_property_info_get_type _frida_g_dbus_property_info_get_type +#define g_dbus_property_info_ref _frida_g_dbus_property_info_ref +#define g_dbus_property_info_unref _frida_g_dbus_property_info_unref +#define g_dbus_proxy_call _frida_g_dbus_proxy_call +#define g_dbus_proxy_call_finish _frida_g_dbus_proxy_call_finish +#define g_dbus_proxy_call_sync _frida_g_dbus_proxy_call_sync +#define g_dbus_proxy_call_with_unix_fd_list _frida_g_dbus_proxy_call_with_unix_fd_list +#define g_dbus_proxy_call_with_unix_fd_list_finish _frida_g_dbus_proxy_call_with_unix_fd_list_finish +#define g_dbus_proxy_call_with_unix_fd_list_sync _frida_g_dbus_proxy_call_with_unix_fd_list_sync +#define g_dbus_proxy_flags_get_type _frida_g_dbus_proxy_flags_get_type +#define g_dbus_proxy_get_cached_property _frida_g_dbus_proxy_get_cached_property +#define g_dbus_proxy_get_cached_property_names _frida_g_dbus_proxy_get_cached_property_names +#define g_dbus_proxy_get_connection _frida_g_dbus_proxy_get_connection +#define g_dbus_proxy_get_default_timeout _frida_g_dbus_proxy_get_default_timeout +#define g_dbus_proxy_get_flags _frida_g_dbus_proxy_get_flags +#define g_dbus_proxy_get_interface_info _frida_g_dbus_proxy_get_interface_info +#define g_dbus_proxy_get_interface_name _frida_g_dbus_proxy_get_interface_name +#define g_dbus_proxy_get_name _frida_g_dbus_proxy_get_name +#define g_dbus_proxy_get_name_owner _frida_g_dbus_proxy_get_name_owner +#define g_dbus_proxy_get_object_path _frida_g_dbus_proxy_get_object_path +#define g_dbus_proxy_get_type _frida_g_dbus_proxy_get_type +#define g_dbus_proxy_new _frida_g_dbus_proxy_new +#define g_dbus_proxy_new_finish _frida_g_dbus_proxy_new_finish +#define g_dbus_proxy_new_for_bus _frida_g_dbus_proxy_new_for_bus +#define g_dbus_proxy_new_for_bus_finish _frida_g_dbus_proxy_new_for_bus_finish +#define g_dbus_proxy_new_for_bus_sync _frida_g_dbus_proxy_new_for_bus_sync +#define g_dbus_proxy_new_sync _frida_g_dbus_proxy_new_sync +#define g_dbus_proxy_set_cached_property _frida_g_dbus_proxy_set_cached_property +#define g_dbus_proxy_set_default_timeout _frida_g_dbus_proxy_set_default_timeout +#define g_dbus_proxy_set_interface_info _frida_g_dbus_proxy_set_interface_info +#define g_dbus_send_message_flags_get_type _frida_g_dbus_send_message_flags_get_type +#define g_dbus_server_flags_get_type _frida_g_dbus_server_flags_get_type +#define g_dbus_server_get_client_address _frida_g_dbus_server_get_client_address +#define g_dbus_server_get_flags _frida_g_dbus_server_get_flags +#define g_dbus_server_get_guid _frida_g_dbus_server_get_guid +#define g_dbus_server_get_type _frida_g_dbus_server_get_type +#define g_dbus_server_is_active _frida_g_dbus_server_is_active +#define g_dbus_server_new_sync _frida_g_dbus_server_new_sync +#define g_dbus_server_start _frida_g_dbus_server_start +#define g_dbus_server_stop _frida_g_dbus_server_stop +#define g_dbus_signal_flags_get_type _frida_g_dbus_signal_flags_get_type +#define g_dbus_signal_info_get_type _frida_g_dbus_signal_info_get_type +#define g_dbus_signal_info_ref _frida_g_dbus_signal_info_ref +#define g_dbus_signal_info_unref _frida_g_dbus_signal_info_unref +#define g_dbus_subtree_flags_get_type _frida_g_dbus_subtree_flags_get_type +#define g_dcgettext _frida_g_dcgettext +#define g_delayed_settings_backend_apply _frida_g_delayed_settings_backend_apply +#define g_delayed_settings_backend_get_has_unapplied _frida_g_delayed_settings_backend_get_has_unapplied +#define g_delayed_settings_backend_get_type _frida_g_delayed_settings_backend_get_type +#define g_delayed_settings_backend_new _frida_g_delayed_settings_backend_new +#define g_delayed_settings_backend_revert _frida_g_delayed_settings_backend_revert +#define g_desktop_app_info_get_action_name _frida_g_desktop_app_info_get_action_name +#define g_desktop_app_info_get_boolean _frida_g_desktop_app_info_get_boolean +#define g_desktop_app_info_get_categories _frida_g_desktop_app_info_get_categories +#define g_desktop_app_info_get_filename _frida_g_desktop_app_info_get_filename +#define g_desktop_app_info_get_generic_name _frida_g_desktop_app_info_get_generic_name +#define g_desktop_app_info_get_implementations _frida_g_desktop_app_info_get_implementations +#define g_desktop_app_info_get_is_hidden _frida_g_desktop_app_info_get_is_hidden +#define g_desktop_app_info_get_keywords _frida_g_desktop_app_info_get_keywords +#define g_desktop_app_info_get_locale_string _frida_g_desktop_app_info_get_locale_string +#define g_desktop_app_info_get_nodisplay _frida_g_desktop_app_info_get_nodisplay +#define g_desktop_app_info_get_show_in _frida_g_desktop_app_info_get_show_in +#define g_desktop_app_info_get_startup_wm_class _frida_g_desktop_app_info_get_startup_wm_class +#define g_desktop_app_info_get_string _frida_g_desktop_app_info_get_string +#define g_desktop_app_info_get_string_list _frida_g_desktop_app_info_get_string_list +#define g_desktop_app_info_get_type _frida_g_desktop_app_info_get_type +#define g_desktop_app_info_has_key _frida_g_desktop_app_info_has_key +#define g_desktop_app_info_launch_action _frida_g_desktop_app_info_launch_action +#define g_desktop_app_info_launch_uris_as_manager _frida_g_desktop_app_info_launch_uris_as_manager +#define g_desktop_app_info_launch_uris_as_manager_with_fds _frida_g_desktop_app_info_launch_uris_as_manager_with_fds +#define g_desktop_app_info_list_actions _frida_g_desktop_app_info_list_actions +#define g_desktop_app_info_lookup_get_default_for_uri_scheme _frida_g_desktop_app_info_lookup_get_default_for_uri_scheme +#define g_desktop_app_info_lookup_get_type _frida_g_desktop_app_info_lookup_get_type +#define g_desktop_app_info_new _frida_g_desktop_app_info_new +#define g_desktop_app_info_new_from_filename _frida_g_desktop_app_info_new_from_filename +#define g_desktop_app_info_new_from_keyfile _frida_g_desktop_app_info_new_from_keyfile +#define g_desktop_app_info_search _frida_g_desktop_app_info_search +#define g_desktop_app_info_set_desktop_env _frida_g_desktop_app_info_set_desktop_env +#define g_dgettext _frida_g_dgettext +#define g_dir_close _frida_g_dir_close +#define g_dir_make_tmp _frida_g_dir_make_tmp +#define g_dir_new_from_dirp _frida_g_dir_new_from_dirp +#define g_dir_open _frida_g_dir_open +#define g_dir_open_with_errno _frida_g_dir_open_with_errno +#define g_dir_read_name _frida_g_dir_read_name +#define g_dir_rewind _frida_g_dir_rewind +#define g_direct_equal _frida_g_direct_equal +#define g_direct_hash _frida_g_direct_hash +#define g_dngettext _frida_g_dngettext +#define g_document_portal_add_documents _frida_g_document_portal_add_documents +#define g_double_equal _frida_g_double_equal +#define g_double_hash _frida_g_double_hash +#define g_dpgettext _frida_g_dpgettext +#define g_dpgettext2 _frida_g_dpgettext2 +#define g_drive_can_eject _frida_g_drive_can_eject +#define g_drive_can_poll_for_media _frida_g_drive_can_poll_for_media +#define g_drive_can_start _frida_g_drive_can_start +#define g_drive_can_start_degraded _frida_g_drive_can_start_degraded +#define g_drive_can_stop _frida_g_drive_can_stop +#define g_drive_eject _frida_g_drive_eject +#define g_drive_eject_finish _frida_g_drive_eject_finish +#define g_drive_eject_with_operation _frida_g_drive_eject_with_operation +#define g_drive_eject_with_operation_finish _frida_g_drive_eject_with_operation_finish +#define g_drive_enumerate_identifiers _frida_g_drive_enumerate_identifiers +#define g_drive_get_icon _frida_g_drive_get_icon +#define g_drive_get_identifier _frida_g_drive_get_identifier +#define g_drive_get_name _frida_g_drive_get_name +#define g_drive_get_sort_key _frida_g_drive_get_sort_key +#define g_drive_get_start_stop_type _frida_g_drive_get_start_stop_type +#define g_drive_get_symbolic_icon _frida_g_drive_get_symbolic_icon +#define g_drive_get_type _frida_g_drive_get_type +#define g_drive_get_volumes _frida_g_drive_get_volumes +#define g_drive_has_media _frida_g_drive_has_media +#define g_drive_has_volumes _frida_g_drive_has_volumes +#define g_drive_is_media_check_automatic _frida_g_drive_is_media_check_automatic +#define g_drive_is_media_removable _frida_g_drive_is_media_removable +#define g_drive_is_removable _frida_g_drive_is_removable +#define g_drive_poll_for_media _frida_g_drive_poll_for_media +#define g_drive_poll_for_media_finish _frida_g_drive_poll_for_media_finish +#define g_drive_start _frida_g_drive_start +#define g_drive_start_finish _frida_g_drive_start_finish +#define g_drive_start_flags_get_type _frida_g_drive_start_flags_get_type +#define g_drive_start_stop_type_get_type _frida_g_drive_start_stop_type_get_type +#define g_drive_stop _frida_g_drive_stop +#define g_drive_stop_finish _frida_g_drive_stop_finish +#define g_dtls_client_connection_get_accepted_cas _frida_g_dtls_client_connection_get_accepted_cas +#define g_dtls_client_connection_get_server_identity _frida_g_dtls_client_connection_get_server_identity +#define g_dtls_client_connection_get_type _frida_g_dtls_client_connection_get_type +#define g_dtls_client_connection_get_validation_flags _frida_g_dtls_client_connection_get_validation_flags +#define g_dtls_client_connection_new _frida_g_dtls_client_connection_new +#define g_dtls_client_connection_set_server_identity _frida_g_dtls_client_connection_set_server_identity +#define g_dtls_client_connection_set_validation_flags _frida_g_dtls_client_connection_set_validation_flags +#define g_dtls_connection_close _frida_g_dtls_connection_close +#define g_dtls_connection_close_async _frida_g_dtls_connection_close_async +#define g_dtls_connection_close_finish _frida_g_dtls_connection_close_finish +#define g_dtls_connection_emit_accept_certificate _frida_g_dtls_connection_emit_accept_certificate +#define g_dtls_connection_get_certificate _frida_g_dtls_connection_get_certificate +#define g_dtls_connection_get_channel_binding_data _frida_g_dtls_connection_get_channel_binding_data +#define g_dtls_connection_get_database _frida_g_dtls_connection_get_database +#define g_dtls_connection_get_interaction _frida_g_dtls_connection_get_interaction +#define g_dtls_connection_get_negotiated_protocol _frida_g_dtls_connection_get_negotiated_protocol +#define g_dtls_connection_get_peer_certificate _frida_g_dtls_connection_get_peer_certificate +#define g_dtls_connection_get_peer_certificate_errors _frida_g_dtls_connection_get_peer_certificate_errors +#define g_dtls_connection_get_rehandshake_mode _frida_g_dtls_connection_get_rehandshake_mode +#define g_dtls_connection_get_require_close_notify _frida_g_dtls_connection_get_require_close_notify +#define g_dtls_connection_get_type _frida_g_dtls_connection_get_type +#define g_dtls_connection_handshake _frida_g_dtls_connection_handshake +#define g_dtls_connection_handshake_async _frida_g_dtls_connection_handshake_async +#define g_dtls_connection_handshake_finish _frida_g_dtls_connection_handshake_finish +#define g_dtls_connection_set_advertised_protocols _frida_g_dtls_connection_set_advertised_protocols +#define g_dtls_connection_set_certificate _frida_g_dtls_connection_set_certificate +#define g_dtls_connection_set_database _frida_g_dtls_connection_set_database +#define g_dtls_connection_set_interaction _frida_g_dtls_connection_set_interaction +#define g_dtls_connection_set_rehandshake_mode _frida_g_dtls_connection_set_rehandshake_mode +#define g_dtls_connection_set_require_close_notify _frida_g_dtls_connection_set_require_close_notify +#define g_dtls_connection_shutdown _frida_g_dtls_connection_shutdown +#define g_dtls_connection_shutdown_async _frida_g_dtls_connection_shutdown_async +#define g_dtls_connection_shutdown_finish _frida_g_dtls_connection_shutdown_finish +#define g_dtls_server_connection_get_type _frida_g_dtls_server_connection_get_type +#define g_dtls_server_connection_new _frida_g_dtls_server_connection_new +#define g_emblem_get_icon _frida_g_emblem_get_icon +#define g_emblem_get_origin _frida_g_emblem_get_origin +#define g_emblem_get_type _frida_g_emblem_get_type +#define g_emblem_new _frida_g_emblem_new +#define g_emblem_new_with_origin _frida_g_emblem_new_with_origin +#define g_emblem_origin_get_type _frida_g_emblem_origin_get_type +#define g_emblemed_icon_add_emblem _frida_g_emblemed_icon_add_emblem +#define g_emblemed_icon_clear_emblems _frida_g_emblemed_icon_clear_emblems +#define g_emblemed_icon_get_emblems _frida_g_emblemed_icon_get_emblems +#define g_emblemed_icon_get_icon _frida_g_emblemed_icon_get_icon +#define g_emblemed_icon_get_type _frida_g_emblemed_icon_get_type +#define g_emblemed_icon_new _frida_g_emblemed_icon_new +#define g_enum_complete_type_info _frida_g_enum_complete_type_info +#define g_enum_get_value _frida_g_enum_get_value +#define g_enum_get_value_by_name _frida_g_enum_get_value_by_name +#define g_enum_get_value_by_nick _frida_g_enum_get_value_by_nick +#define g_enum_register_static _frida_g_enum_register_static +#define g_enum_to_string _frida_g_enum_to_string +#define g_environ_getenv _frida_g_environ_getenv +#define g_environ_setenv _frida_g_environ_setenv +#define g_environ_unsetenv _frida_g_environ_unsetenv +#define g_error_copy _frida_g_error_copy +#define g_error_free _frida_g_error_free +#define g_error_get_type _frida_g_error_get_type +#define g_error_matches _frida_g_error_matches +#define g_error_new _frida_g_error_new +#define g_error_new_literal _frida_g_error_new_literal +#define g_error_new_valist _frida_g_error_new_valist +#define g_fdo_notification_backend_get_type _frida_g_fdo_notification_backend_get_type +#define g_file_append_to _frida_g_file_append_to +#define g_file_append_to_async _frida_g_file_append_to_async +#define g_file_append_to_finish _frida_g_file_append_to_finish +#define g_file_attribute_info_flags_get_type _frida_g_file_attribute_info_flags_get_type +#define g_file_attribute_info_list_add _frida_g_file_attribute_info_list_add +#define g_file_attribute_info_list_dup _frida_g_file_attribute_info_list_dup +#define g_file_attribute_info_list_get_type _frida_g_file_attribute_info_list_get_type +#define g_file_attribute_info_list_lookup _frida_g_file_attribute_info_list_lookup +#define g_file_attribute_info_list_new _frida_g_file_attribute_info_list_new +#define g_file_attribute_info_list_ref _frida_g_file_attribute_info_list_ref +#define g_file_attribute_info_list_unref _frida_g_file_attribute_info_list_unref +#define g_file_attribute_matcher_enumerate_namespace _frida_g_file_attribute_matcher_enumerate_namespace +#define g_file_attribute_matcher_enumerate_next _frida_g_file_attribute_matcher_enumerate_next +#define g_file_attribute_matcher_get_type _frida_g_file_attribute_matcher_get_type +#define g_file_attribute_matcher_matches _frida_g_file_attribute_matcher_matches +#define g_file_attribute_matcher_matches_only _frida_g_file_attribute_matcher_matches_only +#define g_file_attribute_matcher_new _frida_g_file_attribute_matcher_new +#define g_file_attribute_matcher_ref _frida_g_file_attribute_matcher_ref +#define g_file_attribute_matcher_subtract _frida_g_file_attribute_matcher_subtract +#define g_file_attribute_matcher_to_string _frida_g_file_attribute_matcher_to_string +#define g_file_attribute_matcher_unref _frida_g_file_attribute_matcher_unref +#define g_file_attribute_status_get_type _frida_g_file_attribute_status_get_type +#define g_file_attribute_type_get_type _frida_g_file_attribute_type_get_type +#define g_file_build_attribute_list_for_copy _frida_g_file_build_attribute_list_for_copy +#define g_file_copy _frida_g_file_copy +#define g_file_copy_async _frida_g_file_copy_async +#define g_file_copy_attributes _frida_g_file_copy_attributes +#define g_file_copy_finish _frida_g_file_copy_finish +#define g_file_copy_flags_get_type _frida_g_file_copy_flags_get_type +#define g_file_create _frida_g_file_create +#define g_file_create_async _frida_g_file_create_async +#define g_file_create_finish _frida_g_file_create_finish +#define g_file_create_flags_get_type _frida_g_file_create_flags_get_type +#define g_file_create_readwrite _frida_g_file_create_readwrite +#define g_file_create_readwrite_async _frida_g_file_create_readwrite_async +#define g_file_create_readwrite_finish _frida_g_file_create_readwrite_finish +#define g_file_delete _frida_g_file_delete +#define g_file_delete_async _frida_g_file_delete_async +#define g_file_delete_finish _frida_g_file_delete_finish +#define g_file_descriptor_based_get_fd _frida_g_file_descriptor_based_get_fd +#define g_file_descriptor_based_get_type _frida_g_file_descriptor_based_get_type +#define g_file_dup _frida_g_file_dup +#define g_file_eject_mountable _frida_g_file_eject_mountable +#define g_file_eject_mountable_finish _frida_g_file_eject_mountable_finish +#define g_file_eject_mountable_with_operation _frida_g_file_eject_mountable_with_operation +#define g_file_eject_mountable_with_operation_finish _frida_g_file_eject_mountable_with_operation_finish +#define g_file_enumerate_children _frida_g_file_enumerate_children +#define g_file_enumerate_children_async _frida_g_file_enumerate_children_async +#define g_file_enumerate_children_finish _frida_g_file_enumerate_children_finish +#define g_file_enumerator_close _frida_g_file_enumerator_close +#define g_file_enumerator_close_async _frida_g_file_enumerator_close_async +#define g_file_enumerator_close_finish _frida_g_file_enumerator_close_finish +#define g_file_enumerator_get_child _frida_g_file_enumerator_get_child +#define g_file_enumerator_get_container _frida_g_file_enumerator_get_container +#define g_file_enumerator_get_type _frida_g_file_enumerator_get_type +#define g_file_enumerator_has_pending _frida_g_file_enumerator_has_pending +#define g_file_enumerator_is_closed _frida_g_file_enumerator_is_closed +#define g_file_enumerator_iterate _frida_g_file_enumerator_iterate +#define g_file_enumerator_next_file _frida_g_file_enumerator_next_file +#define g_file_enumerator_next_files_async _frida_g_file_enumerator_next_files_async +#define g_file_enumerator_next_files_finish _frida_g_file_enumerator_next_files_finish +#define g_file_enumerator_set_pending _frida_g_file_enumerator_set_pending +#define g_file_equal _frida_g_file_equal +#define g_file_error_from_errno _frida_g_file_error_from_errno +#define g_file_error_quark _frida_g_file_error_quark +#define g_file_find_enclosing_mount _frida_g_file_find_enclosing_mount +#define g_file_find_enclosing_mount_async _frida_g_file_find_enclosing_mount_async +#define g_file_find_enclosing_mount_finish _frida_g_file_find_enclosing_mount_finish +#define g_file_get_basename _frida_g_file_get_basename +#define g_file_get_child _frida_g_file_get_child +#define g_file_get_child_for_display_name _frida_g_file_get_child_for_display_name +#define g_file_get_contents _frida_g_file_get_contents +#define g_file_get_parent _frida_g_file_get_parent +#define g_file_get_parse_name _frida_g_file_get_parse_name +#define g_file_get_path _frida_g_file_get_path +#define g_file_get_relative_path _frida_g_file_get_relative_path +#define g_file_get_type _frida_g_file_get_type +#define g_file_get_uri _frida_g_file_get_uri +#define g_file_get_uri_scheme _frida_g_file_get_uri_scheme +#define g_file_has_parent _frida_g_file_has_parent +#define g_file_has_prefix _frida_g_file_has_prefix +#define g_file_has_uri_scheme _frida_g_file_has_uri_scheme +#define g_file_hash _frida_g_file_hash +#define g_file_icon_get_file _frida_g_file_icon_get_file +#define g_file_icon_get_type _frida_g_file_icon_get_type +#define g_file_icon_new _frida_g_file_icon_new +#define g_file_info_clear_status _frida_g_file_info_clear_status +#define g_file_info_copy_into _frida_g_file_info_copy_into +#define g_file_info_dup _frida_g_file_info_dup +#define g_file_info_get_attribute_as_string _frida_g_file_info_get_attribute_as_string +#define g_file_info_get_attribute_boolean _frida_g_file_info_get_attribute_boolean +#define g_file_info_get_attribute_byte_string _frida_g_file_info_get_attribute_byte_string +#define g_file_info_get_attribute_data _frida_g_file_info_get_attribute_data +#define g_file_info_get_attribute_int32 _frida_g_file_info_get_attribute_int32 +#define g_file_info_get_attribute_int64 _frida_g_file_info_get_attribute_int64 +#define g_file_info_get_attribute_object _frida_g_file_info_get_attribute_object +#define g_file_info_get_attribute_status _frida_g_file_info_get_attribute_status +#define g_file_info_get_attribute_string _frida_g_file_info_get_attribute_string +#define g_file_info_get_attribute_stringv _frida_g_file_info_get_attribute_stringv +#define g_file_info_get_attribute_type _frida_g_file_info_get_attribute_type +#define g_file_info_get_attribute_uint32 _frida_g_file_info_get_attribute_uint32 +#define g_file_info_get_attribute_uint64 _frida_g_file_info_get_attribute_uint64 +#define g_file_info_get_content_type _frida_g_file_info_get_content_type +#define g_file_info_get_deletion_date _frida_g_file_info_get_deletion_date +#define g_file_info_get_display_name _frida_g_file_info_get_display_name +#define g_file_info_get_edit_name _frida_g_file_info_get_edit_name +#define g_file_info_get_etag _frida_g_file_info_get_etag +#define g_file_info_get_file_type _frida_g_file_info_get_file_type +#define g_file_info_get_icon _frida_g_file_info_get_icon +#define g_file_info_get_is_backup _frida_g_file_info_get_is_backup +#define g_file_info_get_is_hidden _frida_g_file_info_get_is_hidden +#define g_file_info_get_is_symlink _frida_g_file_info_get_is_symlink +#define g_file_info_get_modification_date_time _frida_g_file_info_get_modification_date_time +#define g_file_info_get_modification_time _frida_g_file_info_get_modification_time +#define g_file_info_get_name _frida_g_file_info_get_name +#define g_file_info_get_size _frida_g_file_info_get_size +#define g_file_info_get_sort_order _frida_g_file_info_get_sort_order +#define g_file_info_get_symbolic_icon _frida_g_file_info_get_symbolic_icon +#define g_file_info_get_symlink_target _frida_g_file_info_get_symlink_target +#define g_file_info_get_type _frida_g_file_info_get_type +#define g_file_info_has_attribute _frida_g_file_info_has_attribute +#define g_file_info_has_namespace _frida_g_file_info_has_namespace +#define g_file_info_list_attributes _frida_g_file_info_list_attributes +#define g_file_info_new _frida_g_file_info_new +#define g_file_info_remove_attribute _frida_g_file_info_remove_attribute +#define g_file_info_set_attribute _frida_g_file_info_set_attribute +#define g_file_info_set_attribute_boolean _frida_g_file_info_set_attribute_boolean +#define g_file_info_set_attribute_byte_string _frida_g_file_info_set_attribute_byte_string +#define g_file_info_set_attribute_int32 _frida_g_file_info_set_attribute_int32 +#define g_file_info_set_attribute_int64 _frida_g_file_info_set_attribute_int64 +#define g_file_info_set_attribute_mask _frida_g_file_info_set_attribute_mask +#define g_file_info_set_attribute_object _frida_g_file_info_set_attribute_object +#define g_file_info_set_attribute_status _frida_g_file_info_set_attribute_status +#define g_file_info_set_attribute_string _frida_g_file_info_set_attribute_string +#define g_file_info_set_attribute_stringv _frida_g_file_info_set_attribute_stringv +#define g_file_info_set_attribute_uint32 _frida_g_file_info_set_attribute_uint32 +#define g_file_info_set_attribute_uint64 _frida_g_file_info_set_attribute_uint64 +#define g_file_info_set_content_type _frida_g_file_info_set_content_type +#define g_file_info_set_display_name _frida_g_file_info_set_display_name +#define g_file_info_set_edit_name _frida_g_file_info_set_edit_name +#define g_file_info_set_file_type _frida_g_file_info_set_file_type +#define g_file_info_set_icon _frida_g_file_info_set_icon +#define g_file_info_set_is_hidden _frida_g_file_info_set_is_hidden +#define g_file_info_set_is_symlink _frida_g_file_info_set_is_symlink +#define g_file_info_set_modification_date_time _frida_g_file_info_set_modification_date_time +#define g_file_info_set_modification_time _frida_g_file_info_set_modification_time +#define g_file_info_set_name _frida_g_file_info_set_name +#define g_file_info_set_size _frida_g_file_info_set_size +#define g_file_info_set_sort_order _frida_g_file_info_set_sort_order +#define g_file_info_set_symbolic_icon _frida_g_file_info_set_symbolic_icon +#define g_file_info_set_symlink_target _frida_g_file_info_set_symlink_target +#define g_file_info_unset_attribute_mask _frida_g_file_info_unset_attribute_mask +#define g_file_input_stream_get_type _frida_g_file_input_stream_get_type +#define g_file_input_stream_query_info _frida_g_file_input_stream_query_info +#define g_file_input_stream_query_info_async _frida_g_file_input_stream_query_info_async +#define g_file_input_stream_query_info_finish _frida_g_file_input_stream_query_info_finish +#define g_file_io_stream_get_etag _frida_g_file_io_stream_get_etag +#define g_file_io_stream_get_type _frida_g_file_io_stream_get_type +#define g_file_io_stream_query_info _frida_g_file_io_stream_query_info +#define g_file_io_stream_query_info_async _frida_g_file_io_stream_query_info_async +#define g_file_io_stream_query_info_finish _frida_g_file_io_stream_query_info_finish +#define g_file_is_native _frida_g_file_is_native +#define g_file_load_bytes _frida_g_file_load_bytes +#define g_file_load_bytes_async _frida_g_file_load_bytes_async +#define g_file_load_bytes_finish _frida_g_file_load_bytes_finish +#define g_file_load_contents _frida_g_file_load_contents +#define g_file_load_contents_async _frida_g_file_load_contents_async +#define g_file_load_contents_finish _frida_g_file_load_contents_finish +#define g_file_load_partial_contents_async _frida_g_file_load_partial_contents_async +#define g_file_load_partial_contents_finish _frida_g_file_load_partial_contents_finish +#define g_file_make_directory _frida_g_file_make_directory +#define g_file_make_directory_async _frida_g_file_make_directory_async +#define g_file_make_directory_finish _frida_g_file_make_directory_finish +#define g_file_make_directory_with_parents _frida_g_file_make_directory_with_parents +#define g_file_make_symbolic_link _frida_g_file_make_symbolic_link +#define g_file_measure_disk_usage _frida_g_file_measure_disk_usage +#define g_file_measure_disk_usage_async _frida_g_file_measure_disk_usage_async +#define g_file_measure_disk_usage_finish _frida_g_file_measure_disk_usage_finish +#define g_file_measure_flags_get_type _frida_g_file_measure_flags_get_type +#define g_file_monitor _frida_g_file_monitor +#define g_file_monitor_cancel _frida_g_file_monitor_cancel +#define g_file_monitor_directory _frida_g_file_monitor_directory +#define g_file_monitor_emit_event _frida_g_file_monitor_emit_event +#define g_file_monitor_event_get_type _frida_g_file_monitor_event_get_type +#define g_file_monitor_file _frida_g_file_monitor_file +#define g_file_monitor_flags_get_type _frida_g_file_monitor_flags_get_type +#define g_file_monitor_get_type _frida_g_file_monitor_get_type +#define g_file_monitor_is_cancelled _frida_g_file_monitor_is_cancelled +#define g_file_monitor_set_rate_limit _frida_g_file_monitor_set_rate_limit +#define g_file_monitor_source_handle_event _frida_g_file_monitor_source_handle_event +#define g_file_mount_enclosing_volume _frida_g_file_mount_enclosing_volume +#define g_file_mount_enclosing_volume_finish _frida_g_file_mount_enclosing_volume_finish +#define g_file_mount_mountable _frida_g_file_mount_mountable +#define g_file_mount_mountable_finish _frida_g_file_mount_mountable_finish +#define g_file_move _frida_g_file_move +#define g_file_new_build_filename _frida_g_file_new_build_filename +#define g_file_new_for_commandline_arg _frida_g_file_new_for_commandline_arg +#define g_file_new_for_commandline_arg_and_cwd _frida_g_file_new_for_commandline_arg_and_cwd +#define g_file_new_for_path _frida_g_file_new_for_path +#define g_file_new_for_uri _frida_g_file_new_for_uri +#define g_file_new_tmp _frida_g_file_new_tmp +#define g_file_open_readwrite _frida_g_file_open_readwrite +#define g_file_open_readwrite_async _frida_g_file_open_readwrite_async +#define g_file_open_readwrite_finish _frida_g_file_open_readwrite_finish +#define g_file_open_tmp _frida_g_file_open_tmp +#define g_file_output_stream_get_etag _frida_g_file_output_stream_get_etag +#define g_file_output_stream_get_type _frida_g_file_output_stream_get_type +#define g_file_output_stream_query_info _frida_g_file_output_stream_query_info +#define g_file_output_stream_query_info_async _frida_g_file_output_stream_query_info_async +#define g_file_output_stream_query_info_finish _frida_g_file_output_stream_query_info_finish +#define g_file_parse_name _frida_g_file_parse_name +#define g_file_peek_path _frida_g_file_peek_path +#define g_file_poll_mountable _frida_g_file_poll_mountable +#define g_file_poll_mountable_finish _frida_g_file_poll_mountable_finish +#define g_file_query_default_handler _frida_g_file_query_default_handler +#define g_file_query_default_handler_async _frida_g_file_query_default_handler_async +#define g_file_query_default_handler_finish _frida_g_file_query_default_handler_finish +#define g_file_query_exists _frida_g_file_query_exists +#define g_file_query_file_type _frida_g_file_query_file_type +#define g_file_query_filesystem_info _frida_g_file_query_filesystem_info +#define g_file_query_filesystem_info_async _frida_g_file_query_filesystem_info_async +#define g_file_query_filesystem_info_finish _frida_g_file_query_filesystem_info_finish +#define g_file_query_info _frida_g_file_query_info +#define g_file_query_info_async _frida_g_file_query_info_async +#define g_file_query_info_finish _frida_g_file_query_info_finish +#define g_file_query_info_flags_get_type _frida_g_file_query_info_flags_get_type +#define g_file_query_settable_attributes _frida_g_file_query_settable_attributes +#define g_file_query_writable_namespaces _frida_g_file_query_writable_namespaces +#define g_file_read _frida_g_file_read +#define g_file_read_async _frida_g_file_read_async +#define g_file_read_finish _frida_g_file_read_finish +#define g_file_read_link _frida_g_file_read_link +#define g_file_replace _frida_g_file_replace +#define g_file_replace_async _frida_g_file_replace_async +#define g_file_replace_contents _frida_g_file_replace_contents +#define g_file_replace_contents_async _frida_g_file_replace_contents_async +#define g_file_replace_contents_bytes_async _frida_g_file_replace_contents_bytes_async +#define g_file_replace_contents_finish _frida_g_file_replace_contents_finish +#define g_file_replace_finish _frida_g_file_replace_finish +#define g_file_replace_readwrite _frida_g_file_replace_readwrite +#define g_file_replace_readwrite_async _frida_g_file_replace_readwrite_async +#define g_file_replace_readwrite_finish _frida_g_file_replace_readwrite_finish +#define g_file_resolve_relative_path _frida_g_file_resolve_relative_path +#define g_file_set_attribute _frida_g_file_set_attribute +#define g_file_set_attribute_byte_string _frida_g_file_set_attribute_byte_string +#define g_file_set_attribute_int32 _frida_g_file_set_attribute_int32 +#define g_file_set_attribute_int64 _frida_g_file_set_attribute_int64 +#define g_file_set_attribute_string _frida_g_file_set_attribute_string +#define g_file_set_attribute_uint32 _frida_g_file_set_attribute_uint32 +#define g_file_set_attribute_uint64 _frida_g_file_set_attribute_uint64 +#define g_file_set_attributes_async _frida_g_file_set_attributes_async +#define g_file_set_attributes_finish _frida_g_file_set_attributes_finish +#define g_file_set_attributes_from_info _frida_g_file_set_attributes_from_info +#define g_file_set_contents _frida_g_file_set_contents +#define g_file_set_contents_full _frida_g_file_set_contents_full +#define g_file_set_display_name _frida_g_file_set_display_name +#define g_file_set_display_name_async _frida_g_file_set_display_name_async +#define g_file_set_display_name_finish _frida_g_file_set_display_name_finish +#define g_file_start_mountable _frida_g_file_start_mountable +#define g_file_start_mountable_finish _frida_g_file_start_mountable_finish +#define g_file_stop_mountable _frida_g_file_stop_mountable +#define g_file_stop_mountable_finish _frida_g_file_stop_mountable_finish +#define g_file_supports_thread_contexts _frida_g_file_supports_thread_contexts +#define g_file_test _frida_g_file_test +#define g_file_trash _frida_g_file_trash +#define g_file_trash_async _frida_g_file_trash_async +#define g_file_trash_finish _frida_g_file_trash_finish +#define g_file_type_get_type _frida_g_file_type_get_type +#define g_file_unmount_mountable _frida_g_file_unmount_mountable +#define g_file_unmount_mountable_finish _frida_g_file_unmount_mountable_finish +#define g_file_unmount_mountable_with_operation _frida_g_file_unmount_mountable_with_operation +#define g_file_unmount_mountable_with_operation_finish _frida_g_file_unmount_mountable_with_operation_finish +#define g_filename_completer_get_completion_suffix _frida_g_filename_completer_get_completion_suffix +#define g_filename_completer_get_completions _frida_g_filename_completer_get_completions +#define g_filename_completer_get_type _frida_g_filename_completer_get_type +#define g_filename_completer_new _frida_g_filename_completer_new +#define g_filename_completer_set_dirs_only _frida_g_filename_completer_set_dirs_only +#define g_filename_display_basename _frida_g_filename_display_basename +#define g_filename_display_name _frida_g_filename_display_name +#define g_filename_from_uri _frida_g_filename_from_uri +#define g_filename_from_utf8 _frida_g_filename_from_utf8 +#define g_filename_to_uri _frida_g_filename_to_uri +#define g_filename_to_utf8 _frida_g_filename_to_utf8 +#define g_filesystem_preview_type_get_type _frida_g_filesystem_preview_type_get_type +#define g_filter_input_stream_get_base_stream _frida_g_filter_input_stream_get_base_stream +#define g_filter_input_stream_get_close_base_stream _frida_g_filter_input_stream_get_close_base_stream +#define g_filter_input_stream_get_type _frida_g_filter_input_stream_get_type +#define g_filter_input_stream_set_close_base_stream _frida_g_filter_input_stream_set_close_base_stream +#define g_filter_output_stream_get_base_stream _frida_g_filter_output_stream_get_base_stream +#define g_filter_output_stream_get_close_base_stream _frida_g_filter_output_stream_get_close_base_stream +#define g_filter_output_stream_get_type _frida_g_filter_output_stream_get_type +#define g_filter_output_stream_set_close_base_stream _frida_g_filter_output_stream_set_close_base_stream +#define g_find_program_in_path _frida_g_find_program_in_path +#define g_flags_complete_type_info _frida_g_flags_complete_type_info +#define g_flags_get_first_value _frida_g_flags_get_first_value +#define g_flags_get_value_by_name _frida_g_flags_get_value_by_name +#define g_flags_get_value_by_nick _frida_g_flags_get_value_by_nick +#define g_flags_register_static _frida_g_flags_register_static +#define g_flags_to_string _frida_g_flags_to_string +#define g_fopen _frida_g_fopen +#define g_format_size _frida_g_format_size +#define g_format_size_for_display _frida_g_format_size_for_display +#define g_format_size_full _frida_g_format_size_full +#define g_fprintf _frida_g_fprintf +#define g_free _frida_g_free +#define g_freopen _frida_g_freopen +#define g_fsync _frida_g_fsync +#define g_get_application_name _frida_g_get_application_name +#define g_get_charset _frida_g_get_charset +#define g_get_codeset _frida_g_get_codeset +#define g_get_console_charset _frida_g_get_console_charset +#define g_get_current_dir _frida_g_get_current_dir +#define g_get_current_time _frida_g_get_current_time +#define g_get_environ _frida_g_get_environ +#define g_get_filename_charsets _frida_g_get_filename_charsets +#define g_get_home_dir _frida_g_get_home_dir +#define g_get_host_name _frida_g_get_host_name +#define g_get_language_names _frida_g_get_language_names +#define g_get_language_names_with_category _frida_g_get_language_names_with_category +#define g_get_locale_variants _frida_g_get_locale_variants +#define g_get_monotonic_time _frida_g_get_monotonic_time +#define g_get_num_processors _frida_g_get_num_processors +#define g_get_os_info _frida_g_get_os_info +#define g_get_prgname _frida_g_get_prgname +#define g_get_real_name _frida_g_get_real_name +#define g_get_real_time _frida_g_get_real_time +#define g_get_system_config_dirs _frida_g_get_system_config_dirs +#define g_get_system_data_dirs _frida_g_get_system_data_dirs +#define g_get_tmp_dir _frida_g_get_tmp_dir +#define g_get_user_cache_dir _frida_g_get_user_cache_dir +#define g_get_user_config_dir _frida_g_get_user_config_dir +#define g_get_user_data_dir _frida_g_get_user_data_dir +#define g_get_user_name _frida_g_get_user_name +#define g_get_user_runtime_dir _frida_g_get_user_runtime_dir +#define g_get_user_special_dir _frida_g_get_user_special_dir +#define g_get_worker_context _frida_g_get_worker_context +#define g_getenv _frida_g_getenv +#define g_gstring_get_type _frida_g_gstring_get_type +#define g_gtk_notification_backend_get_type _frida_g_gtk_notification_backend_get_type +#define g_gtype_get_type _frida_g_gtype_get_type +#define g_hash_table_add _frida_g_hash_table_add +#define g_hash_table_contains _frida_g_hash_table_contains +#define g_hash_table_destroy _frida_g_hash_table_destroy +#define g_hash_table_find _frida_g_hash_table_find +#define g_hash_table_foreach _frida_g_hash_table_foreach +#define g_hash_table_foreach_remove _frida_g_hash_table_foreach_remove +#define g_hash_table_foreach_steal _frida_g_hash_table_foreach_steal +#define g_hash_table_get_keys _frida_g_hash_table_get_keys +#define g_hash_table_get_keys_as_array _frida_g_hash_table_get_keys_as_array +#define g_hash_table_get_type _frida_g_hash_table_get_type +#define g_hash_table_get_values _frida_g_hash_table_get_values +#define g_hash_table_insert _frida_g_hash_table_insert +#define g_hash_table_iter_get_hash_table _frida_g_hash_table_iter_get_hash_table +#define g_hash_table_iter_init _frida_g_hash_table_iter_init +#define g_hash_table_iter_next _frida_g_hash_table_iter_next +#define g_hash_table_iter_remove _frida_g_hash_table_iter_remove +#define g_hash_table_iter_replace _frida_g_hash_table_iter_replace +#define g_hash_table_iter_steal _frida_g_hash_table_iter_steal +#define g_hash_table_lookup _frida_g_hash_table_lookup +#define g_hash_table_lookup_extended _frida_g_hash_table_lookup_extended +#define g_hash_table_new _frida_g_hash_table_new +#define g_hash_table_new_full _frida_g_hash_table_new_full +#define g_hash_table_ref _frida_g_hash_table_ref +#define g_hash_table_remove _frida_g_hash_table_remove +#define g_hash_table_remove_all _frida_g_hash_table_remove_all +#define g_hash_table_replace _frida_g_hash_table_replace +#define g_hash_table_size _frida_g_hash_table_size +#define g_hash_table_steal _frida_g_hash_table_steal +#define g_hash_table_steal_all _frida_g_hash_table_steal_all +#define g_hash_table_steal_extended _frida_g_hash_table_steal_extended +#define g_hash_table_unref _frida_g_hash_table_unref +#define g_hmac_copy _frida_g_hmac_copy +#define g_hmac_get_digest _frida_g_hmac_get_digest +#define g_hmac_get_string _frida_g_hmac_get_string +#define g_hmac_new _frida_g_hmac_new +#define g_hmac_ref _frida_g_hmac_ref +#define g_hmac_unref _frida_g_hmac_unref +#define g_hmac_update _frida_g_hmac_update +#define g_hook_alloc _frida_g_hook_alloc +#define g_hook_compare_ids _frida_g_hook_compare_ids +#define g_hook_destroy _frida_g_hook_destroy +#define g_hook_destroy_link _frida_g_hook_destroy_link +#define g_hook_find _frida_g_hook_find +#define g_hook_find_data _frida_g_hook_find_data +#define g_hook_find_func _frida_g_hook_find_func +#define g_hook_find_func_data _frida_g_hook_find_func_data +#define g_hook_first_valid _frida_g_hook_first_valid +#define g_hook_free _frida_g_hook_free +#define g_hook_get _frida_g_hook_get +#define g_hook_insert_before _frida_g_hook_insert_before +#define g_hook_insert_sorted _frida_g_hook_insert_sorted +#define g_hook_list_clear _frida_g_hook_list_clear +#define g_hook_list_init _frida_g_hook_list_init +#define g_hook_list_invoke _frida_g_hook_list_invoke +#define g_hook_list_invoke_check _frida_g_hook_list_invoke_check +#define g_hook_list_marshal _frida_g_hook_list_marshal +#define g_hook_list_marshal_check _frida_g_hook_list_marshal_check +#define g_hook_next_valid _frida_g_hook_next_valid +#define g_hook_prepend _frida_g_hook_prepend +#define g_hook_ref _frida_g_hook_ref +#define g_hook_unref _frida_g_hook_unref +#define g_hostname_is_ascii_encoded _frida_g_hostname_is_ascii_encoded +#define g_hostname_is_ip_address _frida_g_hostname_is_ip_address +#define g_hostname_is_non_ascii _frida_g_hostname_is_non_ascii +#define g_hostname_to_ascii _frida_g_hostname_to_ascii +#define g_hostname_to_unicode _frida_g_hostname_to_unicode +#define g_icon_deserialize _frida_g_icon_deserialize +#define g_icon_equal _frida_g_icon_equal +#define g_icon_get_type _frida_g_icon_get_type +#define g_icon_hash _frida_g_icon_hash +#define g_icon_new_for_string _frida_g_icon_new_for_string +#define g_icon_serialize _frida_g_icon_serialize +#define g_icon_to_string _frida_g_icon_to_string +#define g_iconv _frida_g_iconv +#define g_iconv_close _frida_g_iconv_close +#define g_iconv_open _frida_g_iconv_open +#define g_idle_add _frida_g_idle_add +#define g_idle_add_full _frida_g_idle_add_full +#define g_idle_funcs _frida_g_idle_funcs +#define g_idle_remove_by_data _frida_g_idle_remove_by_data +#define g_idle_source_new _frida_g_idle_source_new +#define g_inet_address_equal _frida_g_inet_address_equal +#define g_inet_address_get_family _frida_g_inet_address_get_family +#define g_inet_address_get_is_any _frida_g_inet_address_get_is_any +#define g_inet_address_get_is_link_local _frida_g_inet_address_get_is_link_local +#define g_inet_address_get_is_loopback _frida_g_inet_address_get_is_loopback +#define g_inet_address_get_is_mc_global _frida_g_inet_address_get_is_mc_global +#define g_inet_address_get_is_mc_link_local _frida_g_inet_address_get_is_mc_link_local +#define g_inet_address_get_is_mc_node_local _frida_g_inet_address_get_is_mc_node_local +#define g_inet_address_get_is_mc_org_local _frida_g_inet_address_get_is_mc_org_local +#define g_inet_address_get_is_mc_site_local _frida_g_inet_address_get_is_mc_site_local +#define g_inet_address_get_is_multicast _frida_g_inet_address_get_is_multicast +#define g_inet_address_get_is_site_local _frida_g_inet_address_get_is_site_local +#define g_inet_address_get_native_size _frida_g_inet_address_get_native_size +#define g_inet_address_get_type _frida_g_inet_address_get_type +#define g_inet_address_mask_equal _frida_g_inet_address_mask_equal +#define g_inet_address_mask_get_address _frida_g_inet_address_mask_get_address +#define g_inet_address_mask_get_family _frida_g_inet_address_mask_get_family +#define g_inet_address_mask_get_length _frida_g_inet_address_mask_get_length +#define g_inet_address_mask_get_type _frida_g_inet_address_mask_get_type +#define g_inet_address_mask_matches _frida_g_inet_address_mask_matches +#define g_inet_address_mask_new _frida_g_inet_address_mask_new +#define g_inet_address_mask_new_from_string _frida_g_inet_address_mask_new_from_string +#define g_inet_address_mask_to_string _frida_g_inet_address_mask_to_string +#define g_inet_address_new_any _frida_g_inet_address_new_any +#define g_inet_address_new_from_bytes _frida_g_inet_address_new_from_bytes +#define g_inet_address_new_from_string _frida_g_inet_address_new_from_string +#define g_inet_address_new_loopback _frida_g_inet_address_new_loopback +#define g_inet_address_to_bytes _frida_g_inet_address_to_bytes +#define g_inet_address_to_string _frida_g_inet_address_to_string +#define g_inet_socket_address_get_address _frida_g_inet_socket_address_get_address +#define g_inet_socket_address_get_flowinfo _frida_g_inet_socket_address_get_flowinfo +#define g_inet_socket_address_get_port _frida_g_inet_socket_address_get_port +#define g_inet_socket_address_get_scope_id _frida_g_inet_socket_address_get_scope_id +#define g_inet_socket_address_get_type _frida_g_inet_socket_address_get_type +#define g_inet_socket_address_new _frida_g_inet_socket_address_new +#define g_inet_socket_address_new_from_string _frida_g_inet_socket_address_new_from_string +#define g_initable_get_type _frida_g_initable_get_type +#define g_initable_init _frida_g_initable_init +#define g_initable_new _frida_g_initable_new +#define g_initable_new_valist _frida_g_initable_new_valist +#define g_initable_newv _frida_g_initable_newv +#define g_initially_unowned_get_type _frida_g_initially_unowned_get_type +#define g_inotify_file_monitor_get_type _frida_g_inotify_file_monitor_get_type +#define g_input_stream_async_close_is_via_threads _frida_g_input_stream_async_close_is_via_threads +#define g_input_stream_async_read_is_via_threads _frida_g_input_stream_async_read_is_via_threads +#define g_input_stream_clear_pending _frida_g_input_stream_clear_pending +#define g_input_stream_close _frida_g_input_stream_close +#define g_input_stream_close_async _frida_g_input_stream_close_async +#define g_input_stream_close_finish _frida_g_input_stream_close_finish +#define g_input_stream_get_type _frida_g_input_stream_get_type +#define g_input_stream_has_pending _frida_g_input_stream_has_pending +#define g_input_stream_is_closed _frida_g_input_stream_is_closed +#define g_input_stream_read _frida_g_input_stream_read +#define g_input_stream_read_all _frida_g_input_stream_read_all +#define g_input_stream_read_all_async _frida_g_input_stream_read_all_async +#define g_input_stream_read_all_finish _frida_g_input_stream_read_all_finish +#define g_input_stream_read_async _frida_g_input_stream_read_async +#define g_input_stream_read_bytes _frida_g_input_stream_read_bytes +#define g_input_stream_read_bytes_async _frida_g_input_stream_read_bytes_async +#define g_input_stream_read_bytes_finish _frida_g_input_stream_read_bytes_finish +#define g_input_stream_read_finish _frida_g_input_stream_read_finish +#define g_input_stream_set_pending _frida_g_input_stream_set_pending +#define g_input_stream_skip _frida_g_input_stream_skip +#define g_input_stream_skip_async _frida_g_input_stream_skip_async +#define g_input_stream_skip_finish _frida_g_input_stream_skip_finish +#define g_int64_equal _frida_g_int64_equal +#define g_int64_hash _frida_g_int64_hash +#define g_int_equal _frida_g_int_equal +#define g_int_hash _frida_g_int_hash +#define g_intern_static_string _frida_g_intern_static_string +#define g_intern_string _frida_g_intern_string +#define g_io_add_watch _frida_g_io_add_watch +#define g_io_add_watch_full _frida_g_io_add_watch_full +#define g_io_channel_close _frida_g_io_channel_close +#define g_io_channel_error_from_errno _frida_g_io_channel_error_from_errno +#define g_io_channel_error_quark _frida_g_io_channel_error_quark +#define g_io_channel_flush _frida_g_io_channel_flush +#define g_io_channel_get_buffer_condition _frida_g_io_channel_get_buffer_condition +#define g_io_channel_get_buffer_size _frida_g_io_channel_get_buffer_size +#define g_io_channel_get_buffered _frida_g_io_channel_get_buffered +#define g_io_channel_get_close_on_unref _frida_g_io_channel_get_close_on_unref +#define g_io_channel_get_encoding _frida_g_io_channel_get_encoding +#define g_io_channel_get_flags _frida_g_io_channel_get_flags +#define g_io_channel_get_line_term _frida_g_io_channel_get_line_term +#define g_io_channel_get_type _frida_g_io_channel_get_type +#define g_io_channel_init _frida_g_io_channel_init +#define g_io_channel_new_file _frida_g_io_channel_new_file +#define g_io_channel_read _frida_g_io_channel_read +#define g_io_channel_read_chars _frida_g_io_channel_read_chars +#define g_io_channel_read_line _frida_g_io_channel_read_line +#define g_io_channel_read_line_string _frida_g_io_channel_read_line_string +#define g_io_channel_read_to_end _frida_g_io_channel_read_to_end +#define g_io_channel_read_unichar _frida_g_io_channel_read_unichar +#define g_io_channel_ref _frida_g_io_channel_ref +#define g_io_channel_seek _frida_g_io_channel_seek +#define g_io_channel_seek_position _frida_g_io_channel_seek_position +#define g_io_channel_set_buffer_size _frida_g_io_channel_set_buffer_size +#define g_io_channel_set_buffered _frida_g_io_channel_set_buffered +#define g_io_channel_set_close_on_unref _frida_g_io_channel_set_close_on_unref +#define g_io_channel_set_encoding _frida_g_io_channel_set_encoding +#define g_io_channel_set_flags _frida_g_io_channel_set_flags +#define g_io_channel_set_line_term _frida_g_io_channel_set_line_term +#define g_io_channel_shutdown _frida_g_io_channel_shutdown +#define g_io_channel_unix_get_fd _frida_g_io_channel_unix_get_fd +#define g_io_channel_unix_new _frida_g_io_channel_unix_new +#define g_io_channel_unref _frida_g_io_channel_unref +#define g_io_channel_write _frida_g_io_channel_write +#define g_io_channel_write_chars _frida_g_io_channel_write_chars +#define g_io_channel_write_unichar _frida_g_io_channel_write_unichar +#define g_io_condition_get_type _frida_g_io_condition_get_type +#define g_io_create_watch _frida_g_io_create_watch +#define g_io_error_enum_get_type _frida_g_io_error_enum_get_type +#define g_io_error_from_errno _frida_g_io_error_from_errno +#define g_io_error_quark _frida_g_io_error_quark +#define g_io_extension_get_name _frida_g_io_extension_get_name +#define g_io_extension_get_priority _frida_g_io_extension_get_priority +#define g_io_extension_get_type _frida_g_io_extension_get_type +#define g_io_extension_point_get_extension_by_name _frida_g_io_extension_point_get_extension_by_name +#define g_io_extension_point_get_extensions _frida_g_io_extension_point_get_extensions +#define g_io_extension_point_get_required_type _frida_g_io_extension_point_get_required_type +#define g_io_extension_point_implement _frida_g_io_extension_point_implement +#define g_io_extension_point_lookup _frida_g_io_extension_point_lookup +#define g_io_extension_point_register _frida_g_io_extension_point_register +#define g_io_extension_point_set_required_type _frida_g_io_extension_point_set_required_type +#define g_io_extension_ref_class _frida_g_io_extension_ref_class +#define g_io_module_get_type _frida_g_io_module_get_type +#define g_io_module_new _frida_g_io_module_new +#define g_io_module_scope_block _frida_g_io_module_scope_block +#define g_io_module_scope_flags_get_type _frida_g_io_module_scope_flags_get_type +#define g_io_module_scope_free _frida_g_io_module_scope_free +#define g_io_module_scope_new _frida_g_io_module_scope_new +#define g_io_modules_load_all_in_directory _frida_g_io_modules_load_all_in_directory +#define g_io_modules_load_all_in_directory_with_scope _frida_g_io_modules_load_all_in_directory_with_scope +#define g_io_modules_scan_all_in_directory _frida_g_io_modules_scan_all_in_directory +#define g_io_modules_scan_all_in_directory_with_scope _frida_g_io_modules_scan_all_in_directory_with_scope +#define g_io_scheduler_cancel_all_jobs _frida_g_io_scheduler_cancel_all_jobs +#define g_io_scheduler_job_send_to_mainloop _frida_g_io_scheduler_job_send_to_mainloop +#define g_io_scheduler_job_send_to_mainloop_async _frida_g_io_scheduler_job_send_to_mainloop_async +#define g_io_scheduler_push_job _frida_g_io_scheduler_push_job +#define g_io_stream_clear_pending _frida_g_io_stream_clear_pending +#define g_io_stream_close _frida_g_io_stream_close +#define g_io_stream_close_async _frida_g_io_stream_close_async +#define g_io_stream_close_finish _frida_g_io_stream_close_finish +#define g_io_stream_get_input_stream _frida_g_io_stream_get_input_stream +#define g_io_stream_get_output_stream _frida_g_io_stream_get_output_stream +#define g_io_stream_get_type _frida_g_io_stream_get_type +#define g_io_stream_has_pending _frida_g_io_stream_has_pending +#define g_io_stream_is_closed _frida_g_io_stream_is_closed +#define g_io_stream_set_pending _frida_g_io_stream_set_pending +#define g_io_stream_splice_async _frida_g_io_stream_splice_async +#define g_io_stream_splice_finish _frida_g_io_stream_splice_finish +#define g_io_stream_splice_flags_get_type _frida_g_io_stream_splice_flags_get_type +#define g_io_watch_funcs _frida_g_io_watch_funcs +#define g_key_file_error_quark _frida_g_key_file_error_quark +#define g_key_file_free _frida_g_key_file_free +#define g_key_file_get_boolean _frida_g_key_file_get_boolean +#define g_key_file_get_boolean_list _frida_g_key_file_get_boolean_list +#define g_key_file_get_comment _frida_g_key_file_get_comment +#define g_key_file_get_double _frida_g_key_file_get_double +#define g_key_file_get_double_list _frida_g_key_file_get_double_list +#define g_key_file_get_groups _frida_g_key_file_get_groups +#define g_key_file_get_int64 _frida_g_key_file_get_int64 +#define g_key_file_get_integer _frida_g_key_file_get_integer +#define g_key_file_get_integer_list _frida_g_key_file_get_integer_list +#define g_key_file_get_keys _frida_g_key_file_get_keys +#define g_key_file_get_locale_for_key _frida_g_key_file_get_locale_for_key +#define g_key_file_get_locale_string _frida_g_key_file_get_locale_string +#define g_key_file_get_locale_string_list _frida_g_key_file_get_locale_string_list +#define g_key_file_get_start_group _frida_g_key_file_get_start_group +#define g_key_file_get_string _frida_g_key_file_get_string +#define g_key_file_get_string_list _frida_g_key_file_get_string_list +#define g_key_file_get_type _frida_g_key_file_get_type +#define g_key_file_get_uint64 _frida_g_key_file_get_uint64 +#define g_key_file_get_value _frida_g_key_file_get_value +#define g_key_file_has_group _frida_g_key_file_has_group +#define g_key_file_has_key _frida_g_key_file_has_key +#define g_key_file_load_from_bytes _frida_g_key_file_load_from_bytes +#define g_key_file_load_from_data _frida_g_key_file_load_from_data +#define g_key_file_load_from_data_dirs _frida_g_key_file_load_from_data_dirs +#define g_key_file_load_from_dirs _frida_g_key_file_load_from_dirs +#define g_key_file_load_from_file _frida_g_key_file_load_from_file +#define g_key_file_new _frida_g_key_file_new +#define g_key_file_ref _frida_g_key_file_ref +#define g_key_file_remove_comment _frida_g_key_file_remove_comment +#define g_key_file_remove_group _frida_g_key_file_remove_group +#define g_key_file_remove_key _frida_g_key_file_remove_key +#define g_key_file_save_to_file _frida_g_key_file_save_to_file +#define g_key_file_set_boolean _frida_g_key_file_set_boolean +#define g_key_file_set_boolean_list _frida_g_key_file_set_boolean_list +#define g_key_file_set_comment _frida_g_key_file_set_comment +#define g_key_file_set_double _frida_g_key_file_set_double +#define g_key_file_set_double_list _frida_g_key_file_set_double_list +#define g_key_file_set_int64 _frida_g_key_file_set_int64 +#define g_key_file_set_integer _frida_g_key_file_set_integer +#define g_key_file_set_integer_list _frida_g_key_file_set_integer_list +#define g_key_file_set_list_separator _frida_g_key_file_set_list_separator +#define g_key_file_set_locale_string _frida_g_key_file_set_locale_string +#define g_key_file_set_locale_string_list _frida_g_key_file_set_locale_string_list +#define g_key_file_set_string _frida_g_key_file_set_string +#define g_key_file_set_string_list _frida_g_key_file_set_string_list +#define g_key_file_set_uint64 _frida_g_key_file_set_uint64 +#define g_key_file_set_value _frida_g_key_file_set_value +#define g_key_file_to_data _frida_g_key_file_to_data +#define g_key_file_unref _frida_g_key_file_unref +#define g_keyfile_settings_backend_get_type _frida_g_keyfile_settings_backend_get_type +#define g_keyfile_settings_backend_new _frida_g_keyfile_settings_backend_new +#define g_libintl_bind_textdomain_codeset _frida_g_libintl_bind_textdomain_codeset +#define g_libintl_bindtextdomain _frida_g_libintl_bindtextdomain +#define g_libintl_dcgettext _frida_g_libintl_dcgettext +#define g_libintl_dcngettext _frida_g_libintl_dcngettext +#define g_libintl_dgettext _frida_g_libintl_dgettext +#define g_libintl_dngettext _frida_g_libintl_dngettext +#define g_libintl_gettext _frida_g_libintl_gettext +#define g_libintl_ngettext _frida_g_libintl_ngettext +#define g_libintl_textdomain _frida_g_libintl_textdomain +#define g_list_alloc _frida_g_list_alloc +#define g_list_append _frida_g_list_append +#define g_list_concat _frida_g_list_concat +#define g_list_copy _frida_g_list_copy +#define g_list_copy_deep _frida_g_list_copy_deep +#define g_list_delete_link _frida_g_list_delete_link +#define g_list_find _frida_g_list_find +#define g_list_find_custom _frida_g_list_find_custom +#define g_list_first _frida_g_list_first +#define g_list_foreach _frida_g_list_foreach +#define g_list_free _frida_g_list_free +#define g_list_free_1 _frida_g_list_free_1 +#define g_list_free_full _frida_g_list_free_full +#define g_list_index _frida_g_list_index +#define g_list_insert _frida_g_list_insert +#define g_list_insert_before _frida_g_list_insert_before +#define g_list_insert_before_link _frida_g_list_insert_before_link +#define g_list_insert_sorted _frida_g_list_insert_sorted +#define g_list_insert_sorted_with_data _frida_g_list_insert_sorted_with_data +#define g_list_last _frida_g_list_last +#define g_list_length _frida_g_list_length +#define g_list_model_get_item _frida_g_list_model_get_item +#define g_list_model_get_item_type _frida_g_list_model_get_item_type +#define g_list_model_get_n_items _frida_g_list_model_get_n_items +#define g_list_model_get_object _frida_g_list_model_get_object +#define g_list_model_get_type _frida_g_list_model_get_type +#define g_list_model_items_changed _frida_g_list_model_items_changed +#define g_list_nth _frida_g_list_nth +#define g_list_nth_data _frida_g_list_nth_data +#define g_list_nth_prev _frida_g_list_nth_prev +#define g_list_pop_allocator _frida_g_list_pop_allocator +#define g_list_position _frida_g_list_position +#define g_list_prepend _frida_g_list_prepend +#define g_list_push_allocator _frida_g_list_push_allocator +#define g_list_remove _frida_g_list_remove +#define g_list_remove_all _frida_g_list_remove_all +#define g_list_remove_link _frida_g_list_remove_link +#define g_list_reverse _frida_g_list_reverse +#define g_list_sort _frida_g_list_sort +#define g_list_sort_with_data _frida_g_list_sort_with_data +#define g_list_store_append _frida_g_list_store_append +#define g_list_store_find _frida_g_list_store_find +#define g_list_store_find_with_equal_func _frida_g_list_store_find_with_equal_func +#define g_list_store_get_type _frida_g_list_store_get_type +#define g_list_store_insert _frida_g_list_store_insert +#define g_list_store_insert_sorted _frida_g_list_store_insert_sorted +#define g_list_store_new _frida_g_list_store_new +#define g_list_store_remove _frida_g_list_store_remove +#define g_list_store_remove_all _frida_g_list_store_remove_all +#define g_list_store_sort _frida_g_list_store_sort +#define g_list_store_splice _frida_g_list_store_splice +#define g_listenv _frida_g_listenv +#define g_loadable_icon_get_type _frida_g_loadable_icon_get_type +#define g_loadable_icon_load _frida_g_loadable_icon_load +#define g_loadable_icon_load_async _frida_g_loadable_icon_load_async +#define g_loadable_icon_load_finish _frida_g_loadable_icon_load_finish +#define g_local_file_is_nfs_home _frida_g_local_file_is_nfs_home +#define g_local_file_monitor_get_type _frida_g_local_file_monitor_get_type +#define g_local_file_monitor_new_for_path _frida_g_local_file_monitor_new_for_path +#define g_local_file_monitor_new_in_worker _frida_g_local_file_monitor_new_in_worker +#define g_local_file_new_from_dirname_and_basename _frida_g_local_file_new_from_dirname_and_basename +#define g_locale_from_utf8 _frida_g_locale_from_utf8 +#define g_locale_to_utf8 _frida_g_locale_to_utf8 +#define g_log _frida_g_log +#define g_log_always_fatal _frida_g_log_always_fatal +#define g_log_default_handler _frida_g_log_default_handler +#define g_log_msg_prefix _frida_g_log_msg_prefix +#define g_log_remove_handler _frida_g_log_remove_handler +#define g_log_set_always_fatal _frida_g_log_set_always_fatal +#define g_log_set_default_handler _frida_g_log_set_default_handler +#define g_log_set_fatal_mask _frida_g_log_set_fatal_mask +#define g_log_set_handler _frida_g_log_set_handler +#define g_log_set_handler_full _frida_g_log_set_handler_full +#define g_log_set_writer_func _frida_g_log_set_writer_func +#define g_log_structured _frida_g_log_structured +#define g_log_structured_array _frida_g_log_structured_array +#define g_log_structured_standard _frida_g_log_structured_standard +#define g_log_variant _frida_g_log_variant +#define g_log_writer_default _frida_g_log_writer_default +#define g_log_writer_default_set_use_stderr _frida_g_log_writer_default_set_use_stderr +#define g_log_writer_default_would_drop _frida_g_log_writer_default_would_drop +#define g_log_writer_format_fields _frida_g_log_writer_format_fields +#define g_log_writer_is_journald _frida_g_log_writer_is_journald +#define g_log_writer_journald _frida_g_log_writer_journald +#define g_log_writer_standard_streams _frida_g_log_writer_standard_streams +#define g_log_writer_supports_color _frida_g_log_writer_supports_color +#define g_logv _frida_g_logv +#define g_lstat _frida_g_lstat +#define g_main_context_acquire _frida_g_main_context_acquire +#define g_main_context_add_poll _frida_g_main_context_add_poll +#define g_main_context_check _frida_g_main_context_check +#define g_main_context_default _frida_g_main_context_default +#define g_main_context_dispatch _frida_g_main_context_dispatch +#define g_main_context_find_source_by_funcs_user_data _frida_g_main_context_find_source_by_funcs_user_data +#define g_main_context_find_source_by_id _frida_g_main_context_find_source_by_id +#define g_main_context_find_source_by_user_data _frida_g_main_context_find_source_by_user_data +#define g_main_context_get_poll_func _frida_g_main_context_get_poll_func +#define g_main_context_get_thread_default _frida_g_main_context_get_thread_default +#define g_main_context_get_type _frida_g_main_context_get_type +#define g_main_context_invoke _frida_g_main_context_invoke +#define g_main_context_invoke_full _frida_g_main_context_invoke_full +#define g_main_context_is_owner _frida_g_main_context_is_owner +#define g_main_context_iteration _frida_g_main_context_iteration +#define g_main_context_new _frida_g_main_context_new +#define g_main_context_new_with_next_id _frida_g_main_context_new_with_next_id +#define g_main_context_pending _frida_g_main_context_pending +#define g_main_context_pop_thread_default _frida_g_main_context_pop_thread_default +#define g_main_context_prepare _frida_g_main_context_prepare +#define g_main_context_push_thread_default _frida_g_main_context_push_thread_default +#define g_main_context_query _frida_g_main_context_query +#define g_main_context_ref _frida_g_main_context_ref +#define g_main_context_ref_thread_default _frida_g_main_context_ref_thread_default +#define g_main_context_release _frida_g_main_context_release +#define g_main_context_remove_poll _frida_g_main_context_remove_poll +#define g_main_context_set_poll_func _frida_g_main_context_set_poll_func +#define g_main_context_unref _frida_g_main_context_unref +#define g_main_context_wait _frida_g_main_context_wait +#define g_main_context_wakeup _frida_g_main_context_wakeup +#define g_main_current_source _frida_g_main_current_source +#define g_main_depth _frida_g_main_depth +#define g_main_loop_get_context _frida_g_main_loop_get_context +#define g_main_loop_get_type _frida_g_main_loop_get_type +#define g_main_loop_is_running _frida_g_main_loop_is_running +#define g_main_loop_new _frida_g_main_loop_new +#define g_main_loop_quit _frida_g_main_loop_quit +#define g_main_loop_ref _frida_g_main_loop_ref +#define g_main_loop_run _frida_g_main_loop_run +#define g_main_loop_unref _frida_g_main_loop_unref +#define g_malloc _frida_g_malloc +#define g_malloc0 _frida_g_malloc0 +#define g_malloc0_n _frida_g_malloc0_n +#define g_malloc_n _frida_g_malloc_n +#define g_mapped_file_free _frida_g_mapped_file_free +#define g_mapped_file_get_bytes _frida_g_mapped_file_get_bytes +#define g_mapped_file_get_contents _frida_g_mapped_file_get_contents +#define g_mapped_file_get_length _frida_g_mapped_file_get_length +#define g_mapped_file_get_type _frida_g_mapped_file_get_type +#define g_mapped_file_new _frida_g_mapped_file_new +#define g_mapped_file_new_from_fd _frida_g_mapped_file_new_from_fd +#define g_mapped_file_ref _frida_g_mapped_file_ref +#define g_mapped_file_unref _frida_g_mapped_file_unref +#define g_markup_collect_attributes _frida_g_markup_collect_attributes +#define g_markup_error_quark _frida_g_markup_error_quark +#define g_markup_escape_text _frida_g_markup_escape_text +#define g_markup_parse_context_end_parse _frida_g_markup_parse_context_end_parse +#define g_markup_parse_context_free _frida_g_markup_parse_context_free +#define g_markup_parse_context_get_element _frida_g_markup_parse_context_get_element +#define g_markup_parse_context_get_element_stack _frida_g_markup_parse_context_get_element_stack +#define g_markup_parse_context_get_position _frida_g_markup_parse_context_get_position +#define g_markup_parse_context_get_type _frida_g_markup_parse_context_get_type +#define g_markup_parse_context_get_user_data _frida_g_markup_parse_context_get_user_data +#define g_markup_parse_context_new _frida_g_markup_parse_context_new +#define g_markup_parse_context_parse _frida_g_markup_parse_context_parse +#define g_markup_parse_context_pop _frida_g_markup_parse_context_pop +#define g_markup_parse_context_push _frida_g_markup_parse_context_push +#define g_markup_parse_context_ref _frida_g_markup_parse_context_ref +#define g_markup_parse_context_unref _frida_g_markup_parse_context_unref +#define g_markup_printf_escaped _frida_g_markup_printf_escaped +#define g_markup_vprintf_escaped _frida_g_markup_vprintf_escaped +#define g_match_info_expand_references _frida_g_match_info_expand_references +#define g_match_info_fetch _frida_g_match_info_fetch +#define g_match_info_fetch_all _frida_g_match_info_fetch_all +#define g_match_info_fetch_named _frida_g_match_info_fetch_named +#define g_match_info_fetch_named_pos _frida_g_match_info_fetch_named_pos +#define g_match_info_fetch_pos _frida_g_match_info_fetch_pos +#define g_match_info_free _frida_g_match_info_free +#define g_match_info_get_match_count _frida_g_match_info_get_match_count +#define g_match_info_get_regex _frida_g_match_info_get_regex +#define g_match_info_get_string _frida_g_match_info_get_string +#define g_match_info_get_type _frida_g_match_info_get_type +#define g_match_info_is_partial_match _frida_g_match_info_is_partial_match +#define g_match_info_matches _frida_g_match_info_matches +#define g_match_info_next _frida_g_match_info_next +#define g_match_info_ref _frida_g_match_info_ref +#define g_match_info_unref _frida_g_match_info_unref +#define g_mem_chunk_alloc _frida_g_mem_chunk_alloc +#define g_mem_chunk_alloc0 _frida_g_mem_chunk_alloc0 +#define g_mem_chunk_clean _frida_g_mem_chunk_clean +#define g_mem_chunk_destroy _frida_g_mem_chunk_destroy +#define g_mem_chunk_free _frida_g_mem_chunk_free +#define g_mem_chunk_info _frida_g_mem_chunk_info +#define g_mem_chunk_new _frida_g_mem_chunk_new +#define g_mem_chunk_print _frida_g_mem_chunk_print +#define g_mem_chunk_reset _frida_g_mem_chunk_reset +#define g_mem_gc_friendly _frida_g_mem_gc_friendly +#define g_mem_is_system_malloc _frida_g_mem_is_system_malloc +#define g_mem_profile _frida_g_mem_profile +#define g_mem_set_vtable _frida_g_mem_set_vtable +#define g_memdup _frida_g_memdup +#define g_memory_input_stream_add_bytes _frida_g_memory_input_stream_add_bytes +#define g_memory_input_stream_add_data _frida_g_memory_input_stream_add_data +#define g_memory_input_stream_get_type _frida_g_memory_input_stream_get_type +#define g_memory_input_stream_new _frida_g_memory_input_stream_new +#define g_memory_input_stream_new_from_bytes _frida_g_memory_input_stream_new_from_bytes +#define g_memory_input_stream_new_from_data _frida_g_memory_input_stream_new_from_data +#define g_memory_monitor_dbus_get_type _frida_g_memory_monitor_dbus_get_type +#define g_memory_monitor_dup_default _frida_g_memory_monitor_dup_default +#define g_memory_monitor_get_type _frida_g_memory_monitor_get_type +#define g_memory_monitor_portal_get_type _frida_g_memory_monitor_portal_get_type +#define g_memory_monitor_warning_level_get_type _frida_g_memory_monitor_warning_level_get_type +#define g_memory_output_stream_get_data _frida_g_memory_output_stream_get_data +#define g_memory_output_stream_get_data_size _frida_g_memory_output_stream_get_data_size +#define g_memory_output_stream_get_size _frida_g_memory_output_stream_get_size +#define g_memory_output_stream_get_type _frida_g_memory_output_stream_get_type +#define g_memory_output_stream_new _frida_g_memory_output_stream_new +#define g_memory_output_stream_new_resizable _frida_g_memory_output_stream_new_resizable +#define g_memory_output_stream_steal_as_bytes _frida_g_memory_output_stream_steal_as_bytes +#define g_memory_output_stream_steal_data _frida_g_memory_output_stream_steal_data +#define g_memory_settings_backend_get_type _frida_g_memory_settings_backend_get_type +#define g_memory_settings_backend_new _frida_g_memory_settings_backend_new +#define g_menu_append _frida_g_menu_append +#define g_menu_append_item _frida_g_menu_append_item +#define g_menu_append_section _frida_g_menu_append_section +#define g_menu_append_submenu _frida_g_menu_append_submenu +#define g_menu_attribute_iter_get_name _frida_g_menu_attribute_iter_get_name +#define g_menu_attribute_iter_get_next _frida_g_menu_attribute_iter_get_next +#define g_menu_attribute_iter_get_type _frida_g_menu_attribute_iter_get_type +#define g_menu_attribute_iter_get_value _frida_g_menu_attribute_iter_get_value +#define g_menu_attribute_iter_next _frida_g_menu_attribute_iter_next +#define g_menu_freeze _frida_g_menu_freeze +#define g_menu_get_type _frida_g_menu_get_type +#define g_menu_insert _frida_g_menu_insert +#define g_menu_insert_item _frida_g_menu_insert_item +#define g_menu_insert_section _frida_g_menu_insert_section +#define g_menu_insert_submenu _frida_g_menu_insert_submenu +#define g_menu_item_get_attribute _frida_g_menu_item_get_attribute +#define g_menu_item_get_attribute_value _frida_g_menu_item_get_attribute_value +#define g_menu_item_get_link _frida_g_menu_item_get_link +#define g_menu_item_get_type _frida_g_menu_item_get_type +#define g_menu_item_new _frida_g_menu_item_new +#define g_menu_item_new_from_model _frida_g_menu_item_new_from_model +#define g_menu_item_new_section _frida_g_menu_item_new_section +#define g_menu_item_new_submenu _frida_g_menu_item_new_submenu +#define g_menu_item_set_action_and_target _frida_g_menu_item_set_action_and_target +#define g_menu_item_set_action_and_target_value _frida_g_menu_item_set_action_and_target_value +#define g_menu_item_set_attribute _frida_g_menu_item_set_attribute +#define g_menu_item_set_attribute_value _frida_g_menu_item_set_attribute_value +#define g_menu_item_set_detailed_action _frida_g_menu_item_set_detailed_action +#define g_menu_item_set_icon _frida_g_menu_item_set_icon +#define g_menu_item_set_label _frida_g_menu_item_set_label +#define g_menu_item_set_link _frida_g_menu_item_set_link +#define g_menu_item_set_section _frida_g_menu_item_set_section +#define g_menu_item_set_submenu _frida_g_menu_item_set_submenu +#define g_menu_link_iter_get_name _frida_g_menu_link_iter_get_name +#define g_menu_link_iter_get_next _frida_g_menu_link_iter_get_next +#define g_menu_link_iter_get_type _frida_g_menu_link_iter_get_type +#define g_menu_link_iter_get_value _frida_g_menu_link_iter_get_value +#define g_menu_link_iter_next _frida_g_menu_link_iter_next +#define g_menu_model_get_item_attribute _frida_g_menu_model_get_item_attribute +#define g_menu_model_get_item_attribute_value _frida_g_menu_model_get_item_attribute_value +#define g_menu_model_get_item_link _frida_g_menu_model_get_item_link +#define g_menu_model_get_n_items _frida_g_menu_model_get_n_items +#define g_menu_model_get_type _frida_g_menu_model_get_type +#define g_menu_model_is_mutable _frida_g_menu_model_is_mutable +#define g_menu_model_items_changed _frida_g_menu_model_items_changed +#define g_menu_model_iterate_item_attributes _frida_g_menu_model_iterate_item_attributes +#define g_menu_model_iterate_item_links _frida_g_menu_model_iterate_item_links +#define g_menu_new _frida_g_menu_new +#define g_menu_prepend _frida_g_menu_prepend +#define g_menu_prepend_item _frida_g_menu_prepend_item +#define g_menu_prepend_section _frida_g_menu_prepend_section +#define g_menu_prepend_submenu _frida_g_menu_prepend_submenu +#define g_menu_remove _frida_g_menu_remove +#define g_menu_remove_all _frida_g_menu_remove_all +#define g_mkdir _frida_g_mkdir +#define g_mkdir_with_parents _frida_g_mkdir_with_parents +#define g_mkdtemp _frida_g_mkdtemp +#define g_mkdtemp_full _frida_g_mkdtemp_full +#define g_mkstemp _frida_g_mkstemp +#define g_mkstemp_full _frida_g_mkstemp_full +#define g_module_build_path _frida_g_module_build_path +#define g_module_close _frida_g_module_close +#define g_module_error _frida_g_module_error +#define g_module_make_resident _frida_g_module_make_resident +#define g_module_name _frida_g_module_name +#define g_module_open _frida_g_module_open +#define g_module_supported _frida_g_module_supported +#define g_module_symbol _frida_g_module_symbol +#define g_mount_can_eject _frida_g_mount_can_eject +#define g_mount_can_unmount _frida_g_mount_can_unmount +#define g_mount_eject _frida_g_mount_eject +#define g_mount_eject_finish _frida_g_mount_eject_finish +#define g_mount_eject_with_operation _frida_g_mount_eject_with_operation +#define g_mount_eject_with_operation_finish _frida_g_mount_eject_with_operation_finish +#define g_mount_get_default_location _frida_g_mount_get_default_location +#define g_mount_get_drive _frida_g_mount_get_drive +#define g_mount_get_icon _frida_g_mount_get_icon +#define g_mount_get_name _frida_g_mount_get_name +#define g_mount_get_root _frida_g_mount_get_root +#define g_mount_get_sort_key _frida_g_mount_get_sort_key +#define g_mount_get_symbolic_icon _frida_g_mount_get_symbolic_icon +#define g_mount_get_type _frida_g_mount_get_type +#define g_mount_get_uuid _frida_g_mount_get_uuid +#define g_mount_get_volume _frida_g_mount_get_volume +#define g_mount_guess_content_type _frida_g_mount_guess_content_type +#define g_mount_guess_content_type_finish _frida_g_mount_guess_content_type_finish +#define g_mount_guess_content_type_sync _frida_g_mount_guess_content_type_sync +#define g_mount_is_shadowed _frida_g_mount_is_shadowed +#define g_mount_mount_flags_get_type _frida_g_mount_mount_flags_get_type +#define g_mount_operation_get_anonymous _frida_g_mount_operation_get_anonymous +#define g_mount_operation_get_choice _frida_g_mount_operation_get_choice +#define g_mount_operation_get_domain _frida_g_mount_operation_get_domain +#define g_mount_operation_get_is_tcrypt_hidden_volume _frida_g_mount_operation_get_is_tcrypt_hidden_volume +#define g_mount_operation_get_is_tcrypt_system_volume _frida_g_mount_operation_get_is_tcrypt_system_volume +#define g_mount_operation_get_password _frida_g_mount_operation_get_password +#define g_mount_operation_get_password_save _frida_g_mount_operation_get_password_save +#define g_mount_operation_get_pim _frida_g_mount_operation_get_pim +#define g_mount_operation_get_type _frida_g_mount_operation_get_type +#define g_mount_operation_get_username _frida_g_mount_operation_get_username +#define g_mount_operation_new _frida_g_mount_operation_new +#define g_mount_operation_reply _frida_g_mount_operation_reply +#define g_mount_operation_result_get_type _frida_g_mount_operation_result_get_type +#define g_mount_operation_set_anonymous _frida_g_mount_operation_set_anonymous +#define g_mount_operation_set_choice _frida_g_mount_operation_set_choice +#define g_mount_operation_set_domain _frida_g_mount_operation_set_domain +#define g_mount_operation_set_is_tcrypt_hidden_volume _frida_g_mount_operation_set_is_tcrypt_hidden_volume +#define g_mount_operation_set_is_tcrypt_system_volume _frida_g_mount_operation_set_is_tcrypt_system_volume +#define g_mount_operation_set_password _frida_g_mount_operation_set_password +#define g_mount_operation_set_password_save _frida_g_mount_operation_set_password_save +#define g_mount_operation_set_pim _frida_g_mount_operation_set_pim +#define g_mount_operation_set_username _frida_g_mount_operation_set_username +#define g_mount_remount _frida_g_mount_remount +#define g_mount_remount_finish _frida_g_mount_remount_finish +#define g_mount_shadow _frida_g_mount_shadow +#define g_mount_unmount _frida_g_mount_unmount +#define g_mount_unmount_finish _frida_g_mount_unmount_finish +#define g_mount_unmount_flags_get_type _frida_g_mount_unmount_flags_get_type +#define g_mount_unmount_with_operation _frida_g_mount_unmount_with_operation +#define g_mount_unmount_with_operation_finish _frida_g_mount_unmount_with_operation_finish +#define g_mount_unshadow _frida_g_mount_unshadow +#define g_mutex_clear _frida_g_mutex_clear +#define g_mutex_free _frida_g_mutex_free +#define g_mutex_init _frida_g_mutex_init +#define g_mutex_lock _frida_g_mutex_lock +#define g_mutex_new _frida_g_mutex_new +#define g_mutex_trylock _frida_g_mutex_trylock +#define g_mutex_unlock _frida_g_mutex_unlock +#define g_native_socket_address_get_type _frida_g_native_socket_address_get_type +#define g_native_socket_address_new _frida_g_native_socket_address_new +#define g_native_volume_monitor_get_type _frida_g_native_volume_monitor_get_type +#define g_network_address_get_hostname _frida_g_network_address_get_hostname +#define g_network_address_get_port _frida_g_network_address_get_port +#define g_network_address_get_scheme _frida_g_network_address_get_scheme +#define g_network_address_get_type _frida_g_network_address_get_type +#define g_network_address_new _frida_g_network_address_new +#define g_network_address_new_loopback _frida_g_network_address_new_loopback +#define g_network_address_parse _frida_g_network_address_parse +#define g_network_address_parse_uri _frida_g_network_address_parse_uri +#define g_network_connectivity_get_type _frida_g_network_connectivity_get_type +#define g_network_monitor_base_add_network _frida_g_network_monitor_base_add_network +#define g_network_monitor_base_get_type _frida_g_network_monitor_base_get_type +#define g_network_monitor_base_remove_network _frida_g_network_monitor_base_remove_network +#define g_network_monitor_base_set_networks _frida_g_network_monitor_base_set_networks +#define g_network_monitor_can_reach _frida_g_network_monitor_can_reach +#define g_network_monitor_can_reach_async _frida_g_network_monitor_can_reach_async +#define g_network_monitor_can_reach_finish _frida_g_network_monitor_can_reach_finish +#define g_network_monitor_get_connectivity _frida_g_network_monitor_get_connectivity +#define g_network_monitor_get_default _frida_g_network_monitor_get_default +#define g_network_monitor_get_network_available _frida_g_network_monitor_get_network_available +#define g_network_monitor_get_network_metered _frida_g_network_monitor_get_network_metered +#define g_network_monitor_get_type _frida_g_network_monitor_get_type +#define g_network_monitor_portal_get_type _frida_g_network_monitor_portal_get_type +#define g_network_service_get_domain _frida_g_network_service_get_domain +#define g_network_service_get_protocol _frida_g_network_service_get_protocol +#define g_network_service_get_scheme _frida_g_network_service_get_scheme +#define g_network_service_get_service _frida_g_network_service_get_service +#define g_network_service_get_type _frida_g_network_service_get_type +#define g_network_service_new _frida_g_network_service_new +#define g_network_service_set_scheme _frida_g_network_service_set_scheme +#define g_networking_init _frida_g_networking_init +#define g_node_child_index _frida_g_node_child_index +#define g_node_child_position _frida_g_node_child_position +#define g_node_children_foreach _frida_g_node_children_foreach +#define g_node_copy _frida_g_node_copy +#define g_node_copy_deep _frida_g_node_copy_deep +#define g_node_depth _frida_g_node_depth +#define g_node_destroy _frida_g_node_destroy +#define g_node_find _frida_g_node_find +#define g_node_find_child _frida_g_node_find_child +#define g_node_first_sibling _frida_g_node_first_sibling +#define g_node_get_root _frida_g_node_get_root +#define g_node_insert _frida_g_node_insert +#define g_node_insert_after _frida_g_node_insert_after +#define g_node_insert_before _frida_g_node_insert_before +#define g_node_is_ancestor _frida_g_node_is_ancestor +#define g_node_last_child _frida_g_node_last_child +#define g_node_last_sibling _frida_g_node_last_sibling +#define g_node_max_height _frida_g_node_max_height +#define g_node_n_children _frida_g_node_n_children +#define g_node_n_nodes _frida_g_node_n_nodes +#define g_node_new _frida_g_node_new +#define g_node_nth_child _frida_g_node_nth_child +#define g_node_pop_allocator _frida_g_node_pop_allocator +#define g_node_prepend _frida_g_node_prepend +#define g_node_push_allocator _frida_g_node_push_allocator +#define g_node_reverse_children _frida_g_node_reverse_children +#define g_node_traverse _frida_g_node_traverse +#define g_node_unlink _frida_g_node_unlink +#define g_normalize_mode_get_type _frida_g_normalize_mode_get_type +#define g_notification_add_button _frida_g_notification_add_button +#define g_notification_add_button_with_target _frida_g_notification_add_button_with_target +#define g_notification_add_button_with_target_value _frida_g_notification_add_button_with_target_value +#define g_notification_backend_get_type _frida_g_notification_backend_get_type +#define g_notification_backend_new_default _frida_g_notification_backend_new_default +#define g_notification_backend_send_notification _frida_g_notification_backend_send_notification +#define g_notification_backend_withdraw_notification _frida_g_notification_backend_withdraw_notification +#define g_notification_get_body _frida_g_notification_get_body +#define g_notification_get_button _frida_g_notification_get_button +#define g_notification_get_button_with_action _frida_g_notification_get_button_with_action +#define g_notification_get_default_action _frida_g_notification_get_default_action +#define g_notification_get_icon _frida_g_notification_get_icon +#define g_notification_get_n_buttons _frida_g_notification_get_n_buttons +#define g_notification_get_priority _frida_g_notification_get_priority +#define g_notification_get_title _frida_g_notification_get_title +#define g_notification_get_type _frida_g_notification_get_type +#define g_notification_new _frida_g_notification_new +#define g_notification_priority_get_type _frida_g_notification_priority_get_type +#define g_notification_serialize _frida_g_notification_serialize +#define g_notification_set_body _frida_g_notification_set_body +#define g_notification_set_default_action _frida_g_notification_set_default_action +#define g_notification_set_default_action_and_target _frida_g_notification_set_default_action_and_target +#define g_notification_set_default_action_and_target_value _frida_g_notification_set_default_action_and_target_value +#define g_notification_set_icon _frida_g_notification_set_icon +#define g_notification_set_priority _frida_g_notification_set_priority +#define g_notification_set_title _frida_g_notification_set_title +#define g_notification_set_urgent _frida_g_notification_set_urgent +#define g_null_settings_backend_get_type _frida_g_null_settings_backend_get_type +#define g_null_settings_backend_new _frida_g_null_settings_backend_new +#define g_nullify_pointer _frida_g_nullify_pointer +#define g_number_parser_error_quark _frida_g_number_parser_error_quark +#define g_object_add_toggle_ref _frida_g_object_add_toggle_ref +#define g_object_add_weak_pointer _frida_g_object_add_weak_pointer +#define g_object_bind_property _frida_g_object_bind_property +#define g_object_bind_property_full _frida_g_object_bind_property_full +#define g_object_bind_property_with_closures _frida_g_object_bind_property_with_closures +#define g_object_class_find_property _frida_g_object_class_find_property +#define g_object_class_install_properties _frida_g_object_class_install_properties +#define g_object_class_install_property _frida_g_object_class_install_property +#define g_object_class_list_properties _frida_g_object_class_list_properties +#define g_object_class_override_property _frida_g_object_class_override_property +#define g_object_compat_control _frida_g_object_compat_control +#define g_object_connect _frida_g_object_connect +#define g_object_disconnect _frida_g_object_disconnect +#define g_object_dup_data _frida_g_object_dup_data +#define g_object_dup_qdata _frida_g_object_dup_qdata +#define g_object_force_floating _frida_g_object_force_floating +#define g_object_freeze_notify _frida_g_object_freeze_notify +#define g_object_get _frida_g_object_get +#define g_object_get_data _frida_g_object_get_data +#define g_object_get_property _frida_g_object_get_property +#define g_object_get_qdata _frida_g_object_get_qdata +#define g_object_get_type _frida_g_object_get_type +#define g_object_get_valist _frida_g_object_get_valist +#define g_object_getv _frida_g_object_getv +#define g_object_interface_find_property _frida_g_object_interface_find_property +#define g_object_interface_install_property _frida_g_object_interface_install_property +#define g_object_interface_list_properties _frida_g_object_interface_list_properties +#define g_object_is_floating _frida_g_object_is_floating +#define g_object_new _frida_g_object_new +#define g_object_new_valist _frida_g_object_new_valist +#define g_object_new_with_properties _frida_g_object_new_with_properties +#define g_object_newv _frida_g_object_newv +#define g_object_notify _frida_g_object_notify +#define g_object_notify_by_pspec _frida_g_object_notify_by_pspec +#define g_object_ref _frida_g_object_ref +#define g_object_ref_sink _frida_g_object_ref_sink +#define g_object_remove_toggle_ref _frida_g_object_remove_toggle_ref +#define g_object_remove_weak_pointer _frida_g_object_remove_weak_pointer +#define g_object_replace_data _frida_g_object_replace_data +#define g_object_replace_qdata _frida_g_object_replace_qdata +#define g_object_run_dispose _frida_g_object_run_dispose +#define g_object_set _frida_g_object_set +#define g_object_set_data _frida_g_object_set_data +#define g_object_set_data_full _frida_g_object_set_data_full +#define g_object_set_property _frida_g_object_set_property +#define g_object_set_qdata _frida_g_object_set_qdata +#define g_object_set_qdata_full _frida_g_object_set_qdata_full +#define g_object_set_valist _frida_g_object_set_valist +#define g_object_setv _frida_g_object_setv +#define g_object_steal_data _frida_g_object_steal_data +#define g_object_steal_qdata _frida_g_object_steal_qdata +#define g_object_thaw_notify _frida_g_object_thaw_notify +#define g_object_unref _frida_g_object_unref +#define g_object_watch_closure _frida_g_object_watch_closure +#define g_object_weak_ref _frida_g_object_weak_ref +#define g_object_weak_unref _frida_g_object_weak_unref +#define g_on_error_query _frida_g_on_error_query +#define g_on_error_stack_trace _frida_g_on_error_stack_trace +#define g_once_impl _frida_g_once_impl +#define g_once_init_enter _frida_g_once_init_enter +#define g_once_init_enter_impl _frida_g_once_init_enter_impl +#define g_once_init_leave _frida_g_once_init_leave +#define g_open _frida_g_open +#define g_openuri_portal_open_uri _frida_g_openuri_portal_open_uri +#define g_openuri_portal_open_uri_async _frida_g_openuri_portal_open_uri_async +#define g_openuri_portal_open_uri_finish _frida_g_openuri_portal_open_uri_finish +#define g_option_context_add_group _frida_g_option_context_add_group +#define g_option_context_add_main_entries _frida_g_option_context_add_main_entries +#define g_option_context_free _frida_g_option_context_free +#define g_option_context_get_description _frida_g_option_context_get_description +#define g_option_context_get_help _frida_g_option_context_get_help +#define g_option_context_get_help_enabled _frida_g_option_context_get_help_enabled +#define g_option_context_get_ignore_unknown_options _frida_g_option_context_get_ignore_unknown_options +#define g_option_context_get_main_group _frida_g_option_context_get_main_group +#define g_option_context_get_strict_posix _frida_g_option_context_get_strict_posix +#define g_option_context_get_summary _frida_g_option_context_get_summary +#define g_option_context_new _frida_g_option_context_new +#define g_option_context_parse _frida_g_option_context_parse +#define g_option_context_parse_strv _frida_g_option_context_parse_strv +#define g_option_context_set_description _frida_g_option_context_set_description +#define g_option_context_set_help_enabled _frida_g_option_context_set_help_enabled +#define g_option_context_set_ignore_unknown_options _frida_g_option_context_set_ignore_unknown_options +#define g_option_context_set_main_group _frida_g_option_context_set_main_group +#define g_option_context_set_strict_posix _frida_g_option_context_set_strict_posix +#define g_option_context_set_summary _frida_g_option_context_set_summary +#define g_option_context_set_translate_func _frida_g_option_context_set_translate_func +#define g_option_context_set_translation_domain _frida_g_option_context_set_translation_domain +#define g_option_error_quark _frida_g_option_error_quark +#define g_option_group_add_entries _frida_g_option_group_add_entries +#define g_option_group_free _frida_g_option_group_free +#define g_option_group_get_type _frida_g_option_group_get_type +#define g_option_group_new _frida_g_option_group_new +#define g_option_group_ref _frida_g_option_group_ref +#define g_option_group_set_error_hook _frida_g_option_group_set_error_hook +#define g_option_group_set_parse_hooks _frida_g_option_group_set_parse_hooks +#define g_option_group_set_translate_func _frida_g_option_group_set_translate_func +#define g_option_group_set_translation_domain _frida_g_option_group_set_translation_domain +#define g_option_group_unref _frida_g_option_group_unref +#define g_output_stream_async_close_is_via_threads _frida_g_output_stream_async_close_is_via_threads +#define g_output_stream_async_write_is_via_threads _frida_g_output_stream_async_write_is_via_threads +#define g_output_stream_async_writev_is_via_threads _frida_g_output_stream_async_writev_is_via_threads +#define g_output_stream_clear_pending _frida_g_output_stream_clear_pending +#define g_output_stream_close _frida_g_output_stream_close +#define g_output_stream_close_async _frida_g_output_stream_close_async +#define g_output_stream_close_finish _frida_g_output_stream_close_finish +#define g_output_stream_flush _frida_g_output_stream_flush +#define g_output_stream_flush_async _frida_g_output_stream_flush_async +#define g_output_stream_flush_finish _frida_g_output_stream_flush_finish +#define g_output_stream_get_type _frida_g_output_stream_get_type +#define g_output_stream_has_pending _frida_g_output_stream_has_pending +#define g_output_stream_is_closed _frida_g_output_stream_is_closed +#define g_output_stream_is_closing _frida_g_output_stream_is_closing +#define g_output_stream_printf _frida_g_output_stream_printf +#define g_output_stream_set_pending _frida_g_output_stream_set_pending +#define g_output_stream_splice _frida_g_output_stream_splice +#define g_output_stream_splice_async _frida_g_output_stream_splice_async +#define g_output_stream_splice_finish _frida_g_output_stream_splice_finish +#define g_output_stream_splice_flags_get_type _frida_g_output_stream_splice_flags_get_type +#define g_output_stream_vprintf _frida_g_output_stream_vprintf +#define g_output_stream_write _frida_g_output_stream_write +#define g_output_stream_write_all _frida_g_output_stream_write_all +#define g_output_stream_write_all_async _frida_g_output_stream_write_all_async +#define g_output_stream_write_all_finish _frida_g_output_stream_write_all_finish +#define g_output_stream_write_async _frida_g_output_stream_write_async +#define g_output_stream_write_bytes _frida_g_output_stream_write_bytes +#define g_output_stream_write_bytes_async _frida_g_output_stream_write_bytes_async +#define g_output_stream_write_bytes_finish _frida_g_output_stream_write_bytes_finish +#define g_output_stream_write_finish _frida_g_output_stream_write_finish +#define g_output_stream_writev _frida_g_output_stream_writev +#define g_output_stream_writev_all _frida_g_output_stream_writev_all +#define g_output_stream_writev_all_async _frida_g_output_stream_writev_all_async +#define g_output_stream_writev_all_finish _frida_g_output_stream_writev_all_finish +#define g_output_stream_writev_async _frida_g_output_stream_writev_async +#define g_output_stream_writev_finish _frida_g_output_stream_writev_finish +#define g_param_spec_boolean _frida_g_param_spec_boolean +#define g_param_spec_boxed _frida_g_param_spec_boxed +#define g_param_spec_char _frida_g_param_spec_char +#define g_param_spec_double _frida_g_param_spec_double +#define g_param_spec_enum _frida_g_param_spec_enum +#define g_param_spec_flags _frida_g_param_spec_flags +#define g_param_spec_float _frida_g_param_spec_float +#define g_param_spec_get_blurb _frida_g_param_spec_get_blurb +#define g_param_spec_get_default_value _frida_g_param_spec_get_default_value +#define g_param_spec_get_name _frida_g_param_spec_get_name +#define g_param_spec_get_name_quark _frida_g_param_spec_get_name_quark +#define g_param_spec_get_nick _frida_g_param_spec_get_nick +#define g_param_spec_get_qdata _frida_g_param_spec_get_qdata +#define g_param_spec_get_redirect_target _frida_g_param_spec_get_redirect_target +#define g_param_spec_gtype _frida_g_param_spec_gtype +#define g_param_spec_int _frida_g_param_spec_int +#define g_param_spec_int64 _frida_g_param_spec_int64 +#define g_param_spec_internal _frida_g_param_spec_internal +#define g_param_spec_is_valid_name _frida_g_param_spec_is_valid_name +#define g_param_spec_long _frida_g_param_spec_long +#define g_param_spec_object _frida_g_param_spec_object +#define g_param_spec_override _frida_g_param_spec_override +#define g_param_spec_param _frida_g_param_spec_param +#define g_param_spec_pointer _frida_g_param_spec_pointer +#define g_param_spec_pool_insert _frida_g_param_spec_pool_insert +#define g_param_spec_pool_list _frida_g_param_spec_pool_list +#define g_param_spec_pool_list_owned _frida_g_param_spec_pool_list_owned +#define g_param_spec_pool_lookup _frida_g_param_spec_pool_lookup +#define g_param_spec_pool_new _frida_g_param_spec_pool_new +#define g_param_spec_pool_remove _frida_g_param_spec_pool_remove +#define g_param_spec_ref _frida_g_param_spec_ref +#define g_param_spec_ref_sink _frida_g_param_spec_ref_sink +#define g_param_spec_set_qdata _frida_g_param_spec_set_qdata +#define g_param_spec_set_qdata_full _frida_g_param_spec_set_qdata_full +#define g_param_spec_sink _frida_g_param_spec_sink +#define g_param_spec_steal_qdata _frida_g_param_spec_steal_qdata +#define g_param_spec_string _frida_g_param_spec_string +#define g_param_spec_types _frida_g_param_spec_types +#define g_param_spec_uchar _frida_g_param_spec_uchar +#define g_param_spec_uint _frida_g_param_spec_uint +#define g_param_spec_uint64 _frida_g_param_spec_uint64 +#define g_param_spec_ulong _frida_g_param_spec_ulong +#define g_param_spec_unichar _frida_g_param_spec_unichar +#define g_param_spec_unref _frida_g_param_spec_unref +#define g_param_spec_value_array _frida_g_param_spec_value_array +#define g_param_spec_variant _frida_g_param_spec_variant +#define g_param_type_register_static _frida_g_param_type_register_static +#define g_param_value_convert _frida_g_param_value_convert +#define g_param_value_defaults _frida_g_param_value_defaults +#define g_param_value_set_default _frida_g_param_value_set_default +#define g_param_value_validate _frida_g_param_value_validate +#define g_param_values_cmp _frida_g_param_values_cmp +#define g_parse_debug_string _frida_g_parse_debug_string +#define g_password_save_get_type _frida_g_password_save_get_type +#define g_path_get_basename _frida_g_path_get_basename +#define g_path_get_dirname _frida_g_path_get_dirname +#define g_path_is_absolute _frida_g_path_is_absolute +#define g_path_skip_root _frida_g_path_skip_root +#define g_pattern_match _frida_g_pattern_match +#define g_pattern_match_simple _frida_g_pattern_match_simple +#define g_pattern_match_string _frida_g_pattern_match_string +#define g_pattern_spec_equal _frida_g_pattern_spec_equal +#define g_pattern_spec_free _frida_g_pattern_spec_free +#define g_pattern_spec_new _frida_g_pattern_spec_new +#define g_permission_acquire _frida_g_permission_acquire +#define g_permission_acquire_async _frida_g_permission_acquire_async +#define g_permission_acquire_finish _frida_g_permission_acquire_finish +#define g_permission_get_allowed _frida_g_permission_get_allowed +#define g_permission_get_can_acquire _frida_g_permission_get_can_acquire +#define g_permission_get_can_release _frida_g_permission_get_can_release +#define g_permission_get_type _frida_g_permission_get_type +#define g_permission_impl_update _frida_g_permission_impl_update +#define g_permission_release _frida_g_permission_release +#define g_permission_release_async _frida_g_permission_release_async +#define g_permission_release_finish _frida_g_permission_release_finish +#define g_platform_audit_set_fd_callbacks _frida_g_platform_audit_set_fd_callbacks +#define g_pointer_bit_lock _frida_g_pointer_bit_lock +#define g_pointer_bit_trylock _frida_g_pointer_bit_trylock +#define g_pointer_bit_unlock _frida_g_pointer_bit_unlock +#define g_pointer_type_register_static _frida_g_pointer_type_register_static +#define g_poll _frida_g_poll +#define g_pollable_input_stream_can_poll _frida_g_pollable_input_stream_can_poll +#define g_pollable_input_stream_create_source _frida_g_pollable_input_stream_create_source +#define g_pollable_input_stream_get_type _frida_g_pollable_input_stream_get_type +#define g_pollable_input_stream_is_readable _frida_g_pollable_input_stream_is_readable +#define g_pollable_input_stream_read_nonblocking _frida_g_pollable_input_stream_read_nonblocking +#define g_pollable_output_stream_can_poll _frida_g_pollable_output_stream_can_poll +#define g_pollable_output_stream_create_source _frida_g_pollable_output_stream_create_source +#define g_pollable_output_stream_get_type _frida_g_pollable_output_stream_get_type +#define g_pollable_output_stream_is_writable _frida_g_pollable_output_stream_is_writable +#define g_pollable_output_stream_write_nonblocking _frida_g_pollable_output_stream_write_nonblocking +#define g_pollable_output_stream_writev_nonblocking _frida_g_pollable_output_stream_writev_nonblocking +#define g_pollable_return_get_type _frida_g_pollable_return_get_type +#define g_pollable_source_new _frida_g_pollable_source_new +#define g_pollable_source_new_full _frida_g_pollable_source_new_full +#define g_pollable_stream_read _frida_g_pollable_stream_read +#define g_pollable_stream_write _frida_g_pollable_stream_write +#define g_pollable_stream_write_all _frida_g_pollable_stream_write_all +#define g_pollfd_get_type _frida_g_pollfd_get_type +#define g_portal_notification_backend_get_type _frida_g_portal_notification_backend_get_type +#define g_prefix_error _frida_g_prefix_error +#define g_print _frida_g_print +#define g_printerr _frida_g_printerr +#define g_printf _frida_g_printf +#define g_printf_string_upper_bound _frida_g_printf_string_upper_bound +#define g_private_get _frida_g_private_get +#define g_private_new _frida_g_private_new +#define g_private_replace _frida_g_private_replace +#define g_private_set _frida_g_private_set +#define g_private_set_alloc0 _frida_g_private_set_alloc0 +#define g_propagate_error _frida_g_propagate_error +#define g_propagate_prefixed_error _frida_g_propagate_prefixed_error +#define g_property_action_get_type _frida_g_property_action_get_type +#define g_property_action_new _frida_g_property_action_new +#define g_proxy_address_enumerator_get_type _frida_g_proxy_address_enumerator_get_type +#define g_proxy_address_get_destination_hostname _frida_g_proxy_address_get_destination_hostname +#define g_proxy_address_get_destination_port _frida_g_proxy_address_get_destination_port +#define g_proxy_address_get_destination_protocol _frida_g_proxy_address_get_destination_protocol +#define g_proxy_address_get_password _frida_g_proxy_address_get_password +#define g_proxy_address_get_protocol _frida_g_proxy_address_get_protocol +#define g_proxy_address_get_type _frida_g_proxy_address_get_type +#define g_proxy_address_get_uri _frida_g_proxy_address_get_uri +#define g_proxy_address_get_username _frida_g_proxy_address_get_username +#define g_proxy_address_new _frida_g_proxy_address_new +#define g_proxy_connect _frida_g_proxy_connect +#define g_proxy_connect_async _frida_g_proxy_connect_async +#define g_proxy_connect_finish _frida_g_proxy_connect_finish +#define g_proxy_get_default_for_protocol _frida_g_proxy_get_default_for_protocol +#define g_proxy_get_type _frida_g_proxy_get_type +#define g_proxy_resolver_get_default _frida_g_proxy_resolver_get_default +#define g_proxy_resolver_get_type _frida_g_proxy_resolver_get_type +#define g_proxy_resolver_is_supported _frida_g_proxy_resolver_is_supported +#define g_proxy_resolver_lookup _frida_g_proxy_resolver_lookup +#define g_proxy_resolver_lookup_async _frida_g_proxy_resolver_lookup_async +#define g_proxy_resolver_lookup_finish _frida_g_proxy_resolver_lookup_finish +#define g_proxy_resolver_portal_get_type _frida_g_proxy_resolver_portal_get_type +#define g_proxy_supports_hostname _frida_g_proxy_supports_hostname +#define g_ptr_array_add _frida_g_ptr_array_add +#define g_ptr_array_copy _frida_g_ptr_array_copy +#define g_ptr_array_extend _frida_g_ptr_array_extend +#define g_ptr_array_extend_and_steal _frida_g_ptr_array_extend_and_steal +#define g_ptr_array_find _frida_g_ptr_array_find +#define g_ptr_array_find_with_equal_func _frida_g_ptr_array_find_with_equal_func +#define g_ptr_array_foreach _frida_g_ptr_array_foreach +#define g_ptr_array_free _frida_g_ptr_array_free +#define g_ptr_array_get_type _frida_g_ptr_array_get_type +#define g_ptr_array_insert _frida_g_ptr_array_insert +#define g_ptr_array_new _frida_g_ptr_array_new +#define g_ptr_array_new_full _frida_g_ptr_array_new_full +#define g_ptr_array_new_with_free_func _frida_g_ptr_array_new_with_free_func +#define g_ptr_array_ref _frida_g_ptr_array_ref +#define g_ptr_array_remove _frida_g_ptr_array_remove +#define g_ptr_array_remove_fast _frida_g_ptr_array_remove_fast +#define g_ptr_array_remove_index _frida_g_ptr_array_remove_index +#define g_ptr_array_remove_index_fast _frida_g_ptr_array_remove_index_fast +#define g_ptr_array_remove_range _frida_g_ptr_array_remove_range +#define g_ptr_array_set_free_func _frida_g_ptr_array_set_free_func +#define g_ptr_array_set_size _frida_g_ptr_array_set_size +#define g_ptr_array_sized_new _frida_g_ptr_array_sized_new +#define g_ptr_array_sort _frida_g_ptr_array_sort +#define g_ptr_array_sort_with_data _frida_g_ptr_array_sort_with_data +#define g_ptr_array_steal _frida_g_ptr_array_steal +#define g_ptr_array_steal_index _frida_g_ptr_array_steal_index +#define g_ptr_array_steal_index_fast _frida_g_ptr_array_steal_index_fast +#define g_ptr_array_unref _frida_g_ptr_array_unref +#define g_qsort_with_data _frida_g_qsort_with_data +#define g_quark_from_static_string _frida_g_quark_from_static_string +#define g_quark_from_string _frida_g_quark_from_string +#define g_quark_init _frida_g_quark_init +#define g_quark_to_string _frida_g_quark_to_string +#define g_quark_try_string _frida_g_quark_try_string +#define g_queue_clear _frida_g_queue_clear +#define g_queue_clear_full _frida_g_queue_clear_full +#define g_queue_copy _frida_g_queue_copy +#define g_queue_delete_link _frida_g_queue_delete_link +#define g_queue_find _frida_g_queue_find +#define g_queue_find_custom _frida_g_queue_find_custom +#define g_queue_foreach _frida_g_queue_foreach +#define g_queue_free _frida_g_queue_free +#define g_queue_free_full _frida_g_queue_free_full +#define g_queue_get_length _frida_g_queue_get_length +#define g_queue_index _frida_g_queue_index +#define g_queue_init _frida_g_queue_init +#define g_queue_insert_after _frida_g_queue_insert_after +#define g_queue_insert_after_link _frida_g_queue_insert_after_link +#define g_queue_insert_before _frida_g_queue_insert_before +#define g_queue_insert_before_link _frida_g_queue_insert_before_link +#define g_queue_insert_sorted _frida_g_queue_insert_sorted +#define g_queue_is_empty _frida_g_queue_is_empty +#define g_queue_link_index _frida_g_queue_link_index +#define g_queue_new _frida_g_queue_new +#define g_queue_peek_head _frida_g_queue_peek_head +#define g_queue_peek_head_link _frida_g_queue_peek_head_link +#define g_queue_peek_nth _frida_g_queue_peek_nth +#define g_queue_peek_nth_link _frida_g_queue_peek_nth_link +#define g_queue_peek_tail _frida_g_queue_peek_tail +#define g_queue_peek_tail_link _frida_g_queue_peek_tail_link +#define g_queue_pop_head _frida_g_queue_pop_head +#define g_queue_pop_head_link _frida_g_queue_pop_head_link +#define g_queue_pop_nth _frida_g_queue_pop_nth +#define g_queue_pop_nth_link _frida_g_queue_pop_nth_link +#define g_queue_pop_tail _frida_g_queue_pop_tail +#define g_queue_pop_tail_link _frida_g_queue_pop_tail_link +#define g_queue_push_head _frida_g_queue_push_head +#define g_queue_push_head_link _frida_g_queue_push_head_link +#define g_queue_push_nth _frida_g_queue_push_nth +#define g_queue_push_nth_link _frida_g_queue_push_nth_link +#define g_queue_push_tail _frida_g_queue_push_tail +#define g_queue_push_tail_link _frida_g_queue_push_tail_link +#define g_queue_remove _frida_g_queue_remove +#define g_queue_remove_all _frida_g_queue_remove_all +#define g_queue_reverse _frida_g_queue_reverse +#define g_queue_sort _frida_g_queue_sort +#define g_queue_unlink _frida_g_queue_unlink +#define g_rand_copy _frida_g_rand_copy +#define g_rand_double _frida_g_rand_double +#define g_rand_double_range _frida_g_rand_double_range +#define g_rand_free _frida_g_rand_free +#define g_rand_int _frida_g_rand_int +#define g_rand_int_range _frida_g_rand_int_range +#define g_rand_new _frida_g_rand_new +#define g_rand_new_with_seed _frida_g_rand_new_with_seed +#define g_rand_new_with_seed_array _frida_g_rand_new_with_seed_array +#define g_rand_set_seed _frida_g_rand_set_seed +#define g_rand_set_seed_array _frida_g_rand_set_seed_array +#define g_random_double _frida_g_random_double +#define g_random_double_range _frida_g_random_double_range +#define g_random_int _frida_g_random_int +#define g_random_int_range _frida_g_random_int_range +#define g_random_set_seed _frida_g_random_set_seed +#define g_rc_box_acquire _frida_g_rc_box_acquire +#define g_rc_box_alloc _frida_g_rc_box_alloc +#define g_rc_box_alloc0 _frida_g_rc_box_alloc0 +#define g_rc_box_alloc_full _frida_g_rc_box_alloc_full +#define g_rc_box_dup _frida_g_rc_box_dup +#define g_rc_box_get_size _frida_g_rc_box_get_size +#define g_rc_box_release _frida_g_rc_box_release +#define g_rc_box_release_full _frida_g_rc_box_release_full +#define g_realloc _frida_g_realloc +#define g_realloc_n _frida_g_realloc_n +#define g_rec_mutex_clear _frida_g_rec_mutex_clear +#define g_rec_mutex_init _frida_g_rec_mutex_init +#define g_rec_mutex_lock _frida_g_rec_mutex_lock +#define g_rec_mutex_trylock _frida_g_rec_mutex_trylock +#define g_rec_mutex_unlock _frida_g_rec_mutex_unlock +#define g_ref_count_compare _frida_g_ref_count_compare +#define g_ref_count_dec _frida_g_ref_count_dec +#define g_ref_count_inc _frida_g_ref_count_inc +#define g_ref_count_init _frida_g_ref_count_init +#define g_ref_string_acquire _frida_g_ref_string_acquire +#define g_ref_string_length _frida_g_ref_string_length +#define g_ref_string_new _frida_g_ref_string_new +#define g_ref_string_new_intern _frida_g_ref_string_new_intern +#define g_ref_string_new_len _frida_g_ref_string_new_len +#define g_ref_string_release _frida_g_ref_string_release +#define g_regex_check_replacement _frida_g_regex_check_replacement +#define g_regex_error_quark _frida_g_regex_error_quark +#define g_regex_escape_nul _frida_g_regex_escape_nul +#define g_regex_escape_string _frida_g_regex_escape_string +#define g_regex_get_capture_count _frida_g_regex_get_capture_count +#define g_regex_get_compile_flags _frida_g_regex_get_compile_flags +#define g_regex_get_has_cr_or_lf _frida_g_regex_get_has_cr_or_lf +#define g_regex_get_match_flags _frida_g_regex_get_match_flags +#define g_regex_get_max_backref _frida_g_regex_get_max_backref +#define g_regex_get_max_lookbehind _frida_g_regex_get_max_lookbehind +#define g_regex_get_pattern _frida_g_regex_get_pattern +#define g_regex_get_string_number _frida_g_regex_get_string_number +#define g_regex_get_type _frida_g_regex_get_type +#define g_regex_match _frida_g_regex_match +#define g_regex_match_all _frida_g_regex_match_all +#define g_regex_match_all_full _frida_g_regex_match_all_full +#define g_regex_match_full _frida_g_regex_match_full +#define g_regex_match_simple _frida_g_regex_match_simple +#define g_regex_new _frida_g_regex_new +#define g_regex_ref _frida_g_regex_ref +#define g_regex_replace _frida_g_regex_replace +#define g_regex_replace_eval _frida_g_regex_replace_eval +#define g_regex_replace_literal _frida_g_regex_replace_literal +#define g_regex_split _frida_g_regex_split +#define g_regex_split_full _frida_g_regex_split_full +#define g_regex_split_simple _frida_g_regex_split_simple +#define g_regex_unref _frida_g_regex_unref +#define g_relation_count _frida_g_relation_count +#define g_relation_delete _frida_g_relation_delete +#define g_relation_destroy _frida_g_relation_destroy +#define g_relation_exists _frida_g_relation_exists +#define g_relation_index _frida_g_relation_index +#define g_relation_insert _frida_g_relation_insert +#define g_relation_new _frida_g_relation_new +#define g_relation_print _frida_g_relation_print +#define g_relation_select _frida_g_relation_select +#define g_reload_user_special_dirs_cache _frida_g_reload_user_special_dirs_cache +#define g_remote_action_group_activate_action_full _frida_g_remote_action_group_activate_action_full +#define g_remote_action_group_change_action_state_full _frida_g_remote_action_group_change_action_state_full +#define g_remote_action_group_get_type _frida_g_remote_action_group_get_type +#define g_remove _frida_g_remove +#define g_rename _frida_g_rename +#define g_resolver_error_get_type _frida_g_resolver_error_get_type +#define g_resolver_error_quark _frida_g_resolver_error_quark +#define g_resolver_free_addresses _frida_g_resolver_free_addresses +#define g_resolver_free_targets _frida_g_resolver_free_targets +#define g_resolver_get_default _frida_g_resolver_get_default +#define g_resolver_get_serial _frida_g_resolver_get_serial +#define g_resolver_get_type _frida_g_resolver_get_type +#define g_resolver_lookup_by_address _frida_g_resolver_lookup_by_address +#define g_resolver_lookup_by_address_async _frida_g_resolver_lookup_by_address_async +#define g_resolver_lookup_by_address_finish _frida_g_resolver_lookup_by_address_finish +#define g_resolver_lookup_by_name _frida_g_resolver_lookup_by_name +#define g_resolver_lookup_by_name_async _frida_g_resolver_lookup_by_name_async +#define g_resolver_lookup_by_name_finish _frida_g_resolver_lookup_by_name_finish +#define g_resolver_lookup_by_name_with_flags _frida_g_resolver_lookup_by_name_with_flags +#define g_resolver_lookup_by_name_with_flags_async _frida_g_resolver_lookup_by_name_with_flags_async +#define g_resolver_lookup_by_name_with_flags_finish _frida_g_resolver_lookup_by_name_with_flags_finish +#define g_resolver_lookup_records _frida_g_resolver_lookup_records +#define g_resolver_lookup_records_async _frida_g_resolver_lookup_records_async +#define g_resolver_lookup_records_finish _frida_g_resolver_lookup_records_finish +#define g_resolver_lookup_service _frida_g_resolver_lookup_service +#define g_resolver_lookup_service_async _frida_g_resolver_lookup_service_async +#define g_resolver_lookup_service_finish _frida_g_resolver_lookup_service_finish +#define g_resolver_name_lookup_flags_get_type _frida_g_resolver_name_lookup_flags_get_type +#define g_resolver_record_type_get_type _frida_g_resolver_record_type_get_type +#define g_resolver_set_default _frida_g_resolver_set_default +#define g_resource_enumerate_children _frida_g_resource_enumerate_children +#define g_resource_error_get_type _frida_g_resource_error_get_type +#define g_resource_error_quark _frida_g_resource_error_quark +#define g_resource_file_monitor_get_type _frida_g_resource_file_monitor_get_type +#define g_resource_flags_get_type _frida_g_resource_flags_get_type +#define g_resource_get_info _frida_g_resource_get_info +#define g_resource_get_type _frida_g_resource_get_type +#define g_resource_load _frida_g_resource_load +#define g_resource_lookup_data _frida_g_resource_lookup_data +#define g_resource_lookup_flags_get_type _frida_g_resource_lookup_flags_get_type +#define g_resource_new_from_data _frida_g_resource_new_from_data +#define g_resource_open_stream _frida_g_resource_open_stream +#define g_resource_ref _frida_g_resource_ref +#define g_resource_unref _frida_g_resource_unref +#define g_resources_enumerate_children _frida_g_resources_enumerate_children +#define g_resources_get_info _frida_g_resources_get_info +#define g_resources_lookup_data _frida_g_resources_lookup_data +#define g_resources_open_stream _frida_g_resources_open_stream +#define g_resources_register _frida_g_resources_register +#define g_resources_unregister _frida_g_resources_unregister +#define g_return_if_fail_warning _frida_g_return_if_fail_warning +#define g_rmdir _frida_g_rmdir +#define g_rw_lock_clear _frida_g_rw_lock_clear +#define g_rw_lock_init _frida_g_rw_lock_init +#define g_rw_lock_reader_lock _frida_g_rw_lock_reader_lock +#define g_rw_lock_reader_trylock _frida_g_rw_lock_reader_trylock +#define g_rw_lock_reader_unlock _frida_g_rw_lock_reader_unlock +#define g_rw_lock_writer_lock _frida_g_rw_lock_writer_lock +#define g_rw_lock_writer_trylock _frida_g_rw_lock_writer_trylock +#define g_rw_lock_writer_unlock _frida_g_rw_lock_writer_unlock +#define g_scanner_cur_line _frida_g_scanner_cur_line +#define g_scanner_cur_position _frida_g_scanner_cur_position +#define g_scanner_cur_token _frida_g_scanner_cur_token +#define g_scanner_cur_value _frida_g_scanner_cur_value +#define g_scanner_destroy _frida_g_scanner_destroy +#define g_scanner_eof _frida_g_scanner_eof +#define g_scanner_error _frida_g_scanner_error +#define g_scanner_get_next_token _frida_g_scanner_get_next_token +#define g_scanner_input_file _frida_g_scanner_input_file +#define g_scanner_input_text _frida_g_scanner_input_text +#define g_scanner_lookup_symbol _frida_g_scanner_lookup_symbol +#define g_scanner_new _frida_g_scanner_new +#define g_scanner_peek_next_token _frida_g_scanner_peek_next_token +#define g_scanner_scope_add_symbol _frida_g_scanner_scope_add_symbol +#define g_scanner_scope_foreach_symbol _frida_g_scanner_scope_foreach_symbol +#define g_scanner_scope_lookup_symbol _frida_g_scanner_scope_lookup_symbol +#define g_scanner_scope_remove_symbol _frida_g_scanner_scope_remove_symbol +#define g_scanner_set_scope _frida_g_scanner_set_scope +#define g_scanner_sync_file_offset _frida_g_scanner_sync_file_offset +#define g_scanner_unexp_token _frida_g_scanner_unexp_token +#define g_scanner_warn _frida_g_scanner_warn +#define g_seekable_can_seek _frida_g_seekable_can_seek +#define g_seekable_can_truncate _frida_g_seekable_can_truncate +#define g_seekable_get_type _frida_g_seekable_get_type +#define g_seekable_seek _frida_g_seekable_seek +#define g_seekable_tell _frida_g_seekable_tell +#define g_seekable_truncate _frida_g_seekable_truncate +#define g_sequence_append _frida_g_sequence_append +#define g_sequence_foreach _frida_g_sequence_foreach +#define g_sequence_foreach_range _frida_g_sequence_foreach_range +#define g_sequence_free _frida_g_sequence_free +#define g_sequence_get _frida_g_sequence_get +#define g_sequence_get_begin_iter _frida_g_sequence_get_begin_iter +#define g_sequence_get_end_iter _frida_g_sequence_get_end_iter +#define g_sequence_get_iter_at_pos _frida_g_sequence_get_iter_at_pos +#define g_sequence_get_length _frida_g_sequence_get_length +#define g_sequence_insert_before _frida_g_sequence_insert_before +#define g_sequence_insert_sorted _frida_g_sequence_insert_sorted +#define g_sequence_insert_sorted_iter _frida_g_sequence_insert_sorted_iter +#define g_sequence_is_empty _frida_g_sequence_is_empty +#define g_sequence_iter_compare _frida_g_sequence_iter_compare +#define g_sequence_iter_get_position _frida_g_sequence_iter_get_position +#define g_sequence_iter_get_sequence _frida_g_sequence_iter_get_sequence +#define g_sequence_iter_is_begin _frida_g_sequence_iter_is_begin +#define g_sequence_iter_is_end _frida_g_sequence_iter_is_end +#define g_sequence_iter_move _frida_g_sequence_iter_move +#define g_sequence_iter_next _frida_g_sequence_iter_next +#define g_sequence_iter_prev _frida_g_sequence_iter_prev +#define g_sequence_lookup _frida_g_sequence_lookup +#define g_sequence_lookup_iter _frida_g_sequence_lookup_iter +#define g_sequence_move _frida_g_sequence_move +#define g_sequence_move_range _frida_g_sequence_move_range +#define g_sequence_new _frida_g_sequence_new +#define g_sequence_prepend _frida_g_sequence_prepend +#define g_sequence_range_get_midpoint _frida_g_sequence_range_get_midpoint +#define g_sequence_remove _frida_g_sequence_remove +#define g_sequence_remove_range _frida_g_sequence_remove_range +#define g_sequence_search _frida_g_sequence_search +#define g_sequence_search_iter _frida_g_sequence_search_iter +#define g_sequence_set _frida_g_sequence_set +#define g_sequence_sort _frida_g_sequence_sort +#define g_sequence_sort_changed _frida_g_sequence_sort_changed +#define g_sequence_sort_changed_iter _frida_g_sequence_sort_changed_iter +#define g_sequence_sort_iter _frida_g_sequence_sort_iter +#define g_sequence_swap _frida_g_sequence_swap +#define g_set_application_name _frida_g_set_application_name +#define g_set_error _frida_g_set_error +#define g_set_error_literal _frida_g_set_error_literal +#define g_set_prgname _frida_g_set_prgname +#define g_set_print_handler _frida_g_set_print_handler +#define g_set_printerr_handler _frida_g_set_printerr_handler +#define g_set_user_dirs _frida_g_set_user_dirs +#define g_setenv _frida_g_setenv +#define g_settings_apply _frida_g_settings_apply +#define g_settings_backend_changed _frida_g_settings_backend_changed +#define g_settings_backend_changed_tree _frida_g_settings_backend_changed_tree +#define g_settings_backend_create_tree _frida_g_settings_backend_create_tree +#define g_settings_backend_flatten_tree _frida_g_settings_backend_flatten_tree +#define g_settings_backend_get_default _frida_g_settings_backend_get_default +#define g_settings_backend_get_permission _frida_g_settings_backend_get_permission +#define g_settings_backend_get_type _frida_g_settings_backend_get_type +#define g_settings_backend_get_writable _frida_g_settings_backend_get_writable +#define g_settings_backend_keys_changed _frida_g_settings_backend_keys_changed +#define g_settings_backend_path_changed _frida_g_settings_backend_path_changed +#define g_settings_backend_path_writable_changed _frida_g_settings_backend_path_writable_changed +#define g_settings_backend_read _frida_g_settings_backend_read +#define g_settings_backend_read_user_value _frida_g_settings_backend_read_user_value +#define g_settings_backend_reset _frida_g_settings_backend_reset +#define g_settings_backend_subscribe _frida_g_settings_backend_subscribe +#define g_settings_backend_sync_default _frida_g_settings_backend_sync_default +#define g_settings_backend_unsubscribe _frida_g_settings_backend_unsubscribe +#define g_settings_backend_unwatch _frida_g_settings_backend_unwatch +#define g_settings_backend_watch _frida_g_settings_backend_watch +#define g_settings_backend_writable_changed _frida_g_settings_backend_writable_changed +#define g_settings_backend_write _frida_g_settings_backend_write +#define g_settings_backend_write_tree _frida_g_settings_backend_write_tree +#define g_settings_bind _frida_g_settings_bind +#define g_settings_bind_flags_get_type _frida_g_settings_bind_flags_get_type +#define g_settings_bind_with_mapping _frida_g_settings_bind_with_mapping +#define g_settings_bind_writable _frida_g_settings_bind_writable +#define g_settings_create_action _frida_g_settings_create_action +#define g_settings_delay _frida_g_settings_delay +#define g_settings_get _frida_g_settings_get +#define g_settings_get_boolean _frida_g_settings_get_boolean +#define g_settings_get_child _frida_g_settings_get_child +#define g_settings_get_default_value _frida_g_settings_get_default_value +#define g_settings_get_double _frida_g_settings_get_double +#define g_settings_get_enum _frida_g_settings_get_enum +#define g_settings_get_flags _frida_g_settings_get_flags +#define g_settings_get_has_unapplied _frida_g_settings_get_has_unapplied +#define g_settings_get_int _frida_g_settings_get_int +#define g_settings_get_int64 _frida_g_settings_get_int64 +#define g_settings_get_mapped _frida_g_settings_get_mapped +#define g_settings_get_mapping _frida_g_settings_get_mapping +#define g_settings_get_range _frida_g_settings_get_range +#define g_settings_get_string _frida_g_settings_get_string +#define g_settings_get_strv _frida_g_settings_get_strv +#define g_settings_get_type _frida_g_settings_get_type +#define g_settings_get_uint _frida_g_settings_get_uint +#define g_settings_get_uint64 _frida_g_settings_get_uint64 +#define g_settings_get_user_value _frida_g_settings_get_user_value +#define g_settings_get_value _frida_g_settings_get_value +#define g_settings_is_writable _frida_g_settings_is_writable +#define g_settings_list_children _frida_g_settings_list_children +#define g_settings_list_keys _frida_g_settings_list_keys +#define g_settings_list_relocatable_schemas _frida_g_settings_list_relocatable_schemas +#define g_settings_list_schemas _frida_g_settings_list_schemas +#define g_settings_mapping_is_compatible _frida_g_settings_mapping_is_compatible +#define g_settings_new _frida_g_settings_new +#define g_settings_new_full _frida_g_settings_new_full +#define g_settings_new_with_backend _frida_g_settings_new_with_backend +#define g_settings_new_with_backend_and_path _frida_g_settings_new_with_backend_and_path +#define g_settings_new_with_path _frida_g_settings_new_with_path +#define g_settings_range_check _frida_g_settings_range_check +#define g_settings_reset _frida_g_settings_reset +#define g_settings_revert _frida_g_settings_revert +#define g_settings_schema_get_gettext_domain _frida_g_settings_schema_get_gettext_domain +#define g_settings_schema_get_id _frida_g_settings_schema_get_id +#define g_settings_schema_get_key _frida_g_settings_schema_get_key +#define g_settings_schema_get_path _frida_g_settings_schema_get_path +#define g_settings_schema_get_string _frida_g_settings_schema_get_string +#define g_settings_schema_get_type _frida_g_settings_schema_get_type +#define g_settings_schema_get_value _frida_g_settings_schema_get_value +#define g_settings_schema_has_key _frida_g_settings_schema_has_key +#define g_settings_schema_key_clear _frida_g_settings_schema_key_clear +#define g_settings_schema_key_from_enum _frida_g_settings_schema_key_from_enum +#define g_settings_schema_key_from_flags _frida_g_settings_schema_key_from_flags +#define g_settings_schema_key_get_default_value _frida_g_settings_schema_key_get_default_value +#define g_settings_schema_key_get_description _frida_g_settings_schema_key_get_description +#define g_settings_schema_key_get_name _frida_g_settings_schema_key_get_name +#define g_settings_schema_key_get_per_desktop_default _frida_g_settings_schema_key_get_per_desktop_default +#define g_settings_schema_key_get_range _frida_g_settings_schema_key_get_range +#define g_settings_schema_key_get_summary _frida_g_settings_schema_key_get_summary +#define g_settings_schema_key_get_translated_default _frida_g_settings_schema_key_get_translated_default +#define g_settings_schema_key_get_type _frida_g_settings_schema_key_get_type +#define g_settings_schema_key_get_value_type _frida_g_settings_schema_key_get_value_type +#define g_settings_schema_key_init _frida_g_settings_schema_key_init +#define g_settings_schema_key_range_check _frida_g_settings_schema_key_range_check +#define g_settings_schema_key_range_fixup _frida_g_settings_schema_key_range_fixup +#define g_settings_schema_key_ref _frida_g_settings_schema_key_ref +#define g_settings_schema_key_to_enum _frida_g_settings_schema_key_to_enum +#define g_settings_schema_key_to_flags _frida_g_settings_schema_key_to_flags +#define g_settings_schema_key_type_check _frida_g_settings_schema_key_type_check +#define g_settings_schema_key_unref _frida_g_settings_schema_key_unref +#define g_settings_schema_list _frida_g_settings_schema_list +#define g_settings_schema_list_children _frida_g_settings_schema_list_children +#define g_settings_schema_list_keys _frida_g_settings_schema_list_keys +#define g_settings_schema_ref _frida_g_settings_schema_ref +#define g_settings_schema_source_get_default _frida_g_settings_schema_source_get_default +#define g_settings_schema_source_get_type _frida_g_settings_schema_source_get_type +#define g_settings_schema_source_list_schemas _frida_g_settings_schema_source_list_schemas +#define g_settings_schema_source_lookup _frida_g_settings_schema_source_lookup +#define g_settings_schema_source_new_from_directory _frida_g_settings_schema_source_new_from_directory +#define g_settings_schema_source_ref _frida_g_settings_schema_source_ref +#define g_settings_schema_source_unref _frida_g_settings_schema_source_unref +#define g_settings_schema_unref _frida_g_settings_schema_unref +#define g_settings_set _frida_g_settings_set +#define g_settings_set_boolean _frida_g_settings_set_boolean +#define g_settings_set_double _frida_g_settings_set_double +#define g_settings_set_enum _frida_g_settings_set_enum +#define g_settings_set_flags _frida_g_settings_set_flags +#define g_settings_set_int _frida_g_settings_set_int +#define g_settings_set_int64 _frida_g_settings_set_int64 +#define g_settings_set_mapping _frida_g_settings_set_mapping +#define g_settings_set_string _frida_g_settings_set_string +#define g_settings_set_strv _frida_g_settings_set_strv +#define g_settings_set_uint _frida_g_settings_set_uint +#define g_settings_set_uint64 _frida_g_settings_set_uint64 +#define g_settings_set_value _frida_g_settings_set_value +#define g_settings_sync _frida_g_settings_sync +#define g_settings_unbind _frida_g_settings_unbind +#define g_shell_error_quark _frida_g_shell_error_quark +#define g_shell_parse_argv _frida_g_shell_parse_argv +#define g_shell_quote _frida_g_shell_quote +#define g_shell_unquote _frida_g_shell_unquote +#define g_signal_accumulator_first_wins _frida_g_signal_accumulator_first_wins +#define g_signal_accumulator_true_handled _frida_g_signal_accumulator_true_handled +#define g_signal_add_emission_hook _frida_g_signal_add_emission_hook +#define g_signal_chain_from_overridden _frida_g_signal_chain_from_overridden +#define g_signal_chain_from_overridden_handler _frida_g_signal_chain_from_overridden_handler +#define g_signal_connect_closure _frida_g_signal_connect_closure +#define g_signal_connect_closure_by_id _frida_g_signal_connect_closure_by_id +#define g_signal_connect_data _frida_g_signal_connect_data +#define g_signal_connect_object _frida_g_signal_connect_object +#define g_signal_emit _frida_g_signal_emit +#define g_signal_emit_by_name _frida_g_signal_emit_by_name +#define g_signal_emit_valist _frida_g_signal_emit_valist +#define g_signal_emitv _frida_g_signal_emitv +#define g_signal_get_invocation_hint _frida_g_signal_get_invocation_hint +#define g_signal_handler_block _frida_g_signal_handler_block +#define g_signal_handler_disconnect _frida_g_signal_handler_disconnect +#define g_signal_handler_find _frida_g_signal_handler_find +#define g_signal_handler_is_connected _frida_g_signal_handler_is_connected +#define g_signal_handler_unblock _frida_g_signal_handler_unblock +#define g_signal_handlers_block_matched _frida_g_signal_handlers_block_matched +#define g_signal_handlers_destroy _frida_g_signal_handlers_destroy +#define g_signal_handlers_disconnect_matched _frida_g_signal_handlers_disconnect_matched +#define g_signal_handlers_unblock_matched _frida_g_signal_handlers_unblock_matched +#define g_signal_has_handler_pending _frida_g_signal_has_handler_pending +#define g_signal_is_valid_name _frida_g_signal_is_valid_name +#define g_signal_list_ids _frida_g_signal_list_ids +#define g_signal_lookup _frida_g_signal_lookup +#define g_signal_name _frida_g_signal_name +#define g_signal_new _frida_g_signal_new +#define g_signal_new_class_handler _frida_g_signal_new_class_handler +#define g_signal_new_valist _frida_g_signal_new_valist +#define g_signal_newv _frida_g_signal_newv +#define g_signal_override_class_closure _frida_g_signal_override_class_closure +#define g_signal_override_class_handler _frida_g_signal_override_class_handler +#define g_signal_parse_name _frida_g_signal_parse_name +#define g_signal_query _frida_g_signal_query +#define g_signal_remove_emission_hook _frida_g_signal_remove_emission_hook +#define g_signal_set_va_marshaller _frida_g_signal_set_va_marshaller +#define g_signal_stop_emission _frida_g_signal_stop_emission +#define g_signal_stop_emission_by_name _frida_g_signal_stop_emission_by_name +#define g_signal_type_cclosure_new _frida_g_signal_type_cclosure_new +#define g_simple_action_get_type _frida_g_simple_action_get_type +#define g_simple_action_group_add_entries _frida_g_simple_action_group_add_entries +#define g_simple_action_group_get_type _frida_g_simple_action_group_get_type +#define g_simple_action_group_insert _frida_g_simple_action_group_insert +#define g_simple_action_group_lookup _frida_g_simple_action_group_lookup +#define g_simple_action_group_new _frida_g_simple_action_group_new +#define g_simple_action_group_remove _frida_g_simple_action_group_remove +#define g_simple_action_new _frida_g_simple_action_new +#define g_simple_action_new_stateful _frida_g_simple_action_new_stateful +#define g_simple_action_set_enabled _frida_g_simple_action_set_enabled +#define g_simple_action_set_state _frida_g_simple_action_set_state +#define g_simple_action_set_state_hint _frida_g_simple_action_set_state_hint +#define g_simple_async_report_error_in_idle _frida_g_simple_async_report_error_in_idle +#define g_simple_async_report_gerror_in_idle _frida_g_simple_async_report_gerror_in_idle +#define g_simple_async_report_take_gerror_in_idle _frida_g_simple_async_report_take_gerror_in_idle +#define g_simple_async_result_complete _frida_g_simple_async_result_complete +#define g_simple_async_result_complete_in_idle _frida_g_simple_async_result_complete_in_idle +#define g_simple_async_result_get_op_res_gboolean _frida_g_simple_async_result_get_op_res_gboolean +#define g_simple_async_result_get_op_res_gpointer _frida_g_simple_async_result_get_op_res_gpointer +#define g_simple_async_result_get_op_res_gssize _frida_g_simple_async_result_get_op_res_gssize +#define g_simple_async_result_get_source_tag _frida_g_simple_async_result_get_source_tag +#define g_simple_async_result_get_type _frida_g_simple_async_result_get_type +#define g_simple_async_result_is_valid _frida_g_simple_async_result_is_valid +#define g_simple_async_result_new _frida_g_simple_async_result_new +#define g_simple_async_result_new_error _frida_g_simple_async_result_new_error +#define g_simple_async_result_new_from_error _frida_g_simple_async_result_new_from_error +#define g_simple_async_result_new_take_error _frida_g_simple_async_result_new_take_error +#define g_simple_async_result_propagate_error _frida_g_simple_async_result_propagate_error +#define g_simple_async_result_run_in_thread _frida_g_simple_async_result_run_in_thread +#define g_simple_async_result_set_check_cancellable _frida_g_simple_async_result_set_check_cancellable +#define g_simple_async_result_set_error _frida_g_simple_async_result_set_error +#define g_simple_async_result_set_error_va _frida_g_simple_async_result_set_error_va +#define g_simple_async_result_set_from_error _frida_g_simple_async_result_set_from_error +#define g_simple_async_result_set_handle_cancellation _frida_g_simple_async_result_set_handle_cancellation +#define g_simple_async_result_set_op_res_gboolean _frida_g_simple_async_result_set_op_res_gboolean +#define g_simple_async_result_set_op_res_gpointer _frida_g_simple_async_result_set_op_res_gpointer +#define g_simple_async_result_set_op_res_gssize _frida_g_simple_async_result_set_op_res_gssize +#define g_simple_async_result_take_error _frida_g_simple_async_result_take_error +#define g_simple_io_stream_get_type _frida_g_simple_io_stream_get_type +#define g_simple_io_stream_new _frida_g_simple_io_stream_new +#define g_simple_permission_get_type _frida_g_simple_permission_get_type +#define g_simple_permission_new _frida_g_simple_permission_new +#define g_simple_proxy_resolver_get_type _frida_g_simple_proxy_resolver_get_type +#define g_simple_proxy_resolver_new _frida_g_simple_proxy_resolver_new +#define g_simple_proxy_resolver_set_default_proxy _frida_g_simple_proxy_resolver_set_default_proxy +#define g_simple_proxy_resolver_set_ignore_hosts _frida_g_simple_proxy_resolver_set_ignore_hosts +#define g_simple_proxy_resolver_set_uri_proxy _frida_g_simple_proxy_resolver_set_uri_proxy +#define g_slice_alloc _frida_g_slice_alloc +#define g_slice_alloc0 _frida_g_slice_alloc0 +#define g_slice_copy _frida_g_slice_copy +#define g_slice_free1 _frida_g_slice_free1 +#define g_slice_free_chain_with_offset _frida_g_slice_free_chain_with_offset +#define g_slice_get_config _frida_g_slice_get_config +#define g_slice_get_config_state _frida_g_slice_get_config_state +#define g_slice_set_config _frida_g_slice_set_config +#define g_slist_alloc _frida_g_slist_alloc +#define g_slist_append _frida_g_slist_append +#define g_slist_concat _frida_g_slist_concat +#define g_slist_copy _frida_g_slist_copy +#define g_slist_copy_deep _frida_g_slist_copy_deep +#define g_slist_delete_link _frida_g_slist_delete_link +#define g_slist_find _frida_g_slist_find +#define g_slist_find_custom _frida_g_slist_find_custom +#define g_slist_foreach _frida_g_slist_foreach +#define g_slist_free _frida_g_slist_free +#define g_slist_free_1 _frida_g_slist_free_1 +#define g_slist_free_full _frida_g_slist_free_full +#define g_slist_index _frida_g_slist_index +#define g_slist_insert _frida_g_slist_insert +#define g_slist_insert_before _frida_g_slist_insert_before +#define g_slist_insert_sorted _frida_g_slist_insert_sorted +#define g_slist_insert_sorted_with_data _frida_g_slist_insert_sorted_with_data +#define g_slist_last _frida_g_slist_last +#define g_slist_length _frida_g_slist_length +#define g_slist_nth _frida_g_slist_nth +#define g_slist_nth_data _frida_g_slist_nth_data +#define g_slist_pop_allocator _frida_g_slist_pop_allocator +#define g_slist_position _frida_g_slist_position +#define g_slist_prepend _frida_g_slist_prepend +#define g_slist_push_allocator _frida_g_slist_push_allocator +#define g_slist_remove _frida_g_slist_remove +#define g_slist_remove_all _frida_g_slist_remove_all +#define g_slist_remove_link _frida_g_slist_remove_link +#define g_slist_reverse _frida_g_slist_reverse +#define g_slist_sort _frida_g_slist_sort +#define g_slist_sort_with_data _frida_g_slist_sort_with_data +#define g_snprintf _frida_g_snprintf +#define g_socket _frida_g_socket +#define g_socket_accept _frida_g_socket_accept +#define g_socket_address_enumerator_get_type _frida_g_socket_address_enumerator_get_type +#define g_socket_address_enumerator_next _frida_g_socket_address_enumerator_next +#define g_socket_address_enumerator_next_async _frida_g_socket_address_enumerator_next_async +#define g_socket_address_enumerator_next_finish _frida_g_socket_address_enumerator_next_finish +#define g_socket_address_get_family _frida_g_socket_address_get_family +#define g_socket_address_get_native_size _frida_g_socket_address_get_native_size +#define g_socket_address_get_type _frida_g_socket_address_get_type +#define g_socket_address_new_from_native _frida_g_socket_address_new_from_native +#define g_socket_address_to_native _frida_g_socket_address_to_native +#define g_socket_bind _frida_g_socket_bind +#define g_socket_check_connect_result _frida_g_socket_check_connect_result +#define g_socket_client_add_application_proxy _frida_g_socket_client_add_application_proxy +#define g_socket_client_connect _frida_g_socket_client_connect +#define g_socket_client_connect_async _frida_g_socket_client_connect_async +#define g_socket_client_connect_finish _frida_g_socket_client_connect_finish +#define g_socket_client_connect_to_host _frida_g_socket_client_connect_to_host +#define g_socket_client_connect_to_host_async _frida_g_socket_client_connect_to_host_async +#define g_socket_client_connect_to_host_finish _frida_g_socket_client_connect_to_host_finish +#define g_socket_client_connect_to_service _frida_g_socket_client_connect_to_service +#define g_socket_client_connect_to_service_async _frida_g_socket_client_connect_to_service_async +#define g_socket_client_connect_to_service_finish _frida_g_socket_client_connect_to_service_finish +#define g_socket_client_connect_to_uri _frida_g_socket_client_connect_to_uri +#define g_socket_client_connect_to_uri_async _frida_g_socket_client_connect_to_uri_async +#define g_socket_client_connect_to_uri_finish _frida_g_socket_client_connect_to_uri_finish +#define g_socket_client_event_get_type _frida_g_socket_client_event_get_type +#define g_socket_client_get_enable_proxy _frida_g_socket_client_get_enable_proxy +#define g_socket_client_get_family _frida_g_socket_client_get_family +#define g_socket_client_get_local_address _frida_g_socket_client_get_local_address +#define g_socket_client_get_protocol _frida_g_socket_client_get_protocol +#define g_socket_client_get_proxy_resolver _frida_g_socket_client_get_proxy_resolver +#define g_socket_client_get_socket_type _frida_g_socket_client_get_socket_type +#define g_socket_client_get_timeout _frida_g_socket_client_get_timeout +#define g_socket_client_get_tls _frida_g_socket_client_get_tls +#define g_socket_client_get_tls_validation_flags _frida_g_socket_client_get_tls_validation_flags +#define g_socket_client_get_type _frida_g_socket_client_get_type +#define g_socket_client_new _frida_g_socket_client_new +#define g_socket_client_set_enable_proxy _frida_g_socket_client_set_enable_proxy +#define g_socket_client_set_family _frida_g_socket_client_set_family +#define g_socket_client_set_local_address _frida_g_socket_client_set_local_address +#define g_socket_client_set_protocol _frida_g_socket_client_set_protocol +#define g_socket_client_set_proxy_resolver _frida_g_socket_client_set_proxy_resolver +#define g_socket_client_set_socket_type _frida_g_socket_client_set_socket_type +#define g_socket_client_set_timeout _frida_g_socket_client_set_timeout +#define g_socket_client_set_tls _frida_g_socket_client_set_tls +#define g_socket_client_set_tls_validation_flags _frida_g_socket_client_set_tls_validation_flags +#define g_socket_close _frida_g_socket_close +#define g_socket_condition_check _frida_g_socket_condition_check +#define g_socket_condition_timed_wait _frida_g_socket_condition_timed_wait +#define g_socket_condition_wait _frida_g_socket_condition_wait +#define g_socket_connect _frida_g_socket_connect +#define g_socket_connectable_enumerate _frida_g_socket_connectable_enumerate +#define g_socket_connectable_get_type _frida_g_socket_connectable_get_type +#define g_socket_connectable_proxy_enumerate _frida_g_socket_connectable_proxy_enumerate +#define g_socket_connectable_to_string _frida_g_socket_connectable_to_string +#define g_socket_connection_connect _frida_g_socket_connection_connect +#define g_socket_connection_connect_async _frida_g_socket_connection_connect_async +#define g_socket_connection_connect_finish _frida_g_socket_connection_connect_finish +#define g_socket_connection_factory_create_connection _frida_g_socket_connection_factory_create_connection +#define g_socket_connection_factory_lookup_type _frida_g_socket_connection_factory_lookup_type +#define g_socket_connection_factory_register_type _frida_g_socket_connection_factory_register_type +#define g_socket_connection_get_local_address _frida_g_socket_connection_get_local_address +#define g_socket_connection_get_remote_address _frida_g_socket_connection_get_remote_address +#define g_socket_connection_get_socket _frida_g_socket_connection_get_socket +#define g_socket_connection_get_type _frida_g_socket_connection_get_type +#define g_socket_connection_is_connected _frida_g_socket_connection_is_connected +#define g_socket_connection_set_cached_remote_address _frida_g_socket_connection_set_cached_remote_address +#define g_socket_control_message_deserialize _frida_g_socket_control_message_deserialize +#define g_socket_control_message_get_level _frida_g_socket_control_message_get_level +#define g_socket_control_message_get_msg_type _frida_g_socket_control_message_get_msg_type +#define g_socket_control_message_get_size _frida_g_socket_control_message_get_size +#define g_socket_control_message_get_type _frida_g_socket_control_message_get_type +#define g_socket_control_message_serialize _frida_g_socket_control_message_serialize +#define g_socket_create_source _frida_g_socket_create_source +#define g_socket_family_get_type _frida_g_socket_family_get_type +#define g_socket_get_available_bytes _frida_g_socket_get_available_bytes +#define g_socket_get_blocking _frida_g_socket_get_blocking +#define g_socket_get_broadcast _frida_g_socket_get_broadcast +#define g_socket_get_credentials _frida_g_socket_get_credentials +#define g_socket_get_family _frida_g_socket_get_family +#define g_socket_get_fd _frida_g_socket_get_fd +#define g_socket_get_keepalive _frida_g_socket_get_keepalive +#define g_socket_get_listen_backlog _frida_g_socket_get_listen_backlog +#define g_socket_get_local_address _frida_g_socket_get_local_address +#define g_socket_get_multicast_loopback _frida_g_socket_get_multicast_loopback +#define g_socket_get_multicast_ttl _frida_g_socket_get_multicast_ttl +#define g_socket_get_option _frida_g_socket_get_option +#define g_socket_get_protocol _frida_g_socket_get_protocol +#define g_socket_get_remote_address _frida_g_socket_get_remote_address +#define g_socket_get_socket_type _frida_g_socket_get_socket_type +#define g_socket_get_timeout _frida_g_socket_get_timeout +#define g_socket_get_ttl _frida_g_socket_get_ttl +#define g_socket_get_type _frida_g_socket_get_type +#define g_socket_is_closed _frida_g_socket_is_closed +#define g_socket_is_connected _frida_g_socket_is_connected +#define g_socket_join_multicast_group _frida_g_socket_join_multicast_group +#define g_socket_join_multicast_group_ssm _frida_g_socket_join_multicast_group_ssm +#define g_socket_leave_multicast_group _frida_g_socket_leave_multicast_group +#define g_socket_leave_multicast_group_ssm _frida_g_socket_leave_multicast_group_ssm +#define g_socket_listen _frida_g_socket_listen +#define g_socket_listener_accept _frida_g_socket_listener_accept +#define g_socket_listener_accept_async _frida_g_socket_listener_accept_async +#define g_socket_listener_accept_finish _frida_g_socket_listener_accept_finish +#define g_socket_listener_accept_socket _frida_g_socket_listener_accept_socket +#define g_socket_listener_accept_socket_async _frida_g_socket_listener_accept_socket_async +#define g_socket_listener_accept_socket_finish _frida_g_socket_listener_accept_socket_finish +#define g_socket_listener_add_address _frida_g_socket_listener_add_address +#define g_socket_listener_add_any_inet_port _frida_g_socket_listener_add_any_inet_port +#define g_socket_listener_add_inet_port _frida_g_socket_listener_add_inet_port +#define g_socket_listener_add_socket _frida_g_socket_listener_add_socket +#define g_socket_listener_close _frida_g_socket_listener_close +#define g_socket_listener_event_get_type _frida_g_socket_listener_event_get_type +#define g_socket_listener_get_type _frida_g_socket_listener_get_type +#define g_socket_listener_new _frida_g_socket_listener_new +#define g_socket_listener_set_backlog _frida_g_socket_listener_set_backlog +#define g_socket_msg_flags_get_type _frida_g_socket_msg_flags_get_type +#define g_socket_new _frida_g_socket_new +#define g_socket_new_from_fd _frida_g_socket_new_from_fd +#define g_socket_protocol_get_type _frida_g_socket_protocol_get_type +#define g_socket_receive _frida_g_socket_receive +#define g_socket_receive_from _frida_g_socket_receive_from +#define g_socket_receive_message _frida_g_socket_receive_message +#define g_socket_receive_messages _frida_g_socket_receive_messages +#define g_socket_receive_with_blocking _frida_g_socket_receive_with_blocking +#define g_socket_send _frida_g_socket_send +#define g_socket_send_message _frida_g_socket_send_message +#define g_socket_send_message_with_timeout _frida_g_socket_send_message_with_timeout +#define g_socket_send_messages _frida_g_socket_send_messages +#define g_socket_send_to _frida_g_socket_send_to +#define g_socket_send_with_blocking _frida_g_socket_send_with_blocking +#define g_socket_service_get_type _frida_g_socket_service_get_type +#define g_socket_service_is_active _frida_g_socket_service_is_active +#define g_socket_service_new _frida_g_socket_service_new +#define g_socket_service_start _frida_g_socket_service_start +#define g_socket_service_stop _frida_g_socket_service_stop +#define g_socket_set_blocking _frida_g_socket_set_blocking +#define g_socket_set_broadcast _frida_g_socket_set_broadcast +#define g_socket_set_keepalive _frida_g_socket_set_keepalive +#define g_socket_set_listen_backlog _frida_g_socket_set_listen_backlog +#define g_socket_set_multicast_loopback _frida_g_socket_set_multicast_loopback +#define g_socket_set_multicast_ttl _frida_g_socket_set_multicast_ttl +#define g_socket_set_option _frida_g_socket_set_option +#define g_socket_set_timeout _frida_g_socket_set_timeout +#define g_socket_set_ttl _frida_g_socket_set_ttl +#define g_socket_shutdown _frida_g_socket_shutdown +#define g_socket_speaks_ipv4 _frida_g_socket_speaks_ipv4 +#define g_socket_type_get_type _frida_g_socket_type_get_type +#define g_source_add_child_source _frida_g_source_add_child_source +#define g_source_add_poll _frida_g_source_add_poll +#define g_source_add_unix_fd _frida_g_source_add_unix_fd +#define g_source_attach _frida_g_source_attach +#define g_source_destroy _frida_g_source_destroy +#define g_source_get_can_recurse _frida_g_source_get_can_recurse +#define g_source_get_context _frida_g_source_get_context +#define g_source_get_current_time _frida_g_source_get_current_time +#define g_source_get_id _frida_g_source_get_id +#define g_source_get_name _frida_g_source_get_name +#define g_source_get_priority _frida_g_source_get_priority +#define g_source_get_ready_time _frida_g_source_get_ready_time +#define g_source_get_time _frida_g_source_get_time +#define g_source_get_type _frida_g_source_get_type +#define g_source_is_destroyed _frida_g_source_is_destroyed +#define g_source_modify_unix_fd _frida_g_source_modify_unix_fd +#define g_source_new _frida_g_source_new +#define g_source_query_unix_fd _frida_g_source_query_unix_fd +#define g_source_ref _frida_g_source_ref +#define g_source_remove _frida_g_source_remove +#define g_source_remove_by_funcs_user_data _frida_g_source_remove_by_funcs_user_data +#define g_source_remove_by_user_data _frida_g_source_remove_by_user_data +#define g_source_remove_child_source _frida_g_source_remove_child_source +#define g_source_remove_poll _frida_g_source_remove_poll +#define g_source_remove_unix_fd _frida_g_source_remove_unix_fd +#define g_source_set_callback _frida_g_source_set_callback +#define g_source_set_callback_indirect _frida_g_source_set_callback_indirect +#define g_source_set_can_recurse _frida_g_source_set_can_recurse +#define g_source_set_closure _frida_g_source_set_closure +#define g_source_set_dispose_function _frida_g_source_set_dispose_function +#define g_source_set_dummy_callback _frida_g_source_set_dummy_callback +#define g_source_set_funcs _frida_g_source_set_funcs +#define g_source_set_name _frida_g_source_set_name +#define g_source_set_name_by_id _frida_g_source_set_name_by_id +#define g_source_set_priority _frida_g_source_set_priority +#define g_source_set_ready_time _frida_g_source_set_ready_time +#define g_source_unref _frida_g_source_unref +#define g_spaced_primes_closest _frida_g_spaced_primes_closest +#define g_spawn_async _frida_g_spawn_async +#define g_spawn_async_with_fds _frida_g_spawn_async_with_fds +#define g_spawn_async_with_pipes _frida_g_spawn_async_with_pipes +#define g_spawn_check_exit_status _frida_g_spawn_check_exit_status +#define g_spawn_close_pid _frida_g_spawn_close_pid +#define g_spawn_command_line_async _frida_g_spawn_command_line_async +#define g_spawn_command_line_sync _frida_g_spawn_command_line_sync +#define g_spawn_error_quark _frida_g_spawn_error_quark +#define g_spawn_exit_error_quark _frida_g_spawn_exit_error_quark +#define g_spawn_sync _frida_g_spawn_sync +#define g_sprintf _frida_g_sprintf +#define g_srv_target_copy _frida_g_srv_target_copy +#define g_srv_target_free _frida_g_srv_target_free +#define g_srv_target_get_hostname _frida_g_srv_target_get_hostname +#define g_srv_target_get_port _frida_g_srv_target_get_port +#define g_srv_target_get_priority _frida_g_srv_target_get_priority +#define g_srv_target_get_type _frida_g_srv_target_get_type +#define g_srv_target_get_weight _frida_g_srv_target_get_weight +#define g_srv_target_list_sort _frida_g_srv_target_list_sort +#define g_srv_target_new _frida_g_srv_target_new +#define g_stat _frida_g_stat +#define g_static_mutex_free _frida_g_static_mutex_free +#define g_static_mutex_get_mutex_impl _frida_g_static_mutex_get_mutex_impl +#define g_static_mutex_init _frida_g_static_mutex_init +#define g_static_private_free _frida_g_static_private_free +#define g_static_private_get _frida_g_static_private_get +#define g_static_private_init _frida_g_static_private_init +#define g_static_private_set _frida_g_static_private_set +#define g_static_rec_mutex_free _frida_g_static_rec_mutex_free +#define g_static_rec_mutex_init _frida_g_static_rec_mutex_init +#define g_static_rec_mutex_lock _frida_g_static_rec_mutex_lock +#define g_static_rec_mutex_lock_full _frida_g_static_rec_mutex_lock_full +#define g_static_rec_mutex_trylock _frida_g_static_rec_mutex_trylock +#define g_static_rec_mutex_unlock _frida_g_static_rec_mutex_unlock +#define g_static_rec_mutex_unlock_full _frida_g_static_rec_mutex_unlock_full +#define g_static_resource_fini _frida_g_static_resource_fini +#define g_static_resource_get_resource _frida_g_static_resource_get_resource +#define g_static_resource_init _frida_g_static_resource_init +#define g_static_rw_lock_free _frida_g_static_rw_lock_free +#define g_static_rw_lock_init _frida_g_static_rw_lock_init +#define g_static_rw_lock_reader_lock _frida_g_static_rw_lock_reader_lock +#define g_static_rw_lock_reader_trylock _frida_g_static_rw_lock_reader_trylock +#define g_static_rw_lock_reader_unlock _frida_g_static_rw_lock_reader_unlock +#define g_static_rw_lock_writer_lock _frida_g_static_rw_lock_writer_lock +#define g_static_rw_lock_writer_trylock _frida_g_static_rw_lock_writer_trylock +#define g_static_rw_lock_writer_unlock _frida_g_static_rw_lock_writer_unlock +#define g_stpcpy _frida_g_stpcpy +#define g_str_equal _frida_g_str_equal +#define g_str_has_prefix _frida_g_str_has_prefix +#define g_str_has_suffix _frida_g_str_has_suffix +#define g_str_hash _frida_g_str_hash +#define g_str_is_ascii _frida_g_str_is_ascii +#define g_str_match_string _frida_g_str_match_string +#define g_str_to_ascii _frida_g_str_to_ascii +#define g_str_tokenize_and_fold _frida_g_str_tokenize_and_fold +#define g_strcanon _frida_g_strcanon +#define g_strcasecmp _frida_g_strcasecmp +#define g_strchomp _frida_g_strchomp +#define g_strchug _frida_g_strchug +#define g_strcmp0 _frida_g_strcmp0 +#define g_strcompress _frida_g_strcompress +#define g_strconcat _frida_g_strconcat +#define g_strdelimit _frida_g_strdelimit +#define g_strdown _frida_g_strdown +#define g_strdup _frida_g_strdup +#define g_strdup_printf _frida_g_strdup_printf +#define g_strdup_value_contents _frida_g_strdup_value_contents +#define g_strdup_vprintf _frida_g_strdup_vprintf +#define g_strdupv _frida_g_strdupv +#define g_strerror _frida_g_strerror +#define g_strescape _frida_g_strescape +#define g_strfreev _frida_g_strfreev +#define g_string_append _frida_g_string_append +#define g_string_append_c _frida_g_string_append_c +#define g_string_append_len _frida_g_string_append_len +#define g_string_append_printf _frida_g_string_append_printf +#define g_string_append_unichar _frida_g_string_append_unichar +#define g_string_append_uri_escaped _frida_g_string_append_uri_escaped +#define g_string_append_vprintf _frida_g_string_append_vprintf +#define g_string_ascii_down _frida_g_string_ascii_down +#define g_string_ascii_up _frida_g_string_ascii_up +#define g_string_assign _frida_g_string_assign +#define g_string_chunk_clear _frida_g_string_chunk_clear +#define g_string_chunk_free _frida_g_string_chunk_free +#define g_string_chunk_insert _frida_g_string_chunk_insert +#define g_string_chunk_insert_const _frida_g_string_chunk_insert_const +#define g_string_chunk_insert_len _frida_g_string_chunk_insert_len +#define g_string_chunk_new _frida_g_string_chunk_new +#define g_string_down _frida_g_string_down +#define g_string_equal _frida_g_string_equal +#define g_string_erase _frida_g_string_erase +#define g_string_free _frida_g_string_free +#define g_string_free_to_bytes _frida_g_string_free_to_bytes +#define g_string_hash _frida_g_string_hash +#define g_string_insert _frida_g_string_insert +#define g_string_insert_c _frida_g_string_insert_c +#define g_string_insert_len _frida_g_string_insert_len +#define g_string_insert_unichar _frida_g_string_insert_unichar +#define g_string_new _frida_g_string_new +#define g_string_new_len _frida_g_string_new_len +#define g_string_overwrite _frida_g_string_overwrite +#define g_string_overwrite_len _frida_g_string_overwrite_len +#define g_string_prepend _frida_g_string_prepend +#define g_string_prepend_c _frida_g_string_prepend_c +#define g_string_prepend_len _frida_g_string_prepend_len +#define g_string_prepend_unichar _frida_g_string_prepend_unichar +#define g_string_printf _frida_g_string_printf +#define g_string_set_size _frida_g_string_set_size +#define g_string_sized_new _frida_g_string_sized_new +#define g_string_truncate _frida_g_string_truncate +#define g_string_up _frida_g_string_up +#define g_string_vprintf _frida_g_string_vprintf +#define g_strip_context _frida_g_strip_context +#define g_strjoin _frida_g_strjoin +#define g_strjoinv _frida_g_strjoinv +#define g_strlcat _frida_g_strlcat +#define g_strlcpy _frida_g_strlcpy +#define g_strncasecmp _frida_g_strncasecmp +#define g_strndup _frida_g_strndup +#define g_strnfill _frida_g_strnfill +#define g_strreverse _frida_g_strreverse +#define g_strrstr _frida_g_strrstr +#define g_strrstr_len _frida_g_strrstr_len +#define g_strsignal _frida_g_strsignal +#define g_strsplit _frida_g_strsplit +#define g_strsplit_set _frida_g_strsplit_set +#define g_strstr_len _frida_g_strstr_len +#define g_strtod _frida_g_strtod +#define g_strup _frida_g_strup +#define g_strv_builder_add _frida_g_strv_builder_add +#define g_strv_builder_end _frida_g_strv_builder_end +#define g_strv_builder_new _frida_g_strv_builder_new +#define g_strv_builder_ref _frida_g_strv_builder_ref +#define g_strv_builder_unref _frida_g_strv_builder_unref +#define g_strv_contains _frida_g_strv_contains +#define g_strv_equal _frida_g_strv_equal +#define g_strv_get_type _frida_g_strv_get_type +#define g_strv_length _frida_g_strv_length +#define g_subprocess_communicate _frida_g_subprocess_communicate +#define g_subprocess_communicate_async _frida_g_subprocess_communicate_async +#define g_subprocess_communicate_finish _frida_g_subprocess_communicate_finish +#define g_subprocess_communicate_utf8 _frida_g_subprocess_communicate_utf8 +#define g_subprocess_communicate_utf8_async _frida_g_subprocess_communicate_utf8_async +#define g_subprocess_communicate_utf8_finish _frida_g_subprocess_communicate_utf8_finish +#define g_subprocess_flags_get_type _frida_g_subprocess_flags_get_type +#define g_subprocess_force_exit _frida_g_subprocess_force_exit +#define g_subprocess_get_exit_status _frida_g_subprocess_get_exit_status +#define g_subprocess_get_identifier _frida_g_subprocess_get_identifier +#define g_subprocess_get_if_exited _frida_g_subprocess_get_if_exited +#define g_subprocess_get_if_signaled _frida_g_subprocess_get_if_signaled +#define g_subprocess_get_status _frida_g_subprocess_get_status +#define g_subprocess_get_stderr_pipe _frida_g_subprocess_get_stderr_pipe +#define g_subprocess_get_stdin_pipe _frida_g_subprocess_get_stdin_pipe +#define g_subprocess_get_stdout_pipe _frida_g_subprocess_get_stdout_pipe +#define g_subprocess_get_successful _frida_g_subprocess_get_successful +#define g_subprocess_get_term_sig _frida_g_subprocess_get_term_sig +#define g_subprocess_get_type _frida_g_subprocess_get_type +#define g_subprocess_launcher_close _frida_g_subprocess_launcher_close +#define g_subprocess_launcher_get_type _frida_g_subprocess_launcher_get_type +#define g_subprocess_launcher_getenv _frida_g_subprocess_launcher_getenv +#define g_subprocess_launcher_new _frida_g_subprocess_launcher_new +#define g_subprocess_launcher_set_child_setup _frida_g_subprocess_launcher_set_child_setup +#define g_subprocess_launcher_set_cwd _frida_g_subprocess_launcher_set_cwd +#define g_subprocess_launcher_set_environ _frida_g_subprocess_launcher_set_environ +#define g_subprocess_launcher_set_flags _frida_g_subprocess_launcher_set_flags +#define g_subprocess_launcher_set_stderr_file_path _frida_g_subprocess_launcher_set_stderr_file_path +#define g_subprocess_launcher_set_stdin_file_path _frida_g_subprocess_launcher_set_stdin_file_path +#define g_subprocess_launcher_set_stdout_file_path _frida_g_subprocess_launcher_set_stdout_file_path +#define g_subprocess_launcher_setenv _frida_g_subprocess_launcher_setenv +#define g_subprocess_launcher_spawn _frida_g_subprocess_launcher_spawn +#define g_subprocess_launcher_spawnv _frida_g_subprocess_launcher_spawnv +#define g_subprocess_launcher_take_fd _frida_g_subprocess_launcher_take_fd +#define g_subprocess_launcher_take_stderr_fd _frida_g_subprocess_launcher_take_stderr_fd +#define g_subprocess_launcher_take_stdin_fd _frida_g_subprocess_launcher_take_stdin_fd +#define g_subprocess_launcher_take_stdout_fd _frida_g_subprocess_launcher_take_stdout_fd +#define g_subprocess_launcher_unsetenv _frida_g_subprocess_launcher_unsetenv +#define g_subprocess_new _frida_g_subprocess_new +#define g_subprocess_newv _frida_g_subprocess_newv +#define g_subprocess_send_signal _frida_g_subprocess_send_signal +#define g_subprocess_set_launcher _frida_g_subprocess_set_launcher +#define g_subprocess_wait _frida_g_subprocess_wait +#define g_subprocess_wait_async _frida_g_subprocess_wait_async +#define g_subprocess_wait_check _frida_g_subprocess_wait_check +#define g_subprocess_wait_check_async _frida_g_subprocess_wait_check_async +#define g_subprocess_wait_check_finish _frida_g_subprocess_wait_check_finish +#define g_subprocess_wait_finish _frida_g_subprocess_wait_finish +#define g_system_thread_exit _frida_g_system_thread_exit +#define g_system_thread_free _frida_g_system_thread_free +#define g_system_thread_get_scheduler_settings _frida_g_system_thread_get_scheduler_settings +#define g_system_thread_new _frida_g_system_thread_new +#define g_system_thread_set_name _frida_g_system_thread_set_name +#define g_system_thread_wait _frida_g_system_thread_wait +#define g_task_attach_source _frida_g_task_attach_source +#define g_task_get_cancellable _frida_g_task_get_cancellable +#define g_task_get_check_cancellable _frida_g_task_get_check_cancellable +#define g_task_get_completed _frida_g_task_get_completed +#define g_task_get_context _frida_g_task_get_context +#define g_task_get_name _frida_g_task_get_name +#define g_task_get_priority _frida_g_task_get_priority +#define g_task_get_return_on_cancel _frida_g_task_get_return_on_cancel +#define g_task_get_source_object _frida_g_task_get_source_object +#define g_task_get_source_tag _frida_g_task_get_source_tag +#define g_task_get_task_data _frida_g_task_get_task_data +#define g_task_get_type _frida_g_task_get_type +#define g_task_had_error _frida_g_task_had_error +#define g_task_is_valid _frida_g_task_is_valid +#define g_task_new _frida_g_task_new +#define g_task_propagate_boolean _frida_g_task_propagate_boolean +#define g_task_propagate_int _frida_g_task_propagate_int +#define g_task_propagate_pointer _frida_g_task_propagate_pointer +#define g_task_propagate_value _frida_g_task_propagate_value +#define g_task_report_error _frida_g_task_report_error +#define g_task_report_new_error _frida_g_task_report_new_error +#define g_task_return_boolean _frida_g_task_return_boolean +#define g_task_return_error _frida_g_task_return_error +#define g_task_return_error_if_cancelled _frida_g_task_return_error_if_cancelled +#define g_task_return_int _frida_g_task_return_int +#define g_task_return_new_error _frida_g_task_return_new_error +#define g_task_return_pointer _frida_g_task_return_pointer +#define g_task_return_value _frida_g_task_return_value +#define g_task_run_in_thread _frida_g_task_run_in_thread +#define g_task_run_in_thread_sync _frida_g_task_run_in_thread_sync +#define g_task_set_check_cancellable _frida_g_task_set_check_cancellable +#define g_task_set_name _frida_g_task_set_name +#define g_task_set_priority _frida_g_task_set_priority +#define g_task_set_return_on_cancel _frida_g_task_set_return_on_cancel +#define g_task_set_source_tag _frida_g_task_set_source_tag +#define g_task_set_task_data _frida_g_task_set_task_data +#define g_tcp_connection_get_graceful_disconnect _frida_g_tcp_connection_get_graceful_disconnect +#define g_tcp_connection_get_type _frida_g_tcp_connection_get_type +#define g_tcp_connection_set_graceful_disconnect _frida_g_tcp_connection_set_graceful_disconnect +#define g_tcp_wrapper_connection_get_base_io_stream _frida_g_tcp_wrapper_connection_get_base_io_stream +#define g_tcp_wrapper_connection_get_type _frida_g_tcp_wrapper_connection_get_type +#define g_tcp_wrapper_connection_new _frida_g_tcp_wrapper_connection_new +#define g_test_add_data_func _frida_g_test_add_data_func +#define g_test_add_data_func_full _frida_g_test_add_data_func_full +#define g_test_add_func _frida_g_test_add_func +#define g_test_add_vtable _frida_g_test_add_vtable +#define g_test_assert_expected_messages_internal _frida_g_test_assert_expected_messages_internal +#define g_test_bug _frida_g_test_bug +#define g_test_bug_base _frida_g_test_bug_base +#define g_test_build_filename _frida_g_test_build_filename +#define g_test_config_vars _frida_g_test_config_vars +#define g_test_create_case _frida_g_test_create_case +#define g_test_create_suite _frida_g_test_create_suite +#define g_test_dbus_add_service_dir _frida_g_test_dbus_add_service_dir +#define g_test_dbus_down _frida_g_test_dbus_down +#define g_test_dbus_flags_get_type _frida_g_test_dbus_flags_get_type +#define g_test_dbus_get_bus_address _frida_g_test_dbus_get_bus_address +#define g_test_dbus_get_flags _frida_g_test_dbus_get_flags +#define g_test_dbus_get_type _frida_g_test_dbus_get_type +#define g_test_dbus_new _frida_g_test_dbus_new +#define g_test_dbus_stop _frida_g_test_dbus_stop +#define g_test_dbus_unset _frida_g_test_dbus_unset +#define g_test_dbus_up _frida_g_test_dbus_up +#define g_test_expect_message _frida_g_test_expect_message +#define g_test_fail _frida_g_test_fail +#define g_test_failed _frida_g_test_failed +#define g_test_get_dir _frida_g_test_get_dir +#define g_test_get_filename _frida_g_test_get_filename +#define g_test_get_root _frida_g_test_get_root +#define g_test_incomplete _frida_g_test_incomplete +#define g_test_init _frida_g_test_init +#define g_test_log_buffer_free _frida_g_test_log_buffer_free +#define g_test_log_buffer_new _frida_g_test_log_buffer_new +#define g_test_log_buffer_pop _frida_g_test_log_buffer_pop +#define g_test_log_buffer_push _frida_g_test_log_buffer_push +#define g_test_log_msg_free _frida_g_test_log_msg_free +#define g_test_log_set_fatal_handler _frida_g_test_log_set_fatal_handler +#define g_test_log_type_name _frida_g_test_log_type_name +#define g_test_maximized_result _frida_g_test_maximized_result +#define g_test_message _frida_g_test_message +#define g_test_minimized_result _frida_g_test_minimized_result +#define g_test_queue_destroy _frida_g_test_queue_destroy +#define g_test_queue_free _frida_g_test_queue_free +#define g_test_rand_double _frida_g_test_rand_double +#define g_test_rand_double_range _frida_g_test_rand_double_range +#define g_test_rand_int _frida_g_test_rand_int +#define g_test_rand_int_range _frida_g_test_rand_int_range +#define g_test_run _frida_g_test_run +#define g_test_run_suite _frida_g_test_run_suite +#define g_test_set_nonfatal_assertions _frida_g_test_set_nonfatal_assertions +#define g_test_skip _frida_g_test_skip +#define g_test_subprocess _frida_g_test_subprocess +#define g_test_suite_add _frida_g_test_suite_add +#define g_test_suite_add_suite _frida_g_test_suite_add_suite +#define g_test_summary _frida_g_test_summary +#define g_test_timer_elapsed _frida_g_test_timer_elapsed +#define g_test_timer_last _frida_g_test_timer_last +#define g_test_timer_start _frida_g_test_timer_start +#define g_test_trap_assertions _frida_g_test_trap_assertions +#define g_test_trap_fork _frida_g_test_trap_fork +#define g_test_trap_has_passed _frida_g_test_trap_has_passed +#define g_test_trap_reached_timeout _frida_g_test_trap_reached_timeout +#define g_test_trap_subprocess _frida_g_test_trap_subprocess +#define g_themed_icon_append_name _frida_g_themed_icon_append_name +#define g_themed_icon_get_names _frida_g_themed_icon_get_names +#define g_themed_icon_get_type _frida_g_themed_icon_get_type +#define g_themed_icon_new _frida_g_themed_icon_new +#define g_themed_icon_new_from_names _frida_g_themed_icon_new_from_names +#define g_themed_icon_new_with_default_fallbacks _frida_g_themed_icon_new_with_default_fallbacks +#define g_themed_icon_prepend_name _frida_g_themed_icon_prepend_name +#define g_thread_create _frida_g_thread_create +#define g_thread_create_full _frida_g_thread_create_full +#define g_thread_error_quark _frida_g_thread_error_quark +#define g_thread_exit _frida_g_thread_exit +#define g_thread_foreach _frida_g_thread_foreach +#define g_thread_functions_for_glib_use _frida_g_thread_functions_for_glib_use +#define g_thread_garbage_collect _frida_g_thread_garbage_collect +#define g_thread_get_initialized _frida_g_thread_get_initialized +#define g_thread_get_scheduler_settings _frida_g_thread_get_scheduler_settings +#define g_thread_get_type _frida_g_thread_get_type +#define g_thread_gettime _frida_g_thread_gettime +#define g_thread_init_glib _frida_g_thread_init_glib +#define g_thread_join _frida_g_thread_join +#define g_thread_lifetime_beacon_check _frida_g_thread_lifetime_beacon_check +#define g_thread_lifetime_beacon_free _frida_g_thread_lifetime_beacon_free +#define g_thread_lifetime_beacon_new _frida_g_thread_lifetime_beacon_new +#define g_thread_n_created _frida_g_thread_n_created +#define g_thread_new _frida_g_thread_new +#define g_thread_new_internal _frida_g_thread_new_internal +#define g_thread_perform_cleanup _frida_g_thread_perform_cleanup +#define g_thread_pool_free _frida_g_thread_pool_free +#define g_thread_pool_get_max_idle_time _frida_g_thread_pool_get_max_idle_time +#define g_thread_pool_get_max_threads _frida_g_thread_pool_get_max_threads +#define g_thread_pool_get_max_unused_threads _frida_g_thread_pool_get_max_unused_threads +#define g_thread_pool_get_num_threads _frida_g_thread_pool_get_num_threads +#define g_thread_pool_get_num_unused_threads _frida_g_thread_pool_get_num_unused_threads +#define g_thread_pool_move_to_front _frida_g_thread_pool_move_to_front +#define g_thread_pool_new _frida_g_thread_pool_new +#define g_thread_pool_push _frida_g_thread_pool_push +#define g_thread_pool_set_max_idle_time _frida_g_thread_pool_set_max_idle_time +#define g_thread_pool_set_max_threads _frida_g_thread_pool_set_max_threads +#define g_thread_pool_set_max_unused_threads _frida_g_thread_pool_set_max_unused_threads +#define g_thread_pool_set_sort_function _frida_g_thread_pool_set_sort_function +#define g_thread_pool_stop_unused_threads _frida_g_thread_pool_stop_unused_threads +#define g_thread_pool_unprocessed _frida_g_thread_pool_unprocessed +#define g_thread_private_destroy_later _frida_g_thread_private_destroy_later +#define g_thread_proxy _frida_g_thread_proxy +#define g_thread_ref _frida_g_thread_ref +#define g_thread_schedule_cleanup _frida_g_thread_schedule_cleanup +#define g_thread_self _frida_g_thread_self +#define g_thread_set_callbacks _frida_g_thread_set_callbacks +#define g_thread_set_garbage_handler _frida_g_thread_set_garbage_handler +#define g_thread_set_priority _frida_g_thread_set_priority +#define g_thread_try_new _frida_g_thread_try_new +#define g_thread_unref _frida_g_thread_unref +#define g_thread_use_default_impl _frida_g_thread_use_default_impl +#define g_thread_yield _frida_g_thread_yield +#define g_threaded_resolver_get_type _frida_g_threaded_resolver_get_type +#define g_threaded_socket_service_get_type _frida_g_threaded_socket_service_get_type +#define g_threaded_socket_service_new _frida_g_threaded_socket_service_new +#define g_threads_got_initialized _frida_g_threads_got_initialized +#define g_time_val_add _frida_g_time_val_add +#define g_time_val_from_iso8601 _frida_g_time_val_from_iso8601 +#define g_time_val_to_iso8601 _frida_g_time_val_to_iso8601 +#define g_time_zone_adjust_time _frida_g_time_zone_adjust_time +#define g_time_zone_find_interval _frida_g_time_zone_find_interval +#define g_time_zone_get_abbreviation _frida_g_time_zone_get_abbreviation +#define g_time_zone_get_identifier _frida_g_time_zone_get_identifier +#define g_time_zone_get_offset _frida_g_time_zone_get_offset +#define g_time_zone_get_type _frida_g_time_zone_get_type +#define g_time_zone_is_dst _frida_g_time_zone_is_dst +#define g_time_zone_new _frida_g_time_zone_new +#define g_time_zone_new_identifier _frida_g_time_zone_new_identifier +#define g_time_zone_new_local _frida_g_time_zone_new_local +#define g_time_zone_new_offset _frida_g_time_zone_new_offset +#define g_time_zone_new_utc _frida_g_time_zone_new_utc +#define g_time_zone_ref _frida_g_time_zone_ref +#define g_time_zone_unref _frida_g_time_zone_unref +#define g_timeout_add _frida_g_timeout_add +#define g_timeout_add_full _frida_g_timeout_add_full +#define g_timeout_add_seconds _frida_g_timeout_add_seconds +#define g_timeout_add_seconds_full _frida_g_timeout_add_seconds_full +#define g_timeout_funcs _frida_g_timeout_funcs +#define g_timeout_source_new _frida_g_timeout_source_new +#define g_timeout_source_new_seconds _frida_g_timeout_source_new_seconds +#define g_timer_continue _frida_g_timer_continue +#define g_timer_destroy _frida_g_timer_destroy +#define g_timer_elapsed _frida_g_timer_elapsed +#define g_timer_is_active _frida_g_timer_is_active +#define g_timer_new _frida_g_timer_new +#define g_timer_reset _frida_g_timer_reset +#define g_timer_start _frida_g_timer_start +#define g_timer_stop _frida_g_timer_stop +#define g_tinylist_foreach _frida_g_tinylist_foreach +#define g_tinylist_free _frida_g_tinylist_free +#define g_tinylist_prepend _frida_g_tinylist_prepend +#define g_tinylist_remove _frida_g_tinylist_remove +#define g_tls_authentication_mode_get_type _frida_g_tls_authentication_mode_get_type +#define g_tls_backend_get_certificate_type _frida_g_tls_backend_get_certificate_type +#define g_tls_backend_get_client_connection_type _frida_g_tls_backend_get_client_connection_type +#define g_tls_backend_get_default _frida_g_tls_backend_get_default +#define g_tls_backend_get_default_database _frida_g_tls_backend_get_default_database +#define g_tls_backend_get_dtls_client_connection_type _frida_g_tls_backend_get_dtls_client_connection_type +#define g_tls_backend_get_dtls_server_connection_type _frida_g_tls_backend_get_dtls_server_connection_type +#define g_tls_backend_get_file_database_type _frida_g_tls_backend_get_file_database_type +#define g_tls_backend_get_server_connection_type _frida_g_tls_backend_get_server_connection_type +#define g_tls_backend_get_type _frida_g_tls_backend_get_type +#define g_tls_backend_set_default_database _frida_g_tls_backend_set_default_database +#define g_tls_backend_supports_dtls _frida_g_tls_backend_supports_dtls +#define g_tls_backend_supports_tls _frida_g_tls_backend_supports_tls +#define g_tls_certificate_flags_get_type _frida_g_tls_certificate_flags_get_type +#define g_tls_certificate_get_issuer _frida_g_tls_certificate_get_issuer +#define g_tls_certificate_get_type _frida_g_tls_certificate_get_type +#define g_tls_certificate_is_same _frida_g_tls_certificate_is_same +#define g_tls_certificate_list_new_from_file _frida_g_tls_certificate_list_new_from_file +#define g_tls_certificate_new_from_file _frida_g_tls_certificate_new_from_file +#define g_tls_certificate_new_from_files _frida_g_tls_certificate_new_from_files +#define g_tls_certificate_new_from_pem _frida_g_tls_certificate_new_from_pem +#define g_tls_certificate_new_from_pkcs11_uris _frida_g_tls_certificate_new_from_pkcs11_uris +#define g_tls_certificate_request_flags_get_type _frida_g_tls_certificate_request_flags_get_type +#define g_tls_certificate_verify _frida_g_tls_certificate_verify +#define g_tls_channel_binding_error_get_type _frida_g_tls_channel_binding_error_get_type +#define g_tls_channel_binding_error_quark _frida_g_tls_channel_binding_error_quark +#define g_tls_channel_binding_type_get_type _frida_g_tls_channel_binding_type_get_type +#define g_tls_client_connection_copy_session_state _frida_g_tls_client_connection_copy_session_state +#define g_tls_client_connection_get_accepted_cas _frida_g_tls_client_connection_get_accepted_cas +#define g_tls_client_connection_get_server_identity _frida_g_tls_client_connection_get_server_identity +#define g_tls_client_connection_get_type _frida_g_tls_client_connection_get_type +#define g_tls_client_connection_get_use_ssl3 _frida_g_tls_client_connection_get_use_ssl3 +#define g_tls_client_connection_get_validation_flags _frida_g_tls_client_connection_get_validation_flags +#define g_tls_client_connection_new _frida_g_tls_client_connection_new +#define g_tls_client_connection_set_server_identity _frida_g_tls_client_connection_set_server_identity +#define g_tls_client_connection_set_use_ssl3 _frida_g_tls_client_connection_set_use_ssl3 +#define g_tls_client_connection_set_validation_flags _frida_g_tls_client_connection_set_validation_flags +#define g_tls_connection_emit_accept_certificate _frida_g_tls_connection_emit_accept_certificate +#define g_tls_connection_get_certificate _frida_g_tls_connection_get_certificate +#define g_tls_connection_get_channel_binding_data _frida_g_tls_connection_get_channel_binding_data +#define g_tls_connection_get_database _frida_g_tls_connection_get_database +#define g_tls_connection_get_interaction _frida_g_tls_connection_get_interaction +#define g_tls_connection_get_negotiated_protocol _frida_g_tls_connection_get_negotiated_protocol +#define g_tls_connection_get_peer_certificate _frida_g_tls_connection_get_peer_certificate +#define g_tls_connection_get_peer_certificate_errors _frida_g_tls_connection_get_peer_certificate_errors +#define g_tls_connection_get_rehandshake_mode _frida_g_tls_connection_get_rehandshake_mode +#define g_tls_connection_get_require_close_notify _frida_g_tls_connection_get_require_close_notify +#define g_tls_connection_get_type _frida_g_tls_connection_get_type +#define g_tls_connection_get_use_system_certdb _frida_g_tls_connection_get_use_system_certdb +#define g_tls_connection_handshake _frida_g_tls_connection_handshake +#define g_tls_connection_handshake_async _frida_g_tls_connection_handshake_async +#define g_tls_connection_handshake_finish _frida_g_tls_connection_handshake_finish +#define g_tls_connection_set_advertised_protocols _frida_g_tls_connection_set_advertised_protocols +#define g_tls_connection_set_certificate _frida_g_tls_connection_set_certificate +#define g_tls_connection_set_database _frida_g_tls_connection_set_database +#define g_tls_connection_set_interaction _frida_g_tls_connection_set_interaction +#define g_tls_connection_set_rehandshake_mode _frida_g_tls_connection_set_rehandshake_mode +#define g_tls_connection_set_require_close_notify _frida_g_tls_connection_set_require_close_notify +#define g_tls_connection_set_use_system_certdb _frida_g_tls_connection_set_use_system_certdb +#define g_tls_database_create_certificate_handle _frida_g_tls_database_create_certificate_handle +#define g_tls_database_get_type _frida_g_tls_database_get_type +#define g_tls_database_lookup_certificate_for_handle _frida_g_tls_database_lookup_certificate_for_handle +#define g_tls_database_lookup_certificate_for_handle_async _frida_g_tls_database_lookup_certificate_for_handle_async +#define g_tls_database_lookup_certificate_for_handle_finish _frida_g_tls_database_lookup_certificate_for_handle_finish +#define g_tls_database_lookup_certificate_issuer _frida_g_tls_database_lookup_certificate_issuer +#define g_tls_database_lookup_certificate_issuer_async _frida_g_tls_database_lookup_certificate_issuer_async +#define g_tls_database_lookup_certificate_issuer_finish _frida_g_tls_database_lookup_certificate_issuer_finish +#define g_tls_database_lookup_certificates_issued_by _frida_g_tls_database_lookup_certificates_issued_by +#define g_tls_database_lookup_certificates_issued_by_async _frida_g_tls_database_lookup_certificates_issued_by_async +#define g_tls_database_lookup_certificates_issued_by_finish _frida_g_tls_database_lookup_certificates_issued_by_finish +#define g_tls_database_lookup_flags_get_type _frida_g_tls_database_lookup_flags_get_type +#define g_tls_database_verify_chain _frida_g_tls_database_verify_chain +#define g_tls_database_verify_chain_async _frida_g_tls_database_verify_chain_async +#define g_tls_database_verify_chain_finish _frida_g_tls_database_verify_chain_finish +#define g_tls_database_verify_flags_get_type _frida_g_tls_database_verify_flags_get_type +#define g_tls_error_get_type _frida_g_tls_error_get_type +#define g_tls_error_quark _frida_g_tls_error_quark +#define g_tls_file_database_get_type _frida_g_tls_file_database_get_type +#define g_tls_file_database_new _frida_g_tls_file_database_new +#define g_tls_interaction_ask_password _frida_g_tls_interaction_ask_password +#define g_tls_interaction_ask_password_async _frida_g_tls_interaction_ask_password_async +#define g_tls_interaction_ask_password_finish _frida_g_tls_interaction_ask_password_finish +#define g_tls_interaction_get_type _frida_g_tls_interaction_get_type +#define g_tls_interaction_invoke_ask_password _frida_g_tls_interaction_invoke_ask_password +#define g_tls_interaction_invoke_request_certificate _frida_g_tls_interaction_invoke_request_certificate +#define g_tls_interaction_request_certificate _frida_g_tls_interaction_request_certificate +#define g_tls_interaction_request_certificate_async _frida_g_tls_interaction_request_certificate_async +#define g_tls_interaction_request_certificate_finish _frida_g_tls_interaction_request_certificate_finish +#define g_tls_interaction_result_get_type _frida_g_tls_interaction_result_get_type +#define g_tls_password_flags_get_type _frida_g_tls_password_flags_get_type +#define g_tls_password_get_description _frida_g_tls_password_get_description +#define g_tls_password_get_flags _frida_g_tls_password_get_flags +#define g_tls_password_get_type _frida_g_tls_password_get_type +#define g_tls_password_get_value _frida_g_tls_password_get_value +#define g_tls_password_get_warning _frida_g_tls_password_get_warning +#define g_tls_password_new _frida_g_tls_password_new +#define g_tls_password_set_description _frida_g_tls_password_set_description +#define g_tls_password_set_flags _frida_g_tls_password_set_flags +#define g_tls_password_set_value _frida_g_tls_password_set_value +#define g_tls_password_set_value_full _frida_g_tls_password_set_value_full +#define g_tls_password_set_warning _frida_g_tls_password_set_warning +#define g_tls_rehandshake_mode_get_type _frida_g_tls_rehandshake_mode_get_type +#define g_tls_server_connection_get_type _frida_g_tls_server_connection_get_type +#define g_tls_server_connection_new _frida_g_tls_server_connection_new +#define g_trace_define_int64_counter _frida_g_trace_define_int64_counter +#define g_trace_mark _frida_g_trace_mark +#define g_trace_set_int64_counter _frida_g_trace_set_int64_counter +#define g_trash_portal_trash_file _frida_g_trash_portal_trash_file +#define g_trash_stack_height _frida_g_trash_stack_height +#define g_trash_stack_peek _frida_g_trash_stack_peek +#define g_trash_stack_pop _frida_g_trash_stack_pop +#define g_trash_stack_push _frida_g_trash_stack_push +#define g_tree_destroy _frida_g_tree_destroy +#define g_tree_foreach _frida_g_tree_foreach +#define g_tree_foreach_node _frida_g_tree_foreach_node +#define g_tree_get_type _frida_g_tree_get_type +#define g_tree_height _frida_g_tree_height +#define g_tree_insert _frida_g_tree_insert +#define g_tree_insert_node _frida_g_tree_insert_node +#define g_tree_lookup _frida_g_tree_lookup +#define g_tree_lookup_extended _frida_g_tree_lookup_extended +#define g_tree_lookup_node _frida_g_tree_lookup_node +#define g_tree_lower_bound _frida_g_tree_lower_bound +#define g_tree_new _frida_g_tree_new +#define g_tree_new_full _frida_g_tree_new_full +#define g_tree_new_with_data _frida_g_tree_new_with_data +#define g_tree_nnodes _frida_g_tree_nnodes +#define g_tree_node_first _frida_g_tree_node_first +#define g_tree_node_key _frida_g_tree_node_key +#define g_tree_node_last _frida_g_tree_node_last +#define g_tree_node_next _frida_g_tree_node_next +#define g_tree_node_previous _frida_g_tree_node_previous +#define g_tree_node_value _frida_g_tree_node_value +#define g_tree_ref _frida_g_tree_ref +#define g_tree_remove _frida_g_tree_remove +#define g_tree_replace _frida_g_tree_replace +#define g_tree_replace_node _frida_g_tree_replace_node +#define g_tree_search _frida_g_tree_search +#define g_tree_search_node _frida_g_tree_search_node +#define g_tree_steal _frida_g_tree_steal +#define g_tree_traverse _frida_g_tree_traverse +#define g_tree_unref _frida_g_tree_unref +#define g_tree_upper_bound _frida_g_tree_upper_bound +#define g_try_malloc _frida_g_try_malloc +#define g_try_malloc0 _frida_g_try_malloc0 +#define g_try_malloc0_n _frida_g_try_malloc0_n +#define g_try_malloc_n _frida_g_try_malloc_n +#define g_try_realloc _frida_g_try_realloc +#define g_try_realloc_n _frida_g_try_realloc_n +#define g_tuples_destroy _frida_g_tuples_destroy +#define g_tuples_index _frida_g_tuples_index +#define g_type_add_class_cache_func _frida_g_type_add_class_cache_func +#define g_type_add_class_private _frida_g_type_add_class_private +#define g_type_add_instance_private _frida_g_type_add_instance_private +#define g_type_add_interface_check _frida_g_type_add_interface_check +#define g_type_add_interface_dynamic _frida_g_type_add_interface_dynamic +#define g_type_add_interface_static _frida_g_type_add_interface_static +#define g_type_check_class_cast _frida_g_type_check_class_cast +#define g_type_check_class_is_a _frida_g_type_check_class_is_a +#define g_type_check_instance _frida_g_type_check_instance +#define g_type_check_instance_cast _frida_g_type_check_instance_cast +#define g_type_check_instance_is_a _frida_g_type_check_instance_is_a +#define g_type_check_instance_is_fundamentally_a _frida_g_type_check_instance_is_fundamentally_a +#define g_type_check_is_value_type _frida_g_type_check_is_value_type +#define g_type_check_value _frida_g_type_check_value +#define g_type_check_value_holds _frida_g_type_check_value_holds +#define g_type_children _frida_g_type_children +#define g_type_class_add_private _frida_g_type_class_add_private +#define g_type_class_adjust_private_offset _frida_g_type_class_adjust_private_offset +#define g_type_class_get_instance_private_offset _frida_g_type_class_get_instance_private_offset +#define g_type_class_get_private _frida_g_type_class_get_private +#define g_type_class_peek _frida_g_type_class_peek +#define g_type_class_peek_parent _frida_g_type_class_peek_parent +#define g_type_class_peek_static _frida_g_type_class_peek_static +#define g_type_class_ref _frida_g_type_class_ref +#define g_type_class_unref _frida_g_type_class_unref +#define g_type_class_unref_uncached _frida_g_type_class_unref_uncached +#define g_type_create_instance _frida_g_type_create_instance +#define g_type_default_interface_peek _frida_g_type_default_interface_peek +#define g_type_default_interface_ref _frida_g_type_default_interface_ref +#define g_type_default_interface_unref _frida_g_type_default_interface_unref +#define g_type_depth _frida_g_type_depth +#define g_type_ensure _frida_g_type_ensure +#define g_type_free_instance _frida_g_type_free_instance +#define g_type_from_name _frida_g_type_from_name +#define g_type_fundamental _frida_g_type_fundamental +#define g_type_fundamental_next _frida_g_type_fundamental_next +#define g_type_get_instance_count _frida_g_type_get_instance_count +#define g_type_get_plugin _frida_g_type_get_plugin +#define g_type_get_qdata _frida_g_type_get_qdata +#define g_type_get_type_registration_serial _frida_g_type_get_type_registration_serial +#define g_type_init _frida_g_type_init +#define g_type_init_with_debug_flags _frida_g_type_init_with_debug_flags +#define g_type_instance_get_private _frida_g_type_instance_get_private +#define g_type_interface_add_prerequisite _frida_g_type_interface_add_prerequisite +#define g_type_interface_get_plugin _frida_g_type_interface_get_plugin +#define g_type_interface_instantiatable_prerequisite _frida_g_type_interface_instantiatable_prerequisite +#define g_type_interface_peek _frida_g_type_interface_peek +#define g_type_interface_peek_parent _frida_g_type_interface_peek_parent +#define g_type_interface_prerequisites _frida_g_type_interface_prerequisites +#define g_type_interfaces _frida_g_type_interfaces +#define g_type_is_a _frida_g_type_is_a +#define g_type_module_add_interface _frida_g_type_module_add_interface +#define g_type_module_get_type _frida_g_type_module_get_type +#define g_type_module_register_enum _frida_g_type_module_register_enum +#define g_type_module_register_flags _frida_g_type_module_register_flags +#define g_type_module_register_type _frida_g_type_module_register_type +#define g_type_module_set_name _frida_g_type_module_set_name +#define g_type_module_unuse _frida_g_type_module_unuse +#define g_type_module_use _frida_g_type_module_use +#define g_type_name _frida_g_type_name +#define g_type_name_from_class _frida_g_type_name_from_class +#define g_type_name_from_instance _frida_g_type_name_from_instance +#define g_type_next_base _frida_g_type_next_base +#define g_type_parent _frida_g_type_parent +#define g_type_plugin_complete_interface_info _frida_g_type_plugin_complete_interface_info +#define g_type_plugin_complete_type_info _frida_g_type_plugin_complete_type_info +#define g_type_plugin_get_type _frida_g_type_plugin_get_type +#define g_type_plugin_unuse _frida_g_type_plugin_unuse +#define g_type_plugin_use _frida_g_type_plugin_use +#define g_type_qname _frida_g_type_qname +#define g_type_query _frida_g_type_query +#define g_type_register_dynamic _frida_g_type_register_dynamic +#define g_type_register_fundamental _frida_g_type_register_fundamental +#define g_type_register_static _frida_g_type_register_static +#define g_type_register_static_simple _frida_g_type_register_static_simple +#define g_type_remove_class_cache_func _frida_g_type_remove_class_cache_func +#define g_type_remove_interface_check _frida_g_type_remove_interface_check +#define g_type_set_qdata _frida_g_type_set_qdata +#define g_type_test_flags _frida_g_type_test_flags +#define g_type_value_table_peek _frida_g_type_value_table_peek +#define g_ucs4_to_utf16 _frida_g_ucs4_to_utf16 +#define g_ucs4_to_utf8 _frida_g_ucs4_to_utf8 +#define g_unichar_break_type _frida_g_unichar_break_type +#define g_unichar_combining_class _frida_g_unichar_combining_class +#define g_unichar_compose _frida_g_unichar_compose +#define g_unichar_decompose _frida_g_unichar_decompose +#define g_unichar_digit_value _frida_g_unichar_digit_value +#define g_unichar_fully_decompose _frida_g_unichar_fully_decompose +#define g_unichar_get_mirror_char _frida_g_unichar_get_mirror_char +#define g_unichar_get_script _frida_g_unichar_get_script +#define g_unichar_isalnum _frida_g_unichar_isalnum +#define g_unichar_isalpha _frida_g_unichar_isalpha +#define g_unichar_iscntrl _frida_g_unichar_iscntrl +#define g_unichar_isdefined _frida_g_unichar_isdefined +#define g_unichar_isdigit _frida_g_unichar_isdigit +#define g_unichar_isgraph _frida_g_unichar_isgraph +#define g_unichar_islower _frida_g_unichar_islower +#define g_unichar_ismark _frida_g_unichar_ismark +#define g_unichar_isprint _frida_g_unichar_isprint +#define g_unichar_ispunct _frida_g_unichar_ispunct +#define g_unichar_isspace _frida_g_unichar_isspace +#define g_unichar_istitle _frida_g_unichar_istitle +#define g_unichar_isupper _frida_g_unichar_isupper +#define g_unichar_iswide _frida_g_unichar_iswide +#define g_unichar_iswide_cjk _frida_g_unichar_iswide_cjk +#define g_unichar_isxdigit _frida_g_unichar_isxdigit +#define g_unichar_iszerowidth _frida_g_unichar_iszerowidth +#define g_unichar_to_utf8 _frida_g_unichar_to_utf8 +#define g_unichar_tolower _frida_g_unichar_tolower +#define g_unichar_totitle _frida_g_unichar_totitle +#define g_unichar_toupper _frida_g_unichar_toupper +#define g_unichar_type _frida_g_unichar_type +#define g_unichar_validate _frida_g_unichar_validate +#define g_unichar_xdigit_value _frida_g_unichar_xdigit_value +#define g_unicode_break_type_get_type _frida_g_unicode_break_type_get_type +#define g_unicode_canonical_decomposition _frida_g_unicode_canonical_decomposition +#define g_unicode_canonical_ordering _frida_g_unicode_canonical_ordering +#define g_unicode_script_from_iso15924 _frida_g_unicode_script_from_iso15924 +#define g_unicode_script_get_type _frida_g_unicode_script_get_type +#define g_unicode_script_to_iso15924 _frida_g_unicode_script_to_iso15924 +#define g_unicode_type_get_type _frida_g_unicode_type_get_type +#define g_unix_connection_get_type _frida_g_unix_connection_get_type +#define g_unix_connection_receive_credentials _frida_g_unix_connection_receive_credentials +#define g_unix_connection_receive_credentials_async _frida_g_unix_connection_receive_credentials_async +#define g_unix_connection_receive_credentials_finish _frida_g_unix_connection_receive_credentials_finish +#define g_unix_connection_receive_fd _frida_g_unix_connection_receive_fd +#define g_unix_connection_send_credentials _frida_g_unix_connection_send_credentials +#define g_unix_connection_send_credentials_async _frida_g_unix_connection_send_credentials_async +#define g_unix_connection_send_credentials_finish _frida_g_unix_connection_send_credentials_finish +#define g_unix_connection_send_fd _frida_g_unix_connection_send_fd +#define g_unix_credentials_message_get_credentials _frida_g_unix_credentials_message_get_credentials +#define g_unix_credentials_message_get_type _frida_g_unix_credentials_message_get_type +#define g_unix_credentials_message_is_supported _frida_g_unix_credentials_message_is_supported +#define g_unix_credentials_message_new _frida_g_unix_credentials_message_new +#define g_unix_credentials_message_new_with_credentials _frida_g_unix_credentials_message_new_with_credentials +#define g_unix_error_quark _frida_g_unix_error_quark +#define g_unix_fd_add _frida_g_unix_fd_add +#define g_unix_fd_add_full _frida_g_unix_fd_add_full +#define g_unix_fd_list_append _frida_g_unix_fd_list_append +#define g_unix_fd_list_get _frida_g_unix_fd_list_get +#define g_unix_fd_list_get_length _frida_g_unix_fd_list_get_length +#define g_unix_fd_list_get_type _frida_g_unix_fd_list_get_type +#define g_unix_fd_list_new _frida_g_unix_fd_list_new +#define g_unix_fd_list_new_from_array _frida_g_unix_fd_list_new_from_array +#define g_unix_fd_list_peek_fds _frida_g_unix_fd_list_peek_fds +#define g_unix_fd_list_steal_fds _frida_g_unix_fd_list_steal_fds +#define g_unix_fd_message_append_fd _frida_g_unix_fd_message_append_fd +#define g_unix_fd_message_get_fd_list _frida_g_unix_fd_message_get_fd_list +#define g_unix_fd_message_get_type _frida_g_unix_fd_message_get_type +#define g_unix_fd_message_new _frida_g_unix_fd_message_new +#define g_unix_fd_message_new_with_fd_list _frida_g_unix_fd_message_new_with_fd_list +#define g_unix_fd_message_steal_fds _frida_g_unix_fd_message_steal_fds +#define g_unix_fd_source_funcs _frida_g_unix_fd_source_funcs +#define g_unix_fd_source_new _frida_g_unix_fd_source_new +#define g_unix_get_passwd_entry _frida_g_unix_get_passwd_entry +#define g_unix_input_stream_get_close_fd _frida_g_unix_input_stream_get_close_fd +#define g_unix_input_stream_get_fd _frida_g_unix_input_stream_get_fd +#define g_unix_input_stream_get_type _frida_g_unix_input_stream_get_type +#define g_unix_input_stream_new _frida_g_unix_input_stream_new +#define g_unix_input_stream_set_close_fd _frida_g_unix_input_stream_set_close_fd +#define g_unix_is_mount_path_system_internal _frida_g_unix_is_mount_path_system_internal +#define g_unix_is_system_device_path _frida_g_unix_is_system_device_path +#define g_unix_is_system_fs_type _frida_g_unix_is_system_fs_type +#define g_unix_mount_at _frida_g_unix_mount_at +#define g_unix_mount_compare _frida_g_unix_mount_compare +#define g_unix_mount_copy _frida_g_unix_mount_copy +#define g_unix_mount_entry_get_type _frida_g_unix_mount_entry_get_type +#define g_unix_mount_for _frida_g_unix_mount_for +#define g_unix_mount_free _frida_g_unix_mount_free +#define g_unix_mount_get_device_path _frida_g_unix_mount_get_device_path +#define g_unix_mount_get_fs_type _frida_g_unix_mount_get_fs_type +#define g_unix_mount_get_mount_path _frida_g_unix_mount_get_mount_path +#define g_unix_mount_get_options _frida_g_unix_mount_get_options +#define g_unix_mount_get_root_path _frida_g_unix_mount_get_root_path +#define g_unix_mount_guess_can_eject _frida_g_unix_mount_guess_can_eject +#define g_unix_mount_guess_icon _frida_g_unix_mount_guess_icon +#define g_unix_mount_guess_name _frida_g_unix_mount_guess_name +#define g_unix_mount_guess_should_display _frida_g_unix_mount_guess_should_display +#define g_unix_mount_guess_symbolic_icon _frida_g_unix_mount_guess_symbolic_icon +#define g_unix_mount_is_readonly _frida_g_unix_mount_is_readonly +#define g_unix_mount_is_system_internal _frida_g_unix_mount_is_system_internal +#define g_unix_mount_monitor_get _frida_g_unix_mount_monitor_get +#define g_unix_mount_monitor_get_type _frida_g_unix_mount_monitor_get_type +#define g_unix_mount_monitor_new _frida_g_unix_mount_monitor_new +#define g_unix_mount_monitor_set_rate_limit _frida_g_unix_mount_monitor_set_rate_limit +#define g_unix_mount_point_at _frida_g_unix_mount_point_at +#define g_unix_mount_point_compare _frida_g_unix_mount_point_compare +#define g_unix_mount_point_copy _frida_g_unix_mount_point_copy +#define g_unix_mount_point_free _frida_g_unix_mount_point_free +#define g_unix_mount_point_get_device_path _frida_g_unix_mount_point_get_device_path +#define g_unix_mount_point_get_fs_type _frida_g_unix_mount_point_get_fs_type +#define g_unix_mount_point_get_mount_path _frida_g_unix_mount_point_get_mount_path +#define g_unix_mount_point_get_options _frida_g_unix_mount_point_get_options +#define g_unix_mount_point_get_type _frida_g_unix_mount_point_get_type +#define g_unix_mount_point_guess_can_eject _frida_g_unix_mount_point_guess_can_eject +#define g_unix_mount_point_guess_icon _frida_g_unix_mount_point_guess_icon +#define g_unix_mount_point_guess_name _frida_g_unix_mount_point_guess_name +#define g_unix_mount_point_guess_symbolic_icon _frida_g_unix_mount_point_guess_symbolic_icon +#define g_unix_mount_point_is_loopback _frida_g_unix_mount_point_is_loopback +#define g_unix_mount_point_is_readonly _frida_g_unix_mount_point_is_readonly +#define g_unix_mount_point_is_user_mountable _frida_g_unix_mount_point_is_user_mountable +#define g_unix_mount_points_changed_since _frida_g_unix_mount_points_changed_since +#define g_unix_mount_points_get _frida_g_unix_mount_points_get +#define g_unix_mounts_changed_since _frida_g_unix_mounts_changed_since +#define g_unix_mounts_get _frida_g_unix_mounts_get +#define g_unix_open_pipe _frida_g_unix_open_pipe +#define g_unix_output_stream_get_close_fd _frida_g_unix_output_stream_get_close_fd +#define g_unix_output_stream_get_fd _frida_g_unix_output_stream_get_fd +#define g_unix_output_stream_get_type _frida_g_unix_output_stream_get_type +#define g_unix_output_stream_new _frida_g_unix_output_stream_new +#define g_unix_output_stream_set_close_fd _frida_g_unix_output_stream_set_close_fd +#define g_unix_set_fd_nonblocking _frida_g_unix_set_fd_nonblocking +#define g_unix_signal_add _frida_g_unix_signal_add +#define g_unix_signal_add_full _frida_g_unix_signal_add_full +#define g_unix_signal_funcs _frida_g_unix_signal_funcs +#define g_unix_signal_source_new _frida_g_unix_signal_source_new +#define g_unix_socket_address_abstract_names_supported _frida_g_unix_socket_address_abstract_names_supported +#define g_unix_socket_address_get_address_type _frida_g_unix_socket_address_get_address_type +#define g_unix_socket_address_get_is_abstract _frida_g_unix_socket_address_get_is_abstract +#define g_unix_socket_address_get_path _frida_g_unix_socket_address_get_path +#define g_unix_socket_address_get_path_len _frida_g_unix_socket_address_get_path_len +#define g_unix_socket_address_get_type _frida_g_unix_socket_address_get_type +#define g_unix_socket_address_new _frida_g_unix_socket_address_new +#define g_unix_socket_address_new_abstract _frida_g_unix_socket_address_new_abstract +#define g_unix_socket_address_new_with_type _frida_g_unix_socket_address_new_with_type +#define g_unix_socket_address_type_get_type _frida_g_unix_socket_address_type_get_type +#define g_unlink _frida_g_unlink +#define g_unsetenv _frida_g_unsetenv +#define g_uri_build _frida_g_uri_build +#define g_uri_build_with_user _frida_g_uri_build_with_user +#define g_uri_error_quark _frida_g_uri_error_quark +#define g_uri_escape_bytes _frida_g_uri_escape_bytes +#define g_uri_escape_string _frida_g_uri_escape_string +#define g_uri_get_auth_params _frida_g_uri_get_auth_params +#define g_uri_get_flags _frida_g_uri_get_flags +#define g_uri_get_fragment _frida_g_uri_get_fragment +#define g_uri_get_host _frida_g_uri_get_host +#define g_uri_get_password _frida_g_uri_get_password +#define g_uri_get_path _frida_g_uri_get_path +#define g_uri_get_port _frida_g_uri_get_port +#define g_uri_get_query _frida_g_uri_get_query +#define g_uri_get_scheme _frida_g_uri_get_scheme +#define g_uri_get_type _frida_g_uri_get_type +#define g_uri_get_user _frida_g_uri_get_user +#define g_uri_get_userinfo _frida_g_uri_get_userinfo +#define g_uri_is_valid _frida_g_uri_is_valid +#define g_uri_join _frida_g_uri_join +#define g_uri_join_with_user _frida_g_uri_join_with_user +#define g_uri_list_extract_uris _frida_g_uri_list_extract_uris +#define g_uri_params_iter_init _frida_g_uri_params_iter_init +#define g_uri_params_iter_next _frida_g_uri_params_iter_next +#define g_uri_parse _frida_g_uri_parse +#define g_uri_parse_params _frida_g_uri_parse_params +#define g_uri_parse_relative _frida_g_uri_parse_relative +#define g_uri_parse_scheme _frida_g_uri_parse_scheme +#define g_uri_peek_scheme _frida_g_uri_peek_scheme +#define g_uri_ref _frida_g_uri_ref +#define g_uri_resolve_relative _frida_g_uri_resolve_relative +#define g_uri_split _frida_g_uri_split +#define g_uri_split_network _frida_g_uri_split_network +#define g_uri_split_with_user _frida_g_uri_split_with_user +#define g_uri_to_string _frida_g_uri_to_string +#define g_uri_to_string_partial _frida_g_uri_to_string_partial +#define g_uri_unescape_bytes _frida_g_uri_unescape_bytes +#define g_uri_unescape_segment _frida_g_uri_unescape_segment +#define g_uri_unescape_string _frida_g_uri_unescape_string +#define g_uri_unref _frida_g_uri_unref +#define g_usleep _frida_g_usleep +#define g_utf16_to_ucs4 _frida_g_utf16_to_ucs4 +#define g_utf16_to_utf8 _frida_g_utf16_to_utf8 +#define g_utf8_casefold _frida_g_utf8_casefold +#define g_utf8_collate _frida_g_utf8_collate +#define g_utf8_collate_key _frida_g_utf8_collate_key +#define g_utf8_collate_key_for_filename _frida_g_utf8_collate_key_for_filename +#define g_utf8_find_next_char _frida_g_utf8_find_next_char +#define g_utf8_find_prev_char _frida_g_utf8_find_prev_char +#define g_utf8_get_char _frida_g_utf8_get_char +#define g_utf8_get_char_validated _frida_g_utf8_get_char_validated +#define g_utf8_make_valid _frida_g_utf8_make_valid +#define g_utf8_normalize _frida_g_utf8_normalize +#define g_utf8_offset_to_pointer _frida_g_utf8_offset_to_pointer +#define g_utf8_pointer_to_offset _frida_g_utf8_pointer_to_offset +#define g_utf8_prev_char _frida_g_utf8_prev_char +#define g_utf8_skip _frida_g_utf8_skip +#define g_utf8_strchr _frida_g_utf8_strchr +#define g_utf8_strdown _frida_g_utf8_strdown +#define g_utf8_strlen _frida_g_utf8_strlen +#define g_utf8_strncpy _frida_g_utf8_strncpy +#define g_utf8_strrchr _frida_g_utf8_strrchr +#define g_utf8_strreverse _frida_g_utf8_strreverse +#define g_utf8_strup _frida_g_utf8_strup +#define g_utf8_substring _frida_g_utf8_substring +#define g_utf8_to_ucs4 _frida_g_utf8_to_ucs4 +#define g_utf8_to_ucs4_fast _frida_g_utf8_to_ucs4_fast +#define g_utf8_to_utf16 _frida_g_utf8_to_utf16 +#define g_utf8_validate _frida_g_utf8_validate +#define g_utf8_validate_len _frida_g_utf8_validate_len +#define g_utime _frida_g_utime +#define g_uuid_string_is_valid _frida_g_uuid_string_is_valid +#define g_uuid_string_random _frida_g_uuid_string_random +#define g_value_array_append _frida_g_value_array_append +#define g_value_array_copy _frida_g_value_array_copy +#define g_value_array_free _frida_g_value_array_free +#define g_value_array_get_nth _frida_g_value_array_get_nth +#define g_value_array_get_type _frida_g_value_array_get_type +#define g_value_array_insert _frida_g_value_array_insert +#define g_value_array_new _frida_g_value_array_new +#define g_value_array_prepend _frida_g_value_array_prepend +#define g_value_array_remove _frida_g_value_array_remove +#define g_value_array_sort _frida_g_value_array_sort +#define g_value_array_sort_with_data _frida_g_value_array_sort_with_data +#define g_value_copy _frida_g_value_copy +#define g_value_dup_boxed _frida_g_value_dup_boxed +#define g_value_dup_object _frida_g_value_dup_object +#define g_value_dup_param _frida_g_value_dup_param +#define g_value_dup_string _frida_g_value_dup_string +#define g_value_dup_variant _frida_g_value_dup_variant +#define g_value_fits_pointer _frida_g_value_fits_pointer +#define g_value_get_boolean _frida_g_value_get_boolean +#define g_value_get_boxed _frida_g_value_get_boxed +#define g_value_get_char _frida_g_value_get_char +#define g_value_get_double _frida_g_value_get_double +#define g_value_get_enum _frida_g_value_get_enum +#define g_value_get_flags _frida_g_value_get_flags +#define g_value_get_float _frida_g_value_get_float +#define g_value_get_gtype _frida_g_value_get_gtype +#define g_value_get_int _frida_g_value_get_int +#define g_value_get_int64 _frida_g_value_get_int64 +#define g_value_get_long _frida_g_value_get_long +#define g_value_get_object _frida_g_value_get_object +#define g_value_get_param _frida_g_value_get_param +#define g_value_get_pointer _frida_g_value_get_pointer +#define g_value_get_schar _frida_g_value_get_schar +#define g_value_get_string _frida_g_value_get_string +#define g_value_get_type _frida_g_value_get_type +#define g_value_get_uchar _frida_g_value_get_uchar +#define g_value_get_uint _frida_g_value_get_uint +#define g_value_get_uint64 _frida_g_value_get_uint64 +#define g_value_get_ulong _frida_g_value_get_ulong +#define g_value_get_variant _frida_g_value_get_variant +#define g_value_init _frida_g_value_init +#define g_value_init_from_instance _frida_g_value_init_from_instance +#define g_value_peek_pointer _frida_g_value_peek_pointer +#define g_value_register_transform_func _frida_g_value_register_transform_func +#define g_value_reset _frida_g_value_reset +#define g_value_set_boolean _frida_g_value_set_boolean +#define g_value_set_boxed _frida_g_value_set_boxed +#define g_value_set_boxed_take_ownership _frida_g_value_set_boxed_take_ownership +#define g_value_set_char _frida_g_value_set_char +#define g_value_set_double _frida_g_value_set_double +#define g_value_set_enum _frida_g_value_set_enum +#define g_value_set_flags _frida_g_value_set_flags +#define g_value_set_float _frida_g_value_set_float +#define g_value_set_gtype _frida_g_value_set_gtype +#define g_value_set_instance _frida_g_value_set_instance +#define g_value_set_int _frida_g_value_set_int +#define g_value_set_int64 _frida_g_value_set_int64 +#define g_value_set_interned_string _frida_g_value_set_interned_string +#define g_value_set_long _frida_g_value_set_long +#define g_value_set_object _frida_g_value_set_object +#define g_value_set_object_take_ownership _frida_g_value_set_object_take_ownership +#define g_value_set_param _frida_g_value_set_param +#define g_value_set_param_take_ownership _frida_g_value_set_param_take_ownership +#define g_value_set_pointer _frida_g_value_set_pointer +#define g_value_set_schar _frida_g_value_set_schar +#define g_value_set_static_boxed _frida_g_value_set_static_boxed +#define g_value_set_static_string _frida_g_value_set_static_string +#define g_value_set_string _frida_g_value_set_string +#define g_value_set_string_take_ownership _frida_g_value_set_string_take_ownership +#define g_value_set_uchar _frida_g_value_set_uchar +#define g_value_set_uint _frida_g_value_set_uint +#define g_value_set_uint64 _frida_g_value_set_uint64 +#define g_value_set_ulong _frida_g_value_set_ulong +#define g_value_set_variant _frida_g_value_set_variant +#define g_value_take_boxed _frida_g_value_take_boxed +#define g_value_take_object _frida_g_value_take_object +#define g_value_take_param _frida_g_value_take_param +#define g_value_take_string _frida_g_value_take_string +#define g_value_take_variant _frida_g_value_take_variant +#define g_value_transform _frida_g_value_transform +#define g_value_type_compatible _frida_g_value_type_compatible +#define g_value_type_transformable _frida_g_value_type_transformable +#define g_value_unset _frida_g_value_unset +#define g_variant_builder_add _frida_g_variant_builder_add +#define g_variant_builder_add_parsed _frida_g_variant_builder_add_parsed +#define g_variant_builder_add_value _frida_g_variant_builder_add_value +#define g_variant_builder_clear _frida_g_variant_builder_clear +#define g_variant_builder_close _frida_g_variant_builder_close +#define g_variant_builder_end _frida_g_variant_builder_end +#define g_variant_builder_get_type _frida_g_variant_builder_get_type +#define g_variant_builder_init _frida_g_variant_builder_init +#define g_variant_builder_new _frida_g_variant_builder_new +#define g_variant_builder_open _frida_g_variant_builder_open +#define g_variant_builder_ref _frida_g_variant_builder_ref +#define g_variant_builder_unref _frida_g_variant_builder_unref +#define g_variant_byteswap _frida_g_variant_byteswap +#define g_variant_check_format_string _frida_g_variant_check_format_string +#define g_variant_classify _frida_g_variant_classify +#define g_variant_compare _frida_g_variant_compare +#define g_variant_dict_clear _frida_g_variant_dict_clear +#define g_variant_dict_contains _frida_g_variant_dict_contains +#define g_variant_dict_end _frida_g_variant_dict_end +#define g_variant_dict_get_type _frida_g_variant_dict_get_type +#define g_variant_dict_init _frida_g_variant_dict_init +#define g_variant_dict_insert _frida_g_variant_dict_insert +#define g_variant_dict_insert_value _frida_g_variant_dict_insert_value +#define g_variant_dict_lookup _frida_g_variant_dict_lookup +#define g_variant_dict_lookup_value _frida_g_variant_dict_lookup_value +#define g_variant_dict_new _frida_g_variant_dict_new +#define g_variant_dict_ref _frida_g_variant_dict_ref +#define g_variant_dict_remove _frida_g_variant_dict_remove +#define g_variant_dict_unref _frida_g_variant_dict_unref +#define g_variant_dup_bytestring _frida_g_variant_dup_bytestring +#define g_variant_dup_bytestring_array _frida_g_variant_dup_bytestring_array +#define g_variant_dup_objv _frida_g_variant_dup_objv +#define g_variant_dup_string _frida_g_variant_dup_string +#define g_variant_dup_strv _frida_g_variant_dup_strv +#define g_variant_equal _frida_g_variant_equal +#define g_variant_format_string_scan _frida_g_variant_format_string_scan +#define g_variant_format_string_scan_type _frida_g_variant_format_string_scan_type +#define g_variant_get _frida_g_variant_get +#define g_variant_get_boolean _frida_g_variant_get_boolean +#define g_variant_get_byte _frida_g_variant_get_byte +#define g_variant_get_bytestring _frida_g_variant_get_bytestring +#define g_variant_get_bytestring_array _frida_g_variant_get_bytestring_array +#define g_variant_get_child _frida_g_variant_get_child +#define g_variant_get_child_value _frida_g_variant_get_child_value +#define g_variant_get_data _frida_g_variant_get_data +#define g_variant_get_data_as_bytes _frida_g_variant_get_data_as_bytes +#define g_variant_get_depth _frida_g_variant_get_depth +#define g_variant_get_double _frida_g_variant_get_double +#define g_variant_get_fixed_array _frida_g_variant_get_fixed_array +#define g_variant_get_gtype _frida_g_variant_get_gtype +#define g_variant_get_handle _frida_g_variant_get_handle +#define g_variant_get_int16 _frida_g_variant_get_int16 +#define g_variant_get_int32 _frida_g_variant_get_int32 +#define g_variant_get_int64 _frida_g_variant_get_int64 +#define g_variant_get_maybe _frida_g_variant_get_maybe +#define g_variant_get_normal_form _frida_g_variant_get_normal_form +#define g_variant_get_objv _frida_g_variant_get_objv +#define g_variant_get_size _frida_g_variant_get_size +#define g_variant_get_string _frida_g_variant_get_string +#define g_variant_get_strv _frida_g_variant_get_strv +#define g_variant_get_type _frida_g_variant_get_type +#define g_variant_get_type_info _frida_g_variant_get_type_info +#define g_variant_get_type_string _frida_g_variant_get_type_string +#define g_variant_get_uint16 _frida_g_variant_get_uint16 +#define g_variant_get_uint32 _frida_g_variant_get_uint32 +#define g_variant_get_uint64 _frida_g_variant_get_uint64 +#define g_variant_get_va _frida_g_variant_get_va +#define g_variant_get_variant _frida_g_variant_get_variant +#define g_variant_hash _frida_g_variant_hash +#define g_variant_is_container _frida_g_variant_is_container +#define g_variant_is_floating _frida_g_variant_is_floating +#define g_variant_is_normal_form _frida_g_variant_is_normal_form +#define g_variant_is_object_path _frida_g_variant_is_object_path +#define g_variant_is_of_type _frida_g_variant_is_of_type +#define g_variant_is_signature _frida_g_variant_is_signature +#define g_variant_is_trusted _frida_g_variant_is_trusted +#define g_variant_iter_copy _frida_g_variant_iter_copy +#define g_variant_iter_free _frida_g_variant_iter_free +#define g_variant_iter_init _frida_g_variant_iter_init +#define g_variant_iter_loop _frida_g_variant_iter_loop +#define g_variant_iter_n_children _frida_g_variant_iter_n_children +#define g_variant_iter_new _frida_g_variant_iter_new +#define g_variant_iter_next _frida_g_variant_iter_next +#define g_variant_iter_next_value _frida_g_variant_iter_next_value +#define g_variant_lookup _frida_g_variant_lookup +#define g_variant_lookup_value _frida_g_variant_lookup_value +#define g_variant_n_children _frida_g_variant_n_children +#define g_variant_new _frida_g_variant_new +#define g_variant_new_array _frida_g_variant_new_array +#define g_variant_new_boolean _frida_g_variant_new_boolean +#define g_variant_new_byte _frida_g_variant_new_byte +#define g_variant_new_bytestring _frida_g_variant_new_bytestring +#define g_variant_new_bytestring_array _frida_g_variant_new_bytestring_array +#define g_variant_new_dict_entry _frida_g_variant_new_dict_entry +#define g_variant_new_double _frida_g_variant_new_double +#define g_variant_new_fixed_array _frida_g_variant_new_fixed_array +#define g_variant_new_from_bytes _frida_g_variant_new_from_bytes +#define g_variant_new_from_children _frida_g_variant_new_from_children +#define g_variant_new_from_data _frida_g_variant_new_from_data +#define g_variant_new_handle _frida_g_variant_new_handle +#define g_variant_new_int16 _frida_g_variant_new_int16 +#define g_variant_new_int32 _frida_g_variant_new_int32 +#define g_variant_new_int64 _frida_g_variant_new_int64 +#define g_variant_new_maybe _frida_g_variant_new_maybe +#define g_variant_new_object_path _frida_g_variant_new_object_path +#define g_variant_new_objv _frida_g_variant_new_objv +#define g_variant_new_parsed _frida_g_variant_new_parsed +#define g_variant_new_parsed_va _frida_g_variant_new_parsed_va +#define g_variant_new_printf _frida_g_variant_new_printf +#define g_variant_new_signature _frida_g_variant_new_signature +#define g_variant_new_string _frida_g_variant_new_string +#define g_variant_new_strv _frida_g_variant_new_strv +#define g_variant_new_take_string _frida_g_variant_new_take_string +#define g_variant_new_tuple _frida_g_variant_new_tuple +#define g_variant_new_uint16 _frida_g_variant_new_uint16 +#define g_variant_new_uint32 _frida_g_variant_new_uint32 +#define g_variant_new_uint64 _frida_g_variant_new_uint64 +#define g_variant_new_va _frida_g_variant_new_va +#define g_variant_new_variant _frida_g_variant_new_variant +#define g_variant_parse _frida_g_variant_parse +#define g_variant_parse_error_print_context _frida_g_variant_parse_error_print_context +#define g_variant_parse_error_quark _frida_g_variant_parse_error_quark +#define g_variant_parser_get_error_quark _frida_g_variant_parser_get_error_quark +#define g_variant_print _frida_g_variant_print +#define g_variant_print_string _frida_g_variant_print_string +#define g_variant_ref _frida_g_variant_ref +#define g_variant_ref_sink _frida_g_variant_ref_sink +#define g_variant_serialised_byteswap _frida_g_variant_serialised_byteswap +#define g_variant_serialised_check _frida_g_variant_serialised_check +#define g_variant_serialised_get_child _frida_g_variant_serialised_get_child +#define g_variant_serialised_is_normal _frida_g_variant_serialised_is_normal +#define g_variant_serialised_n_children _frida_g_variant_serialised_n_children +#define g_variant_serialiser_is_object_path _frida_g_variant_serialiser_is_object_path +#define g_variant_serialiser_is_signature _frida_g_variant_serialiser_is_signature +#define g_variant_serialiser_is_string _frida_g_variant_serialiser_is_string +#define g_variant_serialiser_needed_size _frida_g_variant_serialiser_needed_size +#define g_variant_serialiser_serialise _frida_g_variant_serialiser_serialise +#define g_variant_store _frida_g_variant_store +#define g_variant_take_ref _frida_g_variant_take_ref +#define g_variant_type_checked_ _frida_g_variant_type_checked_ +#define g_variant_type_copy _frida_g_variant_type_copy +#define g_variant_type_dup_string _frida_g_variant_type_dup_string +#define g_variant_type_element _frida_g_variant_type_element +#define g_variant_type_equal _frida_g_variant_type_equal +#define g_variant_type_first _frida_g_variant_type_first +#define g_variant_type_free _frida_g_variant_type_free +#define g_variant_type_get_gtype _frida_g_variant_type_get_gtype +#define g_variant_type_get_string_length _frida_g_variant_type_get_string_length +#define g_variant_type_hash _frida_g_variant_type_hash +#define g_variant_type_info_assert_no_infos _frida_g_variant_type_info_assert_no_infos +#define g_variant_type_info_element _frida_g_variant_type_info_element +#define g_variant_type_info_get _frida_g_variant_type_info_get +#define g_variant_type_info_get_type_string _frida_g_variant_type_info_get_type_string +#define g_variant_type_info_member_info _frida_g_variant_type_info_member_info +#define g_variant_type_info_n_members _frida_g_variant_type_info_n_members +#define g_variant_type_info_query _frida_g_variant_type_info_query +#define g_variant_type_info_query_depth _frida_g_variant_type_info_query_depth +#define g_variant_type_info_query_element _frida_g_variant_type_info_query_element +#define g_variant_type_info_ref _frida_g_variant_type_info_ref +#define g_variant_type_info_unref _frida_g_variant_type_info_unref +#define g_variant_type_is_array _frida_g_variant_type_is_array +#define g_variant_type_is_basic _frida_g_variant_type_is_basic +#define g_variant_type_is_container _frida_g_variant_type_is_container +#define g_variant_type_is_definite _frida_g_variant_type_is_definite +#define g_variant_type_is_dict_entry _frida_g_variant_type_is_dict_entry +#define g_variant_type_is_maybe _frida_g_variant_type_is_maybe +#define g_variant_type_is_subtype_of _frida_g_variant_type_is_subtype_of +#define g_variant_type_is_tuple _frida_g_variant_type_is_tuple +#define g_variant_type_is_variant _frida_g_variant_type_is_variant +#define g_variant_type_key _frida_g_variant_type_key +#define g_variant_type_n_items _frida_g_variant_type_n_items +#define g_variant_type_new _frida_g_variant_type_new +#define g_variant_type_new_array _frida_g_variant_type_new_array +#define g_variant_type_new_dict_entry _frida_g_variant_type_new_dict_entry +#define g_variant_type_new_maybe _frida_g_variant_type_new_maybe +#define g_variant_type_new_tuple _frida_g_variant_type_new_tuple +#define g_variant_type_next _frida_g_variant_type_next +#define g_variant_type_peek_string _frida_g_variant_type_peek_string +#define g_variant_type_string_get_depth_ _frida_g_variant_type_string_get_depth_ +#define g_variant_type_string_is_valid _frida_g_variant_type_string_is_valid +#define g_variant_type_string_scan _frida_g_variant_type_string_scan +#define g_variant_type_value _frida_g_variant_type_value +#define g_variant_unref _frida_g_variant_unref +#define g_vasprintf _frida_g_vasprintf +#define g_vfprintf _frida_g_vfprintf +#define g_vfs_get_default _frida_g_vfs_get_default +#define g_vfs_get_file_for_path _frida_g_vfs_get_file_for_path +#define g_vfs_get_file_for_uri _frida_g_vfs_get_file_for_uri +#define g_vfs_get_local _frida_g_vfs_get_local +#define g_vfs_get_supported_uri_schemes _frida_g_vfs_get_supported_uri_schemes +#define g_vfs_get_type _frida_g_vfs_get_type +#define g_vfs_is_active _frida_g_vfs_is_active +#define g_vfs_parse_name _frida_g_vfs_parse_name +#define g_vfs_register_uri_scheme _frida_g_vfs_register_uri_scheme +#define g_vfs_unregister_uri_scheme _frida_g_vfs_unregister_uri_scheme +#define g_volume_can_eject _frida_g_volume_can_eject +#define g_volume_can_mount _frida_g_volume_can_mount +#define g_volume_eject _frida_g_volume_eject +#define g_volume_eject_finish _frida_g_volume_eject_finish +#define g_volume_eject_with_operation _frida_g_volume_eject_with_operation +#define g_volume_eject_with_operation_finish _frida_g_volume_eject_with_operation_finish +#define g_volume_enumerate_identifiers _frida_g_volume_enumerate_identifiers +#define g_volume_get_activation_root _frida_g_volume_get_activation_root +#define g_volume_get_drive _frida_g_volume_get_drive +#define g_volume_get_icon _frida_g_volume_get_icon +#define g_volume_get_identifier _frida_g_volume_get_identifier +#define g_volume_get_mount _frida_g_volume_get_mount +#define g_volume_get_name _frida_g_volume_get_name +#define g_volume_get_sort_key _frida_g_volume_get_sort_key +#define g_volume_get_symbolic_icon _frida_g_volume_get_symbolic_icon +#define g_volume_get_type _frida_g_volume_get_type +#define g_volume_get_uuid _frida_g_volume_get_uuid +#define g_volume_monitor_adopt_orphan_mount _frida_g_volume_monitor_adopt_orphan_mount +#define g_volume_monitor_get _frida_g_volume_monitor_get +#define g_volume_monitor_get_connected_drives _frida_g_volume_monitor_get_connected_drives +#define g_volume_monitor_get_mount_for_uuid _frida_g_volume_monitor_get_mount_for_uuid +#define g_volume_monitor_get_mounts _frida_g_volume_monitor_get_mounts +#define g_volume_monitor_get_type _frida_g_volume_monitor_get_type +#define g_volume_monitor_get_volume_for_uuid _frida_g_volume_monitor_get_volume_for_uuid +#define g_volume_monitor_get_volumes _frida_g_volume_monitor_get_volumes +#define g_volume_mount _frida_g_volume_mount +#define g_volume_mount_finish _frida_g_volume_mount_finish +#define g_volume_should_automount _frida_g_volume_should_automount +#define g_vprintf _frida_g_vprintf +#define g_vsnprintf _frida_g_vsnprintf +#define g_vsprintf _frida_g_vsprintf +#define g_wakeup_acknowledge _frida_g_wakeup_acknowledge +#define g_wakeup_free _frida_g_wakeup_free +#define g_wakeup_get_pollfd _frida_g_wakeup_get_pollfd +#define g_wakeup_new _frida_g_wakeup_new +#define g_wakeup_signal _frida_g_wakeup_signal +#define g_warn_message _frida_g_warn_message +#define g_weak_ref_clear _frida_g_weak_ref_clear +#define g_weak_ref_get _frida_g_weak_ref_get +#define g_weak_ref_init _frida_g_weak_ref_init +#define g_weak_ref_set _frida_g_weak_ref_set +#define g_zlib_compressor_format_get_type _frida_g_zlib_compressor_format_get_type +#define g_zlib_compressor_get_file_info _frida_g_zlib_compressor_get_file_info +#define g_zlib_compressor_get_type _frida_g_zlib_compressor_get_type +#define g_zlib_compressor_new _frida_g_zlib_compressor_new +#define g_zlib_compressor_set_file_info _frida_g_zlib_compressor_set_file_info +#define g_zlib_decompressor_get_file_info _frida_g_zlib_decompressor_get_file_info +#define g_zlib_decompressor_get_type _frida_g_zlib_decompressor_get_type +#define g_zlib_decompressor_new _frida_g_zlib_decompressor_new +#define gio_deinit _frida_gio_deinit +#define gio_init _frida_gio_init +#define gio_prepare_to_fork _frida_gio_prepare_to_fork +#define gio_recover_from_fork_in_child _frida_gio_recover_from_fork_in_child +#define gio_recover_from_fork_in_parent _frida_gio_recover_from_fork_in_parent +#define gio_shutdown _frida_gio_shutdown +#define glib__private__ _frida_glib__private__ +#define glib_binary_age _frida_glib_binary_age +#define glib_check_version _frida_glib_check_version +#define glib_deinit _frida_glib_deinit +#define glib_fd_callbacks _frida_glib_fd_callbacks +#define glib_gettext _frida_glib_gettext +#define glib_has_dconf_access_in_sandbox _frida_glib_has_dconf_access_in_sandbox +#define glib_init _frida_glib_init +#define glib_interface_age _frida_glib_interface_age +#define glib_major_version _frida_glib_major_version +#define glib_mem_profiler_table _frida_glib_mem_profiler_table +#define glib_mem_table _frida_glib_mem_table +#define glib_micro_version _frida_glib_micro_version +#define glib_minor_version _frida_glib_minor_version +#define glib_network_available_in_sandbox _frida_glib_network_available_in_sandbox +#define glib_on_error_halt _frida_glib_on_error_halt +#define glib_pgettext _frida_glib_pgettext +#define glib_prepare_to_fork _frida_glib_prepare_to_fork +#define glib_recover_from_fork_in_child _frida_glib_recover_from_fork_in_child +#define glib_recover_from_fork_in_parent _frida_glib_recover_from_fork_in_parent +#define glib_should_use_portal _frida_glib_should_use_portal +#define glib_shutdown _frida_glib_shutdown +#define glib_thread_callbacks _frida_glib_thread_callbacks +#define gobject_init _frida_gobject_init + +#endif + +/* + * Copyright (C) 2008-2019 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_H__ +#define __GUM_H__ + +/* + * Copyright (C) 2008-2020 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUMDEFS_H__ +#define __GUMDEFS_H__ + + +/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ + +#ifndef __GUM_ENUM_TYPES_H__ +#define __GUM_ENUM_TYPES_H__ + +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __GLIB_GOBJECT_H__ +#define __GLIB_GOBJECT_H__ + +#define __GLIB_GOBJECT_H_INSIDE__ + +/* gbinding.h: Binding for object properties + * + * Copyright (C) 2010 Intel Corp. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * Author: Emmanuele Bassi + */ + +#ifndef __G_BINDING_H__ +#define __G_BINDING_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_LIB_H__ +#define __G_LIB_H__ + +#define __GLIB_H_INSIDE__ + +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_ALLOCA_H__ +#define __G_ALLOCA_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_TYPES_H__ +#define __G_TYPES_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* glibconfig.h + * + * This is a generated file. Please modify 'glibconfig.h.in' + */ + +#ifndef __GLIBCONFIG_H__ +#define __GLIBCONFIG_H__ + +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +/* This file must not include any other glib header file and must thus + * not refer to variables from glibconfig.h + */ + +#ifndef __G_MACROS_H__ +#define __G_MACROS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* We include stddef.h to get the system's definition of NULL + */ +#include + +#ifdef __GNUC__ +#define G_GNUC_CHECK_VERSION(major, minor) \ + ((__GNUC__ > (major)) || \ + ((__GNUC__ == (major)) && \ + (__GNUC_MINOR__ >= (minor)))) +#else +#define G_GNUC_CHECK_VERSION(major, minor) 0 +#endif + +/* Here we provide G_GNUC_EXTENSION as an alias for __extension__, + * where this is valid. This allows for warningless compilation of + * "long long" types even in the presence of '-ansi -pedantic'. + */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) +#define G_GNUC_EXTENSION __extension__ +#else +#define G_GNUC_EXTENSION +#endif + +/* Every compiler that we target supports inlining, but some of them may + * complain about it if we don't say "__inline". If we have C99, or if + * we are using C++, then we can use "inline" directly. Unfortunately + * Visual Studio does not support __STDC_VERSION__, so we need to check + * whether we are on Visual Studio 2013 or earlier to see that we need to + * say "__inline" in C mode. + * Otherwise, we say "__inline" to avoid the warning. + */ +#define G_CAN_INLINE +#ifndef __cplusplus +# ifdef _MSC_VER +# if (_MSC_VER < 1900) +# define G_INLINE_DEFINE_NEEDED +# endif +# elif !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199900) +# define G_INLINE_DEFINE_NEEDED +# endif +#endif + +#ifdef G_INLINE_DEFINE_NEEDED +# undef inline +# define inline __inline +#endif + +#undef G_INLINE_DEFINE_NEEDED + +/** + * G_INLINE_FUNC: + * + * This macro used to be used to conditionally define inline functions + * in a compatible way before this feature was supported in all + * compilers. These days, GLib requires inlining support from the + * compiler, so your GLib-using programs can safely assume that the + * "inline" keyword works properly. + * + * Never use this macro anymore. Just say "static inline". + * + * Deprecated: 2.48: Use "static inline" instead + */ + +/* For historical reasons we need to continue to support those who + * define G_IMPLEMENT_INLINES to mean "don't implement this here". + */ +#ifdef G_IMPLEMENT_INLINES +# define G_INLINE_FUNC extern GLIB_DEPRECATED_MACRO_IN_2_48_FOR(static inline) +# undef G_CAN_INLINE +#else +# define G_INLINE_FUNC static inline GLIB_DEPRECATED_MACRO_IN_2_48_FOR(static inline) +#endif /* G_IMPLEMENT_INLINES */ + +/* Provide macros to feature the GCC function attribute. + */ + +/** + * G_GNUC_PURE: + * + * Expands to the GNU C `pure` function attribute if the compiler is gcc. + * Declaring a function as `pure` enables better optimization of calls to + * the function. A `pure` function has no effects except its return value + * and the return value depends only on the parameters and/or global + * variables. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * gboolean g_type_check_value (const GValue *value) G_GNUC_PURE; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute) for more details. + */ + +/** + * G_GNUC_MALLOC: + * + * Expands to the + * [GNU C `malloc` function attribute](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-functions-that-behave-like-malloc) + * if the compiler is gcc. + * Declaring a function as `malloc` enables better optimization of the function, + * but must only be done if the allocation behaviour of the function is fully + * understood, otherwise miscompilation can result. + * + * A function can have the `malloc` attribute if it returns a pointer which is + * guaranteed to not alias with any other pointer valid when the function + * returns, and moreover no pointers to valid objects occur in any storage + * addressed by the returned pointer. + * + * In practice, this means that `G_GNUC_MALLOC` can be used with any function + * which returns unallocated or zeroed-out memory, but not with functions which + * return initialised structures containing other pointers, or with functions + * that reallocate memory. This definition changed in GLib 2.58 to match the + * stricter definition introduced around GCC 5. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-functions-that-behave-like-malloc) + * for more details. + * + * Since: 2.6 + */ + +/** + * G_GNUC_NO_INLINE: + * + * Expands to the GNU C `noinline` function attribute if the compiler is gcc. + * If the compiler is not gcc, this macro expands to nothing. + * + * Declaring a function as `noinline` prevents the function from being + * considered for inlining. + * + * The attribute may be placed before the declaration or definition, + * right before the `static` keyword. + * + * |[ + * G_GNUC_NO_INLINE + * static int + * do_not_inline_this (void) + * { + * ... + * } + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute) + * for more details. + * + * Since: 2.58 + */ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +#define G_GNUC_PURE __attribute__((__pure__)) +#define G_GNUC_MALLOC __attribute__((__malloc__)) +#define G_GNUC_NO_INLINE __attribute__((noinline)) +#else +#define G_GNUC_PURE +#define G_GNUC_MALLOC +#define G_GNUC_NO_INLINE +#endif + +/** + * G_GNUC_NULL_TERMINATED: + * + * Expands to the GNU C `sentinel` function attribute if the compiler is gcc. + * This function attribute only applies to variadic functions and instructs + * the compiler to check that the argument list is terminated with an + * explicit %NULL. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * gchar *g_strconcat (const gchar *string1, + * ...) G_GNUC_NULL_TERMINATED; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-sentinel-function-attribute) for more details. + * + * Since: 2.8 + */ +#if __GNUC__ >= 4 +#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) +#else +#define G_GNUC_NULL_TERMINATED +#endif + +/* + * We can only use __typeof__ on GCC >= 4.8, and not when compiling C++. Since + * __typeof__ is used in a few places in GLib, provide a pre-processor symbol + * to factor the check out from callers. + * + * This symbol is private. + */ +#undef glib_typeof +#if !defined(__cplusplus) && \ + ((defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \ + defined(__clang__)) +#define glib_typeof(t) __typeof__ (t) +#endif + +/* + * Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html + * These are not available on GCC, but since the pre-processor doesn't do + * operator short-circuiting, we can't use it in a statement or we'll get: + * + * error: missing binary operator before token "(" + * + * So we define it to 0 to satisfy the pre-processor. + */ + +#ifdef __has_attribute +#define g_macro__has_attribute __has_attribute +#else +#define g_macro__has_attribute(x) 0 +#endif + +#ifdef __has_feature +#define g_macro__has_feature __has_feature +#else +#define g_macro__has_feature(x) 0 +#endif + +#ifdef __has_builtin +#define g_macro__has_builtin __has_builtin +#else +#define g_macro__has_builtin(x) 0 +#endif + +/** + * G_GNUC_ALLOC_SIZE: + * @x: the index of the argument specifying the allocation size + * + * Expands to the GNU C `alloc_size` function attribute if the compiler + * is a new enough gcc. This attribute tells the compiler that the + * function returns a pointer to memory of a size that is specified + * by the @xth function parameter. + * + * Place the attribute after the function declaration, just before the + * semicolon. + * + * |[ + * gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute) for more details. + * + * Since: 2.18 + */ + +/** + * G_GNUC_ALLOC_SIZE2: + * @x: the index of the argument specifying one factor of the allocation size + * @y: the index of the argument specifying the second factor of the allocation size + * + * Expands to the GNU C `alloc_size` function attribute if the compiler is a + * new enough gcc. This attribute tells the compiler that the function returns + * a pointer to memory of a size that is specified by the product of two + * function parameters. + * + * Place the attribute after the function declaration, just before the + * semicolon. + * + * |[ + * gpointer g_malloc_n (gsize n_blocks, + * gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1, 2); + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute) for more details. + * + * Since: 2.18 + */ +#if (!defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ + (defined(__clang__) && g_macro__has_attribute(__alloc_size__)) +#define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) +#define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y))) +#else +#define G_GNUC_ALLOC_SIZE(x) +#define G_GNUC_ALLOC_SIZE2(x,y) +#endif + +/** + * G_GNUC_PRINTF: + * @format_idx: the index of the argument corresponding to the + * format string (the arguments are numbered from 1) + * @arg_idx: the index of the first of the format arguments, or 0 if + * there are no format arguments + * + * Expands to the GNU C `format` function attribute if the compiler is gcc. + * This is used for declaring functions which take a variable number of + * arguments, with the same syntax as `printf()`. It allows the compiler + * to type-check the arguments passed to the function. + * + * Place the attribute after the function declaration, just before the + * semicolon. + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) + * for more details. + * + * |[ + * gint g_snprintf (gchar *string, + * gulong n, + * gchar const *format, + * ...) G_GNUC_PRINTF (3, 4); + * ]| + */ + +/** + * G_GNUC_SCANF: + * @format_idx: the index of the argument corresponding to + * the format string (the arguments are numbered from 1) + * @arg_idx: the index of the first of the format arguments, or 0 if + * there are no format arguments + * + * Expands to the GNU C `format` function attribute if the compiler is gcc. + * This is used for declaring functions which take a variable number of + * arguments, with the same syntax as `scanf()`. It allows the compiler + * to type-check the arguments passed to the function. + * + * |[ + * int my_scanf (MyStream *stream, + * const char *format, + * ...) G_GNUC_SCANF (2, 3); + * int my_vscanf (MyStream *stream, + * const char *format, + * va_list ap) G_GNUC_SCANF (2, 0); + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) + * for details. + */ + +/** + * G_GNUC_STRFTIME: + * @format_idx: the index of the argument corresponding to + * the format string (the arguments are numbered from 1) + * + * Expands to the GNU C `strftime` format function attribute if the compiler + * is gcc. This is used for declaring functions which take a format argument + * which is passed to `strftime()` or an API implementing its formats. It allows + * the compiler check the format passed to the function. + * + * |[ + * gsize my_strftime (MyBuffer *buffer, + * const char *format, + * const struct tm *tm) G_GNUC_STRFTIME (2); + * ]| + * + * See the + * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) + * for details. + * + * Since: 2.60 + */ + +/** + * G_GNUC_FORMAT: + * @arg_idx: the index of the argument + * + * Expands to the GNU C `format_arg` function attribute if the compiler + * is gcc. This function attribute specifies that a function takes a + * format string for a `printf()`, `scanf()`, `strftime()` or `strfmon()` style + * function and modifies it, so that the result can be passed to a `printf()`, + * `scanf()`, `strftime()` or `strfmon()` style function (with the remaining + * arguments to the format function the same as they would have been + * for the unmodified string). + * + * Place the attribute after the function declaration, just before the + * semicolon. + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-nonliteral-1) for more details. + * + * |[ + * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2); + * ]| + */ + +/** + * G_GNUC_NORETURN: + * + * Expands to the GNU C `noreturn` function attribute if the compiler is gcc. + * It is used for declaring functions which never return. It enables + * optimization of the function, and avoids possible compiler warnings. + * + * Since 2.68, it is recommended that code uses %G_NORETURN instead of + * %G_GNUC_NORETURN, as that works on more platforms and compilers (in + * particular, MSVC and C++11) than %G_GNUC_NORETURN, which works with GCC and + * Clang only. %G_GNUC_NORETURN continues to work, so has not been deprecated + * yet. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * void g_abort (void) G_GNUC_NORETURN; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute) for more details. + */ + +/** + * G_GNUC_CONST: + * + * Expands to the GNU C `const` function attribute if the compiler is gcc. + * Declaring a function as `const` enables better optimization of calls to + * the function. A `const` function doesn't examine any values except its + * parameters, and has no effects except its return value. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * gchar g_ascii_tolower (gchar c) G_GNUC_CONST; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute) for more details. + * + * A function that has pointer arguments and examines the data pointed to + * must not be declared `const`. Likewise, a function that calls a non-`const` + * function usually must not be `const`. It doesn't make sense for a `const` + * function to return `void`. + */ + +/** + * G_GNUC_UNUSED: + * + * Expands to the GNU C `unused` function attribute if the compiler is gcc. + * It is used for declaring functions and arguments which may never be used. + * It avoids possible compiler warnings. + * + * For functions, place the attribute after the declaration, just before the + * semicolon. For arguments, place the attribute at the beginning of the + * argument declaration. + * + * |[ + * void my_unused_function (G_GNUC_UNUSED gint unused_argument, + * gint other_argument) G_GNUC_UNUSED; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-unused-function-attribute) for more details. + */ + +/** + * G_GNUC_NO_INSTRUMENT: + * + * Expands to the GNU C `no_instrument_function` function attribute if the + * compiler is gcc. Functions with this attribute will not be instrumented + * for profiling, when the compiler is called with the + * `-finstrument-functions` option. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * int do_uninteresting_things (void) G_GNUC_NO_INSTRUMENT; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005finstrument_005ffunction-function-attribute) for more details. + */ + +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +#if !defined (__clang__) && G_GNUC_CHECK_VERSION (4, 4) +#define G_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((__format__ (gnu_printf, format_idx, arg_idx))) +#define G_GNUC_SCANF( format_idx, arg_idx ) \ + __attribute__((__format__ (gnu_scanf, format_idx, arg_idx))) +#define G_GNUC_STRFTIME( format_idx ) \ + __attribute__((__format__ (gnu_strftime, format_idx, 0))) +#else +#define G_GNUC_PRINTF( format_idx, arg_idx ) \ + __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#define G_GNUC_SCANF( format_idx, arg_idx ) \ + __attribute__((__format__ (__scanf__, format_idx, arg_idx))) +#define G_GNUC_STRFTIME( format_idx ) \ + __attribute__((__format__ (__strftime__, format_idx, 0))) +#endif +#define G_GNUC_FORMAT( arg_idx ) \ + __attribute__((__format_arg__ (arg_idx))) +#define G_GNUC_NORETURN \ + __attribute__((__noreturn__)) +#define G_GNUC_CONST \ + __attribute__((__const__)) +#define G_GNUC_UNUSED \ + __attribute__((__unused__)) +#define G_GNUC_NO_INSTRUMENT \ + __attribute__((__no_instrument_function__)) +#else /* !__GNUC__ */ +#define G_GNUC_PRINTF( format_idx, arg_idx ) +#define G_GNUC_SCANF( format_idx, arg_idx ) +#define G_GNUC_STRFTIME( format_idx ) +#define G_GNUC_FORMAT( arg_idx ) +/* NOTE: MSVC has __declspec(noreturn) but unlike GCC __attribute__, + * __declspec can only be placed at the start of the function prototype + * and not at the end, so we can't use it without breaking API. + */ +#define G_GNUC_NORETURN +#define G_GNUC_CONST +#define G_GNUC_UNUSED +#define G_GNUC_NO_INSTRUMENT +#endif /* !__GNUC__ */ + +/** + * G_GNUC_FALLTHROUGH: + * + * Expands to the GNU C `fallthrough` statement attribute if the compiler supports it. + * This allows declaring case statement to explicitly fall through in switch + * statements. To enable this feature, use `-Wimplicit-fallthrough` during + * compilation. + * + * Put the attribute right before the case statement you want to fall through + * to. + * + * |[ + * switch (foo) + * { + * case 1: + * g_message ("it's 1"); + * G_GNUC_FALLTHROUGH; + * case 2: + * g_message ("it's either 1 or 2"); + * break; + * } + * ]| + * + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#index-fallthrough-statement-attribute) for more details. + * + * Since: 2.60 + */ +#if __GNUC__ > 6 +#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) +#elif g_macro__has_attribute (fallthrough) +#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) +#else +#define G_GNUC_FALLTHROUGH +#endif /* __GNUC__ */ + +/** + * G_GNUC_DEPRECATED: + * + * Expands to the GNU C `deprecated` attribute if the compiler is gcc. + * It can be used to mark `typedef`s, variables and functions as deprecated. + * When called with the `-Wdeprecated-declarations` option, + * gcc will generate warnings when deprecated interfaces are used. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * int my_mistake (void) G_GNUC_DEPRECATED; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-deprecated-function-attribute) for more details. + * + * Since: 2.2 + */ +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__) +#define G_GNUC_DEPRECATED __attribute__((__deprecated__)) +#else +#define G_GNUC_DEPRECATED +#endif /* __GNUC__ */ + +/** + * G_GNUC_DEPRECATED_FOR: + * @f: the intended replacement for the deprecated symbol, + * such as the name of a function + * + * Like %G_GNUC_DEPRECATED, but names the intended replacement for the + * deprecated symbol if the version of gcc in use is new enough to support + * custom deprecation messages. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * int my_mistake (void) G_GNUC_DEPRECATED_FOR(my_replacement); + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-deprecated-function-attribute) for more details. + * + * Note that if @f is a macro, it will be expanded in the warning message. + * You can enclose it in quotes to prevent this. (The quotes will show up + * in the warning, but it's better than showing the macro expansion.) + * + * Since: 2.26 + */ +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) +#define G_GNUC_DEPRECATED_FOR(f) \ + __attribute__((deprecated("Use " #f " instead"))) +#else +#define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED +#endif /* __GNUC__ */ + +#ifdef __ICC +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma ("warning (push)") \ + _Pragma ("warning (disable:1478)") +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma ("warning (pop)") +#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma ("GCC diagnostic pop") +#elif defined (_MSC_VER) && (_MSC_VER >= 1500) && !defined (__clang__) +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + __pragma (warning (push)) \ + __pragma (warning (disable : 4996)) +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + __pragma (warning (pop)) +#elif defined (__clang__) +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") +#define G_GNUC_END_IGNORE_DEPRECATIONS \ + _Pragma("clang diagnostic pop") +#else +#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS +#define G_GNUC_END_IGNORE_DEPRECATIONS +#endif + +/** + * G_GNUC_MAY_ALIAS: + * + * Expands to the GNU C `may_alias` type attribute if the compiler is gcc. + * Types with this attribute will not be subjected to type-based alias + * analysis, but are assumed to alias with any other type, just like `char`. + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-may_005falias-type-attribute) for details. + * + * Since: 2.14 + */ +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) +#define G_GNUC_MAY_ALIAS __attribute__((may_alias)) +#else +#define G_GNUC_MAY_ALIAS +#endif + +/** + * G_GNUC_WARN_UNUSED_RESULT: + * + * Expands to the GNU C `warn_unused_result` function attribute if the compiler + * is gcc. This function attribute makes the compiler emit a warning if the + * result of a function call is ignored. + * + * Place the attribute after the declaration, just before the semicolon. + * + * |[ + * GList *g_list_append (GList *list, + * gpointer data) G_GNUC_WARN_UNUSED_RESULT; + * ]| + * + * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warn_005funused_005fresult-function-attribute) for more details. + * + * Since: 2.10 + */ +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define G_GNUC_WARN_UNUSED_RESULT +#endif /* __GNUC__ */ + +/** + * G_GNUC_FUNCTION: + * + * Expands to "" on all modern compilers, and to __FUNCTION__ on gcc + * version 2.x. Don't use it. + * + * Deprecated: 2.16: Use G_STRFUNC() instead + */ + +/** + * G_GNUC_PRETTY_FUNCTION: + * + * Expands to "" on all modern compilers, and to __PRETTY_FUNCTION__ + * on gcc version 2.x. Don't use it. + * + * Deprecated: 2.16: Use G_STRFUNC() instead + */ + +/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with + * macros, so we can refer to them as strings unconditionally. + * usage not-recommended since gcc-3.0 + * + * Mark them as deprecated since 2.26, since that’s when version macros were + * introduced. + */ +#if defined (__GNUC__) && (__GNUC__ < 3) +#define G_GNUC_FUNCTION __FUNCTION__ GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) +#define G_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__ GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) +#else /* !__GNUC__ */ +#define G_GNUC_FUNCTION "" GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) +#define G_GNUC_PRETTY_FUNCTION "" GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) +#endif /* !__GNUC__ */ + +#if g_macro__has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__) +#define G_ANALYZER_ANALYZING 1 +#define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +#else +#define G_ANALYZER_ANALYZING 0 +#define G_ANALYZER_NORETURN +#endif + +#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string) +#define G_STRINGIFY_ARG(contents) #contents + +#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */ +#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 +#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2) +#if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false") +#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \ + (defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \ + (defined (_MSC_VER) && (_MSC_VER >= 1800)) +#define G_STATIC_ASSERT(expr) static_assert (expr, "Expression evaluates to false") +#else +#ifdef __COUNTER__ +#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED +#else +#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __LINE__)[(expr) ? 1 : -1] G_GNUC_UNUSED +#endif +#endif /* __STDC_VERSION__ */ +#define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1 : -1])) +#endif /* !__GI_SCANNER__ */ + +/* Provide a string identifying the current code position */ +#if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__cplusplus) +#define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()" +#else +#define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) +#endif + +/* Provide a string identifying the current function, non-concatenatable */ +#if defined (__GNUC__) && defined (__cplusplus) +#define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) +#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define G_STRFUNC ((const char*) (__func__)) +#elif defined (__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1300)) +#define G_STRFUNC ((const char*) (__FUNCTION__)) +#else +#define G_STRFUNC ((const char*) ("???")) +#endif + +/* Guard C code in headers, while including them from C++ */ +#ifdef __cplusplus +#define G_BEGIN_DECLS extern "C" { +#define G_END_DECLS } +#else +#define G_BEGIN_DECLS +#define G_END_DECLS +#endif + +/* Provide definitions for some commonly used macros. + * Some of them are only provided if they haven't already + * been defined. It is assumed that if they are already + * defined then the current definition is correct. + */ +#ifndef NULL +# ifdef __cplusplus +# define NULL (0L) +# else /* !__cplusplus */ +# define NULL ((void*) 0) +# endif /* !__cplusplus */ +#endif + +#ifndef FALSE +#define FALSE (0) +#endif + +#ifndef TRUE +#define TRUE (!FALSE) +#endif + +#undef MAX +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) + +#undef MIN +#define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +#undef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) + +#undef CLAMP +#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) + +#define G_APPROX_VALUE(a, b, epsilon) \ + (((a) > (b) ? (a) - (b) : (b) - (a)) < (epsilon)) + +/* Count the number of elements in an array. The array must be defined + * as such; using this with a dynamically allocated array will give + * incorrect results. + */ +#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0])) + +/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT + */ +#define GPOINTER_TO_SIZE(p) ((gsize) (p)) +#define GSIZE_TO_POINTER(s) ((gpointer) (gsize) (s)) + +/* Provide convenience macros for handling structure + * fields through their offsets. + */ + +#if (defined(__GNUC__) && __GNUC__ >= 4) || defined (_MSC_VER) +#define G_STRUCT_OFFSET(struct_type, member) \ + ((glong) offsetof (struct_type, member)) +#else +#define G_STRUCT_OFFSET(struct_type, member) \ + ((glong) ((guint8*) &((struct_type*) 0)->member)) +#endif + +#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \ + ((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset))) +#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \ + (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset))) + +/* Provide simple macro statement wrappers: + * G_STMT_START { statements; } G_STMT_END; + * This can be used as a single statement, like: + * if (x) G_STMT_START { ... } G_STMT_END; else ... + * This intentionally does not use compiler extensions like GCC's '({...})' to + * avoid portability issue or side effects when compiled with different compilers. + * MSVC complains about "while(0)": C4127: "Conditional expression is constant", + * so we use __pragma to avoid the warning since the use here is intentional. + */ +#if !(defined (G_STMT_START) && defined (G_STMT_END)) +#define G_STMT_START do +#if defined (_MSC_VER) && (_MSC_VER >= 1500) +#define G_STMT_END \ + __pragma(warning(push)) \ + __pragma(warning(disable:4127)) \ + while(0) \ + __pragma(warning(pop)) +#else +#define G_STMT_END while (0) +#endif +#endif + +/* Provide G_ALIGNOF alignment macro. + * + * Note we cannot use the gcc __alignof__ operator here, as that returns the + * preferred alignment rather than the minimal alignment. See + * https://gitlab.gnome.org/GNOME/glib/merge_requests/538/diffs#note_390790. + */ + +/** + * G_ALIGNOF + * @type: a type-name + * + * Return the minimal alignment required by the platform ABI for values of the given + * type. The address of a variable or struct member of the given type must always be + * a multiple of this alignment. For example, most platforms require int variables + * to be aligned at a 4-byte boundary, so `G_ALIGNOF (int)` is 4 on most platforms. + * + * Note this is not necessarily the same as the value returned by GCC’s + * `__alignof__` operator, which returns the preferred alignment for a type. + * The preferred alignment may be a stricter alignment than the minimal + * alignment. + * + * Since: 2.60 + */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus) +#define G_ALIGNOF(type) _Alignof (type) +#else +#define G_ALIGNOF(type) (G_STRUCT_OFFSET (struct { char a; type b; }, b)) +#endif + +/** + * G_CONST_RETURN: + * + * If %G_DISABLE_CONST_RETURNS is defined, this macro expands + * to nothing. By default, the macro expands to const. The macro + * can be used in place of const for functions that return a value + * that should not be modified. The purpose of this macro is to allow + * us to turn on const for returned constant strings by default, while + * allowing programmers who find that annoying to turn it off. This macro + * should only be used for return values and for "out" parameters, it + * doesn't make sense for "in" parameters. + * + * Deprecated: 2.30: API providers should replace all existing uses with + * const and API consumers should adjust their code accordingly + */ +#ifdef G_DISABLE_CONST_RETURNS +#define G_CONST_RETURN GLIB_DEPRECATED_MACRO_IN_2_30_FOR(const) +#else +#define G_CONST_RETURN const GLIB_DEPRECATED_MACRO_IN_2_30_FOR(const) +#endif + +/** + * G_NORETURN: + * + * Expands to the GNU C or MSVC `noreturn` function attribute depending on + * the compiler. It is used for declaring functions which never return. + * Enables optimization of the function, and avoids possible compiler warnings. + * + * Note that %G_NORETURN supersedes the previous %G_GNUC_NORETURN macro, which + * will eventually be deprecated. %G_NORETURN supports more platforms. + * + * Place the attribute before the function declaration as follows: + * + * |[ + * G_NORETURN void g_abort (void); + * ]| + * + * Since: 2.68 + */ +/* Note: We can’t annotate this with GLIB_AVAILABLE_MACRO_IN_2_68 because it’s + * used within the GLib headers in function declarations which are always + * evaluated when a header is included. This results in warnings in third party + * code which includes glib.h, even if the third party code doesn’t use the new + * macro itself. */ +#if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__)) || (0x5110 <= __SUNPRO_C) + /* For compatibility with G_NORETURN_FUNCPTR on clang, use + __attribute__((__noreturn__)), not _Noreturn. */ +# define G_NORETURN __attribute__ ((__noreturn__)) +#elif 1200 <= _MSC_VER + /* Use MSVC specific syntax. */ +# define G_NORETURN __declspec (noreturn) + /* Use ISO C++11 syntax when the compiler supports it. */ +#elif (__cplusplus >= 201103 && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) || (_MSC_VER >= 1900) +# define G_NORETURN [[noreturn]] + /* Use ISO C11 syntax when the compiler supports it. */ +#elif __STDC_VERSION__ >= 201112 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) +# define G_NORETURN _Noreturn +#else +# define G_NORETURN /* empty */ +#endif + +/** + * G_NORETURN_FUNCPTR: + * + * Expands to the GNU C or MSVC `noreturn` function attribute depending on + * the compiler. It is used for declaring function pointers which never return. + * Enables optimization of the function, and avoids possible compiler warnings. + * + * Place the attribute before the function declaration as follows: + * + * |[ + * G_NORETURN_FUNCPTR void (*funcptr) (void); + * ]| + * + * Note that if the function is not a function pointer, you can simply use + * the %G_NORETURN macro as follows: + * + * |[ + * G_NORETURN void g_abort (void); + * ]| + * + * Since: 2.68 + */ +#if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__)) || (0x5110 <= __SUNPRO_C) +# define G_NORETURN_FUNCPTR __attribute__ ((__noreturn__)) \ + GLIB_AVAILABLE_MACRO_IN_2_68 +#else +# define G_NORETURN_FUNCPTR /* empty */ \ + GLIB_AVAILABLE_MACRO_IN_2_68 +#endif + +/* + * The G_LIKELY and G_UNLIKELY macros let the programmer give hints to + * the compiler about the expected result of an expression. Some compilers + * can use this information for optimizations. + * + * The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when + * putting assignments in g_return_if_fail (). + */ +#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) +#define _G_BOOLEAN_EXPR(expr) \ + G_GNUC_EXTENSION ({ \ + int _g_boolean_var_; \ + if (expr) \ + _g_boolean_var_ = 1; \ + else \ + _g_boolean_var_ = 0; \ + _g_boolean_var_; \ +}) +#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) +#define G_UNLIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 0)) +#else +#define G_LIKELY(expr) (expr) +#define G_UNLIKELY(expr) (expr) +#endif + +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__) +#define G_DEPRECATED __attribute__((__deprecated__)) +#elif defined(_MSC_VER) && (_MSC_VER >= 1300) +#define G_DEPRECATED __declspec(deprecated) +#else +#define G_DEPRECATED +#endif + +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) +#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead"))) +#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) +#define G_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) +#else +#define G_DEPRECATED_FOR(f) G_DEPRECATED +#endif + +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) +#define G_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min))) +#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) +#define G_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min)) +#else +#define G_UNAVAILABLE(maj,min) G_DEPRECATED +#endif + +#ifndef _GLIB_EXTERN +#define _GLIB_EXTERN extern +#endif + +/* These macros are used to mark deprecated symbols in GLib headers, + * and thus have to be exposed in installed headers. But please + * do *not* use them in other projects. Instead, use G_DEPRECATED + * or define your own wrappers around it. + */ + +#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS +#define GLIB_DEPRECATED _GLIB_EXTERN +#define GLIB_DEPRECATED_FOR(f) _GLIB_EXTERN +#define GLIB_UNAVAILABLE(maj,min) _GLIB_EXTERN +#define GLIB_UNAVAILABLE_STATIC_INLINE(maj,min) +#else +#define GLIB_DEPRECATED G_DEPRECATED _GLIB_EXTERN +#define GLIB_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GLIB_EXTERN +#define GLIB_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GLIB_EXTERN +#define GLIB_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min) +#endif + +#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || \ + __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4)) +#define _GLIB_GNUC_DO_PRAGMA(x) _Pragma(G_STRINGIFY (x)) +#define GLIB_DEPRECATED_MACRO _GLIB_GNUC_DO_PRAGMA(GCC warning "Deprecated pre-processor symbol") +#define GLIB_DEPRECATED_MACRO_FOR(f) _GLIB_GNUC_DO_PRAGMA(GCC warning "Deprecated pre-processor symbol, replace with " #f) +#define GLIB_UNAVAILABLE_MACRO(maj,min) _GLIB_GNUC_DO_PRAGMA(GCC warning "Not available before " #maj "." #min) +#else +#define GLIB_DEPRECATED_MACRO +#define GLIB_DEPRECATED_MACRO_FOR(f) +#define GLIB_UNAVAILABLE_MACRO(maj,min) +#endif + +#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ + ((defined (__GNUC__) && (__GNUC__ > 6 || (__GNUC__ == 6 && __GNUC_MINOR__ >= 1))) || \ + (defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0)))) +#define GLIB_DEPRECATED_ENUMERATOR G_DEPRECATED +#define GLIB_DEPRECATED_ENUMERATOR_FOR(f) G_DEPRECATED_FOR(f) +#define GLIB_UNAVAILABLE_ENUMERATOR(maj,min) G_UNAVAILABLE(maj,min) +#else +#define GLIB_DEPRECATED_ENUMERATOR +#define GLIB_DEPRECATED_ENUMERATOR_FOR(f) +#define GLIB_UNAVAILABLE_ENUMERATOR(maj,min) +#endif + +#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ + ((defined (__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))) || \ + (defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0)))) +#define GLIB_DEPRECATED_TYPE G_DEPRECATED +#define GLIB_DEPRECATED_TYPE_FOR(f) G_DEPRECATED_FOR(f) +#define GLIB_UNAVAILABLE_TYPE(maj,min) G_UNAVAILABLE(maj,min) +#else +#define GLIB_DEPRECATED_TYPE +#define GLIB_DEPRECATED_TYPE_FOR(f) +#define GLIB_UNAVAILABLE_TYPE(maj,min) +#endif + +#ifndef __GI_SCANNER__ + +#if defined (__GNUC__) || defined (__clang__) + +/* these macros are private */ +#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName +#define _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) glib_autoptr_clear_##TypeName +#define _GLIB_AUTOPTR_TYPENAME(TypeName) TypeName##_autoptr +#define _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) glib_listautoptr_cleanup_##TypeName +#define _GLIB_AUTOPTR_LIST_TYPENAME(TypeName) TypeName##_listautoptr +#define _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) glib_slistautoptr_cleanup_##TypeName +#define _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName) TypeName##_slistautoptr +#define _GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName) glib_queueautoptr_cleanup_##TypeName +#define _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName) TypeName##_queueautoptr +#define _GLIB_AUTO_FUNC_NAME(TypeName) glib_auto_cleanup_##TypeName +#define _GLIB_CLEANUP(func) __attribute__((cleanup(func))) +#define _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, ParentName, cleanup) \ + typedef TypeName *_GLIB_AUTOPTR_TYPENAME(TypeName); \ + typedef GList *_GLIB_AUTOPTR_LIST_TYPENAME(TypeName); \ + typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName); \ + typedef GQueue *_GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) (TypeName *_ptr) \ + { if (_ptr) (cleanup) ((ParentName *) _ptr); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) \ + { _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) (*_ptr); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) \ + { g_list_free_full (*_l, (GDestroyNotify) (void(*)(void)) cleanup); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) \ + { g_slist_free_full (*_l, (GDestroyNotify) (void(*)(void)) cleanup); } \ + static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName) (GQueue **_q) \ + { if (*_q) g_queue_free_full (*_q, (GDestroyNotify) (void(*)(void)) cleanup); } \ + G_GNUC_END_IGNORE_DEPRECATIONS +#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) \ + _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(ModuleObjName, ParentName, _GLIB_AUTOPTR_CLEAR_FUNC_NAME(ParentName)) + + +/* these macros are API */ +#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) \ + _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { (func) (_ptr); } \ + G_GNUC_END_IGNORE_DEPRECATIONS +#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { if (*_ptr != none) (func) (*_ptr); } \ + G_GNUC_END_IGNORE_DEPRECATIONS +#define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName) +#define g_autolist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_LIST_TYPENAME(TypeName) +#define g_autoslist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName) +#define g_autoqueue(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName) +#define g_auto(TypeName) _GLIB_CLEANUP(_GLIB_AUTO_FUNC_NAME(TypeName)) TypeName +#define g_autofree _GLIB_CLEANUP(g_autoptr_cleanup_generic_gfree) + +#else /* not GNU C */ +/* this (dummy) macro is private */ +#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) + +/* these (dummy) macros are API */ +#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) + +/* no declaration of g_auto() or g_autoptr() here */ +#endif /* __GNUC__ */ + +#else + +#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) + +#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) +#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) + +#endif /* __GI_SCANNER__ */ + +/** + * G_SIZEOF_MEMBER: + * @struct_type: a structure type, e.g. #GOutputVector + * @member: a field in the structure, e.g. `size` + * + * Returns the size of @member in the struct definition without having a + * declared instance of @struct_type. + * + * Returns: the size of @member in bytes. + * + * Since: 2.64 + */ +#define G_SIZEOF_MEMBER(struct_type, member) \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + sizeof (((struct_type *) 0)->member) + +#endif /* __G_MACROS_H__ */ + +#include +#include +#define GLIB_HAVE_ALLOCA_H + +/* Specifies that GLib's g_print*() functions wrap the + * system printf functions. This is useful to know, for example, + * when using glibc's register_printf_function(). + */ +#undef GLIB_USING_SYSTEM_PRINTF + +#define GLIB_STATIC_COMPILATION 1 +#define GOBJECT_STATIC_COMPILATION 1 +#define GIO_STATIC_COMPILATION 1 + +G_BEGIN_DECLS + +#define G_MINFLOAT FLT_MIN +#define G_MAXFLOAT FLT_MAX +#define G_MINDOUBLE DBL_MIN +#define G_MAXDOUBLE DBL_MAX +#define G_MINSHORT SHRT_MIN +#define G_MAXSHORT SHRT_MAX +#define G_MAXUSHORT USHRT_MAX +#define G_MININT INT_MIN +#define G_MAXINT INT_MAX +#define G_MAXUINT UINT_MAX +#define G_MINLONG LONG_MIN +#define G_MAXLONG LONG_MAX +#define G_MAXULONG ULONG_MAX + +typedef signed char gint8; +typedef unsigned char guint8; + +typedef signed short gint16; +typedef unsigned short guint16; + +#define G_GINT16_MODIFIER "h" +#define G_GINT16_FORMAT "hi" +#define G_GUINT16_FORMAT "hu" + + +typedef signed int gint32; +typedef unsigned int guint32; + +#define G_GINT32_MODIFIER "" +#define G_GINT32_FORMAT "i" +#define G_GUINT32_FORMAT "u" + + +#define G_HAVE_GINT64 1 /* deprecated, always true */ + +typedef signed long gint64; +typedef unsigned long guint64; + +#define G_GINT64_CONSTANT(val) (val##L) +#define G_GUINT64_CONSTANT(val) (val##UL) + +#define G_GINT64_MODIFIER "l" +#define G_GINT64_FORMAT "li" +#define G_GUINT64_FORMAT "lu" + + +#define GLIB_SIZEOF_VOID_P 8 +#define GLIB_SIZEOF_LONG 8 +#define GLIB_SIZEOF_SIZE_T 8 +#define GLIB_SIZEOF_SSIZE_T 8 + +typedef signed long gssize; +typedef unsigned long gsize; +#define G_GSIZE_MODIFIER "l" +#define G_GSSIZE_MODIFIER "l" +#define G_GSIZE_FORMAT "lu" +#define G_GSSIZE_FORMAT "li" + +#define G_MAXSIZE G_MAXULONG +#define G_MINSSIZE G_MINLONG +#define G_MAXSSIZE G_MAXLONG + +typedef gint64 goffset; +#define G_MINOFFSET G_MININT64 +#define G_MAXOFFSET G_MAXINT64 + +#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER +#define G_GOFFSET_FORMAT G_GINT64_FORMAT +#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val) + +#define G_POLLFD_FORMAT "%d" + +#define GPOINTER_TO_INT(p) ((gint) (glong) (p)) +#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p)) + +#define GINT_TO_POINTER(i) ((gpointer) (glong) (i)) +#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u)) + +typedef signed long gintptr; +typedef unsigned long guintptr; + +#define G_GINTPTR_MODIFIER "l" +#define G_GINTPTR_FORMAT "li" +#define G_GUINTPTR_FORMAT "lu" + +#define GLIB_MAJOR_VERSION 2 +#define GLIB_MINOR_VERSION 67 +#define GLIB_MICRO_VERSION 1 + +#define G_OS_UNIX + +#define G_VA_COPY va_copy + + +#ifndef __cplusplus +# define G_HAVE_ISO_VARARGS 1 +#endif + +#ifdef __cplusplus +# define G_HAVE_ISO_VARARGS 1 +#endif + +/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi + * is passed ISO vararg support is turned off, and there is no work + * around to turn it on, so we unconditionally turn it off. + */ +#if __GNUC__ == 2 && __GNUC_MINOR__ == 95 +# undef G_HAVE_ISO_VARARGS +#endif + +#define G_HAVE_GROWING_STACK 0 +#define G_HAVE_GNUC_VISIBILITY 1 + +#ifndef _MSC_VER +# define G_HAVE_GNUC_VARARGS 1 +#endif + +#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) +#define G_GNUC_INTERNAL __attribute__((visibility("hidden"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) +#define G_GNUC_INTERNAL __hidden +#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY) +#define G_GNUC_INTERNAL __attribute__((visibility("hidden"))) +#else +#define G_GNUC_INTERNAL +#endif + +#define G_THREADS_ENABLED +#define G_THREADS_IMPL_POSIX + +#define G_ATOMIC_LOCK_FREE + +#define GINT16_TO_LE(val) ((gint16) (val)) +#define GUINT16_TO_LE(val) ((guint16) (val)) +#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val)) +#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val)) + +#define GINT32_TO_LE(val) ((gint32) (val)) +#define GUINT32_TO_LE(val) ((guint32) (val)) +#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val)) +#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) + +#define GINT64_TO_LE(val) ((gint64) (val)) +#define GUINT64_TO_LE(val) ((guint64) (val)) +#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val)) +#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val)) + +#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val)) +#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val)) +#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val)) +#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val)) +#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val)) +#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val)) +#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val)) +#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val)) +#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val)) +#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val)) +#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val)) +#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val)) +#define G_BYTE_ORDER G_LITTLE_ENDIAN + +#define GLIB_SYSDEF_POLLIN =1 +#define GLIB_SYSDEF_POLLOUT =4 +#define GLIB_SYSDEF_POLLPRI =2 +#define GLIB_SYSDEF_POLLHUP =16 +#define GLIB_SYSDEF_POLLERR =8 +#define GLIB_SYSDEF_POLLNVAL =32 + +#define G_MODULE_SUFFIX "so" + +typedef int GPid; +#define G_PID_FORMAT "i" + +#define GLIB_SYSDEF_AF_UNIX 1 +#define GLIB_SYSDEF_AF_INET 2 +#define GLIB_SYSDEF_AF_INET6 10 + +#define GLIB_SYSDEF_MSG_OOB 1 +#define GLIB_SYSDEF_MSG_PEEK 2 +#define GLIB_SYSDEF_MSG_DONTROUTE 4 + +#define G_DIR_SEPARATOR '/' +#define G_DIR_SEPARATOR_S "/" +#define G_SEARCHPATH_SEPARATOR ':' +#define G_SEARCHPATH_SEPARATOR_S ":" + +G_END_DECLS + +#endif /* __GLIBCONFIG_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_VERSION_MACROS_H__ +#define __G_VERSION_MACROS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* Version boundaries checks */ + +#define G_ENCODE_VERSION(major,minor) ((major) << 16 | (minor) << 8) + +/* XXX: Every new stable minor release bump should add a macro here */ + +/** + * GLIB_VERSION_2_26: + * + * A macro that evaluates to the 2.26 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.32 + */ +#define GLIB_VERSION_2_26 (G_ENCODE_VERSION (2, 26)) + +/** + * GLIB_VERSION_2_28: + * + * A macro that evaluates to the 2.28 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.32 + */ +#define GLIB_VERSION_2_28 (G_ENCODE_VERSION (2, 28)) + +/** + * GLIB_VERSION_2_30: + * + * A macro that evaluates to the 2.30 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.32 + */ +#define GLIB_VERSION_2_30 (G_ENCODE_VERSION (2, 30)) + +/** + * GLIB_VERSION_2_32: + * + * A macro that evaluates to the 2.32 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.32 + */ +#define GLIB_VERSION_2_32 (G_ENCODE_VERSION (2, 32)) + +/** + * GLIB_VERSION_2_34: + * + * A macro that evaluates to the 2.34 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.34 + */ +#define GLIB_VERSION_2_34 (G_ENCODE_VERSION (2, 34)) + +/** + * GLIB_VERSION_2_36: + * + * A macro that evaluates to the 2.36 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.36 + */ +#define GLIB_VERSION_2_36 (G_ENCODE_VERSION (2, 36)) + +/** + * GLIB_VERSION_2_38: + * + * A macro that evaluates to the 2.38 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.38 + */ +#define GLIB_VERSION_2_38 (G_ENCODE_VERSION (2, 38)) + +/** + * GLIB_VERSION_2_40: + * + * A macro that evaluates to the 2.40 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.40 + */ +#define GLIB_VERSION_2_40 (G_ENCODE_VERSION (2, 40)) + +/** + * GLIB_VERSION_2_42: + * + * A macro that evaluates to the 2.42 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.42 + */ +#define GLIB_VERSION_2_42 (G_ENCODE_VERSION (2, 42)) + +/** + * GLIB_VERSION_2_44: + * + * A macro that evaluates to the 2.44 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.44 + */ +#define GLIB_VERSION_2_44 (G_ENCODE_VERSION (2, 44)) + +/** + * GLIB_VERSION_2_46: + * + * A macro that evaluates to the 2.46 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.46 + */ +#define GLIB_VERSION_2_46 (G_ENCODE_VERSION (2, 46)) + +/** + * GLIB_VERSION_2_48: + * + * A macro that evaluates to the 2.48 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.48 + */ +#define GLIB_VERSION_2_48 (G_ENCODE_VERSION (2, 48)) + +/** + * GLIB_VERSION_2_50: + * + * A macro that evaluates to the 2.50 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.50 + */ +#define GLIB_VERSION_2_50 (G_ENCODE_VERSION (2, 50)) + +/** + * GLIB_VERSION_2_52: + * + * A macro that evaluates to the 2.52 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.52 + */ +#define GLIB_VERSION_2_52 (G_ENCODE_VERSION (2, 52)) + +/** + * GLIB_VERSION_2_54: + * + * A macro that evaluates to the 2.54 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.54 + */ +#define GLIB_VERSION_2_54 (G_ENCODE_VERSION (2, 54)) + +/** + * GLIB_VERSION_2_56: + * + * A macro that evaluates to the 2.56 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.56 + */ +#define GLIB_VERSION_2_56 (G_ENCODE_VERSION (2, 56)) + +/** + * GLIB_VERSION_2_58: + * + * A macro that evaluates to the 2.58 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.58 + */ +#define GLIB_VERSION_2_58 (G_ENCODE_VERSION (2, 58)) + +/** + * GLIB_VERSION_2_60: + * + * A macro that evaluates to the 2.60 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.60 + */ +#define GLIB_VERSION_2_60 (G_ENCODE_VERSION (2, 60)) + +/** + * GLIB_VERSION_2_62: + * + * A macro that evaluates to the 2.62 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.62 + */ +#define GLIB_VERSION_2_62 (G_ENCODE_VERSION (2, 62)) + +/** + * GLIB_VERSION_2_64: + * + * A macro that evaluates to the 2.64 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.64 + */ +#define GLIB_VERSION_2_64 (G_ENCODE_VERSION (2, 64)) + +/** + * GLIB_VERSION_2_66: + * + * A macro that evaluates to the 2.66 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.66 + */ +#define GLIB_VERSION_2_66 (G_ENCODE_VERSION (2, 66)) + +/** + * GLIB_VERSION_2_68: + * + * A macro that evaluates to the 2.68 version of GLib, in a format + * that can be used by the C pre-processor. + * + * Since: 2.68 + */ +#define GLIB_VERSION_2_68 (G_ENCODE_VERSION (2, 68)) + +/* evaluates to the current stable version; for development cycles, + * this means the next stable target + */ +#if (GLIB_MINOR_VERSION % 2) +#define GLIB_VERSION_CUR_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION + 1)) +#else +#define GLIB_VERSION_CUR_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION)) +#endif + +/* evaluates to the previous stable version */ +#if (GLIB_MINOR_VERSION % 2) +#define GLIB_VERSION_PREV_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 1)) +#else +#define GLIB_VERSION_PREV_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 2)) +#endif + +/** + * GLIB_VERSION_MIN_REQUIRED: + * + * A macro that should be defined by the user prior to including + * the glib.h header. + * The definition should be one of the predefined GLib version + * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,... + * + * This macro defines the earliest version of GLib that the package is + * required to be able to compile against. + * + * If the compiler is configured to warn about the use of deprecated + * functions, then using functions that were deprecated in version + * %GLIB_VERSION_MIN_REQUIRED or earlier will cause warnings (but + * using functions deprecated in later releases will not). + * + * Since: 2.32 + */ +/* If the package sets GLIB_VERSION_MIN_REQUIRED to some future + * GLIB_VERSION_X_Y value that we don't know about, it will compare as + * 0 in preprocessor tests. + */ +#ifndef GLIB_VERSION_MIN_REQUIRED +# define GLIB_VERSION_MIN_REQUIRED (GLIB_VERSION_CUR_STABLE) +#elif GLIB_VERSION_MIN_REQUIRED == 0 +# undef GLIB_VERSION_MIN_REQUIRED +# define GLIB_VERSION_MIN_REQUIRED (GLIB_VERSION_CUR_STABLE + 2) +#endif + +/** + * GLIB_VERSION_MAX_ALLOWED: + * + * A macro that should be defined by the user prior to including + * the glib.h header. + * The definition should be one of the predefined GLib version + * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,... + * + * This macro defines the latest version of the GLib API that the + * package is allowed to make use of. + * + * If the compiler is configured to warn about the use of deprecated + * functions, then using functions added after version + * %GLIB_VERSION_MAX_ALLOWED will cause warnings. + * + * Unless you are using GLIB_CHECK_VERSION() or the like to compile + * different code depending on the GLib version, then this should be + * set to the same value as %GLIB_VERSION_MIN_REQUIRED. + * + * Since: 2.32 + */ +#if !defined (GLIB_VERSION_MAX_ALLOWED) || (GLIB_VERSION_MAX_ALLOWED == 0) +# undef GLIB_VERSION_MAX_ALLOWED +# define GLIB_VERSION_MAX_ALLOWED (GLIB_VERSION_CUR_STABLE) +#endif + +/* sanity checks */ +#if GLIB_VERSION_MIN_REQUIRED > GLIB_VERSION_CUR_STABLE +#error "GLIB_VERSION_MIN_REQUIRED must be <= GLIB_VERSION_CUR_STABLE" +#endif +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_MIN_REQUIRED +#error "GLIB_VERSION_MAX_ALLOWED must be >= GLIB_VERSION_MIN_REQUIRED" +#endif +#if GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_26 +#error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26" +#endif + +/* These macros are used to mark deprecated functions in GLib headers, + * and thus have to be exposed in installed headers. But please + * do *not* use them in other projects. Instead, use G_DEPRECATED + * or define your own wrappers around it. + */ +#define GLIB_AVAILABLE_IN_ALL _GLIB_EXTERN + +/* XXX: Every new stable minor release should add a set of macros here */ + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26 +# define GLIB_DEPRECATED_IN_2_26 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_26_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_26 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_26_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_26 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_26 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_26_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_26 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_26_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_26 +# define GLIB_DEPRECATED_MACRO_IN_2_26_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_26 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_26 +# define GLIB_DEPRECATED_TYPE_IN_2_26_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26 +# define GLIB_AVAILABLE_IN_2_26 GLIB_UNAVAILABLE(2, 26) +# define GLIB_AVAILABLE_MACRO_IN_2_26 GLIB_UNAVAILABLE_MACRO(2, 26) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_26 GLIB_UNAVAILABLE_ENUMERATOR(2, 26) +# define GLIB_AVAILABLE_TYPE_IN_2_26 GLIB_UNAVAILABLE_TYPE(2, 26) +#else +# define GLIB_AVAILABLE_IN_2_26 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_26 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_26 +# define GLIB_AVAILABLE_TYPE_IN_2_26 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28 +# define GLIB_DEPRECATED_IN_2_28 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_28_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_28 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_28_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_28 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_28 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_28_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_28 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_28_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_28 +# define GLIB_DEPRECATED_MACRO_IN_2_28_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_28 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_28 +# define GLIB_DEPRECATED_TYPE_IN_2_28_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28 +# define GLIB_AVAILABLE_IN_2_28 GLIB_UNAVAILABLE(2, 28) +# define GLIB_AVAILABLE_MACRO_IN_2_28 GLIB_UNAVAILABLE_MACRO(2, 28) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_28 GLIB_UNAVAILABLE_ENUMERATOR(2, 28) +# define GLIB_AVAILABLE_TYPE_IN_2_28 GLIB_UNAVAILABLE_TYPE(2, 28) +#else +# define GLIB_AVAILABLE_IN_2_28 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_28 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_28 +# define GLIB_AVAILABLE_TYPE_IN_2_28 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30 +# define GLIB_DEPRECATED_IN_2_30 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_30_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_30 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_30_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_30 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_30 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_30_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_30 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_30_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_30 +# define GLIB_DEPRECATED_MACRO_IN_2_30_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_30 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_30 +# define GLIB_DEPRECATED_TYPE_IN_2_30_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30 +# define GLIB_AVAILABLE_IN_2_30 GLIB_UNAVAILABLE(2, 30) +# define GLIB_AVAILABLE_MACRO_IN_2_30 GLIB_UNAVAILABLE_MACRO(2, 30) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_30 GLIB_UNAVAILABLE_ENUMERATOR(2, 30) +# define GLIB_AVAILABLE_TYPE_IN_2_30 GLIB_UNAVAILABLE_TYPE(2, 30) +#else +# define GLIB_AVAILABLE_IN_2_30 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_30 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_30 +# define GLIB_AVAILABLE_TYPE_IN_2_30 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32 +# define GLIB_DEPRECATED_IN_2_32 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_32_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_32 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_32_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_32 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_32_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_32 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_32_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_32 +# define GLIB_DEPRECATED_MACRO_IN_2_32_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_32 +# define GLIB_DEPRECATED_TYPE_IN_2_32_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_32 +# define GLIB_DEPRECATED_TYPE_IN_2_32_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32 +# define GLIB_AVAILABLE_IN_2_32 GLIB_UNAVAILABLE(2, 32) +# define GLIB_AVAILABLE_MACRO_IN_2_32 GLIB_UNAVAILABLE_MACRO(2, 32) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_32 GLIB_UNAVAILABLE_ENUMERATOR(2, 32) +# define GLIB_AVAILABLE_TYPE_IN_2_32 GLIB_UNAVAILABLE_TYPE(2, 32) +#else +# define GLIB_AVAILABLE_IN_2_32 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_32 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_32 +# define GLIB_AVAILABLE_TYPE_IN_2_32 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34 +# define GLIB_DEPRECATED_IN_2_34 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_34_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_34 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_34_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_34 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_34 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_34_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_34 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_34_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_34 +# define GLIB_DEPRECATED_MACRO_IN_2_34_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_34 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_34 +# define GLIB_DEPRECATED_TYPE_IN_2_34_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34 +# define GLIB_AVAILABLE_IN_2_34 GLIB_UNAVAILABLE(2, 34) +# define GLIB_AVAILABLE_MACRO_IN_2_34 GLIB_UNAVAILABLE_MACRO(2, 34) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_34 GLIB_UNAVAILABLE_ENUMERATOR(2, 34) +# define GLIB_AVAILABLE_TYPE_IN_2_34 GLIB_UNAVAILABLE_TYPE(2, 34) +#else +# define GLIB_AVAILABLE_IN_2_34 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_34 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_34 +# define GLIB_AVAILABLE_TYPE_IN_2_34 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36 +# define GLIB_DEPRECATED_IN_2_36 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_36_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_36 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_36_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_36 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_36 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_36_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_36 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_36_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_36 +# define GLIB_DEPRECATED_MACRO_IN_2_36_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_36 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_36 +# define GLIB_DEPRECATED_TYPE_IN_2_36_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36 +# define GLIB_AVAILABLE_IN_2_36 GLIB_UNAVAILABLE(2, 36) +# define GLIB_AVAILABLE_MACRO_IN_2_36 GLIB_UNAVAILABLE_MACRO(2, 36) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_36 GLIB_UNAVAILABLE_ENUMERATOR(2, 36) +# define GLIB_AVAILABLE_TYPE_IN_2_36 GLIB_UNAVAILABLE_TYPE(2, 36) +#else +# define GLIB_AVAILABLE_IN_2_36 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_36 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_36 +# define GLIB_AVAILABLE_TYPE_IN_2_36 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_38 +# define GLIB_DEPRECATED_IN_2_38 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_38_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_38 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_38_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_38 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_38 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_38_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_38 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_38_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_38 +# define GLIB_DEPRECATED_MACRO_IN_2_38_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_38 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_38 +# define GLIB_DEPRECATED_TYPE_IN_2_38_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 +# define GLIB_AVAILABLE_IN_2_38 GLIB_UNAVAILABLE(2, 38) +# define GLIB_AVAILABLE_MACRO_IN_2_38 GLIB_UNAVAILABLE_MACRO(2, 38) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_38 GLIB_UNAVAILABLE_ENUMERATOR(2, 38) +# define GLIB_AVAILABLE_TYPE_IN_2_38 GLIB_UNAVAILABLE_TYPE(2, 38) +#else +# define GLIB_AVAILABLE_IN_2_38 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_38 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_38 +# define GLIB_AVAILABLE_TYPE_IN_2_38 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_40 +# define GLIB_DEPRECATED_IN_2_40 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_40_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_40 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_40_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_40 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_40 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_40_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_40 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_40_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_40 +# define GLIB_DEPRECATED_MACRO_IN_2_40_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_40 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_40 +# define GLIB_DEPRECATED_TYPE_IN_2_40_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_40 +# define GLIB_AVAILABLE_IN_2_40 GLIB_UNAVAILABLE(2, 40) +# define GLIB_AVAILABLE_MACRO_IN_2_40 GLIB_UNAVAILABLE_MACRO(2, 40) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_40 GLIB_UNAVAILABLE_ENUMERATOR(2, 40) +# define GLIB_AVAILABLE_TYPE_IN_2_40 GLIB_UNAVAILABLE_TYPE(2, 40) +#else +# define GLIB_AVAILABLE_IN_2_40 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_40 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_40 +# define GLIB_AVAILABLE_TYPE_IN_2_40 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_42 +# define GLIB_DEPRECATED_IN_2_42 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_42_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_42 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_42_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_42 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_42_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_42 +# define GLIB_DEPRECATED_MACRO_IN_2_42_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_42 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_42 +# define GLIB_DEPRECATED_TYPE_IN_2_42_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_42 +# define GLIB_AVAILABLE_IN_2_42 GLIB_UNAVAILABLE(2, 42) +# define GLIB_AVAILABLE_MACRO_IN_2_42 GLIB_UNAVAILABLE_MACRO(2, 42) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_42 GLIB_UNAVAILABLE_ENUMERATOR(2, 42) +# define GLIB_AVAILABLE_TYPE_IN_2_42 GLIB_UNAVAILABLE_TYPE(2, 42) +#else +# define GLIB_AVAILABLE_IN_2_42 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_42 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_42 +# define GLIB_AVAILABLE_TYPE_IN_2_42 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_44 +# define GLIB_DEPRECATED_IN_2_44 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_44_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_44 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_44_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_44 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_44 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_44_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_44 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_44_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_44 +# define GLIB_DEPRECATED_MACRO_IN_2_44_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_44 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_44 +# define GLIB_DEPRECATED_TYPE_IN_2_44_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_44 +# define GLIB_AVAILABLE_IN_2_44 GLIB_UNAVAILABLE(2, 44) +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 GLIB_UNAVAILABLE_STATIC_INLINE(2, 44) +# define GLIB_AVAILABLE_MACRO_IN_2_44 GLIB_UNAVAILABLE_MACRO(2, 44) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_44 GLIB_UNAVAILABLE_ENUMERATOR(2, 44) +# define GLIB_AVAILABLE_TYPE_IN_2_44 GLIB_UNAVAILABLE_TYPE(2, 44) +#else +# define GLIB_AVAILABLE_IN_2_44 _GLIB_EXTERN +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +# define GLIB_AVAILABLE_MACRO_IN_2_44 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_44 +# define GLIB_AVAILABLE_TYPE_IN_2_44 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_46 +# define GLIB_DEPRECATED_IN_2_46 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_46_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_46 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_46_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_46 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_46_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_46 +# define GLIB_DEPRECATED_MACRO_IN_2_46_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_46 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_46 +# define GLIB_DEPRECATED_TYPE_IN_2_46_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_46 +# define GLIB_AVAILABLE_IN_2_46 GLIB_UNAVAILABLE(2, 46) +# define GLIB_AVAILABLE_MACRO_IN_2_46 GLIB_UNAVAILABLE_MACRO(2, 46) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_46 GLIB_UNAVAILABLE_ENUMERATOR(2, 46) +# define GLIB_AVAILABLE_TYPE_IN_2_46 GLIB_UNAVAILABLE_TYPE(2, 46) +#else +# define GLIB_AVAILABLE_IN_2_46 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_46 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_46 +# define GLIB_AVAILABLE_TYPE_IN_2_46 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_48 +# define GLIB_DEPRECATED_IN_2_48 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_48_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_48 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_48_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_48 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_48 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_48_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_48 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_48_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_48 +# define GLIB_DEPRECATED_MACRO_IN_2_48_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_48 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_48 +# define GLIB_DEPRECATED_TYPE_IN_2_48_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_48 +# define GLIB_AVAILABLE_IN_2_48 GLIB_UNAVAILABLE(2, 48) +# define GLIB_AVAILABLE_MACRO_IN_2_48 GLIB_UNAVAILABLE_MACRO(2, 48) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_48 GLIB_UNAVAILABLE_ENUMERATOR(2, 48) +# define GLIB_AVAILABLE_TYPE_IN_2_48 GLIB_UNAVAILABLE_TYPE(2, 48) +#else +# define GLIB_AVAILABLE_IN_2_48 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_48 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_48 +# define GLIB_AVAILABLE_TYPE_IN_2_48 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_50 +# define GLIB_DEPRECATED_IN_2_50 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_50_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_50 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_50_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_50 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_50 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_50_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_50 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_50_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_50 +# define GLIB_DEPRECATED_MACRO_IN_2_50_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_50 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_50 +# define GLIB_DEPRECATED_TYPE_IN_2_50_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_50 +# define GLIB_AVAILABLE_IN_2_50 GLIB_UNAVAILABLE(2, 50) +# define GLIB_AVAILABLE_MACRO_IN_2_50 GLIB_UNAVAILABLE_MACRO(2, 50) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_50 GLIB_UNAVAILABLE_ENUMERATOR(2, 50) +# define GLIB_AVAILABLE_TYPE_IN_2_50 GLIB_UNAVAILABLE_TYPE(2, 50) +#else +# define GLIB_AVAILABLE_IN_2_50 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_50 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_50 +# define GLIB_AVAILABLE_TYPE_IN_2_50 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_52 +# define GLIB_DEPRECATED_IN_2_52 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_52_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_52 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_52_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_52 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_52 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_52_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_52 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_52_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_52 +# define GLIB_DEPRECATED_MACRO_IN_2_52_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_52 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_52 +# define GLIB_DEPRECATED_TYPE_IN_2_52_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_52 +# define GLIB_AVAILABLE_IN_2_52 GLIB_UNAVAILABLE(2, 52) +# define GLIB_AVAILABLE_MACRO_IN_2_52 GLIB_UNAVAILABLE_MACRO(2, 52) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_52 GLIB_UNAVAILABLE_ENUMERATOR(2, 52) +# define GLIB_AVAILABLE_TYPE_IN_2_52 GLIB_UNAVAILABLE_TYPE(2, 52) +#else +# define GLIB_AVAILABLE_IN_2_52 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_52 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_52 +# define GLIB_AVAILABLE_TYPE_IN_2_52 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_54 +# define GLIB_DEPRECATED_IN_2_54 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_54_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_54 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_54_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_54 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_54 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_54_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_54 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_54_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_54 +# define GLIB_DEPRECATED_MACRO_IN_2_54_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_54 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_54 +# define GLIB_DEPRECATED_TYPE_IN_2_54_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_54 +# define GLIB_AVAILABLE_IN_2_54 GLIB_UNAVAILABLE(2, 54) +# define GLIB_AVAILABLE_MACRO_IN_2_54 GLIB_UNAVAILABLE_MACRO(2, 54) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_54 GLIB_UNAVAILABLE_ENUMERATOR(2, 54) +# define GLIB_AVAILABLE_TYPE_IN_2_54 GLIB_UNAVAILABLE_TYPE(2, 54) +#else +# define GLIB_AVAILABLE_IN_2_54 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_54 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_54 +# define GLIB_AVAILABLE_TYPE_IN_2_54 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_56 +# define GLIB_DEPRECATED_IN_2_56 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_56_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_56 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_56_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_56 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_56 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_56_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_56 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_56_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_56 +# define GLIB_DEPRECATED_MACRO_IN_2_56_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_56 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_56 +# define GLIB_DEPRECATED_TYPE_IN_2_56_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_56 +# define GLIB_AVAILABLE_IN_2_56 GLIB_UNAVAILABLE(2, 56) +# define GLIB_AVAILABLE_MACRO_IN_2_56 GLIB_UNAVAILABLE_MACRO(2, 56) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_56 GLIB_UNAVAILABLE_ENUMERATOR(2, 56) +# define GLIB_AVAILABLE_TYPE_IN_2_56 GLIB_UNAVAILABLE_TYPE(2, 56) +#else +# define GLIB_AVAILABLE_IN_2_56 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_56 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_56 +# define GLIB_AVAILABLE_TYPE_IN_2_56 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_58 +# define GLIB_DEPRECATED_IN_2_58 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_58_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_58 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_58_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_58 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_58 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_58_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_58 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_58_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_58 +# define GLIB_DEPRECATED_MACRO_IN_2_58_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_58 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_58 +# define GLIB_DEPRECATED_TYPE_IN_2_58_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_58 +# define GLIB_AVAILABLE_IN_2_58 GLIB_UNAVAILABLE(2, 58) +# define GLIB_AVAILABLE_MACRO_IN_2_58 GLIB_UNAVAILABLE_MACRO(2, 58) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_58 GLIB_UNAVAILABLE_ENUMERATOR(2, 58) +# define GLIB_AVAILABLE_TYPE_IN_2_58 GLIB_UNAVAILABLE_TYPE(2, 58) +#else +# define GLIB_AVAILABLE_IN_2_58 _GLIB_EXTERN +# define GLIB_AVAILABLE_MACRO_IN_2_58 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_58 +# define GLIB_AVAILABLE_TYPE_IN_2_58 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_60 +# define GLIB_DEPRECATED_IN_2_60 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_60_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_60 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_60_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_60 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_60 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_60_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_60 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_60_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_60 +# define GLIB_DEPRECATED_MACRO_IN_2_60_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_60 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_60 +# define GLIB_DEPRECATED_TYPE_IN_2_60_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_60 +# define GLIB_AVAILABLE_IN_2_60 GLIB_UNAVAILABLE(2, 60) +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 GLIB_UNAVAILABLE_STATIC_INLINE(2, 60) +# define GLIB_AVAILABLE_MACRO_IN_2_60 GLIB_UNAVAILABLE_MACRO(2, 60) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_60 GLIB_UNAVAILABLE_ENUMERATOR(2, 60) +# define GLIB_AVAILABLE_TYPE_IN_2_60 GLIB_UNAVAILABLE_TYPE(2, 60) +#else +# define GLIB_AVAILABLE_IN_2_60 _GLIB_EXTERN +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 +# define GLIB_AVAILABLE_MACRO_IN_2_60 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_60 +# define GLIB_AVAILABLE_TYPE_IN_2_60 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_62 +# define GLIB_DEPRECATED_IN_2_62 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_62_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_62 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_62_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_62 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_62 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_62_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_62 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_62_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_62 +# define GLIB_DEPRECATED_MACRO_IN_2_62_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_62 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_62 +# define GLIB_DEPRECATED_TYPE_IN_2_62_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_62 +# define GLIB_AVAILABLE_IN_2_62 GLIB_UNAVAILABLE(2, 62) +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 GLIB_UNAVAILABLE_STATIC_INLINE(2, 62) +# define GLIB_AVAILABLE_MACRO_IN_2_62 GLIB_UNAVAILABLE_MACRO(2, 62) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_62 GLIB_UNAVAILABLE_ENUMERATOR(2, 62) +# define GLIB_AVAILABLE_TYPE_IN_2_62 GLIB_UNAVAILABLE_TYPE(2, 62) +#else +# define GLIB_AVAILABLE_IN_2_62 _GLIB_EXTERN +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +# define GLIB_AVAILABLE_MACRO_IN_2_62 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_62 +# define GLIB_AVAILABLE_TYPE_IN_2_62 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 +# define GLIB_DEPRECATED_IN_2_64 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_64_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_64 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_64_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_64 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_64 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_64_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_64 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_64_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_64 +# define GLIB_DEPRECATED_MACRO_IN_2_64_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_64 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_64 +# define GLIB_DEPRECATED_TYPE_IN_2_64_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64 +# define GLIB_AVAILABLE_IN_2_64 GLIB_UNAVAILABLE(2, 64) +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 GLIB_UNAVAILABLE_STATIC_INLINE(2, 64) +# define GLIB_AVAILABLE_MACRO_IN_2_64 GLIB_UNAVAILABLE_MACRO(2, 64) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_64 GLIB_UNAVAILABLE_ENUMERATOR(2, 64) +# define GLIB_AVAILABLE_TYPE_IN_2_64 GLIB_UNAVAILABLE_TYPE(2, 64) +#else +# define GLIB_AVAILABLE_IN_2_64 _GLIB_EXTERN +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 +# define GLIB_AVAILABLE_MACRO_IN_2_64 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_64 +# define GLIB_AVAILABLE_TYPE_IN_2_64 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_66 +# define GLIB_DEPRECATED_IN_2_66 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_66_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_66 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_66_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_66 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_66 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_66_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_66 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_66_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_66 +# define GLIB_DEPRECATED_MACRO_IN_2_66_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_66 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_66 +# define GLIB_DEPRECATED_TYPE_IN_2_66_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_66 +# define GLIB_AVAILABLE_IN_2_66 GLIB_UNAVAILABLE(2, 66) +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_66 GLIB_UNAVAILABLE_STATIC_INLINE(2, 66) +# define GLIB_AVAILABLE_MACRO_IN_2_66 GLIB_UNAVAILABLE_MACRO(2, 66) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_66 GLIB_UNAVAILABLE_ENUMERATOR(2, 66) +# define GLIB_AVAILABLE_TYPE_IN_2_66 GLIB_UNAVAILABLE_TYPE(2, 66) +#else +# define GLIB_AVAILABLE_IN_2_66 _GLIB_EXTERN +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_66 +# define GLIB_AVAILABLE_MACRO_IN_2_66 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_66 +# define GLIB_AVAILABLE_TYPE_IN_2_66 +#endif + +#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68 +# define GLIB_DEPRECATED_IN_2_68 GLIB_DEPRECATED +# define GLIB_DEPRECATED_IN_2_68_FOR(f) GLIB_DEPRECATED_FOR(f) +# define GLIB_DEPRECATED_MACRO_IN_2_68 GLIB_DEPRECATED_MACRO +# define GLIB_DEPRECATED_MACRO_IN_2_68_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_68 GLIB_DEPRECATED_ENUMERATOR +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_68 GLIB_DEPRECATED_TYPE +# define GLIB_DEPRECATED_TYPE_IN_2_68_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) +#else +# define GLIB_DEPRECATED_IN_2_68 _GLIB_EXTERN +# define GLIB_DEPRECATED_IN_2_68_FOR(f) _GLIB_EXTERN +# define GLIB_DEPRECATED_MACRO_IN_2_68 +# define GLIB_DEPRECATED_MACRO_IN_2_68_FOR(f) +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_68 +# define GLIB_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) +# define GLIB_DEPRECATED_TYPE_IN_2_68 +# define GLIB_DEPRECATED_TYPE_IN_2_68_FOR(f) +#endif + +#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_68 +# define GLIB_AVAILABLE_IN_2_68 GLIB_UNAVAILABLE(2, 68) +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_68 GLIB_UNAVAILABLE_STATIC_INLINE(2, 68) +# define GLIB_AVAILABLE_MACRO_IN_2_68 GLIB_UNAVAILABLE_MACRO(2, 68) +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_68 GLIB_UNAVAILABLE_ENUMERATOR(2, 68) +# define GLIB_AVAILABLE_TYPE_IN_2_68 GLIB_UNAVAILABLE_TYPE(2, 68) +#else +# define GLIB_AVAILABLE_IN_2_68 _GLIB_EXTERN +# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_68 +# define GLIB_AVAILABLE_MACRO_IN_2_68 +# define GLIB_AVAILABLE_ENUMERATOR_IN_2_68 +# define GLIB_AVAILABLE_TYPE_IN_2_68 +#endif + +#endif /* __G_VERSION_MACROS_H__ */ +#include + +G_BEGIN_DECLS + +/* Provide type definitions for commonly used types. + * These are useful because a "gint8" can be adjusted + * to be 1 byte (8 bits) on all platforms. Similarly and + * more importantly, "gint32" can be adjusted to be + * 4 bytes (32 bits) on all platforms. + */ + +typedef char gchar; +typedef short gshort; +typedef long glong; +typedef int gint; +typedef gint gboolean; + +typedef unsigned char guchar; +typedef unsigned short gushort; +typedef unsigned long gulong; +typedef unsigned int guint; + +typedef float gfloat; +typedef double gdouble; + +/* Define min and max constants for the fixed size numerical types */ +/** + * G_MININT8: (value -128) + * + * The minimum value which can be held in a #gint8. + * + * Since: 2.4 + */ +#define G_MININT8 ((gint8) (-G_MAXINT8 - 1)) +#define G_MAXINT8 ((gint8) 0x7f) +#define G_MAXUINT8 ((guint8) 0xff) + +/** + * G_MININT16: (value -32768) + * + * The minimum value which can be held in a #gint16. + * + * Since: 2.4 + */ +#define G_MININT16 ((gint16) (-G_MAXINT16 - 1)) +#define G_MAXINT16 ((gint16) 0x7fff) +#define G_MAXUINT16 ((guint16) 0xffff) + +/** + * G_MININT32: (value -2147483648) + * + * The minimum value which can be held in a #gint32. + * + * Since: 2.4 + */ +#define G_MININT32 ((gint32) (-G_MAXINT32 - 1)) +#define G_MAXINT32 ((gint32) 0x7fffffff) +#define G_MAXUINT32 ((guint32) 0xffffffff) + +/** + * G_MININT64: (value -9223372036854775808) + * + * The minimum value which can be held in a #gint64. + */ +#define G_MININT64 ((gint64) (-G_MAXINT64 - G_GINT64_CONSTANT(1))) +#define G_MAXINT64 G_GINT64_CONSTANT(0x7fffffffffffffff) +#define G_MAXUINT64 G_GUINT64_CONSTANT(0xffffffffffffffff) + +typedef void* gpointer; +typedef const void *gconstpointer; + +typedef gint (*GCompareFunc) (gconstpointer a, + gconstpointer b); +typedef gint (*GCompareDataFunc) (gconstpointer a, + gconstpointer b, + gpointer user_data); +typedef gboolean (*GEqualFunc) (gconstpointer a, + gconstpointer b); +typedef void (*GDestroyNotify) (gpointer data); +typedef void (*GFunc) (gpointer data, + gpointer user_data); +typedef guint (*GHashFunc) (gconstpointer key); +typedef void (*GHFunc) (gpointer key, + gpointer value, + gpointer user_data); + +/** + * GCopyFunc: + * @src: (not nullable): A pointer to the data which should be copied + * @data: Additional data + * + * A function of this signature is used to copy the node data + * when doing a deep-copy of a tree. + * + * Returns: (not nullable): A pointer to the copy + * + * Since: 2.4 + */ +typedef gpointer (*GCopyFunc) (gconstpointer src, + gpointer data); +/** + * GFreeFunc: + * @data: a data pointer + * + * Declares a type of function which takes an arbitrary + * data pointer argument and has no return value. It is + * not currently used in GLib or GTK+. + */ +typedef void (*GFreeFunc) (gpointer data); + +/** + * GTranslateFunc: + * @str: the untranslated string + * @data: user data specified when installing the function, e.g. + * in g_option_group_set_translate_func() + * + * The type of functions which are used to translate user-visible + * strings, for output. + * + * Returns: a translation of the string for the current locale. + * The returned string is owned by GLib and must not be freed. + */ +typedef const gchar * (*GTranslateFunc) (const gchar *str, + gpointer data); + + +/* Define some mathematical constants that aren't available + * symbolically in some strict ISO C implementations. + * + * Note that the large number of digits used in these definitions + * doesn't imply that GLib or current computers in general would be + * able to handle floating point numbers with an accuracy like this. + * It's mostly an exercise in futility and future proofing. For + * extended precision floating point support, look somewhere else + * than GLib. + */ +#define G_E 2.7182818284590452353602874713526624977572470937000 +#define G_LN2 0.69314718055994530941723212145817656807550013436026 +#define G_LN10 2.3025850929940456840179914546843642076011014886288 +#define G_PI 3.1415926535897932384626433832795028841971693993751 +#define G_PI_2 1.5707963267948966192313216916397514420985846996876 +#define G_PI_4 0.78539816339744830961566084581987572104929234984378 +#define G_SQRT2 1.4142135623730950488016887242096980785696718753769 + +/* Portable endian checks and conversions + * + * glibconfig.h defines G_BYTE_ORDER which expands to one of + * the below macros. + */ +#define G_LITTLE_ENDIAN 1234 +#define G_BIG_ENDIAN 4321 +#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */ + + +/* Basic bit swapping functions + */ +#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \ + (guint16) ((guint16) (val) >> 8) | \ + (guint16) ((guint16) (val) << 8))) + +#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ + (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ + (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ + (((guint32) (val) & (guint32) 0xff000000U) >> 24))) + +#define GUINT64_SWAP_LE_BE_CONSTANT(val) ((guint64) ( \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x00000000000000ffU)) << 56) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x000000000000ff00U)) << 40) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x0000000000ff0000U)) << 24) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x00000000ff000000U)) << 8) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x000000ff00000000U)) >> 8) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x0000ff0000000000U)) >> 24) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0x00ff000000000000U)) >> 40) | \ + (((guint64) (val) & \ + (guint64) G_GINT64_CONSTANT (0xff00000000000000U)) >> 56))) + +/* Arch specific stuff for speed + */ +#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) + +# if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3 +# define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((guint32) (val))) +# define GUINT64_SWAP_LE_BE(val) ((guint64) __builtin_bswap64 ((guint64) (val))) +# endif + +# if defined (__i386__) +# define GUINT16_SWAP_LE_BE_IA32(val) \ + (G_GNUC_EXTENSION \ + ({ guint16 __v, __x = ((guint16) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("rorw $8, %w0" \ + : "=r" (__v) \ + : "0" (__x) \ + : "cc"); \ + __v; })) +# if !defined (__i486__) && !defined (__i586__) \ + && !defined (__pentium__) && !defined (__i686__) \ + && !defined (__pentiumpro__) && !defined (__pentium4__) +# define GUINT32_SWAP_LE_BE_IA32(val) \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("rorw $8, %w0\n\t" \ + "rorl $16, %0\n\t" \ + "rorw $8, %w0" \ + : "=r" (__v) \ + : "0" (__x) \ + : "cc"); \ + __v; })) +# else /* 486 and higher has bswap */ +# define GUINT32_SWAP_LE_BE_IA32(val) \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("bswap %0" \ + : "=r" (__v) \ + : "0" (__x)); \ + __v; })) +# endif /* processor specific 32-bit stuff */ +# define GUINT64_SWAP_LE_BE_IA32(val) \ + (G_GNUC_EXTENSION \ + ({ union { guint64 __ll; \ + guint32 __l[2]; } __w, __r; \ + __w.__ll = ((guint64) (val)); \ + if (__builtin_constant_p (__w.__ll)) \ + __r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (__w.__ll); \ + else \ + { \ + __r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]); \ + __r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]); \ + } \ + __r.__ll; })) + /* Possibly just use the constant version and let gcc figure it out? */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA32 (val)) +# endif +# elif defined (__ia64__) +# define GUINT16_SWAP_LE_BE_IA64(val) \ + (G_GNUC_EXTENSION \ + ({ guint16 __v, __x = ((guint16) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ __volatile__ ("shl %0 = %1, 48 ;;" \ + "mux1 %0 = %0, @rev ;;" \ + : "=r" (__v) \ + : "r" (__x)); \ + __v; })) +# define GUINT32_SWAP_LE_BE_IA64(val) \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ __volatile__ ("shl %0 = %1, 32 ;;" \ + "mux1 %0 = %0, @rev ;;" \ + : "=r" (__v) \ + : "r" (__x)); \ + __v; })) +# define GUINT64_SWAP_LE_BE_IA64(val) \ + (G_GNUC_EXTENSION \ + ({ guint64 __v, __x = ((guint64) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \ + : "=r" (__v) \ + : "r" (__x)); \ + __v; })) +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA64 (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA64 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA64 (val)) +# endif +# elif defined (__x86_64__) +# define GUINT32_SWAP_LE_BE_X86_64(val) \ + (G_GNUC_EXTENSION \ + ({ guint32 __v, __x = ((guint32) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("bswapl %0" \ + : "=r" (__v) \ + : "0" (__x)); \ + __v; })) +# define GUINT64_SWAP_LE_BE_X86_64(val) \ + (G_GNUC_EXTENSION \ + ({ guint64 __v, __x = ((guint64) (val)); \ + if (__builtin_constant_p (__x)) \ + __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \ + else \ + __asm__ ("bswapq %0" \ + : "=r" (__v) \ + : "0" (__x)); \ + __v; })) + /* gcc seems to figure out optimal code for this on its own */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val)) +# endif +# else /* generic gcc */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) +# ifndef GUINT32_SWAP_LE_BE +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) +# endif +# ifndef GUINT64_SWAP_LE_BE +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val)) +# endif +# endif +#else /* generic */ +# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) +# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) +# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val)) +#endif /* generic */ + +#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val)) +#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val)) +#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \ + (((guint32) (val) & (guint32) 0xffff0000U) >> 16))) +#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \ + (((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \ + (((guint32) (val) & (guint32) 0xff00ff00U) >> 8))) + +/* The G*_TO_?E() macros are defined in glibconfig.h. + * The transformation is symmetric, so the FROM just maps to the TO. + */ +#define GINT16_FROM_LE(val) (GINT16_TO_LE (val)) +#define GUINT16_FROM_LE(val) (GUINT16_TO_LE (val)) +#define GINT16_FROM_BE(val) (GINT16_TO_BE (val)) +#define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val)) +#define GINT32_FROM_LE(val) (GINT32_TO_LE (val)) +#define GUINT32_FROM_LE(val) (GUINT32_TO_LE (val)) +#define GINT32_FROM_BE(val) (GINT32_TO_BE (val)) +#define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) + +#define GINT64_FROM_LE(val) (GINT64_TO_LE (val)) +#define GUINT64_FROM_LE(val) (GUINT64_TO_LE (val)) +#define GINT64_FROM_BE(val) (GINT64_TO_BE (val)) +#define GUINT64_FROM_BE(val) (GUINT64_TO_BE (val)) + +#define GLONG_FROM_LE(val) (GLONG_TO_LE (val)) +#define GULONG_FROM_LE(val) (GULONG_TO_LE (val)) +#define GLONG_FROM_BE(val) (GLONG_TO_BE (val)) +#define GULONG_FROM_BE(val) (GULONG_TO_BE (val)) + +#define GINT_FROM_LE(val) (GINT_TO_LE (val)) +#define GUINT_FROM_LE(val) (GUINT_TO_LE (val)) +#define GINT_FROM_BE(val) (GINT_TO_BE (val)) +#define GUINT_FROM_BE(val) (GUINT_TO_BE (val)) + +#define GSIZE_FROM_LE(val) (GSIZE_TO_LE (val)) +#define GSSIZE_FROM_LE(val) (GSSIZE_TO_LE (val)) +#define GSIZE_FROM_BE(val) (GSIZE_TO_BE (val)) +#define GSSIZE_FROM_BE(val) (GSSIZE_TO_BE (val)) + +/* Portable versions of host-network order stuff + */ +#define g_ntohl(val) (GUINT32_FROM_BE (val)) +#define g_ntohs(val) (GUINT16_FROM_BE (val)) +#define g_htonl(val) (GUINT32_TO_BE (val)) +#define g_htons(val) (GUINT16_TO_BE (val)) + +/* Overflow-checked unsigned integer arithmetic + */ +#ifndef _GLIB_TEST_OVERFLOW_FALLBACK +/* https://bugzilla.gnome.org/show_bug.cgi?id=769104 */ +#if __GNUC__ >= 5 && !defined(__INTEL_COMPILER) +#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS +#elif g_macro__has_builtin(__builtin_uadd_overflow) +#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS +#endif +#endif + +#define g_uint_checked_add(dest, a, b) \ + _GLIB_CHECKED_ADD_U32(dest, a, b) +#define g_uint_checked_mul(dest, a, b) \ + _GLIB_CHECKED_MUL_U32(dest, a, b) + +#define g_uint64_checked_add(dest, a, b) \ + _GLIB_CHECKED_ADD_U64(dest, a, b) +#define g_uint64_checked_mul(dest, a, b) \ + _GLIB_CHECKED_MUL_U64(dest, a, b) + +#if GLIB_SIZEOF_SIZE_T == 8 +#define g_size_checked_add(dest, a, b) \ + _GLIB_CHECKED_ADD_U64(dest, a, b) +#define g_size_checked_mul(dest, a, b) \ + _GLIB_CHECKED_MUL_U64(dest, a, b) +#else +#define g_size_checked_add(dest, a, b) \ + _GLIB_CHECKED_ADD_U32(dest, a, b) +#define g_size_checked_mul(dest, a, b) \ + _GLIB_CHECKED_MUL_U32(dest, a, b) +#endif + +/* The names of the following inlines are private. Use the macro + * definitions above. + */ +#ifdef _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS +static inline gboolean _GLIB_CHECKED_ADD_U32 (guint32 *dest, guint32 a, guint32 b) { + return !__builtin_uadd_overflow(a, b, dest); } +static inline gboolean _GLIB_CHECKED_MUL_U32 (guint32 *dest, guint32 a, guint32 b) { + return !__builtin_umul_overflow(a, b, dest); } +static inline gboolean _GLIB_CHECKED_ADD_U64 (guint64 *dest, guint64 a, guint64 b) { + G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64)); + return !__builtin_uaddll_overflow(a, b, (unsigned long long *) dest); } +static inline gboolean _GLIB_CHECKED_MUL_U64 (guint64 *dest, guint64 a, guint64 b) { + return !__builtin_umulll_overflow(a, b, (unsigned long long *) dest); } +#else +static inline gboolean _GLIB_CHECKED_ADD_U32 (guint32 *dest, guint32 a, guint32 b) { + *dest = a + b; return *dest >= a; } +static inline gboolean _GLIB_CHECKED_MUL_U32 (guint32 *dest, guint32 a, guint32 b) { + *dest = a * b; return !a || *dest / a == b; } +static inline gboolean _GLIB_CHECKED_ADD_U64 (guint64 *dest, guint64 a, guint64 b) { + *dest = a + b; return *dest >= a; } +static inline gboolean _GLIB_CHECKED_MUL_U64 (guint64 *dest, guint64 a, guint64 b) { + *dest = a * b; return !a || *dest / a == b; } +#endif + +/* IEEE Standard 754 Single Precision Storage Format (gfloat): + * + * 31 30 23 22 0 + * +--------+---------------+---------------+ + * | s 1bit | e[30:23] 8bit | f[22:0] 23bit | + * +--------+---------------+---------------+ + * B0------------------->B1------->B2-->B3--> + * + * IEEE Standard 754 Double Precision Storage Format (gdouble): + * + * 63 62 52 51 32 31 0 + * +--------+----------------+----------------+ +---------------+ + * | s 1bit | e[62:52] 11bit | f[51:32] 20bit | | f[31:0] 32bit | + * +--------+----------------+----------------+ +---------------+ + * B0--------------->B1---------->B2--->B3----> B4->B5->B6->B7-> + */ +/* subtract from biased_exponent to form base2 exponent (normal numbers) */ +typedef union _GDoubleIEEE754 GDoubleIEEE754; +typedef union _GFloatIEEE754 GFloatIEEE754; +#define G_IEEE754_FLOAT_BIAS (127) +#define G_IEEE754_DOUBLE_BIAS (1023) +/* multiply with base2 exponent to get base10 exponent (normal numbers) */ +#define G_LOG_2_BASE_10 (0.30102999566398119521) +#if G_BYTE_ORDER == G_LITTLE_ENDIAN +union _GFloatIEEE754 +{ + gfloat v_float; + struct { + guint mantissa : 23; + guint biased_exponent : 8; + guint sign : 1; + } mpn; +}; +union _GDoubleIEEE754 +{ + gdouble v_double; + struct { + guint mantissa_low : 32; + guint mantissa_high : 20; + guint biased_exponent : 11; + guint sign : 1; + } mpn; +}; +#elif G_BYTE_ORDER == G_BIG_ENDIAN +union _GFloatIEEE754 +{ + gfloat v_float; + struct { + guint sign : 1; + guint biased_exponent : 8; + guint mantissa : 23; + } mpn; +}; +union _GDoubleIEEE754 +{ + gdouble v_double; + struct { + guint sign : 1; + guint biased_exponent : 11; + guint mantissa_high : 20; + guint mantissa_low : 32; + } mpn; +}; +#else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */ +#error unknown ENDIAN type +#endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */ + +typedef struct _GTimeVal GTimeVal GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); + +struct _GTimeVal +{ + glong tv_sec; + glong tv_usec; +} GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); + +typedef gint grefcount; +typedef gint gatomicrefcount; /* should be accessed only using atomics */ + +G_END_DECLS + +/* We prefix variable declarations so they can + * properly get exported in Windows DLLs. + */ +#ifndef GLIB_VAR +# ifdef G_PLATFORM_WIN32 +# ifdef GLIB_STATIC_COMPILATION +# define GLIB_VAR extern +# else /* !GLIB_STATIC_COMPILATION */ +# ifdef GLIB_COMPILATION +# ifdef DLL_EXPORT +# define GLIB_VAR extern __declspec(dllexport) +# else /* !DLL_EXPORT */ +# define GLIB_VAR extern +# endif /* !DLL_EXPORT */ +# else /* !GLIB_COMPILATION */ +# define GLIB_VAR extern __declspec(dllimport) +# endif /* !GLIB_COMPILATION */ +# endif /* !GLIB_STATIC_COMPILATION */ +# else /* !G_PLATFORM_WIN32 */ +# define GLIB_VAR _GLIB_EXTERN +# endif /* !G_PLATFORM_WIN32 */ +#endif /* GLIB_VAR */ + +#endif /* __G_TYPES_H__ */ + +#if defined(__BIONIC__) && defined (GLIB_HAVE_ALLOCA_H) +# include +#elif defined(__GNUC__) +/* GCC does the right thing */ +# undef alloca +# define alloca(size) __builtin_alloca (size) +#elif defined (GLIB_HAVE_ALLOCA_H) +/* a native and working alloca.h is there */ +# include +#else /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */ +# if defined(_MSC_VER) || defined(__DMC__) +# include +# define alloca _alloca +# else /* !_MSC_VER && !__DMC__ */ +# ifdef _AIX +# pragma alloca +# else /* !_AIX */ +# ifndef alloca /* predefined by HP cc +Olibcalls */ +G_BEGIN_DECLS +char *alloca (); +G_END_DECLS +# endif /* !alloca */ +# endif /* !_AIX */ +# endif /* !_MSC_VER && !__DMC__ */ +#endif /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */ + +/** + * g_alloca: + * @size: number of bytes to allocate. + * + * Allocates @size bytes on the stack; these bytes will be freed when the current + * stack frame is cleaned up. This macro essentially just wraps the alloca() + * function present on most UNIX variants. + * Thus it provides the same advantages and pitfalls as alloca(): + * + * - alloca() is very fast, as on most systems it's implemented by just adjusting + * the stack pointer register. + * + * - It doesn't cause any memory fragmentation, within its scope, separate alloca() + * blocks just build up and are released together at function end. + * + * - Allocation sizes have to fit into the current stack frame. For instance in a + * threaded environment on Linux, the per-thread stack size is limited to 2 Megabytes, + * so be sparse with alloca() uses. + * + * - Allocation failure due to insufficient stack space is not indicated with a %NULL + * return like e.g. with malloc(). Instead, most systems probably handle it the same + * way as out of stack space situations from infinite function recursion, i.e. + * with a segmentation fault. + * + * - Special care has to be taken when mixing alloca() with GNU C variable sized arrays. + * Stack space allocated with alloca() in the same scope as a variable sized array + * will be freed together with the variable sized array upon exit of that scope, and + * not upon exit of the enclosing function scope. + * + * Returns: space for @size bytes, allocated on the stack + */ +#define g_alloca(size) alloca (size) +/** + * g_newa: + * @struct_type: Type of memory chunks to be allocated + * @n_structs: Number of chunks to be allocated + * + * Wraps g_alloca() in a more typesafe manner. + * + * Returns: Pointer to stack space for @n_structs chunks of type @struct_type + */ +#define g_newa(struct_type, n_structs) ((struct_type*) g_alloca (sizeof (struct_type) * (gsize) (n_structs))) + +#endif /* __G_ALLOCA_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_ARRAY_H__ +#define __G_ARRAY_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GBytes GBytes; +typedef struct _GArray GArray; +typedef struct _GByteArray GByteArray; +typedef struct _GPtrArray GPtrArray; + +struct _GArray +{ + gchar *data; + guint len; +}; + +struct _GByteArray +{ + guint8 *data; + guint len; +}; + +struct _GPtrArray +{ + gpointer *pdata; + guint len; +}; + +/* Resizable arrays. remove fills any cleared spot and shortens the + * array, while preserving the order. remove_fast will distort the + * order by moving the last element to the position of the removed. + */ + +#define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1) +#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &(v), 1) +#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1) +#define g_array_index(a,t,i) (((t*) (void *) (a)->data) [(i)]) + +GLIB_AVAILABLE_IN_ALL +GArray* g_array_new (gboolean zero_terminated, + gboolean clear_, + guint element_size); +GLIB_AVAILABLE_IN_2_64 +gpointer g_array_steal (GArray *array, + gsize *len); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_sized_new (gboolean zero_terminated, + gboolean clear_, + guint element_size, + guint reserved_size); +GLIB_AVAILABLE_IN_2_62 +GArray* g_array_copy (GArray *array); +GLIB_AVAILABLE_IN_ALL +gchar* g_array_free (GArray *array, + gboolean free_segment); +GLIB_AVAILABLE_IN_ALL +GArray *g_array_ref (GArray *array); +GLIB_AVAILABLE_IN_ALL +void g_array_unref (GArray *array); +GLIB_AVAILABLE_IN_ALL +guint g_array_get_element_size (GArray *array); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_append_vals (GArray *array, + gconstpointer data, + guint len); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_prepend_vals (GArray *array, + gconstpointer data, + guint len); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_insert_vals (GArray *array, + guint index_, + gconstpointer data, + guint len); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_set_size (GArray *array, + guint length); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_remove_index (GArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_remove_index_fast (GArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +GArray* g_array_remove_range (GArray *array, + guint index_, + guint length); +GLIB_AVAILABLE_IN_ALL +void g_array_sort (GArray *array, + GCompareFunc compare_func); +GLIB_AVAILABLE_IN_ALL +void g_array_sort_with_data (GArray *array, + GCompareDataFunc compare_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_62 +gboolean g_array_binary_search (GArray *array, + gconstpointer target, + GCompareFunc compare_func, + guint *out_match_index); +GLIB_AVAILABLE_IN_ALL +void g_array_set_clear_func (GArray *array, + GDestroyNotify clear_func); + +/* Resizable pointer array. This interface is much less complicated + * than the above. Add appends a pointer. Remove fills any cleared + * spot and shortens the array. remove_fast will again distort order. + */ +#define g_ptr_array_index(array,index_) ((array)->pdata)[index_] +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_new (void); +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_new_with_free_func (GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_2_64 +gpointer* g_ptr_array_steal (GPtrArray *array, + gsize *len); +GLIB_AVAILABLE_IN_2_62 +GPtrArray *g_ptr_array_copy (GPtrArray *array, + GCopyFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_sized_new (guint reserved_size); +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_new_full (guint reserved_size, + GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_ALL +gpointer* g_ptr_array_free (GPtrArray *array, + gboolean free_seg); +GLIB_AVAILABLE_IN_ALL +GPtrArray* g_ptr_array_ref (GPtrArray *array); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_unref (GPtrArray *array); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_set_free_func (GPtrArray *array, + GDestroyNotify element_free_func); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_set_size (GPtrArray *array, + gint length); +GLIB_AVAILABLE_IN_ALL +gpointer g_ptr_array_remove_index (GPtrArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +gpointer g_ptr_array_remove_index_fast (GPtrArray *array, + guint index_); +GLIB_AVAILABLE_IN_2_58 +gpointer g_ptr_array_steal_index (GPtrArray *array, + guint index_); +GLIB_AVAILABLE_IN_2_58 +gpointer g_ptr_array_steal_index_fast (GPtrArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +gboolean g_ptr_array_remove (GPtrArray *array, + gpointer data); +GLIB_AVAILABLE_IN_ALL +gboolean g_ptr_array_remove_fast (GPtrArray *array, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GPtrArray *g_ptr_array_remove_range (GPtrArray *array, + guint index_, + guint length); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_add (GPtrArray *array, + gpointer data); +GLIB_AVAILABLE_IN_2_62 +void g_ptr_array_extend (GPtrArray *array_to_extend, + GPtrArray *array, + GCopyFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_62 +void g_ptr_array_extend_and_steal (GPtrArray *array_to_extend, + GPtrArray *array); +GLIB_AVAILABLE_IN_2_40 +void g_ptr_array_insert (GPtrArray *array, + gint index_, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_sort (GPtrArray *array, + GCompareFunc compare_func); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_sort_with_data (GPtrArray *array, + GCompareDataFunc compare_func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_ptr_array_foreach (GPtrArray *array, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_54 +gboolean g_ptr_array_find (GPtrArray *haystack, + gconstpointer needle, + guint *index_); +GLIB_AVAILABLE_IN_2_54 +gboolean g_ptr_array_find_with_equal_func (GPtrArray *haystack, + gconstpointer needle, + GEqualFunc equal_func, + guint *index_); + + +/* Byte arrays, an array of guint8. Implemented as a GArray, + * but type-safe. + */ + +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_new (void); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_new_take (guint8 *data, + gsize len); +GLIB_AVAILABLE_IN_2_64 +guint8* g_byte_array_steal (GByteArray *array, + gsize *len); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_sized_new (guint reserved_size); +GLIB_AVAILABLE_IN_ALL +guint8* g_byte_array_free (GByteArray *array, + gboolean free_segment); +GLIB_AVAILABLE_IN_ALL +GBytes* g_byte_array_free_to_bytes (GByteArray *array); +GLIB_AVAILABLE_IN_ALL +GByteArray *g_byte_array_ref (GByteArray *array); +GLIB_AVAILABLE_IN_ALL +void g_byte_array_unref (GByteArray *array); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_append (GByteArray *array, + const guint8 *data, + guint len); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_prepend (GByteArray *array, + const guint8 *data, + guint len); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_set_size (GByteArray *array, + guint length); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_remove_index (GByteArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_remove_index_fast (GByteArray *array, + guint index_); +GLIB_AVAILABLE_IN_ALL +GByteArray* g_byte_array_remove_range (GByteArray *array, + guint index_, + guint length); +GLIB_AVAILABLE_IN_ALL +void g_byte_array_sort (GByteArray *array, + GCompareFunc compare_func); +GLIB_AVAILABLE_IN_ALL +void g_byte_array_sort_with_data (GByteArray *array, + GCompareDataFunc compare_func, + gpointer user_data); + +G_END_DECLS + +#endif /* __G_ARRAY_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_ASYNCQUEUE_H__ +#define __G_ASYNCQUEUE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_THREAD_H__ +#define __G_THREAD_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* + * Copyright © 2011 Ryan Lortie + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_ATOMIC_H__ +#define __G_ATOMIC_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gint g_atomic_int_get (const volatile gint *atomic); +GLIB_AVAILABLE_IN_ALL +void g_atomic_int_set (volatile gint *atomic, + gint newval); +GLIB_AVAILABLE_IN_ALL +void g_atomic_int_inc (volatile gint *atomic); +GLIB_AVAILABLE_IN_ALL +gboolean g_atomic_int_dec_and_test (volatile gint *atomic); +GLIB_AVAILABLE_IN_ALL +gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic, + gint oldval, + gint newval); +GLIB_AVAILABLE_IN_ALL +gint g_atomic_int_add (volatile gint *atomic, + gint val); +GLIB_AVAILABLE_IN_2_30 +guint g_atomic_int_and (volatile guint *atomic, + guint val); +GLIB_AVAILABLE_IN_2_30 +guint g_atomic_int_or (volatile guint *atomic, + guint val); +GLIB_AVAILABLE_IN_ALL +guint g_atomic_int_xor (volatile guint *atomic, + guint val); + +GLIB_AVAILABLE_IN_ALL +gpointer g_atomic_pointer_get (const volatile void *atomic); +GLIB_AVAILABLE_IN_ALL +void g_atomic_pointer_set (volatile void *atomic, + gpointer newval); +GLIB_AVAILABLE_IN_ALL +gboolean g_atomic_pointer_compare_and_exchange (volatile void *atomic, + gpointer oldval, + gpointer newval); +GLIB_AVAILABLE_IN_ALL +gssize g_atomic_pointer_add (volatile void *atomic, + gssize val); +GLIB_AVAILABLE_IN_2_30 +gsize g_atomic_pointer_and (volatile void *atomic, + gsize val); +GLIB_AVAILABLE_IN_2_30 +gsize g_atomic_pointer_or (volatile void *atomic, + gsize val); +GLIB_AVAILABLE_IN_ALL +gsize g_atomic_pointer_xor (volatile void *atomic, + gsize val); + +GLIB_DEPRECATED_IN_2_30_FOR(g_atomic_int_add) +gint g_atomic_int_exchange_and_add (volatile gint *atomic, + gint val); + +G_END_DECLS + +#if defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) + +/* We prefer the new C11-style atomic extension of GCC if available */ +#if defined(__ATOMIC_SEQ_CST) + +#undef g_atomic_int_get +#define g_atomic_int_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + gint gaig_temp; \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + __atomic_load ((gint *)(atomic), &gaig_temp, __ATOMIC_SEQ_CST); \ + (gint) gaig_temp; \ + })) +#undef g_atomic_int_set +#define g_atomic_int_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + gint gais_temp = (gint) (newval); \ + (void) (0 ? *(atomic) ^ (newval) : 1); \ + __atomic_store ((gint *)(atomic), &gais_temp, __ATOMIC_SEQ_CST); \ + })) + +#if defined(glib_typeof) +#undef g_atomic_pointer_get +#define g_atomic_pointer_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + glib_typeof (*(atomic)) gapg_temp_newval; \ + glib_typeof ((atomic)) gapg_temp_atomic = (atomic); \ + __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ + gapg_temp_newval; \ + })) +#undef g_atomic_pointer_set +#define g_atomic_pointer_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + glib_typeof ((atomic)) gaps_temp_atomic = (atomic); \ + glib_typeof (*(atomic)) gaps_temp_newval = (newval); \ + (void) (0 ? (gpointer) * (atomic) : NULL); \ + __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ + })) +#else /* if !defined(glib_typeof) */ +#undef g_atomic_pointer_get +#define g_atomic_pointer_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + gpointer gapg_temp_newval; \ + gpointer *gapg_temp_atomic = (gpointer *)(atomic); \ + __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ + gapg_temp_newval; \ + })) +#undef g_atomic_pointer_set +#define g_atomic_pointer_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + gpointer *gaps_temp_atomic = (gpointer *)(atomic); \ + gpointer gaps_temp_newval = (gpointer)(newval); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ + })) +#endif /* !defined(glib_typeof) */ + +#undef g_atomic_int_inc +#define g_atomic_int_inc(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + (void) __atomic_fetch_add ((atomic), 1, __ATOMIC_SEQ_CST); \ + })) +#undef g_atomic_int_dec_and_test +#define g_atomic_int_dec_and_test(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + __atomic_fetch_sub ((atomic), 1, __ATOMIC_SEQ_CST) == 1; \ + })) +#undef g_atomic_int_compare_and_exchange +#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + gint gaicae_oldval = (oldval); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \ + __atomic_compare_exchange_n ((atomic), &gaicae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ + })) +#undef g_atomic_int_add +#define g_atomic_int_add(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (gint) __atomic_fetch_add ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) +#undef g_atomic_int_and +#define g_atomic_int_and(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __atomic_fetch_and ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) +#undef g_atomic_int_or +#define g_atomic_int_or(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __atomic_fetch_or ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) +#undef g_atomic_int_xor +#define g_atomic_int_xor(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __atomic_fetch_xor ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) + +#if defined(glib_typeof) +#undef g_atomic_pointer_compare_and_exchange +#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \ + glib_typeof ((oldval)) gapcae_oldval = (oldval); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ + })) +#else /* if !defined(glib_typeof) */ +#undef g_atomic_pointer_compare_and_exchange +#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \ + gpointer gapcae_oldval = (gpointer)(oldval); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ + })) +#endif /* defined(glib_typeof) */ +#undef g_atomic_pointer_add +#define g_atomic_pointer_add(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gssize) __atomic_fetch_add ((atomic), (val), __ATOMIC_SEQ_CST); \ + })) +#undef g_atomic_pointer_and +#define g_atomic_pointer_and(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + gsize *gapa_atomic = (gsize *) (atomic); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gsize) __atomic_fetch_and (gapa_atomic, (val), __ATOMIC_SEQ_CST); \ + })) +#undef g_atomic_pointer_or +#define g_atomic_pointer_or(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + gsize *gapo_atomic = (gsize *) (atomic); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gsize) __atomic_fetch_or (gapo_atomic, (val), __ATOMIC_SEQ_CST); \ + })) +#undef g_atomic_pointer_xor +#define g_atomic_pointer_xor(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + gsize *gapx_atomic = (gsize *) (atomic); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gsize) __atomic_fetch_xor (gapx_atomic, (val), __ATOMIC_SEQ_CST); \ + })) + +#else /* defined(__ATOMIC_SEQ_CST) */ + +/* We want to achieve __ATOMIC_SEQ_CST semantics here. See + * https://en.cppreference.com/w/c/atomic/memory_order#Constants. For load + * operations, that means performing an *acquire*: + * > A load operation with this memory order performs the acquire operation on + * > the affected memory location: no reads or writes in the current thread can + * > be reordered before this load. All writes in other threads that release + * > the same atomic variable are visible in the current thread. + * + * “no reads or writes in the current thread can be reordered before this load” + * is implemented using a compiler barrier (a no-op `__asm__` section) to + * prevent instruction reordering. Writes in other threads are synchronised + * using `__sync_synchronize()`. It’s unclear from the GCC documentation whether + * `__sync_synchronize()` acts as a compiler barrier, hence our explicit use of + * one. + * + * For store operations, `__ATOMIC_SEQ_CST` means performing a *release*: + * > A store operation with this memory order performs the release operation: + * > no reads or writes in the current thread can be reordered after this store. + * > All writes in the current thread are visible in other threads that acquire + * > the same atomic variable (see Release-Acquire ordering below) and writes + * > that carry a dependency into the atomic variable become visible in other + * > threads that consume the same atomic (see Release-Consume ordering below). + * + * “no reads or writes in the current thread can be reordered after this store” + * is implemented using a compiler barrier to prevent instruction reordering. + * “All writes in the current thread are visible in other threads” is implemented + * using `__sync_synchronize()`; similarly for “writes that carry a dependency”. + */ +#undef g_atomic_int_get +#define g_atomic_int_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + gint gaig_result; \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + gaig_result = (gint) *(atomic); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + gaig_result; \ + })) +#undef g_atomic_int_set +#define g_atomic_int_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) : 1); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + *(atomic) = (newval); \ + })) +#undef g_atomic_pointer_get +#define g_atomic_pointer_get(atomic) \ + (G_GNUC_EXTENSION ({ \ + gpointer gapg_result; \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + gapg_result = (gpointer) *(atomic); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + gapg_result; \ + })) +#if defined(glib_typeof) +#undef g_atomic_pointer_set +#define g_atomic_pointer_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + *(atomic) = (glib_typeof (*(atomic))) (gsize) (newval); \ + })) +#else /* if !defined(glib_typeof) */ +#undef g_atomic_pointer_set +#define g_atomic_pointer_set(atomic, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __sync_synchronize (); \ + __asm__ __volatile__ ("" : : : "memory"); \ + *(atomic) = (gpointer) (gsize) (newval); \ + })) +#endif /* defined(glib_typeof) */ + +#undef g_atomic_int_inc +#define g_atomic_int_inc(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + (void) __sync_fetch_and_add ((atomic), 1); \ + })) +#undef g_atomic_int_dec_and_test +#define g_atomic_int_dec_and_test(atomic) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ *(atomic) : 1); \ + __sync_fetch_and_sub ((atomic), 1) == 1; \ + })) +#undef g_atomic_int_compare_and_exchange +#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \ + __sync_bool_compare_and_swap ((atomic), (oldval), (newval)) ? TRUE : FALSE; \ + })) +#undef g_atomic_int_add +#define g_atomic_int_add(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (gint) __sync_fetch_and_add ((atomic), (val)); \ + })) +#undef g_atomic_int_and +#define g_atomic_int_and(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __sync_fetch_and_and ((atomic), (val)); \ + })) +#undef g_atomic_int_or +#define g_atomic_int_or(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __sync_fetch_and_or ((atomic), (val)); \ + })) +#undef g_atomic_int_xor +#define g_atomic_int_xor(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ + (void) (0 ? *(atomic) ^ (val) : 1); \ + (guint) __sync_fetch_and_xor ((atomic), (val)); \ + })) + +#undef g_atomic_pointer_compare_and_exchange +#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + __sync_bool_compare_and_swap ((atomic), (oldval), (newval)) ? TRUE : FALSE; \ + })) +#undef g_atomic_pointer_add +#define g_atomic_pointer_add(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gssize) __sync_fetch_and_add ((atomic), (val)); \ + })) +#undef g_atomic_pointer_and +#define g_atomic_pointer_and(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gsize) __sync_fetch_and_and ((atomic), (val)); \ + })) +#undef g_atomic_pointer_or +#define g_atomic_pointer_or(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gsize) __sync_fetch_and_or ((atomic), (val)); \ + })) +#undef g_atomic_pointer_xor +#define g_atomic_pointer_xor(atomic, val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(atomic) : NULL); \ + (void) (0 ? (val) ^ (val) : 1); \ + (gsize) __sync_fetch_and_xor ((atomic), (val)); \ + })) + +#endif /* !defined(__ATOMIC_SEQ_CST) */ + +#else /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */ + +#undef g_atomic_int_get +#define g_atomic_int_get(atomic) \ + (_frida_g_atomic_int_get ((gint *) (atomic))) +#undef g_atomic_int_set +#define g_atomic_int_set(atomic, newval) \ + (_frida_g_atomic_int_set ((gint *) (atomic), (gint) (newval))) +#undef g_atomic_int_compare_and_exchange +#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ + (_frida_g_atomic_int_compare_and_exchange ((gint *) (atomic), (oldval), (newval))) +#undef g_atomic_int_add +#define g_atomic_int_add(atomic, val) \ + (_frida_g_atomic_int_add ((gint *) (atomic), (val))) +#undef g_atomic_int_and +#define g_atomic_int_and(atomic, val) \ + (_frida_g_atomic_int_and ((guint *) (atomic), (val))) +#undef g_atomic_int_or +#define g_atomic_int_or(atomic, val) \ + (_frida_g_atomic_int_or ((guint *) (atomic), (val))) +#undef g_atomic_int_xor +#define g_atomic_int_xor(atomic, val) \ + (_frida_g_atomic_int_xor ((guint *) (atomic), (val))) +#undef g_atomic_int_inc +#define g_atomic_int_inc(atomic) \ + (_frida_g_atomic_int_inc ((gint *) (atomic))) +#undef g_atomic_int_dec_and_test +#define g_atomic_int_dec_and_test(atomic) \ + (_frida_g_atomic_int_dec_and_test ((gint *) (atomic))) + +#undef g_atomic_pointer_get +#define g_atomic_pointer_get(atomic) \ + (_frida_g_atomic_pointer_get (atomic)) +#undef g_atomic_pointer_set +#define g_atomic_pointer_set(atomic, newval) \ + (_frida_g_atomic_pointer_set ((atomic), (gpointer) (newval))) +#undef g_atomic_pointer_compare_and_exchange +#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ + (_frida_g_atomic_pointer_compare_and_exchange ((atomic), (gpointer) (oldval), (gpointer) (newval))) +#undef g_atomic_pointer_add +#define g_atomic_pointer_add(atomic, val) \ + (_frida_g_atomic_pointer_add ((atomic), (gssize) (val))) +#undef g_atomic_pointer_and +#define g_atomic_pointer_and(atomic, val) \ + (_frida_g_atomic_pointer_and ((atomic), (gsize) (val))) +#undef g_atomic_pointer_or +#define g_atomic_pointer_or(atomic, val) \ + (_frida_g_atomic_pointer_or ((atomic), (gsize) (val))) +#undef g_atomic_pointer_xor +#define g_atomic_pointer_xor(atomic, val) \ + (_frida_g_atomic_pointer_xor ((atomic), (gsize) (val))) + +#endif /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */ + +#endif /* __G_ATOMIC_H__ */ +/* gerror.h - Error reporting system + * + * Copyright 2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_ERROR_H__ +#define __G_ERROR_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_QUARK_H__ +#define __G_QUARK_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef guint32 GQuark; + +/* Quarks (string<->id association) + */ +GLIB_AVAILABLE_IN_ALL +GQuark g_quark_try_string (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GQuark g_quark_from_static_string (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GQuark g_quark_from_string (const gchar *string); +GLIB_AVAILABLE_IN_ALL +const gchar * g_quark_to_string (GQuark quark) G_GNUC_CONST; + +#define G_DEFINE_QUARK(QN, q_n) \ +GQuark \ +q_n##_quark (void) \ +{ \ + static GQuark q; \ + \ + if G_UNLIKELY (q == 0) \ + q = g_quark_from_static_string (#QN); \ + \ + return q; \ +} + +GLIB_AVAILABLE_IN_ALL +const gchar * g_intern_string (const gchar *string); +GLIB_AVAILABLE_IN_ALL +const gchar * g_intern_static_string (const gchar *string); + +G_END_DECLS + +#endif /* __G_QUARK_H__ */ + +G_BEGIN_DECLS + +/** + * GError: + * @domain: error domain, e.g. #G_FILE_ERROR + * @code: error code, e.g. %G_FILE_ERROR_NOENT + * @message: human-readable informative error message + * + * The `GError` structure contains information about + * an error that has occurred. + */ +typedef struct _GError GError; + +struct _GError +{ + GQuark domain; + gint code; + gchar *message; +}; + +GLIB_AVAILABLE_IN_ALL +GError* g_error_new (GQuark domain, + gint code, + const gchar *format, + ...) G_GNUC_PRINTF (3, 4); + +GLIB_AVAILABLE_IN_ALL +GError* g_error_new_literal (GQuark domain, + gint code, + const gchar *message); +GLIB_AVAILABLE_IN_ALL +GError* g_error_new_valist (GQuark domain, + gint code, + const gchar *format, + va_list args) G_GNUC_PRINTF(3, 0); + +GLIB_AVAILABLE_IN_ALL +void g_error_free (GError *error); +GLIB_AVAILABLE_IN_ALL +GError* g_error_copy (const GError *error); + +GLIB_AVAILABLE_IN_ALL +gboolean g_error_matches (const GError *error, + GQuark domain, + gint code); + +/* if (err) *err = g_error_new(domain, code, format, ...), also has + * some sanity checks. + */ +GLIB_AVAILABLE_IN_ALL +void g_set_error (GError **err, + GQuark domain, + gint code, + const gchar *format, + ...) G_GNUC_PRINTF (4, 5); + +GLIB_AVAILABLE_IN_ALL +void g_set_error_literal (GError **err, + GQuark domain, + gint code, + const gchar *message); + +/* if (dest) *dest = src; also has some sanity checks. + */ +GLIB_AVAILABLE_IN_ALL +void g_propagate_error (GError **dest, + GError *src); + +/* if (err && *err) { g_error_free(*err); *err = NULL; } */ +GLIB_AVAILABLE_IN_ALL +void g_clear_error (GError **err); + +/* if (err) prefix the formatted string to the ->message */ +GLIB_AVAILABLE_IN_ALL +void g_prefix_error (GError **err, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); + +/* g_propagate_error then g_error_prefix on dest */ +GLIB_AVAILABLE_IN_ALL +void g_propagate_prefixed_error (GError **dest, + GError *src, + const gchar *format, + ...) G_GNUC_PRINTF (3, 4); + +G_END_DECLS + +#endif /* __G_ERROR_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_UTILS_H__ +#define __G_UTILS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* Define G_VA_COPY() to do the right thing for copying va_list variables. + * glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy. + */ +#if !defined (G_VA_COPY) +# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32)) +# define G_VA_COPY(ap1, ap2) (*(ap1) = *(ap2)) +# elif defined (G_VA_COPY_AS_ARRAY) +# define G_VA_COPY(ap1, ap2) memmove ((ap1), (ap2), sizeof (va_list)) +# else /* va_list is a pointer */ +# define G_VA_COPY(ap1, ap2) ((ap1) = (ap2)) +# endif /* va_list is a pointer */ +#endif /* !G_VA_COPY */ + +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_name (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_real_name (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_home_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_tmp_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_host_name (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_prgname (void); +GLIB_AVAILABLE_IN_ALL +void g_set_prgname (const gchar *prgname); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_application_name (void); +GLIB_AVAILABLE_IN_ALL +void g_set_application_name (const gchar *application_name); +GLIB_AVAILABLE_IN_2_64 +gchar * g_get_os_info (const gchar *key_name); + +/** + * G_OS_INFO_KEY_NAME: + * + * A key to get the name of the operating system excluding version information suitable for presentation to the user, e.g. "YoYoOS" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_NAME \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "NAME" + +/** + * G_OS_INFO_KEY_PRETTY_NAME: + * + * A key to get the name of the operating system in a format suitable for presentation to the user, e.g. "YoYoOS Foo" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_PRETTY_NAME \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "PRETTY_NAME" + +/** + * G_OS_INFO_KEY_VERSION: + * + * A key to get the operating system version suitable for presentation to the user, e.g. "42 (Foo)" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_VERSION \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "VERSION" + +/** + * G_OS_INFO_KEY_VERSION_CODENAME: + * + * A key to get a codename identifying the operating system release suitable for processing by scripts or usage in generated filenames, e.g. "foo" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_VERSION_CODENAME \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "VERSION_CODENAME" + +/** + * G_OS_INFO_KEY_VERSION_ID: + * + * A key to get the version of the operating system suitable for processing by scripts or usage in generated filenames, e.g. "42" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_VERSION_ID \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "VERSION_ID" + +/** + * G_OS_INFO_KEY_ID: + * + * A key to get an ID identifying the operating system suitable for processing by scripts or usage in generated filenames, e.g. "yoyoos" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_ID \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "ID" + +/** + * G_OS_INFO_KEY_HOME_URL: + * + * A key to get the homepage for the operating system, e.g. "https://www.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_HOME_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "HOME_URL" + +/** + * G_OS_INFO_KEY_DOCUMENTATION_URL: + * + * A key to get the documentation page for the operating system, e.g. "https://docs.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_DOCUMENTATION_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "DOCUMENTATION_URL" + +/** + * G_OS_INFO_KEY_SUPPORT_URL: + * + * A key to get the support page for the operating system, e.g. "https://support.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_SUPPORT_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "SUPPORT_URL" + +/** + * G_OS_INFO_KEY_BUG_REPORT_URL: + * + * A key to get the bug reporting page for the operating system, e.g. "https://bugs.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_BUG_REPORT_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "BUG_REPORT_URL" + +/** + * G_OS_INFO_KEY_PRIVACY_POLICY_URL: + * + * A key to get the privacy policy for the operating system, e.g. "https://privacy.yoyo-os.com/" + * + * Since: 2.64 + */ +#define G_OS_INFO_KEY_PRIVACY_POLICY_URL \ + GLIB_AVAILABLE_MACRO_IN_2_64 \ + "PRIVACY_POLICY_URL" + +GLIB_AVAILABLE_IN_ALL +void g_reload_user_special_dirs_cache (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_data_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_config_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_cache_dir (void); +GLIB_AVAILABLE_IN_ALL +const gchar * const * g_get_system_data_dirs (void); + +#ifdef G_OS_WIN32 +/* This function is not part of the public GLib API */ +GLIB_AVAILABLE_IN_ALL +const gchar * const * g_win32_get_system_data_dirs_for_module (void (*address_of_function)(void)); +#endif + +#if defined (G_OS_WIN32) && defined (G_CAN_INLINE) +/* This function is not part of the public GLib API either. Just call + * g_get_system_data_dirs() in your code, never mind that that is + * actually a macro and you will in fact call this inline function. + */ +static inline const gchar * const * +_g_win32_get_system_data_dirs (void) +{ + return g_win32_get_system_data_dirs_for_module ((void (*)(void)) &_g_win32_get_system_data_dirs); +} +#undef g_get_system_data_dirs +#define g_get_system_data_dirs _g_win32_get_system_data_dirs +#endif + +GLIB_AVAILABLE_IN_ALL +const gchar * const * g_get_system_config_dirs (void); + +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_runtime_dir (void); + +/** + * GUserDirectory: + * @G_USER_DIRECTORY_DESKTOP: the user's Desktop directory + * @G_USER_DIRECTORY_DOCUMENTS: the user's Documents directory + * @G_USER_DIRECTORY_DOWNLOAD: the user's Downloads directory + * @G_USER_DIRECTORY_MUSIC: the user's Music directory + * @G_USER_DIRECTORY_PICTURES: the user's Pictures directory + * @G_USER_DIRECTORY_PUBLIC_SHARE: the user's shared directory + * @G_USER_DIRECTORY_TEMPLATES: the user's Templates directory + * @G_USER_DIRECTORY_VIDEOS: the user's Movies directory + * @G_USER_N_DIRECTORIES: the number of enum values + * + * These are logical ids for special directories which are defined + * depending on the platform used. You should use g_get_user_special_dir() + * to retrieve the full path associated to the logical id. + * + * The #GUserDirectory enumeration can be extended at later date. Not + * every platform has a directory for every logical id in this + * enumeration. + * + * Since: 2.14 + */ +typedef enum { + G_USER_DIRECTORY_DESKTOP, + G_USER_DIRECTORY_DOCUMENTS, + G_USER_DIRECTORY_DOWNLOAD, + G_USER_DIRECTORY_MUSIC, + G_USER_DIRECTORY_PICTURES, + G_USER_DIRECTORY_PUBLIC_SHARE, + G_USER_DIRECTORY_TEMPLATES, + G_USER_DIRECTORY_VIDEOS, + + G_USER_N_DIRECTORIES +} GUserDirectory; + +GLIB_AVAILABLE_IN_ALL +const gchar * g_get_user_special_dir (GUserDirectory directory); + +/** + * GDebugKey: + * @key: the string + * @value: the flag + * + * Associates a string with a bit flag. + * Used in g_parse_debug_string(). + */ +typedef struct _GDebugKey GDebugKey; +struct _GDebugKey +{ + const gchar *key; + guint value; +}; + +/* Miscellaneous utility functions + */ +GLIB_AVAILABLE_IN_ALL +guint g_parse_debug_string (const gchar *string, + const GDebugKey *keys, + guint nkeys); + +GLIB_AVAILABLE_IN_ALL +gint g_snprintf (gchar *string, + gulong n, + gchar const *format, + ...) G_GNUC_PRINTF (3, 4); +GLIB_AVAILABLE_IN_ALL +gint g_vsnprintf (gchar *string, + gulong n, + gchar const *format, + va_list args) + G_GNUC_PRINTF(3, 0); + +GLIB_AVAILABLE_IN_ALL +void g_nullify_pointer (gpointer *nullify_location); + +typedef enum +{ + G_FORMAT_SIZE_DEFAULT = 0, + G_FORMAT_SIZE_LONG_FORMAT = 1 << 0, + G_FORMAT_SIZE_IEC_UNITS = 1 << 1, + G_FORMAT_SIZE_BITS = 1 << 2 +} GFormatSizeFlags; + +GLIB_AVAILABLE_IN_2_30 +gchar *g_format_size_full (guint64 size, + GFormatSizeFlags flags); +GLIB_AVAILABLE_IN_2_30 +gchar *g_format_size (guint64 size); + +GLIB_DEPRECATED_IN_2_30_FOR(g_format_size) +gchar *g_format_size_for_display (goffset size); + +#define g_ATEXIT(proc) (atexit (proc)) GLIB_DEPRECATED_MACRO_IN_2_32 +#define g_memmove(dest,src,len) \ + G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_40_FOR(memmove) + +/** + * GVoidFunc: + * + * Declares a type of function which takes no arguments + * and has no return value. It is used to specify the type + * function passed to g_atexit(). + */ +typedef void (*GVoidFunc) (void) GLIB_DEPRECATED_TYPE_IN_2_32; +#define ATEXIT(proc) g_ATEXIT(proc) GLIB_DEPRECATED_MACRO_IN_2_32 + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED +void g_atexit (GVoidFunc func); +G_GNUC_END_IGNORE_DEPRECATIONS + +#ifdef G_OS_WIN32 +/* It's a bad idea to wrap atexit() on Windows. If the GLib DLL calls + * atexit(), the function will be called when the GLib DLL is detached + * from the program, which is not what the caller wants. The caller + * wants the function to be called when it *itself* exits (or is + * detached, in case the caller, too, is a DLL). + */ +#if (defined(__MINGW_H) && !defined(_STDLIB_H_)) || (defined(_MSC_VER) && !defined(_INC_STDLIB)) +int atexit (void (*)(void)); +#endif +#undef g_atexit +#define g_atexit(func) atexit(func) GLIB_DEPRECATED_MACRO_IN_2_32 +#endif + + +/* Look for an executable in PATH, following execvp() rules */ +GLIB_AVAILABLE_IN_ALL +gchar* g_find_program_in_path (const gchar *program); + +/* Bit tests + * + * These are defined in a convoluted way because we want the compiler to + * be able to inline the code for performance reasons, but for + * historical reasons, we must continue to provide non-inline versions + * on our ABI. + * + * We define these as functions in gutils.c which are just implemented + * as calls to the _impl() versions in order to preserve the ABI. + */ + +#undef g_bit_nth_lsf +#define g_bit_nth_lsf(mask, nth_bit) g_bit_nth_lsf_impl(mask, nth_bit) +#undef g_bit_nth_msf +#define g_bit_nth_msf(mask, nth_bit) g_bit_nth_msf_impl(mask, nth_bit) +#undef g_bit_storage +#define g_bit_storage(number) g_bit_storage_impl(number) + +GLIB_AVAILABLE_IN_ALL +gint (g_bit_nth_lsf) (gulong mask, + gint nth_bit); +GLIB_AVAILABLE_IN_ALL +gint (g_bit_nth_msf) (gulong mask, + gint nth_bit); +GLIB_AVAILABLE_IN_ALL +guint (g_bit_storage) (gulong number); + +static inline gint +g_bit_nth_lsf_impl (gulong mask, + gint nth_bit) +{ + if (G_UNLIKELY (nth_bit < -1)) + nth_bit = -1; + while (nth_bit < ((GLIB_SIZEOF_LONG * 8) - 1)) + { + nth_bit++; + if (mask & (1UL << nth_bit)) + return nth_bit; + } + return -1; +} + +static inline gint +g_bit_nth_msf_impl (gulong mask, + gint nth_bit) +{ + if (nth_bit < 0 || G_UNLIKELY (nth_bit > GLIB_SIZEOF_LONG * 8)) + nth_bit = GLIB_SIZEOF_LONG * 8; + while (nth_bit > 0) + { + nth_bit--; + if (mask & (1UL << nth_bit)) + return nth_bit; + } + return -1; +} + +static inline guint +g_bit_storage_impl (gulong number) +{ +#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) + return G_LIKELY (number) ? + ((GLIB_SIZEOF_LONG * 8U - 1) ^ (guint) __builtin_clzl(number)) + 1 : 1; +#else + guint n_bits = 0; + + do + { + n_bits++; + number >>= 1; + } + while (number); + return n_bits; +#endif +} + +/* Crashes the program. */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_50 +#ifndef G_OS_WIN32 +# include +# define g_abort() abort () +#else +GLIB_AVAILABLE_IN_2_50 +G_NORETURN void g_abort (void) G_ANALYZER_NORETURN; +#endif +#endif + +/* + * This macro is deprecated. This DllMain() is too complex. It is + * recommended to write an explicit minimal DLlMain() that just saves + * the handle to the DLL and then use that handle instead, for + * instance passing it to + * g_win32_get_package_installation_directory_of_module(). + * + * On Windows, this macro defines a DllMain function that stores the + * actual DLL name that the code being compiled will be included in. + * STATIC should be empty or 'static'. DLL_NAME is the name of the + * (pointer to the) char array where the DLL name will be stored. If + * this is used, you must also include . If you need a more complex + * DLL entry point function, you cannot use this. + * + * On non-Windows platforms, expands to nothing. + */ + +#ifndef G_PLATFORM_WIN32 +# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) GLIB_DEPRECATED_MACRO_IN_2_26 +#else +# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) \ +static char *dll_name; \ + \ +BOOL WINAPI \ +DllMain (HINSTANCE hinstDLL, \ + DWORD fdwReason, \ + LPVOID lpvReserved) \ +{ \ + wchar_t wcbfr[1000]; \ + char *tem; \ + switch (fdwReason) \ + { \ + case DLL_PROCESS_ATTACH: \ + GetModuleFileNameW ((HMODULE) hinstDLL, wcbfr, G_N_ELEMENTS (wcbfr)); \ + tem = g_utf16_to_utf8 (wcbfr, -1, NULL, NULL, NULL); \ + dll_name = g_path_get_basename (tem); \ + g_free (tem); \ + break; \ + } \ + \ + return TRUE; \ +} GLIB_DEPRECATED_MACRO_IN_2_26 +#endif /* G_PLATFORM_WIN32 */ + +G_END_DECLS + +#endif /* __G_UTILS_H__ */ + +G_BEGIN_DECLS + +#define G_THREAD_ERROR g_thread_error_quark () +GLIB_AVAILABLE_IN_ALL +GQuark g_thread_error_quark (void); + +typedef enum +{ + G_THREAD_ERROR_AGAIN /* Resource temporarily unavailable */ +} GThreadError; + +typedef gpointer (*GThreadFunc) (gpointer data); +typedef void (*GThreadGarbageHandler) (gpointer data); + +typedef struct _GThreadCallbacks GThreadCallbacks; +typedef struct _GThread GThread; + +typedef union _GMutex GMutex; +typedef struct _GRecMutex GRecMutex; +typedef struct _GRWLock GRWLock; +typedef struct _GCond GCond; +typedef struct _GPrivate GPrivate; +typedef struct _GOnce GOnce; + +typedef enum +{ + G_PRIVATE_DESTROY_LATE = 1 << 0, + G_PRIVATE_DESTROY_LAST = 1 << 1, +} GPrivateFlags; + +struct _GThreadCallbacks +{ + void (*on_thread_init) (void); + void (*on_thread_realize) (void); + void (*on_thread_dispose) (void); + void (*on_thread_finalize) (void); +}; + +union _GMutex +{ + /*< private >*/ + gpointer p; + guint i[2]; +}; + +struct _GRWLock +{ + /*< private >*/ + gpointer p; + guint i[2]; +}; + +struct _GCond +{ + /*< private >*/ + gpointer p; + guint i[2]; +}; + +struct _GRecMutex +{ + /*< private >*/ + gpointer p; + guint i[2]; +}; + +#define G_PRIVATE_INIT(notify) \ + { NULL, (notify), 0, { NULL } } +#define G_PRIVATE_INIT_WITH_FLAGS(notify, flags) \ + { NULL, (notify), (flags), { NULL } } +struct _GPrivate +{ + /*< private >*/ + gpointer p; + GDestroyNotify notify; + GPrivateFlags flags; + gpointer future[1]; +}; + +typedef enum +{ + G_ONCE_STATUS_NOTCALLED, + G_ONCE_STATUS_PROGRESS, + G_ONCE_STATUS_READY +} GOnceStatus; + +#define G_ONCE_INIT { G_ONCE_STATUS_NOTCALLED, NULL } +struct _GOnce +{ + volatile GOnceStatus status; + volatile gpointer retval; +}; + +#define G_LOCK_NAME(name) g__ ## name ## _lock +#define G_LOCK_DEFINE_STATIC(name) static G_LOCK_DEFINE (name) +#define G_LOCK_DEFINE(name) GMutex G_LOCK_NAME (name) +#define G_LOCK_EXTERN(name) extern GMutex G_LOCK_NAME (name) + +#ifdef G_DEBUG_LOCKS +# define G_LOCK(name) G_STMT_START{ \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): locking: %s ", \ + __FILE__, __LINE__, G_STRFUNC, \ + #name); \ + g_mutex_lock (&G_LOCK_NAME (name)); \ + }G_STMT_END +# define G_UNLOCK(name) G_STMT_START{ \ + g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): unlocking: %s ", \ + __FILE__, __LINE__, G_STRFUNC, \ + #name); \ + g_mutex_unlock (&G_LOCK_NAME (name)); \ + }G_STMT_END +# define G_TRYLOCK(name) \ + (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "file %s: line %d (%s): try locking: %s ", \ + __FILE__, __LINE__, G_STRFUNC, \ + #name), g_mutex_trylock (&G_LOCK_NAME (name))) +#else /* !G_DEBUG_LOCKS */ +# define G_LOCK(name) g_mutex_lock (&G_LOCK_NAME (name)) +# define G_UNLOCK(name) g_mutex_unlock (&G_LOCK_NAME (name)) +# define G_TRYLOCK(name) g_mutex_trylock (&G_LOCK_NAME (name)) +#endif /* !G_DEBUG_LOCKS */ + +GLIB_VAR GThreadCallbacks *glib_thread_callbacks; +GLIB_AVAILABLE_IN_2_68 +void g_thread_set_callbacks (GThreadCallbacks *callbacks); +GLIB_AVAILABLE_IN_2_68 +void g_thread_set_garbage_handler (GThreadGarbageHandler handler, + gpointer user_data); +GLIB_AVAILABLE_IN_2_68 +gboolean g_thread_garbage_collect (void); + +GLIB_AVAILABLE_IN_2_32 +GThread * g_thread_ref (GThread *thread); +GLIB_AVAILABLE_IN_2_32 +void g_thread_unref (GThread *thread); +GLIB_AVAILABLE_IN_2_32 +GThread * g_thread_new (const gchar *name, + GThreadFunc func, + gpointer data); +GLIB_AVAILABLE_IN_2_32 +GThread * g_thread_try_new (const gchar *name, + GThreadFunc func, + gpointer data, + GError **error); +GLIB_AVAILABLE_IN_ALL +GThread * g_thread_self (void); +GLIB_AVAILABLE_IN_ALL +void g_thread_exit (gpointer retval); +GLIB_AVAILABLE_IN_ALL +gpointer g_thread_join (GThread *thread); +GLIB_AVAILABLE_IN_ALL +void g_thread_yield (void); + + +GLIB_AVAILABLE_IN_2_32 +void g_mutex_init (GMutex *mutex); +GLIB_AVAILABLE_IN_2_32 +void g_mutex_clear (GMutex *mutex); +GLIB_AVAILABLE_IN_ALL +void g_mutex_lock (GMutex *mutex); +GLIB_AVAILABLE_IN_ALL +gboolean g_mutex_trylock (GMutex *mutex); +GLIB_AVAILABLE_IN_ALL +void g_mutex_unlock (GMutex *mutex); + +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_init (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_clear (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_writer_lock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +gboolean g_rw_lock_writer_trylock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_writer_unlock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_reader_lock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +gboolean g_rw_lock_reader_trylock (GRWLock *rw_lock); +GLIB_AVAILABLE_IN_2_32 +void g_rw_lock_reader_unlock (GRWLock *rw_lock); + +GLIB_AVAILABLE_IN_2_32 +void g_rec_mutex_init (GRecMutex *rec_mutex); +GLIB_AVAILABLE_IN_2_32 +void g_rec_mutex_clear (GRecMutex *rec_mutex); +GLIB_AVAILABLE_IN_2_32 +void g_rec_mutex_lock (GRecMutex *rec_mutex); +GLIB_AVAILABLE_IN_2_32 +gboolean g_rec_mutex_trylock (GRecMutex *rec_mutex); +GLIB_AVAILABLE_IN_2_32 +void g_rec_mutex_unlock (GRecMutex *rec_mutex); + +GLIB_AVAILABLE_IN_2_32 +void g_cond_init (GCond *cond); +GLIB_AVAILABLE_IN_2_32 +void g_cond_clear (GCond *cond); +GLIB_AVAILABLE_IN_ALL +void g_cond_wait (GCond *cond, + GMutex *mutex); +GLIB_AVAILABLE_IN_ALL +void g_cond_signal (GCond *cond); +GLIB_AVAILABLE_IN_ALL +void g_cond_broadcast (GCond *cond); +GLIB_AVAILABLE_IN_2_32 +gboolean g_cond_wait_until (GCond *cond, + GMutex *mutex, + gint64 end_time); + +GLIB_AVAILABLE_IN_ALL +gpointer g_private_get (GPrivate *key); +GLIB_AVAILABLE_IN_ALL +void g_private_set (GPrivate *key, + gpointer value); +GLIB_AVAILABLE_IN_2_32 +void g_private_replace (GPrivate *key, + gpointer value); + +GLIB_AVAILABLE_IN_ALL +gpointer g_once_impl (GOnce *once, + GThreadFunc func, + gpointer arg); +GLIB_AVAILABLE_IN_ALL +gboolean g_once_init_enter (volatile void *location); +GLIB_AVAILABLE_IN_ALL +void g_once_init_leave (volatile void *location, + gsize result); + +/* Use C11-style atomic extensions to check the fast path for status=ready. If + * they are not available, fall back to using a mutex and condition variable in + * g_once_impl(). + * + * On the C11-style codepath, only the load of once->status needs to be atomic, + * as the writes to it and once->retval in g_once_impl() are related by a + * happens-before relation. Release-acquire semantics are defined such that any + * atomic/non-atomic write which happens-before a store/release is guaranteed to + * be seen by the load/acquire of the same atomic variable. */ +#if defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) && defined(__ATOMIC_SEQ_CST) +# define g_once(once, func, arg) \ + ((__atomic_load_n (&(once)->status, __ATOMIC_ACQUIRE) == G_ONCE_STATUS_READY) ? \ + (once)->retval : \ + g_once_impl ((once), (func), (arg))) +#else +# define g_once(once, func, arg) g_once_impl ((once), (func), (arg)) +#endif + +#ifdef __GNUC__ +#undef g_once_init_enter +# define g_once_init_enter(location) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ + (void) (0 ? (gpointer) *(location) : NULL); \ + (!g_atomic_pointer_get (location) && \ + _frida_g_once_init_enter (location)); \ + })) +#undef g_once_init_leave +# define g_once_init_leave(location, result) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ + 0 ? (void) (*(location) = (result)) : (void) 0; \ + _frida_g_once_init_leave ((location), (gsize) (result)); \ + })) +#else +#undef g_once_init_enter +# define g_once_init_enter(location) \ + (_frida_g_once_init_enter((location))) +#undef g_once_init_leave +# define g_once_init_leave(location, result) \ + (_frida_g_once_init_leave((location), (gsize) (result))) +#endif + +GLIB_AVAILABLE_IN_2_36 +guint g_get_num_processors (void); + +/** + * GMutexLocker: + * + * Opaque type. See g_mutex_locker_new() for details. + * Since: 2.44 + */ +typedef void GMutexLocker; + +/** + * g_mutex_locker_new: + * @mutex: a mutex to lock + * + * Lock @mutex and return a new #GMutexLocker. Unlock with + * g_mutex_locker_free(). Using g_mutex_unlock() on @mutex + * while a #GMutexLocker exists can lead to undefined behaviour. + * + * No allocation is performed, it is equivalent to a g_mutex_lock() call. + * + * This is intended to be used with g_autoptr(). Note that g_autoptr() + * is only available when using GCC or clang, so the following example + * will only work with those compilers: + * |[ + * typedef struct + * { + * ... + * GMutex mutex; + * ... + * } MyObject; + * + * static void + * my_object_do_stuff (MyObject *self) + * { + * g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&self->mutex); + * + * // Code with mutex locked here + * + * if (cond) + * // No need to unlock + * return; + * + * // Optionally early unlock + * g_clear_pointer (&locker, g_mutex_locker_free); + * + * // Code with mutex unlocked here + * } + * ]| + * + * Returns: a #GMutexLocker + * Since: 2.44 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +static inline GMutexLocker * +g_mutex_locker_new (GMutex *mutex) +{ + g_mutex_lock (mutex); + return (GMutexLocker *) mutex; +} + +/** + * g_mutex_locker_free: + * @locker: a GMutexLocker + * + * Unlock @locker's mutex. See g_mutex_locker_new() for details. + * + * No memory is freed, it is equivalent to a g_mutex_unlock() call. + * + * Since: 2.44 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +static inline void +g_mutex_locker_free (GMutexLocker *locker) +{ + g_mutex_unlock ((GMutex *) locker); +} + +/** + * GRecMutexLocker: + * + * Opaque type. See g_rec_mutex_locker_new() for details. + * Since: 2.60 + */ +typedef void GRecMutexLocker; + +/** + * g_rec_mutex_locker_new: + * @rec_mutex: a recursive mutex to lock + * + * Lock @rec_mutex and return a new #GRecMutexLocker. Unlock with + * g_rec_mutex_locker_free(). Using g_rec_mutex_unlock() on @rec_mutex + * while a #GRecMutexLocker exists can lead to undefined behaviour. + * + * No allocation is performed, it is equivalent to a g_rec_mutex_lock() call. + * + * This is intended to be used with g_autoptr(). Note that g_autoptr() + * is only available when using GCC or clang, so the following example + * will only work with those compilers: + * |[ + * typedef struct + * { + * ... + * GRecMutex rec_mutex; + * ... + * } MyObject; + * + * static void + * my_object_do_stuff (MyObject *self) + * { + * g_autoptr(GRecMutexLocker) locker = g_rec_mutex_locker_new (&self->rec_mutex); + * + * // Code with rec_mutex locked here + * + * if (cond) + * // No need to unlock + * return; + * + * // Optionally early unlock + * g_clear_pointer (&locker, g_rec_mutex_locker_free); + * + * // Code with rec_mutex unlocked here + * } + * ]| + * + * Returns: a #GRecMutexLocker + * Since: 2.60 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 +static inline GRecMutexLocker * +g_rec_mutex_locker_new (GRecMutex *rec_mutex) +{ + g_rec_mutex_lock (rec_mutex); + return (GRecMutexLocker *) rec_mutex; +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * g_rec_mutex_locker_free: + * @locker: a GRecMutexLocker + * + * Unlock @locker's recursive mutex. See g_rec_mutex_locker_new() for details. + * + * No memory is freed, it is equivalent to a g_rec_mutex_unlock() call. + * + * Since: 2.60 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 +static inline void +g_rec_mutex_locker_free (GRecMutexLocker *locker) +{ + g_rec_mutex_unlock ((GRecMutex *) locker); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * GRWLockWriterLocker: + * + * Opaque type. See g_rw_lock_writer_locker_new() for details. + * Since: 2.62 + */ +typedef void GRWLockWriterLocker; + +/** + * g_rw_lock_writer_locker_new: + * @rw_lock: a #GRWLock + * + * Obtain a write lock on @rw_lock and return a new #GRWLockWriterLocker. + * Unlock with g_rw_lock_writer_locker_free(). Using g_rw_lock_writer_unlock() + * on @rw_lock while a #GRWLockWriterLocker exists can lead to undefined + * behaviour. + * + * No allocation is performed, it is equivalent to a g_rw_lock_writer_lock() call. + * + * This is intended to be used with g_autoptr(). Note that g_autoptr() + * is only available when using GCC or clang, so the following example + * will only work with those compilers: + * |[ + * typedef struct + * { + * ... + * GRWLock rw_lock; + * GPtrArray *array; + * ... + * } MyObject; + * + * static gchar * + * my_object_get_data (MyObject *self, guint index) + * { + * g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new (&self->rw_lock); + * + * // Code with a read lock obtained on rw_lock here + * + * if (self->array == NULL) + * // No need to unlock + * return NULL; + * + * if (index < self->array->len) + * // No need to unlock + * return g_ptr_array_index (self->array, index); + * + * // Optionally early unlock + * g_clear_pointer (&locker, g_rw_lock_reader_locker_free); + * + * // Code with rw_lock unlocked here + * return NULL; + * } + * + * static void + * my_object_set_data (MyObject *self, guint index, gpointer data) + * { + * g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&self->rw_lock); + * + * // Code with a write lock obtained on rw_lock here + * + * if (self->array == NULL) + * self->array = g_ptr_array_new (); + * + * if (cond) + * // No need to unlock + * return; + * + * if (index >= self->array->len) + * g_ptr_array_set_size (self->array, index+1); + * g_ptr_array_index (self->array, index) = data; + * + * // Optionally early unlock + * g_clear_pointer (&locker, g_rw_lock_writer_locker_free); + * + * // Code with rw_lock unlocked here + * } + * ]| + * + * Returns: a #GRWLockWriterLocker + * Since: 2.62 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +static inline GRWLockWriterLocker * +g_rw_lock_writer_locker_new (GRWLock *rw_lock) +{ + g_rw_lock_writer_lock (rw_lock); + return (GRWLockWriterLocker *) rw_lock; +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * g_rw_lock_writer_locker_free: + * @locker: a GRWLockWriterLocker + * + * Release a write lock on @locker's read-write lock. See + * g_rw_lock_writer_locker_new() for details. + * + * No memory is freed, it is equivalent to a g_rw_lock_writer_unlock() call. + * + * Since: 2.62 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +static inline void +g_rw_lock_writer_locker_free (GRWLockWriterLocker *locker) +{ + g_rw_lock_writer_unlock ((GRWLock *) locker); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * GRWLockReaderLocker: + * + * Opaque type. See g_rw_lock_reader_locker_new() for details. + * Since: 2.62 + */ +typedef void GRWLockReaderLocker; + +/** + * g_rw_lock_reader_locker_new: + * @rw_lock: a #GRWLock + * + * Obtain a read lock on @rw_lock and return a new #GRWLockReaderLocker. + * Unlock with g_rw_lock_reader_locker_free(). Using g_rw_lock_reader_unlock() + * on @rw_lock while a #GRWLockReaderLocker exists can lead to undefined + * behaviour. + * + * No allocation is performed, it is equivalent to a g_rw_lock_reader_lock() call. + * + * This is intended to be used with g_autoptr(). For a code sample, see + * g_rw_lock_writer_locker_new(). + * + * Returns: a #GRWLockReaderLocker + * Since: 2.62 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +static inline GRWLockReaderLocker * +g_rw_lock_reader_locker_new (GRWLock *rw_lock) +{ + g_rw_lock_reader_lock (rw_lock); + return (GRWLockReaderLocker *) rw_lock; +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * g_rw_lock_reader_locker_free: + * @locker: a GRWLockReaderLocker + * + * Release a read lock on @locker's read-write lock. See + * g_rw_lock_reader_locker_new() for details. + * + * No memory is freed, it is equivalent to a g_rw_lock_reader_unlock() call. + * + * Since: 2.62 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 +static inline void +g_rw_lock_reader_locker_free (GRWLockReaderLocker *locker) +{ + g_rw_lock_reader_unlock ((GRWLock *) locker); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_THREAD_H__ */ + +G_BEGIN_DECLS + +typedef struct _GAsyncQueue GAsyncQueue; + +GLIB_AVAILABLE_IN_ALL +GAsyncQueue *g_async_queue_new (void); +GLIB_AVAILABLE_IN_ALL +GAsyncQueue *g_async_queue_new_full (GDestroyNotify item_free_func); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_lock (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_unlock (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +GAsyncQueue *g_async_queue_ref (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_unref (GAsyncQueue *queue); + +GLIB_DEPRECATED_FOR(g_async_queue_ref) +void g_async_queue_ref_unlocked (GAsyncQueue *queue); + +GLIB_DEPRECATED_FOR(g_async_queue_unref) +void g_async_queue_unref_and_unlock (GAsyncQueue *queue); + +GLIB_AVAILABLE_IN_ALL +void g_async_queue_push (GAsyncQueue *queue, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_push_unlocked (GAsyncQueue *queue, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_push_sorted (GAsyncQueue *queue, + gpointer data, + GCompareDataFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_push_sorted_unlocked (GAsyncQueue *queue, + gpointer data, + GCompareDataFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_pop (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_pop_unlocked (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_try_pop (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_try_pop_unlocked (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_timeout_pop (GAsyncQueue *queue, + guint64 timeout); +GLIB_AVAILABLE_IN_ALL +gpointer g_async_queue_timeout_pop_unlocked (GAsyncQueue *queue, + guint64 timeout); +GLIB_AVAILABLE_IN_ALL +gint g_async_queue_length (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +gint g_async_queue_length_unlocked (GAsyncQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_sort (GAsyncQueue *queue, + GCompareDataFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_async_queue_sort_unlocked (GAsyncQueue *queue, + GCompareDataFunc func, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_46 +gboolean g_async_queue_remove (GAsyncQueue *queue, + gpointer item); +GLIB_AVAILABLE_IN_2_46 +gboolean g_async_queue_remove_unlocked (GAsyncQueue *queue, + gpointer item); +GLIB_AVAILABLE_IN_2_46 +void g_async_queue_push_front (GAsyncQueue *queue, + gpointer item); +GLIB_AVAILABLE_IN_2_46 +void g_async_queue_push_front_unlocked (GAsyncQueue *queue, + gpointer item); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_FOR(g_async_queue_timeout_pop) +gpointer g_async_queue_timed_pop (GAsyncQueue *queue, + GTimeVal *end_time); +GLIB_DEPRECATED_FOR(g_async_queue_timeout_pop_unlocked) +gpointer g_async_queue_timed_pop_unlocked (GAsyncQueue *queue, + GTimeVal *end_time); +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_ASYNCQUEUE_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_BACKTRACE_H__ +#define __G_BACKTRACE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#ifdef __sun__ +#include +#endif +#include + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +void g_on_error_query (const gchar *prg_name); +GLIB_AVAILABLE_IN_ALL +void g_on_error_stack_trace (const gchar *prg_name); + +/** + * G_BREAKPOINT: + * + * Inserts a breakpoint instruction into the code. + * + * On architectures which support it, this is implemented as a soft interrupt + * and on other architectures it raises a `SIGTRAP` signal. + * + * `SIGTRAP` is used rather than abort() to allow breakpoints to be skipped past + * in a debugger if they are not the desired target of debugging. + */ +#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__) && __GNUC__ >= 2 +# define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END +#elif (defined (_MSC_VER) || defined (__DMC__)) && defined (_M_IX86) +# define G_BREAKPOINT() G_STMT_START{ __asm int 3h }G_STMT_END +#elif defined (_MSC_VER) +# define G_BREAKPOINT() G_STMT_START{ __debugbreak(); }G_STMT_END +#elif defined (__alpha__) && !defined(__osf__) && defined (__GNUC__) && __GNUC__ >= 2 +# define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("bpt"); }G_STMT_END +#elif defined (__APPLE__) || (defined(_WIN32) && (defined(__clang__) || defined(__GNUC__))) +# define G_BREAKPOINT() G_STMT_START{ __builtin_trap(); }G_STMT_END +#else /* !__i386__ && !__alpha__ */ +# define G_BREAKPOINT() G_STMT_START{ raise (SIGTRAP); }G_STMT_END +#endif /* __i386__ */ + +G_END_DECLS + +#endif /* __G_BACKTRACE_H__ */ +/* gbase64.h - Base64 coding functions + * + * Copyright (C) 2005 Alexander Larsson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_BASE64_H__ +#define __G_BASE64_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gsize g_base64_encode_step (const guchar *in, + gsize len, + gboolean break_lines, + gchar *out, + gint *state, + gint *save); +GLIB_AVAILABLE_IN_ALL +gsize g_base64_encode_close (gboolean break_lines, + gchar *out, + gint *state, + gint *save); +GLIB_AVAILABLE_IN_ALL +gchar* g_base64_encode (const guchar *data, + gsize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gsize g_base64_decode_step (const gchar *in, + gsize len, + guchar *out, + gint *state, + guint *save); +GLIB_AVAILABLE_IN_ALL +guchar *g_base64_decode (const gchar *text, + gsize *out_len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +guchar *g_base64_decode_inplace (gchar *text, + gsize *out_len); + + +G_END_DECLS + +#endif /* __G_BASE64_H__ */ +/* + * Copyright © 2008 Ryan Lortie + * Copyright © 2010 Codethink Limited + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_BITLOCK_H__ +#define __G_BITLOCK_H__ + + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +void g_bit_lock (volatile gint *address, + gint lock_bit); +GLIB_AVAILABLE_IN_ALL +gboolean g_bit_trylock (volatile gint *address, + gint lock_bit); +GLIB_AVAILABLE_IN_ALL +void g_bit_unlock (volatile gint *address, + gint lock_bit); + +GLIB_AVAILABLE_IN_ALL +void g_pointer_bit_lock (volatile void *address, + gint lock_bit); +GLIB_AVAILABLE_IN_ALL +gboolean g_pointer_bit_trylock (volatile void *address, + gint lock_bit); +GLIB_AVAILABLE_IN_ALL +void g_pointer_bit_unlock (volatile void *address, + gint lock_bit); + +#ifdef __GNUC__ + +#undef g_pointer_bit_lock +#define g_pointer_bit_lock(address, lock_bit) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ + _frida_g_pointer_bit_lock ((address), (lock_bit)); \ + })) + +#undef g_pointer_bit_trylock +#define g_pointer_bit_trylock(address, lock_bit) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ + _frida_g_pointer_bit_trylock ((address), (lock_bit)); \ + })) + +#undef g_pointer_bit_unlock +#define g_pointer_bit_unlock(address, lock_bit) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ + _frida_g_pointer_bit_unlock ((address), (lock_bit)); \ + })) + +#endif + +G_END_DECLS + +#endif /* __G_BITLOCK_H_ */ +/* gbookmarkfile.h: parsing and building desktop bookmarks + * + * Copyright (C) 2005-2006 Emmanuele Bassi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_BOOKMARK_FILE_H__ +#define __G_BOOKMARK_FILE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* + * Copyright (C) 2009-2010 Christian Hergert + * Copyright © 2010 Codethink Limited + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * licence, or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + * + * Authors: Christian Hergert + * Thiago Santos + * Emmanuele Bassi + * Ryan Lortie + */ + +#ifndef __G_DATE_TIME_H__ +#define __G_DATE_TIME_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* + * Copyright © 2010 Codethink Limited + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_TIME_ZONE_H__ +#define __G_TIME_ZONE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GTimeZone GTimeZone; + +/** + * GTimeType: + * @G_TIME_TYPE_STANDARD: the time is in local standard time + * @G_TIME_TYPE_DAYLIGHT: the time is in local daylight time + * @G_TIME_TYPE_UNIVERSAL: the time is in UTC + * + * Disambiguates a given time in two ways. + * + * First, specifies if the given time is in universal or local time. + * + * Second, if the time is in local time, specifies if it is local + * standard time or local daylight time. This is important for the case + * where the same local time occurs twice (during daylight savings time + * transitions, for example). + */ +typedef enum +{ + G_TIME_TYPE_STANDARD, + G_TIME_TYPE_DAYLIGHT, + G_TIME_TYPE_UNIVERSAL +} GTimeType; + +GLIB_DEPRECATED_IN_2_68_FOR (g_time_zone_new_identifier) +GTimeZone * g_time_zone_new (const gchar *identifier); +GLIB_AVAILABLE_IN_2_68 +GTimeZone * g_time_zone_new_identifier (const gchar *identifier); +GLIB_AVAILABLE_IN_ALL +GTimeZone * g_time_zone_new_utc (void); +GLIB_AVAILABLE_IN_ALL +GTimeZone * g_time_zone_new_local (void); +GLIB_AVAILABLE_IN_2_58 +GTimeZone * g_time_zone_new_offset (gint32 seconds); + +GLIB_AVAILABLE_IN_ALL +GTimeZone * g_time_zone_ref (GTimeZone *tz); +GLIB_AVAILABLE_IN_ALL +void g_time_zone_unref (GTimeZone *tz); + +GLIB_AVAILABLE_IN_ALL +gint g_time_zone_find_interval (GTimeZone *tz, + GTimeType type, + gint64 time_); + +GLIB_AVAILABLE_IN_ALL +gint g_time_zone_adjust_time (GTimeZone *tz, + GTimeType type, + gint64 *time_); + +GLIB_AVAILABLE_IN_ALL +const gchar * g_time_zone_get_abbreviation (GTimeZone *tz, + gint interval); +GLIB_AVAILABLE_IN_ALL +gint32 g_time_zone_get_offset (GTimeZone *tz, + gint interval); +GLIB_AVAILABLE_IN_ALL +gboolean g_time_zone_is_dst (GTimeZone *tz, + gint interval); +GLIB_AVAILABLE_IN_2_58 +const gchar * g_time_zone_get_identifier (GTimeZone *tz); + +G_END_DECLS + +#endif /* __G_TIME_ZONE_H__ */ + +G_BEGIN_DECLS + +/** + * G_TIME_SPAN_DAY: + * + * Evaluates to a time span of one day. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000)) + +/** + * G_TIME_SPAN_HOUR: + * + * Evaluates to a time span of one hour. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000)) + +/** + * G_TIME_SPAN_MINUTE: + * + * Evaluates to a time span of one minute. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000)) + +/** + * G_TIME_SPAN_SECOND: + * + * Evaluates to a time span of one second. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000)) + +/** + * G_TIME_SPAN_MILLISECOND: + * + * Evaluates to a time span of one millisecond. + * + * Since: 2.26 + */ +#define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000)) + +/** + * GTimeSpan: + * + * A value representing an interval of time, in microseconds. + * + * Since: 2.26 + */ +typedef gint64 GTimeSpan; + +/** + * GDateTime: + * + * `GDateTime` is an opaque structure whose members + * cannot be accessed directly. + * + * Since: 2.26 + */ +typedef struct _GDateTime GDateTime; + +GLIB_AVAILABLE_IN_ALL +void g_date_time_unref (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_ref (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_now (GTimeZone *tz); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_now_local (void); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_now_utc (void); + +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_from_unix_local (gint64 t); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_from_unix_utc (gint64 t); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_local) +GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv); +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_utc) +GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_2_56 +GDateTime * g_date_time_new_from_iso8601 (const gchar *text, + GTimeZone *default_tz); + +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new (GTimeZone *tz, + gint year, + gint month, + gint day, + gint hour, + gint minute, + gdouble seconds); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_local (gint year, + gint month, + gint day, + gint hour, + gint minute, + gdouble seconds); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_new_utc (gint year, + gint month, + gint day, + gint hour, + gint minute, + gdouble seconds); + +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add (GDateTime *datetime, + GTimeSpan timespan); + +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_years (GDateTime *datetime, + gint years); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_months (GDateTime *datetime, + gint months); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_weeks (GDateTime *datetime, + gint weeks); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_days (GDateTime *datetime, + gint days); + +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_hours (GDateTime *datetime, + gint hours); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_minutes (GDateTime *datetime, + gint minutes); +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_seconds (GDateTime *datetime, + gdouble seconds); + +GLIB_AVAILABLE_IN_ALL +G_GNUC_WARN_UNUSED_RESULT +GDateTime * g_date_time_add_full (GDateTime *datetime, + gint years, + gint months, + gint days, + gint hours, + gint minutes, + gdouble seconds); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_compare (gconstpointer dt1, + gconstpointer dt2); +GLIB_AVAILABLE_IN_ALL +GTimeSpan g_date_time_difference (GDateTime *end, + GDateTime *begin); +GLIB_AVAILABLE_IN_ALL +guint g_date_time_hash (gconstpointer datetime); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_time_equal (gconstpointer dt1, + gconstpointer dt2); + +GLIB_AVAILABLE_IN_ALL +void g_date_time_get_ymd (GDateTime *datetime, + gint *year, + gint *month, + gint *day); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_year (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_month (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_day_of_month (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_week_numbering_year (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_week_of_year (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_day_of_week (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_day_of_year (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_hour (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_minute (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_second (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gint g_date_time_get_microsecond (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gdouble g_date_time_get_seconds (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gint64 g_date_time_to_unix (GDateTime *datetime); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_to_unix) +gboolean g_date_time_to_timeval (GDateTime *datetime, + GTimeVal *tv); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime); +GLIB_AVAILABLE_IN_2_58 +GTimeZone * g_date_time_get_timezone (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +const gchar * g_date_time_get_timezone_abbreviation (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_time_is_daylight_savings (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_to_timezone (GDateTime *datetime, + GTimeZone *tz); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_to_local (GDateTime *datetime); +GLIB_AVAILABLE_IN_ALL +GDateTime * g_date_time_to_utc (GDateTime *datetime); + +GLIB_AVAILABLE_IN_ALL +gchar * g_date_time_format (GDateTime *datetime, + const gchar *format) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_62 +gchar * g_date_time_format_iso8601 (GDateTime *datetime) G_GNUC_MALLOC; + +G_END_DECLS + +#endif /* __G_DATE_TIME_H__ */ +#include + +G_BEGIN_DECLS + +/** + * G_BOOKMARK_FILE_ERROR: + * + * Error domain for bookmark file parsing. + * Errors in this domain will be from the #GBookmarkFileError + * enumeration. See #GError for information on error domains. + */ +#define G_BOOKMARK_FILE_ERROR (g_bookmark_file_error_quark ()) + + +/** + * GBookmarkFileError: + * @G_BOOKMARK_FILE_ERROR_INVALID_URI: URI was ill-formed + * @G_BOOKMARK_FILE_ERROR_INVALID_VALUE: a requested field was not found + * @G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED: a requested application did + * not register a bookmark + * @G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND: a requested URI was not found + * @G_BOOKMARK_FILE_ERROR_READ: document was ill formed + * @G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was + * in an unknown encoding + * @G_BOOKMARK_FILE_ERROR_WRITE: an error occurred while writing + * @G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND: requested file was not found + * + * Error codes returned by bookmark file parsing. + */ +typedef enum +{ + G_BOOKMARK_FILE_ERROR_INVALID_URI, + G_BOOKMARK_FILE_ERROR_INVALID_VALUE, + G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED, + G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND, + G_BOOKMARK_FILE_ERROR_READ, + G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING, + G_BOOKMARK_FILE_ERROR_WRITE, + G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND +} GBookmarkFileError; + +GLIB_AVAILABLE_IN_ALL +GQuark g_bookmark_file_error_quark (void); + +/** + * GBookmarkFile: + * + * The `GBookmarkFile` structure contains only + * private data and should not be directly accessed. + */ +typedef struct _GBookmarkFile GBookmarkFile; + +GLIB_AVAILABLE_IN_ALL +GBookmarkFile *g_bookmark_file_new (void); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_free (GBookmarkFile *bookmark); + +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_load_from_file (GBookmarkFile *bookmark, + const gchar *filename, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_load_from_data (GBookmarkFile *bookmark, + const gchar *data, + gsize length, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_load_from_data_dirs (GBookmarkFile *bookmark, + const gchar *file, + gchar **full_path, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar * g_bookmark_file_to_data (GBookmarkFile *bookmark, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_to_file (GBookmarkFile *bookmark, + const gchar *filename, + GError **error); + +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_title (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *title); +GLIB_AVAILABLE_IN_ALL +gchar * g_bookmark_file_get_title (GBookmarkFile *bookmark, + const gchar *uri, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_description (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *description); +GLIB_AVAILABLE_IN_ALL +gchar * g_bookmark_file_get_description (GBookmarkFile *bookmark, + const gchar *uri, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_mime_type (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *mime_type); +GLIB_AVAILABLE_IN_ALL +gchar * g_bookmark_file_get_mime_type (GBookmarkFile *bookmark, + const gchar *uri, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_groups (GBookmarkFile *bookmark, + const gchar *uri, + const gchar **groups, + gsize length); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_add_group (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *group); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_has_group (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *group, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark, + const gchar *uri, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_add_application (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + const gchar *exec); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_has_application (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark, + const gchar *uri, + gsize *length, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_application_info) +gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + const gchar *exec, + gint count, + time_t stamp, + GError **error); +GLIB_AVAILABLE_IN_2_66 +gboolean g_bookmark_file_set_application_info (GBookmarkFile *bookmark, + const char *uri, + const char *name, + const char *exec, + int count, + GDateTime *stamp, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_application_info) +gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + gchar **exec, + guint *count, + time_t *stamp, + GError **error); +GLIB_AVAILABLE_IN_2_66 +gboolean g_bookmark_file_get_application_info (GBookmarkFile *bookmark, + const char *uri, + const char *name, + char **exec, + unsigned int *count, + GDateTime **stamp, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_is_private (GBookmarkFile *bookmark, + const gchar *uri, + gboolean is_private); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_bookmark_file_set_icon (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *href, + const gchar *mime_type); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark, + const gchar *uri, + gchar **href, + gchar **mime_type, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_added_date_time) +void g_bookmark_file_set_added (GBookmarkFile *bookmark, + const gchar *uri, + time_t added); +GLIB_AVAILABLE_IN_2_66 +void g_bookmark_file_set_added_date_time (GBookmarkFile *bookmark, + const char *uri, + GDateTime *added); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_added_date_time) +time_t g_bookmark_file_get_added (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_2_66 +GDateTime *g_bookmark_file_get_added_date_time (GBookmarkFile *bookmark, + const char *uri, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_modified_date_time) +void g_bookmark_file_set_modified (GBookmarkFile *bookmark, + const gchar *uri, + time_t modified); +GLIB_AVAILABLE_IN_2_66 +void g_bookmark_file_set_modified_date_time (GBookmarkFile *bookmark, + const char *uri, + GDateTime *modified); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_modified_date_time) +time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_2_66 +GDateTime *g_bookmark_file_get_modified_date_time (GBookmarkFile *bookmark, + const char *uri, + GError **error); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_visited_date_time) +void g_bookmark_file_set_visited (GBookmarkFile *bookmark, + const gchar *uri, + time_t visited); +GLIB_AVAILABLE_IN_2_66 +void g_bookmark_file_set_visited_date_time (GBookmarkFile *bookmark, + const char *uri, + GDateTime *visited); +GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_visited_date_time) +time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_2_66 +GDateTime *g_bookmark_file_get_visited_date_time (GBookmarkFile *bookmark, + const char *uri, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark, + const gchar *uri); +GLIB_AVAILABLE_IN_ALL +gint g_bookmark_file_get_size (GBookmarkFile *bookmark); +GLIB_AVAILABLE_IN_ALL +gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *group, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark, + const gchar *uri, + const gchar *name, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark, + const gchar *uri, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark, + const gchar *old_uri, + const gchar *new_uri, + GError **error); + +G_END_DECLS + +#endif /* __G_BOOKMARK_FILE_H__ */ +/* + * Copyright © 2009, 2010 Codethink Limited + * Copyright © 2011 Collabora Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + * Stef Walter + */ + +#ifndef __G_BYTES_H__ +#define __G_BYTES_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new (gconstpointer data, + gsize size); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new_take (gpointer data, + gsize size); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new_static (gconstpointer data, + gsize size); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new_with_free_func (gconstpointer data, + gsize size, + GDestroyNotify free_func, + gpointer user_data); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_new_from_bytes (GBytes *bytes, + gsize offset, + gsize length); + +GLIB_AVAILABLE_IN_ALL +gconstpointer g_bytes_get_data (GBytes *bytes, + gsize *size); + +GLIB_AVAILABLE_IN_ALL +gsize g_bytes_get_size (GBytes *bytes); + +GLIB_AVAILABLE_IN_ALL +GBytes * g_bytes_ref (GBytes *bytes); + +GLIB_AVAILABLE_IN_ALL +void g_bytes_unref (GBytes *bytes); + +GLIB_AVAILABLE_IN_ALL +gpointer g_bytes_unref_to_data (GBytes *bytes, + gsize *size); + +GLIB_AVAILABLE_IN_ALL +GByteArray * g_bytes_unref_to_array (GBytes *bytes); + +GLIB_AVAILABLE_IN_ALL +guint g_bytes_hash (gconstpointer bytes); + +GLIB_AVAILABLE_IN_ALL +gboolean g_bytes_equal (gconstpointer bytes1, + gconstpointer bytes2); + +GLIB_AVAILABLE_IN_ALL +gint g_bytes_compare (gconstpointer bytes1, + gconstpointer bytes2); + +G_END_DECLS + +#endif /* __G_BYTES_H__ */ +/* gcharset.h - Charset functions + * + * Copyright (C) 2011 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_CHARSET_H__ +#define __G_CHARSET_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gboolean g_get_charset (const char **charset); +GLIB_AVAILABLE_IN_ALL +gchar * g_get_codeset (void); +GLIB_AVAILABLE_IN_2_62 +gboolean g_get_console_charset (const char **charset); + +GLIB_AVAILABLE_IN_ALL +const gchar * const * g_get_language_names (void); +GLIB_AVAILABLE_IN_2_58 +const gchar * const * g_get_language_names_with_category + (const gchar *category_name); +GLIB_AVAILABLE_IN_ALL +gchar ** g_get_locale_variants (const gchar *locale); + +G_END_DECLS + +#endif /* __G_CHARSET_H__ */ +/* gchecksum.h - data hashing functions + * + * Copyright (C) 2007 Emmanuele Bassi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_CHECKSUM_H__ +#define __G_CHECKSUM_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * GChecksumType: + * @G_CHECKSUM_MD5: Use the MD5 hashing algorithm + * @G_CHECKSUM_SHA1: Use the SHA-1 hashing algorithm + * @G_CHECKSUM_SHA256: Use the SHA-256 hashing algorithm + * @G_CHECKSUM_SHA384: Use the SHA-384 hashing algorithm (Since: 2.51) + * @G_CHECKSUM_SHA512: Use the SHA-512 hashing algorithm (Since: 2.36) + * + * The hashing algorithm to be used by #GChecksum when performing the + * digest of some data. + * + * Note that the #GChecksumType enumeration may be extended at a later + * date to include new hashing algorithm types. + * + * Since: 2.16 + */ +typedef enum { + G_CHECKSUM_MD5, + G_CHECKSUM_SHA1, + G_CHECKSUM_SHA256, + G_CHECKSUM_SHA512, + G_CHECKSUM_SHA384 +} GChecksumType; + +/** + * GChecksum: + * + * An opaque structure representing a checksumming operation. + * To create a new GChecksum, use g_checksum_new(). To free + * a GChecksum, use g_checksum_free(). + * + * Since: 2.16 + */ +typedef struct _GChecksum GChecksum; + +GLIB_AVAILABLE_IN_ALL +gssize g_checksum_type_get_length (GChecksumType checksum_type); + +GLIB_AVAILABLE_IN_ALL +GChecksum * g_checksum_new (GChecksumType checksum_type); +GLIB_AVAILABLE_IN_ALL +void g_checksum_reset (GChecksum *checksum); +GLIB_AVAILABLE_IN_ALL +GChecksum * g_checksum_copy (const GChecksum *checksum); +GLIB_AVAILABLE_IN_ALL +void g_checksum_free (GChecksum *checksum); +GLIB_AVAILABLE_IN_ALL +void g_checksum_update (GChecksum *checksum, + const guchar *data, + gssize length); +GLIB_AVAILABLE_IN_ALL +const gchar * g_checksum_get_string (GChecksum *checksum); +GLIB_AVAILABLE_IN_ALL +void g_checksum_get_digest (GChecksum *checksum, + guint8 *buffer, + gsize *digest_len); + +GLIB_AVAILABLE_IN_ALL +gchar *g_compute_checksum_for_data (GChecksumType checksum_type, + const guchar *data, + gsize length); +GLIB_AVAILABLE_IN_ALL +gchar *g_compute_checksum_for_string (GChecksumType checksum_type, + const gchar *str, + gssize length); + +GLIB_AVAILABLE_IN_2_34 +gchar *g_compute_checksum_for_bytes (GChecksumType checksum_type, + GBytes *data); + +G_END_DECLS + +#endif /* __G_CHECKSUM_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_CONVERT_H__ +#define __G_CONVERT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * GConvertError: + * @G_CONVERT_ERROR_NO_CONVERSION: Conversion between the requested character + * sets is not supported. + * @G_CONVERT_ERROR_ILLEGAL_SEQUENCE: Invalid byte sequence in conversion input; + * or the character sequence could not be represented in the target + * character set. + * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason. + * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input. + * @G_CONVERT_ERROR_BAD_URI: URI is invalid. + * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path. + * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40 + * @G_CONVERT_ERROR_EMBEDDED_NUL: An embedded NUL character is present in + * conversion output where a NUL-terminated string is expected. + * Since: 2.56 + * + * Error codes returned by character set conversion routines. + */ +typedef enum +{ + G_CONVERT_ERROR_NO_CONVERSION, + G_CONVERT_ERROR_ILLEGAL_SEQUENCE, + G_CONVERT_ERROR_FAILED, + G_CONVERT_ERROR_PARTIAL_INPUT, + G_CONVERT_ERROR_BAD_URI, + G_CONVERT_ERROR_NOT_ABSOLUTE_PATH, + G_CONVERT_ERROR_NO_MEMORY, + G_CONVERT_ERROR_EMBEDDED_NUL +} GConvertError; + +/** + * G_CONVERT_ERROR: + * + * Error domain for character set conversions. Errors in this domain will + * be from the #GConvertError enumeration. See #GError for information on + * error domains. + */ +#define G_CONVERT_ERROR g_convert_error_quark() +GLIB_AVAILABLE_IN_ALL +GQuark g_convert_error_quark (void); + +/** + * GIConv: (skip) + * + * The GIConv struct wraps an iconv() conversion descriptor. It contains + * private data and should only be accessed using the following functions. + */ +typedef struct _GIConv *GIConv; + +GLIB_AVAILABLE_IN_ALL +GIConv g_iconv_open (const gchar *to_codeset, + const gchar *from_codeset); +GLIB_AVAILABLE_IN_ALL +gsize g_iconv (GIConv converter, + gchar **inbuf, + gsize *inbytes_left, + gchar **outbuf, + gsize *outbytes_left); +GLIB_AVAILABLE_IN_ALL +gint g_iconv_close (GIConv converter); + + +GLIB_AVAILABLE_IN_ALL +gchar* g_convert (const gchar *str, + gssize len, + const gchar *to_codeset, + const gchar *from_codeset, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_convert_with_iconv (const gchar *str, + gssize len, + GIConv converter, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_convert_with_fallback (const gchar *str, + gssize len, + const gchar *to_codeset, + const gchar *from_codeset, + const gchar *fallback, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; + + +/* Convert between libc's idea of strings and UTF-8. + */ +GLIB_AVAILABLE_IN_ALL +gchar* g_locale_to_utf8 (const gchar *opsysstring, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_locale_from_utf8 (const gchar *utf8string, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; + +/* Convert between the operating system (or C runtime) + * representation of file names and UTF-8. + */ +GLIB_AVAILABLE_IN_ALL +gchar* g_filename_to_utf8 (const gchar *opsysstring, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_filename_from_utf8 (const gchar *utf8string, + gssize len, + gsize *bytes_read, + gsize *bytes_written, + GError **error) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar *g_filename_from_uri (const gchar *uri, + gchar **hostname, + GError **error) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar *g_filename_to_uri (const gchar *filename, + const gchar *hostname, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gboolean g_get_filename_charsets (const gchar ***filename_charsets); + +GLIB_AVAILABLE_IN_ALL +gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar **g_uri_list_extract_uris (const gchar *uri_list); + +G_END_DECLS + +#endif /* __G_CONVERT_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_DATASET_H__ +#define __G_DATASET_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GData GData; + +typedef void (*GDataForeachFunc) (GQuark key_id, + gpointer data, + gpointer user_data); + +/* Keyed Data List + */ +GLIB_AVAILABLE_IN_ALL +void g_datalist_init (GData **datalist); +GLIB_AVAILABLE_IN_ALL +void g_datalist_clear (GData **datalist); +GLIB_AVAILABLE_IN_ALL +gpointer g_datalist_id_get_data (GData **datalist, + GQuark key_id); +GLIB_AVAILABLE_IN_ALL +void g_datalist_id_set_data_full (GData **datalist, + GQuark key_id, + gpointer data, + GDestroyNotify destroy_func); + +typedef gpointer (*GDuplicateFunc) (gpointer data, gpointer user_data); + +GLIB_AVAILABLE_IN_2_34 +gpointer g_datalist_id_dup_data (GData **datalist, + GQuark key_id, + GDuplicateFunc dup_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_34 +gboolean g_datalist_id_replace_data (GData **datalist, + GQuark key_id, + gpointer oldval, + gpointer newval, + GDestroyNotify destroy, + GDestroyNotify *old_destroy); + +GLIB_AVAILABLE_IN_ALL +gpointer g_datalist_id_remove_no_notify (GData **datalist, + GQuark key_id); +GLIB_AVAILABLE_IN_ALL +void g_datalist_foreach (GData **datalist, + GDataForeachFunc func, + gpointer user_data); + +/** + * G_DATALIST_FLAGS_MASK: + * + * A bitmask that restricts the possible flags passed to + * g_datalist_set_flags(). Passing a flags value where + * flags & ~G_DATALIST_FLAGS_MASK != 0 is an error. + */ +#define G_DATALIST_FLAGS_MASK 0x3 + +GLIB_AVAILABLE_IN_ALL +void g_datalist_set_flags (GData **datalist, + guint flags); +GLIB_AVAILABLE_IN_ALL +void g_datalist_unset_flags (GData **datalist, + guint flags); +GLIB_AVAILABLE_IN_ALL +guint g_datalist_get_flags (GData **datalist); + +#define g_datalist_id_set_data(dl, q, d) \ + g_datalist_id_set_data_full ((dl), (q), (d), NULL) +#define g_datalist_id_remove_data(dl, q) \ + g_datalist_id_set_data ((dl), (q), NULL) +#define g_datalist_set_data_full(dl, k, d, f) \ + g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f)) +#define g_datalist_remove_no_notify(dl, k) \ + g_datalist_id_remove_no_notify ((dl), g_quark_try_string (k)) +#define g_datalist_set_data(dl, k, d) \ + g_datalist_set_data_full ((dl), (k), (d), NULL) +#define g_datalist_remove_data(dl, k) \ + g_datalist_id_set_data ((dl), g_quark_try_string (k), NULL) + +/* Location Associated Keyed Data + */ +GLIB_AVAILABLE_IN_ALL +void g_dataset_destroy (gconstpointer dataset_location); +GLIB_AVAILABLE_IN_ALL +gpointer g_dataset_id_get_data (gconstpointer dataset_location, + GQuark key_id); +GLIB_AVAILABLE_IN_ALL +gpointer g_datalist_get_data (GData **datalist, + const gchar *key); +GLIB_AVAILABLE_IN_ALL +void g_dataset_id_set_data_full (gconstpointer dataset_location, + GQuark key_id, + gpointer data, + GDestroyNotify destroy_func); +GLIB_AVAILABLE_IN_ALL +gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, + GQuark key_id); +GLIB_AVAILABLE_IN_ALL +void g_dataset_foreach (gconstpointer dataset_location, + GDataForeachFunc func, + gpointer user_data); +#define g_dataset_id_set_data(l, k, d) \ + g_dataset_id_set_data_full ((l), (k), (d), NULL) +#define g_dataset_id_remove_data(l, k) \ + g_dataset_id_set_data ((l), (k), NULL) +#define g_dataset_get_data(l, k) \ + (g_dataset_id_get_data ((l), g_quark_try_string (k))) +#define g_dataset_set_data_full(l, k, d, f) \ + g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f)) +#define g_dataset_remove_no_notify(l, k) \ + g_dataset_id_remove_no_notify ((l), g_quark_try_string (k)) +#define g_dataset_set_data(l, k, d) \ + g_dataset_set_data_full ((l), (k), (d), NULL) +#define g_dataset_remove_data(l, k) \ + g_dataset_id_set_data ((l), g_quark_try_string (k), NULL) + +G_END_DECLS + +#endif /* __G_DATASET_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_DATE_H__ +#define __G_DATE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + + +G_BEGIN_DECLS + +/* GDate + * + * Date calculations (not time for now, to be resolved). These are a + * mutant combination of Steffen Beyer's DateCalc routines + * (http://www.perl.com/CPAN/authors/id/STBEY/) and Jon Trowbridge's + * date routines (written for in-house software). Written by Havoc + * Pennington + */ + +typedef gint32 GTime GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); +typedef guint16 GDateYear; +typedef guint8 GDateDay; /* day of the month */ +typedef struct _GDate GDate; + +/* enum used to specify order of appearance in parsed date strings */ +typedef enum +{ + G_DATE_DAY = 0, + G_DATE_MONTH = 1, + G_DATE_YEAR = 2 +} GDateDMY; + +/* actual week and month values */ +typedef enum +{ + G_DATE_BAD_WEEKDAY = 0, + G_DATE_MONDAY = 1, + G_DATE_TUESDAY = 2, + G_DATE_WEDNESDAY = 3, + G_DATE_THURSDAY = 4, + G_DATE_FRIDAY = 5, + G_DATE_SATURDAY = 6, + G_DATE_SUNDAY = 7 +} GDateWeekday; +typedef enum +{ + G_DATE_BAD_MONTH = 0, + G_DATE_JANUARY = 1, + G_DATE_FEBRUARY = 2, + G_DATE_MARCH = 3, + G_DATE_APRIL = 4, + G_DATE_MAY = 5, + G_DATE_JUNE = 6, + G_DATE_JULY = 7, + G_DATE_AUGUST = 8, + G_DATE_SEPTEMBER = 9, + G_DATE_OCTOBER = 10, + G_DATE_NOVEMBER = 11, + G_DATE_DECEMBER = 12 +} GDateMonth; + +#define G_DATE_BAD_JULIAN 0U +#define G_DATE_BAD_DAY 0U +#define G_DATE_BAD_YEAR 0U + +/* Note: directly manipulating structs is generally a bad idea, but + * in this case it's an *incredibly* bad idea, because all or part + * of this struct can be invalid at any given time. Use the functions, + * or you will get hosed, I promise. + */ +struct _GDate +{ + guint julian_days : 32; /* julian days representation - we use a + * bitfield hoping that 64 bit platforms + * will pack this whole struct in one big + * int + */ + + guint julian : 1; /* julian is valid */ + guint dmy : 1; /* dmy is valid */ + + /* DMY representation */ + guint day : 6; + guint month : 4; + guint year : 16; +}; + +/* g_date_new() returns an invalid date, you then have to _set() stuff + * to get a usable object. You can also allocate a GDate statically, + * then call g_date_clear() to initialize. + */ +GLIB_AVAILABLE_IN_ALL +GDate* g_date_new (void); +GLIB_AVAILABLE_IN_ALL +GDate* g_date_new_dmy (GDateDay day, + GDateMonth month, + GDateYear year); +GLIB_AVAILABLE_IN_ALL +GDate* g_date_new_julian (guint32 julian_day); +GLIB_AVAILABLE_IN_ALL +void g_date_free (GDate *date); +GLIB_AVAILABLE_IN_2_56 +GDate* g_date_copy (const GDate *date); + +/* check g_date_valid() after doing an operation that might fail, like + * _parse. Almost all g_date operations are undefined on invalid + * dates (the exceptions are the mutators, since you need those to + * return to validity). + */ +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid (const GDate *date); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_day (GDateDay day) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_month (GDateMonth month) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_year (GDateYear year) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_weekday (GDateWeekday weekday) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_julian (guint32 julian_date) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_date_valid_dmy (GDateDay day, + GDateMonth month, + GDateYear year) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +GDateWeekday g_date_get_weekday (const GDate *date); +GLIB_AVAILABLE_IN_ALL +GDateMonth g_date_get_month (const GDate *date); +GLIB_AVAILABLE_IN_ALL +GDateYear g_date_get_year (const GDate *date); +GLIB_AVAILABLE_IN_ALL +GDateDay g_date_get_day (const GDate *date); +GLIB_AVAILABLE_IN_ALL +guint32 g_date_get_julian (const GDate *date); +GLIB_AVAILABLE_IN_ALL +guint g_date_get_day_of_year (const GDate *date); +/* First monday/sunday is the start of week 1; if we haven't reached + * that day, return 0. These are not ISO weeks of the year; that + * routine needs to be added. + * these functions return the number of weeks, starting on the + * corrsponding day + */ +GLIB_AVAILABLE_IN_ALL +guint g_date_get_monday_week_of_year (const GDate *date); +GLIB_AVAILABLE_IN_ALL +guint g_date_get_sunday_week_of_year (const GDate *date); +GLIB_AVAILABLE_IN_ALL +guint g_date_get_iso8601_week_of_year (const GDate *date); + +/* If you create a static date struct you need to clear it to get it + * in a safe state before use. You can clear a whole array at + * once with the ndates argument. + */ +GLIB_AVAILABLE_IN_ALL +void g_date_clear (GDate *date, + guint n_dates); + +/* The parse routine is meant for dates typed in by a user, so it + * permits many formats but tries to catch common typos. If your data + * needs to be strictly validated, it is not an appropriate function. + */ +GLIB_AVAILABLE_IN_ALL +void g_date_set_parse (GDate *date, + const gchar *str); +GLIB_AVAILABLE_IN_ALL +void g_date_set_time_t (GDate *date, + time_t timet); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62_FOR(g_date_set_time_t) +void g_date_set_time_val (GDate *date, + GTimeVal *timeval); +GLIB_DEPRECATED_FOR(g_date_set_time_t) +void g_date_set_time (GDate *date, + GTime time_); +G_GNUC_END_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_ALL +void g_date_set_month (GDate *date, + GDateMonth month); +GLIB_AVAILABLE_IN_ALL +void g_date_set_day (GDate *date, + GDateDay day); +GLIB_AVAILABLE_IN_ALL +void g_date_set_year (GDate *date, + GDateYear year); +GLIB_AVAILABLE_IN_ALL +void g_date_set_dmy (GDate *date, + GDateDay day, + GDateMonth month, + GDateYear y); +GLIB_AVAILABLE_IN_ALL +void g_date_set_julian (GDate *date, + guint32 julian_date); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_is_first_of_month (const GDate *date); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_is_last_of_month (const GDate *date); + +/* To go forward by some number of weeks just go forward weeks*7 days */ +GLIB_AVAILABLE_IN_ALL +void g_date_add_days (GDate *date, + guint n_days); +GLIB_AVAILABLE_IN_ALL +void g_date_subtract_days (GDate *date, + guint n_days); + +/* If you add/sub months while day > 28, the day might change */ +GLIB_AVAILABLE_IN_ALL +void g_date_add_months (GDate *date, + guint n_months); +GLIB_AVAILABLE_IN_ALL +void g_date_subtract_months (GDate *date, + guint n_months); + +/* If it's feb 29, changing years can move you to the 28th */ +GLIB_AVAILABLE_IN_ALL +void g_date_add_years (GDate *date, + guint n_years); +GLIB_AVAILABLE_IN_ALL +void g_date_subtract_years (GDate *date, + guint n_years); +GLIB_AVAILABLE_IN_ALL +gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +guint8 g_date_get_days_in_month (GDateMonth month, + GDateYear year) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST; + +/* Returns the number of days between the two dates. If date2 comes + before date1, a negative value is return. */ +GLIB_AVAILABLE_IN_ALL +gint g_date_days_between (const GDate *date1, + const GDate *date2); + +/* qsort-friendly (with a cast...) */ +GLIB_AVAILABLE_IN_ALL +gint g_date_compare (const GDate *lhs, + const GDate *rhs); +GLIB_AVAILABLE_IN_ALL +void g_date_to_struct_tm (const GDate *date, + struct tm *tm); + +GLIB_AVAILABLE_IN_ALL +void g_date_clamp (GDate *date, + const GDate *min_date, + const GDate *max_date); + +/* Swap date1 and date2's values if date1 > date2. */ +GLIB_AVAILABLE_IN_ALL +void g_date_order (GDate *date1, GDate *date2); + +/* Just like strftime() except you can only use date-related formats. + * Using a time format is undefined. + */ +GLIB_AVAILABLE_IN_ALL +gsize g_date_strftime (gchar *s, + gsize slen, + const gchar *format, + const GDate *date); + +#define g_date_weekday g_date_get_weekday GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_weekday) +#define g_date_month g_date_get_month GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_month) +#define g_date_year g_date_get_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_year) +#define g_date_day g_date_get_day GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_day) +#define g_date_julian g_date_get_julian GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_julian) +#define g_date_day_of_year g_date_get_day_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_day_of_year) +#define g_date_monday_week_of_year g_date_get_monday_week_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_monday_week_of_year) +#define g_date_sunday_week_of_year g_date_get_sunday_week_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_sunday_week_of_year) +#define g_date_days_in_month g_date_get_days_in_month GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_days_in_month) +#define g_date_monday_weeks_in_year g_date_get_monday_weeks_in_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_monday_weeks_in_year) +#define g_date_sunday_weeks_in_year g_date_get_sunday_weeks_in_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_sunday_weeks_in_year) + +G_END_DECLS + +#endif /* __G_DATE_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * gdir.c: Simplified wrapper around the DIRENT functions. + * + * Copyright 2001 Hans Breuer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_DIR_H__ +#define __G_DIR_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +#ifdef G_OS_UNIX +#include +#endif + +G_BEGIN_DECLS + +typedef struct _GDir GDir; + +GLIB_AVAILABLE_IN_ALL +GDir * g_dir_open (const gchar *path, + guint flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +const gchar * g_dir_read_name (GDir *dir); +GLIB_AVAILABLE_IN_ALL +void g_dir_rewind (GDir *dir); +GLIB_AVAILABLE_IN_ALL +void g_dir_close (GDir *dir); + +G_END_DECLS + +#endif /* __G_DIR_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_ENVIRON_H__ +#define __G_ENVIRON_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +const gchar * g_getenv (const gchar *variable); +GLIB_AVAILABLE_IN_ALL +gboolean g_setenv (const gchar *variable, + const gchar *value, + gboolean overwrite); +GLIB_AVAILABLE_IN_ALL +void g_unsetenv (const gchar *variable); +GLIB_AVAILABLE_IN_ALL +gchar ** g_listenv (void); + +GLIB_AVAILABLE_IN_ALL +gchar ** g_get_environ (void); +GLIB_AVAILABLE_IN_ALL +const gchar * g_environ_getenv (gchar **envp, + const gchar *variable); +GLIB_AVAILABLE_IN_ALL +gchar ** g_environ_setenv (gchar **envp, + const gchar *variable, + const gchar *value, + gboolean overwrite) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gchar ** g_environ_unsetenv (gchar **envp, + const gchar *variable) G_GNUC_WARN_UNUSED_RESULT; + +G_END_DECLS + +#endif /* __G_ENVIRON_H__ */ +/* gfileutils.h - File utility functions + * + * Copyright 2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_FILEUTILS_H__ +#define __G_FILEUTILS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +#define G_FILE_ERROR g_file_error_quark () + +typedef enum +{ + G_FILE_ERROR_EXIST, + G_FILE_ERROR_ISDIR, + G_FILE_ERROR_ACCES, + G_FILE_ERROR_NAMETOOLONG, + G_FILE_ERROR_NOENT, + G_FILE_ERROR_NOTDIR, + G_FILE_ERROR_NXIO, + G_FILE_ERROR_NODEV, + G_FILE_ERROR_ROFS, + G_FILE_ERROR_TXTBSY, + G_FILE_ERROR_FAULT, + G_FILE_ERROR_LOOP, + G_FILE_ERROR_NOSPC, + G_FILE_ERROR_NOMEM, + G_FILE_ERROR_MFILE, + G_FILE_ERROR_NFILE, + G_FILE_ERROR_BADF, + G_FILE_ERROR_INVAL, + G_FILE_ERROR_PIPE, + G_FILE_ERROR_AGAIN, + G_FILE_ERROR_INTR, + G_FILE_ERROR_IO, + G_FILE_ERROR_PERM, + G_FILE_ERROR_NOSYS, + G_FILE_ERROR_FAILED +} GFileError; + +/* For backward-compat reasons, these are synced to an old + * anonymous enum in libgnome. But don't use that enum + * in new code. + */ +typedef enum +{ + G_FILE_TEST_IS_REGULAR = 1 << 0, + G_FILE_TEST_IS_SYMLINK = 1 << 1, + G_FILE_TEST_IS_DIR = 1 << 2, + G_FILE_TEST_IS_EXECUTABLE = 1 << 3, + G_FILE_TEST_EXISTS = 1 << 4 +} GFileTest; + +/** + * GFileSetContentsFlags: + * @G_FILE_SET_CONTENTS_NONE: No guarantees about file consistency or durability. + * The most dangerous setting, which is slightly faster than other settings. + * @G_FILE_SET_CONTENTS_CONSISTENT: Guarantee file consistency: after a crash, + * either the old version of the file or the new version of the file will be + * available, but not a mixture. On Unix systems this equates to an `fsync()` + * on the file and use of an atomic `rename()` of the new version of the file + * over the old. + * @G_FILE_SET_CONTENTS_DURABLE: Guarantee file durability: after a crash, the + * new version of the file will be available. On Unix systems this equates to + * an `fsync()` on the file (if %G_FILE_SET_CONTENTS_CONSISTENT is unset), or + * the effects of %G_FILE_SET_CONTENTS_CONSISTENT plus an `fsync()` on the + * directory containing the file after calling `rename()`. + * @G_FILE_SET_CONTENTS_ONLY_EXISTING: Only apply consistency and durability + * guarantees if the file already exists. This may speed up file operations + * if the file doesn’t currently exist, but may result in a corrupted version + * of the new file if the system crashes while writing it. + * + * Flags to pass to g_file_set_contents_full() to affect its safety and + * performance. + * + * Since: 2.66 + */ +typedef enum +{ + G_FILE_SET_CONTENTS_NONE = 0, + G_FILE_SET_CONTENTS_CONSISTENT = 1 << 0, + G_FILE_SET_CONTENTS_DURABLE = 1 << 1, + G_FILE_SET_CONTENTS_ONLY_EXISTING = 1 << 2 +} GFileSetContentsFlags +GLIB_AVAILABLE_ENUMERATOR_IN_2_66; + +GLIB_AVAILABLE_IN_ALL +GQuark g_file_error_quark (void); +/* So other code can generate a GFileError */ +GLIB_AVAILABLE_IN_ALL +GFileError g_file_error_from_errno (gint err_no); + +GLIB_AVAILABLE_IN_ALL +gboolean g_file_test (const gchar *filename, + GFileTest test); +GLIB_AVAILABLE_IN_ALL +gboolean g_file_get_contents (const gchar *filename, + gchar **contents, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_file_set_contents (const gchar *filename, + const gchar *contents, + gssize length, + GError **error); +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_2_66 +gboolean g_file_set_contents_full (const gchar *filename, + const gchar *contents, + gssize length, + GFileSetContentsFlags flags, + int mode, + GError **error); +G_GNUC_END_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_ALL +gchar *g_file_read_link (const gchar *filename, + GError **error); + +/* Wrapper / workalike for mkdtemp() */ +GLIB_AVAILABLE_IN_2_30 +gchar *g_mkdtemp (gchar *tmpl); +GLIB_AVAILABLE_IN_2_30 +gchar *g_mkdtemp_full (gchar *tmpl, + gint mode); + +/* Wrapper / workalike for mkstemp() */ +GLIB_AVAILABLE_IN_ALL +gint g_mkstemp (gchar *tmpl); +GLIB_AVAILABLE_IN_ALL +gint g_mkstemp_full (gchar *tmpl, + gint flags, + gint mode); + +/* Wrappers for g_mkstemp and g_mkdtemp() */ +GLIB_AVAILABLE_IN_ALL +gint g_file_open_tmp (const gchar *tmpl, + gchar **name_used, + GError **error); +GLIB_AVAILABLE_IN_2_30 +gchar *g_dir_make_tmp (const gchar *tmpl, + GError **error); + +GLIB_AVAILABLE_IN_ALL +gchar *g_build_path (const gchar *separator, + const gchar *first_element, + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +gchar *g_build_pathv (const gchar *separator, + gchar **args) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar *g_build_filename (const gchar *first_element, + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_56 +gchar *g_build_filename_valist (const gchar *first_element, + va_list *args) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gint g_mkdir_with_parents (const gchar *pathname, + gint mode); + +#ifdef G_OS_WIN32 + +/* On Win32, the canonical directory separator is the backslash, and + * the search path separator is the semicolon. Note that also the + * (forward) slash works as directory separator. + */ +#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/') + +#else /* !G_OS_WIN32 */ + +#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR) + +#endif /* !G_OS_WIN32 */ + +GLIB_AVAILABLE_IN_ALL +gboolean g_path_is_absolute (const gchar *file_name); +GLIB_AVAILABLE_IN_ALL +const gchar *g_path_skip_root (const gchar *file_name); + +GLIB_DEPRECATED_FOR(g_path_get_basename) +const gchar *g_basename (const gchar *file_name); +#define g_dirname g_path_get_dirname GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_path_get_dirname) + +GLIB_AVAILABLE_IN_ALL +gchar *g_get_current_dir (void); +GLIB_AVAILABLE_IN_ALL +gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_2_58 +gchar *g_canonicalize_filename (const gchar *filename, + const gchar *relative_to) G_GNUC_MALLOC; + +G_END_DECLS + +#endif /* __G_FILEUTILS_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_GETTEXT_H__ +#define __G_GETTEXT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +const gchar *g_strip_context (const gchar *msgid, + const gchar *msgval) G_GNUC_FORMAT(1); + +GLIB_AVAILABLE_IN_ALL +const gchar *g_dgettext (const gchar *domain, + const gchar *msgid) G_GNUC_FORMAT(2); +GLIB_AVAILABLE_IN_ALL +const gchar *g_dcgettext (const gchar *domain, + const gchar *msgid, + gint category) G_GNUC_FORMAT(2); +GLIB_AVAILABLE_IN_ALL +const gchar *g_dngettext (const gchar *domain, + const gchar *msgid, + const gchar *msgid_plural, + gulong n) G_GNUC_FORMAT(3); +GLIB_AVAILABLE_IN_ALL +const gchar *g_dpgettext (const gchar *domain, + const gchar *msgctxtid, + gsize msgidoffset) G_GNUC_FORMAT(2); +GLIB_AVAILABLE_IN_ALL +const gchar *g_dpgettext2 (const gchar *domain, + const gchar *context, + const gchar *msgid) G_GNUC_FORMAT(3); + +G_END_DECLS + +#endif /* __G_GETTEXT_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_HASH_H__ +#define __G_HASH_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_LIST_H__ +#define __G_LIST_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_MEM_H__ +#define __G_MEM_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * GMemVTable: + * @malloc: function to use for allocating memory. + * @realloc: function to use for reallocating memory. + * @free: function to use to free memory. + * @calloc: function to use for allocating zero-filled memory. + * @try_malloc: function to use for allocating memory without a default error handler. + * @try_realloc: function to use for reallocating memory without a default error handler. + * + * A set of functions used to perform memory allocation. The same #GMemVTable must + * be used for all allocations in the same program; a call to g_mem_set_vtable(), + * if it exists, should be prior to any use of GLib. + */ +typedef struct _GMemVTable GMemVTable; + + +#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG +/** + * G_MEM_ALIGN: + * + * Indicates the number of bytes to which memory will be aligned on the + * current platform. + */ +# define G_MEM_ALIGN GLIB_SIZEOF_VOID_P +#else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */ +# define G_MEM_ALIGN GLIB_SIZEOF_LONG +#endif /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */ + + +/* Memory allocation functions + */ + +GLIB_AVAILABLE_IN_ALL +void g_free (gpointer mem); + +GLIB_AVAILABLE_IN_2_34 +void g_clear_pointer (gpointer *pp, + GDestroyNotify destroy); + +GLIB_AVAILABLE_IN_ALL +gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_malloc0 (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_realloc (gpointer mem, + gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gpointer g_try_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_try_malloc0 (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_try_realloc (gpointer mem, + gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_ALL +gpointer g_malloc_n (gsize n_blocks, + gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_ALL +gpointer g_malloc0_n (gsize n_blocks, + gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_ALL +gpointer g_realloc_n (gpointer mem, + gsize n_blocks, + gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gpointer g_try_malloc_n (gsize n_blocks, + gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_ALL +gpointer g_try_malloc0_n (gsize n_blocks, + gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); +GLIB_AVAILABLE_IN_ALL +gpointer g_try_realloc_n (gpointer mem, + gsize n_blocks, + gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT; + +#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 +#undef g_clear_pointer +#define g_clear_pointer(pp, destroy) \ + G_STMT_START \ + { \ + G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ + glib_typeof ((pp)) _pp = (pp); \ + glib_typeof (*(pp)) _ptr = *_pp; \ + *_pp = NULL; \ + if (_ptr) \ + (destroy) (_ptr); \ + } \ + G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_34 +#else /* __GNUC__ */ +#undef g_clear_pointer +#define g_clear_pointer(pp, destroy) \ + G_STMT_START { \ + G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ + /* Only one access, please; work around type aliasing */ \ + union { char *in; gpointer *out; } _pp; \ + gpointer _p; \ + /* This assignment is needed to avoid a gcc warning */ \ + GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ + \ + _pp.in = (char *) (pp); \ + _p = *_pp.out; \ + if (_p) \ + { \ + *_pp.out = NULL; \ + _destroy (_p); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_34 +#endif /* __GNUC__ */ + +/** + * g_steal_pointer: + * @pp: (not nullable): a pointer to a pointer + * + * Sets @pp to %NULL, returning the value that was there before. + * + * Conceptually, this transfers the ownership of the pointer from the + * referenced variable to the "caller" of the macro (ie: "steals" the + * reference). + * + * The return value will be properly typed, according to the type of + * @pp. + * + * This can be very useful when combined with g_autoptr() to prevent the + * return value of a function from being automatically freed. Consider + * the following example (which only works on GCC and clang): + * + * |[ + * GObject * + * create_object (void) + * { + * g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL); + * + * if (early_error_case) + * return NULL; + * + * return g_steal_pointer (&obj); + * } + * ]| + * + * It can also be used in similar ways for 'out' parameters and is + * particularly useful for dealing with optional out parameters: + * + * |[ + * gboolean + * get_object (GObject **obj_out) + * { + * g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL); + * + * if (early_error_case) + * return FALSE; + * + * if (obj_out) + * *obj_out = g_steal_pointer (&obj); + * + * return TRUE; + * } + * ]| + * + * In the above example, the object will be automatically freed in the + * early error case and also in the case that %NULL was given for + * @obj_out. + * + * Since: 2.44 + */ +GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 +static inline gpointer +g_steal_pointer (gpointer pp) +{ + gpointer *ptr = (gpointer *) pp; + gpointer ref; + + ref = *ptr; + *ptr = NULL; + + return ref; +} + +/* type safety */ +#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 +#define g_steal_pointer(pp) ((glib_typeof (*pp)) (g_steal_pointer) (pp)) +#else /* __GNUC__ */ +/* This version does not depend on gcc extensions, but gcc does not warn + * about incompatible-pointer-types: */ +#define g_steal_pointer(pp) \ + (0 ? (*(pp)) : (g_steal_pointer) (pp)) +#endif /* __GNUC__ */ + +/* Optimise: avoid the call to the (slower) _n function if we can + * determine at compile-time that no overflow happens. + */ +#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) +# define _G_NEW(struct_type, n_structs, func) \ + (struct_type *) (G_GNUC_EXTENSION ({ \ + gsize __n = (gsize) (n_structs); \ + gsize __s = sizeof (struct_type); \ + gpointer __p; \ + if (__s == 1) \ + __p = g_##func (__n); \ + else if (__builtin_constant_p (__n) && \ + (__s == 0 || __n <= G_MAXSIZE / __s)) \ + __p = g_##func (__n * __s); \ + else \ + __p = g_##func##_n (__n, __s); \ + __p; \ + })) +# define _G_RENEW(struct_type, mem, n_structs, func) \ + (struct_type *) (G_GNUC_EXTENSION ({ \ + gsize __n = (gsize) (n_structs); \ + gsize __s = sizeof (struct_type); \ + gpointer __p = (gpointer) (mem); \ + if (__s == 1) \ + __p = g_##func (__p, __n); \ + else if (__builtin_constant_p (__n) && \ + (__s == 0 || __n <= G_MAXSIZE / __s)) \ + __p = g_##func (__p, __n * __s); \ + else \ + __p = g_##func##_n (__p, __n, __s); \ + __p; \ + })) + +#else + +/* Unoptimised version: always call the _n() function. */ + +#define _G_NEW(struct_type, n_structs, func) \ + ((struct_type *) g_##func##_n ((n_structs), sizeof (struct_type))) +#define _G_RENEW(struct_type, mem, n_structs, func) \ + ((struct_type *) g_##func##_n (mem, (n_structs), sizeof (struct_type))) + +#endif + +/** + * g_new: + * @struct_type: the type of the elements to allocate + * @n_structs: the number of elements to allocate + * + * Allocates @n_structs elements of type @struct_type. + * The returned pointer is cast to a pointer to the given type. + * If @n_structs is 0 it returns %NULL. + * Care is taken to avoid overflow when calculating the size of the allocated block. + * + * Since the returned pointer is already casted to the right type, + * it is normally unnecessary to cast it explicitly, and doing + * so might hide memory allocation errors. + * + * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type + */ +#define g_new(struct_type, n_structs) _G_NEW (struct_type, n_structs, malloc) +/** + * g_new0: + * @struct_type: the type of the elements to allocate. + * @n_structs: the number of elements to allocate. + * + * Allocates @n_structs elements of type @struct_type, initialized to 0's. + * The returned pointer is cast to a pointer to the given type. + * If @n_structs is 0 it returns %NULL. + * Care is taken to avoid overflow when calculating the size of the allocated block. + * + * Since the returned pointer is already casted to the right type, + * it is normally unnecessary to cast it explicitly, and doing + * so might hide memory allocation errors. + * + * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type. + */ +#define g_new0(struct_type, n_structs) _G_NEW (struct_type, n_structs, malloc0) +/** + * g_renew: + * @struct_type: the type of the elements to allocate + * @mem: the currently allocated memory + * @n_structs: the number of elements to allocate + * + * Reallocates the memory pointed to by @mem, so that it now has space for + * @n_structs elements of type @struct_type. It returns the new address of + * the memory, which may have been moved. + * Care is taken to avoid overflow when calculating the size of the allocated block. + * + * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type + */ +#define g_renew(struct_type, mem, n_structs) _G_RENEW (struct_type, mem, n_structs, realloc) +/** + * g_try_new: + * @struct_type: the type of the elements to allocate + * @n_structs: the number of elements to allocate + * + * Attempts to allocate @n_structs elements of type @struct_type, and returns + * %NULL on failure. Contrast with g_new(), which aborts the program on failure. + * The returned pointer is cast to a pointer to the given type. + * The function returns %NULL when @n_structs is 0 of if an overflow occurs. + * + * Since: 2.8 + * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type + */ +#define g_try_new(struct_type, n_structs) _G_NEW (struct_type, n_structs, try_malloc) +/** + * g_try_new0: + * @struct_type: the type of the elements to allocate + * @n_structs: the number of elements to allocate + * + * Attempts to allocate @n_structs elements of type @struct_type, initialized + * to 0's, and returns %NULL on failure. Contrast with g_new0(), which aborts + * the program on failure. + * The returned pointer is cast to a pointer to the given type. + * The function returns %NULL when @n_structs is 0 or if an overflow occurs. + * + * Since: 2.8 + * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type + */ +#define g_try_new0(struct_type, n_structs) _G_NEW (struct_type, n_structs, try_malloc0) +/** + * g_try_renew: + * @struct_type: the type of the elements to allocate + * @mem: the currently allocated memory + * @n_structs: the number of elements to allocate + * + * Attempts to reallocate the memory pointed to by @mem, so that it now has + * space for @n_structs elements of type @struct_type, and returns %NULL on + * failure. Contrast with g_renew(), which aborts the program on failure. + * It returns the new address of the memory, which may have been moved. + * The function returns %NULL if an overflow occurs. + * + * Since: 2.8 + * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type + */ +#define g_try_renew(struct_type, mem, n_structs) _G_RENEW (struct_type, mem, n_structs, try_realloc) + + +/* Memory allocation virtualization for debugging purposes + * g_mem_set_vtable() has to be the very first GLib function called + * if being used + */ +struct _GMemVTable { + gpointer (*malloc) (gsize n_bytes); + gpointer (*realloc) (gpointer mem, + gsize n_bytes); + /* optional; set to NULL if not supported */ + gpointer (*memalign) (gsize alignment, + gsize size); + void (*free) (gpointer mem); + /* optional; set to NULL if not used ! */ + gpointer (*calloc) (gsize n_blocks, + gsize n_block_bytes); + gpointer (*try_malloc) (gsize n_bytes); + gpointer (*try_realloc) (gpointer mem, + gsize n_bytes); +}; +GLIB_VAR GMemVTable *glib_mem_table; +GLIB_AVAILABLE_IN_ALL +void g_mem_set_vtable (GMemVTable *vtable); +GLIB_AVAILABLE_IN_ALL +gboolean g_mem_is_system_malloc (void); + +GLIB_VAR gboolean g_mem_gc_friendly; + +/* Memory profiler and checker, has to be enabled via g_mem_set_vtable() + */ +GLIB_VAR GMemVTable *glib_mem_profiler_table; +GLIB_DEPRECATED_IN_2_46 +void g_mem_profile (void); + +G_END_DECLS + +#endif /* __G_MEM_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_NODE_H__ +#define __G_NODE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GNode GNode; + +/* Tree traverse flags */ +typedef enum +{ + G_TRAVERSE_LEAVES = 1 << 0, + G_TRAVERSE_NON_LEAVES = 1 << 1, + G_TRAVERSE_ALL = G_TRAVERSE_LEAVES | G_TRAVERSE_NON_LEAVES, + G_TRAVERSE_MASK = 0x03, + G_TRAVERSE_LEAFS = G_TRAVERSE_LEAVES, + G_TRAVERSE_NON_LEAFS = G_TRAVERSE_NON_LEAVES +} GTraverseFlags; + +/* Tree traverse orders */ +typedef enum +{ + G_IN_ORDER, + G_PRE_ORDER, + G_POST_ORDER, + G_LEVEL_ORDER +} GTraverseType; + +typedef gboolean (*GNodeTraverseFunc) (GNode *node, + gpointer data); +typedef void (*GNodeForeachFunc) (GNode *node, + gpointer data); + +/* N-way tree implementation + */ +struct _GNode +{ + gpointer data; + GNode *next; + GNode *prev; + GNode *parent; + GNode *children; +}; + +/** + * G_NODE_IS_ROOT: + * @node: a #GNode + * + * Returns %TRUE if a #GNode is the root of a tree. + * + * Returns: %TRUE if the #GNode is the root of a tree + * (i.e. it has no parent or siblings) + */ +#define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \ + ((GNode*) (node))->prev == NULL && \ + ((GNode*) (node))->next == NULL) + +/** + * G_NODE_IS_LEAF: + * @node: a #GNode + * + * Returns %TRUE if a #GNode is a leaf node. + * + * Returns: %TRUE if the #GNode is a leaf node + * (i.e. it has no children) + */ +#define G_NODE_IS_LEAF(node) (((GNode*) (node))->children == NULL) + +GLIB_AVAILABLE_IN_ALL +GNode* g_node_new (gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_node_destroy (GNode *root); +GLIB_AVAILABLE_IN_ALL +void g_node_unlink (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_copy_deep (GNode *node, + GCopyFunc copy_func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_copy (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_insert (GNode *parent, + gint position, + GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_insert_before (GNode *parent, + GNode *sibling, + GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_insert_after (GNode *parent, + GNode *sibling, + GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_prepend (GNode *parent, + GNode *node); +GLIB_AVAILABLE_IN_ALL +guint g_node_n_nodes (GNode *root, + GTraverseFlags flags); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_get_root (GNode *node); +GLIB_AVAILABLE_IN_ALL +gboolean g_node_is_ancestor (GNode *node, + GNode *descendant); +GLIB_AVAILABLE_IN_ALL +guint g_node_depth (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_find (GNode *root, + GTraverseType order, + GTraverseFlags flags, + gpointer data); + +/* convenience macros */ +/** + * g_node_append: + * @parent: the #GNode to place the new #GNode under + * @node: the #GNode to insert + * + * Inserts a #GNode as the last child of the given parent. + * + * Returns: the inserted #GNode + */ +#define g_node_append(parent, node) \ + g_node_insert_before ((parent), NULL, (node)) + +/** + * g_node_insert_data: + * @parent: the #GNode to place the new #GNode under + * @position: the position to place the new #GNode at. If position is -1, + * the new #GNode is inserted as the last child of @parent + * @data: the data for the new #GNode + * + * Inserts a new #GNode at the given position. + * + * Returns: the new #GNode + */ +#define g_node_insert_data(parent, position, data) \ + g_node_insert ((parent), (position), g_node_new (data)) + +/** + * g_node_insert_data_after: + * @parent: the #GNode to place the new #GNode under + * @sibling: the sibling #GNode to place the new #GNode after + * @data: the data for the new #GNode + * + * Inserts a new #GNode after the given sibling. + * + * Returns: the new #GNode + */ + +#define g_node_insert_data_after(parent, sibling, data) \ + g_node_insert_after ((parent), (sibling), g_node_new (data)) +/** + * g_node_insert_data_before: + * @parent: the #GNode to place the new #GNode under + * @sibling: the sibling #GNode to place the new #GNode before + * @data: the data for the new #GNode + * + * Inserts a new #GNode before the given sibling. + * + * Returns: the new #GNode + */ +#define g_node_insert_data_before(parent, sibling, data) \ + g_node_insert_before ((parent), (sibling), g_node_new (data)) + +/** + * g_node_prepend_data: + * @parent: the #GNode to place the new #GNode under + * @data: the data for the new #GNode + * + * Inserts a new #GNode as the first child of the given parent. + * + * Returns: the new #GNode + */ +#define g_node_prepend_data(parent, data) \ + g_node_prepend ((parent), g_node_new (data)) + +/** + * g_node_append_data: + * @parent: the #GNode to place the new #GNode under + * @data: the data for the new #GNode + * + * Inserts a new #GNode as the last child of the given parent. + * + * Returns: the new #GNode + */ +#define g_node_append_data(parent, data) \ + g_node_insert_before ((parent), NULL, g_node_new (data)) + +/* traversal function, assumes that 'node' is root + * (only traverses 'node' and its subtree). + * this function is just a high level interface to + * low level traversal functions, optimized for speed. + */ +GLIB_AVAILABLE_IN_ALL +void g_node_traverse (GNode *root, + GTraverseType order, + GTraverseFlags flags, + gint max_depth, + GNodeTraverseFunc func, + gpointer data); + +/* return the maximum tree height starting with 'node', this is an expensive + * operation, since we need to visit all nodes. this could be shortened by + * adding 'guint height' to struct _GNode, but then again, this is not very + * often needed, and would make g_node_insert() more time consuming. + */ +GLIB_AVAILABLE_IN_ALL +guint g_node_max_height (GNode *root); + +GLIB_AVAILABLE_IN_ALL +void g_node_children_foreach (GNode *node, + GTraverseFlags flags, + GNodeForeachFunc func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_node_reverse_children (GNode *node); +GLIB_AVAILABLE_IN_ALL +guint g_node_n_children (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_nth_child (GNode *node, + guint n); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_last_child (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_find_child (GNode *node, + GTraverseFlags flags, + gpointer data); +GLIB_AVAILABLE_IN_ALL +gint g_node_child_position (GNode *node, + GNode *child); +GLIB_AVAILABLE_IN_ALL +gint g_node_child_index (GNode *node, + gpointer data); + +GLIB_AVAILABLE_IN_ALL +GNode* g_node_first_sibling (GNode *node); +GLIB_AVAILABLE_IN_ALL +GNode* g_node_last_sibling (GNode *node); + +/** + * g_node_prev_sibling: + * @node: a #GNode + * + * Gets the previous sibling of a #GNode. + * + * Returns: the previous sibling of @node, or %NULL if @node is the first + * node or %NULL + */ +#define g_node_prev_sibling(node) ((node) ? \ + ((GNode*) (node))->prev : NULL) + +/** + * g_node_next_sibling: + * @node: a #GNode + * + * Gets the next sibling of a #GNode. + * + * Returns: the next sibling of @node, or %NULL if @node is the last node + * or %NULL + */ +#define g_node_next_sibling(node) ((node) ? \ + ((GNode*) (node))->next : NULL) + +/** + * g_node_first_child: + * @node: a #GNode + * + * Gets the first child of a #GNode. + * + * Returns: the first child of @node, or %NULL if @node is %NULL + * or has no children + */ +#define g_node_first_child(node) ((node) ? \ + ((GNode*) (node))->children : NULL) + +G_END_DECLS + +#endif /* __G_NODE_H__ */ + +G_BEGIN_DECLS + +typedef struct _GList GList; + +struct _GList +{ + gpointer data; + GList *next; + GList *prev; +}; + +/* Doubly linked lists + */ +GLIB_AVAILABLE_IN_ALL +GList* g_list_alloc (void) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +void g_list_free (GList *list); +GLIB_AVAILABLE_IN_ALL +void g_list_free_1 (GList *list); +#define g_list_free1 g_list_free_1 +GLIB_AVAILABLE_IN_ALL +void g_list_free_full (GList *list, + GDestroyNotify free_func); +GLIB_AVAILABLE_IN_ALL +GList* g_list_append (GList *list, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_prepend (GList *list, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_insert (GList *list, + gpointer data, + gint position) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_insert_sorted (GList *list, + gpointer data, + GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_insert_sorted_with_data (GList *list, + gpointer data, + GCompareDataFunc func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_insert_before (GList *list, + GList *sibling, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_2_62 +GList* g_list_insert_before_link (GList *list, + GList *sibling, + GList *link_) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_concat (GList *list1, + GList *list2) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_remove (GList *list, + gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_remove_all (GList *list, + gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_remove_link (GList *list, + GList *llink) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_delete_link (GList *list, + GList *link_) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_reverse (GList *list) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_copy (GList *list) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_2_34 +GList* g_list_copy_deep (GList *list, + GCopyFunc func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_ALL +GList* g_list_nth (GList *list, + guint n); +GLIB_AVAILABLE_IN_ALL +GList* g_list_nth_prev (GList *list, + guint n); +GLIB_AVAILABLE_IN_ALL +GList* g_list_find (GList *list, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GList* g_list_find_custom (GList *list, + gconstpointer data, + GCompareFunc func); +GLIB_AVAILABLE_IN_ALL +gint g_list_position (GList *list, + GList *llink); +GLIB_AVAILABLE_IN_ALL +gint g_list_index (GList *list, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GList* g_list_last (GList *list); +GLIB_AVAILABLE_IN_ALL +GList* g_list_first (GList *list); +GLIB_AVAILABLE_IN_ALL +guint g_list_length (GList *list); +GLIB_AVAILABLE_IN_ALL +void g_list_foreach (GList *list, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GList* g_list_sort (GList *list, + GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GList* g_list_sort_with_data (GList *list, + GCompareDataFunc compare_func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gpointer g_list_nth_data (GList *list, + guint n); + +GLIB_AVAILABLE_IN_2_64 +void g_clear_list (GList **list_ptr, + GDestroyNotify destroy); + +#undef g_clear_list +#define g_clear_list(list_ptr, destroy) \ + G_STMT_START { \ + GList *_list; \ + \ + _list = *(list_ptr); \ + if (_list) \ + { \ + *list_ptr = NULL; \ + \ + if ((destroy) != NULL) \ + g_list_free_full (_list, (destroy)); \ + else \ + g_list_free (_list); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_64 + + +#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL) +#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) + +G_END_DECLS + +#endif /* __G_LIST_H__ */ + +G_BEGIN_DECLS + +typedef struct _GHashTable GHashTable; + +typedef gboolean (*GHRFunc) (gpointer key, + gpointer value, + gpointer user_data); + +typedef struct _GHashTableIter GHashTableIter; + +struct _GHashTableIter +{ + /*< private >*/ + gpointer dummy1; + gpointer dummy2; + gpointer dummy3; + int dummy4; + gboolean dummy5; + gpointer dummy6; +}; + +GLIB_AVAILABLE_IN_ALL +GHashTable* g_hash_table_new (GHashFunc hash_func, + GEqualFunc key_equal_func); +GLIB_AVAILABLE_IN_ALL +GHashTable* g_hash_table_new_full (GHashFunc hash_func, + GEqualFunc key_equal_func, + GDestroyNotify key_destroy_func, + GDestroyNotify value_destroy_func); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_destroy (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_insert (GHashTable *hash_table, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_replace (GHashTable *hash_table, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_add (GHashTable *hash_table, + gpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_remove (GHashTable *hash_table, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_remove_all (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_steal (GHashTable *hash_table, + gconstpointer key); +GLIB_AVAILABLE_IN_2_58 +gboolean g_hash_table_steal_extended (GHashTable *hash_table, + gconstpointer lookup_key, + gpointer *stolen_key, + gpointer *stolen_value); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_steal_all (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +gpointer g_hash_table_lookup (GHashTable *hash_table, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_contains (GHashTable *hash_table, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_lookup_extended (GHashTable *hash_table, + gconstpointer lookup_key, + gpointer *orig_key, + gpointer *value); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_foreach (GHashTable *hash_table, + GHFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_hash_table_find (GHashTable *hash_table, + GHRFunc predicate, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +guint g_hash_table_foreach_remove (GHashTable *hash_table, + GHRFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +guint g_hash_table_foreach_steal (GHashTable *hash_table, + GHRFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +guint g_hash_table_size (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +GList * g_hash_table_get_keys (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +GList * g_hash_table_get_values (GHashTable *hash_table); +GLIB_AVAILABLE_IN_2_40 +gpointer * g_hash_table_get_keys_as_array (GHashTable *hash_table, + guint *length); + +GLIB_AVAILABLE_IN_ALL +void g_hash_table_iter_init (GHashTableIter *iter, + GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +gboolean g_hash_table_iter_next (GHashTableIter *iter, + gpointer *key, + gpointer *value); +GLIB_AVAILABLE_IN_ALL +GHashTable* g_hash_table_iter_get_hash_table (GHashTableIter *iter); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_iter_remove (GHashTableIter *iter); +GLIB_AVAILABLE_IN_2_30 +void g_hash_table_iter_replace (GHashTableIter *iter, + gpointer value); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_iter_steal (GHashTableIter *iter); + +GLIB_AVAILABLE_IN_ALL +GHashTable* g_hash_table_ref (GHashTable *hash_table); +GLIB_AVAILABLE_IN_ALL +void g_hash_table_unref (GHashTable *hash_table); + +#define g_hash_table_freeze(hash_table) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 +#define g_hash_table_thaw(hash_table) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 + +/* Hash Functions + */ +GLIB_AVAILABLE_IN_ALL +gboolean g_str_equal (gconstpointer v1, + gconstpointer v2); +GLIB_AVAILABLE_IN_ALL +guint g_str_hash (gconstpointer v); + +GLIB_AVAILABLE_IN_ALL +gboolean g_int_equal (gconstpointer v1, + gconstpointer v2); +GLIB_AVAILABLE_IN_ALL +guint g_int_hash (gconstpointer v); + +GLIB_AVAILABLE_IN_ALL +gboolean g_int64_equal (gconstpointer v1, + gconstpointer v2); +GLIB_AVAILABLE_IN_ALL +guint g_int64_hash (gconstpointer v); + +GLIB_AVAILABLE_IN_ALL +gboolean g_double_equal (gconstpointer v1, + gconstpointer v2); +GLIB_AVAILABLE_IN_ALL +guint g_double_hash (gconstpointer v); + +GLIB_AVAILABLE_IN_ALL +guint g_direct_hash (gconstpointer v) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_direct_equal (gconstpointer v1, + gconstpointer v2) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_HASH_H__ */ +/* ghmac.h - secure data hashing + * + * Copyright (C) 2011 Stef Walter + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_HMAC_H__ +#define __G_HMAC_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * GHmac: + * + * An opaque structure representing a HMAC operation. + * To create a new GHmac, use g_hmac_new(). To free + * a GHmac, use g_hmac_unref(). + * + * Since: 2.30 + */ +typedef struct _GHmac GHmac; + +GLIB_AVAILABLE_IN_2_30 +GHmac * g_hmac_new (GChecksumType digest_type, + const guchar *key, + gsize key_len); +GLIB_AVAILABLE_IN_2_30 +GHmac * g_hmac_copy (const GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 +GHmac * g_hmac_ref (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 +void g_hmac_unref (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 +void g_hmac_update (GHmac *hmac, + const guchar *data, + gssize length); +GLIB_AVAILABLE_IN_2_30 +const gchar * g_hmac_get_string (GHmac *hmac); +GLIB_AVAILABLE_IN_2_30 +void g_hmac_get_digest (GHmac *hmac, + guint8 *buffer, + gsize *digest_len); + +GLIB_AVAILABLE_IN_2_30 +gchar *g_compute_hmac_for_data (GChecksumType digest_type, + const guchar *key, + gsize key_len, + const guchar *data, + gsize length); +GLIB_AVAILABLE_IN_2_30 +gchar *g_compute_hmac_for_string (GChecksumType digest_type, + const guchar *key, + gsize key_len, + const gchar *str, + gssize length); +GLIB_AVAILABLE_IN_2_50 +gchar *g_compute_hmac_for_bytes (GChecksumType digest_type, + GBytes *key, + GBytes *data); + + +G_END_DECLS + +#endif /* __G_CHECKSUM_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_HOOK_H__ +#define __G_HOOK_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + + +/* --- typedefs --- */ +typedef struct _GHook GHook; +typedef struct _GHookList GHookList; + +typedef gint (*GHookCompareFunc) (GHook *new_hook, + GHook *sibling); +typedef gboolean (*GHookFindFunc) (GHook *hook, + gpointer data); +typedef void (*GHookMarshaller) (GHook *hook, + gpointer marshal_data); +typedef gboolean (*GHookCheckMarshaller) (GHook *hook, + gpointer marshal_data); +typedef void (*GHookFunc) (gpointer data); +typedef gboolean (*GHookCheckFunc) (gpointer data); +typedef void (*GHookFinalizeFunc) (GHookList *hook_list, + GHook *hook); +typedef enum +{ + G_HOOK_FLAG_ACTIVE = 1 << 0, + G_HOOK_FLAG_IN_CALL = 1 << 1, + G_HOOK_FLAG_MASK = 0x0f +} GHookFlagMask; +#define G_HOOK_FLAG_USER_SHIFT (4) + + +/* --- structures --- */ +struct _GHookList +{ + gulong seq_id; + guint hook_size : 16; + guint is_setup : 1; + GHook *hooks; + gpointer dummy3; + GHookFinalizeFunc finalize_hook; + gpointer dummy[2]; +}; +struct _GHook +{ + gpointer data; + GHook *next; + GHook *prev; + guint ref_count; + gulong hook_id; + guint flags; + gpointer func; + GDestroyNotify destroy; +}; + + +/* --- macros --- */ +#define G_HOOK(hook) ((GHook*) (hook)) +#define G_HOOK_FLAGS(hook) (G_HOOK (hook)->flags) +#define G_HOOK_ACTIVE(hook) ((G_HOOK_FLAGS (hook) & \ + G_HOOK_FLAG_ACTIVE) != 0) +#define G_HOOK_IN_CALL(hook) ((G_HOOK_FLAGS (hook) & \ + G_HOOK_FLAG_IN_CALL) != 0) +#define G_HOOK_IS_VALID(hook) (G_HOOK (hook)->hook_id != 0 && \ + (G_HOOK_FLAGS (hook) & \ + G_HOOK_FLAG_ACTIVE)) +#define G_HOOK_IS_UNLINKED(hook) (G_HOOK (hook)->next == NULL && \ + G_HOOK (hook)->prev == NULL && \ + G_HOOK (hook)->hook_id == 0 && \ + G_HOOK (hook)->ref_count == 0) + + +/* --- prototypes --- */ +/* callback maintenance functions */ +GLIB_AVAILABLE_IN_ALL +void g_hook_list_init (GHookList *hook_list, + guint hook_size); +GLIB_AVAILABLE_IN_ALL +void g_hook_list_clear (GHookList *hook_list); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_alloc (GHookList *hook_list); +GLIB_AVAILABLE_IN_ALL +void g_hook_free (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +GHook * g_hook_ref (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +void g_hook_unref (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +gboolean g_hook_destroy (GHookList *hook_list, + gulong hook_id); +GLIB_AVAILABLE_IN_ALL +void g_hook_destroy_link (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +void g_hook_prepend (GHookList *hook_list, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +void g_hook_insert_before (GHookList *hook_list, + GHook *sibling, + GHook *hook); +GLIB_AVAILABLE_IN_ALL +void g_hook_insert_sorted (GHookList *hook_list, + GHook *hook, + GHookCompareFunc func); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_get (GHookList *hook_list, + gulong hook_id); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_find (GHookList *hook_list, + gboolean need_valids, + GHookFindFunc func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_find_data (GHookList *hook_list, + gboolean need_valids, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_find_func (GHookList *hook_list, + gboolean need_valids, + gpointer func); +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_find_func_data (GHookList *hook_list, + gboolean need_valids, + gpointer func, + gpointer data); +/* return the first valid hook, and increment its reference count */ +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_first_valid (GHookList *hook_list, + gboolean may_be_in_call); +/* return the next valid hook with incremented reference count, and + * decrement the reference count of the original hook + */ +GLIB_AVAILABLE_IN_ALL +GHook* g_hook_next_valid (GHookList *hook_list, + GHook *hook, + gboolean may_be_in_call); +/* GHookCompareFunc implementation to insert hooks sorted by their id */ +GLIB_AVAILABLE_IN_ALL +gint g_hook_compare_ids (GHook *new_hook, + GHook *sibling); +/* convenience macros */ +#define g_hook_append( hook_list, hook ) \ + g_hook_insert_before ((hook_list), NULL, (hook)) +/* invoke all valid hooks with the (*GHookFunc) signature. + */ +GLIB_AVAILABLE_IN_ALL +void g_hook_list_invoke (GHookList *hook_list, + gboolean may_recurse); +/* invoke all valid hooks with the (*GHookCheckFunc) signature, + * and destroy the hook if FALSE is returned. + */ +GLIB_AVAILABLE_IN_ALL +void g_hook_list_invoke_check (GHookList *hook_list, + gboolean may_recurse); +/* invoke a marshaller on all valid hooks. + */ +GLIB_AVAILABLE_IN_ALL +void g_hook_list_marshal (GHookList *hook_list, + gboolean may_recurse, + GHookMarshaller marshaller, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_hook_list_marshal_check (GHookList *hook_list, + gboolean may_recurse, + GHookCheckMarshaller marshaller, + gpointer marshal_data); + +G_END_DECLS + +#endif /* __G_HOOK_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 2008 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_HOST_UTILS_H__ +#define __G_HOST_UTILS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +gboolean g_hostname_is_non_ascii (const gchar *hostname); +GLIB_AVAILABLE_IN_ALL +gboolean g_hostname_is_ascii_encoded (const gchar *hostname); +GLIB_AVAILABLE_IN_ALL +gboolean g_hostname_is_ip_address (const gchar *hostname); + +GLIB_AVAILABLE_IN_ALL +gchar *g_hostname_to_ascii (const gchar *hostname); +GLIB_AVAILABLE_IN_ALL +gchar *g_hostname_to_unicode (const gchar *hostname); + +G_END_DECLS + +#endif /* __G_HOST_UTILS_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_IOCHANNEL_H__ +#define __G_IOCHANNEL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* gmain.h - the GLib Main loop + * Copyright (C) 1998-2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_MAIN_H__ +#define __G_MAIN_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* gpoll.h - poll(2) support + * Copyright (C) 2008 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_POLL_H__ +#define __G_POLL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (__G_MAIN_H__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* Any definitions using GPollFD or GPollFunc are primarily + * for Unix and not guaranteed to be the compatible on all + * operating systems on which GLib runs. Right now, the + * GLib does use these functions on Win32 as well, but interprets + * them in a fairly different way than on Unix. If you use + * these definitions, you are should be prepared to recode + * for different operating systems. + * + * Note that on systems with a working poll(2), that function is used + * in place of g_poll(). Thus g_poll() must have the same signature as + * poll(), meaning GPollFD must have the same layout as struct pollfd. + * + * On Win32, the fd in a GPollFD should be Win32 HANDLE (*not* a file + * descriptor as provided by the C runtime) that can be used by + * MsgWaitForMultipleObjects. This does *not* include file handles + * from CreateFile, SOCKETs, nor pipe handles. (But you can use + * WSAEventSelect to signal events when a SOCKET is readable). + * + * On Win32, fd can also be the special value G_WIN32_MSG_HANDLE to + * indicate polling for messages. + * + * But note that G_WIN32_MSG_HANDLE GPollFDs should not be used by GDK + * (GTK) programs, as GDK itself wants to read messages and convert them + * to GDK events. + * + * So, unless you really know what you are doing, it's best not to try + * to use the main loop polling stuff for your own needs on + * Windows. + */ +typedef struct _GPollFD GPollFD; + +/** + * GPollFunc: + * @ufds: an array of #GPollFD elements + * @nfsd: the number of elements in @ufds + * @timeout_: the maximum time to wait for an event of the file descriptors. + * A negative value indicates an infinite timeout. + * + * Specifies the type of function passed to g_main_context_set_poll_func(). + * The semantics of the function should match those of the poll() system call. + * + * Returns: the number of #GPollFD elements which have events or errors + * reported, or -1 if an error occurred. + */ +typedef gint (*GPollFunc) (GPollFD *ufds, + guint nfsd, + gint timeout_); + +/** + * GPollFD: + * @fd: the file descriptor to poll (or a HANDLE on Win32) + * @events: a bitwise combination from #GIOCondition, specifying which + * events should be polled for. Typically for reading from a file + * descriptor you would use %G_IO_IN | %G_IO_HUP | %G_IO_ERR, and + * for writing you would use %G_IO_OUT | %G_IO_ERR. + * @revents: a bitwise combination of flags from #GIOCondition, returned + * from the poll() function to indicate which events occurred. + * + * Represents a file descriptor, which events to poll for, and which events + * occurred. + */ +struct _GPollFD +{ +#if defined (G_OS_WIN32) && GLIB_SIZEOF_VOID_P == 8 +#ifndef __GTK_DOC_IGNORE__ + gint64 fd; +#endif +#else + gint fd; +#endif + gushort events; + gushort revents; +}; + +/** + * G_POLLFD_FORMAT: + * + * A format specifier that can be used in printf()-style format strings + * when printing the @fd member of a #GPollFD. + */ +/* defined in glibconfig.h */ + +GLIB_AVAILABLE_IN_ALL +gint +g_poll (GPollFD *fds, + guint nfds, + gint timeout); + +G_END_DECLS + +#endif /* __G_POLL_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_SLIST_H__ +#define __G_SLIST_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GSList GSList; + +struct _GSList +{ + gpointer data; + GSList *next; +}; + +/* Singly linked lists + */ +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_alloc (void) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +void g_slist_free (GSList *list); +GLIB_AVAILABLE_IN_ALL +void g_slist_free_1 (GSList *list); +#define g_slist_free1 g_slist_free_1 +GLIB_AVAILABLE_IN_ALL +void g_slist_free_full (GSList *list, + GDestroyNotify free_func); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_append (GSList *list, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_prepend (GSList *list, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_insert (GSList *list, + gpointer data, + gint position) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_insert_sorted (GSList *list, + gpointer data, + GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_insert_sorted_with_data (GSList *list, + gpointer data, + GCompareDataFunc func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_insert_before (GSList *slist, + GSList *sibling, + gpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_concat (GSList *list1, + GSList *list2) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_remove (GSList *list, + gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_remove_all (GSList *list, + gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_remove_link (GSList *list, + GSList *link_) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_delete_link (GSList *list, + GSList *link_) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_reverse (GSList *list) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_copy (GSList *list) G_GNUC_WARN_UNUSED_RESULT; + +GLIB_AVAILABLE_IN_2_34 +GSList* g_slist_copy_deep (GSList *list, + GCopyFunc func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_nth (GSList *list, + guint n); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_find (GSList *list, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_find_custom (GSList *list, + gconstpointer data, + GCompareFunc func); +GLIB_AVAILABLE_IN_ALL +gint g_slist_position (GSList *list, + GSList *llink); +GLIB_AVAILABLE_IN_ALL +gint g_slist_index (GSList *list, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_last (GSList *list); +GLIB_AVAILABLE_IN_ALL +guint g_slist_length (GSList *list); +GLIB_AVAILABLE_IN_ALL +void g_slist_foreach (GSList *list, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_sort (GSList *list, + GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +GSList* g_slist_sort_with_data (GSList *list, + GCompareDataFunc compare_func, + gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; +GLIB_AVAILABLE_IN_ALL +gpointer g_slist_nth_data (GSList *list, + guint n); + +GLIB_AVAILABLE_IN_2_64 +void g_clear_slist (GSList **slist_ptr, + GDestroyNotify destroy); + +#undef g_clear_slist +#define g_clear_slist(slist_ptr, destroy) \ + G_STMT_START { \ + GSList *_slist; \ + \ + _slist = *(slist_ptr); \ + if (_slist) \ + { \ + *slist_ptr = NULL; \ + \ + if ((destroy) != NULL) \ + g_slist_free_full (_slist, (destroy)); \ + else \ + g_slist_free (_slist); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_64 + +#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL) + +G_END_DECLS + +#endif /* __G_SLIST_H__ */ + +G_BEGIN_DECLS + +typedef enum /*< flags >*/ +{ + G_IO_IN GLIB_SYSDEF_POLLIN, + G_IO_OUT GLIB_SYSDEF_POLLOUT, + G_IO_PRI GLIB_SYSDEF_POLLPRI, + G_IO_ERR GLIB_SYSDEF_POLLERR, + G_IO_HUP GLIB_SYSDEF_POLLHUP, + G_IO_NVAL GLIB_SYSDEF_POLLNVAL +} GIOCondition; + + +/** + * GMainContext: + * + * The `GMainContext` struct is an opaque data + * type representing a set of sources to be handled in a main loop. + */ +typedef struct _GMainContext GMainContext; + +/** + * GMainLoop: + * + * The `GMainLoop` struct is an opaque data type + * representing the main event loop of a GLib or GTK+ application. + */ +typedef struct _GMainLoop GMainLoop; + +/** + * GSource: + * + * The `GSource` struct is an opaque data type + * representing an event source. + */ +typedef struct _GSource GSource; +typedef struct _GSourcePrivate GSourcePrivate; + +/** + * GSourceCallbackFuncs: + * @ref: Called when a reference is added to the callback object + * @unref: Called when a reference to the callback object is dropped + * @get: Called to extract the callback function and data from the + * callback object. + * + * The `GSourceCallbackFuncs` struct contains + * functions for managing callback objects. + */ +typedef struct _GSourceCallbackFuncs GSourceCallbackFuncs; + +/** + * GSourceFuncs: + * @prepare: Called before all the file descriptors are polled. If the + * source can determine that it is ready here (without waiting for the + * results of the poll() call) it should return %TRUE. It can also return + * a @timeout_ value which should be the maximum timeout (in milliseconds) + * which should be passed to the poll() call. The actual timeout used will + * be -1 if all sources returned -1, or it will be the minimum of all + * the @timeout_ values returned which were >= 0. Since 2.36 this may + * be %NULL, in which case the effect is as if the function always returns + * %FALSE with a timeout of -1. If @prepare returns a + * timeout and the source also has a ready time set, then the + * lower of the two will be used. + * @check: Called after all the file descriptors are polled. The source + * should return %TRUE if it is ready to be dispatched. Note that some + * time may have passed since the previous prepare function was called, + * so the source should be checked again here. Since 2.36 this may + * be %NULL, in which case the effect is as if the function always returns + * %FALSE. + * @dispatch: Called to dispatch the event source, after it has returned + * %TRUE in either its @prepare or its @check function, or if a ready time + * has been reached. The @dispatch function receives a callback function and + * user data. The callback function may be %NULL if the source was never + * connected to a callback using g_source_set_callback(). The @dispatch + * function should call the callback function with @user_data and whatever + * additional parameters are needed for this type of event source. The + * return value of the @dispatch function should be #G_SOURCE_REMOVE if the + * source should be removed or #G_SOURCE_CONTINUE to keep it. + * @finalize: Called when the source is finalized. At this point, the source + * will have been destroyed, had its callback cleared, and have been removed + * from its #GMainContext, but it will still have its final reference count, + * so methods can be called on it from within this function. + * + * The `GSourceFuncs` struct contains a table of + * functions used to handle event sources in a generic manner. + * + * For idle sources, the prepare and check functions always return %TRUE + * to indicate that the source is always ready to be processed. The prepare + * function also returns a timeout value of 0 to ensure that the poll() call + * doesn't block (since that would be time wasted which could have been spent + * running the idle function). + * + * For timeout sources, the prepare and check functions both return %TRUE + * if the timeout interval has expired. The prepare function also returns + * a timeout value to ensure that the poll() call doesn't block too long + * and miss the next timeout. + * + * For file descriptor sources, the prepare function typically returns %FALSE, + * since it must wait until poll() has been called before it knows whether + * any events need to be processed. It sets the returned timeout to -1 to + * indicate that it doesn't mind how long the poll() call blocks. In the + * check function, it tests the results of the poll() call to see if the + * required condition has been met, and returns %TRUE if so. + */ +typedef struct _GSourceFuncs GSourceFuncs; + +/** + * GPid: + * + * A type which is used to hold a process identification. + * + * On UNIX, processes are identified by a process id (an integer), + * while Windows uses process handles (which are pointers). + * + * GPid is used in GLib only for descendant processes spawned with + * the g_spawn functions. + */ +/* defined in glibconfig.h */ + +/** + * G_PID_FORMAT: + * + * A format specifier that can be used in printf()-style format strings + * when printing a #GPid. + * + * Since: 2.50 + */ +/* defined in glibconfig.h */ + +/** + * GSourceFunc: + * @user_data: data passed to the function, set when the source was + * created with one of the above functions + * + * Specifies the type of function passed to g_timeout_add(), + * g_timeout_add_full(), g_idle_add(), and g_idle_add_full(). + * + * When calling g_source_set_callback(), you may need to cast a function of a + * different type to this type. Use G_SOURCE_FUNC() to avoid warnings about + * incompatible function types. + * + * Returns: %FALSE if the source should be removed. #G_SOURCE_CONTINUE and + * #G_SOURCE_REMOVE are more memorable names for the return value. + */ +typedef gboolean (*GSourceFunc) (gpointer user_data); + +/** + * G_SOURCE_FUNC: + * @f: a function pointer. + * + * Cast a function pointer to a #GSourceFunc, suppressing warnings from GCC 8 + * onwards with `-Wextra` or `-Wcast-function-type` enabled about the function + * types being incompatible. + * + * For example, the correct type of callback for a source created by + * g_child_watch_source_new() is #GChildWatchFunc, which accepts more arguments + * than #GSourceFunc. Casting the function with `(GSourceFunc)` to call + * g_source_set_callback() will trigger a warning, even though it will be cast + * back to the correct type before it is called by the source. + * + * Since: 2.58 + */ +#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f)) GLIB_AVAILABLE_MACRO_IN_2_58 + +/** + * GChildWatchFunc: + * @pid: the process id of the child process + * @status: Status information about the child process, encoded + * in a platform-specific manner + * @user_data: user data passed to g_child_watch_add() + * + * Prototype of a #GChildWatchSource callback, called when a child + * process has exited. To interpret @status, see the documentation + * for g_spawn_check_exit_status(). + */ +typedef void (*GChildWatchFunc) (GPid pid, + gint status, + gpointer user_data); + + +/** + * GSourceDisposeFunc: + * @source: #GSource that is currently being disposed + * + * Dispose function for @source. See g_source_set_dispose_function() for + * details. + * + * Since: 2.64 + */ +GLIB_AVAILABLE_TYPE_IN_2_64 +typedef void (*GSourceDisposeFunc) (GSource *source); + +struct _GSource +{ + /*< private >*/ + gpointer callback_data; + GSourceCallbackFuncs *callback_funcs; + + const GSourceFuncs *source_funcs; + guint ref_count; + + GMainContext *context; + + gint priority; + guint flags; + guint source_id; + + GSList *poll_fds; + + GSource *prev; + GSource *next; + + char *name; + + GSourcePrivate *priv; +}; + +struct _GSourceCallbackFuncs +{ + void (*ref) (gpointer cb_data); + void (*unref) (gpointer cb_data); + void (*get) (gpointer cb_data, + GSource *source, + GSourceFunc *func, + gpointer *data); +}; + +/** + * GSourceDummyMarshal: + * + * This is just a placeholder for #GClosureMarshal, + * which cannot be used here for dependency reasons. + */ +typedef void (*GSourceDummyMarshal) (void); + +struct _GSourceFuncs +{ + gboolean (*prepare) (GSource *source, + gint *timeout_); + gboolean (*check) (GSource *source); + gboolean (*dispatch) (GSource *source, + GSourceFunc callback, + gpointer user_data); + void (*finalize) (GSource *source); /* Can be NULL */ + + /*< private >*/ + /* For use by g_source_set_closure */ + GSourceFunc closure_callback; + GSourceDummyMarshal closure_marshal; /* Really is of type GClosureMarshal */ +}; + +/* Standard priorities */ + +/** + * G_PRIORITY_HIGH: + * + * Use this for high priority event sources. + * + * It is not used within GLib or GTK+. + */ +#define G_PRIORITY_HIGH -100 + +/** + * G_PRIORITY_DEFAULT: + * + * Use this for default priority event sources. + * + * In GLib this priority is used when adding timeout functions + * with g_timeout_add(). In GDK this priority is used for events + * from the X server. + */ +#define G_PRIORITY_DEFAULT 0 + +/** + * G_PRIORITY_HIGH_IDLE: + * + * Use this for high priority idle functions. + * + * GTK+ uses #G_PRIORITY_HIGH_IDLE + 10 for resizing operations, + * and #G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is + * done to ensure that any pending resizes are processed before any + * pending redraws, so that widgets are not redrawn twice unnecessarily.) + */ +#define G_PRIORITY_HIGH_IDLE 100 + +/** + * G_PRIORITY_DEFAULT_IDLE: + * + * Use this for default priority idle functions. + * + * In GLib this priority is used when adding idle functions with + * g_idle_add(). + */ +#define G_PRIORITY_DEFAULT_IDLE 200 + +/** + * G_PRIORITY_LOW: + * + * Use this for very low priority background tasks. + * + * It is not used within GLib or GTK+. + */ +#define G_PRIORITY_LOW 300 + +/** + * G_SOURCE_REMOVE: + * + * Use this macro as the return value of a #GSourceFunc to remove + * the #GSource from the main loop. + * + * Since: 2.32 + */ +#define G_SOURCE_REMOVE FALSE + +/** + * G_SOURCE_CONTINUE: + * + * Use this macro as the return value of a #GSourceFunc to leave + * the #GSource in the main loop. + * + * Since: 2.32 + */ +#define G_SOURCE_CONTINUE TRUE + +/* GMainContext: */ + +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_new (void); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_ref (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +void g_main_context_unref (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_default (void); + +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_iteration (GMainContext *context, + gboolean may_block); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_pending (GMainContext *context); + +/* For implementation of legacy interfaces + */ +GLIB_AVAILABLE_IN_ALL +GSource *g_main_context_find_source_by_id (GMainContext *context, + guint source_id); +GLIB_AVAILABLE_IN_ALL +GSource *g_main_context_find_source_by_user_data (GMainContext *context, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GSource *g_main_context_find_source_by_funcs_user_data (GMainContext *context, + GSourceFuncs *funcs, + gpointer user_data); + +/* Low level functions for implementing custom main loops. + */ +GLIB_AVAILABLE_IN_ALL +void g_main_context_wakeup (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_acquire (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +void g_main_context_release (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_is_owner (GMainContext *context); +GLIB_DEPRECATED_IN_2_58_FOR(g_main_context_is_owner) +gboolean g_main_context_wait (GMainContext *context, + GCond *cond, + GMutex *mutex); + +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_prepare (GMainContext *context, + gint *priority); +GLIB_AVAILABLE_IN_ALL +gint g_main_context_query (GMainContext *context, + gint max_priority, + gint *timeout_, + GPollFD *fds, + gint n_fds); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_context_check (GMainContext *context, + gint max_priority, + GPollFD *fds, + gint n_fds); +GLIB_AVAILABLE_IN_ALL +void g_main_context_dispatch (GMainContext *context); + +GLIB_AVAILABLE_IN_ALL +void g_main_context_set_poll_func (GMainContext *context, + GPollFunc func); +GLIB_AVAILABLE_IN_ALL +GPollFunc g_main_context_get_poll_func (GMainContext *context); + +/* Low level functions for use by source implementations + */ +GLIB_AVAILABLE_IN_ALL +void g_main_context_add_poll (GMainContext *context, + GPollFD *fd, + gint priority); +GLIB_AVAILABLE_IN_ALL +void g_main_context_remove_poll (GMainContext *context, + GPollFD *fd); + +GLIB_AVAILABLE_IN_ALL +gint g_main_depth (void); +GLIB_AVAILABLE_IN_ALL +GSource *g_main_current_source (void); + +/* GMainContexts for other threads + */ +GLIB_AVAILABLE_IN_ALL +void g_main_context_push_thread_default (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +void g_main_context_pop_thread_default (GMainContext *context); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_get_thread_default (void); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_context_ref_thread_default (void); + +/** + * GMainContextPusher: + * + * Opaque type. See g_main_context_pusher_new() for details. + * + * Since: 2.64 + */ +typedef void GMainContextPusher GLIB_AVAILABLE_TYPE_IN_2_64; + +/** + * g_main_context_pusher_new: + * @main_context: (transfer none): a main context to push + * + * Push @main_context as the new thread-default main context for the current + * thread, using g_main_context_push_thread_default(), and return a new + * #GMainContextPusher. Pop with g_main_context_pusher_free(). Using + * g_main_context_pop_thread_default() on @main_context while a + * #GMainContextPusher exists for it can lead to undefined behaviour. + * + * Using two #GMainContextPushers in the same scope is not allowed, as it leads + * to an undefined pop order. + * + * This is intended to be used with g_autoptr(). Note that g_autoptr() + * is only available when using GCC or clang, so the following example + * will only work with those compilers: + * |[ + * typedef struct + * { + * ... + * GMainContext *context; + * ... + * } MyObject; + * + * static void + * my_object_do_stuff (MyObject *self) + * { + * g_autoptr(GMainContextPusher) pusher = g_main_context_pusher_new (self->context); + * + * // Code with main context as the thread default here + * + * if (cond) + * // No need to pop + * return; + * + * // Optionally early pop + * g_clear_pointer (&pusher, g_main_context_pusher_free); + * + * // Code with main context no longer the thread default here + * } + * ]| + * + * Returns: (transfer full): a #GMainContextPusher + * Since: 2.64 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 +static inline GMainContextPusher * +g_main_context_pusher_new (GMainContext *main_context) +{ + g_main_context_push_thread_default (main_context); + return (GMainContextPusher *) main_context; +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * g_main_context_pusher_free: + * @pusher: (transfer full): a #GMainContextPusher + * + * Pop @pusher’s main context as the thread default main context. + * See g_main_context_pusher_new() for details. + * + * This will pop the #GMainContext as the current thread-default main context, + * but will not call g_main_context_unref() on it. + * + * Since: 2.64 + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 +static inline void +g_main_context_pusher_free (GMainContextPusher *pusher) +{ + g_main_context_pop_thread_default ((GMainContext *) pusher); +} +G_GNUC_END_IGNORE_DEPRECATIONS + +/* GMainLoop: */ + +GLIB_AVAILABLE_IN_ALL +GMainLoop *g_main_loop_new (GMainContext *context, + gboolean is_running); +GLIB_AVAILABLE_IN_ALL +void g_main_loop_run (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +void g_main_loop_quit (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +GMainLoop *g_main_loop_ref (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +void g_main_loop_unref (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +gboolean g_main_loop_is_running (GMainLoop *loop); +GLIB_AVAILABLE_IN_ALL +GMainContext *g_main_loop_get_context (GMainLoop *loop); + +/* GSource: */ + +GLIB_AVAILABLE_IN_ALL +GSource *g_source_new (GSourceFuncs *source_funcs, + guint struct_size); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_AVAILABLE_IN_2_64 +void g_source_set_dispose_function (GSource *source, + GSourceDisposeFunc dispose); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +GSource *g_source_ref (GSource *source); +GLIB_AVAILABLE_IN_ALL +void g_source_unref (GSource *source); + +GLIB_AVAILABLE_IN_ALL +guint g_source_attach (GSource *source, + GMainContext *context); +GLIB_AVAILABLE_IN_ALL +void g_source_destroy (GSource *source); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_priority (GSource *source, + gint priority); +GLIB_AVAILABLE_IN_ALL +gint g_source_get_priority (GSource *source); +GLIB_AVAILABLE_IN_ALL +void g_source_set_can_recurse (GSource *source, + gboolean can_recurse); +GLIB_AVAILABLE_IN_ALL +gboolean g_source_get_can_recurse (GSource *source); +GLIB_AVAILABLE_IN_ALL +guint g_source_get_id (GSource *source); + +GLIB_AVAILABLE_IN_ALL +GMainContext *g_source_get_context (GSource *source); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_callback (GSource *source, + GSourceFunc func, + gpointer data, + GDestroyNotify notify); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_funcs (GSource *source, + GSourceFuncs *funcs); +GLIB_AVAILABLE_IN_ALL +gboolean g_source_is_destroyed (GSource *source); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_name (GSource *source, + const char *name); +GLIB_AVAILABLE_IN_ALL +const char * g_source_get_name (GSource *source); +GLIB_AVAILABLE_IN_ALL +void g_source_set_name_by_id (guint tag, + const char *name); + +GLIB_AVAILABLE_IN_2_36 +void g_source_set_ready_time (GSource *source, + gint64 ready_time); +GLIB_AVAILABLE_IN_2_36 +gint64 g_source_get_ready_time (GSource *source); + +#ifdef G_OS_UNIX +GLIB_AVAILABLE_IN_2_36 +gpointer g_source_add_unix_fd (GSource *source, + gint fd, + GIOCondition events); +GLIB_AVAILABLE_IN_2_36 +void g_source_modify_unix_fd (GSource *source, + gpointer tag, + GIOCondition new_events); +GLIB_AVAILABLE_IN_2_36 +void g_source_remove_unix_fd (GSource *source, + gpointer tag); +GLIB_AVAILABLE_IN_2_36 +GIOCondition g_source_query_unix_fd (GSource *source, + gpointer tag); +#endif + +/* Used to implement g_source_connect_closure and internally*/ +GLIB_AVAILABLE_IN_ALL +void g_source_set_callback_indirect (GSource *source, + gpointer callback_data, + GSourceCallbackFuncs *callback_funcs); + +GLIB_AVAILABLE_IN_ALL +void g_source_add_poll (GSource *source, + GPollFD *fd); +GLIB_AVAILABLE_IN_ALL +void g_source_remove_poll (GSource *source, + GPollFD *fd); + +GLIB_AVAILABLE_IN_ALL +void g_source_add_child_source (GSource *source, + GSource *child_source); +GLIB_AVAILABLE_IN_ALL +void g_source_remove_child_source (GSource *source, + GSource *child_source); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_28_FOR(g_source_get_time) +void g_source_get_current_time (GSource *source, + GTimeVal *timeval); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +gint64 g_source_get_time (GSource *source); + + /* void g_source_connect_closure (GSource *source, + GClosure *closure); + */ + +/* Specific source types + */ +GLIB_AVAILABLE_IN_ALL +GSource *g_idle_source_new (void); +GLIB_AVAILABLE_IN_ALL +GSource *g_child_watch_source_new (GPid pid); +GLIB_AVAILABLE_IN_ALL +GSource *g_timeout_source_new (guint interval); +GLIB_AVAILABLE_IN_ALL +GSource *g_timeout_source_new_seconds (guint interval); + +/* Miscellaneous functions + */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62_FOR(g_get_real_time) +void g_get_current_time (GTimeVal *result); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +gint64 g_get_monotonic_time (void); +GLIB_AVAILABLE_IN_ALL +gint64 g_get_real_time (void); + + +/* Source manipulation by ID */ +GLIB_AVAILABLE_IN_ALL +gboolean g_source_remove (guint tag); +GLIB_AVAILABLE_IN_ALL +gboolean g_source_remove_by_user_data (gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gboolean g_source_remove_by_funcs_user_data (GSourceFuncs *funcs, + gpointer user_data); + +/** + * GClearHandleFunc: + * @handle_id: the handle ID to clear + * + * Specifies the type of function passed to g_clear_handle_id(). + * The implementation is expected to free the resource identified + * by @handle_id; for instance, if @handle_id is a #GSource ID, + * g_source_remove() can be used. + * + * Since: 2.56 + */ +typedef void (* GClearHandleFunc) (guint handle_id); + +GLIB_AVAILABLE_IN_2_56 +void g_clear_handle_id (guint *tag_ptr, + GClearHandleFunc clear_func); + +#undef g_clear_handle_id +#define g_clear_handle_id(tag_ptr, clear_func) \ + G_STMT_START { \ + G_STATIC_ASSERT (sizeof *(tag_ptr) == sizeof (guint)); \ + guint *_tag_ptr = (guint *) (tag_ptr); \ + guint _handle_id; \ + \ + _handle_id = *_tag_ptr; \ + if (_handle_id > 0) \ + { \ + *_tag_ptr = 0; \ + clear_func (_handle_id); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_56 + +/* Idles, child watchers and timeouts */ +GLIB_AVAILABLE_IN_ALL +guint g_timeout_add_full (gint priority, + guint interval, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +guint g_timeout_add (guint interval, + GSourceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_timeout_add_seconds_full (gint priority, + guint interval, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +guint g_timeout_add_seconds (guint interval, + GSourceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_child_watch_add_full (gint priority, + GPid pid, + GChildWatchFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +guint g_child_watch_add (GPid pid, + GChildWatchFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_idle_add (GSourceFunc function, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_idle_add_full (gint priority, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +gboolean g_idle_remove_by_data (gpointer data); + +GLIB_AVAILABLE_IN_ALL +void g_main_context_invoke_full (GMainContext *context, + gint priority, + GSourceFunc function, + gpointer data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +void g_main_context_invoke (GMainContext *context, + GSourceFunc function, + gpointer data); + +/* Hook for GClosure / GSource integration. Don't touch */ +GLIB_VAR GSourceFuncs g_timeout_funcs; +GLIB_VAR GSourceFuncs g_child_watch_funcs; +GLIB_VAR GSourceFuncs g_idle_funcs; +#ifdef G_OS_UNIX +GLIB_VAR GSourceFuncs g_unix_signal_funcs; +GLIB_VAR GSourceFuncs g_unix_fd_source_funcs; +#endif + +G_END_DECLS + +#endif /* __G_MAIN_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_STRING_H__ +#define __G_STRING_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* gunicode.h - Unicode manipulation functions + * + * Copyright (C) 1999, 2000 Tom Tromey + * Copyright 2000, 2005 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_UNICODE_H__ +#define __G_UNICODE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * gunichar: + * + * A type which can hold any UTF-32 or UCS-4 character code, + * also known as a Unicode code point. + * + * If you want to produce the UTF-8 representation of a #gunichar, + * use g_ucs4_to_utf8(). See also g_utf8_to_ucs4() for the reverse + * process. + * + * To print/scan values of this type as integer, use + * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT. + * + * The notation to express a Unicode code point in running text is + * as a hexadecimal number with four to six digits and uppercase + * letters, prefixed by the string "U+". Leading zeros are omitted, + * unless the code point would have fewer than four hexadecimal digits. + * For example, "U+0041 LATIN CAPITAL LETTER A". To print a code point + * in the U+-notation, use the format string "U+\%04"G_GINT32_FORMAT"X". + * To scan, use the format string "U+\%06"G_GINT32_FORMAT"X". + * + * |[ + * gunichar c; + * sscanf ("U+0041", "U+%06"G_GINT32_FORMAT"X", &c) + * g_print ("Read U+%04"G_GINT32_FORMAT"X", c); + * ]| + */ +typedef guint32 gunichar; + +/** + * gunichar2: + * + * A type which can hold any UTF-16 code + * pointUTF-16 also has so called + * surrogate pairs to encode characters beyond + * the BMP as pairs of 16bit numbers. Surrogate pairs cannot be stored + * in a single gunichar2 field, but all GLib functions accepting gunichar2 + * arrays will correctly interpret surrogate pairs.. + * + * To print/scan values of this type to/from text you need to convert + * to/from UTF-8, using g_utf16_to_utf8()/g_utf8_to_utf16(). + * + * To print/scan values of this type as integer, use + * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT. + */ +typedef guint16 gunichar2; + +/** + * GUnicodeType: + * @G_UNICODE_CONTROL: General category "Other, Control" (Cc) + * @G_UNICODE_FORMAT: General category "Other, Format" (Cf) + * @G_UNICODE_UNASSIGNED: General category "Other, Not Assigned" (Cn) + * @G_UNICODE_PRIVATE_USE: General category "Other, Private Use" (Co) + * @G_UNICODE_SURROGATE: General category "Other, Surrogate" (Cs) + * @G_UNICODE_LOWERCASE_LETTER: General category "Letter, Lowercase" (Ll) + * @G_UNICODE_MODIFIER_LETTER: General category "Letter, Modifier" (Lm) + * @G_UNICODE_OTHER_LETTER: General category "Letter, Other" (Lo) + * @G_UNICODE_TITLECASE_LETTER: General category "Letter, Titlecase" (Lt) + * @G_UNICODE_UPPERCASE_LETTER: General category "Letter, Uppercase" (Lu) + * @G_UNICODE_SPACING_MARK: General category "Mark, Spacing" (Mc) + * @G_UNICODE_ENCLOSING_MARK: General category "Mark, Enclosing" (Me) + * @G_UNICODE_NON_SPACING_MARK: General category "Mark, Nonspacing" (Mn) + * @G_UNICODE_DECIMAL_NUMBER: General category "Number, Decimal Digit" (Nd) + * @G_UNICODE_LETTER_NUMBER: General category "Number, Letter" (Nl) + * @G_UNICODE_OTHER_NUMBER: General category "Number, Other" (No) + * @G_UNICODE_CONNECT_PUNCTUATION: General category "Punctuation, Connector" (Pc) + * @G_UNICODE_DASH_PUNCTUATION: General category "Punctuation, Dash" (Pd) + * @G_UNICODE_CLOSE_PUNCTUATION: General category "Punctuation, Close" (Pe) + * @G_UNICODE_FINAL_PUNCTUATION: General category "Punctuation, Final quote" (Pf) + * @G_UNICODE_INITIAL_PUNCTUATION: General category "Punctuation, Initial quote" (Pi) + * @G_UNICODE_OTHER_PUNCTUATION: General category "Punctuation, Other" (Po) + * @G_UNICODE_OPEN_PUNCTUATION: General category "Punctuation, Open" (Ps) + * @G_UNICODE_CURRENCY_SYMBOL: General category "Symbol, Currency" (Sc) + * @G_UNICODE_MODIFIER_SYMBOL: General category "Symbol, Modifier" (Sk) + * @G_UNICODE_MATH_SYMBOL: General category "Symbol, Math" (Sm) + * @G_UNICODE_OTHER_SYMBOL: General category "Symbol, Other" (So) + * @G_UNICODE_LINE_SEPARATOR: General category "Separator, Line" (Zl) + * @G_UNICODE_PARAGRAPH_SEPARATOR: General category "Separator, Paragraph" (Zp) + * @G_UNICODE_SPACE_SEPARATOR: General category "Separator, Space" (Zs) + * + * These are the possible character classifications from the + * Unicode specification. + * See [Unicode Character Database](http://www.unicode.org/reports/tr44/#General_Category_Values). + */ +typedef enum +{ + G_UNICODE_CONTROL, + G_UNICODE_FORMAT, + G_UNICODE_UNASSIGNED, + G_UNICODE_PRIVATE_USE, + G_UNICODE_SURROGATE, + G_UNICODE_LOWERCASE_LETTER, + G_UNICODE_MODIFIER_LETTER, + G_UNICODE_OTHER_LETTER, + G_UNICODE_TITLECASE_LETTER, + G_UNICODE_UPPERCASE_LETTER, + G_UNICODE_SPACING_MARK, + G_UNICODE_ENCLOSING_MARK, + G_UNICODE_NON_SPACING_MARK, + G_UNICODE_DECIMAL_NUMBER, + G_UNICODE_LETTER_NUMBER, + G_UNICODE_OTHER_NUMBER, + G_UNICODE_CONNECT_PUNCTUATION, + G_UNICODE_DASH_PUNCTUATION, + G_UNICODE_CLOSE_PUNCTUATION, + G_UNICODE_FINAL_PUNCTUATION, + G_UNICODE_INITIAL_PUNCTUATION, + G_UNICODE_OTHER_PUNCTUATION, + G_UNICODE_OPEN_PUNCTUATION, + G_UNICODE_CURRENCY_SYMBOL, + G_UNICODE_MODIFIER_SYMBOL, + G_UNICODE_MATH_SYMBOL, + G_UNICODE_OTHER_SYMBOL, + G_UNICODE_LINE_SEPARATOR, + G_UNICODE_PARAGRAPH_SEPARATOR, + G_UNICODE_SPACE_SEPARATOR +} GUnicodeType; + +/** + * G_UNICODE_COMBINING_MARK: + * + * Older name for %G_UNICODE_SPACING_MARK. + * + * Deprecated: 2.30: Use %G_UNICODE_SPACING_MARK. + */ +#define G_UNICODE_COMBINING_MARK G_UNICODE_SPACING_MARK GLIB_DEPRECATED_MACRO_IN_2_30_FOR(G_UNICODE_SPACING_MARK) + +/** + * GUnicodeBreakType: + * @G_UNICODE_BREAK_MANDATORY: Mandatory Break (BK) + * @G_UNICODE_BREAK_CARRIAGE_RETURN: Carriage Return (CR) + * @G_UNICODE_BREAK_LINE_FEED: Line Feed (LF) + * @G_UNICODE_BREAK_COMBINING_MARK: Attached Characters and Combining Marks (CM) + * @G_UNICODE_BREAK_SURROGATE: Surrogates (SG) + * @G_UNICODE_BREAK_ZERO_WIDTH_SPACE: Zero Width Space (ZW) + * @G_UNICODE_BREAK_INSEPARABLE: Inseparable (IN) + * @G_UNICODE_BREAK_NON_BREAKING_GLUE: Non-breaking ("Glue") (GL) + * @G_UNICODE_BREAK_CONTINGENT: Contingent Break Opportunity (CB) + * @G_UNICODE_BREAK_SPACE: Space (SP) + * @G_UNICODE_BREAK_AFTER: Break Opportunity After (BA) + * @G_UNICODE_BREAK_BEFORE: Break Opportunity Before (BB) + * @G_UNICODE_BREAK_BEFORE_AND_AFTER: Break Opportunity Before and After (B2) + * @G_UNICODE_BREAK_HYPHEN: Hyphen (HY) + * @G_UNICODE_BREAK_NON_STARTER: Nonstarter (NS) + * @G_UNICODE_BREAK_OPEN_PUNCTUATION: Opening Punctuation (OP) + * @G_UNICODE_BREAK_CLOSE_PUNCTUATION: Closing Punctuation (CL) + * @G_UNICODE_BREAK_QUOTATION: Ambiguous Quotation (QU) + * @G_UNICODE_BREAK_EXCLAMATION: Exclamation/Interrogation (EX) + * @G_UNICODE_BREAK_IDEOGRAPHIC: Ideographic (ID) + * @G_UNICODE_BREAK_NUMERIC: Numeric (NU) + * @G_UNICODE_BREAK_INFIX_SEPARATOR: Infix Separator (Numeric) (IS) + * @G_UNICODE_BREAK_SYMBOL: Symbols Allowing Break After (SY) + * @G_UNICODE_BREAK_ALPHABETIC: Ordinary Alphabetic and Symbol Characters (AL) + * @G_UNICODE_BREAK_PREFIX: Prefix (Numeric) (PR) + * @G_UNICODE_BREAK_POSTFIX: Postfix (Numeric) (PO) + * @G_UNICODE_BREAK_COMPLEX_CONTEXT: Complex Content Dependent (South East Asian) (SA) + * @G_UNICODE_BREAK_AMBIGUOUS: Ambiguous (Alphabetic or Ideographic) (AI) + * @G_UNICODE_BREAK_UNKNOWN: Unknown (XX) + * @G_UNICODE_BREAK_NEXT_LINE: Next Line (NL) + * @G_UNICODE_BREAK_WORD_JOINER: Word Joiner (WJ) + * @G_UNICODE_BREAK_HANGUL_L_JAMO: Hangul L Jamo (JL) + * @G_UNICODE_BREAK_HANGUL_V_JAMO: Hangul V Jamo (JV) + * @G_UNICODE_BREAK_HANGUL_T_JAMO: Hangul T Jamo (JT) + * @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE: Hangul LV Syllable (H2) + * @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE: Hangul LVT Syllable (H3) + * @G_UNICODE_BREAK_CLOSE_PARANTHESIS: Closing Parenthesis (CP). Since 2.28 + * @G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER: Conditional Japanese Starter (CJ). Since: 2.32 + * @G_UNICODE_BREAK_HEBREW_LETTER: Hebrew Letter (HL). Since: 2.32 + * @G_UNICODE_BREAK_REGIONAL_INDICATOR: Regional Indicator (RI). Since: 2.36 + * @G_UNICODE_BREAK_EMOJI_BASE: Emoji Base (EB). Since: 2.50 + * @G_UNICODE_BREAK_EMOJI_MODIFIER: Emoji Modifier (EM). Since: 2.50 + * @G_UNICODE_BREAK_ZERO_WIDTH_JOINER: Zero Width Joiner (ZWJ). Since: 2.50 + * + * These are the possible line break classifications. + * + * Since new unicode versions may add new types here, applications should be ready + * to handle unknown values. They may be regarded as %G_UNICODE_BREAK_UNKNOWN. + * + * See [Unicode Line Breaking Algorithm](http://www.unicode.org/unicode/reports/tr14/). + */ +typedef enum +{ + G_UNICODE_BREAK_MANDATORY, + G_UNICODE_BREAK_CARRIAGE_RETURN, + G_UNICODE_BREAK_LINE_FEED, + G_UNICODE_BREAK_COMBINING_MARK, + G_UNICODE_BREAK_SURROGATE, + G_UNICODE_BREAK_ZERO_WIDTH_SPACE, + G_UNICODE_BREAK_INSEPARABLE, + G_UNICODE_BREAK_NON_BREAKING_GLUE, + G_UNICODE_BREAK_CONTINGENT, + G_UNICODE_BREAK_SPACE, + G_UNICODE_BREAK_AFTER, + G_UNICODE_BREAK_BEFORE, + G_UNICODE_BREAK_BEFORE_AND_AFTER, + G_UNICODE_BREAK_HYPHEN, + G_UNICODE_BREAK_NON_STARTER, + G_UNICODE_BREAK_OPEN_PUNCTUATION, + G_UNICODE_BREAK_CLOSE_PUNCTUATION, + G_UNICODE_BREAK_QUOTATION, + G_UNICODE_BREAK_EXCLAMATION, + G_UNICODE_BREAK_IDEOGRAPHIC, + G_UNICODE_BREAK_NUMERIC, + G_UNICODE_BREAK_INFIX_SEPARATOR, + G_UNICODE_BREAK_SYMBOL, + G_UNICODE_BREAK_ALPHABETIC, + G_UNICODE_BREAK_PREFIX, + G_UNICODE_BREAK_POSTFIX, + G_UNICODE_BREAK_COMPLEX_CONTEXT, + G_UNICODE_BREAK_AMBIGUOUS, + G_UNICODE_BREAK_UNKNOWN, + G_UNICODE_BREAK_NEXT_LINE, + G_UNICODE_BREAK_WORD_JOINER, + G_UNICODE_BREAK_HANGUL_L_JAMO, + G_UNICODE_BREAK_HANGUL_V_JAMO, + G_UNICODE_BREAK_HANGUL_T_JAMO, + G_UNICODE_BREAK_HANGUL_LV_SYLLABLE, + G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE, + G_UNICODE_BREAK_CLOSE_PARANTHESIS, + G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER, + G_UNICODE_BREAK_HEBREW_LETTER, + G_UNICODE_BREAK_REGIONAL_INDICATOR, + G_UNICODE_BREAK_EMOJI_BASE, + G_UNICODE_BREAK_EMOJI_MODIFIER, + G_UNICODE_BREAK_ZERO_WIDTH_JOINER +} GUnicodeBreakType; + +/** + * GUnicodeScript: + * @G_UNICODE_SCRIPT_INVALID_CODE: + * a value never returned from g_unichar_get_script() + * @G_UNICODE_SCRIPT_COMMON: a character used by multiple different scripts + * @G_UNICODE_SCRIPT_INHERITED: a mark glyph that takes its script from the + * base glyph to which it is attached + * @G_UNICODE_SCRIPT_ARABIC: Arabic + * @G_UNICODE_SCRIPT_ARMENIAN: Armenian + * @G_UNICODE_SCRIPT_BENGALI: Bengali + * @G_UNICODE_SCRIPT_BOPOMOFO: Bopomofo + * @G_UNICODE_SCRIPT_CHEROKEE: Cherokee + * @G_UNICODE_SCRIPT_COPTIC: Coptic + * @G_UNICODE_SCRIPT_CYRILLIC: Cyrillic + * @G_UNICODE_SCRIPT_DESERET: Deseret + * @G_UNICODE_SCRIPT_DEVANAGARI: Devanagari + * @G_UNICODE_SCRIPT_ETHIOPIC: Ethiopic + * @G_UNICODE_SCRIPT_GEORGIAN: Georgian + * @G_UNICODE_SCRIPT_GOTHIC: Gothic + * @G_UNICODE_SCRIPT_GREEK: Greek + * @G_UNICODE_SCRIPT_GUJARATI: Gujarati + * @G_UNICODE_SCRIPT_GURMUKHI: Gurmukhi + * @G_UNICODE_SCRIPT_HAN: Han + * @G_UNICODE_SCRIPT_HANGUL: Hangul + * @G_UNICODE_SCRIPT_HEBREW: Hebrew + * @G_UNICODE_SCRIPT_HIRAGANA: Hiragana + * @G_UNICODE_SCRIPT_KANNADA: Kannada + * @G_UNICODE_SCRIPT_KATAKANA: Katakana + * @G_UNICODE_SCRIPT_KHMER: Khmer + * @G_UNICODE_SCRIPT_LAO: Lao + * @G_UNICODE_SCRIPT_LATIN: Latin + * @G_UNICODE_SCRIPT_MALAYALAM: Malayalam + * @G_UNICODE_SCRIPT_MONGOLIAN: Mongolian + * @G_UNICODE_SCRIPT_MYANMAR: Myanmar + * @G_UNICODE_SCRIPT_OGHAM: Ogham + * @G_UNICODE_SCRIPT_OLD_ITALIC: Old Italic + * @G_UNICODE_SCRIPT_ORIYA: Oriya + * @G_UNICODE_SCRIPT_RUNIC: Runic + * @G_UNICODE_SCRIPT_SINHALA: Sinhala + * @G_UNICODE_SCRIPT_SYRIAC: Syriac + * @G_UNICODE_SCRIPT_TAMIL: Tamil + * @G_UNICODE_SCRIPT_TELUGU: Telugu + * @G_UNICODE_SCRIPT_THAANA: Thaana + * @G_UNICODE_SCRIPT_THAI: Thai + * @G_UNICODE_SCRIPT_TIBETAN: Tibetan + * @G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL: + * Canadian Aboriginal + * @G_UNICODE_SCRIPT_YI: Yi + * @G_UNICODE_SCRIPT_TAGALOG: Tagalog + * @G_UNICODE_SCRIPT_HANUNOO: Hanunoo + * @G_UNICODE_SCRIPT_BUHID: Buhid + * @G_UNICODE_SCRIPT_TAGBANWA: Tagbanwa + * @G_UNICODE_SCRIPT_BRAILLE: Braille + * @G_UNICODE_SCRIPT_CYPRIOT: Cypriot + * @G_UNICODE_SCRIPT_LIMBU: Limbu + * @G_UNICODE_SCRIPT_OSMANYA: Osmanya + * @G_UNICODE_SCRIPT_SHAVIAN: Shavian + * @G_UNICODE_SCRIPT_LINEAR_B: Linear B + * @G_UNICODE_SCRIPT_TAI_LE: Tai Le + * @G_UNICODE_SCRIPT_UGARITIC: Ugaritic + * @G_UNICODE_SCRIPT_NEW_TAI_LUE: + * New Tai Lue + * @G_UNICODE_SCRIPT_BUGINESE: Buginese + * @G_UNICODE_SCRIPT_GLAGOLITIC: Glagolitic + * @G_UNICODE_SCRIPT_TIFINAGH: Tifinagh + * @G_UNICODE_SCRIPT_SYLOTI_NAGRI: + * Syloti Nagri + * @G_UNICODE_SCRIPT_OLD_PERSIAN: + * Old Persian + * @G_UNICODE_SCRIPT_KHAROSHTHI: Kharoshthi + * @G_UNICODE_SCRIPT_UNKNOWN: an unassigned code point + * @G_UNICODE_SCRIPT_BALINESE: Balinese + * @G_UNICODE_SCRIPT_CUNEIFORM: Cuneiform + * @G_UNICODE_SCRIPT_PHOENICIAN: Phoenician + * @G_UNICODE_SCRIPT_PHAGS_PA: Phags-pa + * @G_UNICODE_SCRIPT_NKO: N'Ko + * @G_UNICODE_SCRIPT_KAYAH_LI: Kayah Li. Since 2.16.3 + * @G_UNICODE_SCRIPT_LEPCHA: Lepcha. Since 2.16.3 + * @G_UNICODE_SCRIPT_REJANG: Rejang. Since 2.16.3 + * @G_UNICODE_SCRIPT_SUNDANESE: Sundanese. Since 2.16.3 + * @G_UNICODE_SCRIPT_SAURASHTRA: Saurashtra. Since 2.16.3 + * @G_UNICODE_SCRIPT_CHAM: Cham. Since 2.16.3 + * @G_UNICODE_SCRIPT_OL_CHIKI: Ol Chiki. Since 2.16.3 + * @G_UNICODE_SCRIPT_VAI: Vai. Since 2.16.3 + * @G_UNICODE_SCRIPT_CARIAN: Carian. Since 2.16.3 + * @G_UNICODE_SCRIPT_LYCIAN: Lycian. Since 2.16.3 + * @G_UNICODE_SCRIPT_LYDIAN: Lydian. Since 2.16.3 + * @G_UNICODE_SCRIPT_AVESTAN: Avestan. Since 2.26 + * @G_UNICODE_SCRIPT_BAMUM: Bamum. Since 2.26 + * @G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS: + * Egyptian Hieroglpyhs. Since 2.26 + * @G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC: + * Imperial Aramaic. Since 2.26 + * @G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI: + * Inscriptional Pahlavi. Since 2.26 + * @G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN: + * Inscriptional Parthian. Since 2.26 + * @G_UNICODE_SCRIPT_JAVANESE: Javanese. Since 2.26 + * @G_UNICODE_SCRIPT_KAITHI: Kaithi. Since 2.26 + * @G_UNICODE_SCRIPT_LISU: Lisu. Since 2.26 + * @G_UNICODE_SCRIPT_MEETEI_MAYEK: + * Meetei Mayek. Since 2.26 + * @G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN: + * Old South Arabian. Since 2.26 + * @G_UNICODE_SCRIPT_OLD_TURKIC: Old Turkic. Since 2.28 + * @G_UNICODE_SCRIPT_SAMARITAN: Samaritan. Since 2.26 + * @G_UNICODE_SCRIPT_TAI_THAM: Tai Tham. Since 2.26 + * @G_UNICODE_SCRIPT_TAI_VIET: Tai Viet. Since 2.26 + * @G_UNICODE_SCRIPT_BATAK: Batak. Since 2.28 + * @G_UNICODE_SCRIPT_BRAHMI: Brahmi. Since 2.28 + * @G_UNICODE_SCRIPT_MANDAIC: Mandaic. Since 2.28 + * @G_UNICODE_SCRIPT_CHAKMA: Chakma. Since: 2.32 + * @G_UNICODE_SCRIPT_MEROITIC_CURSIVE: Meroitic Cursive. Since: 2.32 + * @G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS: Meroitic Hieroglyphs. Since: 2.32 + * @G_UNICODE_SCRIPT_MIAO: Miao. Since: 2.32 + * @G_UNICODE_SCRIPT_SHARADA: Sharada. Since: 2.32 + * @G_UNICODE_SCRIPT_SORA_SOMPENG: Sora Sompeng. Since: 2.32 + * @G_UNICODE_SCRIPT_TAKRI: Takri. Since: 2.32 + * @G_UNICODE_SCRIPT_BASSA_VAH: Bassa. Since: 2.42 + * @G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN: Caucasian Albanian. Since: 2.42 + * @G_UNICODE_SCRIPT_DUPLOYAN: Duployan. Since: 2.42 + * @G_UNICODE_SCRIPT_ELBASAN: Elbasan. Since: 2.42 + * @G_UNICODE_SCRIPT_GRANTHA: Grantha. Since: 2.42 + * @G_UNICODE_SCRIPT_KHOJKI: Kjohki. Since: 2.42 + * @G_UNICODE_SCRIPT_KHUDAWADI: Khudawadi, Sindhi. Since: 2.42 + * @G_UNICODE_SCRIPT_LINEAR_A: Linear A. Since: 2.42 + * @G_UNICODE_SCRIPT_MAHAJANI: Mahajani. Since: 2.42 + * @G_UNICODE_SCRIPT_MANICHAEAN: Manichaean. Since: 2.42 + * @G_UNICODE_SCRIPT_MENDE_KIKAKUI: Mende Kikakui. Since: 2.42 + * @G_UNICODE_SCRIPT_MODI: Modi. Since: 2.42 + * @G_UNICODE_SCRIPT_MRO: Mro. Since: 2.42 + * @G_UNICODE_SCRIPT_NABATAEAN: Nabataean. Since: 2.42 + * @G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN: Old North Arabian. Since: 2.42 + * @G_UNICODE_SCRIPT_OLD_PERMIC: Old Permic. Since: 2.42 + * @G_UNICODE_SCRIPT_PAHAWH_HMONG: Pahawh Hmong. Since: 2.42 + * @G_UNICODE_SCRIPT_PALMYRENE: Palmyrene. Since: 2.42 + * @G_UNICODE_SCRIPT_PAU_CIN_HAU: Pau Cin Hau. Since: 2.42 + * @G_UNICODE_SCRIPT_PSALTER_PAHLAVI: Psalter Pahlavi. Since: 2.42 + * @G_UNICODE_SCRIPT_SIDDHAM: Siddham. Since: 2.42 + * @G_UNICODE_SCRIPT_TIRHUTA: Tirhuta. Since: 2.42 + * @G_UNICODE_SCRIPT_WARANG_CITI: Warang Citi. Since: 2.42 + * @G_UNICODE_SCRIPT_AHOM: Ahom. Since: 2.48 + * @G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS: Anatolian Hieroglyphs. Since: 2.48 + * @G_UNICODE_SCRIPT_HATRAN: Hatran. Since: 2.48 + * @G_UNICODE_SCRIPT_MULTANI: Multani. Since: 2.48 + * @G_UNICODE_SCRIPT_OLD_HUNGARIAN: Old Hungarian. Since: 2.48 + * @G_UNICODE_SCRIPT_SIGNWRITING: Signwriting. Since: 2.48 + * @G_UNICODE_SCRIPT_ADLAM: Adlam. Since: 2.50 + * @G_UNICODE_SCRIPT_BHAIKSUKI: Bhaiksuki. Since: 2.50 + * @G_UNICODE_SCRIPT_MARCHEN: Marchen. Since: 2.50 + * @G_UNICODE_SCRIPT_NEWA: Newa. Since: 2.50 + * @G_UNICODE_SCRIPT_OSAGE: Osage. Since: 2.50 + * @G_UNICODE_SCRIPT_TANGUT: Tangut. Since: 2.50 + * @G_UNICODE_SCRIPT_MASARAM_GONDI: Masaram Gondi. Since: 2.54 + * @G_UNICODE_SCRIPT_NUSHU: Nushu. Since: 2.54 + * @G_UNICODE_SCRIPT_SOYOMBO: Soyombo. Since: 2.54 + * @G_UNICODE_SCRIPT_ZANABAZAR_SQUARE: Zanabazar Square. Since: 2.54 + * @G_UNICODE_SCRIPT_DOGRA: Dogra. Since: 2.58 + * @G_UNICODE_SCRIPT_GUNJALA_GONDI: Gunjala Gondi. Since: 2.58 + * @G_UNICODE_SCRIPT_HANIFI_ROHINGYA: Hanifi Rohingya. Since: 2.58 + * @G_UNICODE_SCRIPT_MAKASAR: Makasar. Since: 2.58 + * @G_UNICODE_SCRIPT_MEDEFAIDRIN: Medefaidrin. Since: 2.58 + * @G_UNICODE_SCRIPT_OLD_SOGDIAN: Old Sogdian. Since: 2.58 + * @G_UNICODE_SCRIPT_SOGDIAN: Sogdian. Since: 2.58 + * @G_UNICODE_SCRIPT_ELYMAIC: Elym. Since: 2.62 + * @G_UNICODE_SCRIPT_NANDINAGARI: Nand. Since: 2.62 + * @G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG: Rohg. Since: 2.62 + * @G_UNICODE_SCRIPT_WANCHO: Wcho. Since: 2.62 + * @G_UNICODE_SCRIPT_CHORASMIAN: Chorasmian. Since: 2.66 + * @G_UNICODE_SCRIPT_DIVES_AKURU: Dives Akuru. Since: 2.66 + * @G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT: Khitan small script. Since: 2.66 + * @G_UNICODE_SCRIPT_YEZIDI: Yezidi. Since: 2.66 + * + * The #GUnicodeScript enumeration identifies different writing + * systems. The values correspond to the names as defined in the + * Unicode standard. The enumeration has been added in GLib 2.14, + * and is interchangeable with #PangoScript. + * + * Note that new types may be added in the future. Applications + * should be ready to handle unknown values. + * See [Unicode Standard Annex #24: Script names](http://www.unicode.org/reports/tr24/). + */ +typedef enum +{ /* ISO 15924 code */ + G_UNICODE_SCRIPT_INVALID_CODE = -1, + G_UNICODE_SCRIPT_COMMON = 0, /* Zyyy */ + G_UNICODE_SCRIPT_INHERITED, /* Zinh (Qaai) */ + G_UNICODE_SCRIPT_ARABIC, /* Arab */ + G_UNICODE_SCRIPT_ARMENIAN, /* Armn */ + G_UNICODE_SCRIPT_BENGALI, /* Beng */ + G_UNICODE_SCRIPT_BOPOMOFO, /* Bopo */ + G_UNICODE_SCRIPT_CHEROKEE, /* Cher */ + G_UNICODE_SCRIPT_COPTIC, /* Copt (Qaac) */ + G_UNICODE_SCRIPT_CYRILLIC, /* Cyrl (Cyrs) */ + G_UNICODE_SCRIPT_DESERET, /* Dsrt */ + G_UNICODE_SCRIPT_DEVANAGARI, /* Deva */ + G_UNICODE_SCRIPT_ETHIOPIC, /* Ethi */ + G_UNICODE_SCRIPT_GEORGIAN, /* Geor (Geon, Geoa) */ + G_UNICODE_SCRIPT_GOTHIC, /* Goth */ + G_UNICODE_SCRIPT_GREEK, /* Grek */ + G_UNICODE_SCRIPT_GUJARATI, /* Gujr */ + G_UNICODE_SCRIPT_GURMUKHI, /* Guru */ + G_UNICODE_SCRIPT_HAN, /* Hani */ + G_UNICODE_SCRIPT_HANGUL, /* Hang */ + G_UNICODE_SCRIPT_HEBREW, /* Hebr */ + G_UNICODE_SCRIPT_HIRAGANA, /* Hira */ + G_UNICODE_SCRIPT_KANNADA, /* Knda */ + G_UNICODE_SCRIPT_KATAKANA, /* Kana */ + G_UNICODE_SCRIPT_KHMER, /* Khmr */ + G_UNICODE_SCRIPT_LAO, /* Laoo */ + G_UNICODE_SCRIPT_LATIN, /* Latn (Latf, Latg) */ + G_UNICODE_SCRIPT_MALAYALAM, /* Mlym */ + G_UNICODE_SCRIPT_MONGOLIAN, /* Mong */ + G_UNICODE_SCRIPT_MYANMAR, /* Mymr */ + G_UNICODE_SCRIPT_OGHAM, /* Ogam */ + G_UNICODE_SCRIPT_OLD_ITALIC, /* Ital */ + G_UNICODE_SCRIPT_ORIYA, /* Orya */ + G_UNICODE_SCRIPT_RUNIC, /* Runr */ + G_UNICODE_SCRIPT_SINHALA, /* Sinh */ + G_UNICODE_SCRIPT_SYRIAC, /* Syrc (Syrj, Syrn, Syre) */ + G_UNICODE_SCRIPT_TAMIL, /* Taml */ + G_UNICODE_SCRIPT_TELUGU, /* Telu */ + G_UNICODE_SCRIPT_THAANA, /* Thaa */ + G_UNICODE_SCRIPT_THAI, /* Thai */ + G_UNICODE_SCRIPT_TIBETAN, /* Tibt */ + G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL, /* Cans */ + G_UNICODE_SCRIPT_YI, /* Yiii */ + G_UNICODE_SCRIPT_TAGALOG, /* Tglg */ + G_UNICODE_SCRIPT_HANUNOO, /* Hano */ + G_UNICODE_SCRIPT_BUHID, /* Buhd */ + G_UNICODE_SCRIPT_TAGBANWA, /* Tagb */ + + /* Unicode-4.0 additions */ + G_UNICODE_SCRIPT_BRAILLE, /* Brai */ + G_UNICODE_SCRIPT_CYPRIOT, /* Cprt */ + G_UNICODE_SCRIPT_LIMBU, /* Limb */ + G_UNICODE_SCRIPT_OSMANYA, /* Osma */ + G_UNICODE_SCRIPT_SHAVIAN, /* Shaw */ + G_UNICODE_SCRIPT_LINEAR_B, /* Linb */ + G_UNICODE_SCRIPT_TAI_LE, /* Tale */ + G_UNICODE_SCRIPT_UGARITIC, /* Ugar */ + + /* Unicode-4.1 additions */ + G_UNICODE_SCRIPT_NEW_TAI_LUE, /* Talu */ + G_UNICODE_SCRIPT_BUGINESE, /* Bugi */ + G_UNICODE_SCRIPT_GLAGOLITIC, /* Glag */ + G_UNICODE_SCRIPT_TIFINAGH, /* Tfng */ + G_UNICODE_SCRIPT_SYLOTI_NAGRI, /* Sylo */ + G_UNICODE_SCRIPT_OLD_PERSIAN, /* Xpeo */ + G_UNICODE_SCRIPT_KHAROSHTHI, /* Khar */ + + /* Unicode-5.0 additions */ + G_UNICODE_SCRIPT_UNKNOWN, /* Zzzz */ + G_UNICODE_SCRIPT_BALINESE, /* Bali */ + G_UNICODE_SCRIPT_CUNEIFORM, /* Xsux */ + G_UNICODE_SCRIPT_PHOENICIAN, /* Phnx */ + G_UNICODE_SCRIPT_PHAGS_PA, /* Phag */ + G_UNICODE_SCRIPT_NKO, /* Nkoo */ + + /* Unicode-5.1 additions */ + G_UNICODE_SCRIPT_KAYAH_LI, /* Kali */ + G_UNICODE_SCRIPT_LEPCHA, /* Lepc */ + G_UNICODE_SCRIPT_REJANG, /* Rjng */ + G_UNICODE_SCRIPT_SUNDANESE, /* Sund */ + G_UNICODE_SCRIPT_SAURASHTRA, /* Saur */ + G_UNICODE_SCRIPT_CHAM, /* Cham */ + G_UNICODE_SCRIPT_OL_CHIKI, /* Olck */ + G_UNICODE_SCRIPT_VAI, /* Vaii */ + G_UNICODE_SCRIPT_CARIAN, /* Cari */ + G_UNICODE_SCRIPT_LYCIAN, /* Lyci */ + G_UNICODE_SCRIPT_LYDIAN, /* Lydi */ + + /* Unicode-5.2 additions */ + G_UNICODE_SCRIPT_AVESTAN, /* Avst */ + G_UNICODE_SCRIPT_BAMUM, /* Bamu */ + G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, /* Egyp */ + G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC, /* Armi */ + G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI, /* Phli */ + G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN, /* Prti */ + G_UNICODE_SCRIPT_JAVANESE, /* Java */ + G_UNICODE_SCRIPT_KAITHI, /* Kthi */ + G_UNICODE_SCRIPT_LISU, /* Lisu */ + G_UNICODE_SCRIPT_MEETEI_MAYEK, /* Mtei */ + G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN, /* Sarb */ + G_UNICODE_SCRIPT_OLD_TURKIC, /* Orkh */ + G_UNICODE_SCRIPT_SAMARITAN, /* Samr */ + G_UNICODE_SCRIPT_TAI_THAM, /* Lana */ + G_UNICODE_SCRIPT_TAI_VIET, /* Tavt */ + + /* Unicode-6.0 additions */ + G_UNICODE_SCRIPT_BATAK, /* Batk */ + G_UNICODE_SCRIPT_BRAHMI, /* Brah */ + G_UNICODE_SCRIPT_MANDAIC, /* Mand */ + + /* Unicode-6.1 additions */ + G_UNICODE_SCRIPT_CHAKMA, /* Cakm */ + G_UNICODE_SCRIPT_MEROITIC_CURSIVE, /* Merc */ + G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS, /* Mero */ + G_UNICODE_SCRIPT_MIAO, /* Plrd */ + G_UNICODE_SCRIPT_SHARADA, /* Shrd */ + G_UNICODE_SCRIPT_SORA_SOMPENG, /* Sora */ + G_UNICODE_SCRIPT_TAKRI, /* Takr */ + + /* Unicode 7.0 additions */ + G_UNICODE_SCRIPT_BASSA_VAH, /* Bass */ + G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN, /* Aghb */ + G_UNICODE_SCRIPT_DUPLOYAN, /* Dupl */ + G_UNICODE_SCRIPT_ELBASAN, /* Elba */ + G_UNICODE_SCRIPT_GRANTHA, /* Gran */ + G_UNICODE_SCRIPT_KHOJKI, /* Khoj */ + G_UNICODE_SCRIPT_KHUDAWADI, /* Sind */ + G_UNICODE_SCRIPT_LINEAR_A, /* Lina */ + G_UNICODE_SCRIPT_MAHAJANI, /* Mahj */ + G_UNICODE_SCRIPT_MANICHAEAN, /* Mani */ + G_UNICODE_SCRIPT_MENDE_KIKAKUI, /* Mend */ + G_UNICODE_SCRIPT_MODI, /* Modi */ + G_UNICODE_SCRIPT_MRO, /* Mroo */ + G_UNICODE_SCRIPT_NABATAEAN, /* Nbat */ + G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN, /* Narb */ + G_UNICODE_SCRIPT_OLD_PERMIC, /* Perm */ + G_UNICODE_SCRIPT_PAHAWH_HMONG, /* Hmng */ + G_UNICODE_SCRIPT_PALMYRENE, /* Palm */ + G_UNICODE_SCRIPT_PAU_CIN_HAU, /* Pauc */ + G_UNICODE_SCRIPT_PSALTER_PAHLAVI, /* Phlp */ + G_UNICODE_SCRIPT_SIDDHAM, /* Sidd */ + G_UNICODE_SCRIPT_TIRHUTA, /* Tirh */ + G_UNICODE_SCRIPT_WARANG_CITI, /* Wara */ + + /* Unicode 8.0 additions */ + G_UNICODE_SCRIPT_AHOM, /* Ahom */ + G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS, /* Hluw */ + G_UNICODE_SCRIPT_HATRAN, /* Hatr */ + G_UNICODE_SCRIPT_MULTANI, /* Mult */ + G_UNICODE_SCRIPT_OLD_HUNGARIAN, /* Hung */ + G_UNICODE_SCRIPT_SIGNWRITING, /* Sgnw */ + + /* Unicode 9.0 additions */ + G_UNICODE_SCRIPT_ADLAM, /* Adlm */ + G_UNICODE_SCRIPT_BHAIKSUKI, /* Bhks */ + G_UNICODE_SCRIPT_MARCHEN, /* Marc */ + G_UNICODE_SCRIPT_NEWA, /* Newa */ + G_UNICODE_SCRIPT_OSAGE, /* Osge */ + G_UNICODE_SCRIPT_TANGUT, /* Tang */ + + /* Unicode 10.0 additions */ + G_UNICODE_SCRIPT_MASARAM_GONDI, /* Gonm */ + G_UNICODE_SCRIPT_NUSHU, /* Nshu */ + G_UNICODE_SCRIPT_SOYOMBO, /* Soyo */ + G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, /* Zanb */ + + /* Unicode 11.0 additions */ + G_UNICODE_SCRIPT_DOGRA, /* Dogr */ + G_UNICODE_SCRIPT_GUNJALA_GONDI, /* Gong */ + G_UNICODE_SCRIPT_HANIFI_ROHINGYA, /* Rohg */ + G_UNICODE_SCRIPT_MAKASAR, /* Maka */ + G_UNICODE_SCRIPT_MEDEFAIDRIN, /* Medf */ + G_UNICODE_SCRIPT_OLD_SOGDIAN, /* Sogo */ + G_UNICODE_SCRIPT_SOGDIAN, /* Sogd */ + + /* Unicode 12.0 additions */ + G_UNICODE_SCRIPT_ELYMAIC, /* Elym */ + G_UNICODE_SCRIPT_NANDINAGARI, /* Nand */ + G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG, /* Rohg */ + G_UNICODE_SCRIPT_WANCHO, /* Wcho */ + + /* Unicode 13.0 additions */ + G_UNICODE_SCRIPT_CHORASMIAN, /* Chrs */ + G_UNICODE_SCRIPT_DIVES_AKURU, /* Diak */ + G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, /* Kits */ + G_UNICODE_SCRIPT_YEZIDI /* Yezi */ +} GUnicodeScript; + +GLIB_AVAILABLE_IN_ALL +guint32 g_unicode_script_to_iso15924 (GUnicodeScript script); +GLIB_AVAILABLE_IN_ALL +GUnicodeScript g_unicode_script_from_iso15924 (guint32 iso15924); + +/* These are all analogs of the functions. + */ +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isalnum (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isalpha (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_iscntrl (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isdigit (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isgraph (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_islower (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isprint (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_ispunct (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isspace (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isupper (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isxdigit (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_istitle (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_isdefined (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_iswide (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_iswide_cjk(gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_iszerowidth(gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_ismark (gunichar c) G_GNUC_CONST; + +/* More functions. These convert between the three cases. + * See the Unicode book to understand title case. */ +GLIB_AVAILABLE_IN_ALL +gunichar g_unichar_toupper (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gunichar g_unichar_tolower (gunichar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gunichar g_unichar_totitle (gunichar c) G_GNUC_CONST; + +/* If C is a digit (according to 'g_unichar_isdigit'), then return its + numeric value. Otherwise return -1. */ +GLIB_AVAILABLE_IN_ALL +gint g_unichar_digit_value (gunichar c) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +gint g_unichar_xdigit_value (gunichar c) G_GNUC_CONST; + +/* Return the Unicode character type of a given character. */ +GLIB_AVAILABLE_IN_ALL +GUnicodeType g_unichar_type (gunichar c) G_GNUC_CONST; + +/* Return the line break property for a given character */ +GLIB_AVAILABLE_IN_ALL +GUnicodeBreakType g_unichar_break_type (gunichar c) G_GNUC_CONST; + +/* Returns the combining class for a given character */ +GLIB_AVAILABLE_IN_ALL +gint g_unichar_combining_class (gunichar uc) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_get_mirror_char (gunichar ch, + gunichar *mirrored_ch); + +GLIB_AVAILABLE_IN_ALL +GUnicodeScript g_unichar_get_script (gunichar ch) G_GNUC_CONST; + +/* Validate a Unicode character */ +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_validate (gunichar ch) G_GNUC_CONST; + +/* Pairwise canonical compose/decompose */ +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_compose (gunichar a, + gunichar b, + gunichar *ch); +GLIB_AVAILABLE_IN_ALL +gboolean g_unichar_decompose (gunichar ch, + gunichar *a, + gunichar *b); + +GLIB_AVAILABLE_IN_ALL +gsize g_unichar_fully_decompose (gunichar ch, + gboolean compat, + gunichar *result, + gsize result_len); + +/** + * G_UNICHAR_MAX_DECOMPOSITION_LENGTH: + * + * The maximum length (in codepoints) of a compatibility or canonical + * decomposition of a single Unicode character. + * + * This is as defined by Unicode 6.1. + * + * Since: 2.32 + */ +#define G_UNICHAR_MAX_DECOMPOSITION_LENGTH 18 /* codepoints */ + +/* Compute canonical ordering of a string in-place. This rearranges + decomposed characters in the string according to their combining + classes. See the Unicode manual for more information. */ +GLIB_AVAILABLE_IN_ALL +void g_unicode_canonical_ordering (gunichar *string, + gsize len); + + +GLIB_DEPRECATED_IN_2_30 +gunichar *g_unicode_canonical_decomposition (gunichar ch, + gsize *result_len) G_GNUC_MALLOC; + +/* Array of skip-bytes-per-initial character. + */ +GLIB_VAR const gchar * const g_utf8_skip; + +/** + * g_utf8_next_char: + * @p: Pointer to the start of a valid UTF-8 character + * + * Skips to the next character in a UTF-8 string. The string must be + * valid; this macro is as fast as possible, and has no error-checking. + * You would use this macro to iterate over a string character by + * character. The macro returns the start of the next UTF-8 character. + * Before using this macro, use g_utf8_validate() to validate strings + * that may contain invalid UTF-8. + */ +#define g_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(const guchar *)(p)]) + +GLIB_AVAILABLE_IN_ALL +gunichar g_utf8_get_char (const gchar *p) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gunichar g_utf8_get_char_validated (const gchar *p, + gssize max_len) G_GNUC_PURE; + +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_offset_to_pointer (const gchar *str, + glong offset) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +glong g_utf8_pointer_to_offset (const gchar *str, + const gchar *pos) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_prev_char (const gchar *p) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_find_next_char (const gchar *p, + const gchar *end) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_find_prev_char (const gchar *str, + const gchar *p) G_GNUC_PURE; + +GLIB_AVAILABLE_IN_ALL +glong g_utf8_strlen (const gchar *p, + gssize max) G_GNUC_PURE; + +GLIB_AVAILABLE_IN_2_30 +gchar *g_utf8_substring (const gchar *str, + glong start_pos, + glong end_pos) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_strncpy (gchar *dest, + const gchar *src, + gsize n); + +/* Find the UTF-8 character corresponding to ch, in string p. These + functions are equivalants to strchr and strrchr */ +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_strchr (const gchar *p, + gssize len, + gunichar c); +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_strrchr (const gchar *p, + gssize len, + gunichar c); +GLIB_AVAILABLE_IN_ALL +gchar* g_utf8_strreverse (const gchar *str, + gssize len); + +GLIB_AVAILABLE_IN_ALL +gunichar2 *g_utf8_to_utf16 (const gchar *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gunichar * g_utf8_to_ucs4 (const gchar *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gunichar * g_utf8_to_ucs4_fast (const gchar *str, + glong len, + glong *items_written) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gunichar * g_utf16_to_ucs4 (const gunichar2 *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_utf16_to_utf8 (const gunichar2 *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gunichar2 *g_ucs4_to_utf16 (const gunichar *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_ucs4_to_utf8 (const gunichar *str, + glong len, + glong *items_read, + glong *items_written, + GError **error) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gint g_unichar_to_utf8 (gunichar c, + gchar *outbuf); + +GLIB_AVAILABLE_IN_ALL +gboolean g_utf8_validate (const gchar *str, + gssize max_len, + const gchar **end); +GLIB_AVAILABLE_IN_2_60 +gboolean g_utf8_validate_len (const gchar *str, + gsize max_len, + const gchar **end); + +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_strup (const gchar *str, + gssize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_strdown (const gchar *str, + gssize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_casefold (const gchar *str, + gssize len) G_GNUC_MALLOC; + +/** + * GNormalizeMode: + * @G_NORMALIZE_DEFAULT: standardize differences that do not affect the + * text content, such as the above-mentioned accent representation + * @G_NORMALIZE_NFD: another name for %G_NORMALIZE_DEFAULT + * @G_NORMALIZE_DEFAULT_COMPOSE: like %G_NORMALIZE_DEFAULT, but with + * composed forms rather than a maximally decomposed form + * @G_NORMALIZE_NFC: another name for %G_NORMALIZE_DEFAULT_COMPOSE + * @G_NORMALIZE_ALL: beyond %G_NORMALIZE_DEFAULT also standardize the + * "compatibility" characters in Unicode, such as SUPERSCRIPT THREE + * to the standard forms (in this case DIGIT THREE). Formatting + * information may be lost but for most text operations such + * characters should be considered the same + * @G_NORMALIZE_NFKD: another name for %G_NORMALIZE_ALL + * @G_NORMALIZE_ALL_COMPOSE: like %G_NORMALIZE_ALL, but with composed + * forms rather than a maximally decomposed form + * @G_NORMALIZE_NFKC: another name for %G_NORMALIZE_ALL_COMPOSE + * + * Defines how a Unicode string is transformed in a canonical + * form, standardizing such issues as whether a character with + * an accent is represented as a base character and combining + * accent or as a single precomposed character. Unicode strings + * should generally be normalized before comparing them. + */ +typedef enum { + G_NORMALIZE_DEFAULT, + G_NORMALIZE_NFD = G_NORMALIZE_DEFAULT, + G_NORMALIZE_DEFAULT_COMPOSE, + G_NORMALIZE_NFC = G_NORMALIZE_DEFAULT_COMPOSE, + G_NORMALIZE_ALL, + G_NORMALIZE_NFKD = G_NORMALIZE_ALL, + G_NORMALIZE_ALL_COMPOSE, + G_NORMALIZE_NFKC = G_NORMALIZE_ALL_COMPOSE +} GNormalizeMode; + +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_normalize (const gchar *str, + gssize len, + GNormalizeMode mode) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gint g_utf8_collate (const gchar *str1, + const gchar *str2) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_collate_key (const gchar *str, + gssize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar *g_utf8_collate_key_for_filename (const gchar *str, + gssize len) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_2_52 +gchar *g_utf8_make_valid (const gchar *str, + gssize len) G_GNUC_MALLOC; + +G_END_DECLS + +#endif /* __G_UNICODE_H__ */ + +G_BEGIN_DECLS + +typedef struct _GString GString; + +struct _GString +{ + gchar *str; + gsize len; + gsize allocated_len; +}; + +GLIB_AVAILABLE_IN_ALL +GString* g_string_new (const gchar *init); +GLIB_AVAILABLE_IN_ALL +GString* g_string_new_len (const gchar *init, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_sized_new (gsize dfl_size); +GLIB_AVAILABLE_IN_ALL +gchar* g_string_free (GString *string, + gboolean free_segment); +GLIB_AVAILABLE_IN_2_34 +GBytes* g_string_free_to_bytes (GString *string); +GLIB_AVAILABLE_IN_ALL +gboolean g_string_equal (const GString *v, + const GString *v2); +GLIB_AVAILABLE_IN_ALL +guint g_string_hash (const GString *str); +GLIB_AVAILABLE_IN_ALL +GString* g_string_assign (GString *string, + const gchar *rval); +GLIB_AVAILABLE_IN_ALL +GString* g_string_truncate (GString *string, + gsize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_set_size (GString *string, + gsize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_insert_len (GString *string, + gssize pos, + const gchar *val, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append (GString *string, + const gchar *val); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append_len (GString *string, + const gchar *val, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append_c (GString *string, + gchar c); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append_unichar (GString *string, + gunichar wc); +GLIB_AVAILABLE_IN_ALL +GString* g_string_prepend (GString *string, + const gchar *val); +GLIB_AVAILABLE_IN_ALL +GString* g_string_prepend_c (GString *string, + gchar c); +GLIB_AVAILABLE_IN_ALL +GString* g_string_prepend_unichar (GString *string, + gunichar wc); +GLIB_AVAILABLE_IN_ALL +GString* g_string_prepend_len (GString *string, + const gchar *val, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_insert (GString *string, + gssize pos, + const gchar *val); +GLIB_AVAILABLE_IN_ALL +GString* g_string_insert_c (GString *string, + gssize pos, + gchar c); +GLIB_AVAILABLE_IN_ALL +GString* g_string_insert_unichar (GString *string, + gssize pos, + gunichar wc); +GLIB_AVAILABLE_IN_ALL +GString* g_string_overwrite (GString *string, + gsize pos, + const gchar *val); +GLIB_AVAILABLE_IN_ALL +GString* g_string_overwrite_len (GString *string, + gsize pos, + const gchar *val, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_erase (GString *string, + gssize pos, + gssize len); +GLIB_AVAILABLE_IN_ALL +GString* g_string_ascii_down (GString *string); +GLIB_AVAILABLE_IN_ALL +GString* g_string_ascii_up (GString *string); +GLIB_AVAILABLE_IN_ALL +void g_string_vprintf (GString *string, + const gchar *format, + va_list args) + G_GNUC_PRINTF(2, 0); +GLIB_AVAILABLE_IN_ALL +void g_string_printf (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); +GLIB_AVAILABLE_IN_ALL +void g_string_append_vprintf (GString *string, + const gchar *format, + va_list args) + G_GNUC_PRINTF(2, 0); +GLIB_AVAILABLE_IN_ALL +void g_string_append_printf (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); +GLIB_AVAILABLE_IN_ALL +GString* g_string_append_uri_escaped (GString *string, + const gchar *unescaped, + const gchar *reserved_chars_allowed, + gboolean allow_utf8); + +/* -- optimize g_strig_append_c --- */ +#ifdef G_CAN_INLINE +static inline GString* +g_string_append_c_inline (GString *gstring, + gchar c) +{ + if (gstring->len + 1 < gstring->allocated_len) + { + gstring->str[gstring->len++] = c; + gstring->str[gstring->len] = 0; + } + else + g_string_insert_c (gstring, -1, c); + return gstring; +} +#undef g_string_append_c +#define g_string_append_c(gstr,c) g_string_append_c_inline (gstr, c) +#endif /* G_CAN_INLINE */ + + +GLIB_DEPRECATED +GString *g_string_down (GString *string); +GLIB_DEPRECATED +GString *g_string_up (GString *string); + +#define g_string_sprintf g_string_printf GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_string_printf) +#define g_string_sprintfa g_string_append_printf GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_string_append_printf) + +G_END_DECLS + +#endif /* __G_STRING_H__ */ + +G_BEGIN_DECLS + +/* GIOChannel + */ + +typedef struct _GIOChannel GIOChannel; +typedef struct _GIOFuncs GIOFuncs; + +typedef enum +{ + G_IO_ERROR_NONE, + G_IO_ERROR_AGAIN, + G_IO_ERROR_INVAL, + G_IO_ERROR_UNKNOWN +} GIOError; + +#define G_IO_CHANNEL_ERROR g_io_channel_error_quark() + +typedef enum +{ + /* Derived from errno */ + G_IO_CHANNEL_ERROR_FBIG, + G_IO_CHANNEL_ERROR_INVAL, + G_IO_CHANNEL_ERROR_IO, + G_IO_CHANNEL_ERROR_ISDIR, + G_IO_CHANNEL_ERROR_NOSPC, + G_IO_CHANNEL_ERROR_NXIO, + G_IO_CHANNEL_ERROR_OVERFLOW, + G_IO_CHANNEL_ERROR_PIPE, + /* Other */ + G_IO_CHANNEL_ERROR_FAILED +} GIOChannelError; + +typedef enum +{ + G_IO_STATUS_ERROR, + G_IO_STATUS_NORMAL, + G_IO_STATUS_EOF, + G_IO_STATUS_AGAIN +} GIOStatus; + +typedef enum +{ + G_SEEK_CUR, + G_SEEK_SET, + G_SEEK_END +} GSeekType; + +typedef enum +{ + G_IO_FLAG_APPEND = 1 << 0, + G_IO_FLAG_NONBLOCK = 1 << 1, + G_IO_FLAG_IS_READABLE = 1 << 2, /* Read only flag */ + G_IO_FLAG_IS_WRITABLE = 1 << 3, /* Read only flag */ + G_IO_FLAG_IS_WRITEABLE = 1 << 3, /* Misspelling in 2.29.10 and earlier */ + G_IO_FLAG_IS_SEEKABLE = 1 << 4, /* Read only flag */ + G_IO_FLAG_MASK = (1 << 5) - 1, + G_IO_FLAG_GET_MASK = G_IO_FLAG_MASK, + G_IO_FLAG_SET_MASK = G_IO_FLAG_APPEND | G_IO_FLAG_NONBLOCK +} GIOFlags; + +struct _GIOChannel +{ + /*< private >*/ + gint ref_count; + GIOFuncs *funcs; + + gchar *encoding; + GIConv read_cd; + GIConv write_cd; + gchar *line_term; /* String which indicates the end of a line of text */ + guint line_term_len; /* So we can have null in the line term */ + + gsize buf_size; + GString *read_buf; /* Raw data from the channel */ + GString *encoded_read_buf; /* Channel data converted to UTF-8 */ + GString *write_buf; /* Data ready to be written to the file */ + gchar partial_write_buf[6]; /* UTF-8 partial characters, null terminated */ + + /* Group the flags together, immediately after partial_write_buf, to save memory */ + + guint use_buffer : 1; /* The encoding uses the buffers */ + guint do_encode : 1; /* The encoding uses the GIConv coverters */ + guint close_on_unref : 1; /* Close the channel on final unref */ + guint is_readable : 1; /* Cached GIOFlag */ + guint is_writeable : 1; /* ditto */ + guint is_seekable : 1; /* ditto */ + + gpointer reserved1; + gpointer reserved2; +}; + +typedef gboolean (*GIOFunc) (GIOChannel *source, + GIOCondition condition, + gpointer data); +struct _GIOFuncs +{ + GIOStatus (*io_read) (GIOChannel *channel, + gchar *buf, + gsize count, + gsize *bytes_read, + GError **err); + GIOStatus (*io_write) (GIOChannel *channel, + const gchar *buf, + gsize count, + gsize *bytes_written, + GError **err); + GIOStatus (*io_seek) (GIOChannel *channel, + gint64 offset, + GSeekType type, + GError **err); + GIOStatus (*io_close) (GIOChannel *channel, + GError **err); + GSource* (*io_create_watch) (GIOChannel *channel, + GIOCondition condition); + void (*io_free) (GIOChannel *channel); + GIOStatus (*io_set_flags) (GIOChannel *channel, + GIOFlags flags, + GError **err); + GIOFlags (*io_get_flags) (GIOChannel *channel); +}; + +GLIB_AVAILABLE_IN_ALL +void g_io_channel_init (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +GIOChannel *g_io_channel_ref (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +void g_io_channel_unref (GIOChannel *channel); + +GLIB_DEPRECATED_FOR(g_io_channel_read_chars) +GIOError g_io_channel_read (GIOChannel *channel, + gchar *buf, + gsize count, + gsize *bytes_read); + +GLIB_DEPRECATED_FOR(g_io_channel_write_chars) +GIOError g_io_channel_write (GIOChannel *channel, + const gchar *buf, + gsize count, + gsize *bytes_written); + +GLIB_DEPRECATED_FOR(g_io_channel_seek_position) +GIOError g_io_channel_seek (GIOChannel *channel, + gint64 offset, + GSeekType type); + +GLIB_DEPRECATED_FOR(g_io_channel_shutdown) +void g_io_channel_close (GIOChannel *channel); + +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_shutdown (GIOChannel *channel, + gboolean flush, + GError **err); +GLIB_AVAILABLE_IN_ALL +guint g_io_add_watch_full (GIOChannel *channel, + gint priority, + GIOCondition condition, + GIOFunc func, + gpointer user_data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +GSource * g_io_create_watch (GIOChannel *channel, + GIOCondition condition); +GLIB_AVAILABLE_IN_ALL +guint g_io_add_watch (GIOChannel *channel, + GIOCondition condition, + GIOFunc func, + gpointer user_data); + +/* character encoding conversion involved functions. + */ + +GLIB_AVAILABLE_IN_ALL +void g_io_channel_set_buffer_size (GIOChannel *channel, + gsize size); +GLIB_AVAILABLE_IN_ALL +gsize g_io_channel_get_buffer_size (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +GIOCondition g_io_channel_get_buffer_condition (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_set_flags (GIOChannel *channel, + GIOFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOFlags g_io_channel_get_flags (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +void g_io_channel_set_line_term (GIOChannel *channel, + const gchar *line_term, + gint length); +GLIB_AVAILABLE_IN_ALL +const gchar * g_io_channel_get_line_term (GIOChannel *channel, + gint *length); +GLIB_AVAILABLE_IN_ALL +void g_io_channel_set_buffered (GIOChannel *channel, + gboolean buffered); +GLIB_AVAILABLE_IN_ALL +gboolean g_io_channel_get_buffered (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_set_encoding (GIOChannel *channel, + const gchar *encoding, + GError **error); +GLIB_AVAILABLE_IN_ALL +const gchar * g_io_channel_get_encoding (GIOChannel *channel); +GLIB_AVAILABLE_IN_ALL +void g_io_channel_set_close_on_unref (GIOChannel *channel, + gboolean do_close); +GLIB_AVAILABLE_IN_ALL +gboolean g_io_channel_get_close_on_unref (GIOChannel *channel); + + +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_flush (GIOChannel *channel, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_line (GIOChannel *channel, + gchar **str_return, + gsize *length, + gsize *terminator_pos, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_line_string (GIOChannel *channel, + GString *buffer, + gsize *terminator_pos, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_to_end (GIOChannel *channel, + gchar **str_return, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_chars (GIOChannel *channel, + gchar *buf, + gsize count, + gsize *bytes_read, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_read_unichar (GIOChannel *channel, + gunichar *thechar, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_write_chars (GIOChannel *channel, + const gchar *buf, + gssize count, + gsize *bytes_written, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_write_unichar (GIOChannel *channel, + gunichar thechar, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOStatus g_io_channel_seek_position (GIOChannel *channel, + gint64 offset, + GSeekType type, + GError **error); +GLIB_AVAILABLE_IN_ALL +GIOChannel* g_io_channel_new_file (const gchar *filename, + const gchar *mode, + GError **error); + +/* Error handling */ + +GLIB_AVAILABLE_IN_ALL +GQuark g_io_channel_error_quark (void); +GLIB_AVAILABLE_IN_ALL +GIOChannelError g_io_channel_error_from_errno (gint en); + +/* On Unix, IO channels created with this function for any file + * descriptor or socket. + * + * On Win32, this can be used either for files opened with the MSVCRT + * (the Microsoft run-time C library) _open() or _pipe, including file + * descriptors 0, 1 and 2 (corresponding to stdin, stdout and stderr), + * or for Winsock SOCKETs. If the parameter is a legal file + * descriptor, it is assumed to be such, otherwise it should be a + * SOCKET. This relies on SOCKETs and file descriptors not + * overlapping. If you want to be certain, call either + * g_io_channel_win32_new_fd() or g_io_channel_win32_new_socket() + * instead as appropriate. + * + * The term file descriptor as used in the context of Win32 refers to + * the emulated Unix-like file descriptors MSVCRT provides. The native + * corresponding concept is file HANDLE. There isn't as of yet a way to + * get GIOChannels for Win32 file HANDLEs. + */ +GLIB_AVAILABLE_IN_ALL +GIOChannel* g_io_channel_unix_new (int fd); +GLIB_AVAILABLE_IN_ALL +gint g_io_channel_unix_get_fd (GIOChannel *channel); + + +/* Hook for GClosure / GSource integration. Don't touch */ +GLIB_VAR GSourceFuncs g_io_watch_funcs; + +#ifdef G_OS_WIN32 + +/* You can use this "pseudo file descriptor" in a GPollFD to add + * polling for Windows messages. GTK applications should not do that. + */ + +#define G_WIN32_MSG_HANDLE 19981206 + +/* Use this to get a GPollFD from a GIOChannel, so that you can call + * g_io_channel_win32_poll(). After calling this you should only use + * g_io_channel_read() to read from the GIOChannel, i.e. never read() + * from the underlying file descriptor. For SOCKETs, it is possible to call + * recv(). + */ +GLIB_AVAILABLE_IN_ALL +void g_io_channel_win32_make_pollfd (GIOChannel *channel, + GIOCondition condition, + GPollFD *fd); + +/* This can be used to wait until at least one of the channels is readable. + * On Unix you would do a select() on the file descriptors of the channels. + */ +GLIB_AVAILABLE_IN_ALL +gint g_io_channel_win32_poll (GPollFD *fds, + gint n_fds, + gint timeout_); + +/* Create an IO channel for Windows messages for window handle hwnd. */ +#if GLIB_SIZEOF_VOID_P == 8 +/* We use gsize here so that it is still an integer type and not a + * pointer, like the guint in the traditional prototype. We can't use + * intptr_t as that is not portable enough. + */ +GLIB_AVAILABLE_IN_ALL +GIOChannel *g_io_channel_win32_new_messages (gsize hwnd); +#else +GLIB_AVAILABLE_IN_ALL +GIOChannel *g_io_channel_win32_new_messages (guint hwnd); +#endif + +/* Create an IO channel for C runtime (emulated Unix-like) file + * descriptors. After calling g_io_add_watch() on a IO channel + * returned by this function, you shouldn't call read() on the file + * descriptor. This is because adding polling for a file descriptor is + * implemented on Win32 by starting a thread that sits blocked in a + * read() from the file descriptor most of the time. All reads from + * the file descriptor should be done by this internal GLib + * thread. Your code should call only g_io_channel_read_chars(). + */ +GLIB_AVAILABLE_IN_ALL +GIOChannel* g_io_channel_win32_new_fd (gint fd); + +/* Get the C runtime file descriptor of a channel. */ +GLIB_AVAILABLE_IN_ALL +gint g_io_channel_win32_get_fd (GIOChannel *channel); + +/* Create an IO channel for a winsock socket. The parameter should be + * a SOCKET. Contrary to IO channels for file descriptors (on *Win32), + * you can use normal recv() or recvfrom() on sockets even if GLib + * is polling them. + */ +GLIB_AVAILABLE_IN_ALL +GIOChannel *g_io_channel_win32_new_socket (gint socket); + +GLIB_DEPRECATED_FOR(g_io_channel_win32_new_socket) +GIOChannel *g_io_channel_win32_new_stream_socket (gint socket); + +GLIB_AVAILABLE_IN_ALL +void g_io_channel_win32_set_debug (GIOChannel *channel, + gboolean flag); + +#endif + +G_END_DECLS + +#endif /* __G_IOCHANNEL_H__ */ +/* gkeyfile.h - desktop entry file parser + * + * Copyright 2004 Red Hat, Inc. + * + * Ray Strode + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_KEY_FILE_H__ +#define __G_KEY_FILE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef enum +{ + G_KEY_FILE_ERROR_UNKNOWN_ENCODING, + G_KEY_FILE_ERROR_PARSE, + G_KEY_FILE_ERROR_NOT_FOUND, + G_KEY_FILE_ERROR_KEY_NOT_FOUND, + G_KEY_FILE_ERROR_GROUP_NOT_FOUND, + G_KEY_FILE_ERROR_INVALID_VALUE +} GKeyFileError; + +#define G_KEY_FILE_ERROR g_key_file_error_quark() + +GLIB_AVAILABLE_IN_ALL +GQuark g_key_file_error_quark (void); + +typedef struct _GKeyFile GKeyFile; + +typedef enum +{ + G_KEY_FILE_NONE = 0, + G_KEY_FILE_KEEP_COMMENTS = 1 << 0, + G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1 +} GKeyFileFlags; + +GLIB_AVAILABLE_IN_ALL +GKeyFile *g_key_file_new (void); +GLIB_AVAILABLE_IN_ALL +GKeyFile *g_key_file_ref (GKeyFile *key_file); +GLIB_AVAILABLE_IN_ALL +void g_key_file_unref (GKeyFile *key_file); +GLIB_AVAILABLE_IN_ALL +void g_key_file_free (GKeyFile *key_file); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_list_separator (GKeyFile *key_file, + gchar separator); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_load_from_file (GKeyFile *key_file, + const gchar *file, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_load_from_data (GKeyFile *key_file, + const gchar *data, + gsize length, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_2_50 +gboolean g_key_file_load_from_bytes (GKeyFile *key_file, + GBytes *bytes, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_load_from_dirs (GKeyFile *key_file, + const gchar *file, + const gchar **search_dirs, + gchar **full_path, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_load_from_data_dirs (GKeyFile *key_file, + const gchar *file, + gchar **full_path, + GKeyFileFlags flags, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_to_data (GKeyFile *key_file, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_40 +gboolean g_key_file_save_to_file (GKeyFile *key_file, + const gchar *filename, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar **g_key_file_get_groups (GKeyFile *key_file, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar **g_key_file_get_keys (GKeyFile *key_file, + const gchar *group_name, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_has_group (GKeyFile *key_file, + const gchar *group_name); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_has_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_value (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_value (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *value); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *string); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_locale_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_56 +gchar *g_key_file_get_locale_for_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_locale_string (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + const gchar *string); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_get_boolean (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_boolean (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gboolean value); +GLIB_AVAILABLE_IN_ALL +gint g_key_file_get_integer (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_integer (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint value); +GLIB_AVAILABLE_IN_ALL +gint64 g_key_file_get_int64 (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_int64 (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint64 value); +GLIB_AVAILABLE_IN_ALL +guint64 g_key_file_get_uint64 (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_uint64 (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + guint64 value); +GLIB_AVAILABLE_IN_ALL +gdouble g_key_file_get_double (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_double (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gdouble value); +GLIB_AVAILABLE_IN_ALL +gchar **g_key_file_get_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar * const list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gchar **g_key_file_get_locale_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + gsize *length, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_locale_string_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *locale, + const gchar * const list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gboolean *g_key_file_get_boolean_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_boolean_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gboolean list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gint *g_key_file_get_integer_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_double_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gdouble list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gdouble *g_key_file_get_double_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gsize *length, + GError **error) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_key_file_set_integer_list (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + gint list[], + gsize length); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_set_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + const gchar *comment, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_key_file_get_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_remove_comment (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_remove_key (GKeyFile *key_file, + const gchar *group_name, + const gchar *key, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_key_file_remove_group (GKeyFile *key_file, + const gchar *group_name, + GError **error); + +/* Defines for handling freedesktop.org Desktop files */ +#define G_KEY_FILE_DESKTOP_GROUP "Desktop Entry" + +#define G_KEY_FILE_DESKTOP_KEY_TYPE "Type" +#define G_KEY_FILE_DESKTOP_KEY_VERSION "Version" +#define G_KEY_FILE_DESKTOP_KEY_NAME "Name" +#define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME "GenericName" +#define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY "NoDisplay" +#define G_KEY_FILE_DESKTOP_KEY_COMMENT "Comment" +#define G_KEY_FILE_DESKTOP_KEY_ICON "Icon" +#define G_KEY_FILE_DESKTOP_KEY_HIDDEN "Hidden" +#define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN "OnlyShowIn" +#define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN "NotShowIn" +#define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC "TryExec" +#define G_KEY_FILE_DESKTOP_KEY_EXEC "Exec" +#define G_KEY_FILE_DESKTOP_KEY_PATH "Path" +#define G_KEY_FILE_DESKTOP_KEY_TERMINAL "Terminal" +#define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE "MimeType" +#define G_KEY_FILE_DESKTOP_KEY_CATEGORIES "Categories" +#define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "StartupNotify" +#define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass" +#define G_KEY_FILE_DESKTOP_KEY_URL "URL" +#define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable" +#define G_KEY_FILE_DESKTOP_KEY_ACTIONS "Actions" + +#define G_KEY_FILE_DESKTOP_TYPE_APPLICATION "Application" +#define G_KEY_FILE_DESKTOP_TYPE_LINK "Link" +#define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY "Directory" + +G_END_DECLS + +#endif /* __G_KEY_FILE_H__ */ +/* GLIB - Library of useful routines for C programming + * gmappedfile.h: Simplified wrapper around the mmap function + * + * Copyright 2005 Matthias Clasen + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_MAPPED_FILE_H__ +#define __G_MAPPED_FILE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GMappedFile GMappedFile; + +GLIB_AVAILABLE_IN_ALL +GMappedFile *g_mapped_file_new (const gchar *filename, + gboolean writable, + GError **error); +GLIB_AVAILABLE_IN_ALL +GMappedFile *g_mapped_file_new_from_fd (gint fd, + gboolean writable, + GError **error); +GLIB_AVAILABLE_IN_ALL +gsize g_mapped_file_get_length (GMappedFile *file); +GLIB_AVAILABLE_IN_ALL +gchar *g_mapped_file_get_contents (GMappedFile *file); +GLIB_AVAILABLE_IN_2_34 +GBytes * g_mapped_file_get_bytes (GMappedFile *file); +GLIB_AVAILABLE_IN_ALL +GMappedFile *g_mapped_file_ref (GMappedFile *file); +GLIB_AVAILABLE_IN_ALL +void g_mapped_file_unref (GMappedFile *file); + +GLIB_DEPRECATED_FOR(g_mapped_file_unref) +void g_mapped_file_free (GMappedFile *file); + +G_END_DECLS + +#endif /* __G_MAPPED_FILE_H__ */ +/* gmarkup.h - Simple XML-like string parser/writer + * + * Copyright 2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_MARKUP_H__ +#define __G_MARKUP_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + + +G_BEGIN_DECLS + +/** + * GMarkupError: + * @G_MARKUP_ERROR_BAD_UTF8: text being parsed was not valid UTF-8 + * @G_MARKUP_ERROR_EMPTY: document contained nothing, or only whitespace + * @G_MARKUP_ERROR_PARSE: document was ill-formed + * @G_MARKUP_ERROR_UNKNOWN_ELEMENT: error should be set by #GMarkupParser + * functions; element wasn't known + * @G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE: error should be set by #GMarkupParser + * functions; attribute wasn't known + * @G_MARKUP_ERROR_INVALID_CONTENT: error should be set by #GMarkupParser + * functions; content was invalid + * @G_MARKUP_ERROR_MISSING_ATTRIBUTE: error should be set by #GMarkupParser + * functions; a required attribute was missing + * + * Error codes returned by markup parsing. + */ +typedef enum +{ + G_MARKUP_ERROR_BAD_UTF8, + G_MARKUP_ERROR_EMPTY, + G_MARKUP_ERROR_PARSE, + /* The following are primarily intended for specific GMarkupParser + * implementations to set. + */ + G_MARKUP_ERROR_UNKNOWN_ELEMENT, + G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, + G_MARKUP_ERROR_INVALID_CONTENT, + G_MARKUP_ERROR_MISSING_ATTRIBUTE +} GMarkupError; + +/** + * G_MARKUP_ERROR: + * + * Error domain for markup parsing. + * Errors in this domain will be from the #GMarkupError enumeration. + * See #GError for information on error domains. + */ +#define G_MARKUP_ERROR g_markup_error_quark () + +GLIB_AVAILABLE_IN_ALL +GQuark g_markup_error_quark (void); + +/** + * GMarkupParseFlags: + * @G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG: flag you should not use + * @G_MARKUP_TREAT_CDATA_AS_TEXT: When this flag is set, CDATA marked + * sections are not passed literally to the @passthrough function of + * the parser. Instead, the content of the section (without the + * ``) is + * passed to the @text function. This flag was added in GLib 2.12 + * @G_MARKUP_PREFIX_ERROR_POSITION: Normally errors caught by GMarkup + * itself have line/column information prefixed to them to let the + * caller know the location of the error. When this flag is set the + * location information is also prefixed to errors generated by the + * #GMarkupParser implementation functions + * @G_MARKUP_IGNORE_QUALIFIED: Ignore (don't report) qualified + * attributes and tags, along with their contents. A qualified + * attribute or tag is one that contains ':' in its name (ie: is in + * another namespace). Since: 2.40. + * + * Flags that affect the behaviour of the parser. + */ +typedef enum +{ + G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0, + G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1, + G_MARKUP_PREFIX_ERROR_POSITION = 1 << 2, + G_MARKUP_IGNORE_QUALIFIED = 1 << 3 +} GMarkupParseFlags; + +/** + * GMarkupParseContext: + * + * A parse context is used to parse a stream of bytes that + * you expect to contain marked-up text. + * + * See g_markup_parse_context_new(), #GMarkupParser, and so + * on for more details. + */ +typedef struct _GMarkupParseContext GMarkupParseContext; +typedef struct _GMarkupParser GMarkupParser; + +/** + * GMarkupParser: + * @start_element: Callback to invoke when the opening tag of an element + * is seen. The callback's @attribute_names and @attribute_values parameters + * are %NULL-terminated. + * @end_element: Callback to invoke when the closing tag of an element + * is seen. Note that this is also called for empty tags like + * ``. + * @text: Callback to invoke when some text is seen (text is always + * inside an element). Note that the text of an element may be spread + * over multiple calls of this function. If the + * %G_MARKUP_TREAT_CDATA_AS_TEXT flag is set, this function is also + * called for the content of CDATA marked sections. + * @passthrough: Callback to invoke for comments, processing instructions + * and doctype declarations; if you're re-writing the parsed document, + * write the passthrough text back out in the same position. If the + * %G_MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also + * called for CDATA marked sections. + * @error: Callback to invoke when an error occurs. + * + * Any of the fields in #GMarkupParser can be %NULL, in which case they + * will be ignored. Except for the @error function, any of these callbacks + * can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT, + * %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %G_MARKUP_ERROR_INVALID_CONTENT + * errors are intended to be set from these callbacks. If you set an error + * from a callback, g_markup_parse_context_parse() will report that error + * back to its caller. + */ +struct _GMarkupParser +{ + /* Called for open tags */ + void (*start_element) (GMarkupParseContext *context, + const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + gpointer user_data, + GError **error); + + /* Called for close tags */ + void (*end_element) (GMarkupParseContext *context, + const gchar *element_name, + gpointer user_data, + GError **error); + + /* Called for character data */ + /* text is not nul-terminated */ + void (*text) (GMarkupParseContext *context, + const gchar *text, + gsize text_len, + gpointer user_data, + GError **error); + + /* Called for strings that should be re-saved verbatim in this same + * position, but are not otherwise interpretable. At the moment + * this includes comments and processing instructions. + */ + /* text is not nul-terminated. */ + void (*passthrough) (GMarkupParseContext *context, + const gchar *passthrough_text, + gsize text_len, + gpointer user_data, + GError **error); + + /* Called on error, including one set by other + * methods in the vtable. The GError should not be freed. + */ + void (*error) (GMarkupParseContext *context, + GError *error, + gpointer user_data); +}; + +GLIB_AVAILABLE_IN_ALL +GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser, + GMarkupParseFlags flags, + gpointer user_data, + GDestroyNotify user_data_dnotify); +GLIB_AVAILABLE_IN_2_36 +GMarkupParseContext *g_markup_parse_context_ref (GMarkupParseContext *context); +GLIB_AVAILABLE_IN_2_36 +void g_markup_parse_context_unref (GMarkupParseContext *context); +GLIB_AVAILABLE_IN_ALL +void g_markup_parse_context_free (GMarkupParseContext *context); +GLIB_AVAILABLE_IN_ALL +gboolean g_markup_parse_context_parse (GMarkupParseContext *context, + const gchar *text, + gssize text_len, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_markup_parse_context_push (GMarkupParseContext *context, + const GMarkupParser *parser, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_markup_parse_context_pop (GMarkupParseContext *context); + +GLIB_AVAILABLE_IN_ALL +gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context, + GError **error); +GLIB_AVAILABLE_IN_ALL +const gchar * g_markup_parse_context_get_element (GMarkupParseContext *context); +GLIB_AVAILABLE_IN_ALL +const GSList * g_markup_parse_context_get_element_stack (GMarkupParseContext *context); + +/* For user-constructed error messages, has no precise semantics */ +GLIB_AVAILABLE_IN_ALL +void g_markup_parse_context_get_position (GMarkupParseContext *context, + gint *line_number, + gint *char_number); +GLIB_AVAILABLE_IN_ALL +gpointer g_markup_parse_context_get_user_data (GMarkupParseContext *context); + +/* useful when saving */ +GLIB_AVAILABLE_IN_ALL +gchar* g_markup_escape_text (const gchar *text, + gssize length); + +GLIB_AVAILABLE_IN_ALL +gchar *g_markup_printf_escaped (const char *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +gchar *g_markup_vprintf_escaped (const char *format, + va_list args) G_GNUC_PRINTF(1, 0); + +typedef enum +{ + G_MARKUP_COLLECT_INVALID, + G_MARKUP_COLLECT_STRING, + G_MARKUP_COLLECT_STRDUP, + G_MARKUP_COLLECT_BOOLEAN, + G_MARKUP_COLLECT_TRISTATE, + + G_MARKUP_COLLECT_OPTIONAL = (1 << 16) +} GMarkupCollectType; + + +/* useful from start_element */ +GLIB_AVAILABLE_IN_ALL +gboolean g_markup_collect_attributes (const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values, + GError **error, + GMarkupCollectType first_type, + const gchar *first_attr, + ...); + +G_END_DECLS + +#endif /* __G_MARKUP_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_MESSAGES_H__ +#define __G_MESSAGES_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +/* + * Copyright © 2007, 2008 Ryan Lortie + * Copyright © 2009, 2010 Codethink Limited + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_VARIANT_H__ +#define __G_VARIANT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +/* + * Copyright © 2007, 2008 Ryan Lortie + * Copyright © 2009, 2010 Codethink Limited + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#ifndef __G_VARIANT_TYPE_H__ +#define __G_VARIANT_TYPE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * GVariantType: + * + * A type in the GVariant type system. + * + * Two types may not be compared by value; use g_variant_type_equal() or + * g_variant_type_is_subtype_of(). May be copied using + * g_variant_type_copy() and freed using g_variant_type_free(). + **/ +typedef struct _GVariantType GVariantType; + +/** + * G_VARIANT_TYPE_BOOLEAN: + * + * The type of a value that can be either %TRUE or %FALSE. + **/ +#define G_VARIANT_TYPE_BOOLEAN ((const GVariantType *) "b") + +/** + * G_VARIANT_TYPE_BYTE: + * + * The type of an integer value that can range from 0 to 255. + **/ +#define G_VARIANT_TYPE_BYTE ((const GVariantType *) "y") + +/** + * G_VARIANT_TYPE_INT16: + * + * The type of an integer value that can range from -32768 to 32767. + **/ +#define G_VARIANT_TYPE_INT16 ((const GVariantType *) "n") + +/** + * G_VARIANT_TYPE_UINT16: + * + * The type of an integer value that can range from 0 to 65535. + * There were about this many people living in Toronto in the 1870s. + **/ +#define G_VARIANT_TYPE_UINT16 ((const GVariantType *) "q") + +/** + * G_VARIANT_TYPE_INT32: + * + * The type of an integer value that can range from -2147483648 to + * 2147483647. + **/ +#define G_VARIANT_TYPE_INT32 ((const GVariantType *) "i") + +/** + * G_VARIANT_TYPE_UINT32: + * + * The type of an integer value that can range from 0 to 4294967295. + * That's one number for everyone who was around in the late 1970s. + **/ +#define G_VARIANT_TYPE_UINT32 ((const GVariantType *) "u") + +/** + * G_VARIANT_TYPE_INT64: + * + * The type of an integer value that can range from + * -9223372036854775808 to 9223372036854775807. + **/ +#define G_VARIANT_TYPE_INT64 ((const GVariantType *) "x") + +/** + * G_VARIANT_TYPE_UINT64: + * + * The type of an integer value that can range from 0 + * to 18446744073709551615 (inclusive). That's a really big number, + * but a Rubik's cube can have a bit more than twice as many possible + * positions. + **/ +#define G_VARIANT_TYPE_UINT64 ((const GVariantType *) "t") + +/** + * G_VARIANT_TYPE_DOUBLE: + * + * The type of a double precision IEEE754 floating point number. + * These guys go up to about 1.80e308 (plus and minus) but miss out on + * some numbers in between. In any case, that's far greater than the + * estimated number of fundamental particles in the observable + * universe. + **/ +#define G_VARIANT_TYPE_DOUBLE ((const GVariantType *) "d") + +/** + * G_VARIANT_TYPE_STRING: + * + * The type of a string. "" is a string. %NULL is not a string. + **/ +#define G_VARIANT_TYPE_STRING ((const GVariantType *) "s") + +/** + * G_VARIANT_TYPE_OBJECT_PATH: + * + * The type of a D-Bus object reference. These are strings of a + * specific format used to identify objects at a given destination on + * the bus. + * + * If you are not interacting with D-Bus, then there is no reason to make + * use of this type. If you are, then the D-Bus specification contains a + * precise description of valid object paths. + **/ +#define G_VARIANT_TYPE_OBJECT_PATH ((const GVariantType *) "o") + +/** + * G_VARIANT_TYPE_SIGNATURE: + * + * The type of a D-Bus type signature. These are strings of a specific + * format used as type signatures for D-Bus methods and messages. + * + * If you are not interacting with D-Bus, then there is no reason to make + * use of this type. If you are, then the D-Bus specification contains a + * precise description of valid signature strings. + **/ +#define G_VARIANT_TYPE_SIGNATURE ((const GVariantType *) "g") + +/** + * G_VARIANT_TYPE_VARIANT: + * + * The type of a box that contains any other value (including another + * variant). + **/ +#define G_VARIANT_TYPE_VARIANT ((const GVariantType *) "v") + +/** + * G_VARIANT_TYPE_HANDLE: + * + * The type of a 32bit signed integer value, that by convention, is used + * as an index into an array of file descriptors that are sent alongside + * a D-Bus message. + * + * If you are not interacting with D-Bus, then there is no reason to make + * use of this type. + **/ +#define G_VARIANT_TYPE_HANDLE ((const GVariantType *) "h") + +/** + * G_VARIANT_TYPE_UNIT: + * + * The empty tuple type. Has only one instance. Known also as "triv" + * or "void". + **/ +#define G_VARIANT_TYPE_UNIT ((const GVariantType *) "()") + +/** + * G_VARIANT_TYPE_ANY: + * + * An indefinite type that is a supertype of every type (including + * itself). + **/ +#define G_VARIANT_TYPE_ANY ((const GVariantType *) "*") + +/** + * G_VARIANT_TYPE_BASIC: + * + * An indefinite type that is a supertype of every basic (ie: + * non-container) type. + **/ +#define G_VARIANT_TYPE_BASIC ((const GVariantType *) "?") + +/** + * G_VARIANT_TYPE_MAYBE: + * + * An indefinite type that is a supertype of every maybe type. + **/ +#define G_VARIANT_TYPE_MAYBE ((const GVariantType *) "m*") + +/** + * G_VARIANT_TYPE_ARRAY: + * + * An indefinite type that is a supertype of every array type. + **/ +#define G_VARIANT_TYPE_ARRAY ((const GVariantType *) "a*") + +/** + * G_VARIANT_TYPE_TUPLE: + * + * An indefinite type that is a supertype of every tuple type, + * regardless of the number of items in the tuple. + **/ +#define G_VARIANT_TYPE_TUPLE ((const GVariantType *) "r") + +/** + * G_VARIANT_TYPE_DICT_ENTRY: + * + * An indefinite type that is a supertype of every dictionary entry + * type. + **/ +#define G_VARIANT_TYPE_DICT_ENTRY ((const GVariantType *) "{?*}") + +/** + * G_VARIANT_TYPE_DICTIONARY: + * + * An indefinite type that is a supertype of every dictionary type -- + * that is, any array type that has an element type equal to any + * dictionary entry type. + **/ +#define G_VARIANT_TYPE_DICTIONARY ((const GVariantType *) "a{?*}") + +/** + * G_VARIANT_TYPE_STRING_ARRAY: + * + * The type of an array of strings. + **/ +#define G_VARIANT_TYPE_STRING_ARRAY ((const GVariantType *) "as") + +/** + * G_VARIANT_TYPE_OBJECT_PATH_ARRAY: + * + * The type of an array of object paths. + **/ +#define G_VARIANT_TYPE_OBJECT_PATH_ARRAY ((const GVariantType *) "ao") + +/** + * G_VARIANT_TYPE_BYTESTRING: + * + * The type of an array of bytes. This type is commonly used to pass + * around strings that may not be valid utf8. In that case, the + * convention is that the nul terminator character should be included as + * the last character in the array. + **/ +#define G_VARIANT_TYPE_BYTESTRING ((const GVariantType *) "ay") + +/** + * G_VARIANT_TYPE_BYTESTRING_ARRAY: + * + * The type of an array of byte strings (an array of arrays of bytes). + **/ +#define G_VARIANT_TYPE_BYTESTRING_ARRAY ((const GVariantType *) "aay") + +/** + * G_VARIANT_TYPE_VARDICT: + * + * The type of a dictionary mapping strings to variants (the ubiquitous + * "a{sv}" type). + * + * Since: 2.30 + **/ +#define G_VARIANT_TYPE_VARDICT ((const GVariantType *) "a{sv}") + + +/** + * G_VARIANT_TYPE: + * @type_string: a well-formed #GVariantType type string + * + * Converts a string to a const #GVariantType. Depending on the + * current debugging level, this function may perform a runtime check + * to ensure that @string is a valid GVariant type string. + * + * It is always a programmer error to use this macro with an invalid + * type string. If in doubt, use g_variant_type_string_is_valid() to + * check if the string is valid. + * + * Since 2.24 + **/ +#ifndef G_DISABLE_CHECKS +# define G_VARIANT_TYPE(type_string) (g_variant_type_checked_ ((type_string))) +#else +# define G_VARIANT_TYPE(type_string) ((const GVariantType *) (type_string)) +#endif + +/* type string checking */ +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_string_is_valid (const gchar *type_string); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_string_scan (const gchar *string, + const gchar *limit, + const gchar **endptr); + +/* create/destroy */ +GLIB_AVAILABLE_IN_ALL +void g_variant_type_free (GVariantType *type); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_copy (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new (const gchar *type_string); + +/* getters */ +GLIB_AVAILABLE_IN_ALL +gsize g_variant_type_get_string_length (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +const gchar * g_variant_type_peek_string (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gchar * g_variant_type_dup_string (const GVariantType *type); + +/* classification */ +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_definite (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_container (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_basic (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_maybe (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_array (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_tuple (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_dict_entry (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_variant (const GVariantType *type); + +/* for hash tables */ +GLIB_AVAILABLE_IN_ALL +guint g_variant_type_hash (gconstpointer type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_equal (gconstpointer type1, + gconstpointer type2); + +/* subtypes */ +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_type_is_subtype_of (const GVariantType *type, + const GVariantType *supertype); + +/* type iterator interface */ +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_element (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_first (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_next (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gsize g_variant_type_n_items (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_key (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_value (const GVariantType *type); + +/* constructors */ +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new_array (const GVariantType *element); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new_maybe (const GVariantType *element); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new_tuple (const GVariantType * const *items, + gint length); +GLIB_AVAILABLE_IN_ALL +GVariantType * g_variant_type_new_dict_entry (const GVariantType *key, + const GVariantType *value); + +/*< private >*/ +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_type_checked_ (const gchar *); +GLIB_AVAILABLE_IN_2_60 +gsize g_variant_type_string_get_depth_ (const gchar *type_string); + +G_END_DECLS + +#endif /* __G_VARIANT_TYPE_H__ */ + +G_BEGIN_DECLS + +typedef struct _GVariant GVariant; + +typedef enum +{ + G_VARIANT_CLASS_BOOLEAN = 'b', + G_VARIANT_CLASS_BYTE = 'y', + G_VARIANT_CLASS_INT16 = 'n', + G_VARIANT_CLASS_UINT16 = 'q', + G_VARIANT_CLASS_INT32 = 'i', + G_VARIANT_CLASS_UINT32 = 'u', + G_VARIANT_CLASS_INT64 = 'x', + G_VARIANT_CLASS_UINT64 = 't', + G_VARIANT_CLASS_HANDLE = 'h', + G_VARIANT_CLASS_DOUBLE = 'd', + G_VARIANT_CLASS_STRING = 's', + G_VARIANT_CLASS_OBJECT_PATH = 'o', + G_VARIANT_CLASS_SIGNATURE = 'g', + G_VARIANT_CLASS_VARIANT = 'v', + G_VARIANT_CLASS_MAYBE = 'm', + G_VARIANT_CLASS_ARRAY = 'a', + G_VARIANT_CLASS_TUPLE = '(', + G_VARIANT_CLASS_DICT_ENTRY = '{' +} GVariantClass; + +GLIB_AVAILABLE_IN_ALL +void g_variant_unref (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_ref (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_ref_sink (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_floating (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_take_ref (GVariant *value); + +GLIB_AVAILABLE_IN_ALL +const GVariantType * g_variant_get_type (GVariant *value); +GLIB_AVAILABLE_IN_ALL +const gchar * g_variant_get_type_string (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_of_type (GVariant *value, + const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_container (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariantClass g_variant_classify (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_boolean (gboolean value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_byte (guint8 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_int16 (gint16 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_uint16 (guint16 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_int32 (gint32 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_uint32 (guint32 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_int64 (gint64 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_uint64 (guint64 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_handle (gint32 value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_double (gdouble value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_string (const gchar *string); +GLIB_AVAILABLE_IN_2_38 +GVariant * g_variant_new_take_string (gchar *string); +GLIB_AVAILABLE_IN_2_38 +GVariant * g_variant_new_printf (const gchar *format_string, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_object_path (const gchar *object_path); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_object_path (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_signature (const gchar *signature); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_signature (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_variant (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_strv (const gchar * const *strv, + gssize length); +GLIB_AVAILABLE_IN_2_30 +GVariant * g_variant_new_objv (const gchar * const *strv, + gssize length); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_bytestring (const gchar *string); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_bytestring_array (const gchar * const *strv, + gssize length); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_fixed_array (const GVariantType *element_type, + gconstpointer elements, + gsize n_elements, + gsize element_size); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_get_boolean (GVariant *value); +GLIB_AVAILABLE_IN_ALL +guint8 g_variant_get_byte (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gint16 g_variant_get_int16 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +guint16 g_variant_get_uint16 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gint32 g_variant_get_int32 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +guint32 g_variant_get_uint32 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gint64 g_variant_get_int64 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +guint64 g_variant_get_uint64 (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gint32 g_variant_get_handle (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gdouble g_variant_get_double (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_get_variant (GVariant *value); +GLIB_AVAILABLE_IN_ALL +const gchar * g_variant_get_string (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar * g_variant_dup_string (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +const gchar ** g_variant_get_strv (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar ** g_variant_dup_strv (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_2_30 +const gchar ** g_variant_get_objv (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar ** g_variant_dup_objv (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +const gchar * g_variant_get_bytestring (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gchar * g_variant_dup_bytestring (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +const gchar ** g_variant_get_bytestring_array (GVariant *value, + gsize *length); +GLIB_AVAILABLE_IN_ALL +gchar ** g_variant_dup_bytestring_array (GVariant *value, + gsize *length); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_maybe (const GVariantType *child_type, + GVariant *child); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_array (const GVariantType *child_type, + GVariant * const *children, + gsize n_children); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_tuple (GVariant * const *children, + gsize n_children); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_dict_entry (GVariant *key, + GVariant *value); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_get_maybe (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gsize g_variant_n_children (GVariant *value); +GLIB_AVAILABLE_IN_ALL +void g_variant_get_child (GVariant *value, + gsize index_, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_get_child_value (GVariant *value, + gsize index_); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_lookup (GVariant *dictionary, + const gchar *key, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_lookup_value (GVariant *dictionary, + const gchar *key, + const GVariantType *expected_type); +GLIB_AVAILABLE_IN_ALL +gconstpointer g_variant_get_fixed_array (GVariant *value, + gsize *n_elements, + gsize element_size); + +GLIB_AVAILABLE_IN_ALL +gsize g_variant_get_size (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gconstpointer g_variant_get_data (GVariant *value); +GLIB_AVAILABLE_IN_2_36 +GBytes * g_variant_get_data_as_bytes (GVariant *value); +GLIB_AVAILABLE_IN_ALL +void g_variant_store (GVariant *value, + gpointer data); + +GLIB_AVAILABLE_IN_ALL +gchar * g_variant_print (GVariant *value, + gboolean type_annotate); +GLIB_AVAILABLE_IN_ALL +GString * g_variant_print_string (GVariant *value, + GString *string, + gboolean type_annotate); + +GLIB_AVAILABLE_IN_ALL +guint g_variant_hash (gconstpointer value); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_equal (gconstpointer one, + gconstpointer two); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_get_normal_form (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_is_normal_form (GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_byteswap (GVariant *value); + +GLIB_AVAILABLE_IN_2_36 +GVariant * g_variant_new_from_bytes (const GVariantType *type, + GBytes *bytes, + gboolean trusted); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_from_data (const GVariantType *type, + gconstpointer data, + gsize size, + gboolean trusted, + GDestroyNotify notify, + gpointer user_data); + +typedef struct _GVariantIter GVariantIter; +struct _GVariantIter { + /*< private >*/ + gsize x[16]; +}; + +GLIB_AVAILABLE_IN_ALL +GVariantIter * g_variant_iter_new (GVariant *value); +GLIB_AVAILABLE_IN_ALL +gsize g_variant_iter_init (GVariantIter *iter, + GVariant *value); +GLIB_AVAILABLE_IN_ALL +GVariantIter * g_variant_iter_copy (GVariantIter *iter); +GLIB_AVAILABLE_IN_ALL +gsize g_variant_iter_n_children (GVariantIter *iter); +GLIB_AVAILABLE_IN_ALL +void g_variant_iter_free (GVariantIter *iter); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_iter_next_value (GVariantIter *iter); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_iter_next (GVariantIter *iter, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +gboolean g_variant_iter_loop (GVariantIter *iter, + const gchar *format_string, + ...); + + +typedef struct _GVariantBuilder GVariantBuilder; +struct _GVariantBuilder { + /*< private >*/ + union + { + struct { + gsize partial_magic; + const GVariantType *type; + gsize y[14]; + } s; + gsize x[16]; + } u; +}; + +typedef enum +{ + G_VARIANT_PARSE_ERROR_FAILED, + G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED, + G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE, + G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED, + G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END, + G_VARIANT_PARSE_ERROR_INVALID_CHARACTER, + G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING, + G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH, + G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE, + G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING, + G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE, + G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE, + G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG, + G_VARIANT_PARSE_ERROR_TYPE_ERROR, + G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN, + G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD, + G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT, + G_VARIANT_PARSE_ERROR_VALUE_EXPECTED, + G_VARIANT_PARSE_ERROR_RECURSION +} GVariantParseError; +#define G_VARIANT_PARSE_ERROR (g_variant_parse_error_quark ()) + +GLIB_DEPRECATED_IN_2_38_FOR(g_variant_parse_error_quark) +GQuark g_variant_parser_get_error_quark (void); + +GLIB_AVAILABLE_IN_ALL +GQuark g_variant_parse_error_quark (void); + +/** + * G_VARIANT_BUILDER_INIT: + * @variant_type: a const GVariantType* + * + * A stack-allocated #GVariantBuilder must be initialized if it is + * used together with g_auto() to avoid warnings or crashes if + * function returns before g_variant_builder_init() is called on the + * builder. This macro can be used as initializer instead of an + * explicit zeroing a variable when declaring it and a following + * g_variant_builder_init(), but it cannot be assigned to a variable. + * + * The passed @variant_type should be a static GVariantType to avoid + * lifetime issues, as copying the @variant_type does not happen in + * the G_VARIANT_BUILDER_INIT() call, but rather in functions that + * make sure that #GVariantBuilder is valid. + * + * |[ + * g_auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_BYTESTRING); + * ]| + * + * Since: 2.50 + */ +#define G_VARIANT_BUILDER_INIT(variant_type) { { { 2942751021u, variant_type, { 0, } } } } + +GLIB_AVAILABLE_IN_ALL +GVariantBuilder * g_variant_builder_new (const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_unref (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +GVariantBuilder * g_variant_builder_ref (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_init (GVariantBuilder *builder, + const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_builder_end (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_clear (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_open (GVariantBuilder *builder, + const GVariantType *type); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_close (GVariantBuilder *builder); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_add_value (GVariantBuilder *builder, + GVariant *value); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_add (GVariantBuilder *builder, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +void g_variant_builder_add_parsed (GVariantBuilder *builder, + const gchar *format, + ...); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new (const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +void g_variant_get (GVariant *value, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_va (const gchar *format_string, + const gchar **endptr, + va_list *app); +GLIB_AVAILABLE_IN_ALL +void g_variant_get_va (GVariant *value, + const gchar *format_string, + const gchar **endptr, + va_list *app); +GLIB_AVAILABLE_IN_2_34 +gboolean g_variant_check_format_string (GVariant *value, + const gchar *format_string, + gboolean copy_only); + +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_parse (const GVariantType *type, + const gchar *text, + const gchar *limit, + const gchar **endptr, + GError **error); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_parsed (const gchar *format, + ...); +GLIB_AVAILABLE_IN_ALL +GVariant * g_variant_new_parsed_va (const gchar *format, + va_list *app); + +GLIB_AVAILABLE_IN_2_40 +gchar * g_variant_parse_error_print_context (GError *error, + const gchar *source_str); + +GLIB_AVAILABLE_IN_ALL +gint g_variant_compare (gconstpointer one, + gconstpointer two); + +typedef struct _GVariantDict GVariantDict; +struct _GVariantDict { + /*< private >*/ + union + { + struct { + GVariant *asv; + gsize partial_magic; + gsize y[14]; + } s; + gsize x[16]; + } u; +}; + +/** + * G_VARIANT_DICT_INIT: + * @asv: (nullable): a GVariant* + * + * A stack-allocated #GVariantDict must be initialized if it is used + * together with g_auto() to avoid warnings or crashes if function + * returns before g_variant_dict_init() is called on the builder. + * This macro can be used as initializer instead of an explicit + * zeroing a variable when declaring it and a following + * g_variant_dict_init(), but it cannot be assigned to a variable. + * + * The passed @asv has to live long enough for #GVariantDict to gather + * the entries from, as the gathering does not happen in the + * G_VARIANT_DICT_INIT() call, but rather in functions that make sure + * that #GVariantDict is valid. In context where the initialization + * value has to be a constant expression, the only possible value of + * @asv is %NULL. It is still possible to call g_variant_dict_init() + * safely with a different @asv right after the variable was + * initialized with G_VARIANT_DICT_INIT(). + * + * |[ + * g_autoptr(GVariant) variant = get_asv_variant (); + * g_auto(GVariantDict) dict = G_VARIANT_DICT_INIT (variant); + * ]| + * + * Since: 2.50 + */ +#define G_VARIANT_DICT_INIT(asv) { { { asv, 3488698669u, { 0, } } } } + +GLIB_AVAILABLE_IN_2_40 +GVariantDict * g_variant_dict_new (GVariant *from_asv); + +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_init (GVariantDict *dict, + GVariant *from_asv); + +GLIB_AVAILABLE_IN_2_40 +gboolean g_variant_dict_lookup (GVariantDict *dict, + const gchar *key, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_2_40 +GVariant * g_variant_dict_lookup_value (GVariantDict *dict, + const gchar *key, + const GVariantType *expected_type); +GLIB_AVAILABLE_IN_2_40 +gboolean g_variant_dict_contains (GVariantDict *dict, + const gchar *key); +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_insert (GVariantDict *dict, + const gchar *key, + const gchar *format_string, + ...); +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_insert_value (GVariantDict *dict, + const gchar *key, + GVariant *value); +GLIB_AVAILABLE_IN_2_40 +gboolean g_variant_dict_remove (GVariantDict *dict, + const gchar *key); +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_clear (GVariantDict *dict); +GLIB_AVAILABLE_IN_2_40 +GVariant * g_variant_dict_end (GVariantDict *dict); +GLIB_AVAILABLE_IN_2_40 +GVariantDict * g_variant_dict_ref (GVariantDict *dict); +GLIB_AVAILABLE_IN_2_40 +void g_variant_dict_unref (GVariantDict *dict); + +G_END_DECLS + +#endif /* __G_VARIANT_H__ */ + +G_BEGIN_DECLS + +/* calculate a string size, guaranteed to fit format + args. + */ +GLIB_AVAILABLE_IN_ALL +gsize g_printf_string_upper_bound (const gchar* format, + va_list args) G_GNUC_PRINTF(1, 0); + +/* Log level shift offset for user defined + * log levels (0-7 are used by GLib). + */ +#define G_LOG_LEVEL_USER_SHIFT (8) + +/* Glib log levels and flags. + */ +typedef enum +{ + /* log flags */ + G_LOG_FLAG_RECURSION = 1 << 0, + G_LOG_FLAG_FATAL = 1 << 1, + + /* GLib log levels */ + G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */ + G_LOG_LEVEL_CRITICAL = 1 << 3, + G_LOG_LEVEL_WARNING = 1 << 4, + G_LOG_LEVEL_MESSAGE = 1 << 5, + G_LOG_LEVEL_INFO = 1 << 6, + G_LOG_LEVEL_DEBUG = 1 << 7, + + G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL) +} GLogLevelFlags; + +/* GLib log levels that are considered fatal by default */ +#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR) + +typedef void (*GLogFunc) (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data); + +/* Logging mechanism + */ +GLIB_AVAILABLE_IN_ALL +guint g_log_set_handler (const gchar *log_domain, + GLogLevelFlags log_levels, + GLogFunc log_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_46 +guint g_log_set_handler_full (const gchar *log_domain, + GLogLevelFlags log_levels, + GLogFunc log_func, + gpointer user_data, + GDestroyNotify destroy); +GLIB_AVAILABLE_IN_ALL +void g_log_remove_handler (const gchar *log_domain, + guint handler_id); +GLIB_AVAILABLE_IN_ALL +void g_log_default_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer unused_data); +GLIB_AVAILABLE_IN_ALL +GLogFunc g_log_set_default_handler (GLogFunc log_func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_log (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *format, + ...) G_GNUC_PRINTF (3, 4); +GLIB_AVAILABLE_IN_ALL +void g_logv (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *format, + va_list args) G_GNUC_PRINTF(3, 0); +GLIB_AVAILABLE_IN_ALL +GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, + GLogLevelFlags fatal_mask); +GLIB_AVAILABLE_IN_ALL +GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask); + +/* Structured logging mechanism. */ + +/** + * GLogWriterOutput: + * @G_LOG_WRITER_HANDLED: Log writer has handled the log entry. + * @G_LOG_WRITER_UNHANDLED: Log writer could not handle the log entry. + * + * Return values from #GLogWriterFuncs to indicate whether the given log entry + * was successfully handled by the writer, or whether there was an error in + * handling it (and hence a fallback writer should be used). + * + * If a #GLogWriterFunc ignores a log entry, it should return + * %G_LOG_WRITER_HANDLED. + * + * Since: 2.50 + */ +typedef enum +{ + G_LOG_WRITER_HANDLED = 1, + G_LOG_WRITER_UNHANDLED = 0, +} GLogWriterOutput; + +/** + * GLogField: + * @key: field name (UTF-8 string) + * @value: field value (arbitrary bytes) + * @length: length of @value, in bytes, or -1 if it is nul-terminated + * + * Structure representing a single field in a structured log entry. See + * g_log_structured() for details. + * + * Log fields may contain arbitrary values, including binary with embedded nul + * bytes. If the field contains a string, the string must be UTF-8 encoded and + * have a trailing nul byte. Otherwise, @length must be set to a non-negative + * value. + * + * Since: 2.50 + */ +typedef struct _GLogField GLogField; +struct _GLogField +{ + const gchar *key; + gconstpointer value; + gssize length; +}; + +/** + * GLogWriterFunc: + * @log_level: log level of the message + * @fields: (array length=n_fields): fields forming the message + * @n_fields: number of @fields + * @user_data: user data passed to g_log_set_writer_func() + * + * Writer function for log entries. A log entry is a collection of one or more + * #GLogFields, using the standard [field names from journal + * specification](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html). + * See g_log_structured() for more information. + * + * Writer functions must ignore fields which they do not recognise, unless they + * can write arbitrary binary output, as field values may be arbitrary binary. + * + * @log_level is guaranteed to be included in @fields as the `PRIORITY` field, + * but is provided separately for convenience of deciding whether or where to + * output the log entry. + * + * Writer functions should return %G_LOG_WRITER_HANDLED if they handled the log + * message successfully or if they deliberately ignored it. If there was an + * error handling the message (for example, if the writer function is meant to + * send messages to a remote logging server and there is a network error), it + * should return %G_LOG_WRITER_UNHANDLED. This allows writer functions to be + * chained and fall back to simpler handlers in case of failure. + * + * Returns: %G_LOG_WRITER_HANDLED if the log entry was handled successfully; + * %G_LOG_WRITER_UNHANDLED otherwise + * Since: 2.50 + */ +typedef GLogWriterOutput (*GLogWriterFunc) (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_50 +void g_log_structured (const gchar *log_domain, + GLogLevelFlags log_level, + ...); +GLIB_AVAILABLE_IN_2_50 +void g_log_structured_array (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields); + +GLIB_AVAILABLE_IN_2_50 +void g_log_variant (const gchar *log_domain, + GLogLevelFlags log_level, + GVariant *fields); + +GLIB_AVAILABLE_IN_2_50 +void g_log_set_writer_func (GLogWriterFunc func, + gpointer user_data, + GDestroyNotify user_data_free); + +GLIB_AVAILABLE_IN_2_50 +gboolean g_log_writer_supports_color (gint output_fd); +GLIB_AVAILABLE_IN_2_50 +gboolean g_log_writer_is_journald (gint output_fd); + +GLIB_AVAILABLE_IN_2_50 +gchar *g_log_writer_format_fields (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gboolean use_color); + +GLIB_AVAILABLE_IN_2_50 +GLogWriterOutput g_log_writer_journald (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); +GLIB_AVAILABLE_IN_2_50 +GLogWriterOutput g_log_writer_standard_streams (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); +GLIB_AVAILABLE_IN_2_50 +GLogWriterOutput g_log_writer_default (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_68 +void g_log_writer_default_set_use_stderr (gboolean use_stderr); +GLIB_AVAILABLE_IN_2_68 +gboolean g_log_writer_default_would_drop (GLogLevelFlags log_level, + const char *log_domain); + +/** + * G_DEBUG_HERE: + * + * A convenience form of g_log_structured(), recommended to be added to + * functions when debugging. It prints the current monotonic time and the code + * location using %G_STRLOC. + * + * Since: 2.50 + */ +#define G_DEBUG_HERE() \ + g_log_structured (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + "CODE_FILE", __FILE__, \ + "CODE_LINE", G_STRINGIFY (__LINE__), \ + "CODE_FUNC", G_STRFUNC, \ + "MESSAGE", "%" G_GINT64_FORMAT ": %s", \ + g_get_monotonic_time (), G_STRLOC) + +/* internal */ +void _g_log_fallback_handler (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer unused_data); + +/* Internal functions, used to implement the following macros */ +GLIB_AVAILABLE_IN_ALL +void g_return_if_fail_warning (const char *log_domain, + const char *pretty_function, + const char *expression) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +void g_warn_message (const char *domain, + const char *file, + int line, + const char *func, + const char *warnexpr) G_ANALYZER_NORETURN; +GLIB_DEPRECATED +G_NORETURN +void g_assert_warning (const char *log_domain, + const char *file, + const int line, + const char *pretty_function, + const char *expression); + +GLIB_AVAILABLE_IN_2_56 +void g_log_structured_standard (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *file, + const gchar *line, + const gchar *func, + const gchar *message_format, + ...) G_GNUC_PRINTF (6, 7); + +#ifndef G_LOG_DOMAIN +#define G_LOG_DOMAIN ((gchar*) 0) +#endif /* G_LOG_DOMAIN */ + +#if defined(G_HAVE_ISO_VARARGS) && !G_ANALYZER_ANALYZING +#if defined(G_LOG_USE_STRUCTURED) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 +#define g_error(...) G_STMT_START { \ + g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__); \ + for (;;) ; \ + } G_STMT_END +#define g_message(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#define g_critical(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#define g_warning(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#define g_info(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#define g_debug(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, __VA_ARGS__) +#else +/* for(;;) ; so that GCC knows that control doesn't go past g_error(). + * Put space before ending semicolon to avoid C++ build warnings. + */ +#define g_error(...) G_STMT_START { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + __VA_ARGS__); \ + for (;;) ; \ + } G_STMT_END +#define g_message(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_MESSAGE, \ + __VA_ARGS__) +#define g_critical(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + __VA_ARGS__) +#define g_warning(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_WARNING, \ + __VA_ARGS__) +#define g_info(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_INFO, \ + __VA_ARGS__) +#define g_debug(...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_DEBUG, \ + __VA_ARGS__) +#endif +#elif defined(G_HAVE_GNUC_VARARGS) && !G_ANALYZER_ANALYZING +#if defined(G_LOG_USE_STRUCTURED) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 +#define g_error(format...) G_STMT_START { \ + g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format); \ + for (;;) ; \ + } G_STMT_END +#define g_message(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#define g_critical(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#define g_warning(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#define g_info(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#define g_debug(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ + __FILE__, G_STRINGIFY (__LINE__), \ + G_STRFUNC, format) +#else +#define g_error(format...) G_STMT_START { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_ERROR, \ + format); \ + for (;;) ; \ + } G_STMT_END + +#define g_message(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_MESSAGE, \ + format) +#define g_critical(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + format) +#define g_warning(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_WARNING, \ + format) +#define g_info(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_INFO, \ + format) +#define g_debug(format...) g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_DEBUG, \ + format) +#endif +#else /* no varargs macros */ +static G_NORETURN void g_error (const gchar *format, ...) G_ANALYZER_NORETURN; +static void g_critical (const gchar *format, ...) G_ANALYZER_NORETURN; + +static inline void +g_error (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args); + va_end (args); + + for(;;) ; +} +static inline void +g_message (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args); + va_end (args); +} +static inline void +g_critical (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, args); + va_end (args); +} +static inline void +g_warning (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args); + va_end (args); +} +static inline void +g_info (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format, args); + va_end (args); +} +static inline void +g_debug (const gchar *format, + ...) +{ + va_list args; + va_start (args, format); + g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); + va_end (args); +} +#endif /* !__GNUC__ */ + +/** + * g_warning_once: + * @...: format string, followed by parameters to insert + * into the format string (as with printf()) + * + * Logs a warning only once. + * + * g_warning_once() calls g_warning() with the passed message the first time + * the statement is executed; subsequent times it is a no-op. + * + * Note! On platforms where the compiler doesn't support variadic macros, the + * warning is printed each time instead of only once. + * + * Since: 2.64 + */ +#if defined(G_HAVE_ISO_VARARGS) && !G_ANALYZER_ANALYZING +#define g_warning_once(...) \ + G_STMT_START { \ + static int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; /* (atomic) */ \ + if (g_atomic_int_compare_and_exchange (&G_PASTE (_GWarningOnceBoolean, __LINE__), \ + 0, 1)) \ + g_warning (__VA_ARGS__); \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_64 +#elif defined(G_HAVE_GNUC_VARARGS) && !G_ANALYZER_ANALYZING +#define g_warning_once(format...) \ + G_STMT_START { \ + static int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; /* (atomic) */ \ + if (g_atomic_int_compare_and_exchange (&G_PASTE (_GWarningOnceBoolean, __LINE__), \ + 0, 1)) \ + g_warning (format); \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_64 +#else +#define g_warning_once g_warning +#endif + +/** + * GPrintFunc: + * @string: the message to output + * + * Specifies the type of the print handler functions. + * These are called with the complete formatted string to output. + */ +typedef void (*GPrintFunc) (const gchar *string); +GLIB_AVAILABLE_IN_ALL +void g_print (const gchar *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +GPrintFunc g_set_print_handler (GPrintFunc func); +GLIB_AVAILABLE_IN_ALL +void g_printerr (const gchar *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +GPrintFunc g_set_printerr_handler (GPrintFunc func); + +/** + * g_warn_if_reached: + * + * Logs a warning. + * + * Since: 2.16 + */ +#define g_warn_if_reached() \ + do { \ + g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); \ + } while (0) + +/** + * g_warn_if_fail: + * @expr: the expression to check + * + * Logs a warning if the expression is not true. + * + * Since: 2.16 + */ +#define g_warn_if_fail(expr) \ + do { \ + if G_LIKELY (expr) ; \ + else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, #expr); \ + } while (0) + +#ifdef G_DISABLE_CHECKS + +/** + * g_return_if_fail: + * @expr: the expression to check + * + * Verifies that the expression @expr, usually representing a precondition, + * evaluates to %TRUE. If the function returns a value, use + * g_return_val_if_fail() instead. + * + * If @expr evaluates to %FALSE, the current function should be considered to + * have undefined behaviour (a programmer error). The only correct solution + * to such an error is to change the module that is calling the current + * function, so that it avoids this incorrect call. + * + * To make this undefined behaviour visible, if @expr evaluates to %FALSE, + * the result is usually that a critical message is logged and the current + * function returns. + * + * If `G_DISABLE_CHECKS` is defined then the check is not performed. You + * should therefore not depend on any side effects of @expr. + * + * To debug failure of a g_return_if_fail() check, run the code under a debugger + * with `G_DEBUG=fatal-criticals` or `G_DEBUG=fatal-warnings` defined in the + * environment (see [Running GLib Applications](glib-running.html)): + * + * |[ + * G_DEBUG=fatal-warnings gdb ./my-program + * ]| + * + * Any unrelated failures can be skipped over in + * [gdb](https://www.gnu.org/software/gdb/) using the `continue` command. + */ +#define g_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END + +/** + * g_return_val_if_fail: + * @expr: the expression to check + * @val: the value to return from the current function + * if the expression is not true + * + * Verifies that the expression @expr, usually representing a precondition, + * evaluates to %TRUE. If the function does not return a value, use + * g_return_if_fail() instead. + * + * If @expr evaluates to %FALSE, the current function should be considered to + * have undefined behaviour (a programmer error). The only correct solution + * to such an error is to change the module that is calling the current + * function, so that it avoids this incorrect call. + * + * To make this undefined behaviour visible, if @expr evaluates to %FALSE, + * the result is usually that a critical message is logged and @val is + * returned from the current function. + * + * If `G_DISABLE_CHECKS` is defined then the check is not performed. You + * should therefore not depend on any side effects of @expr. + * + * See g_return_if_fail() for guidance on how to debug failure of this check. + */ +#define g_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END + +/** + * g_return_if_reached: + * + * Logs a critical message and returns from the current function. + * This can only be used in functions which do not return a value. + * + * See g_return_if_fail() for guidance on how to debug failure of this check. + */ +#define g_return_if_reached() G_STMT_START{ return; }G_STMT_END + +/** + * g_return_val_if_reached: + * @val: the value to return from the current function + * + * Logs a critical message and returns @val. + * + * See g_return_if_fail() for guidance on how to debug failure of this check. + */ +#define g_return_val_if_reached(val) G_STMT_START{ return (val); }G_STMT_END + +#else /* !G_DISABLE_CHECKS */ + +#define g_return_if_fail(expr) \ + G_STMT_START { \ + if (G_LIKELY (expr)) \ + { } \ + else \ + { \ + g_return_if_fail_warning (G_LOG_DOMAIN, \ + G_STRFUNC, \ + #expr); \ + return; \ + } \ + } G_STMT_END + +#define g_return_val_if_fail(expr, val) \ + G_STMT_START { \ + if (G_LIKELY (expr)) \ + { } \ + else \ + { \ + g_return_if_fail_warning (G_LOG_DOMAIN, \ + G_STRFUNC, \ + #expr); \ + return (val); \ + } \ + } G_STMT_END + +#define g_return_if_reached() \ + G_STMT_START { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d (%s): should not be reached", \ + __FILE__, \ + __LINE__, \ + G_STRFUNC); \ + return; \ + } G_STMT_END + +#define g_return_val_if_reached(val) \ + G_STMT_START { \ + g_log (G_LOG_DOMAIN, \ + G_LOG_LEVEL_CRITICAL, \ + "file %s: line %d (%s): should not be reached", \ + __FILE__, \ + __LINE__, \ + G_STRFUNC); \ + return (val); \ + } G_STMT_END + +#endif /* !G_DISABLE_CHECKS */ + +G_END_DECLS + +#endif /* __G_MESSAGES_H__ */ +/* goption.h - Option parser + * + * Copyright (C) 2004 Anders Carlsson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_OPTION_H__ +#define __G_OPTION_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * GOptionContext: + * + * A `GOptionContext` struct defines which options + * are accepted by the commandline option parser. The struct has only private + * fields and should not be directly accessed. + */ +typedef struct _GOptionContext GOptionContext; + +/** + * GOptionGroup: + * + * A `GOptionGroup` struct defines the options in a single + * group. The struct has only private fields and should not be directly accessed. + * + * All options in a group share the same translation function. Libraries which + * need to parse commandline options are expected to provide a function for + * getting a `GOptionGroup` holding their options, which + * the application can then add to its #GOptionContext. + */ +typedef struct _GOptionGroup GOptionGroup; +typedef struct _GOptionEntry GOptionEntry; + +/** + * GOptionFlags: + * @G_OPTION_FLAG_NONE: No flags. Since: 2.42. + * @G_OPTION_FLAG_HIDDEN: The option doesn't appear in `--help` output. + * @G_OPTION_FLAG_IN_MAIN: The option appears in the main section of the + * `--help` output, even if it is defined in a group. + * @G_OPTION_FLAG_REVERSE: For options of the %G_OPTION_ARG_NONE kind, this + * flag indicates that the sense of the option is reversed. + * @G_OPTION_FLAG_NO_ARG: For options of the %G_OPTION_ARG_CALLBACK kind, + * this flag indicates that the callback does not take any argument + * (like a %G_OPTION_ARG_NONE option). Since 2.8 + * @G_OPTION_FLAG_FILENAME: For options of the %G_OPTION_ARG_CALLBACK + * kind, this flag indicates that the argument should be passed to the + * callback in the GLib filename encoding rather than UTF-8. Since 2.8 + * @G_OPTION_FLAG_OPTIONAL_ARG: For options of the %G_OPTION_ARG_CALLBACK + * kind, this flag indicates that the argument supply is optional. + * If no argument is given then data of %GOptionParseFunc will be + * set to NULL. Since 2.8 + * @G_OPTION_FLAG_NOALIAS: This flag turns off the automatic conflict + * resolution which prefixes long option names with `groupname-` if + * there is a conflict. This option should only be used in situations + * where aliasing is necessary to model some legacy commandline interface. + * It is not safe to use this option, unless all option groups are under + * your direct control. Since 2.8. + * + * Flags which modify individual options. + */ +typedef enum +{ + G_OPTION_FLAG_NONE = 0, + G_OPTION_FLAG_HIDDEN = 1 << 0, + G_OPTION_FLAG_IN_MAIN = 1 << 1, + G_OPTION_FLAG_REVERSE = 1 << 2, + G_OPTION_FLAG_NO_ARG = 1 << 3, + G_OPTION_FLAG_FILENAME = 1 << 4, + G_OPTION_FLAG_OPTIONAL_ARG = 1 << 5, + G_OPTION_FLAG_NOALIAS = 1 << 6 +} GOptionFlags; + +/** + * GOptionArg: + * @G_OPTION_ARG_NONE: No extra argument. This is useful for simple flags. + * @G_OPTION_ARG_STRING: The option takes a UTF-8 string argument. + * @G_OPTION_ARG_INT: The option takes an integer argument. + * @G_OPTION_ARG_CALLBACK: The option provides a callback (of type + * #GOptionArgFunc) to parse the extra argument. + * @G_OPTION_ARG_FILENAME: The option takes a filename as argument, which will + be in the GLib filename encoding rather than UTF-8. + * @G_OPTION_ARG_STRING_ARRAY: The option takes a string argument, multiple + * uses of the option are collected into an array of strings. + * @G_OPTION_ARG_FILENAME_ARRAY: The option takes a filename as argument, + * multiple uses of the option are collected into an array of strings. + * @G_OPTION_ARG_DOUBLE: The option takes a double argument. The argument + * can be formatted either for the user's locale or for the "C" locale. + * Since 2.12 + * @G_OPTION_ARG_INT64: The option takes a 64-bit integer. Like + * %G_OPTION_ARG_INT but for larger numbers. The number can be in + * decimal base, or in hexadecimal (when prefixed with `0x`, for + * example, `0xffffffff`). Since 2.12 + * + * The #GOptionArg enum values determine which type of extra argument the + * options expect to find. If an option expects an extra argument, it can + * be specified in several ways; with a short option: `-x arg`, with a long + * option: `--name arg` or combined in a single argument: `--name=arg`. + */ +typedef enum +{ + G_OPTION_ARG_NONE, + G_OPTION_ARG_STRING, + G_OPTION_ARG_INT, + G_OPTION_ARG_CALLBACK, + G_OPTION_ARG_FILENAME, + G_OPTION_ARG_STRING_ARRAY, + G_OPTION_ARG_FILENAME_ARRAY, + G_OPTION_ARG_DOUBLE, + G_OPTION_ARG_INT64 +} GOptionArg; + +/** + * GOptionArgFunc: + * @option_name: The name of the option being parsed. This will be either a + * single dash followed by a single letter (for a short name) or two dashes + * followed by a long option name. + * @value: The value to be parsed. + * @data: User data added to the #GOptionGroup containing the option when it + * was created with g_option_group_new() + * @error: A return location for errors. The error code %G_OPTION_ERROR_FAILED + * is intended to be used for errors in #GOptionArgFunc callbacks. + * + * The type of function to be passed as callback for %G_OPTION_ARG_CALLBACK + * options. + * + * Returns: %TRUE if the option was successfully parsed, %FALSE if an error + * occurred, in which case @error should be set with g_set_error() + */ +typedef gboolean (*GOptionArgFunc) (const gchar *option_name, + const gchar *value, + gpointer data, + GError **error); + +/** + * GOptionParseFunc: + * @context: The active #GOptionContext + * @group: The group to which the function belongs + * @data: User data added to the #GOptionGroup containing the option when it + * was created with g_option_group_new() + * @error: A return location for error details + * + * The type of function that can be called before and after parsing. + * + * Returns: %TRUE if the function completed successfully, %FALSE if an error + * occurred, in which case @error should be set with g_set_error() + */ +typedef gboolean (*GOptionParseFunc) (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error); + +/** + * GOptionErrorFunc: + * @context: The active #GOptionContext + * @group: The group to which the function belongs + * @data: User data added to the #GOptionGroup containing the option when it + * was created with g_option_group_new() + * @error: The #GError containing details about the parse error + * + * The type of function to be used as callback when a parse error occurs. + */ +typedef void (*GOptionErrorFunc) (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error); + +/** + * G_OPTION_ERROR: + * + * Error domain for option parsing. Errors in this domain will + * be from the #GOptionError enumeration. See #GError for information on + * error domains. + */ +#define G_OPTION_ERROR (g_option_error_quark ()) + +/** + * GOptionError: + * @G_OPTION_ERROR_UNKNOWN_OPTION: An option was not known to the parser. + * This error will only be reported, if the parser hasn't been instructed + * to ignore unknown options, see g_option_context_set_ignore_unknown_options(). + * @G_OPTION_ERROR_BAD_VALUE: A value couldn't be parsed. + * @G_OPTION_ERROR_FAILED: A #GOptionArgFunc callback failed. + * + * Error codes returned by option parsing. + */ +typedef enum +{ + G_OPTION_ERROR_UNKNOWN_OPTION, + G_OPTION_ERROR_BAD_VALUE, + G_OPTION_ERROR_FAILED +} GOptionError; + +GLIB_AVAILABLE_IN_ALL +GQuark g_option_error_quark (void); + +/** + * GOptionEntry: + * @long_name: The long name of an option can be used to specify it + * in a commandline as `--long_name`. Every option must have a + * long name. To resolve conflicts if multiple option groups contain + * the same long name, it is also possible to specify the option as + * `--groupname-long_name`. + * @short_name: If an option has a short name, it can be specified + * `-short_name` in a commandline. @short_name must be a printable + * ASCII character different from '-', or zero if the option has no + * short name. + * @flags: Flags from #GOptionFlags + * @arg: The type of the option, as a #GOptionArg + * @arg_data: If the @arg type is %G_OPTION_ARG_CALLBACK, then @arg_data + * must point to a #GOptionArgFunc callback function, which will be + * called to handle the extra argument. Otherwise, @arg_data is a + * pointer to a location to store the value, the required type of + * the location depends on the @arg type: + * - %G_OPTION_ARG_NONE: %gboolean + * - %G_OPTION_ARG_STRING: %gchar* + * - %G_OPTION_ARG_INT: %gint + * - %G_OPTION_ARG_FILENAME: %gchar* + * - %G_OPTION_ARG_STRING_ARRAY: %gchar** + * - %G_OPTION_ARG_FILENAME_ARRAY: %gchar** + * - %G_OPTION_ARG_DOUBLE: %gdouble + * If @arg type is %G_OPTION_ARG_STRING or %G_OPTION_ARG_FILENAME, + * the location will contain a newly allocated string if the option + * was given. That string needs to be freed by the callee using g_free(). + * Likewise if @arg type is %G_OPTION_ARG_STRING_ARRAY or + * %G_OPTION_ARG_FILENAME_ARRAY, the data should be freed using g_strfreev(). + * @description: the description for the option in `--help` + * output. The @description is translated using the @translate_func + * of the group, see g_option_group_set_translation_domain(). + * @arg_description: The placeholder to use for the extra argument parsed + * by the option in `--help` output. The @arg_description is translated + * using the @translate_func of the group, see + * g_option_group_set_translation_domain(). + * + * A GOptionEntry struct defines a single option. To have an effect, they + * must be added to a #GOptionGroup with g_option_context_add_main_entries() + * or g_option_group_add_entries(). + */ +struct _GOptionEntry +{ + const gchar *long_name; + gchar short_name; + gint flags; + + GOptionArg arg; + gpointer arg_data; + + const gchar *description; + const gchar *arg_description; +}; + +/** + * G_OPTION_REMAINING: + * + * If a long option in the main group has this name, it is not treated as a + * regular option. Instead it collects all non-option arguments which would + * otherwise be left in `argv`. The option must be of type + * %G_OPTION_ARG_CALLBACK, %G_OPTION_ARG_STRING_ARRAY + * or %G_OPTION_ARG_FILENAME_ARRAY. + * + * + * Using #G_OPTION_REMAINING instead of simply scanning `argv` + * for leftover arguments has the advantage that GOption takes care of + * necessary encoding conversions for strings or filenames. + * + * Since: 2.6 + */ +#define G_OPTION_REMAINING "" + +GLIB_AVAILABLE_IN_ALL +GOptionContext *g_option_context_new (const gchar *parameter_string); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_summary (GOptionContext *context, + const gchar *summary); +GLIB_AVAILABLE_IN_ALL +const gchar * g_option_context_get_summary (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_description (GOptionContext *context, + const gchar *description); +GLIB_AVAILABLE_IN_ALL +const gchar * g_option_context_get_description (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +void g_option_context_free (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_help_enabled (GOptionContext *context, + gboolean help_enabled); +GLIB_AVAILABLE_IN_ALL +gboolean g_option_context_get_help_enabled (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_ignore_unknown_options (GOptionContext *context, + gboolean ignore_unknown); +GLIB_AVAILABLE_IN_ALL +gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context); + +GLIB_AVAILABLE_IN_2_44 +void g_option_context_set_strict_posix (GOptionContext *context, + gboolean strict_posix); +GLIB_AVAILABLE_IN_2_44 +gboolean g_option_context_get_strict_posix (GOptionContext *context); + +GLIB_AVAILABLE_IN_ALL +void g_option_context_add_main_entries (GOptionContext *context, + const GOptionEntry *entries, + const gchar *translation_domain); +GLIB_AVAILABLE_IN_ALL +gboolean g_option_context_parse (GOptionContext *context, + gint *argc, + gchar ***argv, + GError **error); +GLIB_AVAILABLE_IN_2_40 +gboolean g_option_context_parse_strv (GOptionContext *context, + gchar ***arguments, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_translate_func (GOptionContext *context, + GTranslateFunc func, + gpointer data, + GDestroyNotify destroy_notify); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_translation_domain (GOptionContext *context, + const gchar *domain); + +GLIB_AVAILABLE_IN_ALL +void g_option_context_add_group (GOptionContext *context, + GOptionGroup *group); +GLIB_AVAILABLE_IN_ALL +void g_option_context_set_main_group (GOptionContext *context, + GOptionGroup *group); +GLIB_AVAILABLE_IN_ALL +GOptionGroup *g_option_context_get_main_group (GOptionContext *context); +GLIB_AVAILABLE_IN_ALL +gchar *g_option_context_get_help (GOptionContext *context, + gboolean main_help, + GOptionGroup *group); + +GLIB_AVAILABLE_IN_ALL +GOptionGroup *g_option_group_new (const gchar *name, + const gchar *description, + const gchar *help_description, + gpointer user_data, + GDestroyNotify destroy); +GLIB_AVAILABLE_IN_ALL +void g_option_group_set_parse_hooks (GOptionGroup *group, + GOptionParseFunc pre_parse_func, + GOptionParseFunc post_parse_func); +GLIB_AVAILABLE_IN_ALL +void g_option_group_set_error_hook (GOptionGroup *group, + GOptionErrorFunc error_func); +GLIB_DEPRECATED_IN_2_44 +void g_option_group_free (GOptionGroup *group); +GLIB_AVAILABLE_IN_2_44 +GOptionGroup *g_option_group_ref (GOptionGroup *group); +GLIB_AVAILABLE_IN_2_44 +void g_option_group_unref (GOptionGroup *group); +GLIB_AVAILABLE_IN_ALL +void g_option_group_add_entries (GOptionGroup *group, + const GOptionEntry *entries); +GLIB_AVAILABLE_IN_ALL +void g_option_group_set_translate_func (GOptionGroup *group, + GTranslateFunc func, + gpointer data, + GDestroyNotify destroy_notify); +GLIB_AVAILABLE_IN_ALL +void g_option_group_set_translation_domain (GOptionGroup *group, + const gchar *domain); + +G_END_DECLS + +#endif /* __G_OPTION_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997, 1999 Peter Mattis, Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_PATTERN_H__ +#define __G_PATTERN_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + + +typedef struct _GPatternSpec GPatternSpec; + +GLIB_AVAILABLE_IN_ALL +GPatternSpec* g_pattern_spec_new (const gchar *pattern); +GLIB_AVAILABLE_IN_ALL +void g_pattern_spec_free (GPatternSpec *pspec); +GLIB_AVAILABLE_IN_ALL +gboolean g_pattern_spec_equal (GPatternSpec *pspec1, + GPatternSpec *pspec2); +GLIB_AVAILABLE_IN_ALL +gboolean g_pattern_match (GPatternSpec *pspec, + guint string_length, + const gchar *string, + const gchar *string_reversed); +GLIB_AVAILABLE_IN_ALL +gboolean g_pattern_match_string (GPatternSpec *pspec, + const gchar *string); +GLIB_AVAILABLE_IN_ALL +gboolean g_pattern_match_simple (const gchar *pattern, + const gchar *string); + +G_END_DECLS + +#endif /* __G_PATTERN_H__ */ +/* + * Copyright © 2018 Ole André Vadla Ravnås + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_PLATFORM_AUDIT_H__ +#define __G_PLATFORM_AUDIT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GFDCallbacks GFDCallbacks; + +struct _GFDCallbacks +{ + void (*on_fd_opened) (gint fd, const gchar *description); + void (*on_fd_closed) (gint fd, const gchar *description); +}; + +GLIB_VAR +GFDCallbacks *glib_fd_callbacks; +GLIB_AVAILABLE_IN_2_68 +void g_platform_audit_set_fd_callbacks (GFDCallbacks *callbacks); + +G_END_DECLS + +#endif /* __G_PLATFORM_AUDIT_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_PRIMES_H__ +#define __G_PRIMES_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* Prime numbers. + */ + +/* This function returns prime numbers spaced by approximately 1.5-2.0 + * and is for use in resizing data structures which prefer + * prime-valued sizes. The closest spaced prime function returns the + * next largest prime, or the highest it knows about which is about + * MAXINT/4. + */ +GLIB_AVAILABLE_IN_ALL +guint g_spaced_primes_closest (guint num) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_PRIMES_H__ */ + /* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_QSORT_H__ +#define __G_QSORT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +void g_qsort_with_data (gconstpointer pbase, + gint total_elems, + gsize size, + GCompareDataFunc compare_func, + gpointer user_data); + +G_END_DECLS + +#endif /* __G_QSORT_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_QUEUE_H__ +#define __G_QUEUE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GQueue GQueue; + +/** + * GQueue: + * @head: a pointer to the first element of the queue + * @tail: a pointer to the last element of the queue + * @length: the number of elements in the queue + * + * Contains the public fields of a + * [Queue][glib-Double-ended-Queues]. + */ +struct _GQueue +{ + GList *head; + GList *tail; + guint length; +}; + +/** + * G_QUEUE_INIT: + * + * A statically-allocated #GQueue must be initialized with this + * macro before it can be used. This macro can be used to initialize + * a variable, but it cannot be assigned to a variable. In that case + * you have to use g_queue_init(). + * + * |[ + * GQueue my_queue = G_QUEUE_INIT; + * ]| + * + * Since: 2.14 + */ +#define G_QUEUE_INIT { NULL, NULL, 0 } + +/* Queues + */ +GLIB_AVAILABLE_IN_ALL +GQueue* g_queue_new (void); +GLIB_AVAILABLE_IN_ALL +void g_queue_free (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_queue_free_full (GQueue *queue, + GDestroyNotify free_func); +GLIB_AVAILABLE_IN_ALL +void g_queue_init (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_queue_clear (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gboolean g_queue_is_empty (GQueue *queue); +GLIB_AVAILABLE_IN_2_60 +void g_queue_clear_full (GQueue *queue, + GDestroyNotify free_func); +GLIB_AVAILABLE_IN_ALL +guint g_queue_get_length (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_queue_reverse (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GQueue * g_queue_copy (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +void g_queue_foreach (GQueue *queue, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +GList * g_queue_find (GQueue *queue, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +GList * g_queue_find_custom (GQueue *queue, + gconstpointer data, + GCompareFunc func); +GLIB_AVAILABLE_IN_ALL +void g_queue_sort (GQueue *queue, + GCompareDataFunc compare_func, + gpointer user_data); + +GLIB_AVAILABLE_IN_ALL +void g_queue_push_head (GQueue *queue, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_queue_push_tail (GQueue *queue, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_queue_push_nth (GQueue *queue, + gpointer data, + gint n); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_pop_head (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_pop_tail (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_pop_nth (GQueue *queue, + guint n); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_peek_head (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_peek_tail (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +gpointer g_queue_peek_nth (GQueue *queue, + guint n); +GLIB_AVAILABLE_IN_ALL +gint g_queue_index (GQueue *queue, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +gboolean g_queue_remove (GQueue *queue, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_queue_remove_all (GQueue *queue, + gconstpointer data); +GLIB_AVAILABLE_IN_ALL +void g_queue_insert_before (GQueue *queue, + GList *sibling, + gpointer data); +GLIB_AVAILABLE_IN_2_62 +void g_queue_insert_before_link + (GQueue *queue, + GList *sibling, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_insert_after (GQueue *queue, + GList *sibling, + gpointer data); +GLIB_AVAILABLE_IN_2_62 +void g_queue_insert_after_link + (GQueue *queue, + GList *sibling, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_insert_sorted (GQueue *queue, + gpointer data, + GCompareDataFunc func, + gpointer user_data); + +GLIB_AVAILABLE_IN_ALL +void g_queue_push_head_link (GQueue *queue, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_push_tail_link (GQueue *queue, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_push_nth_link (GQueue *queue, + gint n, + GList *link_); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_pop_head_link (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_pop_tail_link (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_pop_nth_link (GQueue *queue, + guint n); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_peek_head_link (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_peek_tail_link (GQueue *queue); +GLIB_AVAILABLE_IN_ALL +GList* g_queue_peek_nth_link (GQueue *queue, + guint n); +GLIB_AVAILABLE_IN_ALL +gint g_queue_link_index (GQueue *queue, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_unlink (GQueue *queue, + GList *link_); +GLIB_AVAILABLE_IN_ALL +void g_queue_delete_link (GQueue *queue, + GList *link_); + +G_END_DECLS + +#endif /* __G_QUEUE_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_RAND_H__ +#define __G_RAND_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GRand GRand; + +/* GRand - a good and fast random number generator: Mersenne Twister + * see http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html for more info. + * The range functions return a value in the interval [begin, end). + * int -> [0..2^32-1] + * int_range -> [begin..end-1] + * double -> [0..1) + * double_range -> [begin..end) + */ + +GLIB_AVAILABLE_IN_ALL +GRand* g_rand_new_with_seed (guint32 seed); +GLIB_AVAILABLE_IN_ALL +GRand* g_rand_new_with_seed_array (const guint32 *seed, + guint seed_length); +GLIB_AVAILABLE_IN_ALL +GRand* g_rand_new (void); +GLIB_AVAILABLE_IN_ALL +void g_rand_free (GRand *rand_); +GLIB_AVAILABLE_IN_ALL +GRand* g_rand_copy (GRand *rand_); +GLIB_AVAILABLE_IN_ALL +void g_rand_set_seed (GRand *rand_, + guint32 seed); +GLIB_AVAILABLE_IN_ALL +void g_rand_set_seed_array (GRand *rand_, + const guint32 *seed, + guint seed_length); + +#define g_rand_boolean(rand_) ((g_rand_int (rand_) & (1 << 15)) != 0) + +GLIB_AVAILABLE_IN_ALL +guint32 g_rand_int (GRand *rand_); +GLIB_AVAILABLE_IN_ALL +gint32 g_rand_int_range (GRand *rand_, + gint32 begin, + gint32 end); +GLIB_AVAILABLE_IN_ALL +gdouble g_rand_double (GRand *rand_); +GLIB_AVAILABLE_IN_ALL +gdouble g_rand_double_range (GRand *rand_, + gdouble begin, + gdouble end); +GLIB_AVAILABLE_IN_ALL +void g_random_set_seed (guint32 seed); + +#define g_random_boolean() ((g_random_int () & (1 << 15)) != 0) + +GLIB_AVAILABLE_IN_ALL +guint32 g_random_int (void); +GLIB_AVAILABLE_IN_ALL +gint32 g_random_int_range (gint32 begin, + gint32 end); +GLIB_AVAILABLE_IN_ALL +gdouble g_random_double (void); +GLIB_AVAILABLE_IN_ALL +gdouble g_random_double_range (gdouble begin, + gdouble end); + + +G_END_DECLS + +#endif /* __G_RAND_H__ */ +/* grcbox.h: Reference counted data + * + * Copyright 2018 Emmanuele Bassi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#pragma once + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_58 +gpointer g_rc_box_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_rc_box_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_rc_box_dup (gsize block_size, + gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_rc_box_acquire (gpointer mem_block); +GLIB_AVAILABLE_IN_2_58 +void g_rc_box_release (gpointer mem_block); +GLIB_AVAILABLE_IN_2_58 +void g_rc_box_release_full (gpointer mem_block, + GDestroyNotify clear_func); + +GLIB_AVAILABLE_IN_2_58 +gsize g_rc_box_get_size (gpointer mem_block); + +GLIB_AVAILABLE_IN_2_58 +gpointer g_atomic_rc_box_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_atomic_rc_box_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_atomic_rc_box_dup (gsize block_size, + gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_2_58 +gpointer g_atomic_rc_box_acquire (gpointer mem_block); +GLIB_AVAILABLE_IN_2_58 +void g_atomic_rc_box_release (gpointer mem_block); +GLIB_AVAILABLE_IN_2_58 +void g_atomic_rc_box_release_full (gpointer mem_block, + GDestroyNotify clear_func); + +GLIB_AVAILABLE_IN_2_58 +gsize g_atomic_rc_box_get_size (gpointer mem_block); + +#define g_rc_box_new(type) \ + ((type *) g_rc_box_alloc (sizeof (type))) +#define g_rc_box_new0(type) \ + ((type *) g_rc_box_alloc0 (sizeof (type))) +#define g_atomic_rc_box_new(type) \ + ((type *) g_atomic_rc_box_alloc (sizeof (type))) +#define g_atomic_rc_box_new0(type) \ + ((type *) g_atomic_rc_box_alloc0 (sizeof (type))) + +#ifdef glib_typeof +/* Type check to avoid assigning references to different types */ +#undef g_rc_box_acquire +#define g_rc_box_acquire(mem_block) \ + ((glib_typeof (mem_block)) (_frida_g_rc_box_acquire) (mem_block)) +#undef g_atomic_rc_box_acquire +#define g_atomic_rc_box_acquire(mem_block) \ + ((glib_typeof (mem_block)) (_frida_g_atomic_rc_box_acquire) (mem_block)) + +/* Type check to avoid duplicating data to different types */ +#undef g_rc_box_dup +#define g_rc_box_dup(block_size, mem_block) \ + ((glib_typeof (mem_block)) (_frida_g_rc_box_dup) (block_size, mem_block)) +#undef g_atomic_rc_box_dup +#define g_atomic_rc_box_dup(block_size, mem_block) \ + ((glib_typeof (mem_block)) (_frida_g_atomic_rc_box_dup) (block_size, mem_block)) +#endif + +G_END_DECLS +/* grefcount.h: Reference counting + * + * Copyright 2018 Emmanuele Bassi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __GREFCOUNT_H__ +#define __GREFCOUNT_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#if defined(__GNUC__) && defined(G_DISABLE_CHECKS) +#endif + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_58 +void g_ref_count_init (grefcount *rc); +GLIB_AVAILABLE_IN_2_58 +void g_ref_count_inc (grefcount *rc); +GLIB_AVAILABLE_IN_2_58 +gboolean g_ref_count_dec (grefcount *rc); +GLIB_AVAILABLE_IN_2_58 +gboolean g_ref_count_compare (grefcount *rc, + gint val); + +GLIB_AVAILABLE_IN_2_58 +void g_atomic_ref_count_init (gatomicrefcount *arc); +GLIB_AVAILABLE_IN_2_58 +void g_atomic_ref_count_inc (gatomicrefcount *arc); +GLIB_AVAILABLE_IN_2_58 +gboolean g_atomic_ref_count_dec (gatomicrefcount *arc); +GLIB_AVAILABLE_IN_2_58 +gboolean g_atomic_ref_count_compare (gatomicrefcount *arc, + gint val); + +/* On GCC we can use __extension__ to inline the API without using + * ancillary functions; we only do this when disabling checks, as + * it disables warnings when saturating the reference counters + */ +#if defined(__GNUC__) && defined(G_DISABLE_CHECKS) + +#undef g_ref_count_init +# define g_ref_count_init(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + *(rc) = -1; \ + })) + +#undef g_ref_count_inc +# define g_ref_count_inc(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + if (*(rc) == G_MININT) ; else { \ + *(rc) -= 1; \ + } \ + })) + +#undef g_ref_count_dec +# define g_ref_count_dec(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ + grefcount __rc = *(rc); \ + __rc += 1; \ + if (__rc == 0) ; else { \ + *(rc) = __rc; \ + } \ + (gboolean) (__rc == 0); \ + })) + +#undef g_ref_count_compare +# define g_ref_count_compare(rc,val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ + (void) (0 ? *(rc) ^ (val) : 1); \ + (gboolean) (*(rc) == -(val)); \ + })) + +#undef g_atomic_ref_count_init +# define g_atomic_ref_count_init(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + *(rc) = 1; \ + })) + +#undef g_atomic_ref_count_inc +# define g_atomic_ref_count_inc(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + (void) (g_atomic_int_get (rc) == G_MAXINT ? 0 : g_atomic_int_inc ((rc))); \ + })) + +#undef g_atomic_ref_count_dec +# define g_atomic_ref_count_dec(rc) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ + (void) (0 ? *(rc) ^ *(rc) : 1); \ + g_atomic_int_dec_and_test ((rc)); \ + })) + +#undef g_atomic_ref_count_compare +# define g_atomic_ref_count_compare(rc,val) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ + (void) (0 ? *(rc) ^ (val) : 1); \ + (gboolean) (g_atomic_int_get (rc) == (val)); \ + })) + +#endif /* __GNUC__ && G_DISABLE_CHECKS */ + +G_END_DECLS + +#endif /* __GREFCOUNT_H__ */ +/* grefstring.h: Reference counted strings + * + * Copyright 2018 Emmanuele Bassi + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#pragma once + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_58 +char * g_ref_string_new (const char *str); +GLIB_AVAILABLE_IN_2_58 +char * g_ref_string_new_len (const char *str, + gssize len); +GLIB_AVAILABLE_IN_2_58 +char * g_ref_string_new_intern (const char *str); + +GLIB_AVAILABLE_IN_2_58 +char * g_ref_string_acquire (char *str); +GLIB_AVAILABLE_IN_2_58 +void g_ref_string_release (char *str); + +GLIB_AVAILABLE_IN_2_58 +gsize g_ref_string_length (char *str); + +/** + * GRefString: + * + * A typedef for a reference-counted string. A pointer to a #GRefString can be + * treated like a standard `char*` array by all code, but can additionally have + * `g_ref_string_*()` methods called on it. `g_ref_string_*()` methods cannot be + * called on `char*` arrays not allocated using g_ref_string_new(). + * + * If using #GRefString with autocleanups, g_autoptr() must be used rather than + * g_autofree(), so that the reference counting metadata is also freed. + * + * Since: 2.58 + */ +typedef char GRefString; + +G_END_DECLS +/* GRegex -- regular expression API wrapper around PCRE. + * + * Copyright (C) 1999, 2000 Scott Wimer + * Copyright (C) 2004, Matthias Clasen + * Copyright (C) 2005 - 2007, Marco Barisione + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_REGEX_H__ +#define __G_REGEX_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * GRegexError: + * @G_REGEX_ERROR_COMPILE: Compilation of the regular expression failed. + * @G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression failed. + * @G_REGEX_ERROR_REPLACE: Replacement failed due to an ill-formed replacement + * string. + * @G_REGEX_ERROR_MATCH: The match process failed. + * @G_REGEX_ERROR_INTERNAL: Internal error of the regular expression engine. + * Since 2.16 + * @G_REGEX_ERROR_STRAY_BACKSLASH: "\\" at end of pattern. Since 2.16 + * @G_REGEX_ERROR_MISSING_CONTROL_CHAR: "\\c" at end of pattern. Since 2.16 + * @G_REGEX_ERROR_UNRECOGNIZED_ESCAPE: Unrecognized character follows "\\". + * Since 2.16 + * @G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER: Numbers out of order in "{}" + * quantifier. Since 2.16 + * @G_REGEX_ERROR_QUANTIFIER_TOO_BIG: Number too big in "{}" quantifier. + * Since 2.16 + * @G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS: Missing terminating "]" for + * character class. Since 2.16 + * @G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS: Invalid escape sequence + * in character class. Since 2.16 + * @G_REGEX_ERROR_RANGE_OUT_OF_ORDER: Range out of order in character class. + * Since 2.16 + * @G_REGEX_ERROR_NOTHING_TO_REPEAT: Nothing to repeat. Since 2.16 + * @G_REGEX_ERROR_UNRECOGNIZED_CHARACTER: Unrecognized character after "(?", + * "(?<" or "(?P". Since 2.16 + * @G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS: POSIX named classes are + * supported only within a class. Since 2.16 + * @G_REGEX_ERROR_UNMATCHED_PARENTHESIS: Missing terminating ")" or ")" + * without opening "(". Since 2.16 + * @G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE: Reference to non-existent + * subpattern. Since 2.16 + * @G_REGEX_ERROR_UNTERMINATED_COMMENT: Missing terminating ")" after comment. + * Since 2.16 + * @G_REGEX_ERROR_EXPRESSION_TOO_LARGE: Regular expression too large. + * Since 2.16 + * @G_REGEX_ERROR_MEMORY_ERROR: Failed to get memory. Since 2.16 + * @G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND: Lookbehind assertion is not + * fixed length. Since 2.16 + * @G_REGEX_ERROR_MALFORMED_CONDITION: Malformed number or name after "(?(". + * Since 2.16 + * @G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES: Conditional group contains + * more than two branches. Since 2.16 + * @G_REGEX_ERROR_ASSERTION_EXPECTED: Assertion expected after "(?(". + * Since 2.16 + * @G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME: Unknown POSIX class name. + * Since 2.16 + * @G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED: POSIX collating + * elements are not supported. Since 2.16 + * @G_REGEX_ERROR_HEX_CODE_TOO_LARGE: Character value in "\\x{...}" sequence + * is too large. Since 2.16 + * @G_REGEX_ERROR_INVALID_CONDITION: Invalid condition "(?(0)". Since 2.16 + * @G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND: \\C not allowed in + * lookbehind assertion. Since 2.16 + * @G_REGEX_ERROR_INFINITE_LOOP: Recursive call could loop indefinitely. + * Since 2.16 + * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR: Missing terminator + * in subpattern name. Since 2.16 + * @G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME: Two named subpatterns have + * the same name. Since 2.16 + * @G_REGEX_ERROR_MALFORMED_PROPERTY: Malformed "\\P" or "\\p" sequence. + * Since 2.16 + * @G_REGEX_ERROR_UNKNOWN_PROPERTY: Unknown property name after "\\P" or + * "\\p". Since 2.16 + * @G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG: Subpattern name is too long + * (maximum 32 characters). Since 2.16 + * @G_REGEX_ERROR_TOO_MANY_SUBPATTERNS: Too many named subpatterns (maximum + * 10,000). Since 2.16 + * @G_REGEX_ERROR_INVALID_OCTAL_VALUE: Octal value is greater than "\\377". + * Since 2.16 + * @G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE: "DEFINE" group contains more + * than one branch. Since 2.16 + * @G_REGEX_ERROR_DEFINE_REPETION: Repeating a "DEFINE" group is not allowed. + * This error is never raised. Since: 2.16 Deprecated: 2.34 + * @G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS: Inconsistent newline options. + * Since 2.16 + * @G_REGEX_ERROR_MISSING_BACK_REFERENCE: "\\g" is not followed by a braced, + * angle-bracketed, or quoted name or number, or by a plain number. Since: 2.16 + * @G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE: relative reference must not be zero. Since: 2.34 + * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN: the backtracing + * control verb used does not allow an argument. Since: 2.34 + * @G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB: unknown backtracing + * control verb. Since: 2.34 + * @G_REGEX_ERROR_NUMBER_TOO_BIG: number is too big in escape sequence. Since: 2.34 + * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME: Missing subpattern name. Since: 2.34 + * @G_REGEX_ERROR_MISSING_DIGIT: Missing digit. Since 2.34 + * @G_REGEX_ERROR_INVALID_DATA_CHARACTER: In JavaScript compatibility mode, + * "[" is an invalid data character. Since: 2.34 + * @G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME: different names for subpatterns of the + * same number are not allowed. Since: 2.34 + * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED: the backtracing control + * verb requires an argument. Since: 2.34 + * @G_REGEX_ERROR_INVALID_CONTROL_CHAR: "\\c" must be followed by an ASCII + * character. Since: 2.34 + * @G_REGEX_ERROR_MISSING_NAME: "\\k" is not followed by a braced, angle-bracketed, or + * quoted name. Since: 2.34 + * @G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS: "\\N" is not supported in a class. Since: 2.34 + * @G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES: too many forward references. Since: 2.34 + * @G_REGEX_ERROR_NAME_TOO_LONG: the name is too long in "(*MARK)", "(*PRUNE)", + * "(*SKIP)", or "(*THEN)". Since: 2.34 + * @G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE: the character value in the \\u sequence is + * too large. Since: 2.34 + * + * Error codes returned by regular expressions functions. + * + * Since: 2.14 + */ +typedef enum +{ + G_REGEX_ERROR_COMPILE, + G_REGEX_ERROR_OPTIMIZE, + G_REGEX_ERROR_REPLACE, + G_REGEX_ERROR_MATCH, + G_REGEX_ERROR_INTERNAL, + + /* These are the error codes from PCRE + 100 */ + G_REGEX_ERROR_STRAY_BACKSLASH = 101, + G_REGEX_ERROR_MISSING_CONTROL_CHAR = 102, + G_REGEX_ERROR_UNRECOGNIZED_ESCAPE = 103, + G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER = 104, + G_REGEX_ERROR_QUANTIFIER_TOO_BIG = 105, + G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS = 106, + G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS = 107, + G_REGEX_ERROR_RANGE_OUT_OF_ORDER = 108, + G_REGEX_ERROR_NOTHING_TO_REPEAT = 109, + G_REGEX_ERROR_UNRECOGNIZED_CHARACTER = 112, + G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113, + G_REGEX_ERROR_UNMATCHED_PARENTHESIS = 114, + G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE = 115, + G_REGEX_ERROR_UNTERMINATED_COMMENT = 118, + G_REGEX_ERROR_EXPRESSION_TOO_LARGE = 120, + G_REGEX_ERROR_MEMORY_ERROR = 121, + G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND = 125, + G_REGEX_ERROR_MALFORMED_CONDITION = 126, + G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES = 127, + G_REGEX_ERROR_ASSERTION_EXPECTED = 128, + G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME = 130, + G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131, + G_REGEX_ERROR_HEX_CODE_TOO_LARGE = 134, + G_REGEX_ERROR_INVALID_CONDITION = 135, + G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136, + G_REGEX_ERROR_INFINITE_LOOP = 140, + G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR = 142, + G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME = 143, + G_REGEX_ERROR_MALFORMED_PROPERTY = 146, + G_REGEX_ERROR_UNKNOWN_PROPERTY = 147, + G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG = 148, + G_REGEX_ERROR_TOO_MANY_SUBPATTERNS = 149, + G_REGEX_ERROR_INVALID_OCTAL_VALUE = 151, + G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE = 154, + G_REGEX_ERROR_DEFINE_REPETION = 155, + G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS = 156, + G_REGEX_ERROR_MISSING_BACK_REFERENCE = 157, + G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE = 158, + G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN = 159, + G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB = 160, + G_REGEX_ERROR_NUMBER_TOO_BIG = 161, + G_REGEX_ERROR_MISSING_SUBPATTERN_NAME = 162, + G_REGEX_ERROR_MISSING_DIGIT = 163, + G_REGEX_ERROR_INVALID_DATA_CHARACTER = 164, + G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME = 165, + G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED = 166, + G_REGEX_ERROR_INVALID_CONTROL_CHAR = 168, + G_REGEX_ERROR_MISSING_NAME = 169, + G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS = 171, + G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES = 172, + G_REGEX_ERROR_NAME_TOO_LONG = 175, + G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE = 176 +} GRegexError; + +/** + * G_REGEX_ERROR: + * + * Error domain for regular expressions. Errors in this domain will be + * from the #GRegexError enumeration. See #GError for information on + * error domains. + * + * Since: 2.14 + */ +#define G_REGEX_ERROR g_regex_error_quark () + +GLIB_AVAILABLE_IN_ALL +GQuark g_regex_error_quark (void); + +/** + * GRegexCompileFlags: + * @G_REGEX_CASELESS: Letters in the pattern match both upper- and + * lowercase letters. This option can be changed within a pattern + * by a "(?i)" option setting. + * @G_REGEX_MULTILINE: By default, GRegex treats the strings as consisting + * of a single line of characters (even if it actually contains + * newlines). The "start of line" metacharacter ("^") matches only + * at the start of the string, while the "end of line" metacharacter + * ("$") matches only at the end of the string, or before a terminating + * newline (unless #G_REGEX_DOLLAR_ENDONLY is set). When + * #G_REGEX_MULTILINE is set, the "start of line" and "end of line" + * constructs match immediately following or immediately before any + * newline in the string, respectively, as well as at the very start + * and end. This can be changed within a pattern by a "(?m)" option + * setting. + * @G_REGEX_DOTALL: A dot metacharacter (".") in the pattern matches all + * characters, including newlines. Without it, newlines are excluded. + * This option can be changed within a pattern by a ("?s") option setting. + * @G_REGEX_EXTENDED: Whitespace data characters in the pattern are + * totally ignored except when escaped or inside a character class. + * Whitespace does not include the VT character (code 11). In addition, + * characters between an unescaped "#" outside a character class and + * the next newline character, inclusive, are also ignored. This can + * be changed within a pattern by a "(?x)" option setting. + * @G_REGEX_ANCHORED: The pattern is forced to be "anchored", that is, + * it is constrained to match only at the first matching point in the + * string that is being searched. This effect can also be achieved by + * appropriate constructs in the pattern itself such as the "^" + * metacharacter. + * @G_REGEX_DOLLAR_ENDONLY: A dollar metacharacter ("$") in the pattern + * matches only at the end of the string. Without this option, a + * dollar also matches immediately before the final character if + * it is a newline (but not before any other newlines). This option + * is ignored if #G_REGEX_MULTILINE is set. + * @G_REGEX_UNGREEDY: Inverts the "greediness" of the quantifiers so that + * they are not greedy by default, but become greedy if followed by "?". + * It can also be set by a "(?U)" option setting within the pattern. + * @G_REGEX_RAW: Usually strings must be valid UTF-8 strings, using this + * flag they are considered as a raw sequence of bytes. + * @G_REGEX_NO_AUTO_CAPTURE: Disables the use of numbered capturing + * parentheses in the pattern. Any opening parenthesis that is not + * followed by "?" behaves as if it were followed by "?:" but named + * parentheses can still be used for capturing (and they acquire numbers + * in the usual way). + * @G_REGEX_OPTIMIZE: Optimize the regular expression. If the pattern will + * be used many times, then it may be worth the effort to optimize it + * to improve the speed of matches. + * @G_REGEX_FIRSTLINE: Limits an unanchored pattern to match before (or at) the + * first newline. Since: 2.34 + * @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not + * be unique. This can be helpful for certain types of pattern when it + * is known that only one instance of the named subpattern can ever be + * matched. + * @G_REGEX_NEWLINE_CR: Usually any newline character or character sequence is + * recognized. If this option is set, the only recognized newline character + * is '\r'. + * @G_REGEX_NEWLINE_LF: Usually any newline character or character sequence is + * recognized. If this option is set, the only recognized newline character + * is '\n'. + * @G_REGEX_NEWLINE_CRLF: Usually any newline character or character sequence is + * recognized. If this option is set, the only recognized newline character + * sequence is '\r\n'. + * @G_REGEX_NEWLINE_ANYCRLF: Usually any newline character or character sequence + * is recognized. If this option is set, the only recognized newline character + * sequences are '\r', '\n', and '\r\n'. Since: 2.34 + * @G_REGEX_BSR_ANYCRLF: Usually any newline character or character sequence + * is recognised. If this option is set, then "\R" only recognizes the newline + * characters '\r', '\n' and '\r\n'. Since: 2.34 + * @G_REGEX_JAVASCRIPT_COMPAT: Changes behaviour so that it is compatible with + * JavaScript rather than PCRE. Since: 2.34 + * + * Flags specifying compile-time options. + * + * Since: 2.14 + */ +/* Remember to update G_REGEX_COMPILE_MASK in gregex.c after + * adding a new flag. + */ +typedef enum +{ + G_REGEX_CASELESS = 1 << 0, + G_REGEX_MULTILINE = 1 << 1, + G_REGEX_DOTALL = 1 << 2, + G_REGEX_EXTENDED = 1 << 3, + G_REGEX_ANCHORED = 1 << 4, + G_REGEX_DOLLAR_ENDONLY = 1 << 5, + G_REGEX_UNGREEDY = 1 << 9, + G_REGEX_RAW = 1 << 11, + G_REGEX_NO_AUTO_CAPTURE = 1 << 12, + G_REGEX_OPTIMIZE = 1 << 13, + G_REGEX_FIRSTLINE = 1 << 18, + G_REGEX_DUPNAMES = 1 << 19, + G_REGEX_NEWLINE_CR = 1 << 20, + G_REGEX_NEWLINE_LF = 1 << 21, + G_REGEX_NEWLINE_CRLF = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF, + G_REGEX_NEWLINE_ANYCRLF = G_REGEX_NEWLINE_CR | 1 << 22, + G_REGEX_BSR_ANYCRLF = 1 << 23, + G_REGEX_JAVASCRIPT_COMPAT = 1 << 25 +} GRegexCompileFlags; + +/** + * GRegexMatchFlags: + * @G_REGEX_MATCH_ANCHORED: The pattern is forced to be "anchored", that is, + * it is constrained to match only at the first matching point in the + * string that is being searched. This effect can also be achieved by + * appropriate constructs in the pattern itself such as the "^" + * metacharacter. + * @G_REGEX_MATCH_NOTBOL: Specifies that first character of the string is + * not the beginning of a line, so the circumflex metacharacter should + * not match before it. Setting this without #G_REGEX_MULTILINE (at + * compile time) causes circumflex never to match. This option affects + * only the behaviour of the circumflex metacharacter, it does not + * affect "\A". + * @G_REGEX_MATCH_NOTEOL: Specifies that the end of the subject string is + * not the end of a line, so the dollar metacharacter should not match + * it nor (except in multiline mode) a newline immediately before it. + * Setting this without #G_REGEX_MULTILINE (at compile time) causes + * dollar never to match. This option affects only the behaviour of + * the dollar metacharacter, it does not affect "\Z" or "\z". + * @G_REGEX_MATCH_NOTEMPTY: An empty string is not considered to be a valid + * match if this option is set. If there are alternatives in the pattern, + * they are tried. If all the alternatives match the empty string, the + * entire match fails. For example, if the pattern "a?b?" is applied to + * a string not beginning with "a" or "b", it matches the empty string + * at the start of the string. With this flag set, this match is not + * valid, so GRegex searches further into the string for occurrences + * of "a" or "b". + * @G_REGEX_MATCH_PARTIAL: Turns on the partial matching feature, for more + * documentation on partial matching see g_match_info_is_partial_match(). + * @G_REGEX_MATCH_NEWLINE_CR: Overrides the newline definition set when + * creating a new #GRegex, setting the '\r' character as line terminator. + * @G_REGEX_MATCH_NEWLINE_LF: Overrides the newline definition set when + * creating a new #GRegex, setting the '\n' character as line terminator. + * @G_REGEX_MATCH_NEWLINE_CRLF: Overrides the newline definition set when + * creating a new #GRegex, setting the '\r\n' characters sequence as line terminator. + * @G_REGEX_MATCH_NEWLINE_ANY: Overrides the newline definition set when + * creating a new #GRegex, any Unicode newline sequence + * is recognised as a newline. These are '\r', '\n' and '\rn', and the + * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), + * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and + * U+2029 PARAGRAPH SEPARATOR. + * @G_REGEX_MATCH_NEWLINE_ANYCRLF: Overrides the newline definition set when + * creating a new #GRegex; any '\r', '\n', or '\r\n' character sequence + * is recognized as a newline. Since: 2.34 + * @G_REGEX_MATCH_BSR_ANYCRLF: Overrides the newline definition for "\R" set when + * creating a new #GRegex; only '\r', '\n', or '\r\n' character sequences + * are recognized as a newline by "\R". Since: 2.34 + * @G_REGEX_MATCH_BSR_ANY: Overrides the newline definition for "\R" set when + * creating a new #GRegex; any Unicode newline character or character sequence + * are recognized as a newline by "\R". These are '\r', '\n' and '\rn', and the + * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), + * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and + * U+2029 PARAGRAPH SEPARATOR. Since: 2.34 + * @G_REGEX_MATCH_PARTIAL_SOFT: An alias for #G_REGEX_MATCH_PARTIAL. Since: 2.34 + * @G_REGEX_MATCH_PARTIAL_HARD: Turns on the partial matching feature. In contrast to + * to #G_REGEX_MATCH_PARTIAL_SOFT, this stops matching as soon as a partial match + * is found, without continuing to search for a possible complete match. See + * g_match_info_is_partial_match() for more information. Since: 2.34 + * @G_REGEX_MATCH_NOTEMPTY_ATSTART: Like #G_REGEX_MATCH_NOTEMPTY, but only applied to + * the start of the matched string. For anchored + * patterns this can only happen for pattern containing "\K". Since: 2.34 + * + * Flags specifying match-time options. + * + * Since: 2.14 + */ +/* Remember to update G_REGEX_MATCH_MASK in gregex.c after + * adding a new flag. */ +typedef enum +{ + G_REGEX_MATCH_ANCHORED = 1 << 4, + G_REGEX_MATCH_NOTBOL = 1 << 7, + G_REGEX_MATCH_NOTEOL = 1 << 8, + G_REGEX_MATCH_NOTEMPTY = 1 << 10, + G_REGEX_MATCH_PARTIAL = 1 << 15, + G_REGEX_MATCH_NEWLINE_CR = 1 << 20, + G_REGEX_MATCH_NEWLINE_LF = 1 << 21, + G_REGEX_MATCH_NEWLINE_CRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_LF, + G_REGEX_MATCH_NEWLINE_ANY = 1 << 22, + G_REGEX_MATCH_NEWLINE_ANYCRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_ANY, + G_REGEX_MATCH_BSR_ANYCRLF = 1 << 23, + G_REGEX_MATCH_BSR_ANY = 1 << 24, + G_REGEX_MATCH_PARTIAL_SOFT = G_REGEX_MATCH_PARTIAL, + G_REGEX_MATCH_PARTIAL_HARD = 1 << 27, + G_REGEX_MATCH_NOTEMPTY_ATSTART = 1 << 28 +} GRegexMatchFlags; + +/** + * GRegex: + * + * A GRegex is the "compiled" form of a regular expression pattern. + * This structure is opaque and its fields cannot be accessed directly. + * + * Since: 2.14 + */ +typedef struct _GRegex GRegex; + + +/** + * GMatchInfo: + * + * A GMatchInfo is an opaque struct used to return information about + * matches. + */ +typedef struct _GMatchInfo GMatchInfo; + +/** + * GRegexEvalCallback: + * @match_info: the #GMatchInfo generated by the match. + * Use g_match_info_get_regex() and g_match_info_get_string() if you + * need the #GRegex or the matched string. + * @result: a #GString containing the new string + * @user_data: user data passed to g_regex_replace_eval() + * + * Specifies the type of the function passed to g_regex_replace_eval(). + * It is called for each occurrence of the pattern in the string passed + * to g_regex_replace_eval(), and it should append the replacement to + * @result. + * + * Returns: %FALSE to continue the replacement process, %TRUE to stop it + * + * Since: 2.14 + */ +typedef gboolean (*GRegexEvalCallback) (const GMatchInfo *match_info, + GString *result, + gpointer user_data); + + +GLIB_AVAILABLE_IN_ALL +GRegex *g_regex_new (const gchar *pattern, + GRegexCompileFlags compile_options, + GRegexMatchFlags match_options, + GError **error); +GLIB_AVAILABLE_IN_ALL +GRegex *g_regex_ref (GRegex *regex); +GLIB_AVAILABLE_IN_ALL +void g_regex_unref (GRegex *regex); +GLIB_AVAILABLE_IN_ALL +const gchar *g_regex_get_pattern (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +gint g_regex_get_max_backref (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +gint g_regex_get_capture_count (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_get_has_cr_or_lf (const GRegex *regex); +GLIB_AVAILABLE_IN_2_38 +gint g_regex_get_max_lookbehind (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +gint g_regex_get_string_number (const GRegex *regex, + const gchar *name); +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_escape_string (const gchar *string, + gint length); +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_escape_nul (const gchar *string, + gint length); + +GLIB_AVAILABLE_IN_ALL +GRegexCompileFlags g_regex_get_compile_flags (const GRegex *regex); +GLIB_AVAILABLE_IN_ALL +GRegexMatchFlags g_regex_get_match_flags (const GRegex *regex); + +/* Matching. */ +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match_simple (const gchar *pattern, + const gchar *string, + GRegexCompileFlags compile_options, + GRegexMatchFlags match_options); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match (const GRegex *regex, + const gchar *string, + GRegexMatchFlags match_options, + GMatchInfo **match_info); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match_full (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + GRegexMatchFlags match_options, + GMatchInfo **match_info, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match_all (const GRegex *regex, + const gchar *string, + GRegexMatchFlags match_options, + GMatchInfo **match_info); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_match_all_full (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + GRegexMatchFlags match_options, + GMatchInfo **match_info, + GError **error); + +/* String splitting. */ +GLIB_AVAILABLE_IN_ALL +gchar **g_regex_split_simple (const gchar *pattern, + const gchar *string, + GRegexCompileFlags compile_options, + GRegexMatchFlags match_options); +GLIB_AVAILABLE_IN_ALL +gchar **g_regex_split (const GRegex *regex, + const gchar *string, + GRegexMatchFlags match_options); +GLIB_AVAILABLE_IN_ALL +gchar **g_regex_split_full (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + GRegexMatchFlags match_options, + gint max_tokens, + GError **error); + +/* String replacement. */ +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_replace (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + const gchar *replacement, + GRegexMatchFlags match_options, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_replace_literal (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + const gchar *replacement, + GRegexMatchFlags match_options, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_regex_replace_eval (const GRegex *regex, + const gchar *string, + gssize string_len, + gint start_position, + GRegexMatchFlags match_options, + GRegexEvalCallback eval, + gpointer user_data, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_regex_check_replacement (const gchar *replacement, + gboolean *has_references, + GError **error); + +/* Match info */ +GLIB_AVAILABLE_IN_ALL +GRegex *g_match_info_get_regex (const GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +const gchar *g_match_info_get_string (const GMatchInfo *match_info); + +GLIB_AVAILABLE_IN_ALL +GMatchInfo *g_match_info_ref (GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +void g_match_info_unref (GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +void g_match_info_free (GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_next (GMatchInfo *match_info, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_matches (const GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +gint g_match_info_get_match_count (const GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_is_partial_match (const GMatchInfo *match_info); +GLIB_AVAILABLE_IN_ALL +gchar *g_match_info_expand_references(const GMatchInfo *match_info, + const gchar *string_to_expand, + GError **error); +GLIB_AVAILABLE_IN_ALL +gchar *g_match_info_fetch (const GMatchInfo *match_info, + gint match_num); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_fetch_pos (const GMatchInfo *match_info, + gint match_num, + gint *start_pos, + gint *end_pos); +GLIB_AVAILABLE_IN_ALL +gchar *g_match_info_fetch_named (const GMatchInfo *match_info, + const gchar *name); +GLIB_AVAILABLE_IN_ALL +gboolean g_match_info_fetch_named_pos (const GMatchInfo *match_info, + const gchar *name, + gint *start_pos, + gint *end_pos); +GLIB_AVAILABLE_IN_ALL +gchar **g_match_info_fetch_all (const GMatchInfo *match_info); + +G_END_DECLS + +#endif /* __G_REGEX_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_SCANNER_H__ +#define __G_SCANNER_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GScanner GScanner; +typedef struct _GScannerConfig GScannerConfig; +typedef union _GTokenValue GTokenValue; + +typedef void (*GScannerMsgFunc) (GScanner *scanner, + gchar *message, + gboolean error); + +/* GScanner: Flexible lexical scanner for general purpose. + */ + +/* Character sets */ +#define G_CSET_A_2_Z "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +#define G_CSET_a_2_z "abcdefghijklmnopqrstuvwxyz" +#define G_CSET_DIGITS "0123456789" +#define G_CSET_LATINC "\300\301\302\303\304\305\306"\ + "\307\310\311\312\313\314\315\316\317\320"\ + "\321\322\323\324\325\326"\ + "\330\331\332\333\334\335\336" +#define G_CSET_LATINS "\337\340\341\342\343\344\345\346"\ + "\347\350\351\352\353\354\355\356\357\360"\ + "\361\362\363\364\365\366"\ + "\370\371\372\373\374\375\376\377" + +/* Error types */ +typedef enum +{ + G_ERR_UNKNOWN, + G_ERR_UNEXP_EOF, + G_ERR_UNEXP_EOF_IN_STRING, + G_ERR_UNEXP_EOF_IN_COMMENT, + G_ERR_NON_DIGIT_IN_CONST, + G_ERR_DIGIT_RADIX, + G_ERR_FLOAT_RADIX, + G_ERR_FLOAT_MALFORMED +} GErrorType; + +/* Token types */ +typedef enum +{ + G_TOKEN_EOF = 0, + + G_TOKEN_LEFT_PAREN = '(', + G_TOKEN_RIGHT_PAREN = ')', + G_TOKEN_LEFT_CURLY = '{', + G_TOKEN_RIGHT_CURLY = '}', + G_TOKEN_LEFT_BRACE = '[', + G_TOKEN_RIGHT_BRACE = ']', + G_TOKEN_EQUAL_SIGN = '=', + G_TOKEN_COMMA = ',', + + G_TOKEN_NONE = 256, + + G_TOKEN_ERROR, + + G_TOKEN_CHAR, + G_TOKEN_BINARY, + G_TOKEN_OCTAL, + G_TOKEN_INT, + G_TOKEN_HEX, + G_TOKEN_FLOAT, + G_TOKEN_STRING, + + G_TOKEN_SYMBOL, + G_TOKEN_IDENTIFIER, + G_TOKEN_IDENTIFIER_NULL, + + G_TOKEN_COMMENT_SINGLE, + G_TOKEN_COMMENT_MULTI, + + /*< private >*/ + G_TOKEN_LAST +} GTokenType; + +union _GTokenValue +{ + gpointer v_symbol; + gchar *v_identifier; + gulong v_binary; + gulong v_octal; + gulong v_int; + guint64 v_int64; + gdouble v_float; + gulong v_hex; + gchar *v_string; + gchar *v_comment; + guchar v_char; + guint v_error; +}; + +struct _GScannerConfig +{ + /* Character sets + */ + gchar *cset_skip_characters; /* default: " \t\n" */ + gchar *cset_identifier_first; + gchar *cset_identifier_nth; + gchar *cpair_comment_single; /* default: "#\n" */ + + /* Should symbol lookup work case sensitive? + */ + guint case_sensitive : 1; + + /* Boolean values to be adjusted "on the fly" + * to configure scanning behaviour. + */ + guint skip_comment_multi : 1; /* C like comment */ + guint skip_comment_single : 1; /* single line comment */ + guint scan_comment_multi : 1; /* scan multi line comments? */ + guint scan_identifier : 1; + guint scan_identifier_1char : 1; + guint scan_identifier_NULL : 1; + guint scan_symbols : 1; + guint scan_binary : 1; + guint scan_octal : 1; + guint scan_float : 1; + guint scan_hex : 1; /* '0x0ff0' */ + guint scan_hex_dollar : 1; /* '$0ff0' */ + guint scan_string_sq : 1; /* string: 'anything' */ + guint scan_string_dq : 1; /* string: "\\-escapes!\n" */ + guint numbers_2_int : 1; /* bin, octal, hex => int */ + guint int_2_float : 1; /* int => G_TOKEN_FLOAT? */ + guint identifier_2_string : 1; + guint char_2_token : 1; /* return G_TOKEN_CHAR? */ + guint symbol_2_token : 1; + guint scope_0_fallback : 1; /* try scope 0 on lookups? */ + guint store_int64 : 1; /* use value.v_int64 rather than v_int */ + + /*< private >*/ + guint padding_dummy; +}; + +struct _GScanner +{ + /* unused fields */ + gpointer user_data; + guint max_parse_errors; + + /* g_scanner_error() increments this field */ + guint parse_errors; + + /* name of input stream, featured by the default message handler */ + const gchar *input_name; + + /* quarked data */ + GData *qdata; + + /* link into the scanner configuration */ + GScannerConfig *config; + + /* fields filled in after g_scanner_get_next_token() */ + GTokenType token; + GTokenValue value; + guint line; + guint position; + + /* fields filled in after g_scanner_peek_next_token() */ + GTokenType next_token; + GTokenValue next_value; + guint next_line; + guint next_position; + + /*< private >*/ + /* to be considered private */ + GHashTable *symbol_table; + gint input_fd; + const gchar *text; + const gchar *text_end; + gchar *buffer; + guint scope_id; + + /*< public >*/ + /* handler function for _warn and _error */ + GScannerMsgFunc msg_handler; +}; + +GLIB_AVAILABLE_IN_ALL +GScanner* g_scanner_new (const GScannerConfig *config_templ); +GLIB_AVAILABLE_IN_ALL +void g_scanner_destroy (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +void g_scanner_input_file (GScanner *scanner, + gint input_fd); +GLIB_AVAILABLE_IN_ALL +void g_scanner_sync_file_offset (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +void g_scanner_input_text (GScanner *scanner, + const gchar *text, + guint text_len); +GLIB_AVAILABLE_IN_ALL +GTokenType g_scanner_get_next_token (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +GTokenType g_scanner_peek_next_token (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +GTokenType g_scanner_cur_token (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +GTokenValue g_scanner_cur_value (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +guint g_scanner_cur_line (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +guint g_scanner_cur_position (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +gboolean g_scanner_eof (GScanner *scanner); +GLIB_AVAILABLE_IN_ALL +guint g_scanner_set_scope (GScanner *scanner, + guint scope_id); +GLIB_AVAILABLE_IN_ALL +void g_scanner_scope_add_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol, + gpointer value); +GLIB_AVAILABLE_IN_ALL +void g_scanner_scope_remove_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol); +GLIB_AVAILABLE_IN_ALL +gpointer g_scanner_scope_lookup_symbol (GScanner *scanner, + guint scope_id, + const gchar *symbol); +GLIB_AVAILABLE_IN_ALL +void g_scanner_scope_foreach_symbol (GScanner *scanner, + guint scope_id, + GHFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_scanner_lookup_symbol (GScanner *scanner, + const gchar *symbol); +GLIB_AVAILABLE_IN_ALL +void g_scanner_unexp_token (GScanner *scanner, + GTokenType expected_token, + const gchar *identifier_spec, + const gchar *symbol_spec, + const gchar *symbol_name, + const gchar *message, + gint is_error); +GLIB_AVAILABLE_IN_ALL +void g_scanner_error (GScanner *scanner, + const gchar *format, + ...) G_GNUC_PRINTF (2,3); +GLIB_AVAILABLE_IN_ALL +void g_scanner_warn (GScanner *scanner, + const gchar *format, + ...) G_GNUC_PRINTF (2,3); + +/* keep downward source compatibility */ +#define g_scanner_add_symbol( scanner, symbol, value ) G_STMT_START { \ + g_scanner_scope_add_symbol ((scanner), 0, (symbol), (value)); \ +} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_add_symbol) +#define g_scanner_remove_symbol( scanner, symbol ) G_STMT_START { \ + g_scanner_scope_remove_symbol ((scanner), 0, (symbol)); \ +} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_remove_symbol) +#define g_scanner_foreach_symbol( scanner, func, data ) G_STMT_START { \ + g_scanner_scope_foreach_symbol ((scanner), 0, (func), (data)); \ +} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_foreach_symbol) + +/* The following two functions are deprecated and will be removed in + * the next major release. They do no good. */ +#define g_scanner_freeze_symbol_table(scanner) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 +#define g_scanner_thaw_symbol_table(scanner) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 + +G_END_DECLS + +#endif /* __G_SCANNER_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 + * Soeren Sandmann (sandmann@daimi.au.dk) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_SEQUENCE_H__ +#define __G_SEQUENCE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GSequence GSequence; +typedef struct _GSequenceNode GSequenceIter; + +typedef gint (* GSequenceIterCompareFunc) (GSequenceIter *a, + GSequenceIter *b, + gpointer data); + + +/* GSequence */ +GLIB_AVAILABLE_IN_ALL +GSequence * g_sequence_new (GDestroyNotify data_destroy); +GLIB_AVAILABLE_IN_ALL +void g_sequence_free (GSequence *seq); +GLIB_AVAILABLE_IN_ALL +gint g_sequence_get_length (GSequence *seq); +GLIB_AVAILABLE_IN_ALL +void g_sequence_foreach (GSequence *seq, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_foreach_range (GSequenceIter *begin, + GSequenceIter *end, + GFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_sort (GSequence *seq, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_sort_iter (GSequence *seq, + GSequenceIterCompareFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_2_48 +gboolean g_sequence_is_empty (GSequence *seq); + + +/* Getting iters */ +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_get_begin_iter (GSequence *seq); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_get_end_iter (GSequence *seq); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_get_iter_at_pos (GSequence *seq, + gint pos); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_append (GSequence *seq, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_prepend (GSequence *seq, + gpointer data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_insert_before (GSequenceIter *iter, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_move (GSequenceIter *src, + GSequenceIter *dest); +GLIB_AVAILABLE_IN_ALL +void g_sequence_swap (GSequenceIter *a, + GSequenceIter *b); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_insert_sorted (GSequence *seq, + gpointer data, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_insert_sorted_iter (GSequence *seq, + gpointer data, + GSequenceIterCompareFunc iter_cmp, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_sort_changed (GSequenceIter *iter, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_sort_changed_iter (GSequenceIter *iter, + GSequenceIterCompareFunc iter_cmp, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +void g_sequence_remove (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +void g_sequence_remove_range (GSequenceIter *begin, + GSequenceIter *end); +GLIB_AVAILABLE_IN_ALL +void g_sequence_move_range (GSequenceIter *dest, + GSequenceIter *begin, + GSequenceIter *end); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_search (GSequence *seq, + gpointer data, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_search_iter (GSequence *seq, + gpointer data, + GSequenceIterCompareFunc iter_cmp, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_lookup (GSequence *seq, + gpointer data, + GCompareDataFunc cmp_func, + gpointer cmp_data); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_lookup_iter (GSequence *seq, + gpointer data, + GSequenceIterCompareFunc iter_cmp, + gpointer cmp_data); + + +/* Dereferencing */ +GLIB_AVAILABLE_IN_ALL +gpointer g_sequence_get (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +void g_sequence_set (GSequenceIter *iter, + gpointer data); + +/* Operations on GSequenceIter * */ +GLIB_AVAILABLE_IN_ALL +gboolean g_sequence_iter_is_begin (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +gboolean g_sequence_iter_is_end (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_iter_next (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_iter_prev (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +gint g_sequence_iter_get_position (GSequenceIter *iter); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_iter_move (GSequenceIter *iter, + gint delta); +GLIB_AVAILABLE_IN_ALL +GSequence * g_sequence_iter_get_sequence (GSequenceIter *iter); + + +/* Search */ +GLIB_AVAILABLE_IN_ALL +gint g_sequence_iter_compare (GSequenceIter *a, + GSequenceIter *b); +GLIB_AVAILABLE_IN_ALL +GSequenceIter *g_sequence_range_get_midpoint (GSequenceIter *begin, + GSequenceIter *end); + +G_END_DECLS + +#endif /* __G_SEQUENCE_H__ */ +/* gshell.h - Shell-related utilities + * + * Copyright 2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_SHELL_H__ +#define __G_SHELL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +#define G_SHELL_ERROR g_shell_error_quark () + +typedef enum +{ + /* mismatched or otherwise mangled quoting */ + G_SHELL_ERROR_BAD_QUOTING, + /* string to be parsed was empty */ + G_SHELL_ERROR_EMPTY_STRING, + G_SHELL_ERROR_FAILED +} GShellError; + +GLIB_AVAILABLE_IN_ALL +GQuark g_shell_error_quark (void); + +GLIB_AVAILABLE_IN_ALL +gchar* g_shell_quote (const gchar *unquoted_string); +GLIB_AVAILABLE_IN_ALL +gchar* g_shell_unquote (const gchar *quoted_string, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_shell_parse_argv (const gchar *command_line, + gint *argcp, + gchar ***argvp, + GError **error); + +G_END_DECLS + +#endif /* __G_SHELL_H__ */ +/* GLIB sliced memory - fast threaded memory chunk allocator + * Copyright (C) 2005 Tim Janik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_SLICE_H__ +#define __G_SLICE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* slices - fast allocation/release of small memory blocks + */ +GLIB_AVAILABLE_IN_ALL +gpointer g_slice_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_slice_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +gpointer g_slice_copy (gsize block_size, + gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); +GLIB_AVAILABLE_IN_ALL +void g_slice_free1 (gsize block_size, + gpointer mem_block); +GLIB_AVAILABLE_IN_ALL +void g_slice_free_chain_with_offset (gsize block_size, + gpointer mem_chain, + gsize next_offset); +#define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type))) + +/* Allow the compiler to inline memset(). Since the size is a constant, this + * can significantly improve performance. */ +#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) +# define g_slice_new0(type) \ + (type *) (G_GNUC_EXTENSION ({ \ + gsize __s = sizeof (type); \ + gpointer __p; \ + __p = g_slice_alloc (__s); \ + memset (__p, 0, __s); \ + __p; \ + })) +#else +# define g_slice_new0(type) ((type*) g_slice_alloc0 (sizeof (type))) +#endif + +/* MemoryBlockType * + * g_slice_dup (MemoryBlockType, + * MemoryBlockType *mem_block); + * g_slice_free (MemoryBlockType, + * MemoryBlockType *mem_block); + * g_slice_free_chain (MemoryBlockType, + * MemoryBlockType *first_chain_block, + * memory_block_next_field); + * pseudo prototypes for the macro + * definitions following below. + */ + +/* we go through extra hoops to ensure type safety */ +#define g_slice_dup(type, mem) \ + (1 ? (type*) g_slice_copy (sizeof (type), (mem)) \ + : ((void) ((type*) 0 == (mem)), (type*) 0)) +#define g_slice_free(type, mem) \ +G_STMT_START { \ + if (1) g_slice_free1 (sizeof (type), (mem)); \ + else (void) ((type*) 0 == (mem)); \ +} G_STMT_END +#define g_slice_free_chain(type, mem_chain, next) \ +G_STMT_START { \ + if (1) g_slice_free_chain_with_offset (sizeof (type), \ + (mem_chain), G_STRUCT_OFFSET (type, next)); \ + else (void) ((type*) 0 == (mem_chain)); \ +} G_STMT_END + +/* --- internal debugging API --- */ +typedef enum { + G_SLICE_CONFIG_ALWAYS_MALLOC = 1, + G_SLICE_CONFIG_BYPASS_MAGAZINES, + G_SLICE_CONFIG_WORKING_SET_MSECS, + G_SLICE_CONFIG_COLOR_INCREMENT, + G_SLICE_CONFIG_CHUNK_SIZES, + G_SLICE_CONFIG_CONTENTION_COUNTER +} GSliceConfig; + +GLIB_DEPRECATED_IN_2_34 +void g_slice_set_config (GSliceConfig ckey, gint64 value); +GLIB_DEPRECATED_IN_2_34 +gint64 g_slice_get_config (GSliceConfig ckey); +GLIB_DEPRECATED_IN_2_34 +gint64* g_slice_get_config_state (GSliceConfig ckey, gint64 address, guint *n_values); + +#ifdef G_ENABLE_DEBUG +GLIB_AVAILABLE_IN_ALL +void g_slice_debug_tree_statistics (void); +#endif + +G_END_DECLS + +#endif /* __G_SLICE_H__ */ +/* gspawn.h - Process launching + * + * Copyright 2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, see . + */ + +#ifndef __G_SPAWN_H__ +#define __G_SPAWN_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + + +/* I'm not sure I remember our proposed naming convention here. */ +/** + * G_SPAWN_ERROR: + * + * Error domain for spawning processes. Errors in this domain will + * be from the #GSpawnError enumeration. See #GError for information on + * error domains. + */ +#define G_SPAWN_ERROR g_spawn_error_quark () + +/** + * GSpawnError: + * @G_SPAWN_ERROR_FORK: Fork failed due to lack of memory. + * @G_SPAWN_ERROR_READ: Read or select on pipes failed. + * @G_SPAWN_ERROR_CHDIR: Changing to working directory failed. + * @G_SPAWN_ERROR_ACCES: execv() returned `EACCES` + * @G_SPAWN_ERROR_PERM: execv() returned `EPERM` + * @G_SPAWN_ERROR_TOO_BIG: execv() returned `E2BIG` + * @G_SPAWN_ERROR_2BIG: deprecated alias for %G_SPAWN_ERROR_TOO_BIG (deprecated since GLib 2.32) + * @G_SPAWN_ERROR_NOEXEC: execv() returned `ENOEXEC` + * @G_SPAWN_ERROR_NAMETOOLONG: execv() returned `ENAMETOOLONG` + * @G_SPAWN_ERROR_NOENT: execv() returned `ENOENT` + * @G_SPAWN_ERROR_NOMEM: execv() returned `ENOMEM` + * @G_SPAWN_ERROR_NOTDIR: execv() returned `ENOTDIR` + * @G_SPAWN_ERROR_LOOP: execv() returned `ELOOP` + * @G_SPAWN_ERROR_TXTBUSY: execv() returned `ETXTBUSY` + * @G_SPAWN_ERROR_IO: execv() returned `EIO` + * @G_SPAWN_ERROR_NFILE: execv() returned `ENFILE` + * @G_SPAWN_ERROR_MFILE: execv() returned `EMFILE` + * @G_SPAWN_ERROR_INVAL: execv() returned `EINVAL` + * @G_SPAWN_ERROR_ISDIR: execv() returned `EISDIR` + * @G_SPAWN_ERROR_LIBBAD: execv() returned `ELIBBAD` + * @G_SPAWN_ERROR_FAILED: Some other fatal failure, + * `error->message` should explain. + * + * Error codes returned by spawning processes. + */ +typedef enum +{ + G_SPAWN_ERROR_FORK, /* fork failed due to lack of memory */ + G_SPAWN_ERROR_READ, /* read or select on pipes failed */ + G_SPAWN_ERROR_CHDIR, /* changing to working dir failed */ + G_SPAWN_ERROR_ACCES, /* execv() returned EACCES */ + G_SPAWN_ERROR_PERM, /* execv() returned EPERM */ + G_SPAWN_ERROR_TOO_BIG,/* execv() returned E2BIG */ + G_SPAWN_ERROR_2BIG GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(G_SPAWN_ERROR_TOO_BIG) = G_SPAWN_ERROR_TOO_BIG, + G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */ + G_SPAWN_ERROR_NAMETOOLONG, /* "" "" ENAMETOOLONG */ + G_SPAWN_ERROR_NOENT, /* "" "" ENOENT */ + G_SPAWN_ERROR_NOMEM, /* "" "" ENOMEM */ + G_SPAWN_ERROR_NOTDIR, /* "" "" ENOTDIR */ + G_SPAWN_ERROR_LOOP, /* "" "" ELOOP */ + G_SPAWN_ERROR_TXTBUSY, /* "" "" ETXTBUSY */ + G_SPAWN_ERROR_IO, /* "" "" EIO */ + G_SPAWN_ERROR_NFILE, /* "" "" ENFILE */ + G_SPAWN_ERROR_MFILE, /* "" "" EMFLE */ + G_SPAWN_ERROR_INVAL, /* "" "" EINVAL */ + G_SPAWN_ERROR_ISDIR, /* "" "" EISDIR */ + G_SPAWN_ERROR_LIBBAD, /* "" "" ELIBBAD */ + G_SPAWN_ERROR_FAILED /* other fatal failure, error->message + * should explain + */ +} GSpawnError; + +/** + * G_SPAWN_EXIT_ERROR: + * + * Error domain used by g_spawn_check_exit_status(). The code + * will be the program exit code. + */ +#define G_SPAWN_EXIT_ERROR g_spawn_exit_error_quark () + +/** + * GSpawnChildSetupFunc: + * @user_data: (closure): user data to pass to the function. + * + * Specifies the type of the setup function passed to g_spawn_async(), + * g_spawn_sync() and g_spawn_async_with_pipes(), which can, in very + * limited ways, be used to affect the child's execution. + * + * On POSIX platforms, the function is called in the child after GLib + * has performed all the setup it plans to perform, but before calling + * exec(). Actions taken in this function will only affect the child, + * not the parent. + * + * On Windows, the function is called in the parent. Its usefulness on + * Windows is thus questionable. In many cases executing the child setup + * function in the parent can have ill effects, and you should be very + * careful when porting software to Windows that uses child setup + * functions. + * + * However, even on POSIX, you are extremely limited in what you can + * safely do from a #GSpawnChildSetupFunc, because any mutexes that were + * held by other threads in the parent process at the time of the fork() + * will still be locked in the child process, and they will never be + * unlocked (since the threads that held them don't exist in the child). + * POSIX allows only async-signal-safe functions (see signal(7)) to be + * called in the child between fork() and exec(), which drastically limits + * the usefulness of child setup functions. + * + * In particular, it is not safe to call any function which may + * call malloc(), which includes POSIX functions such as setenv(). + * If you need to set up the child environment differently from + * the parent, you should use g_get_environ(), g_environ_setenv(), + * and g_environ_unsetenv(), and then pass the complete environment + * list to the `g_spawn...` function. + */ +typedef void (* GSpawnChildSetupFunc) (gpointer user_data); + +/** + * GSpawnFlags: + * @G_SPAWN_DEFAULT: no flags, default behaviour + * @G_SPAWN_LEAVE_DESCRIPTORS_OPEN: the parent's open file descriptors will + * be inherited by the child; otherwise all descriptors except stdin, + * stdout and stderr will be closed before calling exec() in the child. + * @G_SPAWN_DO_NOT_REAP_CHILD: the child will not be automatically reaped; + * you must use g_child_watch_add() yourself (or call waitpid() or handle + * `SIGCHLD` yourself), or the child will become a zombie. + * @G_SPAWN_SEARCH_PATH: `argv[0]` need not be an absolute path, it will be + * looked for in the user's `PATH`. + * @G_SPAWN_STDOUT_TO_DEV_NULL: the child's standard output will be discarded, + * instead of going to the same location as the parent's standard output. + * @G_SPAWN_STDERR_TO_DEV_NULL: the child's standard error will be discarded. + * @G_SPAWN_CHILD_INHERITS_STDIN: the child will inherit the parent's standard + * input (by default, the child's standard input is attached to `/dev/null`). + * @G_SPAWN_FILE_AND_ARGV_ZERO: the first element of `argv` is the file to + * execute, while the remaining elements are the actual argument vector + * to pass to the file. Normally g_spawn_async_with_pipes() uses `argv[0]` + * as the file to execute, and passes all of `argv` to the child. + * @G_SPAWN_SEARCH_PATH_FROM_ENVP: if `argv[0]` is not an absolute path, + * it will be looked for in the `PATH` from the passed child environment. + * Since: 2.34 + * @G_SPAWN_CLOEXEC_PIPES: create all pipes with the `O_CLOEXEC` flag set. + * Since: 2.40 + * + * Flags passed to g_spawn_sync(), g_spawn_async() and g_spawn_async_with_pipes(). + */ +typedef enum +{ + G_SPAWN_DEFAULT = 0, + G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0, + G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, + /* look for argv[0] in the path i.e. use execvp() */ + G_SPAWN_SEARCH_PATH = 1 << 2, + /* Dump output to /dev/null */ + G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, + G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, + G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5, + G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6, + G_SPAWN_SEARCH_PATH_FROM_ENVP = 1 << 7, + G_SPAWN_CLOEXEC_PIPES = 1 << 8 +} GSpawnFlags; + +GLIB_AVAILABLE_IN_ALL +GQuark g_spawn_error_quark (void); +GLIB_AVAILABLE_IN_ALL +GQuark g_spawn_exit_error_quark (void); + +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_async (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + GError **error); + + +/* Opens pipes for non-NULL standard_output, standard_input, standard_error, + * and returns the parent's end of the pipes. + */ +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_async_with_pipes (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + gint *standard_input, + gint *standard_output, + gint *standard_error, + GError **error); + +/* Lets you provide fds for stdin/stdout/stderr */ +GLIB_AVAILABLE_IN_2_58 +gboolean g_spawn_async_with_fds (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + GPid *child_pid, + gint stdin_fd, + gint stdout_fd, + gint stderr_fd, + GError **error); + +/* If standard_output or standard_error are non-NULL, the full + * standard output or error of the command will be placed there. + */ + +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_sync (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + gchar **standard_output, + gchar **standard_error, + gint *exit_status, + GError **error); + +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_command_line_sync (const gchar *command_line, + gchar **standard_output, + gchar **standard_error, + gint *exit_status, + GError **error); +GLIB_AVAILABLE_IN_ALL +gboolean g_spawn_command_line_async (const gchar *command_line, + GError **error); + +GLIB_AVAILABLE_IN_2_34 +gboolean g_spawn_check_exit_status (gint exit_status, + GError **error); + +GLIB_AVAILABLE_IN_ALL +void g_spawn_close_pid (GPid pid); + +G_END_DECLS + +#endif /* __G_SPAWN_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_STRFUNCS_H__ +#define __G_STRFUNCS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +G_BEGIN_DECLS + +/* Functions like the ones in that are not affected by locale. */ +typedef enum { + G_ASCII_ALNUM = 1 << 0, + G_ASCII_ALPHA = 1 << 1, + G_ASCII_CNTRL = 1 << 2, + G_ASCII_DIGIT = 1 << 3, + G_ASCII_GRAPH = 1 << 4, + G_ASCII_LOWER = 1 << 5, + G_ASCII_PRINT = 1 << 6, + G_ASCII_PUNCT = 1 << 7, + G_ASCII_SPACE = 1 << 8, + G_ASCII_UPPER = 1 << 9, + G_ASCII_XDIGIT = 1 << 10 +} GAsciiType; + +GLIB_VAR const guint16 * const g_ascii_table; + +#define g_ascii_isalnum(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_ALNUM) != 0) + +#define g_ascii_isalpha(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_ALPHA) != 0) + +#define g_ascii_iscntrl(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_CNTRL) != 0) + +#define g_ascii_isdigit(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_DIGIT) != 0) + +#define g_ascii_isgraph(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_GRAPH) != 0) + +#define g_ascii_islower(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_LOWER) != 0) + +#define g_ascii_isprint(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_PRINT) != 0) + +#define g_ascii_ispunct(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_PUNCT) != 0) + +#define g_ascii_isspace(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_SPACE) != 0) + +#define g_ascii_isupper(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_UPPER) != 0) + +#define g_ascii_isxdigit(c) \ + ((g_ascii_table[(guchar) (c)] & G_ASCII_XDIGIT) != 0) + +GLIB_AVAILABLE_IN_ALL +gchar g_ascii_tolower (gchar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gchar g_ascii_toupper (gchar c) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +gint g_ascii_digit_value (gchar c) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gint g_ascii_xdigit_value (gchar c) G_GNUC_CONST; + +/* String utility functions that modify a string argument or + * return a constant string that must not be freed. + */ +#define G_STR_DELIMITERS "_-|> <." +GLIB_AVAILABLE_IN_ALL +gchar* g_strdelimit (gchar *string, + const gchar *delimiters, + gchar new_delimiter); +GLIB_AVAILABLE_IN_ALL +gchar* g_strcanon (gchar *string, + const gchar *valid_chars, + gchar substitutor); +GLIB_AVAILABLE_IN_ALL +const gchar * g_strerror (gint errnum) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +const gchar * g_strsignal (gint signum) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gchar * g_strreverse (gchar *string); +GLIB_AVAILABLE_IN_ALL +gsize g_strlcpy (gchar *dest, + const gchar *src, + gsize dest_size); +GLIB_AVAILABLE_IN_ALL +gsize g_strlcat (gchar *dest, + const gchar *src, + gsize dest_size); +GLIB_AVAILABLE_IN_ALL +gchar * g_strstr_len (const gchar *haystack, + gssize haystack_len, + const gchar *needle); +GLIB_AVAILABLE_IN_ALL +gchar * g_strrstr (const gchar *haystack, + const gchar *needle); +GLIB_AVAILABLE_IN_ALL +gchar * g_strrstr_len (const gchar *haystack, + gssize haystack_len, + const gchar *needle); + +GLIB_AVAILABLE_IN_ALL +gboolean g_str_has_suffix (const gchar *str, + const gchar *suffix); +GLIB_AVAILABLE_IN_ALL +gboolean g_str_has_prefix (const gchar *str, + const gchar *prefix); + +/* String to/from double conversion functions */ + +GLIB_AVAILABLE_IN_ALL +gdouble g_strtod (const gchar *nptr, + gchar **endptr); +GLIB_AVAILABLE_IN_ALL +gdouble g_ascii_strtod (const gchar *nptr, + gchar **endptr); +GLIB_AVAILABLE_IN_ALL +guint64 g_ascii_strtoull (const gchar *nptr, + gchar **endptr, + guint base); +GLIB_AVAILABLE_IN_ALL +gint64 g_ascii_strtoll (const gchar *nptr, + gchar **endptr, + guint base); +/* 29 bytes should enough for all possible values that + * g_ascii_dtostr can produce. + * Then add 10 for good measure */ +#define G_ASCII_DTOSTR_BUF_SIZE (29 + 10) +GLIB_AVAILABLE_IN_ALL +gchar * g_ascii_dtostr (gchar *buffer, + gint buf_len, + gdouble d); +GLIB_AVAILABLE_IN_ALL +gchar * g_ascii_formatd (gchar *buffer, + gint buf_len, + const gchar *format, + gdouble d); + +/* removes leading spaces */ +GLIB_AVAILABLE_IN_ALL +gchar* g_strchug (gchar *string); +/* removes trailing spaces */ +GLIB_AVAILABLE_IN_ALL +gchar* g_strchomp (gchar *string); +/* removes leading & trailing spaces */ +#define g_strstrip( string ) g_strchomp (g_strchug (string)) + +GLIB_AVAILABLE_IN_ALL +gint g_ascii_strcasecmp (const gchar *s1, + const gchar *s2); +GLIB_AVAILABLE_IN_ALL +gint g_ascii_strncasecmp (const gchar *s1, + const gchar *s2, + gsize n); +GLIB_AVAILABLE_IN_ALL +gchar* g_ascii_strdown (const gchar *str, + gssize len) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_ascii_strup (const gchar *str, + gssize len) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_2_40 +gboolean g_str_is_ascii (const gchar *str); + +GLIB_DEPRECATED +gint g_strcasecmp (const gchar *s1, + const gchar *s2); +GLIB_DEPRECATED +gint g_strncasecmp (const gchar *s1, + const gchar *s2, + guint n); +GLIB_DEPRECATED +gchar* g_strdown (gchar *string); +GLIB_DEPRECATED +gchar* g_strup (gchar *string); + + +/* String utility functions that return a newly allocated string which + * ought to be freed with g_free from the caller at some point. + */ +GLIB_AVAILABLE_IN_ALL +gchar* g_strdup (const gchar *str) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strdup_printf (const gchar *format, + ...) G_GNUC_PRINTF (1, 2) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strdup_vprintf (const gchar *format, + va_list args) G_GNUC_PRINTF(1, 0) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strndup (const gchar *str, + gsize n) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strnfill (gsize length, + gchar fill_char) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +gchar* g_strconcat (const gchar *string1, + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +gchar* g_strjoin (const gchar *separator, + ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; + +/* Make a copy of a string interpreting C string -style escape + * sequences. Inverse of g_strescape. The recognized sequences are \b + * \f \n \r \t \\ \" and the octal format. + */ +GLIB_AVAILABLE_IN_ALL +gchar* g_strcompress (const gchar *source) G_GNUC_MALLOC; + +/* Copy a string escaping nonprintable characters like in C strings. + * Inverse of g_strcompress. The exceptions parameter, if non-NULL, points + * to a string containing characters that are not to be escaped. + * + * Deprecated API: gchar* g_strescape (const gchar *source); + * Luckily this function wasn't used much, using NULL as second parameter + * provides mostly identical semantics. + */ +GLIB_AVAILABLE_IN_ALL +gchar* g_strescape (const gchar *source, + const gchar *exceptions) G_GNUC_MALLOC; + +GLIB_AVAILABLE_IN_ALL +gpointer g_memdup (gconstpointer mem, + guint byte_size) G_GNUC_ALLOC_SIZE(2); + +/* NULL terminated string arrays. + * g_strsplit(), g_strsplit_set() split up string into max_tokens tokens + * at delim and return a newly allocated string array. + * g_strjoinv() concatenates all of str_array's strings, sliding in an + * optional separator, the returned string is newly allocated. + * g_strfreev() frees the array itself and all of its strings. + * g_strdupv() copies a NULL-terminated array of strings + * g_strv_length() returns the length of a NULL-terminated array of strings + */ +typedef gchar** GStrv; +GLIB_AVAILABLE_IN_ALL +gchar** g_strsplit (const gchar *string, + const gchar *delimiter, + gint max_tokens); +GLIB_AVAILABLE_IN_ALL +gchar ** g_strsplit_set (const gchar *string, + const gchar *delimiters, + gint max_tokens); +GLIB_AVAILABLE_IN_ALL +gchar* g_strjoinv (const gchar *separator, + gchar **str_array) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_ALL +void g_strfreev (gchar **str_array); +GLIB_AVAILABLE_IN_ALL +gchar** g_strdupv (gchar **str_array); +GLIB_AVAILABLE_IN_ALL +guint g_strv_length (gchar **str_array); + +GLIB_AVAILABLE_IN_ALL +gchar* g_stpcpy (gchar *dest, + const char *src); + +GLIB_AVAILABLE_IN_2_40 +gchar * g_str_to_ascii (const gchar *str, + const gchar *from_locale); + +GLIB_AVAILABLE_IN_2_40 +gchar ** g_str_tokenize_and_fold (const gchar *string, + const gchar *translit_locale, + gchar ***ascii_alternates); + +GLIB_AVAILABLE_IN_2_40 +gboolean g_str_match_string (const gchar *search_term, + const gchar *potential_hit, + gboolean accept_alternates); + +GLIB_AVAILABLE_IN_2_44 +gboolean g_strv_contains (const gchar * const *strv, + const gchar *str); + +GLIB_AVAILABLE_IN_2_60 +gboolean g_strv_equal (const gchar * const *strv1, + const gchar * const *strv2); + +/* Convenience ASCII string to number API */ + +/** + * GNumberParserError: + * @G_NUMBER_PARSER_ERROR_INVALID: String was not a valid number. + * @G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS: String was a number, but out of bounds. + * + * Error codes returned by functions converting a string to a number. + * + * Since: 2.54 + */ +typedef enum + { + G_NUMBER_PARSER_ERROR_INVALID, + G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS, + } GNumberParserError; + +/** + * G_NUMBER_PARSER_ERROR: + * + * Domain for errors returned by functions converting a string to a + * number. + * + * Since: 2.54 + */ +#define G_NUMBER_PARSER_ERROR (g_number_parser_error_quark ()) + +GLIB_AVAILABLE_IN_2_54 +GQuark g_number_parser_error_quark (void); + +GLIB_AVAILABLE_IN_2_54 +gboolean g_ascii_string_to_signed (const gchar *str, + guint base, + gint64 min, + gint64 max, + gint64 *out_num, + GError **error); + +GLIB_AVAILABLE_IN_2_54 +gboolean g_ascii_string_to_unsigned (const gchar *str, + guint base, + guint64 min, + guint64 max, + guint64 *out_num, + GError **error); + +G_END_DECLS + +#endif /* __G_STRFUNCS_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_STRINGCHUNK_H__ +#define __G_STRINGCHUNK_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GStringChunk GStringChunk; + +GLIB_AVAILABLE_IN_ALL +GStringChunk* g_string_chunk_new (gsize size); +GLIB_AVAILABLE_IN_ALL +void g_string_chunk_free (GStringChunk *chunk); +GLIB_AVAILABLE_IN_ALL +void g_string_chunk_clear (GStringChunk *chunk); +GLIB_AVAILABLE_IN_ALL +gchar* g_string_chunk_insert (GStringChunk *chunk, + const gchar *string); +GLIB_AVAILABLE_IN_ALL +gchar* g_string_chunk_insert_len (GStringChunk *chunk, + const gchar *string, + gssize len); +GLIB_AVAILABLE_IN_ALL +gchar* g_string_chunk_insert_const (GStringChunk *chunk, + const gchar *string); + +G_END_DECLS + +#endif /* __G_STRING_H__ */ +/* + * Copyright © 2020 Canonical Ltd. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_STRVBUILDER_H__ +#define __G_STRVBUILDER_H__ + +#if !defined(__GLIB_H_INSIDE__) && !defined(GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * GStrvBuilder: + * + * A helper object to build a %NULL-terminated string array + * by appending. See g_strv_builder_new(). + * + * Since: 2.68 + */ +typedef struct _GStrvBuilder GStrvBuilder; + +GLIB_AVAILABLE_IN_2_68 +GStrvBuilder *g_strv_builder_new (void); + +GLIB_AVAILABLE_IN_2_68 +void g_strv_builder_unref (GStrvBuilder *builder); + +GLIB_AVAILABLE_IN_2_68 +GStrvBuilder *g_strv_builder_ref (GStrvBuilder *builder); + +GLIB_AVAILABLE_IN_2_68 +void g_strv_builder_add (GStrvBuilder *builder, + const char *value); + +GLIB_AVAILABLE_IN_2_68 +GStrv g_strv_builder_end (GStrvBuilder *builder); + +G_END_DECLS + +#endif /* __G_STRVBUILDER_H__ */ +/* GLib testing utilities + * Copyright (C) 2007 Imendio AB + * Authors: Tim Janik + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_TEST_UTILS_H__ +#define __G_TEST_UTILS_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +#include +#include + +G_BEGIN_DECLS + +typedef struct GTestCase GTestCase; +typedef struct GTestSuite GTestSuite; +typedef void (*GTestFunc) (void); +typedef void (*GTestDataFunc) (gconstpointer user_data); +typedef void (*GTestFixtureFunc) (gpointer fixture, + gconstpointer user_data); + +/* assertion API */ +#define g_assert_cmpstr(s1, cmp, s2) G_STMT_START { \ + const char *__s1 = (s1), *__s2 = (s2); \ + if (g_strcmp0 (__s1, __s2) cmp 0) ; else \ + g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #s1 " " #cmp " " #s2, __s1, #cmp, __s2); \ + } G_STMT_END +#define g_assert_cmpint(n1, cmp, n2) G_STMT_START { \ + gint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'i'); \ + } G_STMT_END +#define g_assert_cmpuint(n1, cmp, n2) G_STMT_START { \ + guint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'i'); \ + } G_STMT_END +#define g_assert_cmphex(n1, cmp, n2) G_STMT_START {\ + guint64 __n1 = (n1), __n2 = (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'x'); \ + } G_STMT_END +#define g_assert_cmpfloat(n1,cmp,n2) G_STMT_START { \ + long double __n1 = (long double) (n1), __n2 = (long double) (n2); \ + if (__n1 cmp __n2) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'f'); \ + } G_STMT_END +#define g_assert_cmpfloat_with_epsilon(n1,n2,epsilon) \ + G_STMT_START { \ + double __n1 = (n1), __n2 = (n2), __epsilon = (epsilon); \ + if (G_APPROX_VALUE (__n1, __n2, __epsilon)) ; else \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #n1 " == " #n2 " (+/- " #epsilon ")", __n1, "==", __n2, 'f'); \ + } G_STMT_END +#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\ + gconstpointer __m1 = m1, __m2 = m2; \ + int __l1 = l1, __l2 = l2; \ + if (__l1 != 0 && __m1 == NULL) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #l1 " == 0 || " #m1 " != NULL)"); \ + else if (__l2 != 0 && __m2 == NULL) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #l2 " == 0 || " #m2 " != NULL)"); \ + else if (__l1 != __l2) \ + g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", \ + (long double) __l1, "==", (long double) __l2, 'i'); \ + else if (__l1 != 0 && __m2 != NULL && memcmp (__m1, __m2, __l1) != 0) \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #m1 " == " #m2 ")"); \ + } G_STMT_END +#define g_assert_cmpvariant(v1, v2) \ + G_STMT_START \ + { \ + GVariant *__v1 = (v1), *__v2 = (v2); \ + if (!g_variant_equal (__v1, __v2)) \ + { \ + gchar *__s1, *__s2, *__msg; \ + __s1 = g_variant_print (__v1, TRUE); \ + __s2 = g_variant_print (__v2, TRUE); \ + __msg = g_strdup_printf ("assertion failed (" #v1 " == " #v2 "): %s does not equal %s", __s1, __s2); \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ + g_free (__s1); \ + g_free (__s2); \ + g_free (__msg); \ + } \ + } \ + G_STMT_END +#define g_assert_cmpstrv(strv1, strv2) \ + G_STMT_START \ + { \ + const char * const *__strv1 = (const char * const *) (strv1); \ + const char * const *__strv2 = (const char * const *) (strv2); \ + if (!__strv1 || !__strv2) \ + { \ + if (__strv1) \ + { \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #strv1 " == " #strv2 "): " #strv2 " is NULL, but " #strv1 " is not"); \ + } \ + else if (__strv2) \ + { \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "assertion failed (" #strv1 " == " #strv2 "): " #strv1 " is NULL, but " #strv2 " is not"); \ + } \ + } \ + else \ + { \ + guint __l1 = g_strv_length ((char **) __strv1); \ + guint __l2 = g_strv_length ((char **) __strv2); \ + if (__l1 != __l2) \ + { \ + char *__msg; \ + __msg = g_strdup_printf ("assertion failed (" #strv1 " == " #strv2 "): length %u does not equal length %u", __l1, __l2); \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ + g_free (__msg); \ + } \ + else \ + { \ + guint __i; \ + for (__i = 0; __i < __l1; __i++) \ + { \ + if (g_strcmp0 (__strv1[__i], __strv2[__i]) != 0) \ + { \ + g_assertion_message_cmpstrv (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #strv1 " == " #strv2, \ + __strv1, __strv2, __i); \ + } \ + } \ + } \ + } \ + } \ + G_STMT_END +#define g_assert_no_errno(expr) G_STMT_START { \ + int __ret, __errsv; \ + errno = 0; \ + __ret = expr; \ + __errsv = errno; \ + if (__ret < 0) \ + { \ + gchar *__msg; \ + __msg = g_strdup_printf ("assertion failed (" #expr " >= 0): errno %i: %s", __errsv, g_strerror (__errsv)); \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ + g_free (__msg); \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_66 +#define g_assert_no_error(err) G_STMT_START { \ + if (err) \ + g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #err, err, 0, 0); \ + } G_STMT_END +#define g_assert_error(err, dom, c) G_STMT_START { \ + if (!err || (err)->domain != dom || (err)->code != c) \ + g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #err, err, dom, c); \ + } G_STMT_END +#define g_assert_true(expr) G_STMT_START { \ + if G_LIKELY (expr) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should be TRUE"); \ + } G_STMT_END +#define g_assert_false(expr) G_STMT_START { \ + if G_LIKELY (!(expr)) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should be FALSE"); \ + } G_STMT_END + +/* Use nullptr in C++ to catch misuse of these macros. */ +#if defined(__cplusplus) && __cplusplus >= 201100L +#define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == nullptr) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should be nullptr"); \ + } G_STMT_END +#define g_assert_nonnull(expr) G_STMT_START { \ + if G_LIKELY ((expr) != nullptr) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should not be nullptr"); \ + } G_STMT_END +#else /* not C++ */ +#define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == NULL) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should be NULL"); \ + } G_STMT_END +#define g_assert_nonnull(expr) G_STMT_START { \ + if G_LIKELY ((expr) != NULL) ; else \ + g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + "'" #expr "' should not be NULL"); \ + } G_STMT_END +#endif + +#ifdef G_DISABLE_ASSERT +/* https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005funreachable + * GCC 5 is not a strict lower bound for versions of GCC which provide __builtin_unreachable(). */ +#if __GNUC__ >= 5 || g_macro__has_builtin(__builtin_unreachable) +#define g_assert_not_reached() G_STMT_START { (void) 0; __builtin_unreachable (); } G_STMT_END +#elif defined (_MSC_VER) +#define g_assert_not_reached() G_STMT_START { (void) 0; __assume (0); } G_STMT_END +#else /* if __builtin_unreachable() is not supported: */ +#define g_assert_not_reached() G_STMT_START { (void) 0; } G_STMT_END +#endif + +#define g_assert(expr) G_STMT_START { (void) 0; } G_STMT_END +#else /* !G_DISABLE_ASSERT */ +#define g_assert_not_reached() G_STMT_START { g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } G_STMT_END +#define g_assert(expr) G_STMT_START { \ + if G_LIKELY (expr) ; else \ + g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ + #expr); \ + } G_STMT_END +#endif /* !G_DISABLE_ASSERT */ + +typedef void (*GAssertionFunc) (const char *domain, + const char *file, + int line, + const char *func, + const char *message, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_68 +void g_assertion_set_handler (GAssertionFunc handler, + gpointer user_data); + +GLIB_AVAILABLE_IN_ALL +int g_strcmp0 (const char *str1, + const char *str2); + +/* report performance results */ +GLIB_AVAILABLE_IN_ALL +void g_test_minimized_result (double minimized_quantity, + const char *format, + ...) G_GNUC_PRINTF (2, 3); +GLIB_AVAILABLE_IN_ALL +void g_test_maximized_result (double maximized_quantity, + const char *format, + ...) G_GNUC_PRINTF (2, 3); + +/* initialize testing framework */ +GLIB_AVAILABLE_IN_ALL +void g_test_init (int *argc, + char ***argv, + ...) G_GNUC_NULL_TERMINATED; + +/** + * G_TEST_OPTION_ISOLATE_DIRS: + * + * Creates a unique temporary directory for each unit test and uses + * g_set_user_dirs() to set XDG directories to point into subdirectories of it + * for the duration of the unit test. The directory tree is cleaned up after the + * test finishes successfully. Note that this doesn’t take effect until + * g_test_run() is called, so calls to (for example) g_get_user_home_dir() will + * return the system-wide value when made in a test program’s main() function. + * + * The following functions will return subdirectories of the temporary directory + * when this option is used. The specific subdirectory paths in use are not + * guaranteed to be stable API — always use a getter function to retrieve them. + * + * - g_get_home_dir() + * - g_get_user_cache_dir() + * - g_get_system_config_dirs() + * - g_get_user_config_dir() + * - g_get_system_data_dirs() + * - g_get_user_data_dir() + * - g_get_user_runtime_dir() + * + * The subdirectories may not be created by the test harness; as with normal + * calls to functions like g_get_user_cache_dir(), the caller must be prepared + * to create the directory if it doesn’t exist. + * + * Since: 2.60 + */ +#define G_TEST_OPTION_ISOLATE_DIRS "isolate_dirs" + +/* While we discourage its use, g_assert() is often used in unit tests + * (especially in legacy code). g_assert_*() should really be used instead. + * g_assert() can be disabled at client program compile time, which can render + * tests useless. Highlight that to the user. */ +#ifdef G_DISABLE_ASSERT +#if defined(G_HAVE_ISO_VARARGS) +#undef g_test_init +#define g_test_init(argc, argv, ...) \ + G_STMT_START { \ + g_printerr ("Tests were compiled with G_DISABLE_ASSERT and are likely no-ops. Aborting.\n"); \ + exit (1); \ + } G_STMT_END +#elif defined(G_HAVE_GNUC_VARARGS) +#undef g_test_init +#define g_test_init(argc, argv...) \ + G_STMT_START { \ + g_printerr ("Tests were compiled with G_DISABLE_ASSERT and are likely no-ops. Aborting.\n"); \ + exit (1); \ + } G_STMT_END +#else /* no varargs */ + /* do nothing */ +#endif /* varargs support */ +#endif /* G_DISABLE_ASSERT */ + +/* query testing framework config */ +#define g_test_initialized() (g_test_config_vars->test_initialized) +#define g_test_quick() (g_test_config_vars->test_quick) +#define g_test_slow() (!g_test_config_vars->test_quick) +#define g_test_thorough() (!g_test_config_vars->test_quick) +#define g_test_perf() (g_test_config_vars->test_perf) +#define g_test_verbose() (g_test_config_vars->test_verbose) +#define g_test_quiet() (g_test_config_vars->test_quiet) +#define g_test_undefined() (g_test_config_vars->test_undefined) +GLIB_AVAILABLE_IN_2_38 +gboolean g_test_subprocess (void); + +/* run all tests under toplevel suite (path: /) */ +GLIB_AVAILABLE_IN_ALL +int g_test_run (void); +/* hook up a test functions under test path */ +GLIB_AVAILABLE_IN_ALL +void g_test_add_func (const char *testpath, + GTestFunc test_func); + +GLIB_AVAILABLE_IN_ALL +void g_test_add_data_func (const char *testpath, + gconstpointer test_data, + GTestDataFunc test_func); + +GLIB_AVAILABLE_IN_2_34 +void g_test_add_data_func_full (const char *testpath, + gpointer test_data, + GTestDataFunc test_func, + GDestroyNotify data_free_func); + +/* tell about failure */ +GLIB_AVAILABLE_IN_2_30 +void g_test_fail (void); +GLIB_AVAILABLE_IN_2_38 +void g_test_incomplete (const gchar *msg); +GLIB_AVAILABLE_IN_2_38 +void g_test_skip (const gchar *msg); +GLIB_AVAILABLE_IN_2_38 +gboolean g_test_failed (void); +GLIB_AVAILABLE_IN_2_38 +void g_test_set_nonfatal_assertions (void); + +/** + * g_test_add: + * @testpath: The test path for a new test case. + * @Fixture: The type of a fixture data structure. + * @tdata: Data argument for the test functions. + * @fsetup: The function to set up the fixture data. + * @ftest: The actual test function. + * @fteardown: The function to tear down the fixture data. + * + * Hook up a new test case at @testpath, similar to g_test_add_func(). + * A fixture data structure with setup and teardown functions may be provided, + * similar to g_test_create_case(). + * + * g_test_add() is implemented as a macro, so that the fsetup(), ftest() and + * fteardown() callbacks can expect a @Fixture pointer as their first argument + * in a type safe manner. They otherwise have type #GTestFixtureFunc. + * + * Since: 2.16 + */ +#define g_test_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \ + G_STMT_START { \ + void (*add_vtable) (const char*, \ + gsize, \ + gconstpointer, \ + void (*) (Fixture*, gconstpointer), \ + void (*) (Fixture*, gconstpointer), \ + void (*) (Fixture*, gconstpointer)) = (void (*) (const gchar *, gsize, gconstpointer, void (*) (Fixture*, gconstpointer), void (*) (Fixture*, gconstpointer), void (*) (Fixture*, gconstpointer))) g_test_add_vtable; \ + add_vtable \ + (testpath, sizeof (Fixture), tdata, fsetup, ftest, fteardown); \ + } G_STMT_END + +/* add test messages to the test report */ +GLIB_AVAILABLE_IN_ALL +void g_test_message (const char *format, + ...) G_GNUC_PRINTF (1, 2); +GLIB_AVAILABLE_IN_ALL +void g_test_bug_base (const char *uri_pattern); +GLIB_AVAILABLE_IN_ALL +void g_test_bug (const char *bug_uri_snippet); +GLIB_AVAILABLE_IN_2_62 +void g_test_summary (const char *summary); +/* measure test timings */ +GLIB_AVAILABLE_IN_ALL +void g_test_timer_start (void); +GLIB_AVAILABLE_IN_ALL +double g_test_timer_elapsed (void); /* elapsed seconds */ +GLIB_AVAILABLE_IN_ALL +double g_test_timer_last (void); /* repeat last elapsed() result */ + +/* automatically g_free or g_object_unref upon teardown */ +GLIB_AVAILABLE_IN_ALL +void g_test_queue_free (gpointer gfree_pointer); +GLIB_AVAILABLE_IN_ALL +void g_test_queue_destroy (GDestroyNotify destroy_func, + gpointer destroy_data); +#define g_test_queue_unref(gobject) g_test_queue_destroy (g_object_unref, gobject) + +/** + * GTestTrapFlags: + * @G_TEST_TRAP_SILENCE_STDOUT: Redirect stdout of the test child to + * `/dev/null` so it cannot be observed on the console during test + * runs. The actual output is still captured though to allow later + * tests with g_test_trap_assert_stdout(). + * @G_TEST_TRAP_SILENCE_STDERR: Redirect stderr of the test child to + * `/dev/null` so it cannot be observed on the console during test + * runs. The actual output is still captured though to allow later + * tests with g_test_trap_assert_stderr(). + * @G_TEST_TRAP_INHERIT_STDIN: If this flag is given, stdin of the + * child process is shared with stdin of its parent process. + * It is redirected to `/dev/null` otherwise. + * + * Test traps are guards around forked tests. + * These flags determine what traps to set. + * + * Deprecated: 2.38: #GTestTrapFlags is used only with g_test_trap_fork(), + * which is deprecated. g_test_trap_subprocess() uses + * #GTestSubprocessFlags. + */ +typedef enum { + G_TEST_TRAP_SILENCE_STDOUT = 1 << 7, + G_TEST_TRAP_SILENCE_STDERR = 1 << 8, + G_TEST_TRAP_INHERIT_STDIN = 1 << 9 +} GTestTrapFlags GLIB_DEPRECATED_TYPE_IN_2_38_FOR(GTestSubprocessFlags); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +GLIB_DEPRECATED_IN_2_38_FOR (g_test_trap_subprocess) +gboolean g_test_trap_fork (guint64 usec_timeout, + GTestTrapFlags test_trap_flags); + +G_GNUC_END_IGNORE_DEPRECATIONS + +typedef enum { + G_TEST_SUBPROCESS_INHERIT_STDIN = 1 << 0, + G_TEST_SUBPROCESS_INHERIT_STDOUT = 1 << 1, + G_TEST_SUBPROCESS_INHERIT_STDERR = 1 << 2 +} GTestSubprocessFlags; + +GLIB_AVAILABLE_IN_2_38 +void g_test_trap_subprocess (const char *test_path, + guint64 usec_timeout, + GTestSubprocessFlags test_flags); + +GLIB_AVAILABLE_IN_ALL +gboolean g_test_trap_has_passed (void); +GLIB_AVAILABLE_IN_ALL +gboolean g_test_trap_reached_timeout (void); +#define g_test_trap_assert_passed() g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 0, 0) +#define g_test_trap_assert_failed() g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 1, 0) +#define g_test_trap_assert_stdout(soutpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 2, soutpattern) +#define g_test_trap_assert_stdout_unmatched(soutpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 3, soutpattern) +#define g_test_trap_assert_stderr(serrpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 4, serrpattern) +#define g_test_trap_assert_stderr_unmatched(serrpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 5, serrpattern) + +/* provide seed-able random numbers for tests */ +#define g_test_rand_bit() (0 != (g_test_rand_int() & (1 << 15))) +GLIB_AVAILABLE_IN_ALL +gint32 g_test_rand_int (void); +GLIB_AVAILABLE_IN_ALL +gint32 g_test_rand_int_range (gint32 begin, + gint32 end); +GLIB_AVAILABLE_IN_ALL +double g_test_rand_double (void); +GLIB_AVAILABLE_IN_ALL +double g_test_rand_double_range (double range_start, + double range_end); + +/* + * semi-internal API: non-documented symbols with stable ABI. You + * should use the non-internal helper macros instead. However, for + * compatibility reason, you may use this semi-internal API. + */ +GLIB_AVAILABLE_IN_ALL +GTestCase* g_test_create_case (const char *test_name, + gsize data_size, + gconstpointer test_data, + GTestFixtureFunc data_setup, + GTestFixtureFunc data_test, + GTestFixtureFunc data_teardown); +GLIB_AVAILABLE_IN_ALL +GTestSuite* g_test_create_suite (const char *suite_name); +GLIB_AVAILABLE_IN_ALL +GTestSuite* g_test_get_root (void); +GLIB_AVAILABLE_IN_ALL +void g_test_suite_add (GTestSuite *suite, + GTestCase *test_case); +GLIB_AVAILABLE_IN_ALL +void g_test_suite_add_suite (GTestSuite *suite, + GTestSuite *nestedsuite); +GLIB_AVAILABLE_IN_ALL +int g_test_run_suite (GTestSuite *suite); + +GLIB_AVAILABLE_IN_ALL +void g_test_trap_assertions (const char *domain, + const char *file, + int line, + const char *func, + guint64 assertion_flags, /* 0-pass, 1-fail, 2-outpattern, 4-errpattern */ + const char *pattern); +GLIB_AVAILABLE_IN_ALL +void g_assertion_message (const char *domain, + const char *file, + int line, + const char *func, + const char *message) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +G_NORETURN +void g_assertion_message_expr (const char *domain, + const char *file, + int line, + const char *func, + const char *expr); +GLIB_AVAILABLE_IN_ALL +void g_assertion_message_cmpstr (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + const char *arg1, + const char *cmp, + const char *arg2) G_ANALYZER_NORETURN; + +GLIB_AVAILABLE_IN_2_68 +void g_assertion_message_cmpstrv (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + const char * const *arg1, + const char * const *arg2, + gsize first_wrong_idx) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +void g_assertion_message_cmpnum (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + long double arg1, + const char *cmp, + long double arg2, + char numtype) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +void g_assertion_message_error (const char *domain, + const char *file, + int line, + const char *func, + const char *expr, + const GError *error, + GQuark error_domain, + int error_code) G_ANALYZER_NORETURN; +GLIB_AVAILABLE_IN_ALL +void g_test_add_vtable (const char *testpath, + gsize data_size, + gconstpointer test_data, + GTestFixtureFunc data_setup, + GTestFixtureFunc data_test, + GTestFixtureFunc data_teardown); +typedef struct { + gboolean test_initialized; + gboolean test_quick; /* disable thorough tests */ + gboolean test_perf; /* run performance tests */ + gboolean test_verbose; /* extra info */ + gboolean test_quiet; /* reduce output */ + gboolean test_undefined; /* run tests that are meant to assert */ +} GTestConfig; +GLIB_VAR const GTestConfig * const g_test_config_vars; + +/* internal logging API */ +typedef enum { + G_TEST_RUN_SUCCESS, + G_TEST_RUN_SKIPPED, + G_TEST_RUN_FAILURE, + G_TEST_RUN_INCOMPLETE +} GTestResult; + +typedef enum { + G_TEST_LOG_NONE, + G_TEST_LOG_ERROR, /* s:msg */ + G_TEST_LOG_START_BINARY, /* s:binaryname s:seed */ + G_TEST_LOG_LIST_CASE, /* s:testpath */ + G_TEST_LOG_SKIP_CASE, /* s:testpath */ + G_TEST_LOG_START_CASE, /* s:testpath */ + G_TEST_LOG_STOP_CASE, /* d:status d:nforks d:elapsed */ + G_TEST_LOG_MIN_RESULT, /* s:blurb d:result */ + G_TEST_LOG_MAX_RESULT, /* s:blurb d:result */ + G_TEST_LOG_MESSAGE, /* s:blurb */ + G_TEST_LOG_START_SUITE, + G_TEST_LOG_STOP_SUITE +} GTestLogType; + +typedef struct { + GTestLogType log_type; + guint n_strings; + gchar **strings; /* NULL terminated */ + guint n_nums; + long double *nums; +} GTestLogMsg; +typedef struct { + /*< private >*/ + GString *data; + GSList *msgs; +} GTestLogBuffer; + +GLIB_AVAILABLE_IN_ALL +const char* g_test_log_type_name (GTestLogType log_type); +GLIB_AVAILABLE_IN_ALL +GTestLogBuffer* g_test_log_buffer_new (void); +GLIB_AVAILABLE_IN_ALL +void g_test_log_buffer_free (GTestLogBuffer *tbuffer); +GLIB_AVAILABLE_IN_ALL +void g_test_log_buffer_push (GTestLogBuffer *tbuffer, + guint n_bytes, + const guint8 *bytes); +GLIB_AVAILABLE_IN_ALL +GTestLogMsg* g_test_log_buffer_pop (GTestLogBuffer *tbuffer); +GLIB_AVAILABLE_IN_ALL +void g_test_log_msg_free (GTestLogMsg *tmsg); + +/** + * GTestLogFatalFunc: + * @log_domain: the log domain of the message + * @log_level: the log level of the message (including the fatal and recursion flags) + * @message: the message to process + * @user_data: user data, set in g_test_log_set_fatal_handler() + * + * Specifies the prototype of fatal log handler functions. + * + * Returns: %TRUE if the program should abort, %FALSE otherwise + * + * Since: 2.22 + */ +typedef gboolean (*GTestLogFatalFunc) (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *message, + gpointer user_data); +GLIB_AVAILABLE_IN_ALL +void +g_test_log_set_fatal_handler (GTestLogFatalFunc log_func, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_34 +void g_test_expect_message (const gchar *log_domain, + GLogLevelFlags log_level, + const gchar *pattern); +GLIB_AVAILABLE_IN_2_34 +void g_test_assert_expected_messages_internal (const char *domain, + const char *file, + int line, + const char *func); + +typedef enum +{ + G_TEST_DIST, + G_TEST_BUILT +} GTestFileType; + +GLIB_AVAILABLE_IN_2_38 +gchar * g_test_build_filename (GTestFileType file_type, + const gchar *first_path, + ...) G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_2_38 +const gchar *g_test_get_dir (GTestFileType file_type); +GLIB_AVAILABLE_IN_2_38 +const gchar *g_test_get_filename (GTestFileType file_type, + const gchar *first_path, + ...) G_GNUC_NULL_TERMINATED; + +#define g_test_assert_expected_messages() g_test_assert_expected_messages_internal (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC) + +G_END_DECLS + +#endif /* __G_TEST_UTILS_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_THREADPOOL_H__ +#define __G_THREADPOOL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GThreadPool GThreadPool; + +/* Thread Pools + */ + +struct _GThreadPool +{ + GFunc func; + gpointer user_data; + gboolean exclusive; +}; + +GLIB_AVAILABLE_IN_ALL +GThreadPool * g_thread_pool_new (GFunc func, + gpointer user_data, + gint max_threads, + gboolean exclusive, + GError **error); +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_free (GThreadPool *pool, + gboolean immediate, + gboolean wait_); +GLIB_AVAILABLE_IN_ALL +gboolean g_thread_pool_push (GThreadPool *pool, + gpointer data, + GError **error); +GLIB_AVAILABLE_IN_ALL +guint g_thread_pool_unprocessed (GThreadPool *pool); +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_set_sort_function (GThreadPool *pool, + GCompareDataFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_46 +gboolean g_thread_pool_move_to_front (GThreadPool *pool, + gpointer data); + +GLIB_AVAILABLE_IN_ALL +gboolean g_thread_pool_set_max_threads (GThreadPool *pool, + gint max_threads, + GError **error); +GLIB_AVAILABLE_IN_ALL +gint g_thread_pool_get_max_threads (GThreadPool *pool); +GLIB_AVAILABLE_IN_ALL +guint g_thread_pool_get_num_threads (GThreadPool *pool); + +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_set_max_unused_threads (gint max_threads); +GLIB_AVAILABLE_IN_ALL +gint g_thread_pool_get_max_unused_threads (void); +GLIB_AVAILABLE_IN_ALL +guint g_thread_pool_get_num_unused_threads (void); +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_stop_unused_threads (void); +GLIB_AVAILABLE_IN_ALL +void g_thread_pool_set_max_idle_time (guint interval); +GLIB_AVAILABLE_IN_ALL +guint g_thread_pool_get_max_idle_time (void); + +G_END_DECLS + +#endif /* __G_THREADPOOL_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_TIMER_H__ +#define __G_TIMER_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* Timer + */ + +/* microseconds per second */ +typedef struct _GTimer GTimer; + +#define G_USEC_PER_SEC 1000000 + +GLIB_AVAILABLE_IN_ALL +GTimer* g_timer_new (void); +GLIB_AVAILABLE_IN_ALL +void g_timer_destroy (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +void g_timer_start (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +void g_timer_stop (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +void g_timer_reset (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +void g_timer_continue (GTimer *timer); +GLIB_AVAILABLE_IN_ALL +gdouble g_timer_elapsed (GTimer *timer, + gulong *microseconds); +GLIB_AVAILABLE_IN_2_62 +gboolean g_timer_is_active (GTimer *timer); + +GLIB_AVAILABLE_IN_ALL +void g_usleep (gulong microseconds); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_62 +void g_time_val_add (GTimeVal *time_, + glong microseconds); +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_iso8601) +gboolean g_time_val_from_iso8601 (const gchar *iso_date, + GTimeVal *time_); +GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_format) +gchar* g_time_val_to_iso8601 (GTimeVal *time_) G_GNUC_MALLOC; +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_TIMER_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_TRASH_STACK_H__ +#define __G_TRASH_STACK_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +typedef struct _GTrashStack GTrashStack GLIB_DEPRECATED_TYPE_IN_2_48; +struct _GTrashStack +{ + GTrashStack *next; +} GLIB_DEPRECATED_TYPE_IN_2_48; + +GLIB_DEPRECATED_IN_2_48 +void g_trash_stack_push (GTrashStack **stack_p, + gpointer data_p); +GLIB_DEPRECATED_IN_2_48 +gpointer g_trash_stack_pop (GTrashStack **stack_p); +GLIB_DEPRECATED_IN_2_48 +gpointer g_trash_stack_peek (GTrashStack **stack_p); +GLIB_DEPRECATED_IN_2_48 +guint g_trash_stack_height (GTrashStack **stack_p); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_TRASH_STACK_H_ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_TREE_H__ +#define __G_TREE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +#undef G_TREE_DEBUG + +typedef struct _GTree GTree; + +/** + * GTreeNode: + * + * An opaque type which identifies a specific node in a #GTree. + * + * Since: 2.68 + */ +typedef struct _GTreeNode GTreeNode; + +typedef gboolean (*GTraverseFunc) (gpointer key, + gpointer value, + gpointer data); + +/** + * GTraverseNodeFunc: + * @node: a #GTreeNode + * @data: user data passed to g_tree_foreach_node() + * + * Specifies the type of function passed to g_tree_foreach_node(). It is + * passed each node, together with the @user_data parameter passed to + * g_tree_foreach_node(). If the function returns %TRUE, the traversal is + * stopped. + * + * Returns: %TRUE to stop the traversal + * Since: 2.68 + */ +typedef gboolean (*GTraverseNodeFunc) (GTreeNode *node, + gpointer data); + +/* Balanced binary trees + */ +GLIB_AVAILABLE_IN_ALL +GTree* g_tree_new (GCompareFunc key_compare_func); +GLIB_AVAILABLE_IN_ALL +GTree* g_tree_new_with_data (GCompareDataFunc key_compare_func, + gpointer key_compare_data); +GLIB_AVAILABLE_IN_ALL +GTree* g_tree_new_full (GCompareDataFunc key_compare_func, + gpointer key_compare_data, + GDestroyNotify key_destroy_func, + GDestroyNotify value_destroy_func); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_node_first (GTree *tree); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_node_last (GTree *tree); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_node_previous (GTreeNode *node); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_node_next (GTreeNode *node); +GLIB_AVAILABLE_IN_ALL +GTree* g_tree_ref (GTree *tree); +GLIB_AVAILABLE_IN_ALL +void g_tree_unref (GTree *tree); +GLIB_AVAILABLE_IN_ALL +void g_tree_destroy (GTree *tree); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_insert_node (GTree *tree, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +void g_tree_insert (GTree *tree, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_replace_node (GTree *tree, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +void g_tree_replace (GTree *tree, + gpointer key, + gpointer value); +GLIB_AVAILABLE_IN_ALL +gboolean g_tree_remove (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_tree_steal (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_2_68 +gpointer g_tree_node_key (GTreeNode *node); +GLIB_AVAILABLE_IN_2_68 +gpointer g_tree_node_value (GTreeNode *node); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_lookup_node (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gpointer g_tree_lookup (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gboolean g_tree_lookup_extended (GTree *tree, + gconstpointer lookup_key, + gpointer *orig_key, + gpointer *value); +GLIB_AVAILABLE_IN_ALL +void g_tree_foreach (GTree *tree, + GTraverseFunc func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_68 +void g_tree_foreach_node (GTree *tree, + GTraverseNodeFunc func, + gpointer user_data); + +GLIB_DEPRECATED +void g_tree_traverse (GTree *tree, + GTraverseFunc traverse_func, + GTraverseType traverse_type, + gpointer user_data); + +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_search_node (GTree *tree, + GCompareFunc search_func, + gconstpointer user_data); +GLIB_AVAILABLE_IN_ALL +gpointer g_tree_search (GTree *tree, + GCompareFunc search_func, + gconstpointer user_data); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_lower_bound (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_2_68 +GTreeNode *g_tree_upper_bound (GTree *tree, + gconstpointer key); +GLIB_AVAILABLE_IN_ALL +gint g_tree_height (GTree *tree); +GLIB_AVAILABLE_IN_ALL +gint g_tree_nnodes (GTree *tree); + +#ifdef G_TREE_DEBUG +/*< private >*/ +#ifndef __GTK_DOC_IGNORE__ +void g_tree_dump (GTree *tree); +#endif /* !__GTK_DOC_IGNORE__ */ +#endif /* G_TREE_DEBUG */ + +G_END_DECLS + +#endif /* __G_TREE_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright © 2020 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * . + */ + +#pragma once + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +typedef struct _GUri GUri; + +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_ref (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +void g_uri_unref (GUri *uri); + +/** + * GUriFlags: + * @G_URI_FLAGS_NONE: No flags set. + * @G_URI_FLAGS_PARSE_RELAXED: Parse the URI more relaxedly than the + * [RFC 3986](https://tools.ietf.org/html/rfc3986) grammar specifies, + * fixing up or ignoring common mistakes in URIs coming from external + * sources. This is also needed for some obscure URI schemes where `;` + * separates the host from the path. Don’t use this flag unless you need to. + * @G_URI_FLAGS_HAS_PASSWORD: The userinfo field may contain a password, + * which will be separated from the username by `:`. + * @G_URI_FLAGS_HAS_AUTH_PARAMS: The userinfo may contain additional + * authentication-related parameters, which will be separated from + * the username and/or password by `;`. + * @G_URI_FLAGS_NON_DNS: The host component should not be assumed to be a + * DNS hostname or IP address (for example, for `smb` URIs with NetBIOS + * hostnames). + * @G_URI_FLAGS_ENCODED: When parsing a URI, this indicates that `%`-encoded + * characters in the userinfo, path, query, and fragment fields + * should not be decoded. (And likewise the host field if + * %G_URI_FLAGS_NON_DNS is also set.) When building a URI, it indicates + * that you have already `%`-encoded the components, and so #GUri + * should not do any encoding itself. + * @G_URI_FLAGS_ENCODED_QUERY: Same as %G_URI_FLAGS_ENCODED, for the query + * field only. + * @G_URI_FLAGS_ENCODED_PATH: Same as %G_URI_FLAGS_ENCODED, for the path only. + * @G_URI_FLAGS_ENCODED_FRAGMENT: Same as %G_URI_FLAGS_ENCODED, for the + * fragment only. + * @G_URI_FLAGS_SCHEME_NORMALIZE: A scheme-based normalization will be applied. + * For example, when parsing an HTTP URI changing omitted path to `/` and + * omitted port to `80`; and when building a URI, changing empty path to `/` + * and default port `80`). This only supports a subset of known schemes. (Since: 2.68) + * + * Flags that describe a URI. + * + * When parsing a URI, if you need to choose different flags based on + * the type of URI, you can use g_uri_peek_scheme() on the URI string + * to check the scheme first, and use that to decide what flags to + * parse it with. + * + * Since: 2.66 + */ +GLIB_AVAILABLE_TYPE_IN_2_66 +typedef enum { + G_URI_FLAGS_NONE = 0, + G_URI_FLAGS_PARSE_RELAXED = 1 << 0, + G_URI_FLAGS_HAS_PASSWORD = 1 << 1, + G_URI_FLAGS_HAS_AUTH_PARAMS = 1 << 2, + G_URI_FLAGS_ENCODED = 1 << 3, + G_URI_FLAGS_NON_DNS = 1 << 4, + G_URI_FLAGS_ENCODED_QUERY = 1 << 5, + G_URI_FLAGS_ENCODED_PATH = 1 << 6, + G_URI_FLAGS_ENCODED_FRAGMENT = 1 << 7, + G_URI_FLAGS_SCHEME_NORMALIZE = 1 << 8, +} GUriFlags; + +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_split (const gchar *uri_ref, + GUriFlags flags, + gchar **scheme, + gchar **userinfo, + gchar **host, + gint *port, + gchar **path, + gchar **query, + gchar **fragment, + GError **error); +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_split_with_user (const gchar *uri_ref, + GUriFlags flags, + gchar **scheme, + gchar **user, + gchar **password, + gchar **auth_params, + gchar **host, + gint *port, + gchar **path, + gchar **query, + gchar **fragment, + GError **error); +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_split_network (const gchar *uri_string, + GUriFlags flags, + gchar **scheme, + gchar **host, + gint *port, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_is_valid (const gchar *uri_string, + GUriFlags flags, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +gchar * g_uri_join (GUriFlags flags, + const gchar *scheme, + const gchar *userinfo, + const gchar *host, + gint port, + const gchar *path, + const gchar *query, + const gchar *fragment); +GLIB_AVAILABLE_IN_2_66 +gchar * g_uri_join_with_user (GUriFlags flags, + const gchar *scheme, + const gchar *user, + const gchar *password, + const gchar *auth_params, + const gchar *host, + gint port, + const gchar *path, + const gchar *query, + const gchar *fragment); + +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_parse (const gchar *uri_string, + GUriFlags flags, + GError **error); +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_parse_relative (GUri *base_uri, + const gchar *uri_ref, + GUriFlags flags, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +gchar * g_uri_resolve_relative (const gchar *base_uri_string, + const gchar *uri_ref, + GUriFlags flags, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_build (GUriFlags flags, + const gchar *scheme, + const gchar *userinfo, + const gchar *host, + gint port, + const gchar *path, + const gchar *query, + const gchar *fragment); +GLIB_AVAILABLE_IN_2_66 +GUri * g_uri_build_with_user (GUriFlags flags, + const gchar *scheme, + const gchar *user, + const gchar *password, + const gchar *auth_params, + const gchar *host, + gint port, + const gchar *path, + const gchar *query, + const gchar *fragment); + +/** + * GUriHideFlags: + * @G_URI_HIDE_NONE: No flags set. + * @G_URI_HIDE_USERINFO: Hide the userinfo. + * @G_URI_HIDE_PASSWORD: Hide the password. + * @G_URI_HIDE_AUTH_PARAMS: Hide the auth_params. + * @G_URI_HIDE_QUERY: Hide the query. + * @G_URI_HIDE_FRAGMENT: Hide the fragment. + * + * Flags describing what parts of the URI to hide in + * g_uri_to_string_partial(). Note that %G_URI_HIDE_PASSWORD and + * %G_URI_HIDE_AUTH_PARAMS will only work if the #GUri was parsed with + * the corresponding flags. + * + * Since: 2.66 + */ +GLIB_AVAILABLE_TYPE_IN_2_66 +typedef enum { + G_URI_HIDE_NONE = 0, + G_URI_HIDE_USERINFO = 1 << 0, + G_URI_HIDE_PASSWORD = 1 << 1, + G_URI_HIDE_AUTH_PARAMS = 1 << 2, + G_URI_HIDE_QUERY = 1 << 3, + G_URI_HIDE_FRAGMENT = 1 << 4, +} GUriHideFlags; + +GLIB_AVAILABLE_IN_2_66 +char * g_uri_to_string (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +char * g_uri_to_string_partial (GUri *uri, + GUriHideFlags flags); + +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_scheme (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_userinfo (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_user (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_password (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_auth_params (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_host (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +gint g_uri_get_port (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_path (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_query (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +const gchar *g_uri_get_fragment (GUri *uri); +GLIB_AVAILABLE_IN_2_66 +GUriFlags g_uri_get_flags (GUri *uri); + +/** + * GUriParamsFlags: + * @G_URI_PARAMS_NONE: No flags set. + * @G_URI_PARAMS_CASE_INSENSITIVE: Parameter names are case insensitive. + * @G_URI_PARAMS_WWW_FORM: Replace `+` with space character. Only useful for + * URLs on the web, using the `https` or `http` schemas. + * @G_URI_PARAMS_PARSE_RELAXED: See %G_URI_FLAGS_PARSE_RELAXED. + * + * Flags modifying the way parameters are handled by g_uri_parse_params() and + * #GUriParamsIter. + * + * Since: 2.66 + */ +GLIB_AVAILABLE_TYPE_IN_2_66 +typedef enum { + G_URI_PARAMS_NONE = 0, + G_URI_PARAMS_CASE_INSENSITIVE = 1 << 0, + G_URI_PARAMS_WWW_FORM = 1 << 1, + G_URI_PARAMS_PARSE_RELAXED = 1 << 2, +} GUriParamsFlags; + +GLIB_AVAILABLE_IN_2_66 +GHashTable *g_uri_parse_params (const gchar *params, + gssize length, + const gchar *separators, + GUriParamsFlags flags, + GError **error); + +typedef struct _GUriParamsIter GUriParamsIter; + +struct _GUriParamsIter +{ + /*< private >*/ + gint dummy0; + gpointer dummy1; + gpointer dummy2; + guint8 dummy3[256]; +}; + +GLIB_AVAILABLE_IN_2_66 +void g_uri_params_iter_init (GUriParamsIter *iter, + const gchar *params, + gssize length, + const gchar *separators, + GUriParamsFlags flags); + +GLIB_AVAILABLE_IN_2_66 +gboolean g_uri_params_iter_next (GUriParamsIter *iter, + gchar **attribute, + gchar **value, + GError **error); + +/** + * G_URI_ERROR: + * + * Error domain for URI methods. Errors in this domain will be from + * the #GUriError enumeration. See #GError for information on error + * domains. + * + * Since: 2.66 + */ +#define G_URI_ERROR (g_uri_error_quark ()) GLIB_AVAILABLE_MACRO_IN_2_66 +GLIB_AVAILABLE_IN_2_66 +GQuark g_uri_error_quark (void); + +/** + * GUriError: + * @G_URI_ERROR_FAILED: Generic error if no more specific error is available. + * See the error message for details. + * @G_URI_ERROR_BAD_SCHEME: The scheme of a URI could not be parsed. + * @G_URI_ERROR_BAD_USER: The user/userinfo of a URI could not be parsed. + * @G_URI_ERROR_BAD_PASSWORD: The password of a URI could not be parsed. + * @G_URI_ERROR_BAD_AUTH_PARAMS: The authentication parameters of a URI could not be parsed. + * @G_URI_ERROR_BAD_HOST: The host of a URI could not be parsed. + * @G_URI_ERROR_BAD_PORT: The port of a URI could not be parsed. + * @G_URI_ERROR_BAD_PATH: The path of a URI could not be parsed. + * @G_URI_ERROR_BAD_QUERY: The query of a URI could not be parsed. + * @G_URI_ERROR_BAD_FRAGMENT: The fragment of a URI could not be parsed. + * + * Error codes returned by #GUri methods. + * + * Since: 2.66 + */ +typedef enum { + G_URI_ERROR_FAILED, + G_URI_ERROR_BAD_SCHEME, + G_URI_ERROR_BAD_USER, + G_URI_ERROR_BAD_PASSWORD, + G_URI_ERROR_BAD_AUTH_PARAMS, + G_URI_ERROR_BAD_HOST, + G_URI_ERROR_BAD_PORT, + G_URI_ERROR_BAD_PATH, + G_URI_ERROR_BAD_QUERY, + G_URI_ERROR_BAD_FRAGMENT, +} GUriError; + +/** + * G_URI_RESERVED_CHARS_GENERIC_DELIMITERS: + * + * Generic delimiters characters as defined in + * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `:/?#[]@`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_GENERIC_DELIMITERS ":/?#[]@" + +/** + * G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS: + * + * Subcomponent delimiter characters as defined in + * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `!$&'()*+,;=`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS "!$&'()*+,;=" + +/** + * G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT: + * + * Allowed characters in path elements. Includes `!$&'()*+,;=:@`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":@" + +/** + * G_URI_RESERVED_CHARS_ALLOWED_IN_PATH: + * + * Allowed characters in a path. Includes `!$&'()*+,;=:@/`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_ALLOWED_IN_PATH G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT "/" + +/** + * G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO: + * + * Allowed characters in userinfo as defined in + * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `!$&'()*+,;=:`. + * + * Since: 2.16 + **/ +#define G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":" + +GLIB_AVAILABLE_IN_ALL +char * g_uri_unescape_string (const char *escaped_string, + const char *illegal_characters); +GLIB_AVAILABLE_IN_ALL +char * g_uri_unescape_segment (const char *escaped_string, + const char *escaped_string_end, + const char *illegal_characters); + +GLIB_AVAILABLE_IN_ALL +char * g_uri_parse_scheme (const char *uri); +GLIB_AVAILABLE_IN_2_66 +const char *g_uri_peek_scheme (const char *uri); + +GLIB_AVAILABLE_IN_ALL +char * g_uri_escape_string (const char *unescaped, + const char *reserved_chars_allowed, + gboolean allow_utf8); + +GLIB_AVAILABLE_IN_2_66 +GBytes * g_uri_unescape_bytes (const char *escaped_string, + gssize length, + const char *illegal_characters, + GError **error); + +GLIB_AVAILABLE_IN_2_66 +char * g_uri_escape_bytes (const guint8 *unescaped, + gsize length, + const char *reserved_chars_allowed); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS +/* guuid.h - UUID functions + * + * Copyright (C) 2013-2015, 2017 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of the + * licence, or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 + * USA. + * + * Authors: Marc-André Lureau + */ + +#ifndef __G_UUID_H__ +#define __G_UUID_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_52 +gboolean g_uuid_string_is_valid (const gchar *str); + +GLIB_AVAILABLE_IN_2_52 +gchar * g_uuid_string_random (void); + +G_END_DECLS + +#endif /* __G_UUID_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_VERSION_H__ +#define __G_VERSION_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_VAR const guint glib_major_version; +GLIB_VAR const guint glib_minor_version; +GLIB_VAR const guint glib_micro_version; +GLIB_VAR const guint glib_interface_age; +GLIB_VAR const guint glib_binary_age; + +GLIB_AVAILABLE_IN_ALL +const gchar * glib_check_version (guint required_major, + guint required_minor, + guint required_micro); + +#define GLIB_CHECK_VERSION(major,minor,micro) \ + (GLIB_MAJOR_VERSION > (major) || \ + (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \ + (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \ + GLIB_MICRO_VERSION >= (micro))) + +G_END_DECLS + +#endif /* __G_VERSION_H__ */ + +#ifdef G_PLATFORM_WIN32 +#include +#endif + +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +#ifndef __G_ALLOCATOR_H__ +#define __G_ALLOCATOR_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GAllocator GAllocator; +typedef struct _GMemChunk GMemChunk; + +#define G_ALLOC_ONLY 1 +#define G_ALLOC_AND_FREE 2 +#define G_ALLOCATOR_LIST 1 +#define G_ALLOCATOR_SLIST 2 +#define G_ALLOCATOR_NODE 3 + +#define g_chunk_new(type, chunk) ((type *) g_mem_chunk_alloc (chunk)) +#define g_chunk_new0(type, chunk) ((type *) g_mem_chunk_alloc0 (chunk)) +#define g_chunk_free(mem, mem_chunk) (g_mem_chunk_free (mem_chunk, mem)) +#define g_mem_chunk_create(type, x, y) (g_mem_chunk_new (NULL, sizeof (type), 0, 0)) + + +GLIB_DEPRECATED +GMemChunk * g_mem_chunk_new (const gchar *name, + gint atom_size, + gsize area_size, + gint type); +GLIB_DEPRECATED +void g_mem_chunk_destroy (GMemChunk *mem_chunk); +GLIB_DEPRECATED +gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk); +GLIB_DEPRECATED +gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk); +GLIB_DEPRECATED +void g_mem_chunk_free (GMemChunk *mem_chunk, + gpointer mem); +GLIB_DEPRECATED +void g_mem_chunk_clean (GMemChunk *mem_chunk); +GLIB_DEPRECATED +void g_mem_chunk_reset (GMemChunk *mem_chunk); +GLIB_DEPRECATED +void g_mem_chunk_print (GMemChunk *mem_chunk); +GLIB_DEPRECATED +void g_mem_chunk_info (void); +GLIB_DEPRECATED +void g_blow_chunks (void); + + +GLIB_DEPRECATED +GAllocator * g_allocator_new (const gchar *name, + guint n_preallocs); +GLIB_DEPRECATED +void g_allocator_free (GAllocator *allocator); +GLIB_DEPRECATED +void g_list_push_allocator (GAllocator *allocator); +GLIB_DEPRECATED +void g_list_pop_allocator (void); +GLIB_DEPRECATED +void g_slist_push_allocator (GAllocator *allocator); +GLIB_DEPRECATED +void g_slist_pop_allocator (void); +GLIB_DEPRECATED +void g_node_push_allocator (GAllocator *allocator); +GLIB_DEPRECATED +void g_node_pop_allocator (void); + +G_END_DECLS + +#endif /* __G_ALLOCATOR_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_CACHE_H__ +#define __G_CACHE_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GCache GCache GLIB_DEPRECATED_TYPE_IN_2_26_FOR(GHashTable); + +typedef gpointer (*GCacheNewFunc) (gpointer key) GLIB_DEPRECATED_TYPE_IN_2_26; +typedef gpointer (*GCacheDupFunc) (gpointer value) GLIB_DEPRECATED_TYPE_IN_2_26; +typedef void (*GCacheDestroyFunc) (gpointer value) GLIB_DEPRECATED_TYPE_IN_2_26; + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +/* Caches + */ +GLIB_DEPRECATED +GCache* g_cache_new (GCacheNewFunc value_new_func, + GCacheDestroyFunc value_destroy_func, + GCacheDupFunc key_dup_func, + GCacheDestroyFunc key_destroy_func, + GHashFunc hash_key_func, + GHashFunc hash_value_func, + GEqualFunc key_equal_func); +GLIB_DEPRECATED +void g_cache_destroy (GCache *cache); +GLIB_DEPRECATED +gpointer g_cache_insert (GCache *cache, + gpointer key); +GLIB_DEPRECATED +void g_cache_remove (GCache *cache, + gconstpointer value); +GLIB_DEPRECATED +void g_cache_key_foreach (GCache *cache, + GHFunc func, + gpointer user_data); +GLIB_DEPRECATED +void g_cache_value_foreach (GCache *cache, + GHFunc func, + gpointer user_data); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_CACHE_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_COMPLETION_H__ +#define __G_COMPLETION_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GCompletion GCompletion; + +typedef gchar* (*GCompletionFunc) (gpointer); + +/* GCompletion + */ + +typedef gint (*GCompletionStrncmpFunc) (const gchar *s1, + const gchar *s2, + gsize n); + +struct _GCompletion +{ + GList* items; + GCompletionFunc func; + + gchar* prefix; + GList* cache; + GCompletionStrncmpFunc strncmp_func; +}; + +GLIB_DEPRECATED_IN_2_26 +GCompletion* g_completion_new (GCompletionFunc func); +GLIB_DEPRECATED_IN_2_26 +void g_completion_add_items (GCompletion* cmp, + GList* items); +GLIB_DEPRECATED_IN_2_26 +void g_completion_remove_items (GCompletion* cmp, + GList* items); +GLIB_DEPRECATED_IN_2_26 +void g_completion_clear_items (GCompletion* cmp); +GLIB_DEPRECATED_IN_2_26 +GList* g_completion_complete (GCompletion* cmp, + const gchar* prefix, + gchar** new_prefix); +GLIB_DEPRECATED_IN_2_26 +GList* g_completion_complete_utf8 (GCompletion *cmp, + const gchar* prefix, + gchar** new_prefix); +GLIB_DEPRECATED_IN_2_26 +void g_completion_set_compare (GCompletion *cmp, + GCompletionStrncmpFunc strncmp_func); +GLIB_DEPRECATED_IN_2_26 +void g_completion_free (GCompletion* cmp); + +G_END_DECLS + +#endif /* __G_COMPLETION_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_DEPRECATED_MAIN_H__ +#define __G_DEPRECATED_MAIN_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* ============== Compat main loop stuff ================== */ + +/** + * g_main_new: + * @is_running: set to %TRUE to indicate that the loop is running. This + * is not very important since calling g_main_run() will set this + * to %TRUE anyway. + * + * Creates a new #GMainLoop for th default main context. + * + * Returns: a new #GMainLoop + * + * Deprecated: 2.2: Use g_main_loop_new() instead + */ +#define g_main_new(is_running) g_main_loop_new (NULL, is_running) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_new) + +/** + * g_main_run: + * @loop: a #GMainLoop + * + * Runs a main loop until it stops running. + * + * Deprecated: 2.2: Use g_main_loop_run() instead + */ +#define g_main_run(loop) g_main_loop_run(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_run) + +/** + * g_main_quit: + * @loop: a #GMainLoop + * + * Stops the #GMainLoop. + * If g_main_run() was called to run the #GMainLoop, it will now return. + * + * Deprecated: 2.2: Use g_main_loop_quit() instead + */ +#define g_main_quit(loop) g_main_loop_quit(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_quit) + +/** + * g_main_destroy: + * @loop: a #GMainLoop + * + * Frees the memory allocated for the #GMainLoop. + * + * Deprecated: 2.2: Use g_main_loop_unref() instead + */ +#define g_main_destroy(loop) g_main_loop_unref(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_unref) + +/** + * g_main_is_running: + * @loop: a #GMainLoop + * + * Checks if the main loop is running. + * + * Returns: %TRUE if the main loop is running + * + * Deprecated: 2.2: Use g_main_loop_is_running() instead + */ +#define g_main_is_running(loop) g_main_loop_is_running(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_is_running) + +/** + * g_main_iteration: + * @may_block: set to %TRUE if it should block (i.e. wait) until an event + * source becomes ready. It will return after an event source has been + * processed. If set to %FALSE it will return immediately if no event + * source is ready to be processed. + * + * Runs a single iteration for the default #GMainContext. + * + * Returns: %TRUE if more events are pending. + * + * Deprecated: 2.2: Use g_main_context_iteration() instead. + */ +#define g_main_iteration(may_block) g_main_context_iteration (NULL, may_block) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_iteration) + +/** + * g_main_pending: + * + * Checks if any events are pending for the default #GMainContext + * (i.e. ready to be processed). + * + * Returns: %TRUE if any events are pending. + * + * Deprecated: 2.2: Use g_main_context_pending() instead. + */ +#define g_main_pending() g_main_context_pending (NULL) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_pending) + +/** + * g_main_set_poll_func: + * @func: the function to call to poll all file descriptors + * + * Sets the function to use for the handle polling of file descriptors + * for the default main context. + * + * Deprecated: 2.2: Use g_main_context_set_poll_func() again + */ +#define g_main_set_poll_func(func) g_main_context_set_poll_func (NULL, func) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_set_poll_func) + +G_END_DECLS + +#endif /* __G_DEPRECATED_MAIN_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_REL_H__ +#define __G_REL_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GRelation GRelation; +typedef struct _GTuples GTuples; + +struct _GTuples +{ + guint len; +}; + +/* GRelation + * + * Indexed Relations. Imagine a really simple table in a + * database. Relations are not ordered. This data type is meant for + * maintaining a N-way mapping. + * + * g_relation_new() creates a relation with FIELDS fields + * + * g_relation_destroy() frees all resources + * g_tuples_destroy() frees the result of g_relation_select() + * + * g_relation_index() indexes relation FIELD with the provided + * equality and hash functions. this must be done before any + * calls to insert are made. + * + * g_relation_insert() inserts a new tuple. you are expected to + * provide the right number of fields. + * + * g_relation_delete() deletes all relations with KEY in FIELD + * g_relation_select() returns ... + * g_relation_count() counts ... + */ + +GLIB_DEPRECATED_IN_2_26 +GRelation* g_relation_new (gint fields); +GLIB_DEPRECATED_IN_2_26 +void g_relation_destroy (GRelation *relation); +GLIB_DEPRECATED_IN_2_26 +void g_relation_index (GRelation *relation, + gint field, + GHashFunc hash_func, + GEqualFunc key_equal_func); +GLIB_DEPRECATED_IN_2_26 +void g_relation_insert (GRelation *relation, + ...); +GLIB_DEPRECATED_IN_2_26 +gint g_relation_delete (GRelation *relation, + gconstpointer key, + gint field); +GLIB_DEPRECATED_IN_2_26 +GTuples* g_relation_select (GRelation *relation, + gconstpointer key, + gint field); +GLIB_DEPRECATED_IN_2_26 +gint g_relation_count (GRelation *relation, + gconstpointer key, + gint field); +GLIB_DEPRECATED_IN_2_26 +gboolean g_relation_exists (GRelation *relation, + ...); +GLIB_DEPRECATED_IN_2_26 +void g_relation_print (GRelation *relation); +GLIB_DEPRECATED_IN_2_26 +void g_tuples_destroy (GTuples *tuples); +GLIB_DEPRECATED_IN_2_26 +gpointer g_tuples_index (GTuples *tuples, + gint index_, + gint field); + +G_END_DECLS + +#endif /* __G_REL_H__ */ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __G_DEPRECATED_THREAD_H__ +#define __G_DEPRECATED_THREAD_H__ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +typedef enum +{ + G_THREAD_PRIORITY_LOW, + G_THREAD_PRIORITY_NORMAL, + G_THREAD_PRIORITY_HIGH, + G_THREAD_PRIORITY_URGENT +} GThreadPriority GLIB_DEPRECATED_TYPE_IN_2_32; + +struct _GThread +{ + /*< private >*/ + GThreadFunc func; + gpointer data; + gboolean joinable; + GThreadPriority priority; +}; + +typedef struct _GThreadFunctions GThreadFunctions GLIB_DEPRECATED_TYPE_IN_2_32; +struct _GThreadFunctions +{ + GMutex* (*mutex_new) (void); + void (*mutex_lock) (GMutex *mutex); + gboolean (*mutex_trylock) (GMutex *mutex); + void (*mutex_unlock) (GMutex *mutex); + void (*mutex_free) (GMutex *mutex); + GCond* (*cond_new) (void); + void (*cond_signal) (GCond *cond); + void (*cond_broadcast) (GCond *cond); + void (*cond_wait) (GCond *cond, + GMutex *mutex); + gboolean (*cond_timed_wait) (GCond *cond, + GMutex *mutex, + GTimeVal *end_time); + void (*cond_free) (GCond *cond); + GPrivate* (*private_new) (GDestroyNotify destructor); + gpointer (*private_get) (GPrivate *private_key); + void (*private_set) (GPrivate *private_key, + gpointer data); + void (*thread_create) (GThreadFunc func, + gpointer data, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority, + gpointer thread, + GError **error); + void (*thread_yield) (void); + void (*thread_join) (gpointer thread); + void (*thread_exit) (void); + void (*thread_set_priority)(gpointer thread, + GThreadPriority priority); + void (*thread_self) (gpointer thread); + gboolean (*thread_equal) (gpointer thread1, + gpointer thread2); +} GLIB_DEPRECATED_TYPE_IN_2_32; + +GLIB_VAR GThreadFunctions g_thread_functions_for_glib_use; +GLIB_VAR gboolean g_thread_use_default_impl; + +GLIB_VAR guint64 (*g_thread_gettime) (void); + +GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new) +GThread *g_thread_create (GThreadFunc func, + gpointer data, + gboolean joinable, + GError **error); + +GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new) +GThread *g_thread_create_full (GThreadFunc func, + gpointer data, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority, + GError **error); + +GLIB_DEPRECATED_IN_2_32 +void g_thread_set_priority (GThread *thread, + GThreadPriority priority); + +GLIB_DEPRECATED_IN_2_32 +void g_thread_foreach (GFunc thread_func, + gpointer user_data); + +#ifndef G_OS_WIN32 +#include +#include +#endif + +#define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl GLIB_DEPRECATED_MACRO_IN_2_32 +#define G_STATIC_MUTEX_INIT { NULL } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) +typedef struct +{ + GMutex *mutex; +#ifndef G_OS_WIN32 + /* only for ABI compatibility reasons */ + pthread_mutex_t unused; +#endif +} GStaticMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GMutex); + +#define g_static_mutex_lock(mutex) \ + g_mutex_lock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_lock) +#define g_static_mutex_trylock(mutex) \ + g_mutex_trylock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_trylock) +#define g_static_mutex_unlock(mutex) \ + g_mutex_unlock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_unlock) + +GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_init) +void g_static_mutex_init (GStaticMutex *mutex); +GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_clear) +void g_static_mutex_free (GStaticMutex *mutex); +GLIB_DEPRECATED_IN_2_32_FOR(GMutex) +GMutex *g_static_mutex_get_mutex_impl (GStaticMutex *mutex); + +typedef struct _GStaticRecMutex GStaticRecMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); +struct _GStaticRecMutex +{ + /*< private >*/ + GStaticMutex mutex; + guint depth; + + /* ABI compat only */ + union { +#ifdef G_OS_WIN32 + void *owner; +#else + pthread_t owner; +#endif + gdouble dummy; + } unused; +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); + +#define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT, 0, { 0 } } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rec_mutex_init) +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_init) +void g_static_rec_mutex_init (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_lock) +void g_static_rec_mutex_lock (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_try_lock) +gboolean g_static_rec_mutex_trylock (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_unlock) +void g_static_rec_mutex_unlock (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32 +void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, + guint depth); + +GLIB_DEPRECATED_IN_2_32 +guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_free) +void g_static_rec_mutex_free (GStaticRecMutex *mutex); + +typedef struct _GStaticRWLock GStaticRWLock GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); +struct _GStaticRWLock +{ + /*< private >*/ + GStaticMutex mutex; + GCond *read_cond; + GCond *write_cond; + guint read_counter; + gboolean have_writer; + guint want_to_read; + guint want_to_write; +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); + +#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rw_lock_init) + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_init) +void g_static_rw_lock_init (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_lock) +void g_static_rw_lock_reader_lock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_trylock) +gboolean g_static_rw_lock_reader_trylock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_unlock) +void g_static_rw_lock_reader_unlock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_lock) +void g_static_rw_lock_writer_lock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_trylock) +gboolean g_static_rw_lock_writer_trylock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_unlock) +void g_static_rw_lock_writer_unlock (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_free) +void g_static_rw_lock_free (GStaticRWLock *lock); + +GLIB_DEPRECATED_IN_2_32 +GPrivate * g_private_new (GDestroyNotify notify); + +typedef struct _GStaticPrivate GStaticPrivate GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); +struct _GStaticPrivate +{ + /*< private >*/ + guint index; +} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); + +#define G_STATIC_PRIVATE_INIT { 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(G_PRIVATE_INIT) +GLIB_DEPRECATED_IN_2_32 +void g_static_private_init (GStaticPrivate *private_key); + +GLIB_DEPRECATED_IN_2_32_FOR(g_private_get) +gpointer g_static_private_get (GStaticPrivate *private_key); + +GLIB_DEPRECATED_IN_2_32_FOR(g_private_set) +void g_static_private_set (GStaticPrivate *private_key, + gpointer data, + GDestroyNotify notify); + +GLIB_DEPRECATED_IN_2_32 +void g_static_private_free (GStaticPrivate *private_key); + +GLIB_DEPRECATED_IN_2_32 +gboolean g_once_init_enter_impl (volatile gsize *location); + +GLIB_DEPRECATED_IN_2_32 +void g_thread_init (gpointer vtable); +GLIB_DEPRECATED_IN_2_32 +void g_thread_init_with_errorcheck_mutexes (gpointer vtable); + +GLIB_DEPRECATED_IN_2_32 +gboolean g_thread_get_initialized (void); + +GLIB_VAR gboolean g_threads_got_initialized; + +#define g_thread_supported() (1) GLIB_DEPRECATED_MACRO_IN_2_32 + +GLIB_DEPRECATED_IN_2_32 +GMutex * g_mutex_new (void); +GLIB_DEPRECATED_IN_2_32 +void g_mutex_free (GMutex *mutex); +GLIB_DEPRECATED_IN_2_32 +GCond * g_cond_new (void); +GLIB_DEPRECATED_IN_2_32 +void g_cond_free (GCond *cond); +GLIB_DEPRECATED_IN_2_32 +gboolean g_cond_timed_wait (GCond *cond, + GMutex *mutex, + GTimeVal *timeval); + +G_GNUC_END_IGNORE_DEPRECATIONS + +G_END_DECLS + +#endif /* __G_DEPRECATED_THREAD_H__ */ + +/* + * Copyright © 2015 Canonical Limited + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) +#error "Only can be included directly." +#endif + +static inline void +g_autoptr_cleanup_generic_gfree (void *p) +{ + void **pp = (void**)p; + g_free (*pp); +} + +static inline void +g_autoptr_cleanup_gstring_free (GString *string) +{ + if (string) + g_string_free (string, TRUE); +} + +/* Ignore deprecations in case we refer to a type which was added in a more + * recent GLib version than the user’s #GLIB_VERSION_MAX_ALLOWED definition. */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +/* If adding a cleanup here, please also add a test case to + * glib/tests/autoptr.c + */ +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAsyncQueue, g_async_queue_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBookmarkFile, g_bookmark_file_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBytes, g_bytes_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GChecksum, g_checksum_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDateTime, g_date_time_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDate, g_date_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDir, g_dir_close) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GError, g_error_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHashTable, g_hash_table_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHmac, g_hmac_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GIOChannel, g_io_channel_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GKeyFile, g_key_file_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GList, g_list_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GArray, g_array_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPtrArray, g_ptr_array_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GByteArray, g_byte_array_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainContext, g_main_context_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainContextPusher, g_main_context_pusher_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainLoop, g_main_loop_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSource, g_source_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMappedFile, g_mapped_file_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMarkupParseContext, g_markup_parse_context_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNode, g_node_destroy) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionContext, g_option_context_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionGroup, g_option_group_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPatternSpec, g_pattern_spec_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GQueue, g_queue_free) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRand, g_rand_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRegex, g_regex_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMatchInfo, g_match_info_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GScanner, g_scanner_destroy) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSequence, g_sequence_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSList, g_slist_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GString, g_autoptr_cleanup_gstring_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GStringChunk, g_string_chunk_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GStrvBuilder, g_strv_builder_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GThread, g_thread_unref) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GMutex, g_mutex_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMutexLocker, g_mutex_locker_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRecMutexLocker, g_rec_mutex_locker_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRWLockWriterLocker, g_rw_lock_writer_locker_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRWLockReaderLocker, g_rw_lock_reader_locker_free) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GCond, g_cond_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTimer, g_timer_destroy) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTimeZone, g_time_zone_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTree, g_tree_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariant, g_variant_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantBuilder, g_variant_builder_unref) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantBuilder, g_variant_builder_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantIter, g_variant_iter_free) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantDict, g_variant_dict_unref) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantDict, g_variant_dict_clear) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantType, g_variant_type_free) +G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRefString, g_ref_string_release) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUri, g_uri_unref) + +G_GNUC_END_IGNORE_DEPRECATIONS + +#undef __GLIB_H_INSIDE__ + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_2_68 +void glib_init (void); + +GLIB_AVAILABLE_IN_2_68 +void glib_shutdown (void); + +GLIB_AVAILABLE_IN_2_68 +void glib_deinit (void); + +GLIB_AVAILABLE_IN_2_68 +void glib_prepare_to_fork (void); + +GLIB_AVAILABLE_IN_2_68 +void glib_recover_from_fork_in_parent (void); + +GLIB_AVAILABLE_IN_2_68 +void glib_recover_from_fork_in_child (void); + +G_END_DECLS + +#endif /* __G_LIB_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_OBJECT_H__ +#define __G_OBJECT_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_TYPE_H__ +#define __G_TYPE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* Basic Type Macros + */ +/** + * G_TYPE_FUNDAMENTAL: + * @type: A #GType value. + * + * The fundamental type which is the ancestor of @type. + * Fundamental types are types that serve as ultimate bases for the derived types, + * thus they are the roots of distinct inheritance hierarchies. + */ +#define G_TYPE_FUNDAMENTAL(type) (g_type_fundamental (type)) +/** + * G_TYPE_FUNDAMENTAL_MAX: + * + * An integer constant that represents the number of identifiers reserved + * for types that are assigned at compile-time. + */ +#define G_TYPE_FUNDAMENTAL_MAX (255 << G_TYPE_FUNDAMENTAL_SHIFT) + +/* Constant fundamental types, + */ +/** + * G_TYPE_INVALID: + * + * An invalid #GType used as error return value in some functions which return + * a #GType. + */ +#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0) +/** + * G_TYPE_NONE: + * + * A fundamental type which is used as a replacement for the C + * void return type. + */ +#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1) +/** + * G_TYPE_INTERFACE: + * + * The fundamental type from which all interfaces are derived. + */ +#define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2) +/** + * G_TYPE_CHAR: + * + * The fundamental type corresponding to #gchar. + * The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed integer. + * This may or may not be the same type a the C type "gchar". + */ +#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3) +/** + * G_TYPE_UCHAR: + * + * The fundamental type corresponding to #guchar. + */ +#define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4) +/** + * G_TYPE_BOOLEAN: + * + * The fundamental type corresponding to #gboolean. + */ +#define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5) +/** + * G_TYPE_INT: + * + * The fundamental type corresponding to #gint. + */ +#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6) +/** + * G_TYPE_UINT: + * + * The fundamental type corresponding to #guint. + */ +#define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7) +/** + * G_TYPE_LONG: + * + * The fundamental type corresponding to #glong. + */ +#define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8) +/** + * G_TYPE_ULONG: + * + * The fundamental type corresponding to #gulong. + */ +#define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9) +/** + * G_TYPE_INT64: + * + * The fundamental type corresponding to #gint64. + */ +#define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10) +/** + * G_TYPE_UINT64: + * + * The fundamental type corresponding to #guint64. + */ +#define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11) +/** + * G_TYPE_ENUM: + * + * The fundamental type from which all enumeration types are derived. + */ +#define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12) +/** + * G_TYPE_FLAGS: + * + * The fundamental type from which all flags types are derived. + */ +#define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13) +/** + * G_TYPE_FLOAT: + * + * The fundamental type corresponding to #gfloat. + */ +#define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14) +/** + * G_TYPE_DOUBLE: + * + * The fundamental type corresponding to #gdouble. + */ +#define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15) +/** + * G_TYPE_STRING: + * + * The fundamental type corresponding to nul-terminated C strings. + */ +#define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16) +/** + * G_TYPE_POINTER: + * + * The fundamental type corresponding to #gpointer. + */ +#define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17) +/** + * G_TYPE_BOXED: + * + * The fundamental type from which all boxed types are derived. + */ +#define G_TYPE_BOXED G_TYPE_MAKE_FUNDAMENTAL (18) +/** + * G_TYPE_PARAM: + * + * The fundamental type from which all #GParamSpec types are derived. + */ +#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19) +/** + * G_TYPE_OBJECT: + * + * The fundamental type for #GObject. + */ +#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20) +/** + * G_TYPE_VARIANT: + * + * The fundamental type corresponding to #GVariant. + * + * All floating #GVariant instances passed through the #GType system are + * consumed. + * + * Note that callbacks in closures, and signal handlers + * for signals of return type %G_TYPE_VARIANT, must never return floating + * variants. + * + * Note: GLib 2.24 did include a boxed type with this name. It was replaced + * with this fundamental type in 2.26. + * + * Since: 2.26 + */ +#define G_TYPE_VARIANT G_TYPE_MAKE_FUNDAMENTAL (21) + + +/* Reserved fundamental type numbers to create new fundamental + * type IDs with G_TYPE_MAKE_FUNDAMENTAL(). + * + * Open an issue on https://gitlab.gnome.org/GNOME/glib/issues/new for + * reservations. + */ +/** + * G_TYPE_FUNDAMENTAL_SHIFT: + * + * Shift value used in converting numbers to type IDs. + */ +#define G_TYPE_FUNDAMENTAL_SHIFT (2) +/** + * G_TYPE_MAKE_FUNDAMENTAL: + * @x: the fundamental type number. + * + * Get the type ID for the fundamental type number @x. + * Use g_type_fundamental_next() instead of this macro to create new fundamental + * types. + * + * Returns: the GType + */ +#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT)) +/** + * G_TYPE_RESERVED_GLIB_FIRST: + * + * First fundamental type number to create a new fundamental type id with + * G_TYPE_MAKE_FUNDAMENTAL() reserved for GLib. + */ +#define G_TYPE_RESERVED_GLIB_FIRST (22) +/** + * G_TYPE_RESERVED_GLIB_LAST: + * + * Last fundamental type number reserved for GLib. + */ +#define G_TYPE_RESERVED_GLIB_LAST (31) +/** + * G_TYPE_RESERVED_BSE_FIRST: + * + * First fundamental type number to create a new fundamental type id with + * G_TYPE_MAKE_FUNDAMENTAL() reserved for BSE. + */ +#define G_TYPE_RESERVED_BSE_FIRST (32) +/** + * G_TYPE_RESERVED_BSE_LAST: + * + * Last fundamental type number reserved for BSE. + */ +#define G_TYPE_RESERVED_BSE_LAST (48) +/** + * G_TYPE_RESERVED_USER_FIRST: + * + * First available fundamental type number to create new fundamental + * type id with G_TYPE_MAKE_FUNDAMENTAL(). + */ +#define G_TYPE_RESERVED_USER_FIRST (49) + + +/* Type Checking Macros + */ +/** + * G_TYPE_IS_FUNDAMENTAL: + * @type: A #GType value + * + * Checks if @type is a fundamental type. + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_FUNDAMENTAL(type) ((type) <= G_TYPE_FUNDAMENTAL_MAX) +/** + * G_TYPE_IS_DERIVED: + * @type: A #GType value + * + * Checks if @type is derived (or in object-oriented terminology: + * inherited) from another type (this holds true for all non-fundamental + * types). + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_DERIVED(type) ((type) > G_TYPE_FUNDAMENTAL_MAX) +/** + * G_TYPE_IS_INTERFACE: + * @type: A #GType value + * + * Checks if @type is an interface type. + * An interface type provides a pure API, the implementation + * of which is provided by another type (which is then said to conform + * to the interface). GLib interfaces are somewhat analogous to Java + * interfaces and C++ classes containing only pure virtual functions, + * with the difference that GType interfaces are not derivable (but see + * g_type_interface_add_prerequisite() for an alternative). + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_INTERFACE(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE) +/** + * G_TYPE_IS_CLASSED: + * @type: A #GType value + * + * Checks if @type is a classed type. + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_CLASSED(type) (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED)) +/** + * G_TYPE_IS_INSTANTIATABLE: + * @type: A #GType value + * + * Checks if @type can be instantiated. Instantiation is the + * process of creating an instance (object) of this type. + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_INSTANTIATABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE)) +/** + * G_TYPE_IS_DERIVABLE: + * @type: A #GType value + * + * Checks if @type is a derivable type. A derivable type can + * be used as the base class of a flat (single-level) class hierarchy. + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DERIVABLE)) +/** + * G_TYPE_IS_DEEP_DERIVABLE: + * @type: A #GType value + * + * Checks if @type is a deep derivable type. A deep derivable type + * can be used as the base class of a deep (multi-level) class hierarchy. + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_DEEP_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE)) +/** + * G_TYPE_IS_ABSTRACT: + * @type: A #GType value + * + * Checks if @type is an abstract type. An abstract type cannot be + * instantiated and is normally used as an abstract base class for + * derived classes. + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)) +/** + * G_TYPE_IS_VALUE_ABSTRACT: + * @type: A #GType value + * + * Checks if @type is an abstract value type. An abstract value type introduces + * a value table, but can't be used for g_value_init() and is normally used as + * an abstract base type for derived value types. + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_VALUE_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT)) +/** + * G_TYPE_IS_VALUE_TYPE: + * @type: A #GType value + * + * Checks if @type is a value type and can be used with g_value_init(). + * + * Returns: %TRUE on success + */ +#define G_TYPE_IS_VALUE_TYPE(type) (g_type_check_is_value_type (type)) +/** + * G_TYPE_HAS_VALUE_TABLE: + * @type: A #GType value + * + * Checks if @type has a #GTypeValueTable. + * + * Returns: %TRUE on success + */ +#define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL) + + +/* Typedefs + */ +/** + * GType: + * + * A numerical value which represents the unique identifier of a registered + * type. + */ +#if GLIB_SIZEOF_SIZE_T != GLIB_SIZEOF_LONG || !defined __cplusplus +typedef gsize GType; +#else /* for historic reasons, C++ links against gulong GTypes */ +typedef gulong GType; +#endif +typedef struct _GValue GValue; +typedef union _GTypeCValue GTypeCValue; +typedef struct _GTypePlugin GTypePlugin; +typedef struct _GTypeClass GTypeClass; +typedef struct _GTypeInterface GTypeInterface; +typedef struct _GTypeInstance GTypeInstance; +typedef struct _GTypeInfo GTypeInfo; +typedef struct _GTypeFundamentalInfo GTypeFundamentalInfo; +typedef struct _GInterfaceInfo GInterfaceInfo; +typedef struct _GTypeValueTable GTypeValueTable; +typedef struct _GTypeQuery GTypeQuery; + + +/* Basic Type Structures + */ +/** + * GTypeClass: + * + * An opaque structure used as the base of all classes. + */ +struct _GTypeClass +{ + /*< private >*/ + GType g_type; +}; +/** + * GTypeInstance: + * + * An opaque structure used as the base of all type instances. + */ +struct _GTypeInstance +{ + /*< private >*/ + GTypeClass *g_class; +}; +/** + * GTypeInterface: + * + * An opaque structure used as the base of all interface types. + */ +struct _GTypeInterface +{ + /*< private >*/ + GType g_type; /* iface type */ + GType g_instance_type; +}; +/** + * GTypeQuery: + * @type: the #GType value of the type + * @type_name: the name of the type + * @class_size: the size of the class structure + * @instance_size: the size of the instance structure + * + * A structure holding information for a specific type. + * It is filled in by the g_type_query() function. + */ +struct _GTypeQuery +{ + GType type; + const gchar *type_name; + guint class_size; + guint instance_size; +}; + + +/* Casts, checks and accessors for structured types + * usage of these macros is reserved to type implementations only + */ +/*< protected >*/ +/** + * G_TYPE_CHECK_INSTANCE: + * @instance: Location of a #GTypeInstance structure + * + * Checks if @instance is a valid #GTypeInstance structure, + * otherwise issues a warning and returns %FALSE. %NULL is not a valid + * #GTypeInstance. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE on success + */ +#define G_TYPE_CHECK_INSTANCE(instance) (_G_TYPE_CHI ((GTypeInstance*) (instance))) +/** + * G_TYPE_CHECK_INSTANCE_CAST: + * @instance: (nullable): Location of a #GTypeInstance structure + * @g_type: The type to be returned + * @c_type: The corresponding C type of @g_type + * + * Checks that @instance is an instance of the type identified by @g_type + * and issues a warning if this is not the case. Returns @instance casted + * to a pointer to @c_type. + * + * No warning will be issued if @instance is %NULL, and %NULL will be returned. + * + * This macro should only be used in type implementations. + */ +#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) +/** + * G_TYPE_CHECK_INSTANCE_TYPE: + * @instance: (nullable): Location of a #GTypeInstance structure. + * @g_type: The type to be checked + * + * Checks if @instance is an instance of the type identified by @g_type. If + * @instance is %NULL, %FALSE will be returned. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE on success + */ +#define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type))) +/** + * G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE: + * @instance: (nullable): Location of a #GTypeInstance structure. + * @g_type: The fundamental type to be checked + * + * Checks if @instance is an instance of the fundamental type identified by @g_type. + * If @instance is %NULL, %FALSE will be returned. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE on success + */ +#define G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE(instance, g_type) (_G_TYPE_CIFT ((instance), (g_type))) +/** + * G_TYPE_INSTANCE_GET_CLASS: + * @instance: Location of the #GTypeInstance structure + * @g_type: The #GType of the class to be returned + * @c_type: The C type of the class structure + * + * Get the class structure of a given @instance, casted + * to a specified ancestor type @g_type of the instance. + * + * Note that while calling a GInstanceInitFunc(), the class pointer + * gets modified, so it might not always return the expected pointer. + * + * This macro should only be used in type implementations. + * + * Returns: a pointer to the class structure + */ +#define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type) (_G_TYPE_IGC ((instance), (g_type), c_type)) +/** + * G_TYPE_INSTANCE_GET_INTERFACE: + * @instance: Location of the #GTypeInstance structure + * @g_type: The #GType of the interface to be returned + * @c_type: The C type of the interface structure + * + * Get the interface structure for interface @g_type of a given @instance. + * + * This macro should only be used in type implementations. + * + * Returns: a pointer to the interface structure + */ +#define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type)) +/** + * G_TYPE_CHECK_CLASS_CAST: + * @g_class: Location of a #GTypeClass structure + * @g_type: The type to be returned + * @c_type: The corresponding C type of class structure of @g_type + * + * Checks that @g_class is a class structure of the type identified by @g_type + * and issues a warning if this is not the case. Returns @g_class casted + * to a pointer to @c_type. %NULL is not a valid class structure. + * + * This macro should only be used in type implementations. + */ +#define G_TYPE_CHECK_CLASS_CAST(g_class, g_type, c_type) (_G_TYPE_CCC ((g_class), (g_type), c_type)) +/** + * G_TYPE_CHECK_CLASS_TYPE: + * @g_class: (nullable): Location of a #GTypeClass structure + * @g_type: The type to be checked + * + * Checks if @g_class is a class structure of the type identified by + * @g_type. If @g_class is %NULL, %FALSE will be returned. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE on success + */ +#define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type) (_G_TYPE_CCT ((g_class), (g_type))) +/** + * G_TYPE_CHECK_VALUE: + * @value: a #GValue + * + * Checks if @value has been initialized to hold values + * of a value type. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE on success + */ +#define G_TYPE_CHECK_VALUE(value) (_G_TYPE_CHV ((value))) +/** + * G_TYPE_CHECK_VALUE_TYPE: + * @value: a #GValue + * @g_type: The type to be checked + * + * Checks if @value has been initialized to hold values + * of type @g_type. + * + * This macro should only be used in type implementations. + * + * Returns: %TRUE on success + */ +#define G_TYPE_CHECK_VALUE_TYPE(value, g_type) (_G_TYPE_CVH ((value), (g_type))) +/** + * G_TYPE_FROM_INSTANCE: + * @instance: Location of a valid #GTypeInstance structure + * + * Get the type identifier from a given @instance structure. + * + * This macro should only be used in type implementations. + * + * Returns: the #GType + */ +#define G_TYPE_FROM_INSTANCE(instance) (G_TYPE_FROM_CLASS (((GTypeInstance*) (instance))->g_class)) +/** + * G_TYPE_FROM_CLASS: + * @g_class: Location of a valid #GTypeClass structure + * + * Get the type identifier from a given @class structure. + * + * This macro should only be used in type implementations. + * + * Returns: the #GType + */ +#define G_TYPE_FROM_CLASS(g_class) (((GTypeClass*) (g_class))->g_type) +/** + * G_TYPE_FROM_INTERFACE: + * @g_iface: Location of a valid #GTypeInterface structure + * + * Get the type identifier from a given @interface structure. + * + * This macro should only be used in type implementations. + * + * Returns: the #GType + */ +#define G_TYPE_FROM_INTERFACE(g_iface) (((GTypeInterface*) (g_iface))->g_type) + +/** + * G_TYPE_INSTANCE_GET_PRIVATE: + * @instance: the instance of a type deriving from @private_type + * @g_type: the type identifying which private data to retrieve + * @c_type: The C type for the private structure + * + * Gets the private structure for a particular type. + * The private structure must have been registered in the + * class_init function with g_type_class_add_private(). + * + * This macro should only be used in type implementations. + * + * Since: 2.4 + * Deprecated: 2.58: Use %G_ADD_PRIVATE and the generated + * `your_type_get_instance_private()` function instead + * Returns: (not nullable): a pointer to the private data structure + */ +#define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type) ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type))) GLIB_DEPRECATED_MACRO_IN_2_58_FOR(G_ADD_PRIVATE) + +/** + * G_TYPE_CLASS_GET_PRIVATE: + * @klass: the class of a type deriving from @private_type + * @g_type: the type identifying which private data to retrieve + * @c_type: The C type for the private structure + * + * Gets the private class structure for a particular type. + * The private structure must have been registered in the + * get_type() function with g_type_add_class_private(). + * + * This macro should only be used in type implementations. + * + * Since: 2.24 + * Returns: (not nullable): a pointer to the private data structure + */ +#define G_TYPE_CLASS_GET_PRIVATE(klass, g_type, c_type) ((c_type*) g_type_class_get_private ((GTypeClass*) (klass), (g_type))) + +/** + * GTypeDebugFlags: + * @G_TYPE_DEBUG_NONE: Print no messages + * @G_TYPE_DEBUG_OBJECTS: Print messages about object bookkeeping + * @G_TYPE_DEBUG_SIGNALS: Print messages about signal emissions + * @G_TYPE_DEBUG_MASK: Mask covering all debug flags + * @G_TYPE_DEBUG_INSTANCE_COUNT: Keep a count of instances of each type + * + * These flags used to be passed to g_type_init_with_debug_flags() which + * is now deprecated. + * + * If you need to enable debugging features, use the GOBJECT_DEBUG + * environment variable. + * + * Deprecated: 2.36: g_type_init() is now done automatically + */ +typedef enum /*< skip >*/ +{ + G_TYPE_DEBUG_NONE = 0, + G_TYPE_DEBUG_OBJECTS = 1 << 0, + G_TYPE_DEBUG_SIGNALS = 1 << 1, + G_TYPE_DEBUG_INSTANCE_COUNT = 1 << 2, + G_TYPE_DEBUG_MASK = 0x07 +} GTypeDebugFlags GLIB_DEPRECATED_TYPE_IN_2_36; + + +/* --- prototypes --- */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS +GLIB_DEPRECATED_IN_2_36 +void g_type_init (void); +GLIB_DEPRECATED_IN_2_36 +void g_type_init_with_debug_flags (GTypeDebugFlags debug_flags); +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +const gchar * g_type_name (GType type); +GLIB_AVAILABLE_IN_ALL +GQuark g_type_qname (GType type); +GLIB_AVAILABLE_IN_ALL +GType g_type_from_name (const gchar *name); +GLIB_AVAILABLE_IN_ALL +GType g_type_parent (GType type); +GLIB_AVAILABLE_IN_ALL +guint g_type_depth (GType type); +GLIB_AVAILABLE_IN_ALL +GType g_type_next_base (GType leaf_type, + GType root_type); +GLIB_AVAILABLE_IN_ALL +gboolean g_type_is_a (GType type, + GType is_a_type); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_class_ref (GType type); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_class_peek (GType type); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_class_peek_static (GType type); +GLIB_AVAILABLE_IN_ALL +void g_type_class_unref (gpointer g_class); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_class_peek_parent (gpointer g_class); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_interface_peek (gpointer instance_class, + GType iface_type); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_interface_peek_parent (gpointer g_iface); + +GLIB_AVAILABLE_IN_ALL +gpointer g_type_default_interface_ref (GType g_type); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_default_interface_peek (GType g_type); +GLIB_AVAILABLE_IN_ALL +void g_type_default_interface_unref (gpointer g_iface); + +/* g_free() the returned arrays */ +GLIB_AVAILABLE_IN_ALL +GType* g_type_children (GType type, + guint *n_children); +GLIB_AVAILABLE_IN_ALL +GType* g_type_interfaces (GType type, + guint *n_interfaces); + +/* per-type _static_ data */ +GLIB_AVAILABLE_IN_ALL +void g_type_set_qdata (GType type, + GQuark quark, + gpointer data); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_get_qdata (GType type, + GQuark quark); +GLIB_AVAILABLE_IN_ALL +void g_type_query (GType type, + GTypeQuery *query); + +GLIB_AVAILABLE_IN_2_44 +int g_type_get_instance_count (GType type); + +/* --- type registration --- */ +/** + * GBaseInitFunc: + * @g_class: (type GObject.TypeClass): The #GTypeClass structure to initialize + * + * A callback function used by the type system to do base initialization + * of the class structures of derived types. It is called as part of the + * initialization process of all derived classes and should reallocate + * or reset all dynamic class members copied over from the parent class. + * For example, class members (such as strings) that are not sufficiently + * handled by a plain memory copy of the parent class into the derived class + * have to be altered. See GClassInitFunc() for a discussion of the class + * initialization process. + */ +typedef void (*GBaseInitFunc) (gpointer g_class); +/** + * GBaseFinalizeFunc: + * @g_class: (type GObject.TypeClass): The #GTypeClass structure to finalize + * + * A callback function used by the type system to finalize those portions + * of a derived types class structure that were setup from the corresponding + * GBaseInitFunc() function. Class finalization basically works the inverse + * way in which class initialization is performed. + * See GClassInitFunc() for a discussion of the class initialization process. + */ +typedef void (*GBaseFinalizeFunc) (gpointer g_class); +/** + * GClassInitFunc: + * @g_class: (type GObject.TypeClass): The #GTypeClass structure to initialize. + * @class_data: The @class_data member supplied via the #GTypeInfo structure. + * + * A callback function used by the type system to initialize the class + * of a specific type. This function should initialize all static class + * members. + * + * The initialization process of a class involves: + * + * - Copying common members from the parent class over to the + * derived class structure. + * - Zero initialization of the remaining members not copied + * over from the parent class. + * - Invocation of the GBaseInitFunc() initializers of all parent + * types and the class' type. + * - Invocation of the class' GClassInitFunc() initializer. + * + * Since derived classes are partially initialized through a memory copy + * of the parent class, the general rule is that GBaseInitFunc() and + * GBaseFinalizeFunc() should take care of necessary reinitialization + * and release of those class members that were introduced by the type + * that specified these GBaseInitFunc()/GBaseFinalizeFunc(). + * GClassInitFunc() should only care about initializing static + * class members, while dynamic class members (such as allocated strings + * or reference counted resources) are better handled by a GBaseInitFunc() + * for this type, so proper initialization of the dynamic class members + * is performed for class initialization of derived types as well. + * + * An example may help to correspond the intend of the different class + * initializers: + * + * |[ + * typedef struct { + * GObjectClass parent_class; + * gint static_integer; + * gchar *dynamic_string; + * } TypeAClass; + * static void + * type_a_base_class_init (TypeAClass *class) + * { + * class->dynamic_string = g_strdup ("some string"); + * } + * static void + * type_a_base_class_finalize (TypeAClass *class) + * { + * g_free (class->dynamic_string); + * } + * static void + * type_a_class_init (TypeAClass *class) + * { + * class->static_integer = 42; + * } + * + * typedef struct { + * TypeAClass parent_class; + * gfloat static_float; + * GString *dynamic_gstring; + * } TypeBClass; + * static void + * type_b_base_class_init (TypeBClass *class) + * { + * class->dynamic_gstring = g_string_new ("some other string"); + * } + * static void + * type_b_base_class_finalize (TypeBClass *class) + * { + * g_string_free (class->dynamic_gstring); + * } + * static void + * type_b_class_init (TypeBClass *class) + * { + * class->static_float = 3.14159265358979323846; + * } + * ]| + * Initialization of TypeBClass will first cause initialization of + * TypeAClass (derived classes reference their parent classes, see + * g_type_class_ref() on this). + * + * Initialization of TypeAClass roughly involves zero-initializing its fields, + * then calling its GBaseInitFunc() type_a_base_class_init() to allocate + * its dynamic members (dynamic_string), and finally calling its GClassInitFunc() + * type_a_class_init() to initialize its static members (static_integer). + * The first step in the initialization process of TypeBClass is then + * a plain memory copy of the contents of TypeAClass into TypeBClass and + * zero-initialization of the remaining fields in TypeBClass. + * The dynamic members of TypeAClass within TypeBClass now need + * reinitialization which is performed by calling type_a_base_class_init() + * with an argument of TypeBClass. + * + * After that, the GBaseInitFunc() of TypeBClass, type_b_base_class_init() + * is called to allocate the dynamic members of TypeBClass (dynamic_gstring), + * and finally the GClassInitFunc() of TypeBClass, type_b_class_init(), + * is called to complete the initialization process with the static members + * (static_float). + * + * Corresponding finalization counter parts to the GBaseInitFunc() functions + * have to be provided to release allocated resources at class finalization + * time. + */ +typedef void (*GClassInitFunc) (gpointer g_class, + gpointer class_data); +/** + * GClassFinalizeFunc: + * @g_class: (type GObject.TypeClass): The #GTypeClass structure to finalize + * @class_data: The @class_data member supplied via the #GTypeInfo structure + * + * A callback function used by the type system to finalize a class. + * This function is rarely needed, as dynamically allocated class resources + * should be handled by GBaseInitFunc() and GBaseFinalizeFunc(). + * Also, specification of a GClassFinalizeFunc() in the #GTypeInfo + * structure of a static type is invalid, because classes of static types + * will never be finalized (they are artificially kept alive when their + * reference count drops to zero). + */ +typedef void (*GClassFinalizeFunc) (gpointer g_class, + gpointer class_data); +/** + * GInstanceInitFunc: + * @instance: The instance to initialize + * @g_class: (type GObject.TypeClass): The class of the type the instance is + * created for + * + * A callback function used by the type system to initialize a new + * instance of a type. This function initializes all instance members and + * allocates any resources required by it. + * + * Initialization of a derived instance involves calling all its parent + * types instance initializers, so the class member of the instance + * is altered during its initialization to always point to the class that + * belongs to the type the current initializer was introduced for. + * + * The extended members of @instance are guaranteed to have been filled with + * zeros before this function is called. + */ +typedef void (*GInstanceInitFunc) (GTypeInstance *instance, + gpointer g_class); +/** + * GInterfaceInitFunc: + * @g_iface: (type GObject.TypeInterface): The interface structure to initialize + * @iface_data: The @interface_data supplied via the #GInterfaceInfo structure + * + * A callback function used by the type system to initialize a new + * interface. This function should initialize all internal data and + * allocate any resources required by the interface. + * + * The members of @iface_data are guaranteed to have been filled with + * zeros before this function is called. + */ +typedef void (*GInterfaceInitFunc) (gpointer g_iface, + gpointer iface_data); +/** + * GInterfaceFinalizeFunc: + * @g_iface: (type GObject.TypeInterface): The interface structure to finalize + * @iface_data: The @interface_data supplied via the #GInterfaceInfo structure + * + * A callback function used by the type system to finalize an interface. + * This function should destroy any internal data and release any resources + * allocated by the corresponding GInterfaceInitFunc() function. + */ +typedef void (*GInterfaceFinalizeFunc) (gpointer g_iface, + gpointer iface_data); +/** + * GTypeClassCacheFunc: + * @cache_data: data that was given to the g_type_add_class_cache_func() call + * @g_class: (type GObject.TypeClass): The #GTypeClass structure which is + * unreferenced + * + * A callback function which is called when the reference count of a class + * drops to zero. It may use g_type_class_ref() to prevent the class from + * being freed. You should not call g_type_class_unref() from a + * #GTypeClassCacheFunc function to prevent infinite recursion, use + * g_type_class_unref_uncached() instead. + * + * The functions have to check the class id passed in to figure + * whether they actually want to cache the class of this type, since all + * classes are routed through the same #GTypeClassCacheFunc chain. + * + * Returns: %TRUE to stop further #GTypeClassCacheFuncs from being + * called, %FALSE to continue + */ +typedef gboolean (*GTypeClassCacheFunc) (gpointer cache_data, + GTypeClass *g_class); +/** + * GTypeInterfaceCheckFunc: + * @check_data: data passed to g_type_add_interface_check() + * @g_iface: (type GObject.TypeInterface): the interface that has been + * initialized + * + * A callback called after an interface vtable is initialized. + * See g_type_add_interface_check(). + * + * Since: 2.4 + */ +typedef void (*GTypeInterfaceCheckFunc) (gpointer check_data, + gpointer g_iface); +/** + * GTypeFundamentalFlags: + * @G_TYPE_FLAG_CLASSED: Indicates a classed type + * @G_TYPE_FLAG_INSTANTIATABLE: Indicates an instantiatable type (implies classed) + * @G_TYPE_FLAG_DERIVABLE: Indicates a flat derivable type + * @G_TYPE_FLAG_DEEP_DERIVABLE: Indicates a deep derivable type (implies derivable) + * + * Bit masks used to check or determine specific characteristics of a + * fundamental type. + */ +typedef enum /*< skip >*/ +{ + G_TYPE_FLAG_CLASSED = (1 << 0), + G_TYPE_FLAG_INSTANTIATABLE = (1 << 1), + G_TYPE_FLAG_DERIVABLE = (1 << 2), + G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3) +} GTypeFundamentalFlags; +/** + * GTypeFlags: + * @G_TYPE_FLAG_ABSTRACT: Indicates an abstract type. No instances can be + * created for an abstract type + * @G_TYPE_FLAG_VALUE_ABSTRACT: Indicates an abstract value type, i.e. a type + * that introduces a value table, but can't be used for + * g_value_init() + * + * Bit masks used to check or determine characteristics of a type. + */ +typedef enum /*< skip >*/ +{ + G_TYPE_FLAG_ABSTRACT = (1 << 4), + G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5) +} GTypeFlags; +/** + * GTypeInfo: + * @class_size: Size of the class structure (required for interface, classed and instantiatable types) + * @base_init: Location of the base initialization function (optional) + * @base_finalize: Location of the base finalization function (optional) + * @class_init: Location of the class initialization function for + * classed and instantiatable types. Location of the default vtable + * inititalization function for interface types. (optional) This function + * is used both to fill in virtual functions in the class or default vtable, + * and to do type-specific setup such as registering signals and object + * properties. + * @class_finalize: Location of the class finalization function for + * classed and instantiatable types. Location of the default vtable + * finalization function for interface types. (optional) + * @class_data: User-supplied data passed to the class init/finalize functions + * @instance_size: Size of the instance (object) structure (required for instantiatable types only) + * @n_preallocs: Prior to GLib 2.10, it specified the number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching). Since GLib 2.10, it is ignored, since instances are allocated with the [slice allocator][glib-Memory-Slices] now. + * @instance_init: Location of the instance initialization function (optional, for instantiatable types only) + * @value_table: A #GTypeValueTable function table for generic handling of GValues + * of this type (usually only useful for fundamental types) + * + * This structure is used to provide the type system with the information + * required to initialize and destruct (finalize) a type's class and + * its instances. + * + * The initialized structure is passed to the g_type_register_static() function + * (or is copied into the provided #GTypeInfo structure in the + * g_type_plugin_complete_type_info()). The type system will perform a deep + * copy of this structure, so its memory does not need to be persistent + * across invocation of g_type_register_static(). + */ +struct _GTypeInfo +{ + /* interface types, classed types, instantiated types */ + guint16 class_size; + + GBaseInitFunc base_init; + GBaseFinalizeFunc base_finalize; + + /* interface types, classed types, instantiated types */ + GClassInitFunc class_init; + GClassFinalizeFunc class_finalize; + gconstpointer class_data; + + /* instantiated types */ + guint16 instance_size; + guint16 n_preallocs; + GInstanceInitFunc instance_init; + + /* value handling */ + const GTypeValueTable *value_table; +}; +/** + * GTypeFundamentalInfo: + * @type_flags: #GTypeFundamentalFlags describing the characteristics of the fundamental type + * + * A structure that provides information to the type system which is + * used specifically for managing fundamental types. + */ +struct _GTypeFundamentalInfo +{ + GTypeFundamentalFlags type_flags; +}; +/** + * GInterfaceInfo: + * @interface_init: location of the interface initialization function + * @interface_finalize: location of the interface finalization function + * @interface_data: user-supplied data passed to the interface init/finalize functions + * + * A structure that provides information to the type system which is + * used specifically for managing interface types. + */ +struct _GInterfaceInfo +{ + GInterfaceInitFunc interface_init; + GInterfaceFinalizeFunc interface_finalize; + gpointer interface_data; +}; +/** + * GTypeValueTable: + * @value_init: Default initialize @values contents by poking values + * directly into the value->data array. The data array of + * the #GValue passed into this function was zero-filled + * with `memset()`, so no care has to be taken to free any + * old contents. E.g. for the implementation of a string + * value that may never be %NULL, the implementation might + * look like: + * |[ + * value->data[0].v_pointer = g_strdup (""); + * ]| + * @value_free: Free any old contents that might be left in the + * data array of the passed in @value. No resources may + * remain allocated through the #GValue contents after + * this function returns. E.g. for our above string type: + * |[ + * // only free strings without a specific flag for static storage + * if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)) + * g_free (value->data[0].v_pointer); + * ]| + * @value_copy: @dest_value is a #GValue with zero-filled data section + * and @src_value is a properly setup #GValue of same or + * derived type. + * The purpose of this function is to copy the contents of + * @src_value into @dest_value in a way, that even after + * @src_value has been freed, the contents of @dest_value + * remain valid. String type example: + * |[ + * dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer); + * ]| + * @value_peek_pointer: If the value contents fit into a pointer, such as objects + * or strings, return this pointer, so the caller can peek at + * the current contents. To extend on our above string example: + * |[ + * return value->data[0].v_pointer; + * ]| + * @collect_format: A string format describing how to collect the contents of + * this value bit-by-bit. Each character in the format represents + * an argument to be collected, and the characters themselves indicate + * the type of the argument. Currently supported arguments are: + * - 'i' - Integers. passed as collect_values[].v_int. + * - 'l' - Longs. passed as collect_values[].v_long. + * - 'd' - Doubles. passed as collect_values[].v_double. + * - 'p' - Pointers. passed as collect_values[].v_pointer. + * It should be noted that for variable argument list construction, + * ANSI C promotes every type smaller than an integer to an int, and + * floats to doubles. So for collection of short int or char, 'i' + * needs to be used, and for collection of floats 'd'. + * @collect_value: The collect_value() function is responsible for converting the + * values collected from a variable argument list into contents + * suitable for storage in a GValue. This function should setup + * @value similar to value_init(); e.g. for a string value that + * does not allow %NULL pointers, it needs to either spew an error, + * or do an implicit conversion by storing an empty string. + * The @value passed in to this function has a zero-filled data + * array, so just like for value_init() it is guaranteed to not + * contain any old contents that might need freeing. + * @n_collect_values is exactly the string length of @collect_format, + * and @collect_values is an array of unions #GTypeCValue with + * length @n_collect_values, containing the collected values + * according to @collect_format. + * @collect_flags is an argument provided as a hint by the caller. + * It may contain the flag %G_VALUE_NOCOPY_CONTENTS indicating, + * that the collected value contents may be considered "static" + * for the duration of the @value lifetime. + * Thus an extra copy of the contents stored in @collect_values is + * not required for assignment to @value. + * For our above string example, we continue with: + * |[ + * if (!collect_values[0].v_pointer) + * value->data[0].v_pointer = g_strdup (""); + * else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) + * { + * value->data[0].v_pointer = collect_values[0].v_pointer; + * // keep a flag for the value_free() implementation to not free this string + * value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS; + * } + * else + * value->data[0].v_pointer = g_strdup (collect_values[0].v_pointer); + * return NULL; + * ]| + * It should be noted, that it is generally a bad idea to follow the + * #G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to + * reentrancy requirements and reference count assertions performed + * by the signal emission code, reference counts should always be + * incremented for reference counted contents stored in the value->data + * array. To deviate from our string example for a moment, and taking + * a look at an exemplary implementation for collect_value() of + * #GObject: + * |[ + * GObject *object = G_OBJECT (collect_values[0].v_pointer); + * g_return_val_if_fail (object != NULL, + * g_strdup_printf ("Object passed as invalid NULL pointer")); + * // never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types + * value->data[0].v_pointer = g_object_ref (object); + * return NULL; + * ]| + * The reference count for valid objects is always incremented, + * regardless of @collect_flags. For invalid objects, the example + * returns a newly allocated string without altering @value. + * Upon success, collect_value() needs to return %NULL. If, however, + * an error condition occurred, collect_value() may spew an + * error by returning a newly allocated non-%NULL string, giving + * a suitable description of the error condition. + * The calling code makes no assumptions about the @value + * contents being valid upon error returns, @value + * is simply thrown away without further freeing. As such, it is + * a good idea to not allocate #GValue contents, prior to returning + * an error, however, collect_values() is not obliged to return + * a correctly setup @value for error returns, simply because + * any non-%NULL return is considered a fatal condition so further + * program behaviour is undefined. + * @lcopy_format: Format description of the arguments to collect for @lcopy_value, + * analogous to @collect_format. Usually, @lcopy_format string consists + * only of 'p's to provide lcopy_value() with pointers to storage locations. + * @lcopy_value: This function is responsible for storing the @value contents into + * arguments passed through a variable argument list which got + * collected into @collect_values according to @lcopy_format. + * @n_collect_values equals the string length of @lcopy_format, + * and @collect_flags may contain %G_VALUE_NOCOPY_CONTENTS. + * In contrast to collect_value(), lcopy_value() is obliged to + * always properly support %G_VALUE_NOCOPY_CONTENTS. + * Similar to collect_value() the function may prematurely abort + * by returning a newly allocated string describing an error condition. + * To complete the string example: + * |[ + * gchar **string_p = collect_values[0].v_pointer; + * g_return_val_if_fail (string_p != NULL, + * g_strdup_printf ("string location passed as NULL")); + * if (collect_flags & G_VALUE_NOCOPY_CONTENTS) + * *string_p = value->data[0].v_pointer; + * else + * *string_p = g_strdup (value->data[0].v_pointer); + * ]| + * And an illustrative version of lcopy_value() for + * reference-counted types: + * |[ + * GObject **object_p = collect_values[0].v_pointer; + * g_return_val_if_fail (object_p != NULL, + * g_strdup_printf ("object location passed as NULL")); + * if (!value->data[0].v_pointer) + * *object_p = NULL; + * else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) // always honour + * *object_p = value->data[0].v_pointer; + * else + * *object_p = g_object_ref (value->data[0].v_pointer); + * return NULL; + * ]| + * + * The #GTypeValueTable provides the functions required by the #GValue + * implementation, to serve as a container for values of a type. + */ + +struct _GTypeValueTable +{ + void (*value_init) (GValue *value); + void (*value_free) (GValue *value); + void (*value_copy) (const GValue *src_value, + GValue *dest_value); + /* varargs functionality (optional) */ + gpointer (*value_peek_pointer) (const GValue *value); + const gchar *collect_format; + gchar* (*collect_value) (GValue *value, + guint n_collect_values, + GTypeCValue *collect_values, + guint collect_flags); + const gchar *lcopy_format; + gchar* (*lcopy_value) (const GValue *value, + guint n_collect_values, + GTypeCValue *collect_values, + guint collect_flags); +}; +GLIB_AVAILABLE_IN_ALL +GType g_type_register_static (GType parent_type, + const gchar *type_name, + const GTypeInfo *info, + GTypeFlags flags); +GLIB_AVAILABLE_IN_ALL +GType g_type_register_static_simple (GType parent_type, + const gchar *type_name, + guint class_size, + GClassInitFunc class_init, + guint instance_size, + GInstanceInitFunc instance_init, + GTypeFlags flags); + +GLIB_AVAILABLE_IN_ALL +GType g_type_register_dynamic (GType parent_type, + const gchar *type_name, + GTypePlugin *plugin, + GTypeFlags flags); +GLIB_AVAILABLE_IN_ALL +GType g_type_register_fundamental (GType type_id, + const gchar *type_name, + const GTypeInfo *info, + const GTypeFundamentalInfo *finfo, + GTypeFlags flags); +GLIB_AVAILABLE_IN_ALL +void g_type_add_interface_static (GType instance_type, + GType interface_type, + const GInterfaceInfo *info); +GLIB_AVAILABLE_IN_ALL +void g_type_add_interface_dynamic (GType instance_type, + GType interface_type, + GTypePlugin *plugin); +GLIB_AVAILABLE_IN_ALL +void g_type_interface_add_prerequisite (GType interface_type, + GType prerequisite_type); +GLIB_AVAILABLE_IN_ALL +GType*g_type_interface_prerequisites (GType interface_type, + guint *n_prerequisites); +GLIB_AVAILABLE_IN_2_68 +GType g_type_interface_instantiatable_prerequisite + (GType interface_type); +GLIB_DEPRECATED_IN_2_58 +void g_type_class_add_private (gpointer g_class, + gsize private_size); +GLIB_AVAILABLE_IN_2_38 +gint g_type_add_instance_private (GType class_type, + gsize private_size); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_instance_get_private (GTypeInstance *instance, + GType private_type); +GLIB_AVAILABLE_IN_2_38 +void g_type_class_adjust_private_offset (gpointer g_class, + gint *private_size_or_offset); + +GLIB_AVAILABLE_IN_ALL +void g_type_add_class_private (GType class_type, + gsize private_size); +GLIB_AVAILABLE_IN_ALL +gpointer g_type_class_get_private (GTypeClass *klass, + GType private_type); +GLIB_AVAILABLE_IN_2_38 +gint g_type_class_get_instance_private_offset (gpointer g_class); + +GLIB_AVAILABLE_IN_2_34 +void g_type_ensure (GType type); +GLIB_AVAILABLE_IN_2_36 +guint g_type_get_type_registration_serial (void); + + +/* --- GType boilerplate --- */ +/** + * G_DECLARE_FINAL_TYPE: + * @ModuleObjName: The name of the new type, in camel case (like GtkWidget) + * @module_obj_name: The name of the new type in lowercase, with words + * separated by '_' (like 'gtk_widget') + * @MODULE: The name of the module, in all caps (like 'GTK') + * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET') + * @ParentName: the name of the parent type, in camel case (like GtkWidget) + * + * A convenience macro for emitting the usual declarations in the header file for a type which is not (at the + * present time) intended to be subclassed. + * + * You might use it in a header as follows: + * + * |[ + * #ifndef _myapp_window_h_ + * #define _myapp_window_h_ + * + * #include + * + * #define MY_APP_TYPE_WINDOW my_app_window_get_type () + * G_DECLARE_FINAL_TYPE (MyAppWindow, my_app_window, MY_APP, WINDOW, GtkWindow) + * + * MyAppWindow * my_app_window_new (void); + * + * ... + * + * #endif + * ]| + * + * This results in the following things happening: + * + * - the usual my_app_window_get_type() function is declared with a return type of #GType + * + * - the MyAppWindow types is defined as a typedef of struct _MyAppWindow. The struct itself is not + * defined and should be defined from the .c file before G_DEFINE_TYPE() is used. + * + * - the MY_APP_WINDOW() cast is emitted as static inline function along with the MY_APP_IS_WINDOW() type + * checking function + * + * - the MyAppWindowClass type is defined as a struct containing GtkWindowClass. This is done for the + * convenience of the person defining the type and should not be considered to be part of the ABI. In + * particular, without a firm declaration of the instance structure, it is not possible to subclass the type + * and therefore the fact that the size of the class structure is exposed is not a concern and it can be + * freely changed at any point in the future. + * + * - g_autoptr() support being added for your type, based on the type of your parent class + * + * You can only use this function if your parent type also supports g_autoptr(). + * + * Because the type macro (MY_APP_TYPE_WINDOW in the above example) is not a callable, you must continue to + * manually define this as a macro for yourself. + * + * The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro + * to be used in the usual way with export control and API versioning macros. + * + * If you want to declare your own class structure, use G_DECLARE_DERIVABLE_TYPE(). + * + * If you are writing a library, it is important to note that it is possible to convert a type from using + * G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you + * should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be + * subclassed. Once a class structure has been exposed it is not possible to change its size or remove or + * reorder items without breaking the API and/or ABI. + * + * Since: 2.44 + **/ +#define G_DECLARE_FINAL_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \ + GType module_obj_name##_get_type (void); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + typedef struct _##ModuleObjName ModuleObjName; \ + typedef struct { ParentName##Class parent_class; } ModuleObjName##Class; \ + \ + _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \ + G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref) \ + \ + G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_DECLARE_DERIVABLE_TYPE: + * @ModuleObjName: The name of the new type, in camel case (like GtkWidget) + * @module_obj_name: The name of the new type in lowercase, with words + * separated by '_' (like 'gtk_widget') + * @MODULE: The name of the module, in all caps (like 'GTK') + * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET') + * @ParentName: the name of the parent type, in camel case (like GtkWidget) + * + * A convenience macro for emitting the usual declarations in the + * header file for a type which is intended to be subclassed. + * + * You might use it in a header as follows: + * + * |[ + * #ifndef _gtk_frobber_h_ + * #define _gtk_frobber_h_ + * + * #define GTK_TYPE_FROBBER gtk_frobber_get_type () + * GDK_AVAILABLE_IN_3_12 + * G_DECLARE_DERIVABLE_TYPE (GtkFrobber, gtk_frobber, GTK, FROBBER, GtkWidget) + * + * struct _GtkFrobberClass + * { + * GtkWidgetClass parent_class; + * + * void (* handle_frob) (GtkFrobber *frobber, + * guint n_frobs); + * + * gpointer padding[12]; + * }; + * + * GtkWidget * gtk_frobber_new (void); + * + * ... + * + * #endif + * ]| + * + * This results in the following things happening: + * + * - the usual gtk_frobber_get_type() function is declared with a return type of #GType + * + * - the GtkFrobber struct is created with GtkWidget as the first and only item. You are expected to use + * a private structure from your .c file to store your instance variables. + * + * - the GtkFrobberClass type is defined as a typedef to struct _GtkFrobberClass, which is left undefined. + * You should do this from the header file directly after you use the macro. + * + * - the GTK_FROBBER() and GTK_FROBBER_CLASS() casts are emitted as static inline functions along with + * the GTK_IS_FROBBER() and GTK_IS_FROBBER_CLASS() type checking functions and GTK_FROBBER_GET_CLASS() + * function. + * + * - g_autoptr() support being added for your type, based on the type of your parent class + * + * You can only use this function if your parent type also supports g_autoptr(). + * + * Because the type macro (GTK_TYPE_FROBBER in the above example) is not a callable, you must continue to + * manually define this as a macro for yourself. + * + * The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro + * to be used in the usual way with export control and API versioning macros. + * + * If you are writing a library, it is important to note that it is possible to convert a type from using + * G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you + * should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be + * subclassed. Once a class structure has been exposed it is not possible to change its size or remove or + * reorder items without breaking the API and/or ABI. If you want to declare your own class structure, use + * G_DECLARE_DERIVABLE_TYPE(). If you want to declare a class without exposing the class or instance + * structures, use G_DECLARE_FINAL_TYPE(). + * + * If you must use G_DECLARE_DERIVABLE_TYPE() you should be sure to include some padding at the bottom of your + * class structure to leave space for the addition of future virtual functions. + * + * Since: 2.44 + **/ +#define G_DECLARE_DERIVABLE_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \ + GType module_obj_name##_get_type (void); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + typedef struct _##ModuleObjName ModuleObjName; \ + typedef struct _##ModuleObjName##Class ModuleObjName##Class; \ + struct _##ModuleObjName { ParentName parent_instance; }; \ + \ + _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \ + G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref) \ + \ + G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ + G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_CLASS (gpointer ptr) { \ + return G_TYPE_CHECK_CLASS_CAST (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME##_CLASS (gpointer ptr) { \ + return G_TYPE_CHECK_CLASS_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_GET_CLASS (gpointer ptr) { \ + return G_TYPE_INSTANCE_GET_CLASS (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \ + G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_DECLARE_INTERFACE: + * @ModuleObjName: The name of the new type, in camel case (like GtkWidget) + * @module_obj_name: The name of the new type in lowercase, with words + * separated by '_' (like 'gtk_widget') + * @MODULE: The name of the module, in all caps (like 'GTK') + * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET') + * @PrerequisiteName: the name of the prerequisite type, in camel case (like GtkWidget) + * + * A convenience macro for emitting the usual declarations in the header file for a GInterface type. + * + * You might use it in a header as follows: + * + * |[ + * #ifndef _my_model_h_ + * #define _my_model_h_ + * + * #define MY_TYPE_MODEL my_model_get_type () + * GDK_AVAILABLE_IN_3_12 + * G_DECLARE_INTERFACE (MyModel, my_model, MY, MODEL, GObject) + * + * struct _MyModelInterface + * { + * GTypeInterface g_iface; + * + * gpointer (* get_item) (MyModel *model); + * }; + * + * gpointer my_model_get_item (MyModel *model); + * + * ... + * + * #endif + * ]| + * + * This results in the following things happening: + * + * - the usual my_model_get_type() function is declared with a return type of #GType + * + * - the MyModelInterface type is defined as a typedef to struct _MyModelInterface, + * which is left undefined. You should do this from the header file directly after + * you use the macro. + * + * - the MY_MODEL() cast is emitted as static inline functions along with + * the MY_IS_MODEL() type checking function and MY_MODEL_GET_IFACE() function. + * + * - g_autoptr() support being added for your type, based on your prerequisite type. + * + * You can only use this function if your prerequisite type also supports g_autoptr(). + * + * Because the type macro (MY_TYPE_MODEL in the above example) is not a callable, you must continue to + * manually define this as a macro for yourself. + * + * The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro + * to be used in the usual way with export control and API versioning macros. + * + * Since: 2.44 + **/ +#define G_DECLARE_INTERFACE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, PrerequisiteName) \ + GType module_obj_name##_get_type (void); \ + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ + typedef struct _##ModuleObjName ModuleObjName; \ + typedef struct _##ModuleObjName##Interface ModuleObjName##Interface; \ + \ + _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, PrerequisiteName) \ + \ + G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ + G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ + return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ + G_GNUC_UNUSED static inline ModuleObjName##Interface * MODULE##_##OBJ_NAME##_GET_IFACE (gpointer ptr) { \ + return G_TYPE_INSTANCE_GET_INTERFACE (ptr, module_obj_name##_get_type (), ModuleObjName##Interface); } \ + G_GNUC_END_IGNORE_DEPRECATIONS + +/** + * G_DEFINE_TYPE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by '_'. + * @T_P: The #GType of the parent type. + * + * A convenience macro for type implementations, which declares a class + * initialization function, an instance initialization function (see #GTypeInfo + * for information about these) and a static variable named `t_n_parent_class` + * pointing to the parent class. Furthermore, it defines a *_get_type() function. + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.4 + */ +#define G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {}) +/** + * G_DEFINE_TYPE_WITH_CODE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type in lowercase, with words separated by '_'. + * @T_P: The #GType of the parent type. + * @_C_: Custom code that gets inserted in the *_get_type() function. + * + * A convenience macro for type implementations. + * Similar to G_DEFINE_TYPE(), but allows you to insert custom code into the + * *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE(). + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.4 + */ +#define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() +/** + * G_DEFINE_TYPE_WITH_PRIVATE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by '_'. + * @T_P: The #GType of the parent type. + * + * A convenience macro for type implementations, which declares a class + * initialization function, an instance initialization function (see #GTypeInfo + * for information about these), a static variable named `t_n_parent_class` + * pointing to the parent class, and adds private instance data to the type. + * Furthermore, it defines a *_get_type() function. See G_DEFINE_TYPE_EXTENDED() + * for an example. + * + * Note that private structs added with this macros must have a struct + * name of the form @TN Private. + * + * The private instance data can be retrieved using the automatically generated + * getter function `t_n_get_instance_private()`. + * + * See also: G_ADD_PRIVATE() + * + * Since: 2.38 + */ +#define G_DEFINE_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, G_ADD_PRIVATE (TN)) +/** + * G_DEFINE_ABSTRACT_TYPE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by '_'. + * @T_P: The #GType of the parent type. + * + * A convenience macro for type implementations. + * Similar to G_DEFINE_TYPE(), but defines an abstract type. + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.4 + */ +#define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {}) +/** + * G_DEFINE_ABSTRACT_TYPE_WITH_CODE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by '_'. + * @T_P: The #GType of the parent type. + * @_C_: Custom code that gets inserted in the @type_name_get_type() function. + * + * A convenience macro for type implementations. + * Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type and + * allows you to insert custom code into the *_get_type() function, e.g. + * interface implementations via G_IMPLEMENT_INTERFACE(). + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.4 + */ +#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() +/** + * G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by '_'. + * @T_P: The #GType of the parent type. + * + * Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines an abstract type. + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Since: 2.38 + */ +#define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (TN)) +/** + * G_DEFINE_TYPE_EXTENDED: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by '_'. + * @T_P: The #GType of the parent type. + * @_f_: #GTypeFlags to pass to g_type_register_static() + * @_C_: Custom code that gets inserted in the *_get_type() function. + * + * The most general convenience macro for type implementations, on which + * G_DEFINE_TYPE(), etc are based. + * + * |[ + * G_DEFINE_TYPE_EXTENDED (GtkGadget, + * gtk_gadget, + * GTK_TYPE_WIDGET, + * 0, + * G_ADD_PRIVATE (GtkGadget) + * G_IMPLEMENT_INTERFACE (TYPE_GIZMO, + * gtk_gadget_gizmo_init)); + * ]| + * expands to + * |[ + * static void gtk_gadget_init (GtkGadget *self); + * static void gtk_gadget_class_init (GtkGadgetClass *klass); + * static gpointer gtk_gadget_parent_class = NULL; + * static gint GtkGadget_private_offset; + * static void gtk_gadget_class_intern_init (gpointer klass) + * { + * gtk_gadget_parent_class = g_type_class_peek_parent (klass); + * if (GtkGadget_private_offset != 0) + * g_type_class_adjust_private_offset (klass, &GtkGadget_private_offset); + * gtk_gadget_class_init ((GtkGadgetClass*) klass); + * } + * static inline gpointer gtk_gadget_get_instance_private (GtkGadget *self) + * { + * return (G_STRUCT_MEMBER_P (self, GtkGadget_private_offset)); + * } + * + * GType + * gtk_gadget_get_type (void) + * { + * static gsize static_g_define_type_id = 0; + * if (g_once_init_enter (&static_g_define_type_id)) + * { + * GType g_define_type_id = + * g_type_register_static_simple (GTK_TYPE_WIDGET, + * g_intern_static_string ("GtkGadget"), + * sizeof (GtkGadgetClass), + * (GClassInitFunc) gtk_gadget_class_intern_init, + * sizeof (GtkGadget), + * (GInstanceInitFunc) gtk_gadget_init, + * 0); + * { + * GtkGadget_private_offset = + * g_type_add_instance_private (g_define_type_id, sizeof (GtkGadgetPrivate)); + * } + * { + * const GInterfaceInfo g_implement_interface_info = { + * (GInterfaceInitFunc) gtk_gadget_gizmo_init + * }; + * g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); + * } + * g_once_init_leave (&static_g_define_type_id, g_define_type_id); + * } + * return static_g_define_type_id; + * } + * ]| + * The only pieces which have to be manually provided are the definitions of + * the instance and class structure and the definitions of the instance and + * class init functions. + * + * Since: 2.4 + */ +#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() + +/** + * G_DEFINE_INTERFACE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words separated by '_'. + * @T_P: The #GType of the prerequisite type for the interface, or 0 + * (%G_TYPE_INVALID) for no prerequisite type. + * + * A convenience macro for #GTypeInterface definitions, which declares + * a default vtable initialization function and defines a *_get_type() + * function. + * + * The macro expects the interface initialization function to have the + * name `t_n ## _default_init`, and the interface structure to have the + * name `TN ## Interface`. + * + * The initialization function has signature + * `static void t_n ## _default_init (TypeName##Interface *klass);`, rather than + * the full #GInterfaceInitFunc signature, for brevity and convenience. If you + * need to use an initialization function with an `iface_data` argument, you + * must write the #GTypeInterface definitions manually. + * + * Since: 2.24 + */ +#define G_DEFINE_INTERFACE(TN, t_n, T_P) G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;) + +/** + * G_DEFINE_INTERFACE_WITH_CODE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words separated by '_'. + * @T_P: The #GType of the prerequisite type for the interface, or 0 + * (%G_TYPE_INVALID) for no prerequisite type. + * @_C_: Custom code that gets inserted in the *_get_type() function. + * + * A convenience macro for #GTypeInterface definitions. Similar to + * G_DEFINE_INTERFACE(), but allows you to insert custom code into the + * *_get_type() function, e.g. additional interface implementations + * via G_IMPLEMENT_INTERFACE(), or additional prerequisite types. See + * G_DEFINE_TYPE_EXTENDED() for a similar example using + * G_DEFINE_TYPE_WITH_CODE(). + * + * Since: 2.24 + */ +#define G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TN, t_n, T_P) {_C_;} _G_DEFINE_INTERFACE_EXTENDED_END() + +/** + * G_IMPLEMENT_INTERFACE: + * @TYPE_IFACE: The #GType of the interface to add + * @iface_init: (type GInterfaceInitFunc): The interface init function, of type #GInterfaceInitFunc + * + * A convenience macro to ease interface addition in the `_C_` section + * of G_DEFINE_TYPE_WITH_CODE() or G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). + * See G_DEFINE_TYPE_EXTENDED() for an example. + * + * Note that this macro can only be used together with the G_DEFINE_TYPE_* + * macros, since it depends on variable names from those macros. + * + * Since: 2.4 + */ +#define G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) { \ + const GInterfaceInfo g_implement_interface_info = { \ + (GInterfaceInitFunc)(void (*)(void)) iface_init, NULL, NULL \ + }; \ + g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \ +} + +/** + * G_ADD_PRIVATE: + * @TypeName: the name of the type in CamelCase + * + * A convenience macro to ease adding private data to instances of a new type + * in the @_C_ section of G_DEFINE_TYPE_WITH_CODE() or + * G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). + * + * For instance: + * + * |[ + * typedef struct _MyObject MyObject; + * typedef struct _MyObjectClass MyObjectClass; + * + * typedef struct { + * gint foo; + * gint bar; + * } MyObjectPrivate; + * + * G_DEFINE_TYPE_WITH_CODE (MyObject, my_object, G_TYPE_OBJECT, + * G_ADD_PRIVATE (MyObject)) + * ]| + * + * Will add MyObjectPrivate as the private data to any instance of the MyObject + * type. + * + * G_DEFINE_TYPE_* macros will automatically create a private function + * based on the arguments to this macro, which can be used to safely + * retrieve the private data from an instance of the type; for instance: + * + * |[ + * gint + * my_object_get_foo (MyObject *obj) + * { + * MyObjectPrivate *priv = my_object_get_instance_private (obj); + * + * g_return_val_if_fail (MY_IS_OBJECT (obj), 0); + * + * return priv->foo; + * } + * + * void + * my_object_set_bar (MyObject *obj, + * gint bar) + * { + * MyObjectPrivate *priv = my_object_get_instance_private (obj); + * + * g_return_if_fail (MY_IS_OBJECT (obj)); + * + * if (priv->bar != bar) + * priv->bar = bar; + * } + * ]| + * + * Note that this macro can only be used together with the G_DEFINE_TYPE_* + * macros, since it depends on variable names from those macros. + * + * Also note that private structs added with these macros must have a struct + * name of the form `TypeNamePrivate`. + * + * It is safe to call the `_get_instance_private` function on %NULL or invalid + * objects since it's only adding an offset to the instance pointer. In that + * case the returned pointer must not be dereferenced. + * + * Since: 2.38 + */ +#define G_ADD_PRIVATE(TypeName) { \ + TypeName##_private_offset = \ + g_type_add_instance_private (g_define_type_id, sizeof (TypeName##Private)); \ +} + +/** + * G_PRIVATE_OFFSET: + * @TypeName: the name of the type in CamelCase + * @field: the name of the field in the private data structure + * + * Evaluates to the offset of the @field inside the instance private data + * structure for @TypeName. + * + * Note that this macro can only be used together with the G_DEFINE_TYPE_* + * and G_ADD_PRIVATE() macros, since it depends on variable names from + * those macros. + * + * Since: 2.38 + */ +#define G_PRIVATE_OFFSET(TypeName, field) \ + (TypeName##_private_offset + (G_STRUCT_OFFSET (TypeName##Private, field))) + +/** + * G_PRIVATE_FIELD_P: + * @TypeName: the name of the type in CamelCase + * @inst: the instance of @TypeName you wish to access + * @field_name: the name of the field in the private data structure + * + * Evaluates to a pointer to the @field_name inside the @inst private data + * structure for @TypeName. + * + * Note that this macro can only be used together with the G_DEFINE_TYPE_* + * and G_ADD_PRIVATE() macros, since it depends on variable names from + * those macros. + * + * Since: 2.38 + */ +#define G_PRIVATE_FIELD_P(TypeName, inst, field_name) \ + G_STRUCT_MEMBER_P (inst, G_PRIVATE_OFFSET (TypeName, field_name)) + +/** + * G_PRIVATE_FIELD: + * @TypeName: the name of the type in CamelCase + * @inst: the instance of @TypeName you wish to access + * @field_type: the type of the field in the private data structure + * @field_name: the name of the field in the private data structure + * + * Evaluates to the @field_name inside the @inst private data + * structure for @TypeName. + * + * Note that this macro can only be used together with the G_DEFINE_TYPE_* + * and G_ADD_PRIVATE() macros, since it depends on variable names from + * those macros. + * + * Since: 2.38 + */ +#define G_PRIVATE_FIELD(TypeName, inst, field_type, field_name) \ + G_STRUCT_MEMBER (field_type, inst, G_PRIVATE_OFFSET (TypeName, field_name)) + +/* we need to have this macro under conditional expansion, as it references + * a function that has been added in 2.38. see bug: + * https://bugzilla.gnome.org/show_bug.cgi?id=703191 + */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 +#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ +static void type_name##_class_intern_init (gpointer klass) \ +{ \ + type_name##_parent_class = g_type_class_peek_parent (klass); \ + if (TypeName##_private_offset != 0) \ + g_type_class_adjust_private_offset (klass, &TypeName##_private_offset); \ + type_name##_class_init ((TypeName##Class*) klass); \ +} + +#else +#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ +static void type_name##_class_intern_init (gpointer klass) \ +{ \ + type_name##_parent_class = g_type_class_peek_parent (klass); \ + type_name##_class_init ((TypeName##Class*) klass); \ +} +#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */ + +/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */ +#define _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \ +\ +static void type_name##_init (TypeName *self); \ +static void type_name##_class_init (TypeName##Class *klass); \ +static GType type_name##_get_type_once (void); \ +static gpointer type_name##_parent_class = NULL; \ +static gint TypeName##_private_offset; \ +\ +_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ +\ +G_GNUC_UNUSED \ +static inline gpointer \ +type_name##_get_instance_private (TypeName *self) \ +{ \ + return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \ +} \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static gsize static_g_define_type_id = 0; + /* Prelude goes here */ + +/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */ +#define _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \ + if (g_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = type_name##_get_type_once (); \ + g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} /* closes type_name##_get_type() */ \ +\ +G_GNUC_NO_INLINE \ +static GType \ +type_name##_get_type_once (void) \ +{ \ + GType g_define_type_id = \ + g_type_register_static_simple (TYPE_PARENT, \ + g_intern_static_string (#TypeName), \ + sizeof (TypeName##Class), \ + (GClassInitFunc)(void (*)(void)) type_name##_class_intern_init, \ + sizeof (TypeName), \ + (GInstanceInitFunc)(void (*)(void)) type_name##_init, \ + (GTypeFlags) flags); \ + { /* custom code follows */ +#define _G_DEFINE_TYPE_EXTENDED_END() \ + /* following custom code */ \ + } \ + return g_define_type_id; \ +} /* closes type_name##_get_type_once() */ + +/* This was defined before we had G_DEFINE_TYPE_WITH_CODE_AND_PRELUDE, it's simplest + * to keep it. + */ +#define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \ + _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \ + _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \ + +#define _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PREREQ) \ +\ +static void type_name##_default_init (TypeName##Interface *klass); \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static gsize static_g_define_type_id = 0; \ + if (g_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = \ + g_type_register_static_simple (G_TYPE_INTERFACE, \ + g_intern_static_string (#TypeName), \ + sizeof (TypeName##Interface), \ + (GClassInitFunc)(void (*)(void)) type_name##_default_init, \ + 0, \ + (GInstanceInitFunc)NULL, \ + (GTypeFlags) 0); \ + if (TYPE_PREREQ != G_TYPE_INVALID) \ + g_type_interface_add_prerequisite (g_define_type_id, TYPE_PREREQ); \ + { /* custom code follows */ +#define _G_DEFINE_INTERFACE_EXTENDED_END() \ + /* following custom code */ \ + } \ + g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} /* closes type_name##_get_type() */ + +/** + * G_DEFINE_BOXED_TYPE: + * @TypeName: The name of the new type, in Camel case + * @type_name: The name of the new type, in lowercase, with words + * separated by '_' + * @copy_func: the #GBoxedCopyFunc for the new type + * @free_func: the #GBoxedFreeFunc for the new type + * + * A convenience macro for boxed type implementations, which defines a + * type_name_get_type() function registering the boxed type. + * + * Since: 2.26 + */ +#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {}) +/** + * G_DEFINE_BOXED_TYPE_WITH_CODE: + * @TypeName: The name of the new type, in Camel case + * @type_name: The name of the new type, in lowercase, with words + * separated by '_' + * @copy_func: the #GBoxedCopyFunc for the new type + * @free_func: the #GBoxedFreeFunc for the new type + * @_C_: Custom code that gets inserted in the *_get_type() function + * + * A convenience macro for boxed type implementations. + * Similar to G_DEFINE_BOXED_TYPE(), but allows to insert custom code into the + * type_name_get_type() function, e.g. to register value transformations with + * g_value_register_transform_func(), for instance: + * + * |[ + * G_DEFINE_BOXED_TYPE_WITH_CODE (GdkRectangle, gdk_rectangle, + * gdk_rectangle_copy, + * gdk_rectangle_free, + * register_rectangle_transform_funcs (g_define_type_id)) + * ]| + * + * Similarly to the %G_DEFINE_TYPE family of macros, the #GType of the newly + * defined boxed type is exposed in the `g_define_type_id` variable. + * + * Since: 2.26 + */ +#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() + +/* Only use this in non-C++ on GCC >= 2.7, except for Darwin/ppc64. + * See https://bugzilla.gnome.org/show_bug.cgi?id=647145 + */ +#if !defined (__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !(defined (__APPLE__) && defined (__ppc64__)) +#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \ +static GType type_name##_get_type_once (void); \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static gsize static_g_define_type_id = 0; \ + if (g_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = type_name##_get_type_once (); \ + g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} \ +\ +G_GNUC_NO_INLINE \ +static GType \ +type_name##_get_type_once (void) \ +{ \ + GType (* _g_register_boxed) \ + (const gchar *, \ + union \ + { \ + TypeName * (*do_copy_type) (TypeName *); \ + TypeName * (*do_const_copy_type) (const TypeName *); \ + GBoxedCopyFunc do_copy_boxed; \ + } __attribute__((__transparent_union__)), \ + union \ + { \ + void (* do_free_type) (TypeName *); \ + GBoxedFreeFunc do_free_boxed; \ + } __attribute__((__transparent_union__)) \ + ) = g_boxed_type_register_static; \ + GType g_define_type_id = \ + _g_register_boxed (g_intern_static_string (#TypeName), copy_func, free_func); \ + { /* custom code follows */ +#else +#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \ +static GType type_name##_get_type_once (void); \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static gsize static_g_define_type_id = 0; \ + if (g_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = type_name##_get_type_once (); \ + g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} \ +\ +G_GNUC_NO_INLINE \ +static GType \ +type_name##_get_type_once (void) \ +{ \ + GType g_define_type_id = \ + g_boxed_type_register_static (g_intern_static_string (#TypeName), \ + (GBoxedCopyFunc) copy_func, \ + (GBoxedFreeFunc) free_func); \ + { /* custom code follows */ +#endif /* __GNUC__ */ + +/** + * G_DEFINE_POINTER_TYPE: + * @TypeName: The name of the new type, in Camel case + * @type_name: The name of the new type, in lowercase, with words + * separated by '_' + * + * A convenience macro for pointer type implementations, which defines a + * type_name_get_type() function registering the pointer type. + * + * Since: 2.26 + */ +#define G_DEFINE_POINTER_TYPE(TypeName, type_name) G_DEFINE_POINTER_TYPE_WITH_CODE (TypeName, type_name, {}) +/** + * G_DEFINE_POINTER_TYPE_WITH_CODE: + * @TypeName: The name of the new type, in Camel case + * @type_name: The name of the new type, in lowercase, with words + * separated by '_' + * @_C_: Custom code that gets inserted in the *_get_type() function + * + * A convenience macro for pointer type implementations. + * Similar to G_DEFINE_POINTER_TYPE(), but allows to insert + * custom code into the type_name_get_type() function. + * + * Since: 2.26 + */ +#define G_DEFINE_POINTER_TYPE_WITH_CODE(TypeName, type_name, _C_) _G_DEFINE_POINTER_TYPE_BEGIN (TypeName, type_name) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() + +#define _G_DEFINE_POINTER_TYPE_BEGIN(TypeName, type_name) \ +static GType type_name##_get_type_once (void); \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + static gsize static_g_define_type_id = 0; \ + if (g_once_init_enter (&static_g_define_type_id)) \ + { \ + GType g_define_type_id = type_name##_get_type_once (); \ + g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ + } \ + return static_g_define_type_id; \ +} \ +\ +G_GNUC_NO_INLINE \ +static GType \ +type_name##_get_type_once (void) \ +{ \ + GType g_define_type_id = \ + g_pointer_type_register_static (g_intern_static_string (#TypeName)); \ + { /* custom code follows */ + +/* --- protected (for fundamental type implementations) --- */ +GLIB_AVAILABLE_IN_ALL +GTypePlugin* g_type_get_plugin (GType type); +GLIB_AVAILABLE_IN_ALL +GTypePlugin* g_type_interface_get_plugin (GType instance_type, + GType interface_type); +GLIB_AVAILABLE_IN_ALL +GType g_type_fundamental_next (void); +GLIB_AVAILABLE_IN_ALL +GType g_type_fundamental (GType type_id); +GLIB_AVAILABLE_IN_ALL +GTypeInstance* g_type_create_instance (GType type); +GLIB_AVAILABLE_IN_ALL +void g_type_free_instance (GTypeInstance *instance); + +GLIB_AVAILABLE_IN_ALL +void g_type_add_class_cache_func (gpointer cache_data, + GTypeClassCacheFunc cache_func); +GLIB_AVAILABLE_IN_ALL +void g_type_remove_class_cache_func (gpointer cache_data, + GTypeClassCacheFunc cache_func); +GLIB_AVAILABLE_IN_ALL +void g_type_class_unref_uncached (gpointer g_class); + +GLIB_AVAILABLE_IN_ALL +void g_type_add_interface_check (gpointer check_data, + GTypeInterfaceCheckFunc check_func); +GLIB_AVAILABLE_IN_ALL +void g_type_remove_interface_check (gpointer check_data, + GTypeInterfaceCheckFunc check_func); + +GLIB_AVAILABLE_IN_ALL +GTypeValueTable* g_type_value_table_peek (GType type); + + +/*< private >*/ +GLIB_AVAILABLE_IN_ALL +gboolean g_type_check_instance (GTypeInstance *instance) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +GTypeInstance* g_type_check_instance_cast (GTypeInstance *instance, + GType iface_type); +GLIB_AVAILABLE_IN_ALL +gboolean g_type_check_instance_is_a (GTypeInstance *instance, + GType iface_type) G_GNUC_PURE; +GLIB_AVAILABLE_IN_2_42 +gboolean g_type_check_instance_is_fundamentally_a (GTypeInstance *instance, + GType fundamental_type) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +GTypeClass* g_type_check_class_cast (GTypeClass *g_class, + GType is_a_type); +GLIB_AVAILABLE_IN_ALL +gboolean g_type_check_class_is_a (GTypeClass *g_class, + GType is_a_type) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gboolean g_type_check_is_value_type (GType type) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_type_check_value (const GValue *value) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gboolean g_type_check_value_holds (const GValue *value, + GType type) G_GNUC_PURE; +GLIB_AVAILABLE_IN_ALL +gboolean g_type_test_flags (GType type, + guint flags) G_GNUC_CONST; + + +/* --- debugging functions --- */ +GLIB_AVAILABLE_IN_ALL +const gchar * g_type_name_from_instance (GTypeInstance *instance); +GLIB_AVAILABLE_IN_ALL +const gchar * g_type_name_from_class (GTypeClass *g_class); + + +/* --- implementation bits --- */ +#ifndef G_DISABLE_CAST_CHECKS +# define _G_TYPE_CIC(ip, gt, ct) \ + ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) +# define _G_TYPE_CCC(cp, gt, ct) \ + ((ct*) g_type_check_class_cast ((GTypeClass*) cp, gt)) +#else /* G_DISABLE_CAST_CHECKS */ +# define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip) +# define _G_TYPE_CCC(cp, gt, ct) ((ct*) cp) +#endif /* G_DISABLE_CAST_CHECKS */ +#define _G_TYPE_CHI(ip) (g_type_check_instance ((GTypeInstance*) ip)) +#define _G_TYPE_CHV(vl) (g_type_check_value ((GValue*) vl)) +#define _G_TYPE_IGC(ip, gt, ct) ((ct*) (((GTypeInstance*) ip)->g_class)) +#define _G_TYPE_IGI(ip, gt, ct) ((ct*) g_type_interface_peek (((GTypeInstance*) ip)->g_class, gt)) +#define _G_TYPE_CIFT(ip, ft) (g_type_check_instance_is_fundamentally_a ((GTypeInstance*) ip, ft)) +#ifdef __GNUC__ +# define _G_TYPE_CIT(ip, gt) (G_GNUC_EXTENSION ({ \ + GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \ + if (!__inst) \ + __r = FALSE; \ + else if (__inst->g_class && __inst->g_class->g_type == __t) \ + __r = TRUE; \ + else \ + __r = g_type_check_instance_is_a (__inst, __t); \ + __r; \ +})) +# define _G_TYPE_CCT(cp, gt) (G_GNUC_EXTENSION ({ \ + GTypeClass *__class = (GTypeClass*) cp; GType __t = gt; gboolean __r; \ + if (!__class) \ + __r = FALSE; \ + else if (__class->g_type == __t) \ + __r = TRUE; \ + else \ + __r = g_type_check_class_is_a (__class, __t); \ + __r; \ +})) +# define _G_TYPE_CVH(vl, gt) (G_GNUC_EXTENSION ({ \ + const GValue *__val = (const GValue*) vl; GType __t = gt; gboolean __r; \ + if (!__val) \ + __r = FALSE; \ + else if (__val->g_type == __t) \ + __r = TRUE; \ + else \ + __r = g_type_check_value_holds (__val, __t); \ + __r; \ +})) +#else /* !__GNUC__ */ +# define _G_TYPE_CIT(ip, gt) (g_type_check_instance_is_a ((GTypeInstance*) ip, gt)) +# define _G_TYPE_CCT(cp, gt) (g_type_check_class_is_a ((GTypeClass*) cp, gt)) +# define _G_TYPE_CVH(vl, gt) (g_type_check_value_holds ((const GValue*) vl, gt)) +#endif /* !__GNUC__ */ +/** + * G_TYPE_FLAG_RESERVED_ID_BIT: + * + * A bit in the type number that's supposed to be left untouched. + */ +#define G_TYPE_FLAG_RESERVED_ID_BIT ((GType) (1 << 0)) + +G_END_DECLS + +#endif /* __G_TYPE_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gvalue.h: generic GValue functions + */ +#ifndef __G_VALUE_H__ +#define __G_VALUE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_TYPE_IS_VALUE: + * @type: A #GType value. + * + * Checks whether the passed in type ID can be used for g_value_init(). + * That is, this macro checks whether this type provides an implementation + * of the #GTypeValueTable functions required for a type to create a #GValue of. + * + * Returns: Whether @type is suitable as a #GValue type. + */ +#define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type)) +/** + * G_IS_VALUE: + * @value: A #GValue structure. + * + * Checks if @value is a valid and initialized #GValue structure. + * + * Returns: %TRUE on success. + */ +#define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value)) +/** + * G_VALUE_TYPE: + * @value: A #GValue structure. + * + * Get the type identifier of @value. + * + * Returns: the #GType. + */ +#define G_VALUE_TYPE(value) (((GValue*) (value))->g_type) +/** + * G_VALUE_TYPE_NAME: + * @value: A #GValue structure. + * + * Gets the type name of @value. + * + * Returns: the type name. + */ +#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value))) +/** + * G_VALUE_HOLDS: + * @value: A #GValue structure. + * @type: A #GType value. + * + * Checks if @value holds (or contains) a value of @type. + * This macro will also check for @value != %NULL and issue a + * warning if the check fails. + * + * Returns: %TRUE if @value holds the @type. + */ +#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type))) + + +/* --- typedefs & structures --- */ +/** + * GValueTransform: + * @src_value: Source value. + * @dest_value: Target value. + * + * The type of value transformation functions which can be registered with + * g_value_register_transform_func(). + * + * @dest_value will be initialized to the correct destination type. + */ +typedef void (*GValueTransform) (const GValue *src_value, + GValue *dest_value); +/** + * GValue: + * + * An opaque structure used to hold different types of values. + * The data within the structure has protected scope: it is accessible only + * to functions within a #GTypeValueTable structure, or implementations of + * the g_value_*() API. That is, code portions which implement new fundamental + * types. + * #GValue users cannot make any assumptions about how data is stored + * within the 2 element @data union, and the @g_type member should + * only be accessed through the G_VALUE_TYPE() macro. + */ +struct _GValue +{ + /*< private >*/ + GType g_type; + + /* public for GTypeValueTable methods */ + union { + gint v_int; + guint v_uint; + glong v_long; + gulong v_ulong; + gint64 v_int64; + guint64 v_uint64; + gfloat v_float; + gdouble v_double; + gpointer v_pointer; + } data[2]; +}; + + +/* --- prototypes --- */ +GLIB_AVAILABLE_IN_ALL +GValue* g_value_init (GValue *value, + GType g_type); +GLIB_AVAILABLE_IN_ALL +void g_value_copy (const GValue *src_value, + GValue *dest_value); +GLIB_AVAILABLE_IN_ALL +GValue* g_value_reset (GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_unset (GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_instance (GValue *value, + gpointer instance); +GLIB_AVAILABLE_IN_2_42 +void g_value_init_from_instance (GValue *value, + gpointer instance); + + +/* --- private --- */ +GLIB_AVAILABLE_IN_ALL +gboolean g_value_fits_pointer (const GValue *value); +GLIB_AVAILABLE_IN_ALL +gpointer g_value_peek_pointer (const GValue *value); + + +/* --- implementation details --- */ +GLIB_AVAILABLE_IN_ALL +gboolean g_value_type_compatible (GType src_type, + GType dest_type); +GLIB_AVAILABLE_IN_ALL +gboolean g_value_type_transformable (GType src_type, + GType dest_type); +GLIB_AVAILABLE_IN_ALL +gboolean g_value_transform (const GValue *src_value, + GValue *dest_value); +GLIB_AVAILABLE_IN_ALL +void g_value_register_transform_func (GType src_type, + GType dest_type, + GValueTransform transform_func); + +/** + * G_VALUE_NOCOPY_CONTENTS: + * + * If passed to G_VALUE_COLLECT(), allocated data won't be copied + * but used verbatim. This does not affect ref-counted types like + * objects. This does not affect usage of g_value_copy(), the data will + * be copied if it is not ref-counted. + */ +#define G_VALUE_NOCOPY_CONTENTS (1 << 27) + +/** + * G_VALUE_INTERNED_STRING: + * + * For string values, indicates that the string contained is canonical and will + * exist for the duration of the process. See g_value_set_interned_string(). + * + * Since: 2.66 + */ +#define G_VALUE_INTERNED_STRING (1 << 28) GLIB_AVAILABLE_MACRO_IN_2_66 + +/** + * G_VALUE_INIT: + * + * A #GValue must be initialized before it can be used. This macro can + * be used as initializer instead of an explicit `{ 0 }` when declaring + * a variable, but it cannot be assigned to a variable. + * + * |[ + * GValue value = G_VALUE_INIT; + * ]| + * + * Since: 2.30 + */ +#define G_VALUE_INIT { 0, { { 0 } } } + + +G_END_DECLS + +#endif /* __G_VALUE_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gparam.h: GParamSpec base class implementation + */ +#ifndef __G_PARAM_H__ +#define __G_PARAM_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* --- standard type macros --- */ +/** + * G_TYPE_IS_PARAM: + * @type: a #GType ID + * + * Checks whether @type "is a" %G_TYPE_PARAM. + */ +#define G_TYPE_IS_PARAM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_PARAM) +/** + * G_PARAM_SPEC: + * @pspec: a valid #GParamSpec + * + * Casts a derived #GParamSpec object (e.g. of type #GParamSpecInt) into + * a #GParamSpec object. + */ +#define G_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM, GParamSpec)) +/** + * G_IS_PARAM_SPEC: + * @pspec: a #GParamSpec + * + * Checks whether @pspec "is a" valid #GParamSpec structure of type %G_TYPE_PARAM + * or derived. + */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_42 +#define G_IS_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE ((pspec), G_TYPE_PARAM)) +#else +#define G_IS_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM)) +#endif +/** + * G_PARAM_SPEC_CLASS: + * @pclass: a valid #GParamSpecClass + * + * Casts a derived #GParamSpecClass structure into a #GParamSpecClass structure. + */ +#define G_PARAM_SPEC_CLASS(pclass) (G_TYPE_CHECK_CLASS_CAST ((pclass), G_TYPE_PARAM, GParamSpecClass)) +/** + * G_IS_PARAM_SPEC_CLASS: + * @pclass: a #GParamSpecClass + * + * Checks whether @pclass "is a" valid #GParamSpecClass structure of type + * %G_TYPE_PARAM or derived. + */ +#define G_IS_PARAM_SPEC_CLASS(pclass) (G_TYPE_CHECK_CLASS_TYPE ((pclass), G_TYPE_PARAM)) +/** + * G_PARAM_SPEC_GET_CLASS: + * @pspec: a valid #GParamSpec + * + * Retrieves the #GParamSpecClass of a #GParamSpec. + */ +#define G_PARAM_SPEC_GET_CLASS(pspec) (G_TYPE_INSTANCE_GET_CLASS ((pspec), G_TYPE_PARAM, GParamSpecClass)) + + +/* --- convenience macros --- */ +/** + * G_PARAM_SPEC_TYPE: + * @pspec: a valid #GParamSpec + * + * Retrieves the #GType of this @pspec. + */ +#define G_PARAM_SPEC_TYPE(pspec) (G_TYPE_FROM_INSTANCE (pspec)) +/** + * G_PARAM_SPEC_TYPE_NAME: + * @pspec: a valid #GParamSpec + * + * Retrieves the #GType name of this @pspec. + */ +#define G_PARAM_SPEC_TYPE_NAME(pspec) (g_type_name (G_PARAM_SPEC_TYPE (pspec))) +/** + * G_PARAM_SPEC_VALUE_TYPE: + * @pspec: a valid #GParamSpec + * + * Retrieves the #GType to initialize a #GValue for this parameter. + */ +#define G_PARAM_SPEC_VALUE_TYPE(pspec) (G_PARAM_SPEC (pspec)->value_type) +/** + * G_VALUE_HOLDS_PARAM: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived from type %G_TYPE_PARAM. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_PARAM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_PARAM)) + + +/* --- flags --- */ +/** + * GParamFlags: + * @G_PARAM_READABLE: the parameter is readable + * @G_PARAM_WRITABLE: the parameter is writable + * @G_PARAM_READWRITE: alias for %G_PARAM_READABLE | %G_PARAM_WRITABLE + * @G_PARAM_CONSTRUCT: the parameter will be set upon object construction + * @G_PARAM_CONSTRUCT_ONLY: the parameter can only be set upon object construction + * @G_PARAM_LAX_VALIDATION: upon parameter conversion (see g_param_value_convert()) + * strict validation is not required + * @G_PARAM_STATIC_NAME: the string used as name when constructing the + * parameter is guaranteed to remain valid and + * unmodified for the lifetime of the parameter. + * Since 2.8 + * @G_PARAM_STATIC_NICK: the string used as nick when constructing the + * parameter is guaranteed to remain valid and + * unmmodified for the lifetime of the parameter. + * Since 2.8 + * @G_PARAM_STATIC_BLURB: the string used as blurb when constructing the + * parameter is guaranteed to remain valid and + * unmodified for the lifetime of the parameter. + * Since 2.8 + * @G_PARAM_EXPLICIT_NOTIFY: calls to g_object_set_property() for this + * property will not automatically result in a "notify" signal being + * emitted: the implementation must call g_object_notify() themselves + * in case the property actually changes. Since: 2.42. + * @G_PARAM_PRIVATE: internal + * @G_PARAM_DEPRECATED: the parameter is deprecated and will be removed + * in a future version. A warning will be generated if it is used + * while running with G_ENABLE_DIAGNOSTIC=1. + * Since 2.26 + * + * Through the #GParamFlags flag values, certain aspects of parameters + * can be configured. See also #G_PARAM_STATIC_STRINGS. + */ +typedef enum +{ + G_PARAM_READABLE = 1 << 0, + G_PARAM_WRITABLE = 1 << 1, + G_PARAM_READWRITE = (G_PARAM_READABLE | G_PARAM_WRITABLE), + G_PARAM_CONSTRUCT = 1 << 2, + G_PARAM_CONSTRUCT_ONLY = 1 << 3, + G_PARAM_LAX_VALIDATION = 1 << 4, + G_PARAM_STATIC_NAME = 1 << 5, + G_PARAM_PRIVATE GLIB_DEPRECATED_ENUMERATOR_IN_2_26 = G_PARAM_STATIC_NAME, + G_PARAM_STATIC_NICK = 1 << 6, + G_PARAM_STATIC_BLURB = 1 << 7, + /* User defined flags go here */ + G_PARAM_EXPLICIT_NOTIFY = 1 << 30, + /* Avoid warning with -Wpedantic for gcc6 */ + G_PARAM_DEPRECATED = (gint)(1u << 31) +} GParamFlags; + +/** + * G_PARAM_STATIC_STRINGS: + * + * #GParamFlags value alias for %G_PARAM_STATIC_NAME | %G_PARAM_STATIC_NICK | %G_PARAM_STATIC_BLURB. + * + * Since 2.13.0 + */ +#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) +/* bits in the range 0xffffff00 are reserved for 3rd party usage */ +/** + * G_PARAM_MASK: + * + * Mask containing the bits of #GParamSpec.flags which are reserved for GLib. + */ +#define G_PARAM_MASK (0x000000ff) +/** + * G_PARAM_USER_SHIFT: + * + * Minimum shift count to be used for user defined flags, to be stored in + * #GParamSpec.flags. The maximum allowed is 10. + */ +#define G_PARAM_USER_SHIFT (8) + +/* --- typedefs & structures --- */ +typedef struct _GParamSpec GParamSpec; +typedef struct _GParamSpecClass GParamSpecClass; +typedef struct _GParameter GParameter GLIB_DEPRECATED_TYPE_IN_2_54; +typedef struct _GParamSpecPool GParamSpecPool; +/** + * GParamSpec: (ref-func g_param_spec_ref_sink) (unref-func g_param_spec_uref) (set-value-func g_value_set_param) (get-value-func g_value_get_param) + * @g_type_instance: private #GTypeInstance portion + * @name: name of this parameter: always an interned string + * @flags: #GParamFlags flags for this parameter + * @value_type: the #GValue type for this parameter + * @owner_type: #GType type that uses (introduces) this parameter + * + * All other fields of the GParamSpec struct are private and + * should not be used directly. + */ +struct _GParamSpec +{ + GTypeInstance g_type_instance; + + const gchar *name; /* interned string */ + GParamFlags flags; + GType value_type; + GType owner_type; /* class or interface using this property */ + + /*< private >*/ + gchar *_nick; + gchar *_blurb; + GData *qdata; + guint ref_count; + guint param_id; /* sort-criteria */ +}; +/** + * GParamSpecClass: + * @g_type_class: the parent class + * @value_type: the #GValue type for this parameter + * @finalize: The instance finalization function (optional), should chain + * up to the finalize method of the parent class. + * @value_set_default: Resets a @value to the default value for this type + * (recommended, the default is g_value_reset()), see + * g_param_value_set_default(). + * @value_validate: Ensures that the contents of @value comply with the + * specifications set out by this type (optional), see + * g_param_value_validate(). + * @values_cmp: Compares @value1 with @value2 according to this type + * (recommended, the default is memcmp()), see g_param_values_cmp(). + * + * The class structure for the GParamSpec type. + * Normally, GParamSpec classes are filled by + * g_param_type_register_static(). + */ +struct _GParamSpecClass +{ + GTypeClass g_type_class; + + GType value_type; + + void (*finalize) (GParamSpec *pspec); + + /* GParam methods */ + void (*value_set_default) (GParamSpec *pspec, + GValue *value); + gboolean (*value_validate) (GParamSpec *pspec, + GValue *value); + gint (*values_cmp) (GParamSpec *pspec, + const GValue *value1, + const GValue *value2); + /*< private >*/ + gpointer dummy[4]; +}; +/** + * GParameter: + * @name: the parameter name + * @value: the parameter value + * + * The GParameter struct is an auxiliary structure used + * to hand parameter name/value pairs to g_object_newv(). + * + * Deprecated: 2.54: This type is not introspectable. + */ +struct _GParameter /* auxiliary structure for _setv() variants */ +{ + const gchar *name; + GValue value; +} GLIB_DEPRECATED_TYPE_IN_2_54; + + +/* --- prototypes --- */ +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_ref (GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +void g_param_spec_unref (GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +void g_param_spec_sink (GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_ref_sink (GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +gpointer g_param_spec_get_qdata (GParamSpec *pspec, + GQuark quark); +GLIB_AVAILABLE_IN_ALL +void g_param_spec_set_qdata (GParamSpec *pspec, + GQuark quark, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_param_spec_set_qdata_full (GParamSpec *pspec, + GQuark quark, + gpointer data, + GDestroyNotify destroy); +GLIB_AVAILABLE_IN_ALL +gpointer g_param_spec_steal_qdata (GParamSpec *pspec, + GQuark quark); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_get_redirect_target (GParamSpec *pspec); + +GLIB_AVAILABLE_IN_ALL +void g_param_value_set_default (GParamSpec *pspec, + GValue *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_param_value_defaults (GParamSpec *pspec, + const GValue *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_param_value_validate (GParamSpec *pspec, + GValue *value); +GLIB_AVAILABLE_IN_ALL +gboolean g_param_value_convert (GParamSpec *pspec, + const GValue *src_value, + GValue *dest_value, + gboolean strict_validation); +GLIB_AVAILABLE_IN_ALL +gint g_param_values_cmp (GParamSpec *pspec, + const GValue *value1, + const GValue *value2); +GLIB_AVAILABLE_IN_ALL +const gchar * g_param_spec_get_name (GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +const gchar * g_param_spec_get_nick (GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +const gchar * g_param_spec_get_blurb (GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +void g_value_set_param (GValue *value, + GParamSpec *param); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_value_get_param (const GValue *value); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_value_dup_param (const GValue *value); + + +GLIB_AVAILABLE_IN_ALL +void g_value_take_param (GValue *value, + GParamSpec *param); +GLIB_DEPRECATED_FOR(g_value_take_param) +void g_value_set_param_take_ownership (GValue *value, + GParamSpec *param); +GLIB_AVAILABLE_IN_2_36 +const GValue * g_param_spec_get_default_value (GParamSpec *pspec); + +GLIB_AVAILABLE_IN_2_46 +GQuark g_param_spec_get_name_quark (GParamSpec *pspec); + +/* --- convenience functions --- */ +typedef struct _GParamSpecTypeInfo GParamSpecTypeInfo; +/** + * GParamSpecTypeInfo: + * @instance_size: Size of the instance (object) structure. + * @n_preallocs: Prior to GLib 2.10, it specified the number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching). Since GLib 2.10, it is ignored, since instances are allocated with the [slice allocator][glib-Memory-Slices] now. + * @instance_init: Location of the instance initialization function (optional). + * @value_type: The #GType of values conforming to this #GParamSpec + * @finalize: The instance finalization function (optional). + * @value_set_default: Resets a @value to the default value for @pspec + * (recommended, the default is g_value_reset()), see + * g_param_value_set_default(). + * @value_validate: Ensures that the contents of @value comply with the + * specifications set out by @pspec (optional), see + * g_param_value_validate(). + * @values_cmp: Compares @value1 with @value2 according to @pspec + * (recommended, the default is memcmp()), see g_param_values_cmp(). + * + * This structure is used to provide the type system with the information + * required to initialize and destruct (finalize) a parameter's class and + * instances thereof. + * The initialized structure is passed to the g_param_type_register_static() + * The type system will perform a deep copy of this structure, so its memory + * does not need to be persistent across invocation of + * g_param_type_register_static(). + */ +struct _GParamSpecTypeInfo +{ + /* type system portion */ + guint16 instance_size; /* obligatory */ + guint16 n_preallocs; /* optional */ + void (*instance_init) (GParamSpec *pspec); /* optional */ + + /* class portion */ + GType value_type; /* obligatory */ + void (*finalize) (GParamSpec *pspec); /* optional */ + void (*value_set_default) (GParamSpec *pspec, /* recommended */ + GValue *value); + gboolean (*value_validate) (GParamSpec *pspec, /* optional */ + GValue *value); + gint (*values_cmp) (GParamSpec *pspec, /* recommended */ + const GValue *value1, + const GValue *value2); +}; +GLIB_AVAILABLE_IN_ALL +GType g_param_type_register_static (const gchar *name, + const GParamSpecTypeInfo *pspec_info); + +GLIB_AVAILABLE_IN_2_66 +gboolean g_param_spec_is_valid_name (const gchar *name); + +/* For registering builting types */ +GType _g_param_type_register_static_constant (const gchar *name, + const GParamSpecTypeInfo *pspec_info, + GType opt_type); + + +/* --- protected --- */ +GLIB_AVAILABLE_IN_ALL +gpointer g_param_spec_internal (GType param_type, + const gchar *name, + const gchar *nick, + const gchar *blurb, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpecPool* g_param_spec_pool_new (gboolean type_prefixing); +GLIB_AVAILABLE_IN_ALL +void g_param_spec_pool_insert (GParamSpecPool *pool, + GParamSpec *pspec, + GType owner_type); +GLIB_AVAILABLE_IN_ALL +void g_param_spec_pool_remove (GParamSpecPool *pool, + GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_pool_lookup (GParamSpecPool *pool, + const gchar *param_name, + GType owner_type, + gboolean walk_ancestors); +GLIB_AVAILABLE_IN_ALL +GList* g_param_spec_pool_list_owned (GParamSpecPool *pool, + GType owner_type); +GLIB_AVAILABLE_IN_ALL +GParamSpec** g_param_spec_pool_list (GParamSpecPool *pool, + GType owner_type, + guint *n_pspecs_p); + + +/* contracts: + * + * gboolean value_validate (GParamSpec *pspec, + * GValue *value): + * modify value contents in the least destructive way, so + * that it complies with pspec's requirements (i.e. + * according to minimum/maximum ranges etc...). return + * whether modification was necessary. + * + * gint values_cmp (GParamSpec *pspec, + * const GValue *value1, + * const GValue *value2): + * return value1 - value2, i.e. (-1) if value1 < value2, + * (+1) if value1 > value2, and (0) otherwise (equality) + */ + +G_END_DECLS + +#endif /* __G_PARAM_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000-2001 Red Hat, Inc. + * Copyright (C) 2005 Imendio AB + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_CLOSURE_H__ +#define __G_CLOSURE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* --- defines --- */ +/** + * G_CLOSURE_NEEDS_MARSHAL: + * @closure: a #GClosure + * + * Check if the closure still needs a marshaller. See g_closure_set_marshal(). + * + * Returns: %TRUE if a #GClosureMarshal marshaller has not yet been set on + * @closure. + */ +#define G_CLOSURE_NEEDS_MARSHAL(closure) (((GClosure*) (closure))->marshal == NULL) +/** + * G_CLOSURE_N_NOTIFIERS: + * @cl: a #GClosure + * + * Get the total number of notifiers connected with the closure @cl. + * The count includes the meta marshaller, the finalize and invalidate notifiers + * and the marshal guards. Note that each guard counts as two notifiers. + * See g_closure_set_meta_marshal(), g_closure_add_finalize_notifier(), + * g_closure_add_invalidate_notifier() and g_closure_add_marshal_guards(). + * + * Returns: number of notifiers + */ +#define G_CLOSURE_N_NOTIFIERS(cl) (((cl)->n_guards << 1L) + \ + (cl)->n_fnotifiers + (cl)->n_inotifiers) +/** + * G_CCLOSURE_SWAP_DATA: + * @cclosure: a #GCClosure + * + * Checks whether the user data of the #GCClosure should be passed as the + * first parameter to the callback. See g_cclosure_new_swap(). + * + * Returns: %TRUE if data has to be swapped. + */ +#define G_CCLOSURE_SWAP_DATA(cclosure) (((GClosure*) (cclosure))->derivative_flag) +/** + * G_CALLBACK: + * @f: a function pointer. + * + * Cast a function pointer to a #GCallback. + */ +#define G_CALLBACK(f) ((GCallback) (f)) + + +/* -- typedefs --- */ +typedef struct _GClosure GClosure; +typedef struct _GClosureNotifyData GClosureNotifyData; + +/** + * GCallback: + * + * The type used for callback functions in structure definitions and function + * signatures. This doesn't mean that all callback functions must take no + * parameters and return void. The required signature of a callback function + * is determined by the context in which is used (e.g. the signal to which it + * is connected). Use G_CALLBACK() to cast the callback function to a #GCallback. + */ +typedef void (*GCallback) (void); +/** + * GClosureNotify: + * @data: data specified when registering the notification callback + * @closure: the #GClosure on which the notification is emitted + * + * The type used for the various notification callbacks which can be registered + * on closures. + */ +typedef void (*GClosureNotify) (gpointer data, + GClosure *closure); +/** + * GClosureMarshal: + * @closure: the #GClosure to which the marshaller belongs + * @return_value: (nullable): a #GValue to store the return + * value. May be %NULL if the callback of @closure doesn't return a + * value. + * @n_param_values: the length of the @param_values array + * @param_values: (array length=n_param_values): an array of + * #GValues holding the arguments on which to invoke the + * callback of @closure + * @invocation_hint: (nullable): the invocation hint given as the + * last argument to g_closure_invoke() + * @marshal_data: (nullable): additional data specified when + * registering the marshaller, see g_closure_set_marshal() and + * g_closure_set_meta_marshal() + * + * The type used for marshaller functions. + */ +typedef void (*GClosureMarshal) (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/** + * GVaClosureMarshal: + * @closure: the #GClosure to which the marshaller belongs + * @return_value: (nullable): a #GValue to store the return + * value. May be %NULL if the callback of @closure doesn't return a + * value. + * @instance: (type GObject.TypeInstance): the instance on which the closure is + * invoked. + * @args: va_list of arguments to be passed to the closure. + * @marshal_data: (nullable): additional data specified when + * registering the marshaller, see g_closure_set_marshal() and + * g_closure_set_meta_marshal() + * @n_params: the length of the @param_types array + * @param_types: (array length=n_params): the #GType of each argument from + * @args. + * + * This is the signature of va_list marshaller functions, an optional + * marshaller that can be used in some situations to avoid + * marshalling the signal argument into GValues. + */ +typedef void (* GVaClosureMarshal) (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/** + * GCClosure: + * @closure: the #GClosure + * @callback: the callback function + * + * A #GCClosure is a specialization of #GClosure for C function callbacks. + */ +typedef struct _GCClosure GCClosure; + + +/* --- structures --- */ +struct _GClosureNotifyData +{ + gpointer data; + GClosureNotify notify; +}; +/** + * GClosure: + * @in_marshal: Indicates whether the closure is currently being invoked with + * g_closure_invoke() + * @is_invalid: Indicates whether the closure has been invalidated by + * g_closure_invalidate() + * + * A #GClosure represents a callback supplied by the programmer. + */ +struct _GClosure +{ + /*< private >*/ + guint ref_count : 15; /* (atomic) */ + /* meta_marshal is not used anymore but must be zero for historical reasons + as it was exposed in the G_CLOSURE_N_NOTIFIERS macro */ + guint meta_marshal_nouse : 1; /* (atomic) */ + guint n_guards : 1; /* (atomic) */ + guint n_fnotifiers : 2; /* finalization notifiers (atomic) */ + guint n_inotifiers : 8; /* invalidation notifiers (atomic) */ + guint in_inotify : 1; /* (atomic) */ + guint floating : 1; /* (atomic) */ + /*< protected >*/ + guint derivative_flag : 1; /* (atomic) */ + /*< public >*/ + guint in_marshal : 1; /* (atomic) */ + guint is_invalid : 1; /* (atomic) */ + + /*< private >*/ void (*marshal) (GClosure *closure, + GValue /*out*/ *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + /*< protected >*/ gpointer data; + + /*< private >*/ GClosureNotifyData *notifiers; + + /* invariants/constraints: + * - ->marshal and ->data are _invalid_ as soon as ->is_invalid==TRUE + * - invocation of all inotifiers occurs prior to fnotifiers + * - order of inotifiers is random + * inotifiers may _not_ free/invalidate parameter values (e.g. ->data) + * - order of fnotifiers is random + * - each notifier may only be removed before or during its invocation + * - reference counting may only happen prior to fnotify invocation + * (in that sense, fnotifiers are really finalization handlers) + */ +}; +/* closure for C function calls, callback() is the user function + */ +struct _GCClosure +{ + GClosure closure; + gpointer callback; +}; + + +/* --- prototypes --- */ +GLIB_AVAILABLE_IN_ALL +GClosure* g_cclosure_new (GCallback callback_func, + gpointer user_data, + GClosureNotify destroy_data); +GLIB_AVAILABLE_IN_ALL +GClosure* g_cclosure_new_swap (GCallback callback_func, + gpointer user_data, + GClosureNotify destroy_data); +GLIB_AVAILABLE_IN_ALL +GClosure* g_signal_type_cclosure_new (GType itype, + guint struct_offset); + + +/* --- prototypes --- */ +GLIB_AVAILABLE_IN_ALL +GClosure* g_closure_ref (GClosure *closure); +GLIB_AVAILABLE_IN_ALL +void g_closure_sink (GClosure *closure); +GLIB_AVAILABLE_IN_ALL +void g_closure_unref (GClosure *closure); +/* intimidating */ +GLIB_AVAILABLE_IN_ALL +GClosure* g_closure_new_simple (guint sizeof_closure, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_closure_add_finalize_notifier (GClosure *closure, + gpointer notify_data, + GClosureNotify notify_func); +GLIB_AVAILABLE_IN_ALL +void g_closure_remove_finalize_notifier (GClosure *closure, + gpointer notify_data, + GClosureNotify notify_func); +GLIB_AVAILABLE_IN_ALL +void g_closure_add_invalidate_notifier (GClosure *closure, + gpointer notify_data, + GClosureNotify notify_func); +GLIB_AVAILABLE_IN_ALL +void g_closure_remove_invalidate_notifier (GClosure *closure, + gpointer notify_data, + GClosureNotify notify_func); +GLIB_AVAILABLE_IN_ALL +void g_closure_add_marshal_guards (GClosure *closure, + gpointer pre_marshal_data, + GClosureNotify pre_marshal_notify, + gpointer post_marshal_data, + GClosureNotify post_marshal_notify); +GLIB_AVAILABLE_IN_ALL +void g_closure_set_marshal (GClosure *closure, + GClosureMarshal marshal); +GLIB_AVAILABLE_IN_ALL +void g_closure_set_meta_marshal (GClosure *closure, + gpointer marshal_data, + GClosureMarshal meta_marshal); +GLIB_AVAILABLE_IN_ALL +void g_closure_invalidate (GClosure *closure); +GLIB_AVAILABLE_IN_ALL +void g_closure_invoke (GClosure *closure, + GValue /*out*/ *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint); + +/* FIXME: + OK: data_object::destroy -> closure_invalidate(); + MIS: closure_invalidate() -> disconnect(closure); + MIS: disconnect(closure) -> (unlink) closure_unref(); + OK: closure_finalize() -> g_free (data_string); + + random remarks: + - need marshaller repo with decent aliasing to base types + - provide marshaller collection, virtually covering anything out there +*/ + +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_generic (GClosure *closure, + GValue *return_gvalue, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_generic_va (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args_list, + gpointer marshal_data, + int n_params, + GType *param_types); + + +G_END_DECLS + +#endif /* __G_CLOSURE_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000-2001 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_SIGNAL_H__ +#define __G_SIGNAL_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +/* GObject - GLib Type, Object, Parameter and Signal Library + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ + +#ifndef __G_MARSHAL_H__ +#define __G_MARSHAL_H__ + +G_BEGIN_DECLS + +/* VOID:VOID */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__VOID (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__VOIDv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:BOOLEAN */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__BOOLEAN (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__BOOLEANv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:CHAR */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__CHAR (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__CHARv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:UCHAR */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UCHAR (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UCHARv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:INT */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__INT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__INTv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:UINT */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UINT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UINTv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:LONG */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__LONG (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__LONGv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:ULONG */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__ULONG (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__ULONGv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:ENUM */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__ENUM (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__ENUMv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:FLAGS */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__FLAGS (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__FLAGSv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:FLOAT */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__FLOAT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__FLOATv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:DOUBLE */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__DOUBLE (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__DOUBLEv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:STRING */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__STRINGv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:PARAM */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__PARAM (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__PARAMv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:BOXED */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__BOXED (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__BOXEDv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:POINTER */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__POINTERv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:OBJECT */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__OBJECT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__OBJECTv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:VARIANT */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__VARIANT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__VARIANTv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* VOID:UINT,POINTER */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UINT_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_VOID__UINT_POINTERv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* BOOL:FLAGS */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_BOOLEAN__FLAGS (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_BOOLEAN__FLAGSv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/** + * g_cclosure_marshal_BOOL__FLAGS: + * @closure: A #GClosure. + * @return_value: A #GValue to store the return value. May be %NULL + * if the callback of closure doesn't return a value. + * @n_param_values: The length of the @param_values array. + * @param_values: An array of #GValues holding the arguments + * on which to invoke the callback of closure. + * @invocation_hint: The invocation hint given as the last argument to + * g_closure_invoke(). + * @marshal_data: Additional data specified when registering the + * marshaller, see g_closure_set_marshal() and + * g_closure_set_meta_marshal() + * + * An old alias for g_cclosure_marshal_BOOLEAN__FLAGS(). + */ +#define g_cclosure_marshal_BOOL__FLAGS g_cclosure_marshal_BOOLEAN__FLAGS + +/* STRING:OBJECT,POINTER */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_STRING__OBJECT_POINTER (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_STRING__OBJECT_POINTERv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/* BOOL:BOXED,BOXED */ +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_BOOLEAN__BOXED_BOXED (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); +GLIB_AVAILABLE_IN_ALL +void g_cclosure_marshal_BOOLEAN__BOXED_BOXEDv (GClosure *closure, + GValue *return_value, + gpointer instance, + va_list args, + gpointer marshal_data, + int n_params, + GType *param_types); + +/** + * g_cclosure_marshal_BOOL__BOXED_BOXED: + * @closure: A #GClosure. + * @return_value: A #GValue to store the return value. May be %NULL + * if the callback of closure doesn't return a value. + * @n_param_values: The length of the @param_values array. + * @param_values: An array of #GValues holding the arguments + * on which to invoke the callback of closure. + * @invocation_hint: The invocation hint given as the last argument to + * g_closure_invoke(). + * @marshal_data: Additional data specified when registering the + * marshaller, see g_closure_set_marshal() and + * g_closure_set_meta_marshal() + * + * An old alias for g_cclosure_marshal_BOOLEAN__BOXED_BOXED(). + */ +#define g_cclosure_marshal_BOOL__BOXED_BOXED g_cclosure_marshal_BOOLEAN__BOXED_BOXED + +G_END_DECLS + +#endif /* __G_MARSHAL_H__ */ + +G_BEGIN_DECLS + +/* --- typedefs --- */ +typedef struct _GSignalQuery GSignalQuery; +typedef struct _GSignalInvocationHint GSignalInvocationHint; +/** + * GSignalCMarshaller: + * + * This is the signature of marshaller functions, required to marshall + * arrays of parameter values to signal emissions into C language callback + * invocations. It is merely an alias to #GClosureMarshal since the #GClosure + * mechanism takes over responsibility of actual function invocation for the + * signal system. + */ +typedef GClosureMarshal GSignalCMarshaller; +/** + * GSignalCVaMarshaller: + * + * This is the signature of va_list marshaller functions, an optional + * marshaller that can be used in some situations to avoid + * marshalling the signal argument into GValues. + */ +typedef GVaClosureMarshal GSignalCVaMarshaller; +/** + * GSignalEmissionHook: + * @ihint: Signal invocation hint, see #GSignalInvocationHint. + * @n_param_values: the number of parameters to the function, including + * the instance on which the signal was emitted. + * @param_values: (array length=n_param_values): the instance on which + * the signal was emitted, followed by the parameters of the emission. + * @data: user data associated with the hook. + * + * A simple function pointer to get invoked when the signal is emitted. This + * allows you to tie a hook to the signal type, so that it will trap all + * emissions of that signal, from any object. + * + * You may not attach these to signals created with the #G_SIGNAL_NO_HOOKS flag. + * + * Returns: whether it wants to stay connected. If it returns %FALSE, the signal + * hook is disconnected (and destroyed). + */ +typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint, + guint n_param_values, + const GValue *param_values, + gpointer data); +/** + * GSignalAccumulator: + * @ihint: Signal invocation hint, see #GSignalInvocationHint. + * @return_accu: Accumulator to collect callback return values in, this + * is the return value of the current signal emission. + * @handler_return: A #GValue holding the return value of the signal handler. + * @data: Callback data that was specified when creating the signal. + * + * The signal accumulator is a special callback function that can be used + * to collect return values of the various callbacks that are called + * during a signal emission. The signal accumulator is specified at signal + * creation time, if it is left %NULL, no accumulation of callback return + * values is performed. The return value of signal emissions is then the + * value returned by the last callback. + * + * Returns: The accumulator function returns whether the signal emission + * should be aborted. Returning %FALSE means to abort the + * current emission and %TRUE is returned for continuation. + */ +typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer data); + + +/* --- run, match and connect types --- */ +/** + * GSignalFlags: + * @G_SIGNAL_RUN_FIRST: Invoke the object method handler in the first emission stage. + * @G_SIGNAL_RUN_LAST: Invoke the object method handler in the third emission stage. + * @G_SIGNAL_RUN_CLEANUP: Invoke the object method handler in the last emission stage. + * @G_SIGNAL_NO_RECURSE: Signals being emitted for an object while currently being in + * emission for this very object will not be emitted recursively, + * but instead cause the first emission to be restarted. + * @G_SIGNAL_DETAILED: This signal supports "::detail" appendices to the signal name + * upon handler connections and emissions. + * @G_SIGNAL_ACTION: Action signals are signals that may freely be emitted on alive + * objects from user code via g_signal_emit() and friends, without + * the need of being embedded into extra code that performs pre or + * post emission adjustments on the object. They can also be thought + * of as object methods which can be called generically by + * third-party code. + * @G_SIGNAL_NO_HOOKS: No emissions hooks are supported for this signal. + * @G_SIGNAL_MUST_COLLECT: Varargs signal emission will always collect the + * arguments, even if there are no signal handlers connected. Since 2.30. + * @G_SIGNAL_DEPRECATED: The signal is deprecated and will be removed + * in a future version. A warning will be generated if it is connected while + * running with G_ENABLE_DIAGNOSTIC=1. Since 2.32. + * @G_SIGNAL_ACCUMULATOR_FIRST_RUN: Only used in #GSignalAccumulator accumulator + * functions for the #GSignalInvocationHint::run_type field to mark the first + * call to the accumulator function for a signal emission. Since 2.68. + * + * The signal flags are used to specify a signal's behaviour, the overall + * signal description outlines how especially the RUN flags control the + * stages of a signal emission. + */ +typedef enum +{ + G_SIGNAL_RUN_FIRST = 1 << 0, + G_SIGNAL_RUN_LAST = 1 << 1, + G_SIGNAL_RUN_CLEANUP = 1 << 2, + G_SIGNAL_NO_RECURSE = 1 << 3, + G_SIGNAL_DETAILED = 1 << 4, + G_SIGNAL_ACTION = 1 << 5, + G_SIGNAL_NO_HOOKS = 1 << 6, + G_SIGNAL_MUST_COLLECT = 1 << 7, + G_SIGNAL_DEPRECATED = 1 << 8, + /* normal signal flags until 1 << 16 */ + G_SIGNAL_ACCUMULATOR_FIRST_RUN = 1 << 17, +} GSignalFlags; +/** + * G_SIGNAL_FLAGS_MASK: + * + * A mask for all #GSignalFlags bits. + */ +#define G_SIGNAL_FLAGS_MASK 0x1ff +/** + * GConnectFlags: + * @G_CONNECT_AFTER: whether the handler should be called before or after the + * default handler of the signal. + * @G_CONNECT_SWAPPED: whether the instance and data should be swapped when + * calling the handler; see g_signal_connect_swapped() for an example. + * + * The connection flags are used to specify the behaviour of a signal's + * connection. + */ +typedef enum +{ + G_CONNECT_AFTER = 1 << 0, + G_CONNECT_SWAPPED = 1 << 1 +} GConnectFlags; +/** + * GSignalMatchType: + * @G_SIGNAL_MATCH_ID: The signal id must be equal. + * @G_SIGNAL_MATCH_DETAIL: The signal detail must be equal. + * @G_SIGNAL_MATCH_CLOSURE: The closure must be the same. + * @G_SIGNAL_MATCH_FUNC: The C closure callback must be the same. + * @G_SIGNAL_MATCH_DATA: The closure data must be the same. + * @G_SIGNAL_MATCH_UNBLOCKED: Only unblocked signals may be matched. + * + * The match types specify what g_signal_handlers_block_matched(), + * g_signal_handlers_unblock_matched() and g_signal_handlers_disconnect_matched() + * match signals by. + */ +typedef enum +{ + G_SIGNAL_MATCH_ID = 1 << 0, + G_SIGNAL_MATCH_DETAIL = 1 << 1, + G_SIGNAL_MATCH_CLOSURE = 1 << 2, + G_SIGNAL_MATCH_FUNC = 1 << 3, + G_SIGNAL_MATCH_DATA = 1 << 4, + G_SIGNAL_MATCH_UNBLOCKED = 1 << 5 +} GSignalMatchType; +/** + * G_SIGNAL_MATCH_MASK: + * + * A mask for all #GSignalMatchType bits. + */ +#define G_SIGNAL_MATCH_MASK 0x3f +/** + * G_SIGNAL_TYPE_STATIC_SCOPE: + * + * This macro flags signal argument types for which the signal system may + * assume that instances thereof remain persistent across all signal emissions + * they are used in. This is only useful for non ref-counted, value-copy types. + * + * To flag a signal argument in this way, add `| G_SIGNAL_TYPE_STATIC_SCOPE` + * to the corresponding argument of g_signal_new(). + * |[ + * g_signal_new ("size_request", + * G_TYPE_FROM_CLASS (gobject_class), + * G_SIGNAL_RUN_FIRST, + * G_STRUCT_OFFSET (GtkWidgetClass, size_request), + * NULL, NULL, + * _gtk_marshal_VOID__BOXED, + * G_TYPE_NONE, 1, + * GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE); + * ]| + */ +#define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT) + + +/* --- signal information --- */ +/** + * GSignalInvocationHint: + * @signal_id: The signal id of the signal invoking the callback + * @detail: The detail passed on for this emission + * @run_type: The stage the signal emission is currently in, this + * field will contain one of %G_SIGNAL_RUN_FIRST, + * %G_SIGNAL_RUN_LAST or %G_SIGNAL_RUN_CLEANUP and %G_SIGNAL_ACCUMULATOR_FIRST_RUN. + * %G_SIGNAL_ACCUMULATOR_FIRST_RUN is only set for the first run of the accumulator + * function for a signal emission. + * + * The #GSignalInvocationHint structure is used to pass on additional information + * to callbacks during a signal emission. + */ +struct _GSignalInvocationHint +{ + guint signal_id; + GQuark detail; + GSignalFlags run_type; +}; +/** + * GSignalQuery: + * @signal_id: The signal id of the signal being queried, or 0 if the + * signal to be queried was unknown. + * @signal_name: The signal name. + * @itype: The interface/instance type that this signal can be emitted for. + * @signal_flags: The signal flags as passed in to g_signal_new(). + * @return_type: The return type for user callbacks. + * @n_params: The number of parameters that user callbacks take. + * @param_types: (array length=n_params): The individual parameter types for + * user callbacks, note that the effective callback signature is: + * |[ + * @return_type callback (#gpointer data1, + * [param_types param_names,] + * gpointer data2); + * ]| + * + * A structure holding in-depth information for a specific signal. It is + * filled in by the g_signal_query() function. + */ +struct _GSignalQuery +{ + guint signal_id; + const gchar *signal_name; + GType itype; + GSignalFlags signal_flags; + GType return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ + guint n_params; + const GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ +}; + + +/* --- signals --- */ +GLIB_AVAILABLE_IN_ALL +guint g_signal_newv (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + GClosure *class_closure, + GSignalAccumulator accumulator, + gpointer accu_data, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + GType *param_types); +GLIB_AVAILABLE_IN_ALL +guint g_signal_new_valist (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + GClosure *class_closure, + GSignalAccumulator accumulator, + gpointer accu_data, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + va_list args); +GLIB_AVAILABLE_IN_ALL +guint g_signal_new (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + guint class_offset, + GSignalAccumulator accumulator, + gpointer accu_data, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + ...); +GLIB_AVAILABLE_IN_ALL +guint g_signal_new_class_handler (const gchar *signal_name, + GType itype, + GSignalFlags signal_flags, + GCallback class_handler, + GSignalAccumulator accumulator, + gpointer accu_data, + GSignalCMarshaller c_marshaller, + GType return_type, + guint n_params, + ...); +GLIB_AVAILABLE_IN_ALL +void g_signal_set_va_marshaller (guint signal_id, + GType instance_type, + GSignalCVaMarshaller va_marshaller); + +GLIB_AVAILABLE_IN_ALL +void g_signal_emitv (const GValue *instance_and_params, + guint signal_id, + GQuark detail, + GValue *return_value); +GLIB_AVAILABLE_IN_ALL +void g_signal_emit_valist (gpointer instance, + guint signal_id, + GQuark detail, + va_list var_args); +GLIB_AVAILABLE_IN_ALL +void g_signal_emit (gpointer instance, + guint signal_id, + GQuark detail, + ...); +GLIB_AVAILABLE_IN_ALL +void g_signal_emit_by_name (gpointer instance, + const gchar *detailed_signal, + ...); +GLIB_AVAILABLE_IN_ALL +guint g_signal_lookup (const gchar *name, + GType itype); +GLIB_AVAILABLE_IN_ALL +const gchar * g_signal_name (guint signal_id); +GLIB_AVAILABLE_IN_ALL +void g_signal_query (guint signal_id, + GSignalQuery *query); +GLIB_AVAILABLE_IN_ALL +guint* g_signal_list_ids (GType itype, + guint *n_ids); +GLIB_AVAILABLE_IN_2_66 +gboolean g_signal_is_valid_name (const gchar *name); +GLIB_AVAILABLE_IN_ALL +gboolean g_signal_parse_name (const gchar *detailed_signal, + GType itype, + guint *signal_id_p, + GQuark *detail_p, + gboolean force_detail_quark); +GLIB_AVAILABLE_IN_ALL +GSignalInvocationHint* g_signal_get_invocation_hint (gpointer instance); + + +/* --- signal emissions --- */ +GLIB_AVAILABLE_IN_ALL +void g_signal_stop_emission (gpointer instance, + guint signal_id, + GQuark detail); +GLIB_AVAILABLE_IN_ALL +void g_signal_stop_emission_by_name (gpointer instance, + const gchar *detailed_signal); +GLIB_AVAILABLE_IN_ALL +gulong g_signal_add_emission_hook (guint signal_id, + GQuark detail, + GSignalEmissionHook hook_func, + gpointer hook_data, + GDestroyNotify data_destroy); +GLIB_AVAILABLE_IN_ALL +void g_signal_remove_emission_hook (guint signal_id, + gulong hook_id); + + +/* --- signal handlers --- */ +GLIB_AVAILABLE_IN_ALL +gboolean g_signal_has_handler_pending (gpointer instance, + guint signal_id, + GQuark detail, + gboolean may_be_blocked); +GLIB_AVAILABLE_IN_ALL +gulong g_signal_connect_closure_by_id (gpointer instance, + guint signal_id, + GQuark detail, + GClosure *closure, + gboolean after); +GLIB_AVAILABLE_IN_ALL +gulong g_signal_connect_closure (gpointer instance, + const gchar *detailed_signal, + GClosure *closure, + gboolean after); +GLIB_AVAILABLE_IN_ALL +gulong g_signal_connect_data (gpointer instance, + const gchar *detailed_signal, + GCallback c_handler, + gpointer data, + GClosureNotify destroy_data, + GConnectFlags connect_flags); +GLIB_AVAILABLE_IN_ALL +void g_signal_handler_block (gpointer instance, + gulong handler_id); +GLIB_AVAILABLE_IN_ALL +void g_signal_handler_unblock (gpointer instance, + gulong handler_id); +GLIB_AVAILABLE_IN_ALL +void g_signal_handler_disconnect (gpointer instance, + gulong handler_id); +GLIB_AVAILABLE_IN_ALL +gboolean g_signal_handler_is_connected (gpointer instance, + gulong handler_id); +GLIB_AVAILABLE_IN_ALL +gulong g_signal_handler_find (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_signal_handlers_block_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_signal_handlers_unblock_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); +GLIB_AVAILABLE_IN_ALL +guint g_signal_handlers_disconnect_matched (gpointer instance, + GSignalMatchType mask, + guint signal_id, + GQuark detail, + GClosure *closure, + gpointer func, + gpointer data); + +GLIB_AVAILABLE_IN_2_62 +void g_clear_signal_handler (gulong *handler_id_ptr, + gpointer instance); + +#undef g_clear_signal_handler +#define g_clear_signal_handler(handler_id_ptr, instance) \ + G_STMT_START { \ + G_STATIC_ASSERT (sizeof *(handler_id_ptr) == sizeof (gulong)); \ + gulong _handler_id = *(handler_id_ptr); \ + \ + if (_handler_id > 0) \ + { \ + g_signal_handler_disconnect ((instance), _handler_id); \ + *(handler_id_ptr) = 0; \ + } \ + } G_STMT_END \ + GLIB_AVAILABLE_MACRO_IN_2_62 + +/* --- overriding and chaining --- */ +GLIB_AVAILABLE_IN_ALL +void g_signal_override_class_closure (guint signal_id, + GType instance_type, + GClosure *class_closure); +GLIB_AVAILABLE_IN_ALL +void g_signal_override_class_handler (const gchar *signal_name, + GType instance_type, + GCallback class_handler); +GLIB_AVAILABLE_IN_ALL +void g_signal_chain_from_overridden (const GValue *instance_and_params, + GValue *return_value); +GLIB_AVAILABLE_IN_ALL +void g_signal_chain_from_overridden_handler (gpointer instance, + ...); + + +/* --- convenience --- */ +/** + * g_signal_connect: + * @instance: the instance to connect to. + * @detailed_signal: a string of the form "signal-name::detail". + * @c_handler: the #GCallback to connect. + * @data: data to pass to @c_handler calls. + * + * Connects a #GCallback function to a signal for a particular object. + * + * The handler will be called before the default handler of the signal. + * + * See [memory management of signal handlers][signal-memory-management] for + * details on how to handle the return value and memory management of @data. + * + * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) + */ +#define g_signal_connect(instance, detailed_signal, c_handler, data) \ + g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0) +/** + * g_signal_connect_after: + * @instance: the instance to connect to. + * @detailed_signal: a string of the form "signal-name::detail". + * @c_handler: the #GCallback to connect. + * @data: data to pass to @c_handler calls. + * + * Connects a #GCallback function to a signal for a particular object. + * + * The handler will be called after the default handler of the signal. + * + * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) + */ +#define g_signal_connect_after(instance, detailed_signal, c_handler, data) \ + g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_AFTER) +/** + * g_signal_connect_swapped: + * @instance: the instance to connect to. + * @detailed_signal: a string of the form "signal-name::detail". + * @c_handler: the #GCallback to connect. + * @data: data to pass to @c_handler calls. + * + * Connects a #GCallback function to a signal for a particular object. + * + * The instance on which the signal is emitted and @data will be swapped when + * calling the handler. This is useful when calling pre-existing functions to + * operate purely on the @data, rather than the @instance: swapping the + * parameters avoids the need to write a wrapper function. + * + * For example, this allows the shorter code: + * |[ + * g_signal_connect_swapped (button, "clicked", + * (GCallback) gtk_widget_hide, other_widget); + * ]| + * + * Rather than the cumbersome: + * |[ + * static void + * button_clicked_cb (GtkButton *button, GtkWidget *other_widget) + * { + * gtk_widget_hide (other_widget); + * } + * + * ... + * + * g_signal_connect (button, "clicked", + * (GCallback) button_clicked_cb, other_widget); + * ]| + * + * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) + */ +#define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \ + g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_SWAPPED) +/** + * g_signal_handlers_disconnect_by_func: + * @instance: The instance to remove handlers from. + * @func: The C closure callback of the handlers (useless for non-C closures). + * @data: The closure data of the handlers' closures. + * + * Disconnects all handlers on an instance that match @func and @data. + * + * Returns: The number of handlers that matched. + */ +#define g_signal_handlers_disconnect_by_func(instance, func, data) \ + g_signal_handlers_disconnect_matched ((instance), \ + (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ + 0, 0, NULL, (func), (data)) + +/** + * g_signal_handlers_disconnect_by_data: + * @instance: The instance to remove handlers from + * @data: the closure data of the handlers' closures + * + * Disconnects all handlers on an instance that match @data. + * + * Returns: The number of handlers that matched. + * + * Since: 2.32 + */ +#define g_signal_handlers_disconnect_by_data(instance, data) \ + g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (data)) + +/** + * g_signal_handlers_block_by_func: + * @instance: The instance to block handlers from. + * @func: The C closure callback of the handlers (useless for non-C closures). + * @data: The closure data of the handlers' closures. + * + * Blocks all handlers on an instance that match @func and @data. + * + * Returns: The number of handlers that matched. + */ +#define g_signal_handlers_block_by_func(instance, func, data) \ + g_signal_handlers_block_matched ((instance), \ + (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ + 0, 0, NULL, (func), (data)) +/** + * g_signal_handlers_unblock_by_func: + * @instance: The instance to unblock handlers from. + * @func: The C closure callback of the handlers (useless for non-C closures). + * @data: The closure data of the handlers' closures. + * + * Unblocks all handlers on an instance that match @func and @data. + * + * Returns: The number of handlers that matched. + */ +#define g_signal_handlers_unblock_by_func(instance, func, data) \ + g_signal_handlers_unblock_matched ((instance), \ + (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ + 0, 0, NULL, (func), (data)) + + +GLIB_AVAILABLE_IN_ALL +gboolean g_signal_accumulator_true_handled (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer dummy); + +GLIB_AVAILABLE_IN_ALL +gboolean g_signal_accumulator_first_wins (GSignalInvocationHint *ihint, + GValue *return_accu, + const GValue *handler_return, + gpointer dummy); + +/*< private >*/ +GLIB_AVAILABLE_IN_ALL +void g_signal_handlers_destroy (gpointer instance); +void _g_signals_destroy (GType itype); + +G_END_DECLS + +#endif /* __G_SIGNAL_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000-2001 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_BOXED_H__ +#define __G_BOXED_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +#ifndef __GI_SCANNER__ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000-2001 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __GLIB_TYPES_H__ +#define __GLIB_TYPES_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) && !defined(GLIB_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* A hack necesssary to preprocess this file with g-ir-scanner */ +#ifdef __GI_SCANNER__ +typedef gsize GType; +#endif + +/* --- GLib boxed types --- */ +/** + * G_TYPE_DATE: + * + * The #GType for #GDate. + */ +#define G_TYPE_DATE (g_date_get_type ()) + +/** + * G_TYPE_STRV: + * + * The #GType for a boxed type holding a %NULL-terminated array of strings. + * + * The code fragments in the following example show the use of a property of + * type #G_TYPE_STRV with g_object_class_install_property(), g_object_set() + * and g_object_get(). + * + * |[ + * g_object_class_install_property (object_class, + * PROP_AUTHORS, + * g_param_spec_boxed ("authors", + * _("Authors"), + * _("List of authors"), + * G_TYPE_STRV, + * G_PARAM_READWRITE)); + * + * gchar *authors[] = { "Owen", "Tim", NULL }; + * g_object_set (obj, "authors", authors, NULL); + * + * gchar *writers[]; + * g_object_get (obj, "authors", &writers, NULL); + * /* do something with writers */ + * g_strfreev (writers); + * ]| + * + * Since: 2.4 + */ +#define G_TYPE_STRV (g_strv_get_type ()) + +/** + * G_TYPE_GSTRING: + * + * The #GType for #GString. + */ +#define G_TYPE_GSTRING (g_gstring_get_type ()) + +/** + * G_TYPE_HASH_TABLE: + * + * The #GType for a boxed type holding a #GHashTable reference. + * + * Since: 2.10 + */ +#define G_TYPE_HASH_TABLE (g_hash_table_get_type ()) + +/** + * G_TYPE_REGEX: + * + * The #GType for a boxed type holding a #GRegex reference. + * + * Since: 2.14 + */ +#define G_TYPE_REGEX (g_regex_get_type ()) + +/** + * G_TYPE_MATCH_INFO: + * + * The #GType for a boxed type holding a #GMatchInfo reference. + * + * Since: 2.30 + */ +#define G_TYPE_MATCH_INFO (g_match_info_get_type ()) + +/** + * G_TYPE_ARRAY: + * + * The #GType for a boxed type holding a #GArray reference. + * + * Since: 2.22 + */ +#define G_TYPE_ARRAY (g_array_get_type ()) + +/** + * G_TYPE_BYTE_ARRAY: + * + * The #GType for a boxed type holding a #GByteArray reference. + * + * Since: 2.22 + */ +#define G_TYPE_BYTE_ARRAY (g_byte_array_get_type ()) + +/** + * G_TYPE_PTR_ARRAY: + * + * The #GType for a boxed type holding a #GPtrArray reference. + * + * Since: 2.22 + */ +#define G_TYPE_PTR_ARRAY (g_ptr_array_get_type ()) + +/** + * G_TYPE_BYTES: + * + * The #GType for #GBytes. + * + * Since: 2.32 + */ +#define G_TYPE_BYTES (g_bytes_get_type ()) + +/** + * G_TYPE_VARIANT_TYPE: + * + * The #GType for a boxed type holding a #GVariantType. + * + * Since: 2.24 + */ +#define G_TYPE_VARIANT_TYPE (g_variant_type_get_gtype ()) + +/** + * G_TYPE_ERROR: + * + * The #GType for a boxed type holding a #GError. + * + * Since: 2.26 + */ +#define G_TYPE_ERROR (g_error_get_type ()) + +/** + * G_TYPE_DATE_TIME: + * + * The #GType for a boxed type holding a #GDateTime. + * + * Since: 2.26 + */ +#define G_TYPE_DATE_TIME (g_date_time_get_type ()) + +/** + * G_TYPE_TIME_ZONE: + * + * The #GType for a boxed type holding a #GTimeZone. + * + * Since: 2.34 + */ +#define G_TYPE_TIME_ZONE (g_time_zone_get_type ()) + +/** + * G_TYPE_IO_CHANNEL: + * + * The #GType for #GIOChannel. + */ +#define G_TYPE_IO_CHANNEL (g_io_channel_get_type ()) + +/** + * G_TYPE_IO_CONDITION: + * + * The #GType for #GIOCondition. + */ +#define G_TYPE_IO_CONDITION (g_io_condition_get_type ()) + +/** + * G_TYPE_VARIANT_BUILDER: + * + * The #GType for a boxed type holding a #GVariantBuilder. + * + * Since: 2.30 + */ +#define G_TYPE_VARIANT_BUILDER (g_variant_builder_get_type ()) + +/** + * G_TYPE_VARIANT_DICT: + * + * The #GType for a boxed type holding a #GVariantDict. + * + * Since: 2.40 + */ +#define G_TYPE_VARIANT_DICT (g_variant_dict_get_type ()) + +/** + * G_TYPE_MAIN_LOOP: + * + * The #GType for a boxed type holding a #GMainLoop. + * + * Since: 2.30 + */ +#define G_TYPE_MAIN_LOOP (g_main_loop_get_type ()) + +/** + * G_TYPE_MAIN_CONTEXT: + * + * The #GType for a boxed type holding a #GMainContext. + * + * Since: 2.30 + */ +#define G_TYPE_MAIN_CONTEXT (g_main_context_get_type ()) + +/** + * G_TYPE_SOURCE: + * + * The #GType for a boxed type holding a #GSource. + * + * Since: 2.30 + */ +#define G_TYPE_SOURCE (g_source_get_type ()) + +/** + * G_TYPE_POLLFD: + * + * The #GType for a boxed type holding a #GPollFD. + * + * Since: 2.36 + */ +#define G_TYPE_POLLFD (g_pollfd_get_type ()) + +/** + * G_TYPE_MARKUP_PARSE_CONTEXT: + * + * The #GType for a boxed type holding a #GMarkupParseContext. + * + * Since: 2.36 + */ +#define G_TYPE_MARKUP_PARSE_CONTEXT (g_markup_parse_context_get_type ()) + +/** + * G_TYPE_KEY_FILE: + * + * The #GType for a boxed type holding a #GKeyFile. + * + * Since: 2.32 + */ +#define G_TYPE_KEY_FILE (g_key_file_get_type ()) + +/** + * G_TYPE_MAPPED_FILE: + * + * The #GType for a boxed type holding a #GMappedFile. + * + * Since: 2.40 + */ +#define G_TYPE_MAPPED_FILE (g_mapped_file_get_type ()) + +/** + * G_TYPE_THREAD: + * + * The #GType for a boxed type holding a #GThread. + * + * Since: 2.36 + */ +#define G_TYPE_THREAD (g_thread_get_type ()) + +/** + * G_TYPE_CHECKSUM: + * + * The #GType for a boxed type holding a #GChecksum. + * + * Since: 2.36 + */ +#define G_TYPE_CHECKSUM (g_checksum_get_type ()) + +/** + * G_TYPE_OPTION_GROUP: + * + * The #GType for a boxed type holding a #GOptionGroup. + * + * Since: 2.44 + */ +#define G_TYPE_OPTION_GROUP (g_option_group_get_type ()) + +/** + * G_TYPE_URI: + * + * The #GType for a boxed type holding a #GUri. + * + * Since: 2.66 + */ +#define G_TYPE_URI (g_uri_get_type ()) + +/** + * G_TYPE_TREE: + * + * The #GType for #GTree. + * + * Since: 2.68 + */ +#define G_TYPE_TREE (g_tree_get_type ()) + +GLIB_AVAILABLE_IN_ALL +GType g_date_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_strv_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_gstring_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_hash_table_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_array_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_byte_array_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_ptr_array_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_bytes_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_variant_type_get_gtype (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_regex_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_30 +GType g_match_info_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_error_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_date_time_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_time_zone_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_io_channel_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_io_condition_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_variant_builder_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_40 +GType g_variant_dict_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_key_file_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_30 +GType g_main_loop_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_30 +GType g_main_context_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_30 +GType g_source_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_36 +GType g_pollfd_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_36 +GType g_thread_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_36 +GType g_checksum_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_36 +GType g_markup_parse_context_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_40 +GType g_mapped_file_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_44 +GType g_option_group_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_66 +GType g_uri_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_2_68 +GType g_tree_get_type (void) G_GNUC_CONST; + +GLIB_DEPRECATED_FOR('G_TYPE_VARIANT') +GType g_variant_get_gtype (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __GLIB_TYPES_H__ */ +#endif + +G_BEGIN_DECLS + +/* --- type macros --- */ +#define G_TYPE_IS_BOXED(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED) +/** + * G_VALUE_HOLDS_BOXED: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived + * from type %G_TYPE_BOXED. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED)) + + +/* --- typedefs --- */ +/** + * GBoxedCopyFunc: + * @boxed: (not nullable): The boxed structure to be copied. + * + * This function is provided by the user and should produce a copy + * of the passed in boxed structure. + * + * Returns: (not nullable): The newly created copy of the boxed structure. + */ +typedef gpointer (*GBoxedCopyFunc) (gpointer boxed); + +/** + * GBoxedFreeFunc: + * @boxed: (not nullable): The boxed structure to be freed. + * + * This function is provided by the user and should free the boxed + * structure passed. + */ +typedef void (*GBoxedFreeFunc) (gpointer boxed); + + +/* --- prototypes --- */ +GLIB_AVAILABLE_IN_ALL +gpointer g_boxed_copy (GType boxed_type, + gconstpointer src_boxed); +GLIB_AVAILABLE_IN_ALL +void g_boxed_free (GType boxed_type, + gpointer boxed); +GLIB_AVAILABLE_IN_ALL +void g_value_set_boxed (GValue *value, + gconstpointer v_boxed); +GLIB_AVAILABLE_IN_ALL +void g_value_set_static_boxed (GValue *value, + gconstpointer v_boxed); +GLIB_AVAILABLE_IN_ALL +void g_value_take_boxed (GValue *value, + gconstpointer v_boxed); +GLIB_DEPRECATED_FOR(g_value_take_boxed) +void g_value_set_boxed_take_ownership (GValue *value, + gconstpointer v_boxed); +GLIB_AVAILABLE_IN_ALL +gpointer g_value_get_boxed (const GValue *value); +GLIB_AVAILABLE_IN_ALL +gpointer g_value_dup_boxed (const GValue *value); + + +/* --- convenience --- */ +GLIB_AVAILABLE_IN_ALL +GType g_boxed_type_register_static (const gchar *name, + GBoxedCopyFunc boxed_copy, + GBoxedFreeFunc boxed_free); + +/* --- GObject boxed types --- */ +/** + * G_TYPE_CLOSURE: + * + * The #GType for #GClosure. + */ +#define G_TYPE_CLOSURE (g_closure_get_type ()) + +/** + * G_TYPE_VALUE: + * + * The type ID of the "GValue" type which is a boxed type, + * used to pass around pointers to GValues. + */ +#define G_TYPE_VALUE (g_value_get_type ()) + +GLIB_AVAILABLE_IN_ALL +GType g_closure_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_value_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __G_BOXED_H__ */ + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_TYPE_IS_OBJECT: + * @type: Type id to check + * + * Check if the passed in type id is a %G_TYPE_OBJECT or derived from it. + * + * Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT. + */ +#define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT) +/** + * G_OBJECT: + * @object: Object which is subject to casting. + * + * Casts a #GObject or derived pointer into a (GObject*) pointer. + * Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + */ +#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject)) +/** + * G_OBJECT_CLASS: + * @class: a valid #GObjectClass + * + * Casts a derived #GObjectClass structure into a #GObjectClass structure. + */ +#define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass)) +/** + * G_IS_OBJECT: + * @object: Instance to check for being a %G_TYPE_OBJECT. + * + * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT. + */ +#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_42 +#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE ((object), G_TYPE_OBJECT)) +#else +#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT)) +#endif +/** + * G_IS_OBJECT_CLASS: + * @class: a #GObjectClass + * + * Checks whether @class "is a" valid #GObjectClass structure of type + * %G_TYPE_OBJECT or derived. + */ +#define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT)) +/** + * G_OBJECT_GET_CLASS: + * @object: a #GObject instance. + * + * Get the class structure associated to a #GObject instance. + * + * Returns: pointer to object class structure. + */ +#define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass)) +/** + * G_OBJECT_TYPE: + * @object: Object to return the type id for. + * + * Get the type id of an object. + * + * Returns: Type id of @object. + */ +#define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object)) +/** + * G_OBJECT_TYPE_NAME: + * @object: Object to return the type name for. + * + * Get the name of an object's type. + * + * Returns: Type name of @object. The string is owned by the type system and + * should not be freed. + */ +#define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object))) +/** + * G_OBJECT_CLASS_TYPE: + * @class: a valid #GObjectClass + * + * Get the type id of a class structure. + * + * Returns: Type id of @class. + */ +#define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) +/** + * G_OBJECT_CLASS_NAME: + * @class: a valid #GObjectClass + * + * Return the name of a class structure's type. + * + * Returns: Type name of @class. The string is owned by the type system and + * should not be freed. + */ +#define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class))) +/** + * G_VALUE_HOLDS_OBJECT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived from type %G_TYPE_OBJECT. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT)) + +/* --- type macros --- */ +/** + * G_TYPE_INITIALLY_UNOWNED: + * + * The type for #GInitiallyUnowned. + */ +#define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type()) +/** + * G_INITIALLY_UNOWNED: + * @object: Object which is subject to casting. + * + * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*) + * pointer. Depending on the current debugging level, this function may invoke + * certain runtime checks to identify invalid casts. + */ +#define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned)) +/** + * G_INITIALLY_UNOWNED_CLASS: + * @class: a valid #GInitiallyUnownedClass + * + * Casts a derived #GInitiallyUnownedClass structure into a + * #GInitiallyUnownedClass structure. + */ +#define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass)) +/** + * G_IS_INITIALLY_UNOWNED: + * @object: Instance to check for being a %G_TYPE_INITIALLY_UNOWNED. + * + * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_INITIALLY_UNOWNED. + */ +#define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED)) +/** + * G_IS_INITIALLY_UNOWNED_CLASS: + * @class: a #GInitiallyUnownedClass + * + * Checks whether @class "is a" valid #GInitiallyUnownedClass structure of type + * %G_TYPE_INITIALLY_UNOWNED or derived. + */ +#define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED)) +/** + * G_INITIALLY_UNOWNED_GET_CLASS: + * @object: a #GInitiallyUnowned instance. + * + * Get the class structure associated to a #GInitiallyUnowned instance. + * + * Returns: pointer to object class structure. + */ +#define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass)) +/* GInitiallyUnowned ia a GObject with initially floating reference count */ + + +/* --- typedefs & structures --- */ +typedef struct _GObject GObject; +typedef struct _GObjectClass GObjectClass; +typedef struct _GObject GInitiallyUnowned; +typedef struct _GObjectClass GInitiallyUnownedClass; +typedef struct _GObjectConstructParam GObjectConstructParam; +/** + * GObjectGetPropertyFunc: + * @object: a #GObject + * @property_id: the numeric id under which the property was registered with + * g_object_class_install_property(). + * @value: a #GValue to return the property value in + * @pspec: the #GParamSpec describing the property + * + * The type of the @get_property function of #GObjectClass. + */ +typedef void (*GObjectGetPropertyFunc) (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); +/** + * GObjectSetPropertyFunc: + * @object: a #GObject + * @property_id: the numeric id under which the property was registered with + * g_object_class_install_property(). + * @value: the new value for the property + * @pspec: the #GParamSpec describing the property + * + * The type of the @set_property function of #GObjectClass. + */ +typedef void (*GObjectSetPropertyFunc) (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +/** + * GObjectFinalizeFunc: + * @object: the #GObject being finalized + * + * The type of the @finalize function of #GObjectClass. + */ +typedef void (*GObjectFinalizeFunc) (GObject *object); +/** + * GWeakNotify: + * @data: data that was provided when the weak reference was established + * @where_the_object_was: the object being disposed + * + * A #GWeakNotify function can be added to an object as a callback that gets + * triggered when the object is finalized. Since the object is already being + * disposed when the #GWeakNotify is called, there's not much you could do + * with the object, apart from e.g. using its address as hash-index or the like. + */ +typedef void (*GWeakNotify) (gpointer data, + GObject *where_the_object_was); +/** + * GObject: + * + * All the fields in the GObject structure are private + * to the #GObject implementation and should never be accessed directly. + */ +struct _GObject +{ + GTypeInstance g_type_instance; + + /*< private >*/ + guint ref_count; /* (atomic) */ + GData *qdata; +}; +/** + * GObjectClass: + * @g_type_class: the parent class + * @constructor: the @constructor function is called by g_object_new () to + * complete the object initialization after all the construction properties are + * set. The first thing a @constructor implementation must do is chain up to the + * @constructor of the parent class. Overriding @constructor should be rarely + * needed, e.g. to handle construct properties, or to implement singletons. + * @set_property: the generic setter for all properties of this type. Should be + * overridden for every type with properties. If implementations of + * @set_property don't emit property change notification explicitly, this will + * be done implicitly by the type system. However, if the notify signal is + * emitted explicitly, the type system will not emit it a second time. + * @get_property: the generic getter for all properties of this type. Should be + * overridden for every type with properties. + * @dispose: the @dispose function is supposed to drop all references to other + * objects, but keep the instance otherwise intact, so that client method + * invocations still work. It may be run multiple times (due to reference + * loops). Before returning, @dispose should chain up to the @dispose method + * of the parent class. + * @finalize: instance finalization function, should finish the finalization of + * the instance begun in @dispose and chain up to the @finalize method of the + * parent class. + * @dispatch_properties_changed: emits property change notification for a bunch + * of properties. Overriding @dispatch_properties_changed should be rarely + * needed. + * @notify: the class closure for the notify signal + * @constructed: the @constructed function is called by g_object_new() as the + * final step of the object creation process. At the point of the call, all + * construction properties have been set on the object. The purpose of this + * call is to allow for object initialisation steps that can only be performed + * after construction properties have been set. @constructed implementors + * should chain up to the @constructed call of their parent class to allow it + * to complete its initialisation. + * + * The class structure for the GObject type. + * + * |[ + * // Example of implementing a singleton using a constructor. + * static MySingleton *the_singleton = NULL; + * + * static GObject* + * my_singleton_constructor (GType type, + * guint n_construct_params, + * GObjectConstructParam *construct_params) + * { + * GObject *object; + * + * if (!the_singleton) + * { + * object = G_OBJECT_CLASS (parent_class)->constructor (type, + * n_construct_params, + * construct_params); + * the_singleton = MY_SINGLETON (object); + * } + * else + * object = g_object_ref (G_OBJECT (the_singleton)); + * + * return object; + * } + * ]| + */ +struct _GObjectClass +{ + GTypeClass g_type_class; + + /*< private >*/ + GSList *construct_properties; + + /*< public >*/ + /* seldom overridden */ + GObject* (*constructor) (GType type, + guint n_construct_properties, + GObjectConstructParam *construct_properties); + /* overridable methods */ + void (*set_property) (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); + void (*get_property) (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + void (*dispose) (GObject *object); + void (*finalize) (GObject *object); + /* seldom overridden */ + void (*dispatch_properties_changed) (GObject *object, + guint n_pspecs, + GParamSpec **pspecs); + /* signals */ + void (*notify) (GObject *object, + GParamSpec *pspec); + + /* called when done constructing */ + void (*constructed) (GObject *object); + + /*< private >*/ + gsize flags; + + /* padding */ + gpointer pdummy[6]; +}; +/** + * GObjectConstructParam: + * @pspec: the #GParamSpec of the construct parameter + * @value: the value to set the parameter to + * + * The GObjectConstructParam struct is an auxiliary + * structure used to hand #GParamSpec/#GValue pairs to the @constructor of + * a #GObjectClass. + */ +struct _GObjectConstructParam +{ + GParamSpec *pspec; + GValue *value; +}; + +/** + * GInitiallyUnowned: + * + * All the fields in the GInitiallyUnowned structure + * are private to the #GInitiallyUnowned implementation and should never be + * accessed directly. + */ +/** + * GInitiallyUnownedClass: + * + * The class structure for the GInitiallyUnowned type. + */ + + +/* --- prototypes --- */ +GLIB_AVAILABLE_IN_ALL +GType g_initially_unowned_get_type (void); +GLIB_AVAILABLE_IN_ALL +void g_object_class_install_property (GObjectClass *oclass, + guint property_id, + GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_object_class_find_property (GObjectClass *oclass, + const gchar *property_name); +GLIB_AVAILABLE_IN_ALL +GParamSpec**g_object_class_list_properties (GObjectClass *oclass, + guint *n_properties); +GLIB_AVAILABLE_IN_ALL +void g_object_class_override_property (GObjectClass *oclass, + guint property_id, + const gchar *name); +GLIB_AVAILABLE_IN_ALL +void g_object_class_install_properties (GObjectClass *oclass, + guint n_pspecs, + GParamSpec **pspecs); + +GLIB_AVAILABLE_IN_ALL +void g_object_interface_install_property (gpointer g_iface, + GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_object_interface_find_property (gpointer g_iface, + const gchar *property_name); +GLIB_AVAILABLE_IN_ALL +GParamSpec**g_object_interface_list_properties (gpointer g_iface, + guint *n_properties_p); + +GLIB_AVAILABLE_IN_ALL +GType g_object_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gpointer g_object_new (GType object_type, + const gchar *first_property_name, + ...); +GLIB_AVAILABLE_IN_2_54 +GObject* g_object_new_with_properties (GType object_type, + guint n_properties, + const char *names[], + const GValue values[]); + +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + +GLIB_DEPRECATED_IN_2_54_FOR(g_object_new_with_properties) +gpointer g_object_newv (GType object_type, + guint n_parameters, + GParameter *parameters); + +G_GNUC_END_IGNORE_DEPRECATIONS + +GLIB_AVAILABLE_IN_ALL +GObject* g_object_new_valist (GType object_type, + const gchar *first_property_name, + va_list var_args); +GLIB_AVAILABLE_IN_ALL +void g_object_set (gpointer object, + const gchar *first_property_name, + ...) G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +void g_object_get (gpointer object, + const gchar *first_property_name, + ...) G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +gpointer g_object_connect (gpointer object, + const gchar *signal_spec, + ...) G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_ALL +void g_object_disconnect (gpointer object, + const gchar *signal_spec, + ...) G_GNUC_NULL_TERMINATED; +GLIB_AVAILABLE_IN_2_54 +void g_object_setv (GObject *object, + guint n_properties, + const gchar *names[], + const GValue values[]); +GLIB_AVAILABLE_IN_ALL +void g_object_set_valist (GObject *object, + const gchar *first_property_name, + va_list var_args); +GLIB_AVAILABLE_IN_2_54 +void g_object_getv (GObject *object, + guint n_properties, + const gchar *names[], + GValue values[]); +GLIB_AVAILABLE_IN_ALL +void g_object_get_valist (GObject *object, + const gchar *first_property_name, + va_list var_args); +GLIB_AVAILABLE_IN_ALL +void g_object_set_property (GObject *object, + const gchar *property_name, + const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_object_get_property (GObject *object, + const gchar *property_name, + GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_object_freeze_notify (GObject *object); +GLIB_AVAILABLE_IN_ALL +void g_object_notify (GObject *object, + const gchar *property_name); +GLIB_AVAILABLE_IN_ALL +void g_object_notify_by_pspec (GObject *object, + GParamSpec *pspec); +GLIB_AVAILABLE_IN_ALL +void g_object_thaw_notify (GObject *object); +GLIB_AVAILABLE_IN_ALL +gboolean g_object_is_floating (gpointer object); +GLIB_AVAILABLE_IN_ALL +gpointer g_object_ref_sink (gpointer object); +GLIB_AVAILABLE_IN_ALL +gpointer g_object_ref (gpointer object); +GLIB_AVAILABLE_IN_ALL +void g_object_unref (gpointer object); +GLIB_AVAILABLE_IN_ALL +void g_object_weak_ref (GObject *object, + GWeakNotify notify, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_object_weak_unref (GObject *object, + GWeakNotify notify, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_object_add_weak_pointer (GObject *object, + gpointer *weak_pointer_location); +GLIB_AVAILABLE_IN_ALL +void g_object_remove_weak_pointer (GObject *object, + gpointer *weak_pointer_location); + +#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 +/* Make reference APIs type safe with macros */ +#undef g_object_ref +#define g_object_ref(Obj) ((glib_typeof (Obj)) (_frida_g_object_ref) (Obj)) +#undef g_object_ref_sink +#define g_object_ref_sink(Obj) ((glib_typeof (Obj)) (_frida_g_object_ref_sink) (Obj)) +#endif + +/** + * GToggleNotify: + * @data: Callback data passed to g_object_add_toggle_ref() + * @object: The object on which g_object_add_toggle_ref() was called. + * @is_last_ref: %TRUE if the toggle reference is now the + * last reference to the object. %FALSE if the toggle + * reference was the last reference and there are now other + * references. + * + * A callback function used for notification when the state + * of a toggle reference changes. See g_object_add_toggle_ref(). + */ +typedef void (*GToggleNotify) (gpointer data, + GObject *object, + gboolean is_last_ref); + +GLIB_AVAILABLE_IN_ALL +void g_object_add_toggle_ref (GObject *object, + GToggleNotify notify, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_object_remove_toggle_ref (GObject *object, + GToggleNotify notify, + gpointer data); + +GLIB_AVAILABLE_IN_ALL +gpointer g_object_get_qdata (GObject *object, + GQuark quark); +GLIB_AVAILABLE_IN_ALL +void g_object_set_qdata (GObject *object, + GQuark quark, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_object_set_qdata_full (GObject *object, + GQuark quark, + gpointer data, + GDestroyNotify destroy); +GLIB_AVAILABLE_IN_ALL +gpointer g_object_steal_qdata (GObject *object, + GQuark quark); + +GLIB_AVAILABLE_IN_2_34 +gpointer g_object_dup_qdata (GObject *object, + GQuark quark, + GDuplicateFunc dup_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_34 +gboolean g_object_replace_qdata (GObject *object, + GQuark quark, + gpointer oldval, + gpointer newval, + GDestroyNotify destroy, + GDestroyNotify *old_destroy); + +GLIB_AVAILABLE_IN_ALL +gpointer g_object_get_data (GObject *object, + const gchar *key); +GLIB_AVAILABLE_IN_ALL +void g_object_set_data (GObject *object, + const gchar *key, + gpointer data); +GLIB_AVAILABLE_IN_ALL +void g_object_set_data_full (GObject *object, + const gchar *key, + gpointer data, + GDestroyNotify destroy); +GLIB_AVAILABLE_IN_ALL +gpointer g_object_steal_data (GObject *object, + const gchar *key); + +GLIB_AVAILABLE_IN_2_34 +gpointer g_object_dup_data (GObject *object, + const gchar *key, + GDuplicateFunc dup_func, + gpointer user_data); +GLIB_AVAILABLE_IN_2_34 +gboolean g_object_replace_data (GObject *object, + const gchar *key, + gpointer oldval, + gpointer newval, + GDestroyNotify destroy, + GDestroyNotify *old_destroy); + + +GLIB_AVAILABLE_IN_ALL +void g_object_watch_closure (GObject *object, + GClosure *closure); +GLIB_AVAILABLE_IN_ALL +GClosure* g_cclosure_new_object (GCallback callback_func, + GObject *object); +GLIB_AVAILABLE_IN_ALL +GClosure* g_cclosure_new_object_swap (GCallback callback_func, + GObject *object); +GLIB_AVAILABLE_IN_ALL +GClosure* g_closure_new_object (guint sizeof_closure, + GObject *object); +GLIB_AVAILABLE_IN_ALL +void g_value_set_object (GValue *value, + gpointer v_object); +GLIB_AVAILABLE_IN_ALL +gpointer g_value_get_object (const GValue *value); +GLIB_AVAILABLE_IN_ALL +gpointer g_value_dup_object (const GValue *value); +GLIB_AVAILABLE_IN_ALL +gulong g_signal_connect_object (gpointer instance, + const gchar *detailed_signal, + GCallback c_handler, + gpointer gobject, + GConnectFlags connect_flags); + +/*< protected >*/ +GLIB_AVAILABLE_IN_ALL +void g_object_force_floating (GObject *object); +GLIB_AVAILABLE_IN_ALL +void g_object_run_dispose (GObject *object); + + +GLIB_AVAILABLE_IN_ALL +void g_value_take_object (GValue *value, + gpointer v_object); +GLIB_DEPRECATED_FOR(g_value_take_object) +void g_value_set_object_take_ownership (GValue *value, + gpointer v_object); + +GLIB_DEPRECATED +gsize g_object_compat_control (gsize what, + gpointer data); + +/* --- implementation macros --- */ +#define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \ +G_STMT_START { \ + GObject *_glib__object = (GObject*) (object); \ + GParamSpec *_glib__pspec = (GParamSpec*) (pspec); \ + guint _glib__property_id = (property_id); \ + g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'", \ + __FILE__, __LINE__, \ + (pname), \ + _glib__property_id, \ + _glib__pspec->name, \ + g_type_name (G_PARAM_SPEC_TYPE (_glib__pspec)), \ + G_OBJECT_TYPE_NAME (_glib__object)); \ +} G_STMT_END +/** + * G_OBJECT_WARN_INVALID_PROPERTY_ID: + * @object: the #GObject on which set_property() or get_property() was called + * @property_id: the numeric id of the property + * @pspec: the #GParamSpec of the property + * + * This macro should be used to emit a standard warning about unexpected + * properties in set_property() and get_property() implementations. + */ +#define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \ + G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec)) + +GLIB_AVAILABLE_IN_ALL +void g_clear_object (GObject **object_ptr); +#undef g_clear_object +#define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref) + +/** + * g_set_object: (skip) + * @object_ptr: (inout) (not optional) (nullable): a pointer to a #GObject reference + * @new_object: (nullable) (transfer none): a pointer to the new #GObject to + * assign to @object_ptr, or %NULL to clear the pointer + * + * Updates a #GObject pointer to refer to @new_object. It increments the + * reference count of @new_object (if non-%NULL), decrements the reference + * count of the current value of @object_ptr (if non-%NULL), and assigns + * @new_object to @object_ptr. The assignment is not atomic. + * + * @object_ptr must not be %NULL, but can point to a %NULL value. + * + * A macro is also included that allows this function to be used without + * pointer casts. The function itself is static inline, so its address may vary + * between compilation units. + * + * One convenient usage of this function is in implementing property setters: + * |[ + * void + * foo_set_bar (Foo *foo, + * Bar *new_bar) + * { + * g_return_if_fail (IS_FOO (foo)); + * g_return_if_fail (new_bar == NULL || IS_BAR (new_bar)); + * + * if (g_set_object (&foo->bar, new_bar)) + * g_object_notify (foo, "bar"); + * } + * ]| + * + * Returns: %TRUE if the value of @object_ptr changed, %FALSE otherwise + * + * Since: 2.44 + */ +static inline gboolean +(g_set_object) (GObject **object_ptr, + GObject *new_object) +{ + GObject *old_object = *object_ptr; + + /* rely on g_object_[un]ref() to check the pointers are actually GObjects; + * elide a (object_ptr != NULL) check because most of the time we will be + * operating on struct members with a constant offset, so a NULL check would + * not catch bugs + */ + + if (old_object == new_object) + return FALSE; + + if (new_object != NULL) + g_object_ref (new_object); + + *object_ptr = new_object; + + if (old_object != NULL) + g_object_unref (old_object); + + return TRUE; +} + +/* We need GCC for __extension__, which we need to sort out strict aliasing of @object_ptr */ +#if defined(__GNUC__) + +#define g_set_object(object_ptr, new_object) \ + (G_GNUC_EXTENSION ({ \ + G_STATIC_ASSERT (sizeof *(object_ptr) == sizeof (new_object)); \ + /* Only one access, please; work around type aliasing */ \ + union { char *in; GObject **out; } _object_ptr; \ + _object_ptr.in = (char *) (object_ptr); \ + /* Check types match */ \ + (void) (0 ? *(object_ptr) = (new_object), FALSE : FALSE); \ + (g_set_object) (_object_ptr.out, (GObject *) new_object); \ + })) \ + GLIB_AVAILABLE_MACRO_IN_2_44 + +#else /* if !defined(__GNUC__) */ + +#define g_set_object(object_ptr, new_object) \ + (/* Check types match. */ \ + 0 ? *(object_ptr) = (new_object), FALSE : \ + (g_set_object) ((GObject **) (object_ptr), (GObject *) (new_object)) \ + ) + +#endif /* !defined(__GNUC__) */ + +/** + * g_assert_finalize_object: (skip) + * @object: (transfer full) (type GObject.Object): an object + * + * Assert that @object is non-%NULL, then release one reference to it with + * g_object_unref() and assert that it has been finalized (i.e. that there + * are no more references). + * + * If assertions are disabled via `G_DISABLE_ASSERT`, + * this macro just calls g_object_unref() without any further checks. + * + * This macro should only be used in regression tests. + * + * Since: 2.62 + */ +static inline void +(g_assert_finalize_object) (GObject *object) +{ + gpointer weak_pointer = object; + + g_assert_true (G_IS_OBJECT (weak_pointer)); + g_object_add_weak_pointer (object, &weak_pointer); + g_object_unref (weak_pointer); + g_assert_null (weak_pointer); +} + +#ifdef G_DISABLE_ASSERT +#define g_assert_finalize_object(object) g_object_unref (object) +#else +#define g_assert_finalize_object(object) (g_assert_finalize_object ((GObject *) object)) +#endif + +/** + * g_clear_weak_pointer: (skip) + * @weak_pointer_location: The memory address of a pointer + * + * Clears a weak reference to a #GObject. + * + * @weak_pointer_location must not be %NULL. + * + * If the weak reference is %NULL then this function does nothing. + * Otherwise, the weak reference to the object is removed for that location + * and the pointer is set to %NULL. + * + * A macro is also included that allows this function to be used without + * pointer casts. The function itself is static inline, so its address may vary + * between compilation units. + * + * Since: 2.56 + */ +static inline void +(g_clear_weak_pointer) (gpointer *weak_pointer_location) +{ + GObject *object = (GObject *) *weak_pointer_location; + + if (object != NULL) + { + g_object_remove_weak_pointer (object, weak_pointer_location); + *weak_pointer_location = NULL; + } +} + +#define g_clear_weak_pointer(weak_pointer_location) \ + (/* Check types match. */ \ + (g_clear_weak_pointer) ((gpointer *) (weak_pointer_location)) \ + ) + +/** + * g_set_weak_pointer: (skip) + * @weak_pointer_location: the memory address of a pointer + * @new_object: (nullable) (transfer none): a pointer to the new #GObject to + * assign to it, or %NULL to clear the pointer + * + * Updates a pointer to weakly refer to @new_object. It assigns @new_object + * to @weak_pointer_location and ensures that @weak_pointer_location will + * automatically be set to %NULL if @new_object gets destroyed. The assignment + * is not atomic. The weak reference is not thread-safe, see + * g_object_add_weak_pointer() for details. + * + * @weak_pointer_location must not be %NULL. + * + * A macro is also included that allows this function to be used without + * pointer casts. The function itself is static inline, so its address may vary + * between compilation units. + * + * One convenient usage of this function is in implementing property setters: + * |[ + * void + * foo_set_bar (Foo *foo, + * Bar *new_bar) + * { + * g_return_if_fail (IS_FOO (foo)); + * g_return_if_fail (new_bar == NULL || IS_BAR (new_bar)); + * + * if (g_set_weak_pointer (&foo->bar, new_bar)) + * g_object_notify (foo, "bar"); + * } + * ]| + * + * Returns: %TRUE if the value of @weak_pointer_location changed, %FALSE otherwise + * + * Since: 2.56 + */ +static inline gboolean +(g_set_weak_pointer) (gpointer *weak_pointer_location, + GObject *new_object) +{ + GObject *old_object = (GObject *) *weak_pointer_location; + + /* elide a (weak_pointer_location != NULL) check because most of the time we + * will be operating on struct members with a constant offset, so a NULL + * check would not catch bugs + */ + + if (old_object == new_object) + return FALSE; + + if (old_object != NULL) + g_object_remove_weak_pointer (old_object, weak_pointer_location); + + *weak_pointer_location = new_object; + + if (new_object != NULL) + g_object_add_weak_pointer (new_object, weak_pointer_location); + + return TRUE; +} + +#define g_set_weak_pointer(weak_pointer_location, new_object) \ + (/* Check types match. */ \ + 0 ? *(weak_pointer_location) = (new_object), FALSE : \ + (g_set_weak_pointer) ((gpointer *) (weak_pointer_location), (GObject *) (new_object)) \ + ) + +typedef struct { + /**/ + union { gpointer p; } priv; +} GWeakRef; + +GLIB_AVAILABLE_IN_ALL +void g_weak_ref_init (GWeakRef *weak_ref, + gpointer object); +GLIB_AVAILABLE_IN_ALL +void g_weak_ref_clear (GWeakRef *weak_ref); +GLIB_AVAILABLE_IN_ALL +gpointer g_weak_ref_get (GWeakRef *weak_ref); +GLIB_AVAILABLE_IN_ALL +void g_weak_ref_set (GWeakRef *weak_ref, + gpointer object); + +G_END_DECLS + +#endif /* __G_OBJECT_H__ */ + +G_BEGIN_DECLS + +#define G_TYPE_BINDING_FLAGS (g_binding_flags_get_type ()) + +#define G_TYPE_BINDING (g_binding_get_type ()) +#define G_BINDING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_BINDING, GBinding)) +#define G_IS_BINDING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_BINDING)) + +/** + * GBinding: + * + * GBinding is an opaque structure whose members + * cannot be accessed directly. + * + * Since: 2.26 + */ +typedef struct _GBinding GBinding; + +/** + * GBindingTransformFunc: + * @binding: a #GBinding + * @from_value: the #GValue containing the value to transform + * @to_value: the #GValue in which to store the transformed value + * @user_data: data passed to the transform function + * + * A function to be called to transform @from_value to @to_value. If + * this is the @transform_to function of a binding, then @from_value + * is the @source_property on the @source object, and @to_value is the + * @target_property on the @target object. If this is the + * @transform_from function of a %G_BINDING_BIDIRECTIONAL binding, + * then those roles are reversed. + * + * Returns: %TRUE if the transformation was successful, and %FALSE + * otherwise + * + * Since: 2.26 + */ +typedef gboolean (* GBindingTransformFunc) (GBinding *binding, + const GValue *from_value, + GValue *to_value, + gpointer user_data); + +/** + * GBindingFlags: + * @G_BINDING_DEFAULT: The default binding; if the source property + * changes, the target property is updated with its value. + * @G_BINDING_BIDIRECTIONAL: Bidirectional binding; if either the + * property of the source or the property of the target changes, + * the other is updated. + * @G_BINDING_SYNC_CREATE: Synchronize the values of the source and + * target properties when creating the binding; the direction of + * the synchronization is always from the source to the target. + * @G_BINDING_INVERT_BOOLEAN: If the two properties being bound are + * booleans, setting one to %TRUE will result in the other being + * set to %FALSE and vice versa. This flag will only work for + * boolean properties, and cannot be used when passing custom + * transformation functions to g_object_bind_property_full(). + * + * Flags to be passed to g_object_bind_property() or + * g_object_bind_property_full(). + * + * This enumeration can be extended at later date. + * + * Since: 2.26 + */ +typedef enum { /*< prefix=G_BINDING >*/ + G_BINDING_DEFAULT = 0, + + G_BINDING_BIDIRECTIONAL = 1 << 0, + G_BINDING_SYNC_CREATE = 1 << 1, + G_BINDING_INVERT_BOOLEAN = 1 << 2 +} GBindingFlags; + +GLIB_AVAILABLE_IN_ALL +GType g_binding_flags_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +GType g_binding_get_type (void) G_GNUC_CONST; + +GLIB_AVAILABLE_IN_ALL +GBindingFlags g_binding_get_flags (GBinding *binding); +GLIB_DEPRECATED_IN_2_68_FOR(g_binding_dup_source) +GObject * g_binding_get_source (GBinding *binding); +GLIB_AVAILABLE_IN_2_68 +GObject * g_binding_dup_source (GBinding *binding); +GLIB_DEPRECATED_IN_2_68_FOR(g_binding_dup_target) +GObject * g_binding_get_target (GBinding *binding); +GLIB_AVAILABLE_IN_2_68 +GObject * g_binding_dup_target (GBinding *binding); +GLIB_AVAILABLE_IN_ALL +const gchar * g_binding_get_source_property (GBinding *binding); +GLIB_AVAILABLE_IN_ALL +const gchar * g_binding_get_target_property (GBinding *binding); +GLIB_AVAILABLE_IN_2_38 +void g_binding_unbind (GBinding *binding); + +GLIB_AVAILABLE_IN_ALL +GBinding *g_object_bind_property (gpointer source, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags); +GLIB_AVAILABLE_IN_ALL +GBinding *g_object_bind_property_full (gpointer source, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags, + GBindingTransformFunc transform_to, + GBindingTransformFunc transform_from, + gpointer user_data, + GDestroyNotify notify); +GLIB_AVAILABLE_IN_ALL +GBinding *g_object_bind_property_with_closures (gpointer source, + const gchar *source_property, + gpointer target, + const gchar *target_property, + GBindingFlags flags, + GClosure *transform_to, + GClosure *transform_from); + +G_END_DECLS + +#endif /* __G_BINDING_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_ENUMS_H__ +#define __G_ENUMS_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_TYPE_IS_ENUM: + * @type: a #GType ID. + * + * Checks whether @type "is a" %G_TYPE_ENUM. + * + * Returns: %TRUE if @type "is a" %G_TYPE_ENUM. + */ +#define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM) +/** + * G_ENUM_CLASS: + * @class: a valid #GEnumClass + * + * Casts a derived #GEnumClass structure into a #GEnumClass structure. + */ +#define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass)) +/** + * G_IS_ENUM_CLASS: + * @class: a #GEnumClass + * + * Checks whether @class "is a" valid #GEnumClass structure of type %G_TYPE_ENUM + * or derived. + */ +#define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM)) +/** + * G_ENUM_CLASS_TYPE: + * @class: a #GEnumClass + * + * Get the type identifier from a given #GEnumClass structure. + * + * Returns: the #GType + */ +#define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) +/** + * G_ENUM_CLASS_TYPE_NAME: + * @class: a #GEnumClass + * + * Get the static type name from a given #GEnumClass structure. + * + * Returns: the type name. + */ +#define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_CLASS_TYPE (class))) + + +/** + * G_TYPE_IS_FLAGS: + * @type: a #GType ID. + * + * Checks whether @type "is a" %G_TYPE_FLAGS. + * + * Returns: %TRUE if @type "is a" %G_TYPE_FLAGS. + */ +#define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS) +/** + * G_FLAGS_CLASS: + * @class: a valid #GFlagsClass + * + * Casts a derived #GFlagsClass structure into a #GFlagsClass structure. + */ +#define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass)) +/** + * G_IS_FLAGS_CLASS: + * @class: a #GFlagsClass + * + * Checks whether @class "is a" valid #GFlagsClass structure of type %G_TYPE_FLAGS + * or derived. + */ +#define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS)) +/** + * G_FLAGS_CLASS_TYPE: + * @class: a #GFlagsClass + * + * Get the type identifier from a given #GFlagsClass structure. + * + * Returns: the #GType + */ +#define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) +/** + * G_FLAGS_CLASS_TYPE_NAME: + * @class: a #GFlagsClass + * + * Get the static type name from a given #GFlagsClass structure. + * + * Returns: the type name. + */ +#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class))) + + +/** + * G_VALUE_HOLDS_ENUM: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived from type %G_TYPE_ENUM. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM)) +/** + * G_VALUE_HOLDS_FLAGS: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values derived from type %G_TYPE_FLAGS. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS)) + + +/* --- enum/flag values & classes --- */ +typedef struct _GEnumClass GEnumClass; +typedef struct _GFlagsClass GFlagsClass; +typedef struct _GEnumValue GEnumValue; +typedef struct _GFlagsValue GFlagsValue; + +/** + * GEnumClass: + * @g_type_class: the parent class + * @minimum: the smallest possible value. + * @maximum: the largest possible value. + * @n_values: the number of possible values. + * @values: an array of #GEnumValue structs describing the + * individual values. + * + * The class of an enumeration type holds information about its + * possible values. + */ +struct _GEnumClass +{ + GTypeClass g_type_class; + + /*< public >*/ + gint minimum; + gint maximum; + guint n_values; + GEnumValue *values; +}; +/** + * GFlagsClass: + * @g_type_class: the parent class + * @mask: a mask covering all possible values. + * @n_values: the number of possible values. + * @values: an array of #GFlagsValue structs describing the + * individual values. + * + * The class of a flags type holds information about its + * possible values. + */ +struct _GFlagsClass +{ + GTypeClass g_type_class; + + /*< public >*/ + guint mask; + guint n_values; + GFlagsValue *values; +}; +/** + * GEnumValue: + * @value: the enum value + * @value_name: the name of the value + * @value_nick: the nickname of the value + * + * A structure which contains a single enum value, its name, and its + * nickname. + */ +struct _GEnumValue +{ + gint value; + const gchar *value_name; + const gchar *value_nick; +}; +/** + * GFlagsValue: + * @value: the flags value + * @value_name: the name of the value + * @value_nick: the nickname of the value + * + * A structure which contains a single flags value, its name, and its + * nickname. + */ +struct _GFlagsValue +{ + guint value; + const gchar *value_name; + const gchar *value_nick; +}; + + +/* --- prototypes --- */ +GLIB_AVAILABLE_IN_ALL +GEnumValue* g_enum_get_value (GEnumClass *enum_class, + gint value); +GLIB_AVAILABLE_IN_ALL +GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class, + const gchar *name); +GLIB_AVAILABLE_IN_ALL +GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class, + const gchar *nick); +GLIB_AVAILABLE_IN_ALL +GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class, + guint value); +GLIB_AVAILABLE_IN_ALL +GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class, + const gchar *name); +GLIB_AVAILABLE_IN_ALL +GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class, + const gchar *nick); +GLIB_AVAILABLE_IN_2_54 +gchar *g_enum_to_string (GType g_enum_type, + gint value); +GLIB_AVAILABLE_IN_2_54 +gchar *g_flags_to_string (GType flags_type, + guint value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_enum (GValue *value, + gint v_enum); +GLIB_AVAILABLE_IN_ALL +gint g_value_get_enum (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_flags (GValue *value, + guint v_flags); +GLIB_AVAILABLE_IN_ALL +guint g_value_get_flags (const GValue *value); + + + +/* --- registration functions --- */ +/* const_static_values is a NULL terminated array of enum/flags + * values that is taken over! + */ +GLIB_AVAILABLE_IN_ALL +GType g_enum_register_static (const gchar *name, + const GEnumValue *const_static_values); +GLIB_AVAILABLE_IN_ALL +GType g_flags_register_static (const gchar *name, + const GFlagsValue *const_static_values); +/* functions to complete the type information + * for enums/flags implemented by plugins + */ +GLIB_AVAILABLE_IN_ALL +void g_enum_complete_type_info (GType g_enum_type, + GTypeInfo *info, + const GEnumValue *const_values); +GLIB_AVAILABLE_IN_ALL +void g_flags_complete_type_info (GType g_flags_type, + GTypeInfo *info, + const GFlagsValue *const_values); + +G_END_DECLS + +#endif /* __G_ENUMS_H__ */ + +/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ + +#ifndef __GOBJECT_ENUM_TYPES_H__ +#define __GOBJECT_ENUM_TYPES_H__ + + +G_BEGIN_DECLS + +/* enumerations from "../../../deps/glib/gobject/../glib/gunicode.h" */ +GLIB_AVAILABLE_IN_2_60 GType g_unicode_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_UNICODE_TYPE (g_unicode_type_get_type ()) +GLIB_AVAILABLE_IN_2_60 GType g_unicode_break_type_get_type (void) G_GNUC_CONST; +#define G_TYPE_UNICODE_BREAK_TYPE (g_unicode_break_type_get_type ()) +GLIB_AVAILABLE_IN_2_60 GType g_unicode_script_get_type (void) G_GNUC_CONST; +#define G_TYPE_UNICODE_SCRIPT (g_unicode_script_get_type ()) +GLIB_AVAILABLE_IN_2_60 GType g_normalize_mode_get_type (void) G_GNUC_CONST; +#define G_TYPE_NORMALIZE_MODE (g_normalize_mode_get_type ()) +G_END_DECLS + +#endif /* __GOBJECT_ENUM_TYPES_H__ */ + +/* Generated data ends here */ + +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gparamspecs.h: GLib default param specs + */ +#ifndef __G_PARAMSPECS_H__ +#define __G_PARAMSPECS_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_TYPE_PARAM_CHAR: + * + * The #GType of #GParamSpecChar. + */ +#define G_TYPE_PARAM_CHAR (g_param_spec_types[0]) +/** + * G_IS_PARAM_SPEC_CHAR: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_CHAR. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_CHAR)) +/** + * G_PARAM_SPEC_CHAR: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecChar. + */ +#define G_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_CHAR, GParamSpecChar)) + +/** + * G_TYPE_PARAM_UCHAR: + * + * The #GType of #GParamSpecUChar. + */ +#define G_TYPE_PARAM_UCHAR (g_param_spec_types[1]) +/** + * G_IS_PARAM_SPEC_UCHAR: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UCHAR. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UCHAR)) +/** + * G_PARAM_SPEC_UCHAR: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecUChar. + */ +#define G_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UCHAR, GParamSpecUChar)) + +/** + * G_TYPE_PARAM_BOOLEAN: + * + * The #GType of #GParamSpecBoolean. + */ +#define G_TYPE_PARAM_BOOLEAN (g_param_spec_types[2]) +/** + * G_IS_PARAM_SPEC_BOOLEAN: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_BOOLEAN. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOOLEAN)) +/** + * G_PARAM_SPEC_BOOLEAN: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecBoolean. + */ +#define G_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOOLEAN, GParamSpecBoolean)) + +/** + * G_TYPE_PARAM_INT: + * + * The #GType of #GParamSpecInt. + */ +#define G_TYPE_PARAM_INT (g_param_spec_types[3]) +/** + * G_IS_PARAM_SPEC_INT: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_INT. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT)) +/** + * G_PARAM_SPEC_INT: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecInt. + */ +#define G_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT, GParamSpecInt)) + +/** + * G_TYPE_PARAM_UINT: + * + * The #GType of #GParamSpecUInt. + */ +#define G_TYPE_PARAM_UINT (g_param_spec_types[4]) +/** + * G_IS_PARAM_SPEC_UINT: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UINT. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT)) +/** + * G_PARAM_SPEC_UINT: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecUInt. + */ +#define G_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT, GParamSpecUInt)) + +/** + * G_TYPE_PARAM_LONG: + * + * The #GType of #GParamSpecLong. + */ +#define G_TYPE_PARAM_LONG (g_param_spec_types[5]) +/** + * G_IS_PARAM_SPEC_LONG: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_LONG. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG)) +/** + * G_PARAM_SPEC_LONG: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecLong. + */ +#define G_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong)) + +/** + * G_TYPE_PARAM_ULONG: + * + * The #GType of #GParamSpecULong. + */ +#define G_TYPE_PARAM_ULONG (g_param_spec_types[6]) +/** + * G_IS_PARAM_SPEC_ULONG: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_ULONG. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG)) +/** + * G_PARAM_SPEC_ULONG: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecULong. + */ +#define G_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong)) + +/** + * G_TYPE_PARAM_INT64: + * + * The #GType of #GParamSpecInt64. + */ +#define G_TYPE_PARAM_INT64 (g_param_spec_types[7]) +/** + * G_IS_PARAM_SPEC_INT64: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_INT64. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_INT64(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT64)) +/** + * G_PARAM_SPEC_INT64: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecInt64. + */ +#define G_PARAM_SPEC_INT64(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT64, GParamSpecInt64)) + +/** + * G_TYPE_PARAM_UINT64: + * + * The #GType of #GParamSpecUInt64. + */ +#define G_TYPE_PARAM_UINT64 (g_param_spec_types[8]) +/** + * G_IS_PARAM_SPEC_UINT64: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UINT64. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_UINT64(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT64)) +/** + * G_PARAM_SPEC_UINT64: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecUInt64. + */ +#define G_PARAM_SPEC_UINT64(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT64, GParamSpecUInt64)) + +/** + * G_TYPE_PARAM_UNICHAR: + * + * The #GType of #GParamSpecUnichar. + */ +#define G_TYPE_PARAM_UNICHAR (g_param_spec_types[9]) +/** + * G_PARAM_SPEC_UNICHAR: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecUnichar. + */ +#define G_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UNICHAR, GParamSpecUnichar)) +/** + * G_IS_PARAM_SPEC_UNICHAR: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UNICHAR. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UNICHAR)) + +/** + * G_TYPE_PARAM_ENUM: + * + * The #GType of #GParamSpecEnum. + */ +#define G_TYPE_PARAM_ENUM (g_param_spec_types[10]) +/** + * G_IS_PARAM_SPEC_ENUM: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_ENUM. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM)) +/** + * G_PARAM_SPEC_ENUM: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecEnum. + */ +#define G_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum)) + +/** + * G_TYPE_PARAM_FLAGS: + * + * The #GType of #GParamSpecFlags. + */ +#define G_TYPE_PARAM_FLAGS (g_param_spec_types[11]) +/** + * G_IS_PARAM_SPEC_FLAGS: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_FLAGS. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLAGS)) +/** + * G_PARAM_SPEC_FLAGS: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecFlags. + */ +#define G_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLAGS, GParamSpecFlags)) + +/** + * G_TYPE_PARAM_FLOAT: + * + * The #GType of #GParamSpecFloat. + */ +#define G_TYPE_PARAM_FLOAT (g_param_spec_types[12]) +/** + * G_IS_PARAM_SPEC_FLOAT: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_FLOAT. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLOAT)) +/** + * G_PARAM_SPEC_FLOAT: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecFloat. + */ +#define G_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLOAT, GParamSpecFloat)) + +/** + * G_TYPE_PARAM_DOUBLE: + * + * The #GType of #GParamSpecDouble. + */ +#define G_TYPE_PARAM_DOUBLE (g_param_spec_types[13]) +/** + * G_IS_PARAM_SPEC_DOUBLE: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_DOUBLE. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_DOUBLE)) +/** + * G_PARAM_SPEC_DOUBLE: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecDouble. + */ +#define G_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_DOUBLE, GParamSpecDouble)) + +/** + * G_TYPE_PARAM_STRING: + * + * The #GType of #GParamSpecString. + */ +#define G_TYPE_PARAM_STRING (g_param_spec_types[14]) +/** + * G_IS_PARAM_SPEC_STRING: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_STRING. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_STRING)) +/** + * G_PARAM_SPEC_STRING: + * @pspec: a valid #GParamSpec instance + * + * Casts a #GParamSpec instance into a #GParamSpecString. + */ +#define G_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_STRING, GParamSpecString)) + +/** + * G_TYPE_PARAM_PARAM: + * + * The #GType of #GParamSpecParam. + */ +#define G_TYPE_PARAM_PARAM (g_param_spec_types[15]) +/** + * G_IS_PARAM_SPEC_PARAM: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_PARAM. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_PARAM)) +/** + * G_PARAM_SPEC_PARAM: + * @pspec: a valid #GParamSpec instance + * + * Casts a #GParamSpec instance into a #GParamSpecParam. + */ +#define G_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_PARAM, GParamSpecParam)) + +/** + * G_TYPE_PARAM_BOXED: + * + * The #GType of #GParamSpecBoxed. + */ +#define G_TYPE_PARAM_BOXED (g_param_spec_types[16]) +/** + * G_IS_PARAM_SPEC_BOXED: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_BOXED. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOXED)) +/** + * G_PARAM_SPEC_BOXED: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecBoxed. + */ +#define G_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOXED, GParamSpecBoxed)) + +/** + * G_TYPE_PARAM_POINTER: + * + * The #GType of #GParamSpecPointer. + */ +#define G_TYPE_PARAM_POINTER (g_param_spec_types[17]) +/** + * G_IS_PARAM_SPEC_POINTER: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_POINTER. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_POINTER)) +/** + * G_PARAM_SPEC_POINTER: + * @pspec: a valid #GParamSpec instance + * + * Casts a #GParamSpec instance into a #GParamSpecPointer. + */ +#define G_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_POINTER, GParamSpecPointer)) + +/** + * G_TYPE_PARAM_VALUE_ARRAY: + * + * The #GType of #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray + */ +#define G_TYPE_PARAM_VALUE_ARRAY (g_param_spec_types[18]) GLIB_DEPRECATED_MACRO_IN_2_32 +/** + * G_IS_PARAM_SPEC_VALUE_ARRAY: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VALUE_ARRAY. + * + * Returns: %TRUE on success. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray + */ +#define G_IS_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VALUE_ARRAY)) GLIB_DEPRECATED_MACRO_IN_2_32 +/** + * G_PARAM_SPEC_VALUE_ARRAY: + * @pspec: a valid #GParamSpec instance + * + * Cast a #GParamSpec instance into a #GParamSpecValueArray. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray + */ +#define G_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VALUE_ARRAY, GParamSpecValueArray)) GLIB_DEPRECATED_MACRO_IN_2_32 + +/** + * G_TYPE_PARAM_OBJECT: + * + * The #GType of #GParamSpecObject. + */ +#define G_TYPE_PARAM_OBJECT (g_param_spec_types[19]) +/** + * G_IS_PARAM_SPEC_OBJECT: + * @pspec: a valid #GParamSpec instance + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_OBJECT. + * + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OBJECT)) +/** + * G_PARAM_SPEC_OBJECT: + * @pspec: a valid #GParamSpec instance + * + * Casts a #GParamSpec instance into a #GParamSpecObject. + */ +#define G_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OBJECT, GParamSpecObject)) + +/** + * G_TYPE_PARAM_OVERRIDE: + * + * The #GType of #GParamSpecOverride. + * + * Since: 2.4 + */ +#define G_TYPE_PARAM_OVERRIDE (g_param_spec_types[20]) +/** + * G_IS_PARAM_SPEC_OVERRIDE: + * @pspec: a #GParamSpec + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_OVERRIDE. + * + * Since: 2.4 + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_OVERRIDE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OVERRIDE)) +/** + * G_PARAM_SPEC_OVERRIDE: + * @pspec: a #GParamSpec + * + * Casts a #GParamSpec into a #GParamSpecOverride. + * + * Since: 2.4 + */ +#define G_PARAM_SPEC_OVERRIDE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OVERRIDE, GParamSpecOverride)) + +/** + * G_TYPE_PARAM_GTYPE: + * + * The #GType of #GParamSpecGType. + * + * Since: 2.10 + */ +#define G_TYPE_PARAM_GTYPE (g_param_spec_types[21]) +/** + * G_IS_PARAM_SPEC_GTYPE: + * @pspec: a #GParamSpec + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_GTYPE. + * + * Since: 2.10 + * Returns: %TRUE on success. + */ +#define G_IS_PARAM_SPEC_GTYPE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_GTYPE)) +/** + * G_PARAM_SPEC_GTYPE: + * @pspec: a #GParamSpec + * + * Casts a #GParamSpec into a #GParamSpecGType. + * + * Since: 2.10 + */ +#define G_PARAM_SPEC_GTYPE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_GTYPE, GParamSpecGType)) + +/** + * G_TYPE_PARAM_VARIANT: + * + * The #GType of #GParamSpecVariant. + * + * Since: 2.26 + */ +#define G_TYPE_PARAM_VARIANT (g_param_spec_types[22]) +/** + * G_IS_PARAM_SPEC_VARIANT: + * @pspec: a #GParamSpec + * + * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VARIANT. + * + * Returns: %TRUE on success + * + * Since: 2.26 + */ +#define G_IS_PARAM_SPEC_VARIANT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VARIANT)) +/** + * G_PARAM_SPEC_VARIANT: + * @pspec: a #GParamSpec + * + * Casts a #GParamSpec into a #GParamSpecVariant. + * + * Since: 2.26 + */ +#define G_PARAM_SPEC_VARIANT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VARIANT, GParamSpecVariant)) + +/* --- typedefs & structures --- */ +typedef struct _GParamSpecChar GParamSpecChar; +typedef struct _GParamSpecUChar GParamSpecUChar; +typedef struct _GParamSpecBoolean GParamSpecBoolean; +typedef struct _GParamSpecInt GParamSpecInt; +typedef struct _GParamSpecUInt GParamSpecUInt; +typedef struct _GParamSpecLong GParamSpecLong; +typedef struct _GParamSpecULong GParamSpecULong; +typedef struct _GParamSpecInt64 GParamSpecInt64; +typedef struct _GParamSpecUInt64 GParamSpecUInt64; +typedef struct _GParamSpecUnichar GParamSpecUnichar; +typedef struct _GParamSpecEnum GParamSpecEnum; +typedef struct _GParamSpecFlags GParamSpecFlags; +typedef struct _GParamSpecFloat GParamSpecFloat; +typedef struct _GParamSpecDouble GParamSpecDouble; +typedef struct _GParamSpecString GParamSpecString; +typedef struct _GParamSpecParam GParamSpecParam; +typedef struct _GParamSpecBoxed GParamSpecBoxed; +typedef struct _GParamSpecPointer GParamSpecPointer; +typedef struct _GParamSpecValueArray GParamSpecValueArray; +typedef struct _GParamSpecObject GParamSpecObject; +typedef struct _GParamSpecOverride GParamSpecOverride; +typedef struct _GParamSpecGType GParamSpecGType; +typedef struct _GParamSpecVariant GParamSpecVariant; + +/** + * GParamSpecChar: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for character properties. + */ +struct _GParamSpecChar +{ + GParamSpec parent_instance; + + gint8 minimum; + gint8 maximum; + gint8 default_value; +}; +/** + * GParamSpecUChar: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unsigned character properties. + */ +struct _GParamSpecUChar +{ + GParamSpec parent_instance; + + guint8 minimum; + guint8 maximum; + guint8 default_value; +}; +/** + * GParamSpecBoolean: + * @parent_instance: private #GParamSpec portion + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for boolean properties. + */ +struct _GParamSpecBoolean +{ + GParamSpec parent_instance; + + gboolean default_value; +}; +/** + * GParamSpecInt: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for integer properties. + */ +struct _GParamSpecInt +{ + GParamSpec parent_instance; + + gint minimum; + gint maximum; + gint default_value; +}; +/** + * GParamSpecUInt: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unsigned integer properties. + */ +struct _GParamSpecUInt +{ + GParamSpec parent_instance; + + guint minimum; + guint maximum; + guint default_value; +}; +/** + * GParamSpecLong: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for long integer properties. + */ +struct _GParamSpecLong +{ + GParamSpec parent_instance; + + glong minimum; + glong maximum; + glong default_value; +}; +/** + * GParamSpecULong: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unsigned long integer properties. + */ +struct _GParamSpecULong +{ + GParamSpec parent_instance; + + gulong minimum; + gulong maximum; + gulong default_value; +}; +/** + * GParamSpecInt64: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for 64bit integer properties. + */ +struct _GParamSpecInt64 +{ + GParamSpec parent_instance; + + gint64 minimum; + gint64 maximum; + gint64 default_value; +}; +/** + * GParamSpecUInt64: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unsigned 64bit integer properties. + */ +struct _GParamSpecUInt64 +{ + GParamSpec parent_instance; + + guint64 minimum; + guint64 maximum; + guint64 default_value; +}; +/** + * GParamSpecUnichar: + * @parent_instance: private #GParamSpec portion + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for unichar (unsigned integer) properties. + */ +struct _GParamSpecUnichar +{ + GParamSpec parent_instance; + + gunichar default_value; +}; +/** + * GParamSpecEnum: + * @parent_instance: private #GParamSpec portion + * @enum_class: the #GEnumClass for the enum + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for enum + * properties. + */ +struct _GParamSpecEnum +{ + GParamSpec parent_instance; + + GEnumClass *enum_class; + gint default_value; +}; +/** + * GParamSpecFlags: + * @parent_instance: private #GParamSpec portion + * @flags_class: the #GFlagsClass for the flags + * @default_value: default value for the property specified + * + * A #GParamSpec derived structure that contains the meta data for flags + * properties. + */ +struct _GParamSpecFlags +{ + GParamSpec parent_instance; + + GFlagsClass *flags_class; + guint default_value; +}; +/** + * GParamSpecFloat: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * @epsilon: values closer than @epsilon will be considered identical + * by g_param_values_cmp(); the default value is 1e-30. + * + * A #GParamSpec derived structure that contains the meta data for float properties. + */ +struct _GParamSpecFloat +{ + GParamSpec parent_instance; + + gfloat minimum; + gfloat maximum; + gfloat default_value; + gfloat epsilon; +}; +/** + * GParamSpecDouble: + * @parent_instance: private #GParamSpec portion + * @minimum: minimum value for the property specified + * @maximum: maximum value for the property specified + * @default_value: default value for the property specified + * @epsilon: values closer than @epsilon will be considered identical + * by g_param_values_cmp(); the default value is 1e-90. + * + * A #GParamSpec derived structure that contains the meta data for double properties. + */ +struct _GParamSpecDouble +{ + GParamSpec parent_instance; + + gdouble minimum; + gdouble maximum; + gdouble default_value; + gdouble epsilon; +}; +/** + * GParamSpecString: + * @parent_instance: private #GParamSpec portion + * @default_value: default value for the property specified + * @cset_first: a string containing the allowed values for the first byte + * @cset_nth: a string containing the allowed values for the subsequent bytes + * @substitutor: the replacement byte for bytes which don't match @cset_first or @cset_nth. + * @null_fold_if_empty: replace empty string by %NULL + * @ensure_non_null: replace %NULL strings by an empty string + * + * A #GParamSpec derived structure that contains the meta data for string + * properties. + */ +struct _GParamSpecString +{ + GParamSpec parent_instance; + + gchar *default_value; + gchar *cset_first; + gchar *cset_nth; + gchar substitutor; + guint null_fold_if_empty : 1; + guint ensure_non_null : 1; +}; +/** + * GParamSpecParam: + * @parent_instance: private #GParamSpec portion + * + * A #GParamSpec derived structure that contains the meta data for %G_TYPE_PARAM + * properties. + */ +struct _GParamSpecParam +{ + GParamSpec parent_instance; +}; +/** + * GParamSpecBoxed: + * @parent_instance: private #GParamSpec portion + * + * A #GParamSpec derived structure that contains the meta data for boxed properties. + */ +struct _GParamSpecBoxed +{ + GParamSpec parent_instance; +}; +/** + * GParamSpecPointer: + * @parent_instance: private #GParamSpec portion + * + * A #GParamSpec derived structure that contains the meta data for pointer properties. + */ +struct _GParamSpecPointer +{ + GParamSpec parent_instance; +}; +/** + * GParamSpecValueArray: + * @parent_instance: private #GParamSpec portion + * @element_spec: a #GParamSpec describing the elements contained in arrays of this property, may be %NULL + * @fixed_n_elements: if greater than 0, arrays of this property will always have this many elements + * + * A #GParamSpec derived structure that contains the meta data for #GValueArray properties. + */ +struct _GParamSpecValueArray +{ + GParamSpec parent_instance; + GParamSpec *element_spec; + guint fixed_n_elements; +}; +/** + * GParamSpecObject: + * @parent_instance: private #GParamSpec portion + * + * A #GParamSpec derived structure that contains the meta data for object properties. + */ +struct _GParamSpecObject +{ + GParamSpec parent_instance; +}; +/** + * GParamSpecOverride: + * + * This is a type of #GParamSpec type that simply redirects operations to + * another paramspec. All operations other than getting or + * setting the value are redirected, including accessing the nick and + * blurb, validating a value, and so forth. See + * g_param_spec_get_redirect_target() for retrieving the overridden + * property. #GParamSpecOverride is used in implementing + * g_object_class_override_property(), and will not be directly useful + * unless you are implementing a new base type similar to GObject. + * + * Since: 2.4 + */ +struct _GParamSpecOverride +{ + /*< private >*/ + GParamSpec parent_instance; + GParamSpec *overridden; +}; +/** + * GParamSpecGType: + * @parent_instance: private #GParamSpec portion + * @is_a_type: a #GType whose subtypes can occur as values + * + * A #GParamSpec derived structure that contains the meta data for #GType properties. + * + * Since: 2.10 + */ +struct _GParamSpecGType +{ + GParamSpec parent_instance; + GType is_a_type; +}; +/** + * GParamSpecVariant: + * @parent_instance: private #GParamSpec portion + * @type: a #GVariantType, or %NULL + * @default_value: a #GVariant, or %NULL + * + * A #GParamSpec derived structure that contains the meta data for #GVariant properties. + * + * When comparing values with g_param_values_cmp(), scalar values with the same + * type will be compared with g_variant_compare(). Other non-%NULL variants will + * be checked for equality with g_variant_equal(), and their sort order is + * otherwise undefined. %NULL is ordered before non-%NULL variants. Two %NULL + * values compare equal. + * + * Since: 2.26 + */ +struct _GParamSpecVariant +{ + GParamSpec parent_instance; + GVariantType *type; + GVariant *default_value; + + /*< private >*/ + gpointer padding[4]; +}; + +/* --- GParamSpec prototypes --- */ +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_char (const gchar *name, + const gchar *nick, + const gchar *blurb, + gint8 minimum, + gint8 maximum, + gint8 default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_uchar (const gchar *name, + const gchar *nick, + const gchar *blurb, + guint8 minimum, + guint8 maximum, + guint8 default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_boolean (const gchar *name, + const gchar *nick, + const gchar *blurb, + gboolean default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_int (const gchar *name, + const gchar *nick, + const gchar *blurb, + gint minimum, + gint maximum, + gint default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_uint (const gchar *name, + const gchar *nick, + const gchar *blurb, + guint minimum, + guint maximum, + guint default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_long (const gchar *name, + const gchar *nick, + const gchar *blurb, + glong minimum, + glong maximum, + glong default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_ulong (const gchar *name, + const gchar *nick, + const gchar *blurb, + gulong minimum, + gulong maximum, + gulong default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_int64 (const gchar *name, + const gchar *nick, + const gchar *blurb, + gint64 minimum, + gint64 maximum, + gint64 default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_uint64 (const gchar *name, + const gchar *nick, + const gchar *blurb, + guint64 minimum, + guint64 maximum, + guint64 default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_unichar (const gchar *name, + const gchar *nick, + const gchar *blurb, + gunichar default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_enum (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType enum_type, + gint default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_flags (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType flags_type, + guint default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_float (const gchar *name, + const gchar *nick, + const gchar *blurb, + gfloat minimum, + gfloat maximum, + gfloat default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_double (const gchar *name, + const gchar *nick, + const gchar *blurb, + gdouble minimum, + gdouble maximum, + gdouble default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_string (const gchar *name, + const gchar *nick, + const gchar *blurb, + const gchar *default_value, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_param (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType param_type, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_boxed (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType boxed_type, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_pointer (const gchar *name, + const gchar *nick, + const gchar *blurb, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_value_array (const gchar *name, + const gchar *nick, + const gchar *blurb, + GParamSpec *element_spec, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_object (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType object_type, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_override (const gchar *name, + GParamSpec *overridden); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_gtype (const gchar *name, + const gchar *nick, + const gchar *blurb, + GType is_a_type, + GParamFlags flags); +GLIB_AVAILABLE_IN_ALL +GParamSpec* g_param_spec_variant (const gchar *name, + const gchar *nick, + const gchar *blurb, + const GVariantType *type, + GVariant *default_value, + GParamFlags flags); + +/* --- internal --- */ +/* We prefix variable declarations so they can + * properly get exported in windows dlls. + */ +#ifndef GOBJECT_VAR +# ifdef G_PLATFORM_WIN32 +# ifdef GOBJECT_STATIC_COMPILATION +# define GOBJECT_VAR extern +# else /* !GOBJECT_STATIC_COMPILATION */ +# ifdef GOBJECT_COMPILATION +# ifdef DLL_EXPORT +# define GOBJECT_VAR extern __declspec(dllexport) +# else /* !DLL_EXPORT */ +# define GOBJECT_VAR extern +# endif /* !DLL_EXPORT */ +# else /* !GOBJECT_COMPILATION */ +# define GOBJECT_VAR extern __declspec(dllimport) +# endif /* !GOBJECT_COMPILATION */ +# endif /* !GOBJECT_STATIC_COMPILATION */ +# else /* !G_PLATFORM_WIN32 */ +# define GOBJECT_VAR _GLIB_EXTERN +# endif /* !G_PLATFORM_WIN32 */ +#endif /* GOBJECT_VAR */ + +GOBJECT_VAR GType *g_param_spec_types; + +G_END_DECLS + +#endif /* __G_PARAMSPECS_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2001 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_SOURCECLOSURE_H__ +#define __G_SOURCECLOSURE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +GLIB_AVAILABLE_IN_ALL +void g_source_set_closure (GSource *source, + GClosure *closure); + +GLIB_AVAILABLE_IN_ALL +void g_source_set_dummy_callback (GSource *source); + +G_END_DECLS + +#endif /* __G_SOURCECLOSURE_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ +#ifndef __G_TYPE_MODULE_H__ +#define __G_TYPE_MODULE_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +typedef struct _GTypeModule GTypeModule; +typedef struct _GTypeModuleClass GTypeModuleClass; + +#define G_TYPE_TYPE_MODULE (g_type_module_get_type ()) +#define G_TYPE_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), G_TYPE_TYPE_MODULE, GTypeModule)) +#define G_TYPE_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TYPE_MODULE, GTypeModuleClass)) +#define G_IS_TYPE_MODULE(module) (G_TYPE_CHECK_INSTANCE_TYPE ((module), G_TYPE_TYPE_MODULE)) +#define G_IS_TYPE_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TYPE_MODULE)) +#define G_TYPE_MODULE_GET_CLASS(module) (G_TYPE_INSTANCE_GET_CLASS ((module), G_TYPE_TYPE_MODULE, GTypeModuleClass)) + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTypeModule, g_object_unref) + +/** + * GTypeModule: + * @name: the name of the module + * + * The members of the GTypeModule structure should not + * be accessed directly, except for the @name field. + */ +struct _GTypeModule +{ + GObject parent_instance; + + guint use_count; + GSList *type_infos; + GSList *interface_infos; + + /*< public >*/ + gchar *name; +}; + +/** + * GTypeModuleClass: + * @parent_class: the parent class + * @load: loads the module and registers one or more types using + * g_type_module_register_type(). + * @unload: unloads the module + * + * In order to implement dynamic loading of types based on #GTypeModule, + * the @load and @unload functions in #GTypeModuleClass must be implemented. + */ +struct _GTypeModuleClass +{ + GObjectClass parent_class; + + /*< public >*/ + gboolean (* load) (GTypeModule *module); + void (* unload) (GTypeModule *module); + + /*< private >*/ + /* Padding for future expansion */ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); + void (*reserved4) (void); +}; + +/** + * G_DEFINE_DYNAMIC_TYPE: + * @TN: The name of the new type, in Camel case. + * @t_n: The name of the new type, in lowercase, with words + * separated by '_'. + * @T_P: The #GType of the parent type. + * + * A convenience macro for dynamic type implementations, which declares a + * class initialization function, an instance initialization function (see + * #GTypeInfo for information about these) and a static variable named + * `t_n`_parent_class pointing to the parent class. Furthermore, + * it defines a `*_get_type()` and a static `*_register_type()` functions + * for use in your `module_init()`. + * + * See G_DEFINE_DYNAMIC_TYPE_EXTENDED() for an example. + * + * Since: 2.14 + */ +#define G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P) G_DEFINE_DYNAMIC_TYPE_EXTENDED (TN, t_n, T_P, 0, {}) +/** + * G_DEFINE_DYNAMIC_TYPE_EXTENDED: + * @TypeName: The name of the new type, in Camel case. + * @type_name: The name of the new type, in lowercase, with words + * separated by '_'. + * @TYPE_PARENT: The #GType of the parent type. + * @flags: #GTypeFlags to pass to g_type_module_register_type() + * @CODE: Custom code that gets inserted in the *_get_type() function. + * + * A more general version of G_DEFINE_DYNAMIC_TYPE() which + * allows to specify #GTypeFlags and custom code. + * + * |[ + * G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtkGadget, + * gtk_gadget, + * GTK_TYPE_THING, + * 0, + * G_IMPLEMENT_INTERFACE_DYNAMIC (TYPE_GIZMO, + * gtk_gadget_gizmo_init)); + * ]| + * expands to + * |[ + * static void gtk_gadget_init (GtkGadget *self); + * static void gtk_gadget_class_init (GtkGadgetClass *klass); + * static void gtk_gadget_class_finalize (GtkGadgetClass *klass); + * + * static gpointer gtk_gadget_parent_class = NULL; + * static GType gtk_gadget_type_id = 0; + * + * static void gtk_gadget_class_intern_init (gpointer klass) + * { + * gtk_gadget_parent_class = g_type_class_peek_parent (klass); + * gtk_gadget_class_init ((GtkGadgetClass*) klass); + * } + * + * GType + * gtk_gadget_get_type (void) + * { + * return gtk_gadget_type_id; + * } + * + * static void + * gtk_gadget_register_type (GTypeModule *type_module) + * { + * const GTypeInfo g_define_type_info = { + * sizeof (GtkGadgetClass), + * (GBaseInitFunc) NULL, + * (GBaseFinalizeFunc) NULL, + * (GClassInitFunc) gtk_gadget_class_intern_init, + * (GClassFinalizeFunc) gtk_gadget_class_finalize, + * NULL, // class_data + * sizeof (GtkGadget), + * 0, // n_preallocs + * (GInstanceInitFunc) gtk_gadget_init, + * NULL // value_table + * }; + * gtk_gadget_type_id = g_type_module_register_type (type_module, + * GTK_TYPE_THING, + * "GtkGadget", + * &g_define_type_info, + * (GTypeFlags) flags); + * { + * const GInterfaceInfo g_implement_interface_info = { + * (GInterfaceInitFunc) gtk_gadget_gizmo_init + * }; + * g_type_module_add_interface (type_module, g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); + * } + * } + * ]| + * + * Since: 2.14 + */ +#define G_DEFINE_DYNAMIC_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \ +static void type_name##_init (TypeName *self); \ +static void type_name##_class_init (TypeName##Class *klass); \ +static void type_name##_class_finalize (TypeName##Class *klass); \ +static gpointer type_name##_parent_class = NULL; \ +static GType type_name##_type_id = 0; \ +static gint TypeName##_private_offset; \ +\ +_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ +\ +G_GNUC_UNUSED \ +static inline gpointer \ +type_name##_get_instance_private (TypeName *self) \ +{ \ + return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \ +} \ +\ +GType \ +type_name##_get_type (void) \ +{ \ + return type_name##_type_id; \ +} \ +static void \ +type_name##_register_type (GTypeModule *type_module) \ +{ \ + GType g_define_type_id G_GNUC_UNUSED; \ + const GTypeInfo g_define_type_info = { \ + sizeof (TypeName##Class), \ + (GBaseInitFunc) NULL, \ + (GBaseFinalizeFunc) NULL, \ + (GClassInitFunc)(void (*)(void)) type_name##_class_intern_init, \ + (GClassFinalizeFunc)(void (*)(void)) type_name##_class_finalize, \ + NULL, /* class_data */ \ + sizeof (TypeName), \ + 0, /* n_preallocs */ \ + (GInstanceInitFunc)(void (*)(void)) type_name##_init, \ + NULL /* value_table */ \ + }; \ + type_name##_type_id = g_type_module_register_type (type_module, \ + TYPE_PARENT, \ + #TypeName, \ + &g_define_type_info, \ + (GTypeFlags) flags); \ + g_define_type_id = type_name##_type_id; \ + { CODE ; } \ +} + +/** + * G_IMPLEMENT_INTERFACE_DYNAMIC: + * @TYPE_IFACE: The #GType of the interface to add + * @iface_init: The interface init function + * + * A convenience macro to ease interface addition in the @_C_ section + * of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). See G_DEFINE_DYNAMIC_TYPE_EXTENDED() + * for an example. + * + * Note that this macro can only be used together with the + * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable + * names from that macro. + * + * Since: 2.24 + */ +#define G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) { \ + const GInterfaceInfo g_implement_interface_info = { \ + (GInterfaceInitFunc)(void (*)(void)) iface_init, NULL, NULL \ + }; \ + g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \ +} + +/** + * G_ADD_PRIVATE_DYNAMIC: + * @TypeName: the name of the type in CamelCase + * + * A convenience macro to ease adding private data to instances of a new dynamic + * type in the @_C_ section of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). See + * G_ADD_PRIVATE() for details, it is similar but for static types. + * + * Note that this macro can only be used together with the + * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable + * names from that macro. + * + * Since: 2.38 + */ +#define G_ADD_PRIVATE_DYNAMIC(TypeName) { \ + TypeName##_private_offset = sizeof (TypeName##Private); \ +} + +GLIB_AVAILABLE_IN_ALL +GType g_type_module_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +gboolean g_type_module_use (GTypeModule *module); +GLIB_AVAILABLE_IN_ALL +void g_type_module_unuse (GTypeModule *module); +GLIB_AVAILABLE_IN_ALL +void g_type_module_set_name (GTypeModule *module, + const gchar *name); +GLIB_AVAILABLE_IN_ALL +GType g_type_module_register_type (GTypeModule *module, + GType parent_type, + const gchar *type_name, + const GTypeInfo *type_info, + GTypeFlags flags); +GLIB_AVAILABLE_IN_ALL +void g_type_module_add_interface (GTypeModule *module, + GType instance_type, + GType interface_type, + const GInterfaceInfo *interface_info); +GLIB_AVAILABLE_IN_ALL +GType g_type_module_register_enum (GTypeModule *module, + const gchar *name, + const GEnumValue *const_static_values); +GLIB_AVAILABLE_IN_ALL +GType g_type_module_register_flags (GTypeModule *module, + const gchar *name, + const GFlagsValue *const_static_values); + +G_END_DECLS + +#endif /* __G_TYPE_MODULE_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2000 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + */ +#ifndef __G_TYPE_PLUGIN_H__ +#define __G_TYPE_PLUGIN_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* --- type macros --- */ +#define G_TYPE_TYPE_PLUGIN (g_type_plugin_get_type ()) +#define G_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TYPE_PLUGIN, GTypePlugin)) +#define G_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), G_TYPE_TYPE_PLUGIN, GTypePluginClass)) +#define G_IS_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TYPE_PLUGIN)) +#define G_IS_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), G_TYPE_TYPE_PLUGIN)) +#define G_TYPE_PLUGIN_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_TYPE_PLUGIN, GTypePluginClass)) + + +/* --- typedefs & structures --- */ +typedef struct _GTypePluginClass GTypePluginClass; +/** + * GTypePluginUse: + * @plugin: the #GTypePlugin whose use count should be increased + * + * The type of the @use_plugin function of #GTypePluginClass, which gets called + * to increase the use count of @plugin. + */ +typedef void (*GTypePluginUse) (GTypePlugin *plugin); +/** + * GTypePluginUnuse: + * @plugin: the #GTypePlugin whose use count should be decreased + * + * The type of the @unuse_plugin function of #GTypePluginClass. + */ +typedef void (*GTypePluginUnuse) (GTypePlugin *plugin); +/** + * GTypePluginCompleteTypeInfo: + * @plugin: the #GTypePlugin + * @g_type: the #GType whose info is completed + * @info: the #GTypeInfo struct to fill in + * @value_table: the #GTypeValueTable to fill in + * + * The type of the @complete_type_info function of #GTypePluginClass. + */ +typedef void (*GTypePluginCompleteTypeInfo) (GTypePlugin *plugin, + GType g_type, + GTypeInfo *info, + GTypeValueTable *value_table); +/** + * GTypePluginCompleteInterfaceInfo: + * @plugin: the #GTypePlugin + * @instance_type: the #GType of an instantiatable type to which the interface + * is added + * @interface_type: the #GType of the interface whose info is completed + * @info: the #GInterfaceInfo to fill in + * + * The type of the @complete_interface_info function of #GTypePluginClass. + */ +typedef void (*GTypePluginCompleteInterfaceInfo) (GTypePlugin *plugin, + GType instance_type, + GType interface_type, + GInterfaceInfo *info); +/** + * GTypePlugin: + * + * The GTypePlugin typedef is used as a placeholder + * for objects that implement the GTypePlugin interface. + */ +/** + * GTypePluginClass: + * @use_plugin: Increases the use count of the plugin. + * @unuse_plugin: Decreases the use count of the plugin. + * @complete_type_info: Fills in the #GTypeInfo and + * #GTypeValueTable structs for the type. The structs are initialized + * with `memset(s, 0, sizeof (s))` before calling this function. + * @complete_interface_info: Fills in missing parts of the #GInterfaceInfo + * for the interface. The structs is initialized with + * `memset(s, 0, sizeof (s))` before calling this function. + * + * The #GTypePlugin interface is used by the type system in order to handle + * the lifecycle of dynamically loaded types. + */ +struct _GTypePluginClass +{ + /*< private >*/ + GTypeInterface base_iface; + + /*< public >*/ + GTypePluginUse use_plugin; + GTypePluginUnuse unuse_plugin; + GTypePluginCompleteTypeInfo complete_type_info; + GTypePluginCompleteInterfaceInfo complete_interface_info; +}; + + +/* --- prototypes --- */ +GLIB_AVAILABLE_IN_ALL +GType g_type_plugin_get_type (void) G_GNUC_CONST; +GLIB_AVAILABLE_IN_ALL +void g_type_plugin_use (GTypePlugin *plugin); +GLIB_AVAILABLE_IN_ALL +void g_type_plugin_unuse (GTypePlugin *plugin); +GLIB_AVAILABLE_IN_ALL +void g_type_plugin_complete_type_info (GTypePlugin *plugin, + GType g_type, + GTypeInfo *info, + GTypeValueTable *value_table); +GLIB_AVAILABLE_IN_ALL +void g_type_plugin_complete_interface_info (GTypePlugin *plugin, + GType instance_type, + GType interface_type, + GInterfaceInfo *info); + +G_END_DECLS + +#endif /* __G_TYPE_PLUGIN_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 2001 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gvaluearray.h: GLib array type holding GValues + */ +#ifndef __G_VALUE_ARRAY_H__ +#define __G_VALUE_ARRAY_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/** + * G_TYPE_VALUE_ARRAY: + * + * The type ID of the "GValueArray" type which is a boxed type, + * used to pass around pointers to GValueArrays. + * + * Deprecated: 2.32: Use #GArray instead of #GValueArray + */ +#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ()) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(G_TYPE_ARRAY) + +/* --- typedefs & structs --- */ +typedef struct _GValueArray GValueArray; +/** + * GValueArray: + * @n_values: number of values contained in the array + * @values: array of values + * + * A #GValueArray contains an array of #GValue elements. + */ +struct _GValueArray +{ + guint n_values; + GValue *values; + + /*< private >*/ + guint n_prealloced; +}; + +/* --- prototypes --- */ +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GType g_value_array_get_type (void) G_GNUC_CONST; + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValue* g_value_array_get_nth (GValueArray *value_array, + guint index_); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_new (guint n_prealloced); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +void g_value_array_free (GValueArray *value_array); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_copy (const GValueArray *value_array); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_prepend (GValueArray *value_array, + const GValue *value); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_append (GValueArray *value_array, + const GValue *value); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_insert (GValueArray *value_array, + guint index_, + const GValue *value); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_remove (GValueArray *value_array, + guint index_); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_sort (GValueArray *value_array, + GCompareFunc compare_func); + +GLIB_DEPRECATED_IN_2_32_FOR(GArray) +GValueArray* g_value_array_sort_with_data (GValueArray *value_array, + GCompareDataFunc compare_func, + gpointer user_data); + + +G_END_DECLS + +#endif /* __G_VALUE_ARRAY_H__ */ +/* GObject - GLib Type, Object, Parameter and Signal Library + * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see . + * + * gvaluetypes.h: GLib default values + */ +#ifndef __G_VALUETYPES_H__ +#define __G_VALUETYPES_H__ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + + +G_BEGIN_DECLS + +/* --- type macros --- */ +/** + * G_VALUE_HOLDS_CHAR: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR)) +/** + * G_VALUE_HOLDS_UCHAR: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR)) +/** + * G_VALUE_HOLDS_BOOLEAN: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN)) +/** + * G_VALUE_HOLDS_INT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_INT. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT)) +/** + * G_VALUE_HOLDS_UINT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_UINT. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT)) +/** + * G_VALUE_HOLDS_LONG: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_LONG. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG)) +/** + * G_VALUE_HOLDS_ULONG: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG)) +/** + * G_VALUE_HOLDS_INT64: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_INT64. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_INT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64)) +/** + * G_VALUE_HOLDS_UINT64: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_UINT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64)) +/** + * G_VALUE_HOLDS_FLOAT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT)) +/** + * G_VALUE_HOLDS_DOUBLE: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE)) +/** + * G_VALUE_HOLDS_STRING: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_STRING. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING)) +/** + * G_VALUE_IS_INTERNED_STRING: + * @value: a valid #GValue structure + * + * Checks whether @value contains a string which is canonical. + * + * Returns: %TRUE if the value contains a string in its canonical + * representation, as returned by g_intern_string(). See also + * g_value_set_interned_string(). + * + * Since: 2.66 + */ +#define G_VALUE_IS_INTERNED_STRING(value) (G_VALUE_HOLDS_STRING (value) && ((value)->data[1].v_uint & G_VALUE_INTERNED_STRING)) GLIB_AVAILABLE_MACRO_IN_2_66 +/** + * G_VALUE_HOLDS_POINTER: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER. + * + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER)) +/** + * G_TYPE_GTYPE: + * + * The type for #GType. + */ +#define G_TYPE_GTYPE (g_gtype_get_type()) +/** + * G_VALUE_HOLDS_GTYPE: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE. + * + * Since: 2.12 + * Returns: %TRUE on success. + */ +#define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE)) +/** + * G_VALUE_HOLDS_VARIANT: + * @value: a valid #GValue structure + * + * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT. + * + * Returns: %TRUE on success. + * + * Since: 2.26 + */ +#define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT)) + + +/* --- prototypes --- */ +GLIB_DEPRECATED_IN_2_32_FOR(g_value_set_schar) +void g_value_set_char (GValue *value, + gchar v_char); +GLIB_DEPRECATED_IN_2_32_FOR(g_value_get_schar) +gchar g_value_get_char (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_schar (GValue *value, + gint8 v_char); +GLIB_AVAILABLE_IN_ALL +gint8 g_value_get_schar (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_uchar (GValue *value, + guchar v_uchar); +GLIB_AVAILABLE_IN_ALL +guchar g_value_get_uchar (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_boolean (GValue *value, + gboolean v_boolean); +GLIB_AVAILABLE_IN_ALL +gboolean g_value_get_boolean (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_int (GValue *value, + gint v_int); +GLIB_AVAILABLE_IN_ALL +gint g_value_get_int (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_uint (GValue *value, + guint v_uint); +GLIB_AVAILABLE_IN_ALL +guint g_value_get_uint (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_long (GValue *value, + glong v_long); +GLIB_AVAILABLE_IN_ALL +glong g_value_get_long (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_ulong (GValue *value, + gulong v_ulong); +GLIB_AVAILABLE_IN_ALL +gulong g_value_get_ulong (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_int64 (GValue *value, + gint64 v_int64); +GLIB_AVAILABLE_IN_ALL +gint64 g_value_get_int64 (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_uint64 (GValue *value, + guint64 v_uint64); +GLIB_AVAILABLE_IN_ALL +guint64 g_value_get_uint64 (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_float (GValue *value, + gfloat v_float); +GLIB_AVAILABLE_IN_ALL +gfloat g_value_get_float (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_double (GValue *value, + gdouble v_double); +GLIB_AVAILABLE_IN_ALL +gdouble g_value_get_double (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_string (GValue *value, + const gchar *v_string); +GLIB_AVAILABLE_IN_ALL +void g_value_set_static_string (GValue *value, + const gchar *v_string); +GLIB_AVAILABLE_IN_2_66 +void g_value_set_interned_string (GValue *value, + const gchar *v_string); +GLIB_AVAILABLE_IN_ALL +const gchar * g_value_get_string (const GValue *value); +GLIB_AVAILABLE_IN_ALL +gchar* g_value_dup_string (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_pointer (GValue *value, + gpointer v_pointer); +GLIB_AVAILABLE_IN_ALL +gpointer g_value_get_pointer (const GValue *value); +GLIB_AVAILABLE_IN_ALL +GType g_gtype_get_type (void); +GLIB_AVAILABLE_IN_ALL +void g_value_set_gtype (GValue *value, + GType v_gtype); +GLIB_AVAILABLE_IN_ALL +GType g_value_get_gtype (const GValue *value); +GLIB_AVAILABLE_IN_ALL +void g_value_set_variant (GValue *value, + GVariant *variant); +GLIB_AVAILABLE_IN_ALL +void g_value_take_variant (GValue *value, + GVariant *variant); +GLIB_AVAILABLE_IN_ALL +GVariant* g_value_get_variant (const GValue *value); +GLIB_AVAILABLE_IN_ALL +GVariant* g_value_dup_variant (const GValue *value); + + +/* Convenience for registering new pointer types */ +GLIB_AVAILABLE_IN_ALL +GType g_pointer_type_register_static (const gchar *name); + +/* debugging aid, describe value contents as string */ +GLIB_AVAILABLE_IN_ALL +gchar* g_strdup_value_contents (const GValue *value); + + +GLIB_AVAILABLE_IN_ALL +void g_value_take_string (GValue *value, + gchar *v_string); +GLIB_DEPRECATED_FOR(g_value_take_string) +void g_value_set_string_take_ownership (GValue *value, + gchar *v_string); + + +/* humpf, need a C representable type name for G_TYPE_STRING */ +/** + * gchararray: + * + * A C representable type name for #G_TYPE_STRING. + */ +typedef gchar* gchararray; + + +G_END_DECLS + +#endif /* __G_VALUETYPES_H__ */ + +/* + * Copyright © 2015 Canonical Limited + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + * + * Author: Ryan Lortie + */ + +#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) +#error "Only can be included directly." +#endif + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GClosure, g_closure_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GEnumClass, g_type_class_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFlagsClass, g_type_class_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GParamSpec, g_param_spec_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTypeClass, g_type_class_unref) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset) + +#undef __GLIB_GOBJECT_H_INSIDE__ + +GLIB_AVAILABLE_IN_2_68 +void gobject_init (void); + +#endif /* __GLIB_GOBJECT_H__ */ + +G_BEGIN_DECLS + +/* Enumerations from "gumdarwinmodule.h" */ +GType gum_darwin_module_flags_get_type (void) G_GNUC_CONST; +#define GUM_TYPE_DARWIN_MODULE_FLAGS (gum_darwin_module_flags_get_type ()) + +/* Enumerations from "gumdefs.h" */ +GType gum_cpu_type_get_type (void) G_GNUC_CONST; +#define GUM_TYPE_CPU_TYPE (gum_cpu_type_get_type ()) + +/* Enumerations from "guminterceptor.h" */ +GType gum_attach_return_get_type (void) G_GNUC_CONST; +#define GUM_TYPE_ATTACH_RETURN (gum_attach_return_get_type ()) +GType gum_replace_return_get_type (void) G_GNUC_CONST; +#define GUM_TYPE_REPLACE_RETURN (gum_replace_return_get_type ()) + +/* Enumerations from "gumprocess.h" */ +GType gum_code_signing_policy_get_type (void) G_GNUC_CONST; +#define GUM_TYPE_CODE_SIGNING_POLICY (gum_code_signing_policy_get_type ()) +G_END_DECLS + +#endif /* __GUM_ENUM_TYPES_H__ */ + +/* Generated data ends here */ + + +#if !defined (GUM_STATIC) && defined (G_OS_WIN32) +# ifdef GUM_EXPORTS +# define GUM_API __declspec(dllexport) +# else +# define GUM_API __declspec(dllimport) +# endif +#else +# define GUM_API +#endif + +#if !defined (__arm__) && !defined (__aarch64__) +# if GLIB_SIZEOF_VOID_P == 4 +# define GUM_NATIVE_CPU GUM_CPU_IA32 +# else +# define GUM_NATIVE_CPU GUM_CPU_AMD64 +# endif +#elif defined (__arm__) || defined (__aarch64__) +# if GLIB_SIZEOF_VOID_P == 4 +# define GUM_NATIVE_CPU GUM_CPU_ARM +# else +# define GUM_NATIVE_CPU GUM_CPU_ARM64 +# endif +#elif defined (__mips__) +# define GUM_NATIVE_CPU GUM_CPU_MIPS +#endif +#ifdef G_OS_WIN32 +# define GUM_NATIVE_ABI GUM_ABI_WINDOWS +# define GUM_NATIVE_ABI_IS_WINDOWS 1 +# define GUM_NATIVE_ABI_IS_UNIX 0 +#else +# define GUM_NATIVE_ABI GUM_ABI_UNIX +# define GUM_NATIVE_ABI_IS_WINDOWS 0 +# define GUM_NATIVE_ABI_IS_UNIX 1 +#endif + +G_BEGIN_DECLS + +typedef guint64 GumAddress; +#define GUM_ADDRESS(a) ((GumAddress) (guintptr) (a)) +#define GUM_TYPE_ADDRESS (gum_address_get_type ()) +typedef guint GumOS; +typedef guint GumCallingConvention; +typedef guint GumAbiType; +typedef guint GumCpuFeatures; +typedef guint GumInstructionEncoding; +typedef guint GumArgType; +typedef struct _GumArgument GumArgument; +typedef guint GumBranchHint; +typedef struct _GumIA32CpuContext GumIA32CpuContext; +typedef struct _GumX64CpuContext GumX64CpuContext; +typedef struct _GumArmCpuContext GumArmCpuContext; +typedef struct _GumArm64CpuContext GumArm64CpuContext; +typedef struct _GumMipsCpuContext GumMipsCpuContext; +/* + * The only non-legacy big-endian configuration on 32-bit ARM systems is BE8. + * In this configuration, whilst the data is in big-endian, the code stream is + * still in little-endian. Since Capstone is disassembling the code stream, it + * should work in little-endian even on BE8 systems. + */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN || defined (__arm__) +# define GUM_DEFAULT_CS_ENDIAN CS_MODE_LITTLE_ENDIAN +#else +# define GUM_DEFAULT_CS_ENDIAN CS_MODE_BIG_ENDIAN +#endif +#if !defined (__arm__) && !defined (__aarch64__) && !defined (__mips__) +# define GUM_DEFAULT_CS_ARCH CS_ARCH_X86 +# if GLIB_SIZEOF_VOID_P == 4 +/** + * GUM_DEFAULT_CS_MODE: (skip) + */ +# define GUM_DEFAULT_CS_MODE CS_MODE_32 +typedef GumIA32CpuContext GumCpuContext; +# else +/** + * GUM_DEFAULT_CS_MODE: (skip) + */ +# define GUM_DEFAULT_CS_MODE CS_MODE_64 +typedef GumX64CpuContext GumCpuContext; +# endif +#elif defined (__arm__) && !defined (__aarch64__) +# define GUM_DEFAULT_CS_ARCH CS_ARCH_ARM +/** + * GUM_DEFAULT_CS_MODE: (skip) + */ +# define GUM_DEFAULT_CS_MODE \ + ((cs_mode) (CS_MODE_ARM | CS_MODE_V8 | GUM_DEFAULT_CS_ENDIAN)) +# define GUM_PSR_T_BIT 0x20 +typedef GumArmCpuContext GumCpuContext; +#elif defined (__aarch64__) +# define GUM_DEFAULT_CS_ARCH CS_ARCH_ARM64 +/** + * GUM_DEFAULT_CS_MODE: (skip) + */ +# define GUM_DEFAULT_CS_MODE GUM_DEFAULT_CS_ENDIAN +typedef GumArm64CpuContext GumCpuContext; +#elif defined (__mips__) +# define GUM_DEFAULT_CS_ARCH CS_ARCH_MIPS +# if GLIB_SIZEOF_VOID_P == 4 +/** + * GUM_DEFAULT_CS_MODE: (skip) + */ +# define GUM_DEFAULT_CS_MODE ((cs_mode) \ + (CS_MODE_MIPS32 | GUM_DEFAULT_CS_ENDIAN)) +# else +/** + * GUM_DEFAULT_CS_MODE: (skip) + */ +# define GUM_DEFAULT_CS_MODE ((cs_mode) \ + (CS_MODE_MIPS64 | GUM_DEFAULT_CS_ENDIAN)) +# endif +typedef GumMipsCpuContext GumCpuContext; +#endif +typedef guint GumRelocationScenario; + +enum _GumOS +{ + GUM_OS_WINDOWS, + GUM_OS_MACOS, + GUM_OS_LINUX, + GUM_OS_IOS, + GUM_OS_ANDROID, + GUM_OS_QNX +}; + +enum _GumCallingConvention +{ + GUM_CALL_CAPI, + GUM_CALL_SYSAPI +}; + +enum _GumAbiType +{ + GUM_ABI_UNIX, + GUM_ABI_WINDOWS +}; + +typedef enum { + GUM_CPU_INVALID, + GUM_CPU_IA32, + GUM_CPU_AMD64, + GUM_CPU_ARM, + GUM_CPU_ARM64, + GUM_CPU_MIPS +} GumCpuType; + +enum _GumCpuFeatures +{ + GUM_CPU_AVX2 = 1 << 0, + GUM_CPU_VFP2 = 1 << 1, + GUM_CPU_VFP3 = 1 << 2, + GUM_CPU_PTRAUTH = 1 << 3, +}; + +enum _GumInstructionEncoding +{ + GUM_INSTRUCTION_DEFAULT, + GUM_INSTRUCTION_SPECIAL +}; + +enum _GumArgType +{ + GUM_ARG_ADDRESS, + GUM_ARG_REGISTER +}; + +struct _GumArgument +{ + GumArgType type; + + union + { + GumAddress address; + gint reg; + } value; +}; + +enum _GumBranchHint +{ + GUM_NO_HINT, + GUM_LIKELY, + GUM_UNLIKELY +}; + +struct _GumIA32CpuContext +{ + guint32 eip; + + guint32 edi; + guint32 esi; + guint32 ebp; + guint32 esp; + guint32 ebx; + guint32 edx; + guint32 ecx; + guint32 eax; +}; + +struct _GumX64CpuContext +{ + guint64 rip; + + guint64 r15; + guint64 r14; + guint64 r13; + guint64 r12; + guint64 r11; + guint64 r10; + guint64 r9; + guint64 r8; + + guint64 rdi; + guint64 rsi; + guint64 rbp; + guint64 rsp; + guint64 rbx; + guint64 rdx; + guint64 rcx; + guint64 rax; +}; + +struct _GumArmCpuContext +{ + guint32 cpsr; + guint32 pc; + guint32 sp; + + guint32 r8; + guint32 r9; + guint32 r10; + guint32 r11; + guint32 r12; + + guint32 r[8]; + guint32 lr; +}; + +struct _GumArm64CpuContext +{ + guint64 pc; + guint64 sp; + + guint64 x[29]; + guint64 fp; + guint64 lr; + guint8 q[128]; +}; + +struct _GumMipsCpuContext +{ + /* + * This structure represents the register state pushed onto the stack by the + * trampoline which allows us to vector from the original minimal assembly + * hook to architecture agnostic C code inside frida-gum. These registers are + * natively sized. Even if some have not been expanded to 64-bits from the + * MIPS32 architecture MIPS can only perform aligned data access and as such + * pushing zero extended values is simpler than attempting to push minimally + * sized data types. + */ + gsize pc; + + gsize gp; + gsize sp; + gsize fp; + gsize ra; + + gsize hi; + gsize lo; + + gsize at; + + gsize v0; + gsize v1; + + gsize a0; + gsize a1; + gsize a2; + gsize a3; + + gsize t0; + gsize t1; + gsize t2; + gsize t3; + gsize t4; + gsize t5; + gsize t6; + gsize t7; + gsize t8; + gsize t9; + + gsize s0; + gsize s1; + gsize s2; + gsize s3; + gsize s4; + gsize s5; + gsize s6; + gsize s7; + + gsize k0; + gsize k1; +}; + +enum _GumRelocationScenario +{ + GUM_SCENARIO_OFFLINE, + GUM_SCENARIO_ONLINE +}; + +#ifndef __arm__ +# if GLIB_SIZEOF_VOID_P == 8 +# define GUM_CPU_CONTEXT_XAX(c) ((c)->rax) +# define GUM_CPU_CONTEXT_XCX(c) ((c)->rcx) +# define GUM_CPU_CONTEXT_XDX(c) ((c)->rdx) +# define GUM_CPU_CONTEXT_XBX(c) ((c)->rbx) +# define GUM_CPU_CONTEXT_XSP(c) ((c)->rsp) +# define GUM_CPU_CONTEXT_XBP(c) ((c)->rbp) +# define GUM_CPU_CONTEXT_XSI(c) ((c)->rsi) +# define GUM_CPU_CONTEXT_XDI(c) ((c)->rdi) +# define GUM_CPU_CONTEXT_XIP(c) ((c)->rip) +# define GUM_CPU_CONTEXT_OFFSET_XAX (G_STRUCT_OFFSET (GumCpuContext, rax)) +# define GUM_CPU_CONTEXT_OFFSET_XCX (G_STRUCT_OFFSET (GumCpuContext, rcx)) +# define GUM_CPU_CONTEXT_OFFSET_XDX (G_STRUCT_OFFSET (GumCpuContext, rdx)) +# define GUM_CPU_CONTEXT_OFFSET_XBX (G_STRUCT_OFFSET (GumCpuContext, rbx)) +# define GUM_CPU_CONTEXT_OFFSET_XSP (G_STRUCT_OFFSET (GumCpuContext, rsp)) +# define GUM_CPU_CONTEXT_OFFSET_XBP (G_STRUCT_OFFSET (GumCpuContext, rbp)) +# define GUM_CPU_CONTEXT_OFFSET_XSI (G_STRUCT_OFFSET (GumCpuContext, rsi)) +# define GUM_CPU_CONTEXT_OFFSET_XDI (G_STRUCT_OFFSET (GumCpuContext, rdi)) +# define GUM_CPU_CONTEXT_OFFSET_XIP (G_STRUCT_OFFSET (GumCpuContext, rip)) +# else +# define GUM_CPU_CONTEXT_XAX(c) ((c)->eax) +# define GUM_CPU_CONTEXT_XCX(c) ((c)->ecx) +# define GUM_CPU_CONTEXT_XDX(c) ((c)->edx) +# define GUM_CPU_CONTEXT_XBX(c) ((c)->ebx) +# define GUM_CPU_CONTEXT_XSP(c) ((c)->esp) +# define GUM_CPU_CONTEXT_XBP(c) ((c)->ebp) +# define GUM_CPU_CONTEXT_XSI(c) ((c)->esi) +# define GUM_CPU_CONTEXT_XDI(c) ((c)->edi) +# define GUM_CPU_CONTEXT_XIP(c) ((c)->eip) +# define GUM_CPU_CONTEXT_OFFSET_XAX (G_STRUCT_OFFSET (GumCpuContext, eax)) +# define GUM_CPU_CONTEXT_OFFSET_XCX (G_STRUCT_OFFSET (GumCpuContext, ecx)) +# define GUM_CPU_CONTEXT_OFFSET_XDX (G_STRUCT_OFFSET (GumCpuContext, edx)) +# define GUM_CPU_CONTEXT_OFFSET_XBX (G_STRUCT_OFFSET (GumCpuContext, ebx)) +# define GUM_CPU_CONTEXT_OFFSET_XSP (G_STRUCT_OFFSET (GumCpuContext, esp)) +# define GUM_CPU_CONTEXT_OFFSET_XBP (G_STRUCT_OFFSET (GumCpuContext, ebp)) +# define GUM_CPU_CONTEXT_OFFSET_XSI (G_STRUCT_OFFSET (GumCpuContext, esi)) +# define GUM_CPU_CONTEXT_OFFSET_XDI (G_STRUCT_OFFSET (GumCpuContext, edi)) +# define GUM_CPU_CONTEXT_OFFSET_XIP (G_STRUCT_OFFSET (GumCpuContext, eip)) +# endif +#endif + +#define GUM_MAX_PATH 260 +#define GUM_MAX_TYPE_NAME 16 +#define GUM_MAX_SYMBOL_NAME 2048 + +#define GUM_MAX_THREADS 768 +#define GUM_MAX_CALL_DEPTH 32 +#define GUM_MAX_BACKTRACE_DEPTH 16 +#define GUM_MAX_WORST_CASE_INFO_SIZE 128 + +#define GUM_MAX_LISTENERS_PER_FUNCTION 2 +#define GUM_MAX_LISTENER_DATA 512 + +#define GUM_MAX_THREAD_RANGES 2 + +#if GLIB_SIZEOF_VOID_P == 8 +#define GUM_CPU_MODE CS_MODE_64 +#define GUM_THUNK +#else +#define GUM_CPU_MODE CS_MODE_32 +#define GUM_THUNK GUM_FASTCALL +#endif +#if !defined (G_OS_WIN32) && GLIB_SIZEOF_VOID_P == 8 +# define GUM_THUNK_REG_ARG0 GUM_REG_XDI +# define GUM_THUNK_REG_ARG1 GUM_REG_XSI +#else +# define GUM_THUNK_REG_ARG0 GUM_REG_XCX +# define GUM_THUNK_REG_ARG1 GUM_REG_XDX +#endif +#define GUM_RED_ZONE_SIZE 128 + +#ifdef _MSC_VER +# define GUM_CDECL __cdecl +# define GUM_STDCALL __stdcall +# define GUM_FASTCALL __fastcall +# define GUM_NOINLINE __declspec (noinline) +#else +# ifndef __arm__ +# if GLIB_SIZEOF_VOID_P == 4 +# define GUM_CDECL __attribute__((cdecl)) +# define GUM_STDCALL __attribute__((stdcall)) +# else +# define GUM_CDECL +# define GUM_STDCALL +# endif +# define GUM_FASTCALL __attribute__((fastcall)) +# else +# define GUM_CDECL +# define GUM_STDCALL +# define GUM_FASTCALL +# endif +# define GUM_NOINLINE __attribute__((noinline)) +#endif + +#define GUM_ALIGN_POINTER(t, p, b) \ + ((t) GSIZE_TO_POINTER (((GPOINTER_TO_SIZE (p) + ((gsize) (b - 1))) & \ + ~((gsize) (b - 1))))) +#define GUM_ALIGN_SIZE(s, b) \ + ((((gsize) s) + ((gsize) (b - 1))) & ~((gsize) (b - 1))) + +#define GUM_FUNCPTR_TO_POINTER(f) (GSIZE_TO_POINTER (f)) +#define GUM_POINTER_TO_FUNCPTR(t, p) ((t) GPOINTER_TO_SIZE (p)) + +#define GUM_INT2_MASK 0x00000003U +#define GUM_INT4_MASK 0x0000000fU +#define GUM_INT5_MASK 0x0000001fU +#define GUM_INT6_MASK 0x0000003fU +#define GUM_INT8_MASK 0x000000ffU +#define GUM_INT10_MASK 0x000003ffU +#define GUM_INT11_MASK 0x000007ffU +#define GUM_INT12_MASK 0x00000fffU +#define GUM_INT14_MASK 0x00003fffU +#define GUM_INT16_MASK 0x0000ffffU +#define GUM_INT18_MASK 0x0003ffffU +#define GUM_INT19_MASK 0x0007ffffU +#define GUM_INT24_MASK 0x00ffffffU +#define GUM_INT26_MASK 0x03ffffffU +#define GUM_INT28_MASK 0x0fffffffU +#define GUM_INT32_MASK 0xffffffffU + +#define GUM_IS_WITHIN_UINT7_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (0) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (127)) +#define GUM_IS_WITHIN_UINT8_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (0) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (255)) +#define GUM_IS_WITHIN_INT8_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-128) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (127)) +#define GUM_IS_WITHIN_INT11_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-1024) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (1023)) +#define GUM_IS_WITHIN_INT14_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-8192) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (8191)) +#define GUM_IS_WITHIN_INT16_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-32768) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (32767)) +#define GUM_IS_WITHIN_INT18_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-131072) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (131071)) +#define GUM_IS_WITHIN_INT19_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-262144) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (262143)) +#define GUM_IS_WITHIN_INT20_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-524288) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (524287)) +#define GUM_IS_WITHIN_INT21_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-1048576) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (1048575)) +#define GUM_IS_WITHIN_INT24_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-8388608) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (8388607)) +#define GUM_IS_WITHIN_INT26_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-33554432) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (33554431)) +#define GUM_IS_WITHIN_INT28_RANGE(i) \ + (((gint64) (i)) >= G_GINT64_CONSTANT (-134217728) && \ + ((gint64) (i)) <= G_GINT64_CONSTANT (134217727)) +#define GUM_IS_WITHIN_INT32_RANGE(i) \ + (((gint64) (i)) >= (gint64) G_MININT32 && \ + ((gint64) (i)) <= (gint64) G_MAXINT32) + +GUM_API GumCpuFeatures gum_query_cpu_features (void); + +GUM_API gpointer gum_cpu_context_get_nth_argument (GumCpuContext * self, + guint n); +GUM_API void gum_cpu_context_replace_nth_argument (GumCpuContext * self, + guint n, gpointer value); +GUM_API gpointer gum_cpu_context_get_return_value (GumCpuContext * self); +GUM_API void gum_cpu_context_replace_return_value (GumCpuContext * self, + gpointer value); + +GUM_API GType gum_address_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif + +/* + * Copyright (C) 2016-2018 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_API_RESOLVER_H__ +#define __GUM_API_RESOLVER_H__ + + +G_BEGIN_DECLS + +#define GUM_TYPE_API_RESOLVER (gum_api_resolver_get_type ()) +G_DECLARE_INTERFACE (GumApiResolver, gum_api_resolver, GUM, API_RESOLVER, + GObject) + +typedef struct _GumApiDetails GumApiDetails; + +typedef gboolean (* GumFoundApiFunc) (const GumApiDetails * details, + gpointer user_data); + +struct _GumApiResolverInterface +{ + GTypeInterface parent; + + void (* enumerate_matches) (GumApiResolver * self, const gchar * query, + GumFoundApiFunc func, gpointer user_data, GError ** error); +}; + +struct _GumApiDetails +{ + const gchar * name; + GumAddress address; +}; + +GUM_API GumApiResolver * gum_api_resolver_make (const gchar * type); + +GUM_API void gum_api_resolver_enumerate_matches (GumApiResolver * self, + const gchar * query, GumFoundApiFunc func, gpointer user_data, + GError ** error); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2008-2018 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_BACKTRACER_H__ +#define __GUM_BACKTRACER_H__ + +/* + * Copyright (C) 2008-2010 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_RETURN_ADDRESS_H__ +#define __GUM_RETURN_ADDRESS_H__ + + +typedef struct _GumReturnAddressDetails GumReturnAddressDetails; +typedef gpointer GumReturnAddress; +typedef struct _GumReturnAddressArray GumReturnAddressArray; + +struct _GumReturnAddressDetails +{ + GumReturnAddress address; + gchar module_name[GUM_MAX_PATH + 1]; + gchar function_name[GUM_MAX_SYMBOL_NAME + 1]; + gchar file_name[GUM_MAX_PATH + 1]; + guint line_number; +}; + +struct _GumReturnAddressArray +{ + guint len; + GumReturnAddress items[GUM_MAX_BACKTRACE_DEPTH]; +}; + +G_BEGIN_DECLS + +GUM_API gboolean gum_return_address_details_from_address ( + GumReturnAddress address, GumReturnAddressDetails * details); + +GUM_API gboolean gum_return_address_array_is_equal ( + const GumReturnAddressArray * array1, + const GumReturnAddressArray * array2); + +G_END_DECLS + +#endif + +G_BEGIN_DECLS + +#define GUM_TYPE_BACKTRACER (gum_backtracer_get_type ()) +G_DECLARE_INTERFACE (GumBacktracer, gum_backtracer, GUM, BACKTRACER, GObject) + +struct _GumBacktracerInterface +{ + GTypeInterface parent; + + void (* generate) (GumBacktracer * self, const GumCpuContext * cpu_context, + GumReturnAddressArray * return_addresses); +}; + +GUM_API GumBacktracer * gum_backtracer_make_accurate (void); +GUM_API GumBacktracer * gum_backtracer_make_fuzzy (void); + +GUM_API void gum_backtracer_generate (GumBacktracer * self, + const GumCpuContext * cpu_context, + GumReturnAddressArray * return_addresses); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2017-2018 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_CLOAK_H__ +#define __GUM_CLOAK_H__ + +/* + * Copyright (C) 2008-2020 Ole André Vadla Ravnås + * Copyright (C) 2008 Christian Berentsen + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_MEMORY_H__ +#define __GUM_MEMORY_H__ + + +#define GUM_TYPE_MEMORY_RANGE (gum_memory_range_get_type ()) +#define GUM_MEMORY_RANGE_INCLUDES(r, a) ((a) >= (r)->base_address && \ + (a) < ((r)->base_address + (r)->size)) + +#define GUM_PAGE_RW ((GumPageProtection) (GUM_PAGE_READ | GUM_PAGE_WRITE)) +#define GUM_PAGE_RX ((GumPageProtection) (GUM_PAGE_READ | GUM_PAGE_EXECUTE)) +#define GUM_PAGE_RWX ((GumPageProtection) (GUM_PAGE_READ | GUM_PAGE_WRITE | \ + GUM_PAGE_EXECUTE)) + +G_BEGIN_DECLS + +typedef guint GumPtrauthSupport; +typedef guint GumRwxSupport; +typedef guint GumMemoryOperation; +typedef guint GumPageProtection; +typedef struct _GumAddressSpec GumAddressSpec; +typedef struct _GumMemoryRange GumMemoryRange; +typedef struct _GumMatchPattern GumMatchPattern; + +typedef gboolean (* GumMemoryIsNearFunc) (gpointer memory, gpointer address); + +enum _GumPtrauthSupport +{ + GUM_PTRAUTH_INVALID, + GUM_PTRAUTH_UNSUPPORTED, + GUM_PTRAUTH_SUPPORTED +}; + +enum _GumRwxSupport +{ + GUM_RWX_NONE, + GUM_RWX_ALLOCATIONS_ONLY, + GUM_RWX_FULL +}; + +enum _GumMemoryOperation +{ + GUM_MEMOP_INVALID, + GUM_MEMOP_READ, + GUM_MEMOP_WRITE, + GUM_MEMOP_EXECUTE +}; + +enum _GumPageProtection +{ + GUM_PAGE_NO_ACCESS = 0, + GUM_PAGE_READ = (1 << 0), + GUM_PAGE_WRITE = (1 << 1), + GUM_PAGE_EXECUTE = (1 << 2), +}; + +struct _GumAddressSpec +{ + gpointer near_address; + gsize max_distance; +}; + +struct _GumMemoryRange +{ + GumAddress base_address; + gsize size; +}; + +typedef void (* GumMemoryPatchApplyFunc) (gpointer mem, gpointer user_data); +typedef gboolean (* GumMemoryScanMatchFunc) (GumAddress address, gsize size, + gpointer user_data); + +GUM_API void gum_internal_heap_ref (void); +GUM_API void gum_internal_heap_unref (void); + +GUM_API gpointer gum_sign_code_pointer (gpointer value); +GUM_API gpointer gum_strip_code_pointer (gpointer value); +GUM_API GumAddress gum_sign_code_address (GumAddress value); +GUM_API GumAddress gum_strip_code_address (GumAddress value); +GUM_API GumPtrauthSupport gum_query_ptrauth_support (void); +GUM_API guint gum_query_page_size (void); +GUM_API gboolean gum_query_is_rwx_supported (void); +GUM_API GumRwxSupport gum_query_rwx_support (void); +GUM_API gboolean gum_memory_is_readable (gconstpointer address, gsize len); +GUM_API guint8 * gum_memory_read (gconstpointer address, gsize len, + gsize * n_bytes_read); +GUM_API gboolean gum_memory_write (gpointer address, const guint8 * bytes, + gsize len); +GUM_API gboolean gum_memory_patch_code (gpointer address, gsize size, + GumMemoryPatchApplyFunc apply, gpointer apply_data); +GUM_API gboolean gum_memory_mark_code (gpointer address, gsize size); + +GUM_API void gum_memory_scan (const GumMemoryRange * range, + const GumMatchPattern * pattern, GumMemoryScanMatchFunc func, + gpointer user_data); + +GUM_API GumMatchPattern * gum_match_pattern_new_from_string ( + const gchar * match_combined_str); +GUM_API void gum_match_pattern_free (GumMatchPattern * pattern); + +GUM_API void gum_ensure_code_readable (gconstpointer address, gsize size); + +GUM_API void gum_mprotect (gpointer address, gsize size, + GumPageProtection page_prot); +GUM_API gboolean gum_try_mprotect (gpointer address, gsize size, + GumPageProtection page_prot); + +GUM_API void gum_clear_cache (gpointer address, gsize size); + +#define gum_new(struct_type, n_structs) \ + ((struct_type *) gum_malloc (n_structs * sizeof (struct_type))) +#define gum_new0(struct_type, n_structs) \ + ((struct_type *) gum_malloc0 (n_structs * sizeof (struct_type))) + +GUM_API guint gum_peek_private_memory_usage (void); + +GUM_API gpointer gum_malloc (gsize size); +GUM_API gpointer gum_malloc0 (gsize size); +GUM_API gsize gum_malloc_usable_size (gconstpointer mem); +GUM_API gpointer gum_calloc (gsize count, gsize size); +GUM_API gpointer gum_realloc (gpointer mem, gsize size); +GUM_API gpointer gum_memalign (gsize alignment, gsize size); +GUM_API gpointer gum_memdup (gconstpointer mem, gsize byte_size); +GUM_API void gum_free (gpointer mem); + +GUM_API gpointer gum_alloc_n_pages (guint n_pages, GumPageProtection page_prot); +GUM_API gpointer gum_try_alloc_n_pages (guint n_pages, + GumPageProtection page_prot); +GUM_API gpointer gum_alloc_n_pages_near (guint n_pages, + GumPageProtection page_prot, const GumAddressSpec * address_spec); +GUM_API gpointer gum_try_alloc_n_pages_near (guint n_pages, + GumPageProtection page_prot, const GumAddressSpec * address_spec); +GUM_API void gum_query_page_allocation_range (gconstpointer mem, guint size, + GumMemoryRange * range); +GUM_API void gum_free_pages (gpointer mem); + +GUM_API gpointer gum_memory_allocate (gpointer address, gsize size, + gsize alignment, GumPageProtection page_prot); +GUM_API gboolean gum_memory_free (gpointer address, gsize size); +GUM_API gboolean gum_memory_release (gpointer address, gsize size); +GUM_API gboolean gum_memory_commit (gpointer address, gsize size, + GumPageProtection page_prot); +GUM_API gboolean gum_memory_decommit (gpointer address, gsize size); + +GUM_API GType gum_memory_range_get_type (void) G_GNUC_CONST; +GUM_API GumMemoryRange * gum_memory_range_copy (const GumMemoryRange * range); +GUM_API void gum_memory_range_free (GumMemoryRange * range); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2008-2020 Ole André Vadla Ravnås + * Copyright (C) 2020 Francesco Tamagni + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_PROCESS_H__ +#define __GUM_PROCESS_H__ + + +#define GUM_THREAD_ID_INVALID ((GumThreadId) -1) + +#define GUM_TYPE_MODULE_DETAILS (gum_module_details_get_type ()) + +G_BEGIN_DECLS + +typedef guint GumProcessId; +typedef gsize GumThreadId; +typedef guint GumThreadState; +typedef struct _GumThreadDetails GumThreadDetails; +typedef struct _GumModuleDetails GumModuleDetails; +typedef guint GumImportType; +typedef guint GumExportType; +typedef guint GumSymbolType; +typedef struct _GumImportDetails GumImportDetails; +typedef struct _GumExportDetails GumExportDetails; +typedef struct _GumSymbolDetails GumSymbolDetails; +typedef struct _GumSymbolSection GumSymbolSection; +typedef struct _GumRangeDetails GumRangeDetails; +typedef struct _GumFileMapping GumFileMapping; +typedef struct _GumMallocRangeDetails GumMallocRangeDetails; + +typedef enum { + GUM_CODE_SIGNING_OPTIONAL, + GUM_CODE_SIGNING_REQUIRED +} GumCodeSigningPolicy; + +enum _GumThreadState +{ + GUM_THREAD_RUNNING = 1, + GUM_THREAD_STOPPED, + GUM_THREAD_WAITING, + GUM_THREAD_UNINTERRUPTIBLE, + GUM_THREAD_HALTED +}; + +struct _GumThreadDetails +{ + GumThreadId id; + GumThreadState state; + GumCpuContext cpu_context; +}; + +struct _GumModuleDetails +{ + const gchar * name; + const GumMemoryRange * range; + const gchar * path; +}; + +enum _GumImportType +{ + GUM_IMPORT_UNKNOWN, + GUM_IMPORT_FUNCTION, + GUM_IMPORT_VARIABLE +}; + +enum _GumExportType +{ + GUM_EXPORT_FUNCTION = 1, + GUM_EXPORT_VARIABLE +}; + +enum _GumSymbolType +{ + /* Common */ + GUM_SYMBOL_UNKNOWN, + GUM_SYMBOL_SECTION, + + /* Mach-O */ + GUM_SYMBOL_UNDEFINED, + GUM_SYMBOL_ABSOLUTE, + GUM_SYMBOL_PREBOUND_UNDEFINED, + GUM_SYMBOL_INDIRECT, + + /* ELF */ + GUM_SYMBOL_OBJECT, + GUM_SYMBOL_FUNCTION, + GUM_SYMBOL_FILE, + GUM_SYMBOL_COMMON, + GUM_SYMBOL_TLS, +}; + +struct _GumImportDetails +{ + GumImportType type; + const gchar * name; + const gchar * module; + GumAddress address; + GumAddress slot; +}; + +struct _GumExportDetails +{ + GumExportType type; + const gchar * name; + GumAddress address; +}; + +struct _GumSymbolDetails +{ + gboolean is_global; + GumSymbolType type; + const GumSymbolSection * section; + const gchar * name; + GumAddress address; + gssize size; +}; + +struct _GumSymbolSection +{ + const gchar * id; + GumPageProtection protection; +}; + +struct _GumRangeDetails +{ + const GumMemoryRange * range; + GumPageProtection protection; + const GumFileMapping * file; +}; + +struct _GumFileMapping +{ + const gchar * path; + guint64 offset; + gsize size; +}; + +struct _GumMallocRangeDetails +{ + const GumMemoryRange * range; +}; + +typedef void (* GumModifyThreadFunc) (GumThreadId thread_id, + GumCpuContext * cpu_context, gpointer user_data); +typedef gboolean (* GumFoundThreadFunc) (const GumThreadDetails * details, + gpointer user_data); +typedef gboolean (* GumFoundModuleFunc) (const GumModuleDetails * details, + gpointer user_data); +typedef gboolean (* GumFoundImportFunc) (const GumImportDetails * details, + gpointer user_data); +typedef gboolean (* GumFoundExportFunc) (const GumExportDetails * details, + gpointer user_data); +typedef gboolean (* GumFoundSymbolFunc) (const GumSymbolDetails * details, + gpointer user_data); +typedef gboolean (* GumFoundRangeFunc) (const GumRangeDetails * details, + gpointer user_data); +typedef gboolean (* GumFoundMallocRangeFunc) ( + const GumMallocRangeDetails * details, gpointer user_data); + +GUM_API GumOS gum_process_get_native_os (void); +GUM_API GumCodeSigningPolicy gum_process_get_code_signing_policy (void); +GUM_API void gum_process_set_code_signing_policy (GumCodeSigningPolicy policy); +GUM_API const gchar * gum_process_query_libc_name (void); +GUM_API gboolean gum_process_is_debugger_attached (void); +GUM_API GumProcessId gum_process_get_id (void); +GUM_API GumThreadId gum_process_get_current_thread_id (void); +GUM_API gboolean gum_process_has_thread (GumThreadId thread_id); +GUM_API gboolean gum_process_modify_thread (GumThreadId thread_id, + GumModifyThreadFunc func, gpointer user_data); +GUM_API void gum_process_enumerate_threads (GumFoundThreadFunc func, + gpointer user_data); +GUM_API void gum_process_enumerate_modules (GumFoundModuleFunc func, + gpointer user_data); +GUM_API void gum_process_enumerate_ranges (GumPageProtection prot, + GumFoundRangeFunc func, gpointer user_data); +GUM_API void gum_process_enumerate_malloc_ranges ( + GumFoundMallocRangeFunc func, gpointer user_data); +GUM_API guint gum_thread_try_get_ranges (GumMemoryRange * ranges, + guint max_length); +GUM_API gint gum_thread_get_system_error (void); +GUM_API void gum_thread_set_system_error (gint value); +GUM_API gboolean gum_module_load (const gchar * module_name, GError ** error); +GUM_API gboolean gum_module_ensure_initialized (const gchar * module_name); +GUM_API void gum_module_enumerate_imports (const gchar * module_name, + GumFoundImportFunc func, gpointer user_data); +GUM_API void gum_module_enumerate_exports (const gchar * module_name, + GumFoundExportFunc func, gpointer user_data); +GUM_API void gum_module_enumerate_symbols (const gchar * module_name, + GumFoundSymbolFunc func, gpointer user_data); +GUM_API void gum_module_enumerate_ranges (const gchar * module_name, + GumPageProtection prot, GumFoundRangeFunc func, gpointer user_data); +GUM_API GumAddress gum_module_find_base_address (const gchar * module_name); +GUM_API GumAddress gum_module_find_export_by_name (const gchar * module_name, + const gchar * symbol_name); +GUM_API GumAddress gum_module_find_symbol_by_name (const gchar * module_name, + const gchar * symbol_name); + +GUM_API const gchar * gum_code_signing_policy_to_string ( + GumCodeSigningPolicy policy); + +GUM_API GType gum_module_details_get_type (void) G_GNUC_CONST; +GUM_API GumModuleDetails * gum_module_details_copy ( + const GumModuleDetails * module); +GUM_API void gum_module_details_free (GumModuleDetails * module); + +GUM_API const gchar * gum_symbol_type_to_string (GumSymbolType type); + +G_END_DECLS + +#endif + +G_BEGIN_DECLS + +typedef gboolean (* GumCloakFoundThreadFunc) (GumThreadId id, + gpointer user_data); +typedef gboolean (* GumCloakFoundRangeFunc) (const GumMemoryRange * range, + gpointer user_data); +typedef gboolean (* GumCloakFoundFDFunc) (gint fd, gpointer user_data); + +GUM_API void gum_cloak_add_thread (GumThreadId id); +GUM_API void gum_cloak_remove_thread (GumThreadId id); +GUM_API gboolean gum_cloak_has_thread (GumThreadId id); +GUM_API void gum_cloak_enumerate_threads (GumCloakFoundThreadFunc func, + gpointer user_data); + +GUM_API void gum_cloak_add_range (const GumMemoryRange * range); +GUM_API void gum_cloak_remove_range (const GumMemoryRange * range); +GUM_API GArray * gum_cloak_clip_range (const GumMemoryRange * range); +GUM_API void gum_cloak_enumerate_ranges (GumCloakFoundRangeFunc func, + gpointer user_data); + +GUM_API void gum_cloak_add_file_descriptor (gint fd); +GUM_API void gum_cloak_remove_file_descriptor (gint fd); +GUM_API gboolean gum_cloak_has_file_descriptor (gint fd); +GUM_API void gum_cloak_enumerate_file_descriptors (GumCloakFoundFDFunc func, + gpointer user_data); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2010 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_CODE_ALLOCATOR_H__ +#define __GUM_CODE_ALLOCATOR_H__ + + +typedef struct _GumCodeAllocator GumCodeAllocator; +typedef struct _GumCodeSlice GumCodeSlice; +typedef struct _GumCodeDeflector GumCodeDeflector; + +struct _GumCodeAllocator +{ + gsize slice_size; + gsize pages_per_batch; + gsize slices_per_batch; + gsize pages_metadata_size; + + GSList * uncommitted_pages; + GHashTable * dirty_pages; + GList * free_slices; + + GSList * dispatchers; +}; + +struct _GumCodeSlice +{ + gpointer data; + gsize size; +}; + +struct _GumCodeDeflector +{ + gpointer return_address; + gpointer target; + gpointer trampoline; +}; + +void gum_code_allocator_init (GumCodeAllocator * allocator, gsize slice_size); +void gum_code_allocator_free (GumCodeAllocator * allocator); + +GumCodeSlice * gum_code_allocator_alloc_slice (GumCodeAllocator * self); +GumCodeSlice * gum_code_allocator_try_alloc_slice_near (GumCodeAllocator * self, + const GumAddressSpec * spec, gsize alignment); +void gum_code_allocator_commit (GumCodeAllocator * self); +void gum_code_slice_free (GumCodeSlice * slice); + +GumCodeDeflector * gum_code_allocator_alloc_deflector (GumCodeAllocator * self, + const GumAddressSpec * caller, gpointer return_address, gpointer target, + gboolean dedicated); +void gum_code_deflector_free (GumCodeDeflector * deflector); + +#endif +/* + * Copyright (C) 2016-2019 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_CODE_SEGMENT_H__ +#define __GUM_CODE_SEGMENT_H__ + + +G_BEGIN_DECLS + +typedef struct _GumCodeSegment GumCodeSegment; + +GUM_API gboolean gum_code_segment_is_supported (void); + +GUM_API GumCodeSegment * gum_code_segment_new (gsize size, + const GumAddressSpec * spec); +GUM_API void gum_code_segment_free (GumCodeSegment * segment); + +GUM_API gpointer gum_code_segment_get_address (GumCodeSegment * self); +GUM_API gsize gum_code_segment_get_size (GumCodeSegment * self); +GUM_API gsize gum_code_segment_get_virtual_size (GumCodeSegment * self); + +GUM_API void gum_code_segment_realize (GumCodeSegment * self); +GUM_API void gum_code_segment_map (GumCodeSegment * self, gsize source_offset, + gsize source_size, gpointer target_address); + +GUM_API gboolean gum_code_segment_mark (gpointer code, gsize size, + GError ** error); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2015-2020 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_DARWIN_MODULE_H__ +#define __GUM_DARWIN_MODULE_H__ + + +#define GUM_DARWIN_EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE 2 + +G_BEGIN_DECLS + +#define GUM_TYPE_DARWIN_MODULE (gum_darwin_module_get_type ()) +G_DECLARE_FINAL_TYPE (GumDarwinModule, gum_darwin_module, GUM_DARWIN, MODULE, + GObject) + +#define GUM_DARWIN_PORT_NULL 0 +#define GUM_DARWIN_EXPORT_KIND_MASK 3 + +typedef guint GumDarwinModuleFiletype; +typedef gint GumDarwinCpuType; +typedef gint GumDarwinCpuSubtype; + +typedef struct _GumDarwinModuleImage GumDarwinModuleImage; + +typedef struct _GumDarwinModuleImageSegment GumDarwinModuleImageSegment; +typedef struct _GumDarwinSectionDetails GumDarwinSectionDetails; +typedef struct _GumDarwinChainedFixupsDetails GumDarwinChainedFixupsDetails; +typedef struct _GumDarwinRebaseDetails GumDarwinRebaseDetails; +typedef struct _GumDarwinBindDetails GumDarwinBindDetails; +typedef struct _GumDarwinThreadedItem GumDarwinThreadedItem; +typedef struct _GumDarwinInitPointersDetails GumDarwinInitPointersDetails; +typedef struct _GumDarwinInitOffsetsDetails GumDarwinInitOffsetsDetails; +typedef struct _GumDarwinTermPointersDetails GumDarwinTermPointersDetails; +typedef struct _GumDarwinSegment GumDarwinSegment; +typedef struct _GumDarwinExportDetails GumDarwinExportDetails; +typedef struct _GumDarwinSymbolDetails GumDarwinSymbolDetails; + +typedef guint8 GumDarwinRebaseType; +typedef guint8 GumDarwinBindType; +typedef guint8 GumDarwinThreadedItemType; +typedef gint GumDarwinBindOrdinal; +typedef guint8 GumDarwinBindSymbolFlags; +typedef guint8 GumDarwinExportSymbolKind; +typedef guint8 GumDarwinExportSymbolFlags; + +typedef guint GumDarwinPort; +typedef gint GumDarwinPageProtection; + +typedef gboolean (* GumFoundDarwinExportFunc) ( + const GumDarwinExportDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinSymbolFunc) ( + const GumDarwinSymbolDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinSectionFunc) ( + const GumDarwinSectionDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinChainedFixupsFunc) ( + const GumDarwinChainedFixupsDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinRebaseFunc) ( + const GumDarwinRebaseDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinBindFunc) ( + const GumDarwinBindDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinInitPointersFunc) ( + const GumDarwinInitPointersDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinInitOffsetsFunc) ( + const GumDarwinInitOffsetsDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinTermPointersFunc) ( + const GumDarwinTermPointersDetails * details, gpointer user_data); +typedef gboolean (* GumFoundDarwinDependencyFunc) (const gchar * path, + gpointer user_data); + +typedef struct _GumDyldInfoCommand GumDyldInfoCommand; +typedef struct _GumSymtabCommand GumSymtabCommand; +typedef struct _GumDysymtabCommand GumDysymtabCommand; + +typedef enum { + GUM_DARWIN_MODULE_FLAGS_NONE = 0, + GUM_DARWIN_MODULE_FLAGS_HEADER_ONLY = (1 << 0), +} GumDarwinModuleFlags; + +struct _GumDarwinModule +{ + GObject parent; + + GumDarwinModuleFiletype filetype; + gchar * name; + gchar * uuid; + + GumDarwinPort task; + gboolean is_local; + gboolean is_kernel; + GumCpuType cpu_type; + GumPtrauthSupport ptrauth_support; + gsize pointer_size; + GumAddress base_address; + gchar * source_path; + GBytes * source_blob; + GumDarwinModuleFlags flags; + + GumDarwinModuleImage * image; + + const GumDyldInfoCommand * info; + const GumSymtabCommand * symtab; + const GumDysymtabCommand * dysymtab; + + GumAddress preferred_address; + + GArray * segments; + GArray * text_ranges; + + const guint8 * rebases; + const guint8 * rebases_end; + gpointer rebases_malloc_data; + + const guint8 * binds; + const guint8 * binds_end; + gpointer binds_malloc_data; + + const guint8 * lazy_binds; + const guint8 * lazy_binds_end; + gpointer lazy_binds_malloc_data; + + const guint8 * exports; + const guint8 * exports_end; + gpointer exports_malloc_data; + + GPtrArray * dependencies; + GPtrArray * reexports; +}; + +enum _GumDarwinModuleFiletype +{ + GUM_DARWIN_MODULE_FILETYPE_OBJECT = 1, + GUM_DARWIN_MODULE_FILETYPE_EXECUTE, + GUM_DARWIN_MODULE_FILETYPE_FVMLIB, + GUM_DARWIN_MODULE_FILETYPE_CORE, + GUM_DARWIN_MODULE_FILETYPE_PRELOAD, + GUM_DARWIN_MODULE_FILETYPE_DYLIB, + GUM_DARWIN_MODULE_FILETYPE_DYLINKER, + GUM_DARWIN_MODULE_FILETYPE_BUNDLE, + GUM_DARWIN_MODULE_FILETYPE_DYLIB_STUB, + GUM_DARWIN_MODULE_FILETYPE_DSYM, + GUM_DARWIN_MODULE_FILETYPE_KEXT_BUNDLE, + GUM_DARWIN_MODULE_FILETYPE_FILESET, +}; + +enum _GumDarwinCpuArchType +{ + GUM_DARWIN_CPU_ARCH_ABI64 = 0x01000000, + GUM_DARWIN_CPU_ARCH_ABI64_32 = 0x02000000, +}; + +enum _GumDarwinCpuType +{ + GUM_DARWIN_CPU_X86 = 7, + GUM_DARWIN_CPU_X86_64 = 7 | GUM_DARWIN_CPU_ARCH_ABI64, + GUM_DARWIN_CPU_ARM = 12, + GUM_DARWIN_CPU_ARM64 = 12 | GUM_DARWIN_CPU_ARCH_ABI64, + GUM_DARWIN_CPU_ARM64_32 = 12 | GUM_DARWIN_CPU_ARCH_ABI64_32, +}; + +enum _GumDarwinCpuSubtype +{ + GUM_DARWIN_CPU_SUBTYPE_ARM64E = 2, + + GUM_DARWIN_CPU_SUBTYPE_MASK = 0x00ffffff, +}; + +struct _GumDarwinModuleImage +{ + gpointer data; + guint64 size; + gconstpointer linkedit; + + guint64 source_offset; + guint64 source_size; + guint64 shared_offset; + guint64 shared_size; + GArray * shared_segments; + + GBytes * bytes; + gpointer malloc_data; +}; + +struct _GumDarwinModuleImageSegment +{ + guint64 offset; + guint64 size; + GumDarwinPageProtection protection; +}; + +struct _GumDarwinSectionDetails +{ + gchar segment_name[17]; + gchar section_name[17]; + GumAddress vm_address; + guint64 size; + GumDarwinPageProtection protection; + guint32 file_offset; + guint32 flags; +}; + +struct _GumDarwinChainedFixupsDetails +{ + GumAddress vm_address; + guint64 file_offset; + guint32 size; +}; + +struct _GumDarwinRebaseDetails +{ + const GumDarwinSegment * segment; + guint64 offset; + GumDarwinRebaseType type; + GumAddress slide; +}; + +struct _GumDarwinBindDetails +{ + const GumDarwinSegment * segment; + guint64 offset; + GumDarwinBindType type; + GumDarwinBindOrdinal library_ordinal; + const gchar * symbol_name; + GumDarwinBindSymbolFlags symbol_flags; + gint64 addend; + guint16 threaded_table_size; +}; + +struct _GumDarwinThreadedItem +{ + gboolean is_authenticated; + GumDarwinThreadedItemType type; + guint16 delta; + guint8 key; + gboolean has_address_diversity; + guint16 diversity; + + guint16 bind_ordinal; + + GumAddress rebase_address; +}; + +struct _GumDarwinInitPointersDetails +{ + GumAddress address; + guint64 count; +}; + +struct _GumDarwinInitOffsetsDetails +{ + GumAddress address; + guint64 count; +}; + +struct _GumDarwinTermPointersDetails +{ + GumAddress address; + guint64 count; +}; + +struct _GumDarwinSegment +{ + gchar name[17]; + GumAddress vm_address; + guint64 vm_size; + guint64 file_offset; + guint64 file_size; + GumDarwinPageProtection protection; +}; + +struct _GumDarwinExportDetails +{ + const gchar * name; + guint64 flags; + + union + { + struct + { + guint64 offset; + }; + + struct + { + guint64 stub; + guint64 resolver; + }; + + struct + { + gint reexport_library_ordinal; + const gchar * reexport_symbol; + }; + }; +}; + +struct _GumDarwinSymbolDetails +{ + const gchar * name; + GumAddress address; + + /* These map 1:1 to their struct nlist / nlist_64 equivalents. */ + guint8 type; + guint8 section; + guint16 description; +}; + +enum _GumDarwinRebaseType +{ + GUM_DARWIN_REBASE_POINTER = 1, + GUM_DARWIN_REBASE_TEXT_ABSOLUTE32, + GUM_DARWIN_REBASE_TEXT_PCREL32, +}; + +enum _GumDarwinBindType +{ + GUM_DARWIN_BIND_POINTER = 1, + GUM_DARWIN_BIND_TEXT_ABSOLUTE32, + GUM_DARWIN_BIND_TEXT_PCREL32, + GUM_DARWIN_BIND_THREADED_TABLE, + GUM_DARWIN_BIND_THREADED_ITEMS, +}; + +enum _GumDarwinThreadedItemType +{ + GUM_DARWIN_THREADED_REBASE, + GUM_DARWIN_THREADED_BIND +}; + +enum _GumDarwinBindOrdinal +{ + GUM_DARWIN_BIND_SELF = 0, + GUM_DARWIN_BIND_MAIN_EXECUTABLE = -1, + GUM_DARWIN_BIND_FLAT_LOOKUP = -2, + GUM_DARWIN_BIND_WEAK_LOOKUP = -3, +}; + +enum _GumDarwinBindSymbolFlags +{ + GUM_DARWIN_BIND_WEAK_IMPORT = 0x1, + GUM_DARWIN_BIND_NON_WEAK_DEFINITION = 0x8, +}; + +enum _GumDarwinExportSymbolKind +{ + GUM_DARWIN_EXPORT_REGULAR, + GUM_DARWIN_EXPORT_THREAD_LOCAL, + GUM_DARWIN_EXPORT_ABSOLUTE +}; + +enum _GumDarwinExportSymbolFlags +{ + GUM_DARWIN_EXPORT_WEAK_DEFINITION = 0x04, + GUM_DARWIN_EXPORT_REEXPORT = 0x08, + GUM_DARWIN_EXPORT_STUB_AND_RESOLVER = 0x10, +}; + +GUM_API GumDarwinModule * gum_darwin_module_new_from_file (const gchar * path, + GumCpuType cpu_type, GumPtrauthSupport ptrauth_support, + GumDarwinModuleFlags flags, GError ** error); +GUM_API GumDarwinModule * gum_darwin_module_new_from_blob (GBytes * blob, + GumCpuType cpu_type, GumPtrauthSupport ptrauth_support, + GumDarwinModuleFlags flags, GError ** error); +GUM_API GumDarwinModule * gum_darwin_module_new_from_memory (const gchar * name, + GumDarwinPort task, GumAddress base_address, GumDarwinModuleFlags flags, + GError ** error); + +GUM_API gboolean gum_darwin_module_resolve_export (GumDarwinModule * self, + const gchar * symbol, GumDarwinExportDetails * details); +GUM_API GumAddress gum_darwin_module_resolve_symbol_address ( + GumDarwinModule * self, const gchar * symbol); +GUM_API gboolean gum_darwin_module_get_lacks_exports_for_reexports ( + GumDarwinModule * self); +GUM_API void gum_darwin_module_enumerate_imports (GumDarwinModule * self, + GumFoundImportFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_exports (GumDarwinModule * self, + GumFoundDarwinExportFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_symbols (GumDarwinModule * self, + GumFoundDarwinSymbolFunc func, gpointer user_data); +GUM_API GumAddress gum_darwin_module_get_slide (GumDarwinModule * self); +GUM_API const GumDarwinSegment * gum_darwin_module_get_nth_segment ( + GumDarwinModule * self, gsize index); +GUM_API void gum_darwin_module_enumerate_sections (GumDarwinModule * self, + GumFoundDarwinSectionFunc func, gpointer user_data); +GUM_API gboolean gum_darwin_module_is_address_in_text_section ( + GumDarwinModule * self, GumAddress address); +GUM_API void gum_darwin_module_enumerate_chained_fixups (GumDarwinModule * self, + GumFoundDarwinChainedFixupsFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_rebases (GumDarwinModule * self, + GumFoundDarwinRebaseFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_binds (GumDarwinModule * self, + GumFoundDarwinBindFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_lazy_binds (GumDarwinModule * self, + GumFoundDarwinBindFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_init_pointers (GumDarwinModule * self, + GumFoundDarwinInitPointersFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_init_offsets (GumDarwinModule * self, + GumFoundDarwinInitOffsetsFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_term_pointers (GumDarwinModule * self, + GumFoundDarwinTermPointersFunc func, gpointer user_data); +GUM_API void gum_darwin_module_enumerate_dependencies (GumDarwinModule * self, + GumFoundDarwinDependencyFunc func, gpointer user_data); +GUM_API const gchar * gum_darwin_module_get_dependency_by_ordinal ( + GumDarwinModule * self, gint ordinal); + +GUM_API void gum_darwin_threaded_item_parse (guint64 value, + GumDarwinThreadedItem * result); + +GUM_API GumDarwinModuleImage * gum_darwin_module_image_new (void); +GUM_API GumDarwinModuleImage * gum_darwin_module_image_dup ( + const GumDarwinModuleImage * other); +GUM_API void gum_darwin_module_image_free (GumDarwinModuleImage * image); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2009 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_EVENT_H__ +#define __GUM_EVENT_H__ + + +G_BEGIN_DECLS + +typedef guint GumEventType; + +typedef union _GumEvent GumEvent; + +typedef struct _GumAnyEvent GumAnyEvent; +typedef struct _GumCallEvent GumCallEvent; +typedef struct _GumRetEvent GumRetEvent; +typedef struct _GumExecEvent GumExecEvent; +typedef struct _GumBlockEvent GumBlockEvent; +typedef struct _GumCompileEvent GumCompileEvent; + +enum _GumEventType +{ + GUM_NOTHING = 0, + GUM_CALL = 1 << 0, + GUM_RET = 1 << 1, + GUM_EXEC = 1 << 2, + GUM_BLOCK = 1 << 3, + GUM_COMPILE = 1 << 4, +}; + +struct _GumAnyEvent +{ + GumEventType type; +}; + +struct _GumCallEvent +{ + GumEventType type; + + gpointer location; + gpointer target; + gint depth; +}; + +struct _GumRetEvent +{ + GumEventType type; + + gpointer location; + gpointer target; + gint depth; +}; + +struct _GumExecEvent +{ + GumEventType type; + + gpointer location; +}; + +struct _GumBlockEvent +{ + GumEventType type; + + gpointer begin; + gpointer end; +}; + +struct _GumCompileEvent +{ + GumEventType type; + + gpointer begin; + gpointer end; +}; + +union _GumEvent +{ + GumEventType type; + + GumAnyEvent any; + GumCallEvent call; + GumRetEvent ret; + GumExecEvent exec; + GumBlockEvent block; + GumCompileEvent compile; +}; + +G_END_DECLS + +#endif +/* + * Copyright (C) 2009-2020 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_EVENT_SINK_H__ +#define __GUM_EVENT_SINK_H__ + + +G_BEGIN_DECLS + +#define GUM_TYPE_EVENT_SINK (gum_event_sink_get_type ()) +G_DECLARE_INTERFACE (GumEventSink, gum_event_sink, GUM, EVENT_SINK, GObject) + +#define GUM_TYPE_DEFAULT_EVENT_SINK (gum_default_event_sink_get_type ()) +G_DECLARE_FINAL_TYPE (GumDefaultEventSink, gum_default_event_sink, GUM, + DEFAULT_EVENT_SINK, GObject) + +struct _GumEventSinkInterface +{ + GTypeInterface parent; + + GumEventType (* query_mask) (GumEventSink * self); + void (* start) (GumEventSink * self); + void (* process) (GumEventSink * self, const GumEvent * event, + GumCpuContext * cpu_context); + void (* flush) (GumEventSink * self); + void (* stop) (GumEventSink * self); +}; + +GUM_API GumEventType gum_event_sink_query_mask (GumEventSink * self); +GUM_API void gum_event_sink_start (GumEventSink * self); +GUM_API void gum_event_sink_process (GumEventSink * self, + const GumEvent * event, GumCpuContext * cpu_context); +GUM_API void gum_event_sink_flush (GumEventSink * self); +GUM_API void gum_event_sink_stop (GumEventSink * self); + +GUM_API GumEventSink * gum_event_sink_make_default (void); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2015-2018 Ole André Vadla Ravnås + * Copyright (C) 2020 Francesco Tamagni + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_EXCEPTOR_H__ +#define __GUM_EXCEPTOR_H__ + +#include + +G_BEGIN_DECLS + +#define GUM_TYPE_EXCEPTOR (gum_exceptor_get_type ()) +G_DECLARE_FINAL_TYPE (GumExceptor, gum_exceptor, GUM, EXCEPTOR, GObject) + +#if defined (G_OS_WIN32) || defined (__APPLE__) +# define GUM_NATIVE_SETJMP(env) setjmp (env) +# define GUM_NATIVE_LONGJMP longjmp + typedef jmp_buf GumExceptorNativeJmpBuf; +#else +# define GUM_NATIVE_SETJMP(env) sigsetjmp (env, TRUE) +# define GUM_NATIVE_LONGJMP siglongjmp +# if !defined (GUM_GIR_COMPILATION) + typedef sigjmp_buf GumExceptorNativeJmpBuf; +# endif +#endif + +typedef struct _GumExceptionDetails GumExceptionDetails; +typedef guint GumExceptionType; +typedef struct _GumExceptionMemoryDetails GumExceptionMemoryDetails; +typedef gboolean (* GumExceptionHandler) (GumExceptionDetails * details, + gpointer user_data); + +typedef struct _GumExceptorScope GumExceptorScope; + +enum _GumExceptionType +{ + GUM_EXCEPTION_ABORT = 1, + GUM_EXCEPTION_ACCESS_VIOLATION, + GUM_EXCEPTION_GUARD_PAGE, + GUM_EXCEPTION_ILLEGAL_INSTRUCTION, + GUM_EXCEPTION_STACK_OVERFLOW, + GUM_EXCEPTION_ARITHMETIC, + GUM_EXCEPTION_BREAKPOINT, + GUM_EXCEPTION_SINGLE_STEP, + GUM_EXCEPTION_SYSTEM +}; + +struct _GumExceptionMemoryDetails +{ + GumMemoryOperation operation; + gpointer address; +}; + +struct _GumExceptionDetails +{ + GumThreadId thread_id; + GumExceptionType type; + gpointer address; + GumExceptionMemoryDetails memory; + GumCpuContext context; + gpointer native_context; +}; + +struct _GumExceptorScope +{ + GumExceptionDetails exception; + + /*< private */ + gboolean exception_occurred; + gpointer padding[2]; + jmp_buf env; +#ifdef __ANDROID__ + sigset_t mask; +#endif + + GumExceptorScope * next; +}; + +GUM_API GumExceptor * gum_exceptor_obtain (void); + +GUM_API void gum_exceptor_add (GumExceptor * self, GumExceptionHandler func, + gpointer user_data); +GUM_API void gum_exceptor_remove (GumExceptor * self, GumExceptionHandler func, + gpointer user_data); + +#if defined (_MSC_VER) && GLIB_SIZEOF_VOID_P == 8 +/* + * On MSVC/64-bit setjmp() is actually an intrinsic that calls _setjmp() with a + * a hidden second argument specifying the frame pointer. This makes sense when + * the longjmp() is guaranteed to happen from code we control, but is not + * reliable otherwise. + */ +# define gum_exceptor_try(self, scope) ( \ + _gum_exceptor_prepare_try (self, scope), \ + ((int (*) (jmp_buf env, void * frame_pointer)) _setjmp) ( \ + (scope)->env, NULL) == 0) +#else +# define gum_exceptor_try(self, scope) ( \ + _gum_exceptor_prepare_try (self, scope), \ + GUM_NATIVE_SETJMP ((scope)->env) == 0) +#endif +GUM_API gboolean gum_exceptor_catch (GumExceptor * self, + GumExceptorScope * scope); +GUM_API gboolean gum_exceptor_has_scope (GumExceptor * self, + GumThreadId thread_id); + +GUM_API gchar * gum_exception_details_to_string ( + const GumExceptionDetails * details); + +GUM_API void _gum_exceptor_prepare_try (GumExceptor * self, + GumExceptorScope * scope); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2009 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_FUNCTION_H__ +#define __GUM_FUNCTION_H__ + +G_BEGIN_DECLS + +typedef struct _GumFunctionDetails GumFunctionDetails; + +struct _GumFunctionDetails +{ + const gchar * name; + gpointer address; + gint num_arguments; +}; + +G_END_DECLS + +#endif +/* + * Copyright (C) 2008-2019 Ole André Vadla Ravnås + * Copyright (C) 2008 Christian Berentsen + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_INTERCEPTOR_H__ +#define __GUM_INTERCEPTOR_H__ + +/* + * Copyright (C) 2008-2018 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_INVOCATION_LISTENER_H__ +#define __GUM_INVOCATION_LISTENER_H__ + +/* + * Copyright (C) 2008-2019 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_INVOCATION_CONTEXT_H__ +#define __GUM_INVOCATION_CONTEXT_H__ + + + +#define GUM_IC_GET_THREAD_DATA(context, data_type) \ + ((data_type *) gum_invocation_context_get_listener_thread_data (context, \ + sizeof (data_type))) +#define GUM_IC_GET_FUNC_DATA(context, data_type) \ + ((data_type) gum_invocation_context_get_listener_function_data (context)) +#define GUM_IC_GET_INVOCATION_DATA(context, data_type) \ + ((data_type *) \ + gum_invocation_context_get_listener_invocation_data (context,\ + sizeof (data_type))) + +#define GUM_IC_GET_REPLACEMENT_DATA(ctx, data_type) \ + ((data_type) gum_invocation_context_get_replacement_data (ctx)) + +typedef struct _GumInvocationBackend GumInvocationBackend; +typedef struct _GumInvocationContext GumInvocationContext; +typedef guint GumPointCut; + +struct _GumInvocationBackend +{ + GumPointCut (* get_point_cut) (GumInvocationContext * context); + + GumThreadId (* get_thread_id) (GumInvocationContext * context); + guint (* get_depth) (GumInvocationContext * context); + + gpointer (* get_listener_thread_data) (GumInvocationContext * context, + gsize required_size); + gpointer (* get_listener_function_data) (GumInvocationContext * context); + gpointer (* get_listener_invocation_data) ( + GumInvocationContext * context, gsize required_size); + + gpointer (* get_replacement_data) (GumInvocationContext * context); + + gpointer state; + gpointer data; +}; + +struct _GumInvocationContext +{ + GCallback function; + GumCpuContext * cpu_context; + gint system_error; + + /*< private */ + GumInvocationBackend * backend; +}; + +enum _GumPointCut +{ + GUM_POINT_ENTER, + GUM_POINT_LEAVE +}; + +G_BEGIN_DECLS + +GUM_API GumPointCut gum_invocation_context_get_point_cut ( + GumInvocationContext * context); + +GUM_API gpointer gum_invocation_context_get_nth_argument ( + GumInvocationContext * context, guint n); +GUM_API void gum_invocation_context_replace_nth_argument ( + GumInvocationContext * context, guint n, gpointer value); +GUM_API gpointer gum_invocation_context_get_return_value ( + GumInvocationContext * context); +GUM_API void gum_invocation_context_replace_return_value ( + GumInvocationContext * context, gpointer value); + +GUM_API gpointer gum_invocation_context_get_return_address ( + GumInvocationContext * context); + +GUM_API guint gum_invocation_context_get_thread_id ( + GumInvocationContext * context); +GUM_API guint gum_invocation_context_get_depth ( + GumInvocationContext * context); + +GUM_API gpointer gum_invocation_context_get_listener_thread_data ( + GumInvocationContext * context, gsize required_size); +GUM_API gpointer gum_invocation_context_get_listener_function_data ( + GumInvocationContext * context); +GUM_API gpointer gum_invocation_context_get_listener_invocation_data ( + GumInvocationContext * context, gsize required_size); + +GUM_API gpointer gum_invocation_context_get_replacement_data ( + GumInvocationContext * context); + +G_END_DECLS + +#endif + +G_BEGIN_DECLS + +#define GUM_TYPE_INVOCATION_LISTENER (gum_invocation_listener_get_type ()) +G_DECLARE_INTERFACE (GumInvocationListener, gum_invocation_listener, GUM, + INVOCATION_LISTENER, GObject) + +struct _GumInvocationListenerInterface +{ + GTypeInterface parent; + + void (* on_enter) (GumInvocationListener * self, + GumInvocationContext * context); + void (* on_leave) (GumInvocationListener * self, + GumInvocationContext * context); +}; + +GUM_API void gum_invocation_listener_on_enter (GumInvocationListener * self, + GumInvocationContext * context); +GUM_API void gum_invocation_listener_on_leave (GumInvocationListener * self, + GumInvocationContext * context); + +G_END_DECLS + +#endif + +G_BEGIN_DECLS + +#define GUM_TYPE_INTERCEPTOR (gum_interceptor_get_type ()) +G_DECLARE_FINAL_TYPE (GumInterceptor, gum_interceptor, GUM, INTERCEPTOR, + GObject) + +typedef GArray GumInvocationStack; +typedef guint GumInvocationState; + +typedef enum +{ + GUM_ATTACH_OK = 0, + GUM_ATTACH_WRONG_SIGNATURE = -1, + GUM_ATTACH_ALREADY_ATTACHED = -2, + GUM_ATTACH_POLICY_VIOLATION = -3 +} GumAttachReturn; + +typedef enum +{ + GUM_REPLACE_OK = 0, + GUM_REPLACE_WRONG_SIGNATURE = -1, + GUM_REPLACE_ALREADY_REPLACED = -2, + GUM_REPLACE_POLICY_VIOLATION = -3 +} GumReplaceReturn; + +GUM_API GumInterceptor * gum_interceptor_obtain (void); + +GUM_API GumAttachReturn gum_interceptor_attach (GumInterceptor * self, + gpointer function_address, GumInvocationListener * listener, + gpointer listener_function_data); +GUM_API void gum_interceptor_detach (GumInterceptor * self, + GumInvocationListener * listener); + +GUM_API GumReplaceReturn gum_interceptor_replace (GumInterceptor * self, + gpointer function_address, gpointer replacement_function, + gpointer replacement_data); +GUM_API void gum_interceptor_revert (GumInterceptor * self, + gpointer function_address); + +GUM_API void gum_interceptor_begin_transaction (GumInterceptor * self); +GUM_API void gum_interceptor_end_transaction (GumInterceptor * self); +GUM_API gboolean gum_interceptor_flush (GumInterceptor * self); + +GUM_API GumInvocationContext * gum_interceptor_get_current_invocation (void); +GUM_API GumInvocationStack * gum_interceptor_get_current_stack (void); + +GUM_API void gum_interceptor_ignore_current_thread (GumInterceptor * self); +GUM_API void gum_interceptor_unignore_current_thread (GumInterceptor * self); + +GUM_API void gum_interceptor_ignore_other_threads (GumInterceptor * self); +GUM_API void gum_interceptor_unignore_other_threads (GumInterceptor * self); + +GUM_API gpointer gum_invocation_stack_translate (GumInvocationStack * self, + gpointer return_address); + +GUM_API void gum_interceptor_save (GumInvocationState * state); +GUM_API void gum_interceptor_restore (GumInvocationState * state); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2015 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_KERNEL_H__ +#define __GUM_KERNEL_H__ + + +G_BEGIN_DECLS + +typedef struct _GumKernelModuleRangeDetails GumKernelModuleRangeDetails; + +struct _GumKernelModuleRangeDetails +{ + gchar name[48]; + GumAddress address; + guint64 size; + GumPageProtection protection; +}; + +typedef gboolean (* GumFoundKernelModuleRangeFunc) ( + const GumKernelModuleRangeDetails * details, gpointer user_data); + +GUM_API gboolean gum_kernel_api_is_available (void); +GUM_API guint gum_kernel_query_page_size (void); +GUM_API GumAddress gum_kernel_alloc_n_pages (guint n_pages); +GUM_API void gum_kernel_free_pages (GumAddress mem); +GUM_API gboolean gum_kernel_try_mprotect (GumAddress address, gsize size, + GumPageProtection page_prot); +GUM_API guint8 * gum_kernel_read (GumAddress address, gsize len, + gsize * n_bytes_read); +GUM_API gboolean gum_kernel_write (GumAddress address, const guint8 * bytes, + gsize len); +GUM_API void gum_kernel_scan (const GumMemoryRange * range, + const GumMatchPattern * pattern, GumMemoryScanMatchFunc func, + gpointer user_data); +GUM_API void gum_kernel_enumerate_ranges (GumPageProtection prot, + GumFoundRangeFunc func, gpointer user_data); +GUM_API void gum_kernel_enumerate_module_ranges (const gchar * module_name, + GumPageProtection prot, GumFoundKernelModuleRangeFunc func, + gpointer user_data); +GUM_API void gum_kernel_enumerate_modules (GumFoundModuleFunc func, + gpointer user_data); +GUM_API GumAddress gum_kernel_find_base_address (void); +GUM_API void gum_kernel_set_base_address (GumAddress base); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2015 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_LIBC_H__ +#define __GUM_LIBC_H__ + + +G_BEGIN_DECLS + +G_GNUC_INTERNAL gpointer gum_memset (gpointer dst, gint c, gsize n); +G_GNUC_INTERNAL gpointer gum_memcpy (gpointer dst, gconstpointer src, gsize n); +G_GNUC_INTERNAL gpointer gum_memmove (gpointer dst, gconstpointer src, gsize n); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2010-2018 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_MEMORY_ACCESS_MONITOR_H__ +#define __GUM_MEMORY_ACCESS_MONITOR_H__ + + +G_BEGIN_DECLS + +#define GUM_TYPE_MEMORY_ACCESS_MONITOR (gum_memory_access_monitor_get_type ()) +G_DECLARE_FINAL_TYPE (GumMemoryAccessMonitor, gum_memory_access_monitor, GUM, + MEMORY_ACCESS_MONITOR, GObject) + +typedef struct _GumMemoryAccessDetails GumMemoryAccessDetails; + +typedef void (* GumMemoryAccessNotify) (GumMemoryAccessMonitor * monitor, + const GumMemoryAccessDetails * details, gpointer user_data); + +struct _GumMemoryAccessDetails +{ + GumMemoryOperation operation; + gpointer from; + gpointer address; + + guint range_index; + guint page_index; + guint pages_completed; + guint pages_total; +}; + +GUM_API GumMemoryAccessMonitor * gum_memory_access_monitor_new ( + const GumMemoryRange * ranges, guint num_ranges, + GumPageProtection access_mask, gboolean auto_reset, + GumMemoryAccessNotify func, gpointer data, + GDestroyNotify data_destroy); + +GUM_API gboolean gum_memory_access_monitor_enable ( + GumMemoryAccessMonitor * self, GError ** error); +GUM_API void gum_memory_access_monitor_disable (GumMemoryAccessMonitor * self); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2013-2018 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_MEMORY_MAP_H__ +#define __GUM_MEMORY_MAP_H__ + + +G_BEGIN_DECLS + +#define GUM_TYPE_MEMORY_MAP (gum_memory_map_get_type ()) +G_DECLARE_FINAL_TYPE (GumMemoryMap, gum_memory_map, GUM, MEMORY_MAP, GObject) + +GUM_API GumMemoryMap * gum_memory_map_new (GumPageProtection prot); + +GUM_API gboolean gum_memory_map_contains (GumMemoryMap * self, + const GumMemoryRange * range); + +GUM_API void gum_memory_map_update (GumMemoryMap * self); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2017-2019 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_METAL_ARRAY_H__ +#define __GUM_METAL_ARRAY_H__ + + +typedef struct _GumMetalArray GumMetalArray; + +struct _GumMetalArray +{ + gpointer data; + guint length; + guint capacity; + + guint element_size; +}; + +G_BEGIN_DECLS + +GUM_API void gum_metal_array_init (GumMetalArray * array, guint element_size); +GUM_API void gum_metal_array_free (GumMetalArray * array); + +GUM_API gpointer gum_metal_array_element_at (GumMetalArray * self, + guint index_); +GUM_API gpointer gum_metal_array_insert_at (GumMetalArray * self, guint index_); +GUM_API void gum_metal_array_remove_at (GumMetalArray * self, guint index_); +GUM_API void gum_metal_array_remove_all (GumMetalArray * self); +GUM_API gpointer gum_metal_array_append (GumMetalArray * self); + +GUM_API void gum_metal_array_get_extents (GumMetalArray * self, + gpointer * start, gpointer * end); +GUM_API void gum_metal_array_ensure_capacity (GumMetalArray * self, + guint capacity); + +G_END_DECLS + +#endif +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see . + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + +#ifndef __GUM_METAL_HASH_H__ +#define __GUM_METAL_HASH_H__ + + +G_BEGIN_DECLS + +typedef struct _GumMetalHashTable GumMetalHashTable; +typedef struct _GumMetalHashTableIter GumMetalHashTableIter; + +struct _GumMetalHashTableIter +{ + gpointer dummy1; + gpointer dummy2; + gpointer dummy3; + int dummy4; + gboolean dummy5; + gpointer dummy6; +}; + +GUM_API GumMetalHashTable * gum_metal_hash_table_new (GHashFunc hash_func, + GEqualFunc key_equal_func); +GUM_API GumMetalHashTable * gum_metal_hash_table_new_full (GHashFunc hash_func, + GEqualFunc key_equal_func, GDestroyNotify key_destroy_func, + GDestroyNotify value_destroy_func); +GUM_API void gum_metal_hash_table_destroy (GumMetalHashTable * hash_table); +GUM_API gboolean gum_metal_hash_table_insert (GumMetalHashTable * hash_table, + gpointer key, gpointer value); +GUM_API gboolean gum_metal_hash_table_replace (GumMetalHashTable * hash_table, + gpointer key, gpointer value); +GUM_API gboolean gum_metal_hash_table_add (GumMetalHashTable * hash_table, + gpointer key); +GUM_API gboolean gum_metal_hash_table_remove (GumMetalHashTable * hash_table, + gconstpointer key); +GUM_API void gum_metal_hash_table_remove_all (GumMetalHashTable * hash_table); +GUM_API gboolean gum_metal_hash_table_steal (GumMetalHashTable * hash_table, + gconstpointer key); +GUM_API void gum_metal_hash_table_steal_all (GumMetalHashTable * hash_table); +GUM_API gpointer gum_metal_hash_table_lookup (GumMetalHashTable * hash_table, + gconstpointer key); +GUM_API gboolean gum_metal_hash_table_contains (GumMetalHashTable * hash_table, + gconstpointer key); +GUM_API gboolean gum_metal_hash_table_lookup_extended ( + GumMetalHashTable * hash_table, gconstpointer lookup_key, + gpointer * orig_key, gpointer * value); +GUM_API void gum_metal_hash_table_foreach (GumMetalHashTable * hash_table, + GHFunc func, gpointer user_data); +GUM_API gpointer gum_metal_hash_table_find (GumMetalHashTable * hash_table, + GHRFunc predicate, gpointer user_data); +GUM_API guint gum_metal_hash_table_foreach_remove ( + GumMetalHashTable * hash_table, GHRFunc func, gpointer user_data); +GUM_API guint gum_metal_hash_table_foreach_steal (GumMetalHashTable * hash_table, + GHRFunc func, gpointer user_data); +GUM_API guint gum_metal_hash_table_size (GumMetalHashTable * hash_table); + +GUM_API void gum_metal_hash_table_iter_init (GumMetalHashTableIter * iter, + GumMetalHashTable * hash_table); +GUM_API gboolean gum_metal_hash_table_iter_next (GumMetalHashTableIter * iter, + gpointer * key, gpointer * value); +GUM_API GumMetalHashTable* gum_metal_hash_table_iter_get_hash_table ( + GumMetalHashTableIter * iter); +GUM_API void gum_metal_hash_table_iter_remove (GumMetalHashTableIter * iter); +GUM_API void gum_metal_hash_table_iter_replace (GumMetalHashTableIter * iter, + gpointer value); +GUM_API void gum_metal_hash_table_iter_steal (GumMetalHashTableIter * iter); + +GUM_API GumMetalHashTable * gum_metal_hash_table_ref ( + GumMetalHashTable * hash_table); +GUM_API void gum_metal_hash_table_unref (GumMetalHashTable * hash_table); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2016 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_MODULE_API_RESOLVER_H__ +#define __GUM_MODULE_API_RESOLVER_H__ + + +G_BEGIN_DECLS + +#define GUM_TYPE_MODULE_API_RESOLVER (gum_module_api_resolver_get_type ()) +G_DECLARE_FINAL_TYPE (GumModuleApiResolver, gum_module_api_resolver, GUM, + MODULE_API_RESOLVER, GObject) + +GUM_API GumApiResolver * gum_module_api_resolver_new (void); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2015-2017 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_MODULE_MAP_H__ +#define __GUM_MODULE_MAP_H__ + + +G_BEGIN_DECLS + +#define GUM_TYPE_MODULE_MAP (gum_module_map_get_type ()) +G_DECLARE_FINAL_TYPE (GumModuleMap, gum_module_map, GUM, MODULE_MAP, GObject) + +typedef gboolean (* GumModuleMapFilterFunc) (const GumModuleDetails * details, + gpointer user_data); + +GUM_API GumModuleMap * gum_module_map_new (void); +GUM_API GumModuleMap * gum_module_map_new_filtered (GumModuleMapFilterFunc func, + gpointer data, GDestroyNotify data_destroy); + +GUM_API const GumModuleDetails * gum_module_map_find (GumModuleMap * self, + GumAddress address); + +GUM_API void gum_module_map_update (GumModuleMap * self); + +GUM_API GArray * gum_module_map_get_values (GumModuleMap * self); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2014 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_PRINTF_H__ +#define __GUM_PRINTF_H__ + + +G_BEGIN_DECLS + +gint gum_vsnprintf (gchar * str, gsize size, const gchar * format, + va_list args); +gint gum_snprintf (gchar * str, gsize size, const gchar * format, ...); +gint gum_vasprintf (gchar ** ret, const gchar * format, va_list ap); +gint gum_asprintf (gchar ** ret, const gchar * format, ...); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2010-2019 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_SPINLOCK_H__ +#define __GUM_SPINLOCK_H__ + + +#define GUM_SPINLOCK_INIT { NULL } + +G_BEGIN_DECLS + +typedef struct _GumSpinlock GumSpinlock; + +struct _GumSpinlock +{ + gpointer data; +}; + +void gum_spinlock_init (GumSpinlock * spinlock); + +void gum_spinlock_acquire (GumSpinlock * spinlock); +void gum_spinlock_release (GumSpinlock * spinlock); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2009-2018 Ole André Vadla Ravnås + * Copyright (C) 2010 Karl Trygve Kalleberg + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_STALKER_H__ +#define __GUM_STALKER_H__ + +#ifndef CAPSTONE_ENGINE_H +#define CAPSTONE_ENGINE_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2013-2016 */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#if defined(CAPSTONE_HAS_OSXKERNEL) +#include +#else +#include +#include +#endif + +/* Capstone Disassembly Engine */ +/* By Axel Souchet & Nguyen Anh Quynh, 2014 */ + +#ifndef CAPSTONE_PLATFORM_H +#define CAPSTONE_PLATFORM_H + + +// handle C99 issue (for pre-2013 VisualStudio) +#if !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) +// MSVC + +// stdbool.h +#if (_MSC_VER < 1800) || defined(_KERNEL_MODE) +// this system does not have stdbool.h +#ifndef __cplusplus +typedef unsigned char bool; +#define false 0 +#define true 1 +#endif // __cplusplus + +#else +// VisualStudio 2013+ -> C99 is supported +#include +#endif // (_MSC_VER < 1800) || defined(_KERNEL_MODE) + +#else +// not MSVC -> C99 is supported +#include +#endif // !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) + + +// handle inttypes.h / stdint.h compatibility +#if defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) +#include "windowsce/stdint.h" +#endif // defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) + +#if defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) +// this system does not have inttypes.h + +#if defined(_MSC_VER) && (_MSC_VER <= 1600 || defined(_KERNEL_MODE)) +// this system does not have stdint.h +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#endif // defined(_MSC_VER) && (_MSC_VER <= 1600 || defined(_KERNEL_MODE)) + +#if defined(_MSC_VER) && (_MSC_VER < 1600 || defined(_KERNEL_MODE)) +#define INT8_MIN (-127i8 - 1) +#define INT16_MIN (-32767i16 - 1) +#define INT32_MIN (-2147483647i32 - 1) +#define INT64_MIN (-9223372036854775807i64 - 1) +#define INT8_MAX 127i8 +#define INT16_MAX 32767i16 +#define INT32_MAX 2147483647i32 +#define INT64_MAX 9223372036854775807i64 +#define UINT8_MAX 0xffui8 +#define UINT16_MAX 0xffffui16 +#define UINT32_MAX 0xffffffffui32 +#define UINT64_MAX 0xffffffffffffffffui64 +#endif // defined(_MSC_VER) && (_MSC_VER < 1600 || defined(_KERNEL_MODE)) + +#ifdef CAPSTONE_HAS_OSXKERNEL +// this system has stdint.h +#include +#endif + +#define __PRI_8_LENGTH_MODIFIER__ "hh" +#define __PRI_64_LENGTH_MODIFIER__ "ll" + +#define PRId8 __PRI_8_LENGTH_MODIFIER__ "d" +#define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i" +#define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o" +#define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u" +#define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x" +#define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X" + +#define PRId16 "hd" +#define PRIi16 "hi" +#define PRIo16 "ho" +#define PRIu16 "hu" +#define PRIx16 "hx" +#define PRIX16 "hX" + +#if defined(_MSC_VER) && _MSC_VER <= 1700 +#define PRId32 "ld" +#define PRIi32 "li" +#define PRIo32 "lo" +#define PRIu32 "lu" +#define PRIx32 "lx" +#define PRIX32 "lX" +#else // OSX +#define PRId32 "d" +#define PRIi32 "i" +#define PRIo32 "o" +#define PRIu32 "u" +#define PRIx32 "x" +#define PRIX32 "X" +#endif // defined(_MSC_VER) && _MSC_VER <= 1700 + +#if defined(_MSC_VER) && _MSC_VER <= 1700 +// redefine functions from inttypes.h used in cstool +#define strtoull _strtoui64 +#endif + +#define PRId64 __PRI_64_LENGTH_MODIFIER__ "d" +#define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i" +#define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o" +#define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u" +#define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x" +#define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X" + +#else +// this system has inttypes.h by default +#include +#endif // defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) + +#endif + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#pragma warning(disable:4100) +#define CAPSTONE_API __cdecl +#ifdef CAPSTONE_SHARED +#define CAPSTONE_EXPORT __declspec(dllexport) +#else // defined(CAPSTONE_STATIC) +#define CAPSTONE_EXPORT +#endif +#else +#define CAPSTONE_API +#if (defined(__GNUC__) || defined(__IBMC__)) && !defined(CAPSTONE_STATIC) +#define CAPSTONE_EXPORT __attribute__((visibility("default"))) +#else // defined(CAPSTONE_STATIC) +#define CAPSTONE_EXPORT +#endif +#endif + +#if (defined(__GNUC__) || defined(__IBMC__)) +#define CAPSTONE_DEPRECATED __attribute__((deprecated)) +#elif defined(_MSC_VER) +#define CAPSTONE_DEPRECATED __declspec(deprecated) +#else +#pragma message("WARNING: You need to implement CAPSTONE_DEPRECATED for this compiler") +#define CAPSTONE_DEPRECATED +#endif + +// Capstone API version +#define CS_API_MAJOR 5 +#define CS_API_MINOR 0 + +// Version for bleeding edge code of the Github's "next" branch. +// Use this if you want the absolutely latest development code. +// This version number will be bumped up whenever we have a new major change. +#define CS_NEXT_VERSION 5 + +// Capstone package version +#define CS_VERSION_MAJOR CS_API_MAJOR +#define CS_VERSION_MINOR CS_API_MINOR +#define CS_VERSION_EXTRA 0 + +/// Macro to create combined version which can be compared to +/// result of cs_version() API. +#define CS_MAKE_VERSION(major, minor) ((major << 8) + minor) + +/// Maximum size of an instruction mnemonic string. +#define CS_MNEMONIC_SIZE 32 + +// Handle using with all API +typedef size_t csh; + +/// Architecture type +typedef enum cs_arch { + CS_ARCH_ARM = 0, ///< ARM architecture (including Thumb, Thumb-2) + CS_ARCH_ARM64, ///< ARM-64, also called AArch64 + CS_ARCH_MIPS, ///< Mips architecture + CS_ARCH_X86, ///< X86 architecture (including x86 & x86-64) + CS_ARCH_PPC, ///< PowerPC architecture + CS_ARCH_SPARC, ///< Sparc architecture + CS_ARCH_SYSZ, ///< SystemZ architecture + CS_ARCH_XCORE, ///< XCore architecture + CS_ARCH_M68K, ///< 68K architecture + CS_ARCH_TMS320C64X, ///< TMS320C64x architecture + CS_ARCH_M680X, ///< 680X architecture + CS_ARCH_EVM, ///< Ethereum architecture + CS_ARCH_MOS65XX, ///< MOS65XX architecture (including MOS6502) + CS_ARCH_WASM, ///< WebAssembly architecture + CS_ARCH_BPF, ///< Berkeley Packet Filter architecture (including eBPF) + CS_ARCH_RISCV, ///< RISCV architecture + CS_ARCH_MAX, + CS_ARCH_ALL = 0xFFFF, // All architectures - for cs_support() +} cs_arch; + +// Support value to verify diet mode of the engine. +// If cs_support(CS_SUPPORT_DIET) return True, the engine was compiled +// in diet mode. +#define CS_SUPPORT_DIET (CS_ARCH_ALL + 1) + +// Support value to verify X86 reduce mode of the engine. +// If cs_support(CS_SUPPORT_X86_REDUCE) return True, the engine was compiled +// in X86 reduce mode. +#define CS_SUPPORT_X86_REDUCE (CS_ARCH_ALL + 2) + +/// Mode type +typedef enum cs_mode { + CS_MODE_LITTLE_ENDIAN = 0, ///< little-endian mode (default mode) + CS_MODE_ARM = 0, ///< 32-bit ARM + CS_MODE_16 = 1 << 1, ///< 16-bit mode (X86) + CS_MODE_32 = 1 << 2, ///< 32-bit mode (X86) + CS_MODE_64 = 1 << 3, ///< 64-bit mode (X86, PPC) + CS_MODE_THUMB = 1 << 4, ///< ARM's Thumb mode, including Thumb-2 + CS_MODE_MCLASS = 1 << 5, ///< ARM's Cortex-M series + CS_MODE_V8 = 1 << 6, ///< ARMv8 A32 encodings for ARM + CS_MODE_MICRO = 1 << 4, ///< MicroMips mode (MIPS) + CS_MODE_MIPS3 = 1 << 5, ///< Mips III ISA + CS_MODE_MIPS32R6 = 1 << 6, ///< Mips32r6 ISA + CS_MODE_MIPS2 = 1 << 7, ///< Mips II ISA + CS_MODE_V9 = 1 << 4, ///< SparcV9 mode (Sparc) + CS_MODE_QPX = 1 << 4, ///< Quad Processing eXtensions mode (PPC) + CS_MODE_SPE = 1 << 5, ///< Signal Processing Engine mode (PPC) + CS_MODE_BOOKE = 1 << 6, ///< Book-E mode (PPC) + CS_MODE_M68K_000 = 1 << 1, ///< M68K 68000 mode + CS_MODE_M68K_010 = 1 << 2, ///< M68K 68010 mode + CS_MODE_M68K_020 = 1 << 3, ///< M68K 68020 mode + CS_MODE_M68K_030 = 1 << 4, ///< M68K 68030 mode + CS_MODE_M68K_040 = 1 << 5, ///< M68K 68040 mode + CS_MODE_M68K_060 = 1 << 6, ///< M68K 68060 mode + CS_MODE_BIG_ENDIAN = 1U << 31, ///< big-endian mode + CS_MODE_MIPS32 = CS_MODE_32, ///< Mips32 ISA (Mips) + CS_MODE_MIPS64 = CS_MODE_64, ///< Mips64 ISA (Mips) + CS_MODE_M680X_6301 = 1 << 1, ///< M680X Hitachi 6301,6303 mode + CS_MODE_M680X_6309 = 1 << 2, ///< M680X Hitachi 6309 mode + CS_MODE_M680X_6800 = 1 << 3, ///< M680X Motorola 6800,6802 mode + CS_MODE_M680X_6801 = 1 << 4, ///< M680X Motorola 6801,6803 mode + CS_MODE_M680X_6805 = 1 << 5, ///< M680X Motorola/Freescale 6805 mode + CS_MODE_M680X_6808 = 1 << 6, ///< M680X Motorola/Freescale/NXP 68HC08 mode + CS_MODE_M680X_6809 = 1 << 7, ///< M680X Motorola 6809 mode + CS_MODE_M680X_6811 = 1 << 8, ///< M680X Motorola/Freescale/NXP 68HC11 mode + CS_MODE_M680X_CPU12 = 1 << 9, ///< M680X Motorola/Freescale/NXP CPU12 + ///< used on M68HC12/HCS12 + CS_MODE_M680X_HCS08 = 1 << 10, ///< M680X Freescale/NXP HCS08 mode + CS_MODE_BPF_CLASSIC = 0, ///< Classic BPF mode (default) + CS_MODE_BPF_EXTENDED = 1 << 0, ///< Extended BPF mode + CS_MODE_RISCV32 = 1 << 0, ///< RISCV RV32G + CS_MODE_RISCV64 = 1 << 1, ///< RISCV RV64G + CS_MODE_RISCVC = 1 << 2, ///< RISCV compressed instructure mode + CS_MODE_MOS65XX_6502 = 1 << 1, ///< MOS65XXX MOS 6502 + CS_MODE_MOS65XX_65C02 = 1 << 2, ///< MOS65XXX WDC 65c02 + CS_MODE_MOS65XX_W65C02 = 1 << 3, ///< MOS65XXX WDC W65c02 + CS_MODE_MOS65XX_65816 = 1 << 4, ///< MOS65XXX WDC 65816, 8-bit m/x + CS_MODE_MOS65XX_65816_LONG_M = (1 << 5), ///< MOS65XXX WDC 65816, 16-bit m, 8-bit x + CS_MODE_MOS65XX_65816_LONG_X = (1 << 6), ///< MOS65XXX WDC 65816, 8-bit m, 16-bit x + CS_MODE_MOS65XX_65816_LONG_MX = CS_MODE_MOS65XX_65816_LONG_M | CS_MODE_MOS65XX_65816_LONG_X, +} cs_mode; + +typedef void* (CAPSTONE_API *cs_malloc_t)(size_t size); +typedef void* (CAPSTONE_API *cs_calloc_t)(size_t nmemb, size_t size); +typedef void* (CAPSTONE_API *cs_realloc_t)(void *ptr, size_t size); +typedef void (CAPSTONE_API *cs_free_t)(void *ptr); +typedef int (CAPSTONE_API *cs_vsnprintf_t)(char *str, size_t size, const char *format, va_list ap); + + +/// User-defined dynamic memory related functions: malloc/calloc/realloc/free/vsnprintf() +/// By default, Capstone uses system's malloc(), calloc(), realloc(), free() & vsnprintf(). +typedef struct cs_opt_mem { + cs_malloc_t malloc; + cs_calloc_t calloc; + cs_realloc_t realloc; + cs_free_t free; + cs_vsnprintf_t vsnprintf; +} cs_opt_mem; + +/// Customize mnemonic for instructions with alternative name. +/// To reset existing customized instruction to its default mnemonic, +/// call cs_option(CS_OPT_MNEMONIC) again with the same @id and NULL value +/// for @mnemonic. +typedef struct cs_opt_mnem { + /// ID of instruction to be customized. + unsigned int id; + /// Customized instruction mnemonic. + const char *mnemonic; +} cs_opt_mnem; + +/// Runtime option for the disassembled engine +typedef enum cs_opt_type { + CS_OPT_INVALID = 0, ///< No option specified + CS_OPT_SYNTAX, ///< Assembly output syntax + CS_OPT_DETAIL, ///< Break down instruction structure into details + CS_OPT_MODE, ///< Change engine's mode at run-time + CS_OPT_MEM, ///< User-defined dynamic memory related functions + CS_OPT_SKIPDATA, ///< Skip data when disassembling. Then engine is in SKIPDATA mode. + CS_OPT_SKIPDATA_SETUP, ///< Setup user-defined function for SKIPDATA option + CS_OPT_MNEMONIC, ///< Customize instruction mnemonic + CS_OPT_UNSIGNED, ///< print immediate operands in unsigned form +} cs_opt_type; + +/// Runtime option value (associated with option type above) +typedef enum cs_opt_value { + CS_OPT_OFF = 0, ///< Turn OFF an option - default for CS_OPT_DETAIL, CS_OPT_SKIPDATA, CS_OPT_UNSIGNED. + CS_OPT_ON = 3, ///< Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA). + CS_OPT_SYNTAX_DEFAULT = 0, ///< Default asm syntax (CS_OPT_SYNTAX). + CS_OPT_SYNTAX_INTEL, ///< X86 Intel asm syntax - default on X86 (CS_OPT_SYNTAX). + CS_OPT_SYNTAX_ATT, ///< X86 ATT asm syntax (CS_OPT_SYNTAX). + CS_OPT_SYNTAX_NOREGNAME, ///< Prints register name with only number (CS_OPT_SYNTAX) + CS_OPT_SYNTAX_MASM, ///< X86 Intel Masm syntax (CS_OPT_SYNTAX). + CS_OPT_SYNTAX_MOTOROLA, ///< MOS65XX use $ as hex prefix +} cs_opt_value; + +/// Common instruction operand types - to be consistent across all architectures. +typedef enum cs_op_type { + CS_OP_INVALID = 0, ///< uninitialized/invalid operand. + CS_OP_REG, ///< Register operand. + CS_OP_IMM, ///< Immediate operand. + CS_OP_MEM, ///< Memory operand. + CS_OP_FP, ///< Floating-Point operand. +} cs_op_type; + +/// Common instruction operand access types - to be consistent across all architectures. +/// It is possible to combine access types, for example: CS_AC_READ | CS_AC_WRITE +typedef enum cs_ac_type { + CS_AC_INVALID = 0, ///< Uninitialized/invalid access type. + CS_AC_READ = 1 << 0, ///< Operand read from memory or register. + CS_AC_WRITE = 1 << 1, ///< Operand write to memory or register. +} cs_ac_type; + +/// Common instruction groups - to be consistent across all architectures. +typedef enum cs_group_type { + CS_GRP_INVALID = 0, ///< uninitialized/invalid group. + CS_GRP_JUMP, ///< all jump instructions (conditional+direct+indirect jumps) + CS_GRP_CALL, ///< all call instructions + CS_GRP_RET, ///< all return instructions + CS_GRP_INT, ///< all interrupt instructions (int+syscall) + CS_GRP_IRET, ///< all interrupt return instructions + CS_GRP_PRIVILEGE, ///< all privileged instructions + CS_GRP_BRANCH_RELATIVE, ///< all relative branching instructions +} cs_group_type; + +/** + User-defined callback function for SKIPDATA option. + See tests/test_skipdata.c for sample code demonstrating this API. + + @code: the input buffer containing code to be disassembled. + This is the same buffer passed to cs_disasm(). + @code_size: size (in bytes) of the above @code buffer. + @offset: the position of the currently-examining byte in the input + buffer @code mentioned above. + @user_data: user-data passed to cs_option() via @user_data field in + cs_opt_skipdata struct below. + + @return: return number of bytes to skip, or 0 to immediately stop disassembling. +*/ +typedef size_t (CAPSTONE_API *cs_skipdata_cb_t)(const uint8_t *code, size_t code_size, size_t offset, void *user_data); + +/// User-customized setup for SKIPDATA option +typedef struct cs_opt_skipdata { + /// Capstone considers data to skip as special "instructions". + /// User can specify the string for this instruction's "mnemonic" here. + /// By default (if @mnemonic is NULL), Capstone use ".byte". + const char *mnemonic; + + /// User-defined callback function to be called when Capstone hits data. + /// If the returned value from this callback is positive (>0), Capstone + /// will skip exactly that number of bytes & continue. Otherwise, if + /// the callback returns 0, Capstone stops disassembling and returns + /// immediately from cs_disasm() + /// NOTE: if this callback pointer is NULL, Capstone would skip a number + /// of bytes depending on architectures, as following: + /// Arm: 2 bytes (Thumb mode) or 4 bytes. + /// Arm64: 4 bytes. + /// Mips: 4 bytes. + /// M680x: 1 byte. + /// PowerPC: 4 bytes. + /// Sparc: 4 bytes. + /// SystemZ: 2 bytes. + /// X86: 1 bytes. + /// XCore: 2 bytes. + /// EVM: 1 bytes. + /// RISCV: 4 bytes. + /// WASM: 1 bytes. + /// MOS65XX: 1 bytes. + /// BPF: 8 bytes. + cs_skipdata_cb_t callback; // default value is NULL + + /// User-defined data to be passed to @callback function pointer. + void *user_data; +} cs_opt_skipdata; + + +#ifndef CAPSTONE_ARM_H +#define CAPSTONE_ARM_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2013-2015 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// ARM shift type +typedef enum arm_shifter { + ARM_SFT_INVALID = 0, + ARM_SFT_ASR, ///< shift with immediate const + ARM_SFT_LSL, ///< shift with immediate const + ARM_SFT_LSR, ///< shift with immediate const + ARM_SFT_ROR, ///< shift with immediate const + ARM_SFT_RRX, ///< shift with immediate const + ARM_SFT_ASR_REG, ///< shift with register + ARM_SFT_LSL_REG, ///< shift with register + ARM_SFT_LSR_REG, ///< shift with register + ARM_SFT_ROR_REG, ///< shift with register + ARM_SFT_RRX_REG, ///< shift with register +} arm_shifter; + +/// ARM condition code +typedef enum arm_cc { + ARM_CC_INVALID = 0, + ARM_CC_EQ, ///< Equal Equal + ARM_CC_NE, ///< Not equal Not equal, or unordered + ARM_CC_HS, ///< Carry set >, ==, or unordered + ARM_CC_LO, ///< Carry clear Less than + ARM_CC_MI, ///< Minus, negative Less than + ARM_CC_PL, ///< Plus, positive or zero >, ==, or unordered + ARM_CC_VS, ///< Overflow Unordered + ARM_CC_VC, ///< No overflow Not unordered + ARM_CC_HI, ///< Unsigned higher Greater than, or unordered + ARM_CC_LS, ///< Unsigned lower or same Less than or equal + ARM_CC_GE, ///< Greater than or equal Greater than or equal + ARM_CC_LT, ///< Less than Less than, or unordered + ARM_CC_GT, ///< Greater than Greater than + ARM_CC_LE, ///< Less than or equal <, ==, or unordered + ARM_CC_AL ///< Always (unconditional) Always (unconditional) +} arm_cc; + +typedef enum arm_sysreg { + /// Special registers for MSR + ARM_SYSREG_INVALID = 0, + + // SPSR* registers can be OR combined + ARM_SYSREG_SPSR_C = 1, + ARM_SYSREG_SPSR_X = 2, + ARM_SYSREG_SPSR_S = 4, + ARM_SYSREG_SPSR_F = 8, + + // CPSR* registers can be OR combined + ARM_SYSREG_CPSR_C = 16, + ARM_SYSREG_CPSR_X = 32, + ARM_SYSREG_CPSR_S = 64, + ARM_SYSREG_CPSR_F = 128, + + // independent registers + ARM_SYSREG_APSR = 256, + ARM_SYSREG_APSR_G, + ARM_SYSREG_APSR_NZCVQ, + ARM_SYSREG_APSR_NZCVQG, + + ARM_SYSREG_IAPSR, + ARM_SYSREG_IAPSR_G, + ARM_SYSREG_IAPSR_NZCVQG, + ARM_SYSREG_IAPSR_NZCVQ, + + ARM_SYSREG_EAPSR, + ARM_SYSREG_EAPSR_G, + ARM_SYSREG_EAPSR_NZCVQG, + ARM_SYSREG_EAPSR_NZCVQ, + + ARM_SYSREG_XPSR, + ARM_SYSREG_XPSR_G, + ARM_SYSREG_XPSR_NZCVQG, + ARM_SYSREG_XPSR_NZCVQ, + + ARM_SYSREG_IPSR, + ARM_SYSREG_EPSR, + ARM_SYSREG_IEPSR, + + ARM_SYSREG_MSP, + ARM_SYSREG_PSP, + ARM_SYSREG_PRIMASK, + ARM_SYSREG_BASEPRI, + ARM_SYSREG_BASEPRI_MAX, + ARM_SYSREG_FAULTMASK, + ARM_SYSREG_CONTROL, + ARM_SYSREG_MSPLIM, + ARM_SYSREG_PSPLIM, + ARM_SYSREG_MSP_NS, + ARM_SYSREG_PSP_NS, + ARM_SYSREG_MSPLIM_NS, + ARM_SYSREG_PSPLIM_NS, + ARM_SYSREG_PRIMASK_NS, + ARM_SYSREG_BASEPRI_NS, + ARM_SYSREG_FAULTMASK_NS, + ARM_SYSREG_CONTROL_NS, + ARM_SYSREG_SP_NS, + + // Banked Registers + ARM_SYSREG_R8_USR, + ARM_SYSREG_R9_USR, + ARM_SYSREG_R10_USR, + ARM_SYSREG_R11_USR, + ARM_SYSREG_R12_USR, + ARM_SYSREG_SP_USR, + ARM_SYSREG_LR_USR, + ARM_SYSREG_R8_FIQ, + ARM_SYSREG_R9_FIQ, + ARM_SYSREG_R10_FIQ, + ARM_SYSREG_R11_FIQ, + ARM_SYSREG_R12_FIQ, + ARM_SYSREG_SP_FIQ, + ARM_SYSREG_LR_FIQ, + ARM_SYSREG_LR_IRQ, + ARM_SYSREG_SP_IRQ, + ARM_SYSREG_LR_SVC, + ARM_SYSREG_SP_SVC, + ARM_SYSREG_LR_ABT, + ARM_SYSREG_SP_ABT, + ARM_SYSREG_LR_UND, + ARM_SYSREG_SP_UND, + ARM_SYSREG_LR_MON, + ARM_SYSREG_SP_MON, + ARM_SYSREG_ELR_HYP, + ARM_SYSREG_SP_HYP, + + ARM_SYSREG_SPSR_FIQ, + ARM_SYSREG_SPSR_IRQ, + ARM_SYSREG_SPSR_SVC, + ARM_SYSREG_SPSR_ABT, + ARM_SYSREG_SPSR_UND, + ARM_SYSREG_SPSR_MON, + ARM_SYSREG_SPSR_HYP, +} arm_sysreg; + +/// The memory barrier constants map directly to the 4-bit encoding of +/// the option field for Memory Barrier operations. +typedef enum arm_mem_barrier { + ARM_MB_INVALID = 0, + ARM_MB_RESERVED_0, + ARM_MB_OSHLD, + ARM_MB_OSHST, + ARM_MB_OSH, + ARM_MB_RESERVED_4, + ARM_MB_NSHLD, + ARM_MB_NSHST, + ARM_MB_NSH, + ARM_MB_RESERVED_8, + ARM_MB_ISHLD, + ARM_MB_ISHST, + ARM_MB_ISH, + ARM_MB_RESERVED_12, + ARM_MB_LD, + ARM_MB_ST, + ARM_MB_SY, +} arm_mem_barrier; + +/// Operand type for instruction's operands +typedef enum arm_op_type { + ARM_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + ARM_OP_REG, ///< = CS_OP_REG (Register operand). + ARM_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + ARM_OP_MEM, ///< = CS_OP_MEM (Memory operand). + ARM_OP_FP, ///< = CS_OP_FP (Floating-Point operand). + ARM_OP_CIMM = 64, ///< C-Immediate (coprocessor registers) + ARM_OP_PIMM, ///< P-Immediate (coprocessor registers) + ARM_OP_SETEND, ///< operand for SETEND instruction + ARM_OP_SYSREG, ///< MSR/MRS special register operand +} arm_op_type; + +/// Operand type for SETEND instruction +typedef enum arm_setend_type { + ARM_SETEND_INVALID = 0, ///< Uninitialized. + ARM_SETEND_BE, ///< BE operand. + ARM_SETEND_LE, ///< LE operand +} arm_setend_type; + +typedef enum arm_cpsmode_type { + ARM_CPSMODE_INVALID = 0, + ARM_CPSMODE_IE = 2, + ARM_CPSMODE_ID = 3 +} arm_cpsmode_type; + +/// Operand type for SETEND instruction +typedef enum arm_cpsflag_type { + ARM_CPSFLAG_INVALID = 0, + ARM_CPSFLAG_F = 1, + ARM_CPSFLAG_I = 2, + ARM_CPSFLAG_A = 4, + ARM_CPSFLAG_NONE = 16, ///< no flag +} arm_cpsflag_type; + +/// Data type for elements of vector instructions. +typedef enum arm_vectordata_type { + ARM_VECTORDATA_INVALID = 0, + + // Integer type + ARM_VECTORDATA_I8, + ARM_VECTORDATA_I16, + ARM_VECTORDATA_I32, + ARM_VECTORDATA_I64, + + // Signed integer type + ARM_VECTORDATA_S8, + ARM_VECTORDATA_S16, + ARM_VECTORDATA_S32, + ARM_VECTORDATA_S64, + + // Unsigned integer type + ARM_VECTORDATA_U8, + ARM_VECTORDATA_U16, + ARM_VECTORDATA_U32, + ARM_VECTORDATA_U64, + + // Data type for VMUL/VMULL + ARM_VECTORDATA_P8, + + // Floating type + ARM_VECTORDATA_F16, + ARM_VECTORDATA_F32, + ARM_VECTORDATA_F64, + + // Convert float <-> float + ARM_VECTORDATA_F16F64, // f16.f64 + ARM_VECTORDATA_F64F16, // f64.f16 + ARM_VECTORDATA_F32F16, // f32.f16 + ARM_VECTORDATA_F16F32, // f32.f16 + ARM_VECTORDATA_F64F32, // f64.f32 + ARM_VECTORDATA_F32F64, // f32.f64 + + // Convert integer <-> float + ARM_VECTORDATA_S32F32, // s32.f32 + ARM_VECTORDATA_U32F32, // u32.f32 + ARM_VECTORDATA_F32S32, // f32.s32 + ARM_VECTORDATA_F32U32, // f32.u32 + ARM_VECTORDATA_F64S16, // f64.s16 + ARM_VECTORDATA_F32S16, // f32.s16 + ARM_VECTORDATA_F64S32, // f64.s32 + ARM_VECTORDATA_S16F64, // s16.f64 + ARM_VECTORDATA_S16F32, // s16.f64 + ARM_VECTORDATA_S32F64, // s32.f64 + ARM_VECTORDATA_U16F64, // u16.f64 + ARM_VECTORDATA_U16F32, // u16.f32 + ARM_VECTORDATA_U32F64, // u32.f64 + ARM_VECTORDATA_F64U16, // f64.u16 + ARM_VECTORDATA_F32U16, // f32.u16 + ARM_VECTORDATA_F64U32, // f64.u32 + ARM_VECTORDATA_F16U16, // f16.u16 + ARM_VECTORDATA_U16F16, // u16.f16 + ARM_VECTORDATA_F16U32, // f16.u32 + ARM_VECTORDATA_U32F16, // u32.f16 +} arm_vectordata_type; + +/// ARM registers +typedef enum arm_reg { + ARM_REG_INVALID = 0, + ARM_REG_APSR, + ARM_REG_APSR_NZCV, + ARM_REG_CPSR, + ARM_REG_FPEXC, + ARM_REG_FPINST, + ARM_REG_FPSCR, + ARM_REG_FPSCR_NZCV, + ARM_REG_FPSID, + ARM_REG_ITSTATE, + ARM_REG_LR, + ARM_REG_PC, + ARM_REG_SP, + ARM_REG_SPSR, + ARM_REG_D0, + ARM_REG_D1, + ARM_REG_D2, + ARM_REG_D3, + ARM_REG_D4, + ARM_REG_D5, + ARM_REG_D6, + ARM_REG_D7, + ARM_REG_D8, + ARM_REG_D9, + ARM_REG_D10, + ARM_REG_D11, + ARM_REG_D12, + ARM_REG_D13, + ARM_REG_D14, + ARM_REG_D15, + ARM_REG_D16, + ARM_REG_D17, + ARM_REG_D18, + ARM_REG_D19, + ARM_REG_D20, + ARM_REG_D21, + ARM_REG_D22, + ARM_REG_D23, + ARM_REG_D24, + ARM_REG_D25, + ARM_REG_D26, + ARM_REG_D27, + ARM_REG_D28, + ARM_REG_D29, + ARM_REG_D30, + ARM_REG_D31, + ARM_REG_FPINST2, + ARM_REG_MVFR0, + ARM_REG_MVFR1, + ARM_REG_MVFR2, + ARM_REG_Q0, + ARM_REG_Q1, + ARM_REG_Q2, + ARM_REG_Q3, + ARM_REG_Q4, + ARM_REG_Q5, + ARM_REG_Q6, + ARM_REG_Q7, + ARM_REG_Q8, + ARM_REG_Q9, + ARM_REG_Q10, + ARM_REG_Q11, + ARM_REG_Q12, + ARM_REG_Q13, + ARM_REG_Q14, + ARM_REG_Q15, + ARM_REG_R0, + ARM_REG_R1, + ARM_REG_R2, + ARM_REG_R3, + ARM_REG_R4, + ARM_REG_R5, + ARM_REG_R6, + ARM_REG_R7, + ARM_REG_R8, + ARM_REG_R9, + ARM_REG_R10, + ARM_REG_R11, + ARM_REG_R12, + ARM_REG_S0, + ARM_REG_S1, + ARM_REG_S2, + ARM_REG_S3, + ARM_REG_S4, + ARM_REG_S5, + ARM_REG_S6, + ARM_REG_S7, + ARM_REG_S8, + ARM_REG_S9, + ARM_REG_S10, + ARM_REG_S11, + ARM_REG_S12, + ARM_REG_S13, + ARM_REG_S14, + ARM_REG_S15, + ARM_REG_S16, + ARM_REG_S17, + ARM_REG_S18, + ARM_REG_S19, + ARM_REG_S20, + ARM_REG_S21, + ARM_REG_S22, + ARM_REG_S23, + ARM_REG_S24, + ARM_REG_S25, + ARM_REG_S26, + ARM_REG_S27, + ARM_REG_S28, + ARM_REG_S29, + ARM_REG_S30, + ARM_REG_S31, + + ARM_REG_ENDING, // <-- mark the end of the list or registers + + // alias registers + ARM_REG_R13 = ARM_REG_SP, + ARM_REG_R14 = ARM_REG_LR, + ARM_REG_R15 = ARM_REG_PC, + + ARM_REG_SB = ARM_REG_R9, + ARM_REG_SL = ARM_REG_R10, + ARM_REG_FP = ARM_REG_R11, + ARM_REG_IP = ARM_REG_R12, +} arm_reg; + +/// Instruction's operand referring to memory +/// This is associated with ARM_OP_MEM operand type above +typedef struct arm_op_mem { + arm_reg base; ///< base register + arm_reg index; ///< index register + int scale; ///< scale for index register (can be 1, or -1) + int disp; ///< displacement/offset value + /// left-shift on index register, or 0 if irrelevant + /// NOTE: this value can also be fetched via operand.shift.value + int lshift; +} arm_op_mem; + +/// Instruction operand +typedef struct cs_arm_op { + int vector_index; ///< Vector Index for some vector operands (or -1 if irrelevant) + + struct { + arm_shifter type; + unsigned int value; + } shift; + + arm_op_type type; ///< operand type + + union { + int reg; ///< register value for REG/SYSREG operand + int32_t imm; ///< immediate value for C-IMM, P-IMM or IMM operand + double fp; ///< floating point value for FP operand + arm_op_mem mem; ///< base/index/scale/disp value for MEM operand + arm_setend_type setend; ///< SETEND instruction's operand type + }; + + /// in some instructions, an operand can be subtracted or added to + /// the base register, + /// if TRUE, this operand is subtracted. otherwise, it is added. + bool subtracted; + + /// How is this operand accessed? (READ, WRITE or READ|WRITE) + /// This field is combined of cs_ac_type. + /// NOTE: this field is irrelevant if engine is compiled in DIET mode. + uint8_t access; + + /// Neon lane index for NEON instructions (or -1 if irrelevant) + int8_t neon_lane; +} cs_arm_op; + +/// Instruction structure +typedef struct cs_arm { + bool usermode; ///< User-mode registers to be loaded (for LDM/STM instructions) + int vector_size; ///< Scalar size for vector instructions + arm_vectordata_type vector_data; ///< Data type for elements of vector instructions + arm_cpsmode_type cps_mode; ///< CPS mode for CPS instruction + arm_cpsflag_type cps_flag; ///< CPS mode for CPS instruction + arm_cc cc; ///< conditional code for this insn + bool update_flags; ///< does this insn update flags? + bool writeback; ///< does this insn write-back? + arm_mem_barrier mem_barrier; ///< Option for some memory barrier instructions + + /// Number of operands of this instruction, + /// or 0 when instruction has no operand. + uint8_t op_count; + + cs_arm_op operands[36]; ///< operands for this instruction. +} cs_arm; + +/// ARM instruction +typedef enum arm_insn { + ARM_INS_INVALID = 0, + + ARM_INS_ADC, + ARM_INS_ADD, + ARM_INS_ADDW, + ARM_INS_ADR, + ARM_INS_AESD, + ARM_INS_AESE, + ARM_INS_AESIMC, + ARM_INS_AESMC, + ARM_INS_AND, + ARM_INS_ASR, + ARM_INS_B, + ARM_INS_BFC, + ARM_INS_BFI, + ARM_INS_BIC, + ARM_INS_BKPT, + ARM_INS_BL, + ARM_INS_BLX, + ARM_INS_BLXNS, + ARM_INS_BX, + ARM_INS_BXJ, + ARM_INS_BXNS, + ARM_INS_CBNZ, + ARM_INS_CBZ, + ARM_INS_CDP, + ARM_INS_CDP2, + ARM_INS_CLREX, + ARM_INS_CLZ, + ARM_INS_CMN, + ARM_INS_CMP, + ARM_INS_CPS, + ARM_INS_CRC32B, + ARM_INS_CRC32CB, + ARM_INS_CRC32CH, + ARM_INS_CRC32CW, + ARM_INS_CRC32H, + ARM_INS_CRC32W, + ARM_INS_CSDB, + ARM_INS_DBG, + ARM_INS_DCPS1, + ARM_INS_DCPS2, + ARM_INS_DCPS3, + ARM_INS_DFB, + ARM_INS_DMB, + ARM_INS_DSB, + ARM_INS_EOR, + ARM_INS_ERET, + ARM_INS_ESB, + ARM_INS_FADDD, + ARM_INS_FADDS, + ARM_INS_FCMPZD, + ARM_INS_FCMPZS, + ARM_INS_FCONSTD, + ARM_INS_FCONSTS, + ARM_INS_FLDMDBX, + ARM_INS_FLDMIAX, + ARM_INS_FMDHR, + ARM_INS_FMDLR, + ARM_INS_FMSTAT, + ARM_INS_FSTMDBX, + ARM_INS_FSTMIAX, + ARM_INS_FSUBD, + ARM_INS_FSUBS, + ARM_INS_HINT, + ARM_INS_HLT, + ARM_INS_HVC, + ARM_INS_ISB, + ARM_INS_IT, + ARM_INS_LDA, + ARM_INS_LDAB, + ARM_INS_LDAEX, + ARM_INS_LDAEXB, + ARM_INS_LDAEXD, + ARM_INS_LDAEXH, + ARM_INS_LDAH, + ARM_INS_LDC, + ARM_INS_LDC2, + ARM_INS_LDC2L, + ARM_INS_LDCL, + ARM_INS_LDM, + ARM_INS_LDMDA, + ARM_INS_LDMDB, + ARM_INS_LDMIB, + ARM_INS_LDR, + ARM_INS_LDRB, + ARM_INS_LDRBT, + ARM_INS_LDRD, + ARM_INS_LDREX, + ARM_INS_LDREXB, + ARM_INS_LDREXD, + ARM_INS_LDREXH, + ARM_INS_LDRH, + ARM_INS_LDRHT, + ARM_INS_LDRSB, + ARM_INS_LDRSBT, + ARM_INS_LDRSH, + ARM_INS_LDRSHT, + ARM_INS_LDRT, + ARM_INS_LSL, + ARM_INS_LSR, + ARM_INS_MCR, + ARM_INS_MCR2, + ARM_INS_MCRR, + ARM_INS_MCRR2, + ARM_INS_MLA, + ARM_INS_MLS, + ARM_INS_MOV, + ARM_INS_MOVS, + ARM_INS_MOVT, + ARM_INS_MOVW, + ARM_INS_MRC, + ARM_INS_MRC2, + ARM_INS_MRRC, + ARM_INS_MRRC2, + ARM_INS_MRS, + ARM_INS_MSR, + ARM_INS_MUL, + ARM_INS_MVN, + ARM_INS_NEG, + ARM_INS_NOP, + ARM_INS_ORN, + ARM_INS_ORR, + ARM_INS_PKHBT, + ARM_INS_PKHTB, + ARM_INS_PLD, + ARM_INS_PLDW, + ARM_INS_PLI, + ARM_INS_POP, + ARM_INS_PUSH, + ARM_INS_QADD, + ARM_INS_QADD16, + ARM_INS_QADD8, + ARM_INS_QASX, + ARM_INS_QDADD, + ARM_INS_QDSUB, + ARM_INS_QSAX, + ARM_INS_QSUB, + ARM_INS_QSUB16, + ARM_INS_QSUB8, + ARM_INS_RBIT, + ARM_INS_REV, + ARM_INS_REV16, + ARM_INS_REVSH, + ARM_INS_RFEDA, + ARM_INS_RFEDB, + ARM_INS_RFEIA, + ARM_INS_RFEIB, + ARM_INS_ROR, + ARM_INS_RRX, + ARM_INS_RSB, + ARM_INS_RSC, + ARM_INS_SADD16, + ARM_INS_SADD8, + ARM_INS_SASX, + ARM_INS_SBC, + ARM_INS_SBFX, + ARM_INS_SDIV, + ARM_INS_SEL, + ARM_INS_SETEND, + ARM_INS_SETPAN, + ARM_INS_SEV, + ARM_INS_SEVL, + ARM_INS_SG, + ARM_INS_SHA1C, + ARM_INS_SHA1H, + ARM_INS_SHA1M, + ARM_INS_SHA1P, + ARM_INS_SHA1SU0, + ARM_INS_SHA1SU1, + ARM_INS_SHA256H, + ARM_INS_SHA256H2, + ARM_INS_SHA256SU0, + ARM_INS_SHA256SU1, + ARM_INS_SHADD16, + ARM_INS_SHADD8, + ARM_INS_SHASX, + ARM_INS_SHSAX, + ARM_INS_SHSUB16, + ARM_INS_SHSUB8, + ARM_INS_SMC, + ARM_INS_SMLABB, + ARM_INS_SMLABT, + ARM_INS_SMLAD, + ARM_INS_SMLADX, + ARM_INS_SMLAL, + ARM_INS_SMLALBB, + ARM_INS_SMLALBT, + ARM_INS_SMLALD, + ARM_INS_SMLALDX, + ARM_INS_SMLALTB, + ARM_INS_SMLALTT, + ARM_INS_SMLATB, + ARM_INS_SMLATT, + ARM_INS_SMLAWB, + ARM_INS_SMLAWT, + ARM_INS_SMLSD, + ARM_INS_SMLSDX, + ARM_INS_SMLSLD, + ARM_INS_SMLSLDX, + ARM_INS_SMMLA, + ARM_INS_SMMLAR, + ARM_INS_SMMLS, + ARM_INS_SMMLSR, + ARM_INS_SMMUL, + ARM_INS_SMMULR, + ARM_INS_SMUAD, + ARM_INS_SMUADX, + ARM_INS_SMULBB, + ARM_INS_SMULBT, + ARM_INS_SMULL, + ARM_INS_SMULTB, + ARM_INS_SMULTT, + ARM_INS_SMULWB, + ARM_INS_SMULWT, + ARM_INS_SMUSD, + ARM_INS_SMUSDX, + ARM_INS_SRSDA, + ARM_INS_SRSDB, + ARM_INS_SRSIA, + ARM_INS_SRSIB, + ARM_INS_SSAT, + ARM_INS_SSAT16, + ARM_INS_SSAX, + ARM_INS_SSUB16, + ARM_INS_SSUB8, + ARM_INS_STC, + ARM_INS_STC2, + ARM_INS_STC2L, + ARM_INS_STCL, + ARM_INS_STL, + ARM_INS_STLB, + ARM_INS_STLEX, + ARM_INS_STLEXB, + ARM_INS_STLEXD, + ARM_INS_STLEXH, + ARM_INS_STLH, + ARM_INS_STM, + ARM_INS_STMDA, + ARM_INS_STMDB, + ARM_INS_STMIB, + ARM_INS_STR, + ARM_INS_STRB, + ARM_INS_STRBT, + ARM_INS_STRD, + ARM_INS_STREX, + ARM_INS_STREXB, + ARM_INS_STREXD, + ARM_INS_STREXH, + ARM_INS_STRH, + ARM_INS_STRHT, + ARM_INS_STRT, + ARM_INS_SUB, + ARM_INS_SUBS, + ARM_INS_SUBW, + ARM_INS_SVC, + ARM_INS_SWP, + ARM_INS_SWPB, + ARM_INS_SXTAB, + ARM_INS_SXTAB16, + ARM_INS_SXTAH, + ARM_INS_SXTB, + ARM_INS_SXTB16, + ARM_INS_SXTH, + ARM_INS_TBB, + ARM_INS_TBH, + ARM_INS_TEQ, + ARM_INS_TRAP, + ARM_INS_TSB, + ARM_INS_TST, + ARM_INS_TT, + ARM_INS_TTA, + ARM_INS_TTAT, + ARM_INS_TTT, + ARM_INS_UADD16, + ARM_INS_UADD8, + ARM_INS_UASX, + ARM_INS_UBFX, + ARM_INS_UDF, + ARM_INS_UDIV, + ARM_INS_UHADD16, + ARM_INS_UHADD8, + ARM_INS_UHASX, + ARM_INS_UHSAX, + ARM_INS_UHSUB16, + ARM_INS_UHSUB8, + ARM_INS_UMAAL, + ARM_INS_UMLAL, + ARM_INS_UMULL, + ARM_INS_UQADD16, + ARM_INS_UQADD8, + ARM_INS_UQASX, + ARM_INS_UQSAX, + ARM_INS_UQSUB16, + ARM_INS_UQSUB8, + ARM_INS_USAD8, + ARM_INS_USADA8, + ARM_INS_USAT, + ARM_INS_USAT16, + ARM_INS_USAX, + ARM_INS_USUB16, + ARM_INS_USUB8, + ARM_INS_UXTAB, + ARM_INS_UXTAB16, + ARM_INS_UXTAH, + ARM_INS_UXTB, + ARM_INS_UXTB16, + ARM_INS_UXTH, + ARM_INS_VABA, + ARM_INS_VABAL, + ARM_INS_VABD, + ARM_INS_VABDL, + ARM_INS_VABS, + ARM_INS_VACGE, + ARM_INS_VACGT, + ARM_INS_VACLE, + ARM_INS_VACLT, + ARM_INS_VADD, + ARM_INS_VADDHN, + ARM_INS_VADDL, + ARM_INS_VADDW, + ARM_INS_VAND, + ARM_INS_VBIC, + ARM_INS_VBIF, + ARM_INS_VBIT, + ARM_INS_VBSL, + ARM_INS_VCADD, + ARM_INS_VCEQ, + ARM_INS_VCGE, + ARM_INS_VCGT, + ARM_INS_VCLE, + ARM_INS_VCLS, + ARM_INS_VCLT, + ARM_INS_VCLZ, + ARM_INS_VCMLA, + ARM_INS_VCMP, + ARM_INS_VCMPE, + ARM_INS_VCNT, + ARM_INS_VCVT, + ARM_INS_VCVTA, + ARM_INS_VCVTB, + ARM_INS_VCVTM, + ARM_INS_VCVTN, + ARM_INS_VCVTP, + ARM_INS_VCVTR, + ARM_INS_VCVTT, + ARM_INS_VDIV, + ARM_INS_VDUP, + ARM_INS_VEOR, + ARM_INS_VEXT, + ARM_INS_VFMA, + ARM_INS_VFMS, + ARM_INS_VFNMA, + ARM_INS_VFNMS, + ARM_INS_VHADD, + ARM_INS_VHSUB, + ARM_INS_VINS, + ARM_INS_VJCVT, + ARM_INS_VLD1, + ARM_INS_VLD2, + ARM_INS_VLD3, + ARM_INS_VLD4, + ARM_INS_VLDMDB, + ARM_INS_VLDMIA, + ARM_INS_VLDR, + ARM_INS_VLLDM, + ARM_INS_VLSTM, + ARM_INS_VMAX, + ARM_INS_VMAXNM, + ARM_INS_VMIN, + ARM_INS_VMINNM, + ARM_INS_VMLA, + ARM_INS_VMLAL, + ARM_INS_VMLS, + ARM_INS_VMLSL, + ARM_INS_VMOV, + ARM_INS_VMOVL, + ARM_INS_VMOVN, + ARM_INS_VMOVX, + ARM_INS_VMRS, + ARM_INS_VMSR, + ARM_INS_VMUL, + ARM_INS_VMULL, + ARM_INS_VMVN, + ARM_INS_VNEG, + ARM_INS_VNMLA, + ARM_INS_VNMLS, + ARM_INS_VNMUL, + ARM_INS_VORN, + ARM_INS_VORR, + ARM_INS_VPADAL, + ARM_INS_VPADD, + ARM_INS_VPADDL, + ARM_INS_VPMAX, + ARM_INS_VPMIN, + ARM_INS_VPOP, + ARM_INS_VPUSH, + ARM_INS_VQABS, + ARM_INS_VQADD, + ARM_INS_VQDMLAL, + ARM_INS_VQDMLSL, + ARM_INS_VQDMULH, + ARM_INS_VQDMULL, + ARM_INS_VQMOVN, + ARM_INS_VQMOVUN, + ARM_INS_VQNEG, + ARM_INS_VQRDMLAH, + ARM_INS_VQRDMLSH, + ARM_INS_VQRDMULH, + ARM_INS_VQRSHL, + ARM_INS_VQRSHRN, + ARM_INS_VQRSHRUN, + ARM_INS_VQSHL, + ARM_INS_VQSHLU, + ARM_INS_VQSHRN, + ARM_INS_VQSHRUN, + ARM_INS_VQSUB, + ARM_INS_VRADDHN, + ARM_INS_VRECPE, + ARM_INS_VRECPS, + ARM_INS_VREV16, + ARM_INS_VREV32, + ARM_INS_VREV64, + ARM_INS_VRHADD, + ARM_INS_VRINTA, + ARM_INS_VRINTM, + ARM_INS_VRINTN, + ARM_INS_VRINTP, + ARM_INS_VRINTR, + ARM_INS_VRINTX, + ARM_INS_VRINTZ, + ARM_INS_VRSHL, + ARM_INS_VRSHR, + ARM_INS_VRSHRN, + ARM_INS_VRSQRTE, + ARM_INS_VRSQRTS, + ARM_INS_VRSRA, + ARM_INS_VRSUBHN, + ARM_INS_VSDOT, + ARM_INS_VSELEQ, + ARM_INS_VSELGE, + ARM_INS_VSELGT, + ARM_INS_VSELVS, + ARM_INS_VSHL, + ARM_INS_VSHLL, + ARM_INS_VSHR, + ARM_INS_VSHRN, + ARM_INS_VSLI, + ARM_INS_VSQRT, + ARM_INS_VSRA, + ARM_INS_VSRI, + ARM_INS_VST1, + ARM_INS_VST2, + ARM_INS_VST3, + ARM_INS_VST4, + ARM_INS_VSTMDB, + ARM_INS_VSTMIA, + ARM_INS_VSTR, + ARM_INS_VSUB, + ARM_INS_VSUBHN, + ARM_INS_VSUBL, + ARM_INS_VSUBW, + ARM_INS_VSWP, + ARM_INS_VTBL, + ARM_INS_VTBX, + ARM_INS_VTRN, + ARM_INS_VTST, + ARM_INS_VUDOT, + ARM_INS_VUZP, + ARM_INS_VZIP, + ARM_INS_WFE, + ARM_INS_WFI, + ARM_INS_YIELD, + + ARM_INS_ENDING, // <-- mark the end of the list of instructions +} arm_insn; + +/// Group of ARM instructions +typedef enum arm_insn_group { + ARM_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + // Generic groups + // all jump instructions (conditional+direct+indirect jumps) + ARM_GRP_JUMP, ///< = CS_GRP_JUMP + ARM_GRP_CALL, ///< = CS_GRP_CALL + ARM_GRP_INT = 4, ///< = CS_GRP_INT + ARM_GRP_PRIVILEGE = 6, ///< = CS_GRP_PRIVILEGE + ARM_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE + + // Architecture-specific groups + ARM_GRP_CRYPTO = 128, + ARM_GRP_DATABARRIER, + ARM_GRP_DIVIDE, + ARM_GRP_FPARMV8, + ARM_GRP_MULTPRO, + ARM_GRP_NEON, + ARM_GRP_T2EXTRACTPACK, + ARM_GRP_THUMB2DSP, + ARM_GRP_TRUSTZONE, + ARM_GRP_V4T, + ARM_GRP_V5T, + ARM_GRP_V5TE, + ARM_GRP_V6, + ARM_GRP_V6T2, + ARM_GRP_V7, + ARM_GRP_V8, + ARM_GRP_VFP2, + ARM_GRP_VFP3, + ARM_GRP_VFP4, + ARM_GRP_ARM, + ARM_GRP_MCLASS, + ARM_GRP_NOTMCLASS, + ARM_GRP_THUMB, + ARM_GRP_THUMB1ONLY, + ARM_GRP_THUMB2, + ARM_GRP_PREV8, + ARM_GRP_FPVMLX, + ARM_GRP_MULOPS, + ARM_GRP_CRC, + ARM_GRP_DPVFP, + ARM_GRP_V6M, + ARM_GRP_VIRTUALIZATION, + + ARM_GRP_ENDING, +} arm_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_ARM64_H +#define CAPSTONE_ARM64_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2013-2015 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// ARM64 shift type +typedef enum arm64_shifter { + ARM64_SFT_INVALID = 0, + ARM64_SFT_LSL = 1, + ARM64_SFT_MSL = 2, + ARM64_SFT_LSR = 3, + ARM64_SFT_ASR = 4, + ARM64_SFT_ROR = 5, +} arm64_shifter; + +/// ARM64 extender type +typedef enum arm64_extender { + ARM64_EXT_INVALID = 0, + ARM64_EXT_UXTB = 1, + ARM64_EXT_UXTH = 2, + ARM64_EXT_UXTW = 3, + ARM64_EXT_UXTX = 4, + ARM64_EXT_SXTB = 5, + ARM64_EXT_SXTH = 6, + ARM64_EXT_SXTW = 7, + ARM64_EXT_SXTX = 8, +} arm64_extender; + +/// ARM64 condition code +typedef enum arm64_cc { + ARM64_CC_INVALID = 0, + ARM64_CC_EQ = 1, ///< Equal + ARM64_CC_NE = 2, ///< Not equal: Not equal, or unordered + ARM64_CC_HS = 3, ///< Unsigned higher or same: >, ==, or unordered + ARM64_CC_LO = 4, ///< Unsigned lower or same: Less than + ARM64_CC_MI = 5, ///< Minus, negative: Less than + ARM64_CC_PL = 6, ///< Plus, positive or zero: >, ==, or unordered + ARM64_CC_VS = 7, ///< Overflow: Unordered + ARM64_CC_VC = 8, ///< No overflow: Ordered + ARM64_CC_HI = 9, ///< Unsigned higher: Greater than, or unordered + ARM64_CC_LS = 10, ///< Unsigned lower or same: Less than or equal + ARM64_CC_GE = 11, ///< Greater than or equal: Greater than or equal + ARM64_CC_LT = 12, ///< Less than: Less than, or unordered + ARM64_CC_GT = 13, ///< Signed greater than: Greater than + ARM64_CC_LE = 14, ///< Signed less than or equal: <, ==, or unordered + ARM64_CC_AL = 15, ///< Always (unconditional): Always (unconditional) + ARM64_CC_NV = 16, ///< Always (unconditional): Always (unconditional) + //< Note the NV exists purely to disassemble 0b1111. Execution is "always". +} arm64_cc; + +/// System registers +typedef enum arm64_sysreg { + // System registers for MRS + ARM64_SYSREG_INVALID = 0, + + ARM64_SYSREG_MDCCSR_EL0 = 0x9808, + ARM64_SYSREG_DBGDTRRX_EL0 = 0x9828, + ARM64_SYSREG_MDRAR_EL1 = 0x8080, + ARM64_SYSREG_OSLSR_EL1 = 0x808C, + ARM64_SYSREG_DBGAUTHSTATUS_EL1 = 0x83F6, + ARM64_SYSREG_PMCEID0_EL0 = 0xDCE6, + ARM64_SYSREG_PMCEID1_EL0 = 0xDCE7, + ARM64_SYSREG_MIDR_EL1 = 0xC000, + ARM64_SYSREG_CCSIDR_EL1 = 0xC800, + ARM64_SYSREG_CCSIDR2_EL1 = 0xC802, + ARM64_SYSREG_CLIDR_EL1 = 0xC801, + ARM64_SYSREG_CTR_EL0 = 0xD801, + ARM64_SYSREG_MPIDR_EL1 = 0xC005, + ARM64_SYSREG_REVIDR_EL1 = 0xC006, + ARM64_SYSREG_AIDR_EL1 = 0xC807, + ARM64_SYSREG_DCZID_EL0 = 0xD807, + ARM64_SYSREG_ID_PFR0_EL1 = 0xC008, + ARM64_SYSREG_ID_PFR1_EL1 = 0xC009, + ARM64_SYSREG_ID_DFR0_EL1 = 0xC00A, + ARM64_SYSREG_ID_AFR0_EL1 = 0xC00B, + ARM64_SYSREG_ID_MMFR0_EL1 = 0xC00C, + ARM64_SYSREG_ID_MMFR1_EL1 = 0xC00D, + ARM64_SYSREG_ID_MMFR2_EL1 = 0xC00E, + ARM64_SYSREG_ID_MMFR3_EL1 = 0xC00F, + ARM64_SYSREG_ID_ISAR0_EL1 = 0xC010, + ARM64_SYSREG_ID_ISAR1_EL1 = 0xC011, + ARM64_SYSREG_ID_ISAR2_EL1 = 0xC012, + ARM64_SYSREG_ID_ISAR3_EL1 = 0xC013, + ARM64_SYSREG_ID_ISAR4_EL1 = 0xC014, + ARM64_SYSREG_ID_ISAR5_EL1 = 0xC015, + ARM64_SYSREG_ID_ISAR6_EL1 = 0xC017, + ARM64_SYSREG_ID_AA64PFR0_EL1 = 0xC020, + ARM64_SYSREG_ID_AA64PFR1_EL1 = 0xC021, + ARM64_SYSREG_ID_AA64DFR0_EL1 = 0xC028, + ARM64_SYSREG_ID_AA64DFR1_EL1 = 0xC029, + ARM64_SYSREG_ID_AA64AFR0_EL1 = 0xC02C, + ARM64_SYSREG_ID_AA64AFR1_EL1 = 0xC02D, + ARM64_SYSREG_ID_AA64ISAR0_EL1 = 0xC030, + ARM64_SYSREG_ID_AA64ISAR1_EL1 = 0xC031, + ARM64_SYSREG_ID_AA64MMFR0_EL1 = 0xC038, + ARM64_SYSREG_ID_AA64MMFR1_EL1 = 0xC039, + ARM64_SYSREG_ID_AA64MMFR2_EL1 = 0xC03A, + ARM64_SYSREG_MVFR0_EL1 = 0xC018, + ARM64_SYSREG_MVFR1_EL1 = 0xC019, + ARM64_SYSREG_MVFR2_EL1 = 0xC01A, + ARM64_SYSREG_RVBAR_EL1 = 0xC601, + ARM64_SYSREG_RVBAR_EL2 = 0xE601, + ARM64_SYSREG_RVBAR_EL3 = 0xF601, + ARM64_SYSREG_ISR_EL1 = 0xC608, + ARM64_SYSREG_CNTPCT_EL0 = 0xDF01, + ARM64_SYSREG_CNTVCT_EL0 = 0xDF02, + ARM64_SYSREG_ID_MMFR4_EL1 = 0xC016, + ARM64_SYSREG_TRCSTATR = 0x8818, + ARM64_SYSREG_TRCIDR8 = 0x8806, + ARM64_SYSREG_TRCIDR9 = 0x880E, + ARM64_SYSREG_TRCIDR10 = 0x8816, + ARM64_SYSREG_TRCIDR11 = 0x881E, + ARM64_SYSREG_TRCIDR12 = 0x8826, + ARM64_SYSREG_TRCIDR13 = 0x882E, + ARM64_SYSREG_TRCIDR0 = 0x8847, + ARM64_SYSREG_TRCIDR1 = 0x884F, + ARM64_SYSREG_TRCIDR2 = 0x8857, + ARM64_SYSREG_TRCIDR3 = 0x885F, + ARM64_SYSREG_TRCIDR4 = 0x8867, + ARM64_SYSREG_TRCIDR5 = 0x886F, + ARM64_SYSREG_TRCIDR6 = 0x8877, + ARM64_SYSREG_TRCIDR7 = 0x887F, + ARM64_SYSREG_TRCOSLSR = 0x888C, + ARM64_SYSREG_TRCPDSR = 0x88AC, + ARM64_SYSREG_TRCDEVAFF0 = 0x8BD6, + ARM64_SYSREG_TRCDEVAFF1 = 0x8BDE, + ARM64_SYSREG_TRCLSR = 0x8BEE, + ARM64_SYSREG_TRCAUTHSTATUS = 0x8BF6, + ARM64_SYSREG_TRCDEVARCH = 0x8BFE, + ARM64_SYSREG_TRCDEVID = 0x8B97, + ARM64_SYSREG_TRCDEVTYPE = 0x8B9F, + ARM64_SYSREG_TRCPIDR4 = 0x8BA7, + ARM64_SYSREG_TRCPIDR5 = 0x8BAF, + ARM64_SYSREG_TRCPIDR6 = 0x8BB7, + ARM64_SYSREG_TRCPIDR7 = 0x8BBF, + ARM64_SYSREG_TRCPIDR0 = 0x8BC7, + ARM64_SYSREG_TRCPIDR1 = 0x8BCF, + ARM64_SYSREG_TRCPIDR2 = 0x8BD7, + ARM64_SYSREG_TRCPIDR3 = 0x8BDF, + ARM64_SYSREG_TRCCIDR0 = 0x8BE7, + ARM64_SYSREG_TRCCIDR1 = 0x8BEF, + ARM64_SYSREG_TRCCIDR2 = 0x8BF7, + ARM64_SYSREG_TRCCIDR3 = 0x8BFF, + ARM64_SYSREG_ICC_IAR1_EL1 = 0xC660, + ARM64_SYSREG_ICC_IAR0_EL1 = 0xC640, + ARM64_SYSREG_ICC_HPPIR1_EL1 = 0xC662, + ARM64_SYSREG_ICC_HPPIR0_EL1 = 0xC642, + ARM64_SYSREG_ICC_RPR_EL1 = 0xC65B, + ARM64_SYSREG_ICH_VTR_EL2 = 0xE659, + ARM64_SYSREG_ICH_EISR_EL2 = 0xE65B, + ARM64_SYSREG_ICH_ELRSR_EL2 = 0xE65D, + ARM64_SYSREG_ID_AA64ZFR0_EL1 = 0xC024, + ARM64_SYSREG_LORID_EL1 = 0xC527, + ARM64_SYSREG_ERRIDR_EL1 = 0xC298, + ARM64_SYSREG_ERXFR_EL1 = 0xC2A0, + ARM64_SYSREG_DBGDTRTX_EL0 = 0x9828, + ARM64_SYSREG_OSLAR_EL1 = 0x8084, + ARM64_SYSREG_PMSWINC_EL0 = 0xDCE4, + ARM64_SYSREG_TRCOSLAR = 0x8884, + ARM64_SYSREG_TRCLAR = 0x8BE6, + ARM64_SYSREG_ICC_EOIR1_EL1 = 0xC661, + ARM64_SYSREG_ICC_EOIR0_EL1 = 0xC641, + ARM64_SYSREG_ICC_DIR_EL1 = 0xC659, + ARM64_SYSREG_ICC_SGI1R_EL1 = 0xC65D, + ARM64_SYSREG_ICC_ASGI1R_EL1 = 0xC65E, + ARM64_SYSREG_ICC_SGI0R_EL1 = 0xC65F, + ARM64_SYSREG_OSDTRRX_EL1 = 0x8002, + ARM64_SYSREG_OSDTRTX_EL1 = 0x801A, + ARM64_SYSREG_TEECR32_EL1 = 0x9000, + ARM64_SYSREG_MDCCINT_EL1 = 0x8010, + ARM64_SYSREG_MDSCR_EL1 = 0x8012, + ARM64_SYSREG_DBGDTR_EL0 = 0x9820, + ARM64_SYSREG_OSECCR_EL1 = 0x8032, + ARM64_SYSREG_DBGVCR32_EL2 = 0xA038, + ARM64_SYSREG_DBGBVR0_EL1 = 0x8004, + ARM64_SYSREG_DBGBVR1_EL1 = 0x800C, + ARM64_SYSREG_DBGBVR2_EL1 = 0x8014, + ARM64_SYSREG_DBGBVR3_EL1 = 0x801C, + ARM64_SYSREG_DBGBVR4_EL1 = 0x8024, + ARM64_SYSREG_DBGBVR5_EL1 = 0x802C, + ARM64_SYSREG_DBGBVR6_EL1 = 0x8034, + ARM64_SYSREG_DBGBVR7_EL1 = 0x803C, + ARM64_SYSREG_DBGBVR8_EL1 = 0x8044, + ARM64_SYSREG_DBGBVR9_EL1 = 0x804C, + ARM64_SYSREG_DBGBVR10_EL1 = 0x8054, + ARM64_SYSREG_DBGBVR11_EL1 = 0x805C, + ARM64_SYSREG_DBGBVR12_EL1 = 0x8064, + ARM64_SYSREG_DBGBVR13_EL1 = 0x806C, + ARM64_SYSREG_DBGBVR14_EL1 = 0x8074, + ARM64_SYSREG_DBGBVR15_EL1 = 0x807C, + ARM64_SYSREG_DBGBCR0_EL1 = 0x8005, + ARM64_SYSREG_DBGBCR1_EL1 = 0x800D, + ARM64_SYSREG_DBGBCR2_EL1 = 0x8015, + ARM64_SYSREG_DBGBCR3_EL1 = 0x801D, + ARM64_SYSREG_DBGBCR4_EL1 = 0x8025, + ARM64_SYSREG_DBGBCR5_EL1 = 0x802D, + ARM64_SYSREG_DBGBCR6_EL1 = 0x8035, + ARM64_SYSREG_DBGBCR7_EL1 = 0x803D, + ARM64_SYSREG_DBGBCR8_EL1 = 0x8045, + ARM64_SYSREG_DBGBCR9_EL1 = 0x804D, + ARM64_SYSREG_DBGBCR10_EL1 = 0x8055, + ARM64_SYSREG_DBGBCR11_EL1 = 0x805D, + ARM64_SYSREG_DBGBCR12_EL1 = 0x8065, + ARM64_SYSREG_DBGBCR13_EL1 = 0x806D, + ARM64_SYSREG_DBGBCR14_EL1 = 0x8075, + ARM64_SYSREG_DBGBCR15_EL1 = 0x807D, + ARM64_SYSREG_DBGWVR0_EL1 = 0x8006, + ARM64_SYSREG_DBGWVR1_EL1 = 0x800E, + ARM64_SYSREG_DBGWVR2_EL1 = 0x8016, + ARM64_SYSREG_DBGWVR3_EL1 = 0x801E, + ARM64_SYSREG_DBGWVR4_EL1 = 0x8026, + ARM64_SYSREG_DBGWVR5_EL1 = 0x802E, + ARM64_SYSREG_DBGWVR6_EL1 = 0x8036, + ARM64_SYSREG_DBGWVR7_EL1 = 0x803E, + ARM64_SYSREG_DBGWVR8_EL1 = 0x8046, + ARM64_SYSREG_DBGWVR9_EL1 = 0x804E, + ARM64_SYSREG_DBGWVR10_EL1 = 0x8056, + ARM64_SYSREG_DBGWVR11_EL1 = 0x805E, + ARM64_SYSREG_DBGWVR12_EL1 = 0x8066, + ARM64_SYSREG_DBGWVR13_EL1 = 0x806E, + ARM64_SYSREG_DBGWVR14_EL1 = 0x8076, + ARM64_SYSREG_DBGWVR15_EL1 = 0x807E, + ARM64_SYSREG_DBGWCR0_EL1 = 0x8007, + ARM64_SYSREG_DBGWCR1_EL1 = 0x800F, + ARM64_SYSREG_DBGWCR2_EL1 = 0x8017, + ARM64_SYSREG_DBGWCR3_EL1 = 0x801F, + ARM64_SYSREG_DBGWCR4_EL1 = 0x8027, + ARM64_SYSREG_DBGWCR5_EL1 = 0x802F, + ARM64_SYSREG_DBGWCR6_EL1 = 0x8037, + ARM64_SYSREG_DBGWCR7_EL1 = 0x803F, + ARM64_SYSREG_DBGWCR8_EL1 = 0x8047, + ARM64_SYSREG_DBGWCR9_EL1 = 0x804F, + ARM64_SYSREG_DBGWCR10_EL1 = 0x8057, + ARM64_SYSREG_DBGWCR11_EL1 = 0x805F, + ARM64_SYSREG_DBGWCR12_EL1 = 0x8067, + ARM64_SYSREG_DBGWCR13_EL1 = 0x806F, + ARM64_SYSREG_DBGWCR14_EL1 = 0x8077, + ARM64_SYSREG_DBGWCR15_EL1 = 0x807F, + ARM64_SYSREG_TEEHBR32_EL1 = 0x9080, + ARM64_SYSREG_OSDLR_EL1 = 0x809C, + ARM64_SYSREG_DBGPRCR_EL1 = 0x80A4, + ARM64_SYSREG_DBGCLAIMSET_EL1 = 0x83C6, + ARM64_SYSREG_DBGCLAIMCLR_EL1 = 0x83CE, + ARM64_SYSREG_CSSELR_EL1 = 0xD000, + ARM64_SYSREG_VPIDR_EL2 = 0xE000, + ARM64_SYSREG_VMPIDR_EL2 = 0xE005, + ARM64_SYSREG_CPACR_EL1 = 0xC082, + ARM64_SYSREG_SCTLR_EL1 = 0xC080, + ARM64_SYSREG_SCTLR_EL2 = 0xE080, + ARM64_SYSREG_SCTLR_EL3 = 0xF080, + ARM64_SYSREG_ACTLR_EL1 = 0xC081, + ARM64_SYSREG_ACTLR_EL2 = 0xE081, + ARM64_SYSREG_ACTLR_EL3 = 0xF081, + ARM64_SYSREG_HCR_EL2 = 0xE088, + ARM64_SYSREG_SCR_EL3 = 0xF088, + ARM64_SYSREG_MDCR_EL2 = 0xE089, + ARM64_SYSREG_SDER32_EL3 = 0xF089, + ARM64_SYSREG_CPTR_EL2 = 0xE08A, + ARM64_SYSREG_CPTR_EL3 = 0xF08A, + ARM64_SYSREG_HSTR_EL2 = 0xE08B, + ARM64_SYSREG_HACR_EL2 = 0xE08F, + ARM64_SYSREG_MDCR_EL3 = 0xF099, + ARM64_SYSREG_TTBR0_EL1 = 0xC100, + ARM64_SYSREG_TTBR0_EL2 = 0xE100, + ARM64_SYSREG_TTBR0_EL3 = 0xF100, + ARM64_SYSREG_TTBR1_EL1 = 0xC101, + ARM64_SYSREG_TCR_EL1 = 0xC102, + ARM64_SYSREG_TCR_EL2 = 0xE102, + ARM64_SYSREG_TCR_EL3 = 0xF102, + ARM64_SYSREG_VTTBR_EL2 = 0xE108, + ARM64_SYSREG_VTCR_EL2 = 0xE10A, + ARM64_SYSREG_DACR32_EL2 = 0xE180, + ARM64_SYSREG_SPSR_EL1 = 0xC200, + ARM64_SYSREG_SPSR_EL2 = 0xE200, + ARM64_SYSREG_SPSR_EL3 = 0xF200, + ARM64_SYSREG_ELR_EL1 = 0xC201, + ARM64_SYSREG_ELR_EL2 = 0xE201, + ARM64_SYSREG_ELR_EL3 = 0xF201, + ARM64_SYSREG_SP_EL0 = 0xC208, + ARM64_SYSREG_SP_EL1 = 0xE208, + ARM64_SYSREG_SP_EL2 = 0xF208, + ARM64_SYSREG_SPSEL = 0xC210, + ARM64_SYSREG_NZCV = 0xDA10, + ARM64_SYSREG_DAIF = 0xDA11, + ARM64_SYSREG_CURRENTEL = 0xC212, + ARM64_SYSREG_SPSR_IRQ = 0xE218, + ARM64_SYSREG_SPSR_ABT = 0xE219, + ARM64_SYSREG_SPSR_UND = 0xE21A, + ARM64_SYSREG_SPSR_FIQ = 0xE21B, + ARM64_SYSREG_FPCR = 0xDA20, + ARM64_SYSREG_FPSR = 0xDA21, + ARM64_SYSREG_DSPSR_EL0 = 0xDA28, + ARM64_SYSREG_DLR_EL0 = 0xDA29, + ARM64_SYSREG_IFSR32_EL2 = 0xE281, + ARM64_SYSREG_AFSR0_EL1 = 0xC288, + ARM64_SYSREG_AFSR0_EL2 = 0xE288, + ARM64_SYSREG_AFSR0_EL3 = 0xF288, + ARM64_SYSREG_AFSR1_EL1 = 0xC289, + ARM64_SYSREG_AFSR1_EL2 = 0xE289, + ARM64_SYSREG_AFSR1_EL3 = 0xF289, + ARM64_SYSREG_ESR_EL1 = 0xC290, + ARM64_SYSREG_ESR_EL2 = 0xE290, + ARM64_SYSREG_ESR_EL3 = 0xF290, + ARM64_SYSREG_FPEXC32_EL2 = 0xE298, + ARM64_SYSREG_FAR_EL1 = 0xC300, + ARM64_SYSREG_FAR_EL2 = 0xE300, + ARM64_SYSREG_FAR_EL3 = 0xF300, + ARM64_SYSREG_HPFAR_EL2 = 0xE304, + ARM64_SYSREG_PAR_EL1 = 0xC3A0, + ARM64_SYSREG_PMCR_EL0 = 0xDCE0, + ARM64_SYSREG_PMCNTENSET_EL0 = 0xDCE1, + ARM64_SYSREG_PMCNTENCLR_EL0 = 0xDCE2, + ARM64_SYSREG_PMOVSCLR_EL0 = 0xDCE3, + ARM64_SYSREG_PMSELR_EL0 = 0xDCE5, + ARM64_SYSREG_PMCCNTR_EL0 = 0xDCE8, + ARM64_SYSREG_PMXEVTYPER_EL0 = 0xDCE9, + ARM64_SYSREG_PMXEVCNTR_EL0 = 0xDCEA, + ARM64_SYSREG_PMUSERENR_EL0 = 0xDCF0, + ARM64_SYSREG_PMINTENSET_EL1 = 0xC4F1, + ARM64_SYSREG_PMINTENCLR_EL1 = 0xC4F2, + ARM64_SYSREG_PMOVSSET_EL0 = 0xDCF3, + ARM64_SYSREG_MAIR_EL1 = 0xC510, + ARM64_SYSREG_MAIR_EL2 = 0xE510, + ARM64_SYSREG_MAIR_EL3 = 0xF510, + ARM64_SYSREG_AMAIR_EL1 = 0xC518, + ARM64_SYSREG_AMAIR_EL2 = 0xE518, + ARM64_SYSREG_AMAIR_EL3 = 0xF518, + ARM64_SYSREG_VBAR_EL1 = 0xC600, + ARM64_SYSREG_VBAR_EL2 = 0xE600, + ARM64_SYSREG_VBAR_EL3 = 0xF600, + ARM64_SYSREG_RMR_EL1 = 0xC602, + ARM64_SYSREG_RMR_EL2 = 0xE602, + ARM64_SYSREG_RMR_EL3 = 0xF602, + ARM64_SYSREG_CONTEXTIDR_EL1 = 0xC681, + ARM64_SYSREG_TPIDR_EL0 = 0xDE82, + ARM64_SYSREG_TPIDR_EL2 = 0xE682, + ARM64_SYSREG_TPIDR_EL3 = 0xF682, + ARM64_SYSREG_TPIDRRO_EL0 = 0xDE83, + ARM64_SYSREG_TPIDR_EL1 = 0xC684, + ARM64_SYSREG_CNTFRQ_EL0 = 0xDF00, + ARM64_SYSREG_CNTVOFF_EL2 = 0xE703, + ARM64_SYSREG_CNTKCTL_EL1 = 0xC708, + ARM64_SYSREG_CNTHCTL_EL2 = 0xE708, + ARM64_SYSREG_CNTP_TVAL_EL0 = 0xDF10, + ARM64_SYSREG_CNTHP_TVAL_EL2 = 0xE710, + ARM64_SYSREG_CNTPS_TVAL_EL1 = 0xFF10, + ARM64_SYSREG_CNTP_CTL_EL0 = 0xDF11, + ARM64_SYSREG_CNTHP_CTL_EL2 = 0xE711, + ARM64_SYSREG_CNTPS_CTL_EL1 = 0xFF11, + ARM64_SYSREG_CNTP_CVAL_EL0 = 0xDF12, + ARM64_SYSREG_CNTHP_CVAL_EL2 = 0xE712, + ARM64_SYSREG_CNTPS_CVAL_EL1 = 0xFF12, + ARM64_SYSREG_CNTV_TVAL_EL0 = 0xDF18, + ARM64_SYSREG_CNTV_CTL_EL0 = 0xDF19, + ARM64_SYSREG_CNTV_CVAL_EL0 = 0xDF1A, + ARM64_SYSREG_PMEVCNTR0_EL0 = 0xDF40, + ARM64_SYSREG_PMEVCNTR1_EL0 = 0xDF41, + ARM64_SYSREG_PMEVCNTR2_EL0 = 0xDF42, + ARM64_SYSREG_PMEVCNTR3_EL0 = 0xDF43, + ARM64_SYSREG_PMEVCNTR4_EL0 = 0xDF44, + ARM64_SYSREG_PMEVCNTR5_EL0 = 0xDF45, + ARM64_SYSREG_PMEVCNTR6_EL0 = 0xDF46, + ARM64_SYSREG_PMEVCNTR7_EL0 = 0xDF47, + ARM64_SYSREG_PMEVCNTR8_EL0 = 0xDF48, + ARM64_SYSREG_PMEVCNTR9_EL0 = 0xDF49, + ARM64_SYSREG_PMEVCNTR10_EL0 = 0xDF4A, + ARM64_SYSREG_PMEVCNTR11_EL0 = 0xDF4B, + ARM64_SYSREG_PMEVCNTR12_EL0 = 0xDF4C, + ARM64_SYSREG_PMEVCNTR13_EL0 = 0xDF4D, + ARM64_SYSREG_PMEVCNTR14_EL0 = 0xDF4E, + ARM64_SYSREG_PMEVCNTR15_EL0 = 0xDF4F, + ARM64_SYSREG_PMEVCNTR16_EL0 = 0xDF50, + ARM64_SYSREG_PMEVCNTR17_EL0 = 0xDF51, + ARM64_SYSREG_PMEVCNTR18_EL0 = 0xDF52, + ARM64_SYSREG_PMEVCNTR19_EL0 = 0xDF53, + ARM64_SYSREG_PMEVCNTR20_EL0 = 0xDF54, + ARM64_SYSREG_PMEVCNTR21_EL0 = 0xDF55, + ARM64_SYSREG_PMEVCNTR22_EL0 = 0xDF56, + ARM64_SYSREG_PMEVCNTR23_EL0 = 0xDF57, + ARM64_SYSREG_PMEVCNTR24_EL0 = 0xDF58, + ARM64_SYSREG_PMEVCNTR25_EL0 = 0xDF59, + ARM64_SYSREG_PMEVCNTR26_EL0 = 0xDF5A, + ARM64_SYSREG_PMEVCNTR27_EL0 = 0xDF5B, + ARM64_SYSREG_PMEVCNTR28_EL0 = 0xDF5C, + ARM64_SYSREG_PMEVCNTR29_EL0 = 0xDF5D, + ARM64_SYSREG_PMEVCNTR30_EL0 = 0xDF5E, + ARM64_SYSREG_PMCCFILTR_EL0 = 0xDF7F, + ARM64_SYSREG_PMEVTYPER0_EL0 = 0xDF60, + ARM64_SYSREG_PMEVTYPER1_EL0 = 0xDF61, + ARM64_SYSREG_PMEVTYPER2_EL0 = 0xDF62, + ARM64_SYSREG_PMEVTYPER3_EL0 = 0xDF63, + ARM64_SYSREG_PMEVTYPER4_EL0 = 0xDF64, + ARM64_SYSREG_PMEVTYPER5_EL0 = 0xDF65, + ARM64_SYSREG_PMEVTYPER6_EL0 = 0xDF66, + ARM64_SYSREG_PMEVTYPER7_EL0 = 0xDF67, + ARM64_SYSREG_PMEVTYPER8_EL0 = 0xDF68, + ARM64_SYSREG_PMEVTYPER9_EL0 = 0xDF69, + ARM64_SYSREG_PMEVTYPER10_EL0 = 0xDF6A, + ARM64_SYSREG_PMEVTYPER11_EL0 = 0xDF6B, + ARM64_SYSREG_PMEVTYPER12_EL0 = 0xDF6C, + ARM64_SYSREG_PMEVTYPER13_EL0 = 0xDF6D, + ARM64_SYSREG_PMEVTYPER14_EL0 = 0xDF6E, + ARM64_SYSREG_PMEVTYPER15_EL0 = 0xDF6F, + ARM64_SYSREG_PMEVTYPER16_EL0 = 0xDF70, + ARM64_SYSREG_PMEVTYPER17_EL0 = 0xDF71, + ARM64_SYSREG_PMEVTYPER18_EL0 = 0xDF72, + ARM64_SYSREG_PMEVTYPER19_EL0 = 0xDF73, + ARM64_SYSREG_PMEVTYPER20_EL0 = 0xDF74, + ARM64_SYSREG_PMEVTYPER21_EL0 = 0xDF75, + ARM64_SYSREG_PMEVTYPER22_EL0 = 0xDF76, + ARM64_SYSREG_PMEVTYPER23_EL0 = 0xDF77, + ARM64_SYSREG_PMEVTYPER24_EL0 = 0xDF78, + ARM64_SYSREG_PMEVTYPER25_EL0 = 0xDF79, + ARM64_SYSREG_PMEVTYPER26_EL0 = 0xDF7A, + ARM64_SYSREG_PMEVTYPER27_EL0 = 0xDF7B, + ARM64_SYSREG_PMEVTYPER28_EL0 = 0xDF7C, + ARM64_SYSREG_PMEVTYPER29_EL0 = 0xDF7D, + ARM64_SYSREG_PMEVTYPER30_EL0 = 0xDF7E, + ARM64_SYSREG_TRCPRGCTLR = 0x8808, + ARM64_SYSREG_TRCPROCSELR = 0x8810, + ARM64_SYSREG_TRCCONFIGR = 0x8820, + ARM64_SYSREG_TRCAUXCTLR = 0x8830, + ARM64_SYSREG_TRCEVENTCTL0R = 0x8840, + ARM64_SYSREG_TRCEVENTCTL1R = 0x8848, + ARM64_SYSREG_TRCSTALLCTLR = 0x8858, + ARM64_SYSREG_TRCTSCTLR = 0x8860, + ARM64_SYSREG_TRCSYNCPR = 0x8868, + ARM64_SYSREG_TRCCCCTLR = 0x8870, + ARM64_SYSREG_TRCBBCTLR = 0x8878, + ARM64_SYSREG_TRCTRACEIDR = 0x8801, + ARM64_SYSREG_TRCQCTLR = 0x8809, + ARM64_SYSREG_TRCVICTLR = 0x8802, + ARM64_SYSREG_TRCVIIECTLR = 0x880A, + ARM64_SYSREG_TRCVISSCTLR = 0x8812, + ARM64_SYSREG_TRCVIPCSSCTLR = 0x881A, + ARM64_SYSREG_TRCVDCTLR = 0x8842, + ARM64_SYSREG_TRCVDSACCTLR = 0x884A, + ARM64_SYSREG_TRCVDARCCTLR = 0x8852, + ARM64_SYSREG_TRCSEQEVR0 = 0x8804, + ARM64_SYSREG_TRCSEQEVR1 = 0x880C, + ARM64_SYSREG_TRCSEQEVR2 = 0x8814, + ARM64_SYSREG_TRCSEQRSTEVR = 0x8834, + ARM64_SYSREG_TRCSEQSTR = 0x883C, + ARM64_SYSREG_TRCEXTINSELR = 0x8844, + ARM64_SYSREG_TRCCNTRLDVR0 = 0x8805, + ARM64_SYSREG_TRCCNTRLDVR1 = 0x880D, + ARM64_SYSREG_TRCCNTRLDVR2 = 0x8815, + ARM64_SYSREG_TRCCNTRLDVR3 = 0x881D, + ARM64_SYSREG_TRCCNTCTLR0 = 0x8825, + ARM64_SYSREG_TRCCNTCTLR1 = 0x882D, + ARM64_SYSREG_TRCCNTCTLR2 = 0x8835, + ARM64_SYSREG_TRCCNTCTLR3 = 0x883D, + ARM64_SYSREG_TRCCNTVR0 = 0x8845, + ARM64_SYSREG_TRCCNTVR1 = 0x884D, + ARM64_SYSREG_TRCCNTVR2 = 0x8855, + ARM64_SYSREG_TRCCNTVR3 = 0x885D, + ARM64_SYSREG_TRCIMSPEC0 = 0x8807, + ARM64_SYSREG_TRCIMSPEC1 = 0x880F, + ARM64_SYSREG_TRCIMSPEC2 = 0x8817, + ARM64_SYSREG_TRCIMSPEC3 = 0x881F, + ARM64_SYSREG_TRCIMSPEC4 = 0x8827, + ARM64_SYSREG_TRCIMSPEC5 = 0x882F, + ARM64_SYSREG_TRCIMSPEC6 = 0x8837, + ARM64_SYSREG_TRCIMSPEC7 = 0x883F, + ARM64_SYSREG_TRCRSCTLR2 = 0x8890, + ARM64_SYSREG_TRCRSCTLR3 = 0x8898, + ARM64_SYSREG_TRCRSCTLR4 = 0x88A0, + ARM64_SYSREG_TRCRSCTLR5 = 0x88A8, + ARM64_SYSREG_TRCRSCTLR6 = 0x88B0, + ARM64_SYSREG_TRCRSCTLR7 = 0x88B8, + ARM64_SYSREG_TRCRSCTLR8 = 0x88C0, + ARM64_SYSREG_TRCRSCTLR9 = 0x88C8, + ARM64_SYSREG_TRCRSCTLR10 = 0x88D0, + ARM64_SYSREG_TRCRSCTLR11 = 0x88D8, + ARM64_SYSREG_TRCRSCTLR12 = 0x88E0, + ARM64_SYSREG_TRCRSCTLR13 = 0x88E8, + ARM64_SYSREG_TRCRSCTLR14 = 0x88F0, + ARM64_SYSREG_TRCRSCTLR15 = 0x88F8, + ARM64_SYSREG_TRCRSCTLR16 = 0x8881, + ARM64_SYSREG_TRCRSCTLR17 = 0x8889, + ARM64_SYSREG_TRCRSCTLR18 = 0x8891, + ARM64_SYSREG_TRCRSCTLR19 = 0x8899, + ARM64_SYSREG_TRCRSCTLR20 = 0x88A1, + ARM64_SYSREG_TRCRSCTLR21 = 0x88A9, + ARM64_SYSREG_TRCRSCTLR22 = 0x88B1, + ARM64_SYSREG_TRCRSCTLR23 = 0x88B9, + ARM64_SYSREG_TRCRSCTLR24 = 0x88C1, + ARM64_SYSREG_TRCRSCTLR25 = 0x88C9, + ARM64_SYSREG_TRCRSCTLR26 = 0x88D1, + ARM64_SYSREG_TRCRSCTLR27 = 0x88D9, + ARM64_SYSREG_TRCRSCTLR28 = 0x88E1, + ARM64_SYSREG_TRCRSCTLR29 = 0x88E9, + ARM64_SYSREG_TRCRSCTLR30 = 0x88F1, + ARM64_SYSREG_TRCRSCTLR31 = 0x88F9, + ARM64_SYSREG_TRCSSCCR0 = 0x8882, + ARM64_SYSREG_TRCSSCCR1 = 0x888A, + ARM64_SYSREG_TRCSSCCR2 = 0x8892, + ARM64_SYSREG_TRCSSCCR3 = 0x889A, + ARM64_SYSREG_TRCSSCCR4 = 0x88A2, + ARM64_SYSREG_TRCSSCCR5 = 0x88AA, + ARM64_SYSREG_TRCSSCCR6 = 0x88B2, + ARM64_SYSREG_TRCSSCCR7 = 0x88BA, + ARM64_SYSREG_TRCSSCSR0 = 0x88C2, + ARM64_SYSREG_TRCSSCSR1 = 0x88CA, + ARM64_SYSREG_TRCSSCSR2 = 0x88D2, + ARM64_SYSREG_TRCSSCSR3 = 0x88DA, + ARM64_SYSREG_TRCSSCSR4 = 0x88E2, + ARM64_SYSREG_TRCSSCSR5 = 0x88EA, + ARM64_SYSREG_TRCSSCSR6 = 0x88F2, + ARM64_SYSREG_TRCSSCSR7 = 0x88FA, + ARM64_SYSREG_TRCSSPCICR0 = 0x8883, + ARM64_SYSREG_TRCSSPCICR1 = 0x888B, + ARM64_SYSREG_TRCSSPCICR2 = 0x8893, + ARM64_SYSREG_TRCSSPCICR3 = 0x889B, + ARM64_SYSREG_TRCSSPCICR4 = 0x88A3, + ARM64_SYSREG_TRCSSPCICR5 = 0x88AB, + ARM64_SYSREG_TRCSSPCICR6 = 0x88B3, + ARM64_SYSREG_TRCSSPCICR7 = 0x88BB, + ARM64_SYSREG_TRCPDCR = 0x88A4, + ARM64_SYSREG_TRCACVR0 = 0x8900, + ARM64_SYSREG_TRCACVR1 = 0x8910, + ARM64_SYSREG_TRCACVR2 = 0x8920, + ARM64_SYSREG_TRCACVR3 = 0x8930, + ARM64_SYSREG_TRCACVR4 = 0x8940, + ARM64_SYSREG_TRCACVR5 = 0x8950, + ARM64_SYSREG_TRCACVR6 = 0x8960, + ARM64_SYSREG_TRCACVR7 = 0x8970, + ARM64_SYSREG_TRCACVR8 = 0x8901, + ARM64_SYSREG_TRCACVR9 = 0x8911, + ARM64_SYSREG_TRCACVR10 = 0x8921, + ARM64_SYSREG_TRCACVR11 = 0x8931, + ARM64_SYSREG_TRCACVR12 = 0x8941, + ARM64_SYSREG_TRCACVR13 = 0x8951, + ARM64_SYSREG_TRCACVR14 = 0x8961, + ARM64_SYSREG_TRCACVR15 = 0x8971, + ARM64_SYSREG_TRCACATR0 = 0x8902, + ARM64_SYSREG_TRCACATR1 = 0x8912, + ARM64_SYSREG_TRCACATR2 = 0x8922, + ARM64_SYSREG_TRCACATR3 = 0x8932, + ARM64_SYSREG_TRCACATR4 = 0x8942, + ARM64_SYSREG_TRCACATR5 = 0x8952, + ARM64_SYSREG_TRCACATR6 = 0x8962, + ARM64_SYSREG_TRCACATR7 = 0x8972, + ARM64_SYSREG_TRCACATR8 = 0x8903, + ARM64_SYSREG_TRCACATR9 = 0x8913, + ARM64_SYSREG_TRCACATR10 = 0x8923, + ARM64_SYSREG_TRCACATR11 = 0x8933, + ARM64_SYSREG_TRCACATR12 = 0x8943, + ARM64_SYSREG_TRCACATR13 = 0x8953, + ARM64_SYSREG_TRCACATR14 = 0x8963, + ARM64_SYSREG_TRCACATR15 = 0x8973, + ARM64_SYSREG_TRCDVCVR0 = 0x8904, + ARM64_SYSREG_TRCDVCVR1 = 0x8924, + ARM64_SYSREG_TRCDVCVR2 = 0x8944, + ARM64_SYSREG_TRCDVCVR3 = 0x8964, + ARM64_SYSREG_TRCDVCVR4 = 0x8905, + ARM64_SYSREG_TRCDVCVR5 = 0x8925, + ARM64_SYSREG_TRCDVCVR6 = 0x8945, + ARM64_SYSREG_TRCDVCVR7 = 0x8965, + ARM64_SYSREG_TRCDVCMR0 = 0x8906, + ARM64_SYSREG_TRCDVCMR1 = 0x8926, + ARM64_SYSREG_TRCDVCMR2 = 0x8946, + ARM64_SYSREG_TRCDVCMR3 = 0x8966, + ARM64_SYSREG_TRCDVCMR4 = 0x8907, + ARM64_SYSREG_TRCDVCMR5 = 0x8927, + ARM64_SYSREG_TRCDVCMR6 = 0x8947, + ARM64_SYSREG_TRCDVCMR7 = 0x8967, + ARM64_SYSREG_TRCCIDCVR0 = 0x8980, + ARM64_SYSREG_TRCCIDCVR1 = 0x8990, + ARM64_SYSREG_TRCCIDCVR2 = 0x89A0, + ARM64_SYSREG_TRCCIDCVR3 = 0x89B0, + ARM64_SYSREG_TRCCIDCVR4 = 0x89C0, + ARM64_SYSREG_TRCCIDCVR5 = 0x89D0, + ARM64_SYSREG_TRCCIDCVR6 = 0x89E0, + ARM64_SYSREG_TRCCIDCVR7 = 0x89F0, + ARM64_SYSREG_TRCVMIDCVR0 = 0x8981, + ARM64_SYSREG_TRCVMIDCVR1 = 0x8991, + ARM64_SYSREG_TRCVMIDCVR2 = 0x89A1, + ARM64_SYSREG_TRCVMIDCVR3 = 0x89B1, + ARM64_SYSREG_TRCVMIDCVR4 = 0x89C1, + ARM64_SYSREG_TRCVMIDCVR5 = 0x89D1, + ARM64_SYSREG_TRCVMIDCVR6 = 0x89E1, + ARM64_SYSREG_TRCVMIDCVR7 = 0x89F1, + ARM64_SYSREG_TRCCIDCCTLR0 = 0x8982, + ARM64_SYSREG_TRCCIDCCTLR1 = 0x898A, + ARM64_SYSREG_TRCVMIDCCTLR0 = 0x8992, + ARM64_SYSREG_TRCVMIDCCTLR1 = 0x899A, + ARM64_SYSREG_TRCITCTRL = 0x8B84, + ARM64_SYSREG_TRCCLAIMSET = 0x8BC6, + ARM64_SYSREG_TRCCLAIMCLR = 0x8BCE, + ARM64_SYSREG_ICC_BPR1_EL1 = 0xC663, + ARM64_SYSREG_ICC_BPR0_EL1 = 0xC643, + ARM64_SYSREG_ICC_PMR_EL1 = 0xC230, + ARM64_SYSREG_ICC_CTLR_EL1 = 0xC664, + ARM64_SYSREG_ICC_CTLR_EL3 = 0xF664, + ARM64_SYSREG_ICC_SRE_EL1 = 0xC665, + ARM64_SYSREG_ICC_SRE_EL2 = 0xE64D, + ARM64_SYSREG_ICC_SRE_EL3 = 0xF665, + ARM64_SYSREG_ICC_IGRPEN0_EL1 = 0xC666, + ARM64_SYSREG_ICC_IGRPEN1_EL1 = 0xC667, + ARM64_SYSREG_ICC_IGRPEN1_EL3 = 0xF667, + ARM64_SYSREG_ICC_SEIEN_EL1 = 0xC668, + ARM64_SYSREG_ICC_AP0R0_EL1 = 0xC644, + ARM64_SYSREG_ICC_AP0R1_EL1 = 0xC645, + ARM64_SYSREG_ICC_AP0R2_EL1 = 0xC646, + ARM64_SYSREG_ICC_AP0R3_EL1 = 0xC647, + ARM64_SYSREG_ICC_AP1R0_EL1 = 0xC648, + ARM64_SYSREG_ICC_AP1R1_EL1 = 0xC649, + ARM64_SYSREG_ICC_AP1R2_EL1 = 0xC64A, + ARM64_SYSREG_ICC_AP1R3_EL1 = 0xC64B, + ARM64_SYSREG_ICH_AP0R0_EL2 = 0xE640, + ARM64_SYSREG_ICH_AP0R1_EL2 = 0xE641, + ARM64_SYSREG_ICH_AP0R2_EL2 = 0xE642, + ARM64_SYSREG_ICH_AP0R3_EL2 = 0xE643, + ARM64_SYSREG_ICH_AP1R0_EL2 = 0xE648, + ARM64_SYSREG_ICH_AP1R1_EL2 = 0xE649, + ARM64_SYSREG_ICH_AP1R2_EL2 = 0xE64A, + ARM64_SYSREG_ICH_AP1R3_EL2 = 0xE64B, + ARM64_SYSREG_ICH_HCR_EL2 = 0xE658, + ARM64_SYSREG_ICH_MISR_EL2 = 0xE65A, + ARM64_SYSREG_ICH_VMCR_EL2 = 0xE65F, + ARM64_SYSREG_ICH_VSEIR_EL2 = 0xE64C, + ARM64_SYSREG_ICH_LR0_EL2 = 0xE660, + ARM64_SYSREG_ICH_LR1_EL2 = 0xE661, + ARM64_SYSREG_ICH_LR2_EL2 = 0xE662, + ARM64_SYSREG_ICH_LR3_EL2 = 0xE663, + ARM64_SYSREG_ICH_LR4_EL2 = 0xE664, + ARM64_SYSREG_ICH_LR5_EL2 = 0xE665, + ARM64_SYSREG_ICH_LR6_EL2 = 0xE666, + ARM64_SYSREG_ICH_LR7_EL2 = 0xE667, + ARM64_SYSREG_ICH_LR8_EL2 = 0xE668, + ARM64_SYSREG_ICH_LR9_EL2 = 0xE669, + ARM64_SYSREG_ICH_LR10_EL2 = 0xE66A, + ARM64_SYSREG_ICH_LR11_EL2 = 0xE66B, + ARM64_SYSREG_ICH_LR12_EL2 = 0xE66C, + ARM64_SYSREG_ICH_LR13_EL2 = 0xE66D, + ARM64_SYSREG_ICH_LR14_EL2 = 0xE66E, + ARM64_SYSREG_ICH_LR15_EL2 = 0xE66F, + ARM64_SYSREG_PAN = 0xC213, + ARM64_SYSREG_LORSA_EL1 = 0xC520, + ARM64_SYSREG_LOREA_EL1 = 0xC521, + ARM64_SYSREG_LORN_EL1 = 0xC522, + ARM64_SYSREG_LORC_EL1 = 0xC523, + ARM64_SYSREG_TTBR1_EL2 = 0xE101, + ARM64_SYSREG_CONTEXTIDR_EL2 = 0xE681, + ARM64_SYSREG_CNTHV_TVAL_EL2 = 0xE718, + ARM64_SYSREG_CNTHV_CVAL_EL2 = 0xE71A, + ARM64_SYSREG_CNTHV_CTL_EL2 = 0xE719, + ARM64_SYSREG_SCTLR_EL12 = 0xE880, + ARM64_SYSREG_CPACR_EL12 = 0xE882, + ARM64_SYSREG_TTBR0_EL12 = 0xE900, + ARM64_SYSREG_TTBR1_EL12 = 0xE901, + ARM64_SYSREG_TCR_EL12 = 0xE902, + ARM64_SYSREG_AFSR0_EL12 = 0xEA88, + ARM64_SYSREG_AFSR1_EL12 = 0xEA89, + ARM64_SYSREG_ESR_EL12 = 0xEA90, + ARM64_SYSREG_FAR_EL12 = 0xEB00, + ARM64_SYSREG_MAIR_EL12 = 0xED10, + ARM64_SYSREG_AMAIR_EL12 = 0xED18, + ARM64_SYSREG_VBAR_EL12 = 0xEE00, + ARM64_SYSREG_CONTEXTIDR_EL12 = 0xEE81, + ARM64_SYSREG_CNTKCTL_EL12 = 0xEF08, + ARM64_SYSREG_CNTP_TVAL_EL02 = 0xEF10, + ARM64_SYSREG_CNTP_CTL_EL02 = 0xEF11, + ARM64_SYSREG_CNTP_CVAL_EL02 = 0xEF12, + ARM64_SYSREG_CNTV_TVAL_EL02 = 0xEF18, + ARM64_SYSREG_CNTV_CTL_EL02 = 0xEF19, + ARM64_SYSREG_CNTV_CVAL_EL02 = 0xEF1A, + ARM64_SYSREG_SPSR_EL12 = 0xEA00, + ARM64_SYSREG_ELR_EL12 = 0xEA01, + ARM64_SYSREG_UAO = 0xC214, + ARM64_SYSREG_PMBLIMITR_EL1 = 0xC4D0, + ARM64_SYSREG_PMBPTR_EL1 = 0xC4D1, + ARM64_SYSREG_PMBSR_EL1 = 0xC4D3, + ARM64_SYSREG_PMBIDR_EL1 = 0xC4D7, + ARM64_SYSREG_PMSCR_EL2 = 0xE4C8, + ARM64_SYSREG_PMSCR_EL12 = 0xECC8, + ARM64_SYSREG_PMSCR_EL1 = 0xC4C8, + ARM64_SYSREG_PMSICR_EL1 = 0xC4CA, + ARM64_SYSREG_PMSIRR_EL1 = 0xC4CB, + ARM64_SYSREG_PMSFCR_EL1 = 0xC4CC, + ARM64_SYSREG_PMSEVFR_EL1 = 0xC4CD, + ARM64_SYSREG_PMSLATFR_EL1 = 0xC4CE, + ARM64_SYSREG_PMSIDR_EL1 = 0xC4CF, + ARM64_SYSREG_ERRSELR_EL1 = 0xC299, + ARM64_SYSREG_ERXCTLR_EL1 = 0xC2A1, + ARM64_SYSREG_ERXSTATUS_EL1 = 0xC2A2, + ARM64_SYSREG_ERXADDR_EL1 = 0xC2A3, + ARM64_SYSREG_ERXMISC0_EL1 = 0xC2A8, + ARM64_SYSREG_ERXMISC1_EL1 = 0xC2A9, + ARM64_SYSREG_DISR_EL1 = 0xC609, + ARM64_SYSREG_VDISR_EL2 = 0xE609, + ARM64_SYSREG_VSESR_EL2 = 0xE293, + ARM64_SYSREG_APIAKEYLO_EL1 = 0xC108, + ARM64_SYSREG_APIAKEYHI_EL1 = 0xC109, + ARM64_SYSREG_APIBKEYLO_EL1 = 0xC10A, + ARM64_SYSREG_APIBKEYHI_EL1 = 0xC10B, + ARM64_SYSREG_APDAKEYLO_EL1 = 0xC110, + ARM64_SYSREG_APDAKEYHI_EL1 = 0xC111, + ARM64_SYSREG_APDBKEYLO_EL1 = 0xC112, + ARM64_SYSREG_APDBKEYHI_EL1 = 0xC113, + ARM64_SYSREG_APGAKEYLO_EL1 = 0xC118, + ARM64_SYSREG_APGAKEYHI_EL1 = 0xC119, + ARM64_SYSREG_VSTCR_EL2 = 0xE132, + ARM64_SYSREG_VSTTBR_EL2 = 0xE130, + ARM64_SYSREG_CNTHVS_TVAL_EL2 = 0xE720, + ARM64_SYSREG_CNTHVS_CVAL_EL2 = 0xE722, + ARM64_SYSREG_CNTHVS_CTL_EL2 = 0xE721, + ARM64_SYSREG_CNTHPS_TVAL_EL2 = 0xE728, + ARM64_SYSREG_CNTHPS_CVAL_EL2 = 0xE72A, + ARM64_SYSREG_CNTHPS_CTL_EL2 = 0xE729, + ARM64_SYSREG_SDER32_EL2 = 0xE099, + ARM64_SYSREG_ERXPFGCTL_EL1 = 0xC2A5, + ARM64_SYSREG_ERXPFGCDN_EL1 = 0xC2A6, + ARM64_SYSREG_ERXTS_EL1 = 0xC2AF, + ARM64_SYSREG_ERXMISC2_EL1 = 0xC2AA, + ARM64_SYSREG_ERXMISC3_EL1 = 0xC2AB, + ARM64_SYSREG_ERXPFGF_EL1 = 0xC2A4, + ARM64_SYSREG_MPAM0_EL1 = 0xC529, + ARM64_SYSREG_MPAM1_EL1 = 0xC528, + ARM64_SYSREG_MPAM2_EL2 = 0xE528, + ARM64_SYSREG_MPAM3_EL3 = 0xF528, + ARM64_SYSREG_MPAM1_EL12 = 0xED28, + ARM64_SYSREG_MPAMHCR_EL2 = 0xE520, + ARM64_SYSREG_MPAMVPMV_EL2 = 0xE521, + ARM64_SYSREG_MPAMVPM0_EL2 = 0xE530, + ARM64_SYSREG_MPAMVPM1_EL2 = 0xE531, + ARM64_SYSREG_MPAMVPM2_EL2 = 0xE532, + ARM64_SYSREG_MPAMVPM3_EL2 = 0xE533, + ARM64_SYSREG_MPAMVPM4_EL2 = 0xE534, + ARM64_SYSREG_MPAMVPM5_EL2 = 0xE535, + ARM64_SYSREG_MPAMVPM6_EL2 = 0xE536, + ARM64_SYSREG_MPAMVPM7_EL2 = 0xE537, + ARM64_SYSREG_MPAMIDR_EL1 = 0xC524, + ARM64_SYSREG_AMCR_EL0 = 0xDE90, + ARM64_SYSREG_AMCFGR_EL0 = 0xDE91, + ARM64_SYSREG_AMCGCR_EL0 = 0xDE92, + ARM64_SYSREG_AMUSERENR_EL0 = 0xDE93, + ARM64_SYSREG_AMCNTENCLR0_EL0 = 0xDE94, + ARM64_SYSREG_AMCNTENSET0_EL0 = 0xDE95, + ARM64_SYSREG_AMEVCNTR00_EL0 = 0xDEA0, + ARM64_SYSREG_AMEVCNTR01_EL0 = 0xDEA1, + ARM64_SYSREG_AMEVCNTR02_EL0 = 0xDEA2, + ARM64_SYSREG_AMEVCNTR03_EL0 = 0xDEA3, + ARM64_SYSREG_AMEVTYPER00_EL0 = 0xDEB0, + ARM64_SYSREG_AMEVTYPER01_EL0 = 0xDEB1, + ARM64_SYSREG_AMEVTYPER02_EL0 = 0xDEB2, + ARM64_SYSREG_AMEVTYPER03_EL0 = 0xDEB3, + ARM64_SYSREG_AMCNTENCLR1_EL0 = 0xDE98, + ARM64_SYSREG_AMCNTENSET1_EL0 = 0xDE99, + ARM64_SYSREG_AMEVCNTR10_EL0 = 0xDEE0, + ARM64_SYSREG_AMEVCNTR11_EL0 = 0xDEE1, + ARM64_SYSREG_AMEVCNTR12_EL0 = 0xDEE2, + ARM64_SYSREG_AMEVCNTR13_EL0 = 0xDEE3, + ARM64_SYSREG_AMEVCNTR14_EL0 = 0xDEE4, + ARM64_SYSREG_AMEVCNTR15_EL0 = 0xDEE5, + ARM64_SYSREG_AMEVCNTR16_EL0 = 0xDEE6, + ARM64_SYSREG_AMEVCNTR17_EL0 = 0xDEE7, + ARM64_SYSREG_AMEVCNTR18_EL0 = 0xDEE8, + ARM64_SYSREG_AMEVCNTR19_EL0 = 0xDEE9, + ARM64_SYSREG_AMEVCNTR110_EL0 = 0xDEEA, + ARM64_SYSREG_AMEVCNTR111_EL0 = 0xDEEB, + ARM64_SYSREG_AMEVCNTR112_EL0 = 0xDEEC, + ARM64_SYSREG_AMEVCNTR113_EL0 = 0xDEED, + ARM64_SYSREG_AMEVCNTR114_EL0 = 0xDEEE, + ARM64_SYSREG_AMEVCNTR115_EL0 = 0xDEEF, + ARM64_SYSREG_AMEVTYPER10_EL0 = 0xDEF0, + ARM64_SYSREG_AMEVTYPER11_EL0 = 0xDEF1, + ARM64_SYSREG_AMEVTYPER12_EL0 = 0xDEF2, + ARM64_SYSREG_AMEVTYPER13_EL0 = 0xDEF3, + ARM64_SYSREG_AMEVTYPER14_EL0 = 0xDEF4, + ARM64_SYSREG_AMEVTYPER15_EL0 = 0xDEF5, + ARM64_SYSREG_AMEVTYPER16_EL0 = 0xDEF6, + ARM64_SYSREG_AMEVTYPER17_EL0 = 0xDEF7, + ARM64_SYSREG_AMEVTYPER18_EL0 = 0xDEF8, + ARM64_SYSREG_AMEVTYPER19_EL0 = 0xDEF9, + ARM64_SYSREG_AMEVTYPER110_EL0 = 0xDEFA, + ARM64_SYSREG_AMEVTYPER111_EL0 = 0xDEFB, + ARM64_SYSREG_AMEVTYPER112_EL0 = 0xDEFC, + ARM64_SYSREG_AMEVTYPER113_EL0 = 0xDEFD, + ARM64_SYSREG_AMEVTYPER114_EL0 = 0xDEFE, + ARM64_SYSREG_AMEVTYPER115_EL0 = 0xDEFF, + ARM64_SYSREG_TRFCR_EL1 = 0xC091, + ARM64_SYSREG_TRFCR_EL2 = 0xE091, + ARM64_SYSREG_TRFCR_EL12 = 0xE891, + ARM64_SYSREG_DIT = 0xDA15, + ARM64_SYSREG_VNCR_EL2 = 0xE110, + ARM64_SYSREG_ZCR_EL1 = 0xC090, + ARM64_SYSREG_ZCR_EL2 = 0xE090, + ARM64_SYSREG_ZCR_EL3 = 0xF090, + ARM64_SYSREG_ZCR_EL12 = 0xE890, + ARM64_SYSREG_CPM_IOACC_CTL_EL3 = 0xFF90, +} arm64_sysreg; + +/// System PState Field (MSR instruction) +typedef enum arm64_pstate { + ARM64_PSTATE_INVALID = 0, + ARM64_PSTATE_SPSEL = 0x05, + ARM64_PSTATE_DAIFSET = 0x1e, + ARM64_PSTATE_DAIFCLR = 0x1f, + ARM64_PSTATE_PAN = 0x4, + ARM64_PSTATE_UAO = 0x3, + ARM64_PSTATE_DIT = 0x1a, +} arm64_pstate; + +/// Vector arrangement specifier (for FloatingPoint/Advanced SIMD insn) +typedef enum arm64_vas { + ARM64_VAS_INVALID = 0, + ARM64_VAS_16B, + ARM64_VAS_8B, + ARM64_VAS_4B, + ARM64_VAS_1B, + ARM64_VAS_8H, + ARM64_VAS_4H, + ARM64_VAS_2H, + ARM64_VAS_1H, + ARM64_VAS_4S, + ARM64_VAS_2S, + ARM64_VAS_1S, + ARM64_VAS_2D, + ARM64_VAS_1D, + ARM64_VAS_1Q, +} arm64_vas; + +/// Memory barrier operands +typedef enum arm64_barrier_op { + ARM64_BARRIER_INVALID = 0, + ARM64_BARRIER_OSHLD = 0x1, + ARM64_BARRIER_OSHST = 0x2, + ARM64_BARRIER_OSH = 0x3, + ARM64_BARRIER_NSHLD = 0x5, + ARM64_BARRIER_NSHST = 0x6, + ARM64_BARRIER_NSH = 0x7, + ARM64_BARRIER_ISHLD = 0x9, + ARM64_BARRIER_ISHST = 0xa, + ARM64_BARRIER_ISH = 0xb, + ARM64_BARRIER_LD = 0xd, + ARM64_BARRIER_ST = 0xe, + ARM64_BARRIER_SY = 0xf +} arm64_barrier_op; + +/// Operand type for instruction's operands +typedef enum arm64_op_type { + ARM64_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + ARM64_OP_REG, ///< = CS_OP_REG (Register operand). + ARM64_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + ARM64_OP_MEM, ///< = CS_OP_MEM (Memory operand). + ARM64_OP_FP, ///< = CS_OP_FP (Floating-Point operand). + ARM64_OP_CIMM = 64, ///< C-Immediate + ARM64_OP_REG_MRS, ///< MRS register operand. + ARM64_OP_REG_MSR, ///< MSR register operand. + ARM64_OP_PSTATE, ///< PState operand. + ARM64_OP_SYS, ///< SYS operand for IC/DC/AT/TLBI instructions. + ARM64_OP_PREFETCH, ///< Prefetch operand (PRFM). + ARM64_OP_BARRIER, ///< Memory barrier operand (ISB/DMB/DSB instructions). +} arm64_op_type; + +/// TLBI operations +typedef enum arm64_tlbi_op { + ARM64_TLBI_INVALID = 0, + + ARM64_TLBI_IPAS2E1IS, + ARM64_TLBI_IPAS2LE1IS, + ARM64_TLBI_VMALLE1IS, + ARM64_TLBI_ALLE2IS, + ARM64_TLBI_ALLE3IS, + ARM64_TLBI_VAE1IS, + ARM64_TLBI_VAE2IS, + ARM64_TLBI_VAE3IS, + ARM64_TLBI_ASIDE1IS, + ARM64_TLBI_VAAE1IS, + ARM64_TLBI_ALLE1IS, + ARM64_TLBI_VALE1IS, + ARM64_TLBI_VALE2IS, + ARM64_TLBI_VALE3IS, + ARM64_TLBI_VMALLS12E1IS, + ARM64_TLBI_VAALE1IS, + ARM64_TLBI_IPAS2E1, + ARM64_TLBI_IPAS2LE1, + ARM64_TLBI_VMALLE1, + ARM64_TLBI_ALLE2, + ARM64_TLBI_ALLE3, + ARM64_TLBI_VAE1, + ARM64_TLBI_VAE2, + ARM64_TLBI_VAE3, + ARM64_TLBI_ASIDE1, + ARM64_TLBI_VAAE1, + ARM64_TLBI_ALLE1, + ARM64_TLBI_VALE1, + ARM64_TLBI_VALE2, + ARM64_TLBI_VALE3, + ARM64_TLBI_VMALLS12E1, + ARM64_TLBI_VAALE1, + ARM64_TLBI_VMALLE1OS, + ARM64_TLBI_VAE1OS, + ARM64_TLBI_ASIDE1OS, + ARM64_TLBI_VAAE1OS, + ARM64_TLBI_VALE1OS, + ARM64_TLBI_VAALE1OS, + ARM64_TLBI_IPAS2E1OS, + ARM64_TLBI_IPAS2LE1OS, + ARM64_TLBI_VAE2OS, + ARM64_TLBI_VALE2OS, + ARM64_TLBI_VMALLS12E1OS, + ARM64_TLBI_VAE3OS, + ARM64_TLBI_VALE3OS, + ARM64_TLBI_ALLE2OS, + ARM64_TLBI_ALLE1OS, + ARM64_TLBI_ALLE3OS, + ARM64_TLBI_RVAE1, + ARM64_TLBI_RVAAE1, + ARM64_TLBI_RVALE1, + ARM64_TLBI_RVAALE1, + ARM64_TLBI_RVAE1IS, + ARM64_TLBI_RVAAE1IS, + ARM64_TLBI_RVALE1IS, + ARM64_TLBI_RVAALE1IS, + ARM64_TLBI_RVAE1OS, + ARM64_TLBI_RVAAE1OS, + ARM64_TLBI_RVALE1OS, + ARM64_TLBI_RVAALE1OS, + ARM64_TLBI_RIPAS2E1IS, + ARM64_TLBI_RIPAS2LE1IS, + ARM64_TLBI_RIPAS2E1, + ARM64_TLBI_RIPAS2LE1, + ARM64_TLBI_RIPAS2E1OS, + ARM64_TLBI_RIPAS2LE1OS, + ARM64_TLBI_RVAE2, + ARM64_TLBI_RVALE2, + ARM64_TLBI_RVAE2IS, + ARM64_TLBI_RVALE2IS, + ARM64_TLBI_RVAE2OS, + ARM64_TLBI_RVALE2OS, + ARM64_TLBI_RVAE3, + ARM64_TLBI_RVALE3, + ARM64_TLBI_RVAE3IS, + ARM64_TLBI_RVALE3IS, + ARM64_TLBI_RVAE3OS, + ARM64_TLBI_RVALE3OS, +} arm64_tlbi_op; + +/// AT operations +typedef enum arm64_at_op { + ARM64_AT_S1E1R, + ARM64_AT_S1E2R, + ARM64_AT_S1E3R, + ARM64_AT_S1E1W, + ARM64_AT_S1E2W, + ARM64_AT_S1E3W, + ARM64_AT_S1E0R, + ARM64_AT_S1E0W, + ARM64_AT_S12E1R, + ARM64_AT_S12E1W, + ARM64_AT_S12E0R, + ARM64_AT_S12E0W, + ARM64_AT_S1E1RP, + ARM64_AT_S1E1WP, +} arm64_at_op; + +/// DC operations +typedef enum arm64_dc_op { + ARM64_DC_INVALID = 0, + ARM64_DC_ZVA, + ARM64_DC_IVAC, + ARM64_DC_ISW, + ARM64_DC_CVAC, + ARM64_DC_CSW, + ARM64_DC_CVAU, + ARM64_DC_CIVAC, + ARM64_DC_CISW, + ARM64_DC_CVAP, +} arm64_dc_op; + +/// IC operations +typedef enum arm64_ic_op { + ARM64_IC_INVALID = 0, + ARM64_IC_IALLUIS, + ARM64_IC_IALLU, + ARM64_IC_IVAU, +} arm64_ic_op; + +/// Prefetch operations (PRFM) +typedef enum arm64_prefetch_op { + ARM64_PRFM_INVALID = 0, + ARM64_PRFM_PLDL1KEEP = 0x00 + 1, + ARM64_PRFM_PLDL1STRM = 0x01 + 1, + ARM64_PRFM_PLDL2KEEP = 0x02 + 1, + ARM64_PRFM_PLDL2STRM = 0x03 + 1, + ARM64_PRFM_PLDL3KEEP = 0x04 + 1, + ARM64_PRFM_PLDL3STRM = 0x05 + 1, + ARM64_PRFM_PLIL1KEEP = 0x08 + 1, + ARM64_PRFM_PLIL1STRM = 0x09 + 1, + ARM64_PRFM_PLIL2KEEP = 0x0a + 1, + ARM64_PRFM_PLIL2STRM = 0x0b + 1, + ARM64_PRFM_PLIL3KEEP = 0x0c + 1, + ARM64_PRFM_PLIL3STRM = 0x0d + 1, + ARM64_PRFM_PSTL1KEEP = 0x10 + 1, + ARM64_PRFM_PSTL1STRM = 0x11 + 1, + ARM64_PRFM_PSTL2KEEP = 0x12 + 1, + ARM64_PRFM_PSTL2STRM = 0x13 + 1, + ARM64_PRFM_PSTL3KEEP = 0x14 + 1, + ARM64_PRFM_PSTL3STRM = 0x15 + 1, +} arm64_prefetch_op; + +/// ARM64 registers +typedef enum arm64_reg { + ARM64_REG_INVALID = 0, + + ARM64_REG_FFR = 1, + ARM64_REG_FP = 2, + ARM64_REG_LR = 3, + ARM64_REG_NZCV = 4, + ARM64_REG_SP = 5, + ARM64_REG_WSP = 6, + ARM64_REG_WZR = 7, + ARM64_REG_XZR = 8, + ARM64_REG_B0 = 9, + ARM64_REG_B1 = 10, + ARM64_REG_B2 = 11, + ARM64_REG_B3 = 12, + ARM64_REG_B4 = 13, + ARM64_REG_B5 = 14, + ARM64_REG_B6 = 15, + ARM64_REG_B7 = 16, + ARM64_REG_B8 = 17, + ARM64_REG_B9 = 18, + ARM64_REG_B10 = 19, + ARM64_REG_B11 = 20, + ARM64_REG_B12 = 21, + ARM64_REG_B13 = 22, + ARM64_REG_B14 = 23, + ARM64_REG_B15 = 24, + ARM64_REG_B16 = 25, + ARM64_REG_B17 = 26, + ARM64_REG_B18 = 27, + ARM64_REG_B19 = 28, + ARM64_REG_B20 = 29, + ARM64_REG_B21 = 30, + ARM64_REG_B22 = 31, + ARM64_REG_B23 = 32, + ARM64_REG_B24 = 33, + ARM64_REG_B25 = 34, + ARM64_REG_B26 = 35, + ARM64_REG_B27 = 36, + ARM64_REG_B28 = 37, + ARM64_REG_B29 = 38, + ARM64_REG_B30 = 39, + ARM64_REG_B31 = 40, + ARM64_REG_D0 = 41, + ARM64_REG_D1 = 42, + ARM64_REG_D2 = 43, + ARM64_REG_D3 = 44, + ARM64_REG_D4 = 45, + ARM64_REG_D5 = 46, + ARM64_REG_D6 = 47, + ARM64_REG_D7 = 48, + ARM64_REG_D8 = 49, + ARM64_REG_D9 = 50, + ARM64_REG_D10 = 51, + ARM64_REG_D11 = 52, + ARM64_REG_D12 = 53, + ARM64_REG_D13 = 54, + ARM64_REG_D14 = 55, + ARM64_REG_D15 = 56, + ARM64_REG_D16 = 57, + ARM64_REG_D17 = 58, + ARM64_REG_D18 = 59, + ARM64_REG_D19 = 60, + ARM64_REG_D20 = 61, + ARM64_REG_D21 = 62, + ARM64_REG_D22 = 63, + ARM64_REG_D23 = 64, + ARM64_REG_D24 = 65, + ARM64_REG_D25 = 66, + ARM64_REG_D26 = 67, + ARM64_REG_D27 = 68, + ARM64_REG_D28 = 69, + ARM64_REG_D29 = 70, + ARM64_REG_D30 = 71, + ARM64_REG_D31 = 72, + ARM64_REG_H0 = 73, + ARM64_REG_H1 = 74, + ARM64_REG_H2 = 75, + ARM64_REG_H3 = 76, + ARM64_REG_H4 = 77, + ARM64_REG_H5 = 78, + ARM64_REG_H6 = 79, + ARM64_REG_H7 = 80, + ARM64_REG_H8 = 81, + ARM64_REG_H9 = 82, + ARM64_REG_H10 = 83, + ARM64_REG_H11 = 84, + ARM64_REG_H12 = 85, + ARM64_REG_H13 = 86, + ARM64_REG_H14 = 87, + ARM64_REG_H15 = 88, + ARM64_REG_H16 = 89, + ARM64_REG_H17 = 90, + ARM64_REG_H18 = 91, + ARM64_REG_H19 = 92, + ARM64_REG_H20 = 93, + ARM64_REG_H21 = 94, + ARM64_REG_H22 = 95, + ARM64_REG_H23 = 96, + ARM64_REG_H24 = 97, + ARM64_REG_H25 = 98, + ARM64_REG_H26 = 99, + ARM64_REG_H27 = 100, + ARM64_REG_H28 = 101, + ARM64_REG_H29 = 102, + ARM64_REG_H30 = 103, + ARM64_REG_H31 = 104, + ARM64_REG_P0 = 105, + ARM64_REG_P1 = 106, + ARM64_REG_P2 = 107, + ARM64_REG_P3 = 108, + ARM64_REG_P4 = 109, + ARM64_REG_P5 = 110, + ARM64_REG_P6 = 111, + ARM64_REG_P7 = 112, + ARM64_REG_P8 = 113, + ARM64_REG_P9 = 114, + ARM64_REG_P10 = 115, + ARM64_REG_P11 = 116, + ARM64_REG_P12 = 117, + ARM64_REG_P13 = 118, + ARM64_REG_P14 = 119, + ARM64_REG_P15 = 120, + ARM64_REG_Q0 = 121, + ARM64_REG_Q1 = 122, + ARM64_REG_Q2 = 123, + ARM64_REG_Q3 = 124, + ARM64_REG_Q4 = 125, + ARM64_REG_Q5 = 126, + ARM64_REG_Q6 = 127, + ARM64_REG_Q7 = 128, + ARM64_REG_Q8 = 129, + ARM64_REG_Q9 = 130, + ARM64_REG_Q10 = 131, + ARM64_REG_Q11 = 132, + ARM64_REG_Q12 = 133, + ARM64_REG_Q13 = 134, + ARM64_REG_Q14 = 135, + ARM64_REG_Q15 = 136, + ARM64_REG_Q16 = 137, + ARM64_REG_Q17 = 138, + ARM64_REG_Q18 = 139, + ARM64_REG_Q19 = 140, + ARM64_REG_Q20 = 141, + ARM64_REG_Q21 = 142, + ARM64_REG_Q22 = 143, + ARM64_REG_Q23 = 144, + ARM64_REG_Q24 = 145, + ARM64_REG_Q25 = 146, + ARM64_REG_Q26 = 147, + ARM64_REG_Q27 = 148, + ARM64_REG_Q28 = 149, + ARM64_REG_Q29 = 150, + ARM64_REG_Q30 = 151, + ARM64_REG_Q31 = 152, + ARM64_REG_S0 = 153, + ARM64_REG_S1 = 154, + ARM64_REG_S2 = 155, + ARM64_REG_S3 = 156, + ARM64_REG_S4 = 157, + ARM64_REG_S5 = 158, + ARM64_REG_S6 = 159, + ARM64_REG_S7 = 160, + ARM64_REG_S8 = 161, + ARM64_REG_S9 = 162, + ARM64_REG_S10 = 163, + ARM64_REG_S11 = 164, + ARM64_REG_S12 = 165, + ARM64_REG_S13 = 166, + ARM64_REG_S14 = 167, + ARM64_REG_S15 = 168, + ARM64_REG_S16 = 169, + ARM64_REG_S17 = 170, + ARM64_REG_S18 = 171, + ARM64_REG_S19 = 172, + ARM64_REG_S20 = 173, + ARM64_REG_S21 = 174, + ARM64_REG_S22 = 175, + ARM64_REG_S23 = 176, + ARM64_REG_S24 = 177, + ARM64_REG_S25 = 178, + ARM64_REG_S26 = 179, + ARM64_REG_S27 = 180, + ARM64_REG_S28 = 181, + ARM64_REG_S29 = 182, + ARM64_REG_S30 = 183, + ARM64_REG_S31 = 184, + ARM64_REG_W0 = 185, + ARM64_REG_W1 = 186, + ARM64_REG_W2 = 187, + ARM64_REG_W3 = 188, + ARM64_REG_W4 = 189, + ARM64_REG_W5 = 190, + ARM64_REG_W6 = 191, + ARM64_REG_W7 = 192, + ARM64_REG_W8 = 193, + ARM64_REG_W9 = 194, + ARM64_REG_W10 = 195, + ARM64_REG_W11 = 196, + ARM64_REG_W12 = 197, + ARM64_REG_W13 = 198, + ARM64_REG_W14 = 199, + ARM64_REG_W15 = 200, + ARM64_REG_W16 = 201, + ARM64_REG_W17 = 202, + ARM64_REG_W18 = 203, + ARM64_REG_W19 = 204, + ARM64_REG_W20 = 205, + ARM64_REG_W21 = 206, + ARM64_REG_W22 = 207, + ARM64_REG_W23 = 208, + ARM64_REG_W24 = 209, + ARM64_REG_W25 = 210, + ARM64_REG_W26 = 211, + ARM64_REG_W27 = 212, + ARM64_REG_W28 = 213, + ARM64_REG_W29 = 214, + ARM64_REG_W30 = 215, + ARM64_REG_X0 = 216, + ARM64_REG_X1 = 217, + ARM64_REG_X2 = 218, + ARM64_REG_X3 = 219, + ARM64_REG_X4 = 220, + ARM64_REG_X5 = 221, + ARM64_REG_X6 = 222, + ARM64_REG_X7 = 223, + ARM64_REG_X8 = 224, + ARM64_REG_X9 = 225, + ARM64_REG_X10 = 226, + ARM64_REG_X11 = 227, + ARM64_REG_X12 = 228, + ARM64_REG_X13 = 229, + ARM64_REG_X14 = 230, + ARM64_REG_X15 = 231, + ARM64_REG_X16 = 232, + ARM64_REG_X17 = 233, + ARM64_REG_X18 = 234, + ARM64_REG_X19 = 235, + ARM64_REG_X20 = 236, + ARM64_REG_X21 = 237, + ARM64_REG_X22 = 238, + ARM64_REG_X23 = 239, + ARM64_REG_X24 = 240, + ARM64_REG_X25 = 241, + ARM64_REG_X26 = 242, + ARM64_REG_X27 = 243, + ARM64_REG_X28 = 244, + ARM64_REG_Z0 = 245, + ARM64_REG_Z1 = 246, + ARM64_REG_Z2 = 247, + ARM64_REG_Z3 = 248, + ARM64_REG_Z4 = 249, + ARM64_REG_Z5 = 250, + ARM64_REG_Z6 = 251, + ARM64_REG_Z7 = 252, + ARM64_REG_Z8 = 253, + ARM64_REG_Z9 = 254, + ARM64_REG_Z10 = 255, + ARM64_REG_Z11 = 256, + ARM64_REG_Z12 = 257, + ARM64_REG_Z13 = 258, + ARM64_REG_Z14 = 259, + ARM64_REG_Z15 = 260, + ARM64_REG_Z16 = 261, + ARM64_REG_Z17 = 262, + ARM64_REG_Z18 = 263, + ARM64_REG_Z19 = 264, + ARM64_REG_Z20 = 265, + ARM64_REG_Z21 = 266, + ARM64_REG_Z22 = 267, + ARM64_REG_Z23 = 268, + ARM64_REG_Z24 = 269, + ARM64_REG_Z25 = 270, + ARM64_REG_Z26 = 271, + ARM64_REG_Z27 = 272, + ARM64_REG_Z28 = 273, + ARM64_REG_Z29 = 274, + ARM64_REG_Z30 = 275, + ARM64_REG_Z31 = 276, + + ARM64_REG_V0, + ARM64_REG_V1, + ARM64_REG_V2, + ARM64_REG_V3, + ARM64_REG_V4, + ARM64_REG_V5, + ARM64_REG_V6, + ARM64_REG_V7, + ARM64_REG_V8, + ARM64_REG_V9, + ARM64_REG_V10, + ARM64_REG_V11, + ARM64_REG_V12, + ARM64_REG_V13, + ARM64_REG_V14, + ARM64_REG_V15, + ARM64_REG_V16, + ARM64_REG_V17, + ARM64_REG_V18, + ARM64_REG_V19, + ARM64_REG_V20, + ARM64_REG_V21, + ARM64_REG_V22, + ARM64_REG_V23, + ARM64_REG_V24, + ARM64_REG_V25, + ARM64_REG_V26, + ARM64_REG_V27, + ARM64_REG_V28, + ARM64_REG_V29, + ARM64_REG_V30, + ARM64_REG_V31, + + ARM64_REG_ENDING, // <-- mark the end of the list of registers + + // alias registers + ARM64_REG_IP0 = ARM64_REG_X16, + ARM64_REG_IP1 = ARM64_REG_X17, + ARM64_REG_X29 = ARM64_REG_FP, + ARM64_REG_X30 = ARM64_REG_LR, +} arm64_reg; + +/// Instruction's operand referring to memory +/// This is associated with ARM64_OP_MEM operand type above +typedef struct arm64_op_mem { + arm64_reg base; ///< base register + arm64_reg index; ///< index register + int32_t disp; ///< displacement/offset value +} arm64_op_mem; + +/// Instruction operand +typedef struct cs_arm64_op { + int vector_index; ///< Vector Index for some vector operands (or -1 if irrelevant) + arm64_vas vas; ///< Vector Arrangement Specifier + struct { + arm64_shifter type; ///< shifter type of this operand + unsigned int value; ///< shifter value of this operand + } shift; + arm64_extender ext; ///< extender type of this operand + arm64_op_type type; ///< operand type + union { + arm64_reg reg; ///< register value for REG operand + int64_t imm; ///< immediate value, or index for C-IMM or IMM operand + double fp; ///< floating point value for FP operand + arm64_op_mem mem; ///< base/index/scale/disp value for MEM operand + arm64_pstate pstate; ///< PState field of MSR instruction. + unsigned int sys; ///< IC/DC/AT/TLBI operation (see arm64_ic_op, arm64_dc_op, arm64_at_op, arm64_tlbi_op) + arm64_prefetch_op prefetch; ///< PRFM operation. + arm64_barrier_op barrier; ///< Memory barrier operation (ISB/DMB/DSB instructions). + }; + + /// How is this operand accessed? (READ, WRITE or READ|WRITE) + /// This field is combined of cs_ac_type. + /// NOTE: this field is irrelevant if engine is compiled in DIET mode. + uint8_t access; +} cs_arm64_op; + +/// Instruction structure +typedef struct cs_arm64 { + arm64_cc cc; ///< conditional code for this insn + bool update_flags; ///< does this insn update flags? + bool writeback; ///< does this insn request writeback? 'True' means 'yes' + + /// Number of operands of this instruction, + /// or 0 when instruction has no operand. + uint8_t op_count; + + cs_arm64_op operands[8]; ///< operands for this instruction. +} cs_arm64; + +/// ARM64 instruction +typedef enum arm64_insn { + ARM64_INS_INVALID = 0, + + ARM64_INS_ABS, + ARM64_INS_ADC, + ARM64_INS_ADCS, + ARM64_INS_ADD, + ARM64_INS_ADDHN, + ARM64_INS_ADDHN2, + ARM64_INS_ADDP, + ARM64_INS_ADDPL, + ARM64_INS_ADDS, + ARM64_INS_ADDV, + ARM64_INS_ADDVL, + ARM64_INS_ADR, + ARM64_INS_ADRP, + ARM64_INS_AESD, + ARM64_INS_AESE, + ARM64_INS_AESIMC, + ARM64_INS_AESMC, + ARM64_INS_AND, + ARM64_INS_ANDS, + ARM64_INS_ANDV, + ARM64_INS_ASR, + ARM64_INS_ASRD, + ARM64_INS_ASRR, + ARM64_INS_ASRV, + ARM64_INS_AUTDA, + ARM64_INS_AUTDB, + ARM64_INS_AUTDZA, + ARM64_INS_AUTDZB, + ARM64_INS_AUTIA, + ARM64_INS_AUTIA1716, + ARM64_INS_AUTIASP, + ARM64_INS_AUTIAZ, + ARM64_INS_AUTIB, + ARM64_INS_AUTIB1716, + ARM64_INS_AUTIBSP, + ARM64_INS_AUTIBZ, + ARM64_INS_AUTIZA, + ARM64_INS_AUTIZB, + ARM64_INS_B, + ARM64_INS_BCAX, + ARM64_INS_BFM, + ARM64_INS_BIC, + ARM64_INS_BICS, + ARM64_INS_BIF, + ARM64_INS_BIT, + ARM64_INS_BL, + ARM64_INS_BLR, + ARM64_INS_BLRAA, + ARM64_INS_BLRAAZ, + ARM64_INS_BLRAB, + ARM64_INS_BLRABZ, + ARM64_INS_BR, + ARM64_INS_BRAA, + ARM64_INS_BRAAZ, + ARM64_INS_BRAB, + ARM64_INS_BRABZ, + ARM64_INS_BRK, + ARM64_INS_BRKA, + ARM64_INS_BRKAS, + ARM64_INS_BRKB, + ARM64_INS_BRKBS, + ARM64_INS_BRKN, + ARM64_INS_BRKNS, + ARM64_INS_BRKPA, + ARM64_INS_BRKPAS, + ARM64_INS_BRKPB, + ARM64_INS_BRKPBS, + ARM64_INS_BSL, + ARM64_INS_CAS, + ARM64_INS_CASA, + ARM64_INS_CASAB, + ARM64_INS_CASAH, + ARM64_INS_CASAL, + ARM64_INS_CASALB, + ARM64_INS_CASALH, + ARM64_INS_CASB, + ARM64_INS_CASH, + ARM64_INS_CASL, + ARM64_INS_CASLB, + ARM64_INS_CASLH, + ARM64_INS_CASP, + ARM64_INS_CASPA, + ARM64_INS_CASPAL, + ARM64_INS_CASPL, + ARM64_INS_CBNZ, + ARM64_INS_CBZ, + ARM64_INS_CCMN, + ARM64_INS_CCMP, + ARM64_INS_CFINV, + ARM64_INS_CINC, + ARM64_INS_CINV, + ARM64_INS_CLASTA, + ARM64_INS_CLASTB, + ARM64_INS_CLREX, + ARM64_INS_CLS, + ARM64_INS_CLZ, + ARM64_INS_CMEQ, + ARM64_INS_CMGE, + ARM64_INS_CMGT, + ARM64_INS_CMHI, + ARM64_INS_CMHS, + ARM64_INS_CMLE, + ARM64_INS_CMLO, + ARM64_INS_CMLS, + ARM64_INS_CMLT, + ARM64_INS_CMN, + ARM64_INS_CMP, + ARM64_INS_CMPEQ, + ARM64_INS_CMPGE, + ARM64_INS_CMPGT, + ARM64_INS_CMPHI, + ARM64_INS_CMPHS, + ARM64_INS_CMPLE, + ARM64_INS_CMPLO, + ARM64_INS_CMPLS, + ARM64_INS_CMPLT, + ARM64_INS_CMPNE, + ARM64_INS_CMTST, + ARM64_INS_CNEG, + ARM64_INS_CNOT, + ARM64_INS_CNT, + ARM64_INS_CNTB, + ARM64_INS_CNTD, + ARM64_INS_CNTH, + ARM64_INS_CNTP, + ARM64_INS_CNTW, + ARM64_INS_COMPACT, + ARM64_INS_CPY, + ARM64_INS_CRC32B, + ARM64_INS_CRC32CB, + ARM64_INS_CRC32CH, + ARM64_INS_CRC32CW, + ARM64_INS_CRC32CX, + ARM64_INS_CRC32H, + ARM64_INS_CRC32W, + ARM64_INS_CRC32X, + ARM64_INS_CSDB, + ARM64_INS_CSEL, + ARM64_INS_CSET, + ARM64_INS_CSETM, + ARM64_INS_CSINC, + ARM64_INS_CSINV, + ARM64_INS_CSNEG, + ARM64_INS_CTERMEQ, + ARM64_INS_CTERMNE, + ARM64_INS_DCPS1, + ARM64_INS_DCPS2, + ARM64_INS_DCPS3, + ARM64_INS_DECB, + ARM64_INS_DECD, + ARM64_INS_DECH, + ARM64_INS_DECP, + ARM64_INS_DECW, + ARM64_INS_DMB, + ARM64_INS_DRPS, + ARM64_INS_DSB, + ARM64_INS_DUP, + ARM64_INS_DUPM, + ARM64_INS_EON, + ARM64_INS_EOR, + ARM64_INS_EOR3, + ARM64_INS_EORS, + ARM64_INS_EORV, + ARM64_INS_ERET, + ARM64_INS_ERETAA, + ARM64_INS_ERETAB, + ARM64_INS_ESB, + ARM64_INS_EXT, + ARM64_INS_EXTR, + ARM64_INS_FABD, + ARM64_INS_FABS, + ARM64_INS_FACGE, + ARM64_INS_FACGT, + ARM64_INS_FACLE, + ARM64_INS_FACLT, + ARM64_INS_FADD, + ARM64_INS_FADDA, + ARM64_INS_FADDP, + ARM64_INS_FADDV, + ARM64_INS_FCADD, + ARM64_INS_FCCMP, + ARM64_INS_FCCMPE, + ARM64_INS_FCMEQ, + ARM64_INS_FCMGE, + ARM64_INS_FCMGT, + ARM64_INS_FCMLA, + ARM64_INS_FCMLE, + ARM64_INS_FCMLT, + ARM64_INS_FCMNE, + ARM64_INS_FCMP, + ARM64_INS_FCMPE, + ARM64_INS_FCMUO, + ARM64_INS_FCPY, + ARM64_INS_FCSEL, + ARM64_INS_FCVT, + ARM64_INS_FCVTAS, + ARM64_INS_FCVTAU, + ARM64_INS_FCVTL, + ARM64_INS_FCVTL2, + ARM64_INS_FCVTMS, + ARM64_INS_FCVTMU, + ARM64_INS_FCVTN, + ARM64_INS_FCVTN2, + ARM64_INS_FCVTNS, + ARM64_INS_FCVTNU, + ARM64_INS_FCVTPS, + ARM64_INS_FCVTPU, + ARM64_INS_FCVTXN, + ARM64_INS_FCVTXN2, + ARM64_INS_FCVTZS, + ARM64_INS_FCVTZU, + ARM64_INS_FDIV, + ARM64_INS_FDIVR, + ARM64_INS_FDUP, + ARM64_INS_FEXPA, + ARM64_INS_FJCVTZS, + ARM64_INS_FMAD, + ARM64_INS_FMADD, + ARM64_INS_FMAX, + ARM64_INS_FMAXNM, + ARM64_INS_FMAXNMP, + ARM64_INS_FMAXNMV, + ARM64_INS_FMAXP, + ARM64_INS_FMAXV, + ARM64_INS_FMIN, + ARM64_INS_FMINNM, + ARM64_INS_FMINNMP, + ARM64_INS_FMINNMV, + ARM64_INS_FMINP, + ARM64_INS_FMINV, + ARM64_INS_FMLA, + ARM64_INS_FMLS, + ARM64_INS_FMOV, + ARM64_INS_FMSB, + ARM64_INS_FMSUB, + ARM64_INS_FMUL, + ARM64_INS_FMULX, + ARM64_INS_FNEG, + ARM64_INS_FNMAD, + ARM64_INS_FNMADD, + ARM64_INS_FNMLA, + ARM64_INS_FNMLS, + ARM64_INS_FNMSB, + ARM64_INS_FNMSUB, + ARM64_INS_FNMUL, + ARM64_INS_FRECPE, + ARM64_INS_FRECPS, + ARM64_INS_FRECPX, + ARM64_INS_FRINTA, + ARM64_INS_FRINTI, + ARM64_INS_FRINTM, + ARM64_INS_FRINTN, + ARM64_INS_FRINTP, + ARM64_INS_FRINTX, + ARM64_INS_FRINTZ, + ARM64_INS_FRSQRTE, + ARM64_INS_FRSQRTS, + ARM64_INS_FSCALE, + ARM64_INS_FSQRT, + ARM64_INS_FSUB, + ARM64_INS_FSUBR, + ARM64_INS_FTMAD, + ARM64_INS_FTSMUL, + ARM64_INS_FTSSEL, + ARM64_INS_HINT, + ARM64_INS_HLT, + ARM64_INS_HVC, + ARM64_INS_INCB, + ARM64_INS_INCD, + ARM64_INS_INCH, + ARM64_INS_INCP, + ARM64_INS_INCW, + ARM64_INS_INDEX, + ARM64_INS_INS, + ARM64_INS_INSR, + ARM64_INS_ISB, + ARM64_INS_LASTA, + ARM64_INS_LASTB, + ARM64_INS_LD1, + ARM64_INS_LD1B, + ARM64_INS_LD1D, + ARM64_INS_LD1H, + ARM64_INS_LD1R, + ARM64_INS_LD1RB, + ARM64_INS_LD1RD, + ARM64_INS_LD1RH, + ARM64_INS_LD1RQB, + ARM64_INS_LD1RQD, + ARM64_INS_LD1RQH, + ARM64_INS_LD1RQW, + ARM64_INS_LD1RSB, + ARM64_INS_LD1RSH, + ARM64_INS_LD1RSW, + ARM64_INS_LD1RW, + ARM64_INS_LD1SB, + ARM64_INS_LD1SH, + ARM64_INS_LD1SW, + ARM64_INS_LD1W, + ARM64_INS_LD2, + ARM64_INS_LD2B, + ARM64_INS_LD2D, + ARM64_INS_LD2H, + ARM64_INS_LD2R, + ARM64_INS_LD2W, + ARM64_INS_LD3, + ARM64_INS_LD3B, + ARM64_INS_LD3D, + ARM64_INS_LD3H, + ARM64_INS_LD3R, + ARM64_INS_LD3W, + ARM64_INS_LD4, + ARM64_INS_LD4B, + ARM64_INS_LD4D, + ARM64_INS_LD4H, + ARM64_INS_LD4R, + ARM64_INS_LD4W, + ARM64_INS_LDADD, + ARM64_INS_LDADDA, + ARM64_INS_LDADDAB, + ARM64_INS_LDADDAH, + ARM64_INS_LDADDAL, + ARM64_INS_LDADDALB, + ARM64_INS_LDADDALH, + ARM64_INS_LDADDB, + ARM64_INS_LDADDH, + ARM64_INS_LDADDL, + ARM64_INS_LDADDLB, + ARM64_INS_LDADDLH, + ARM64_INS_LDAPR, + ARM64_INS_LDAPRB, + ARM64_INS_LDAPRH, + ARM64_INS_LDAPUR, + ARM64_INS_LDAPURB, + ARM64_INS_LDAPURH, + ARM64_INS_LDAPURSB, + ARM64_INS_LDAPURSH, + ARM64_INS_LDAPURSW, + ARM64_INS_LDAR, + ARM64_INS_LDARB, + ARM64_INS_LDARH, + ARM64_INS_LDAXP, + ARM64_INS_LDAXR, + ARM64_INS_LDAXRB, + ARM64_INS_LDAXRH, + ARM64_INS_LDCLR, + ARM64_INS_LDCLRA, + ARM64_INS_LDCLRAB, + ARM64_INS_LDCLRAH, + ARM64_INS_LDCLRAL, + ARM64_INS_LDCLRALB, + ARM64_INS_LDCLRALH, + ARM64_INS_LDCLRB, + ARM64_INS_LDCLRH, + ARM64_INS_LDCLRL, + ARM64_INS_LDCLRLB, + ARM64_INS_LDCLRLH, + ARM64_INS_LDEOR, + ARM64_INS_LDEORA, + ARM64_INS_LDEORAB, + ARM64_INS_LDEORAH, + ARM64_INS_LDEORAL, + ARM64_INS_LDEORALB, + ARM64_INS_LDEORALH, + ARM64_INS_LDEORB, + ARM64_INS_LDEORH, + ARM64_INS_LDEORL, + ARM64_INS_LDEORLB, + ARM64_INS_LDEORLH, + ARM64_INS_LDFF1B, + ARM64_INS_LDFF1D, + ARM64_INS_LDFF1H, + ARM64_INS_LDFF1SB, + ARM64_INS_LDFF1SH, + ARM64_INS_LDFF1SW, + ARM64_INS_LDFF1W, + ARM64_INS_LDLAR, + ARM64_INS_LDLARB, + ARM64_INS_LDLARH, + ARM64_INS_LDNF1B, + ARM64_INS_LDNF1D, + ARM64_INS_LDNF1H, + ARM64_INS_LDNF1SB, + ARM64_INS_LDNF1SH, + ARM64_INS_LDNF1SW, + ARM64_INS_LDNF1W, + ARM64_INS_LDNP, + ARM64_INS_LDNT1B, + ARM64_INS_LDNT1D, + ARM64_INS_LDNT1H, + ARM64_INS_LDNT1W, + ARM64_INS_LDP, + ARM64_INS_LDPSW, + ARM64_INS_LDR, + ARM64_INS_LDRAA, + ARM64_INS_LDRAB, + ARM64_INS_LDRB, + ARM64_INS_LDRH, + ARM64_INS_LDRSB, + ARM64_INS_LDRSH, + ARM64_INS_LDRSW, + ARM64_INS_LDSET, + ARM64_INS_LDSETA, + ARM64_INS_LDSETAB, + ARM64_INS_LDSETAH, + ARM64_INS_LDSETAL, + ARM64_INS_LDSETALB, + ARM64_INS_LDSETALH, + ARM64_INS_LDSETB, + ARM64_INS_LDSETH, + ARM64_INS_LDSETL, + ARM64_INS_LDSETLB, + ARM64_INS_LDSETLH, + ARM64_INS_LDSMAX, + ARM64_INS_LDSMAXA, + ARM64_INS_LDSMAXAB, + ARM64_INS_LDSMAXAH, + ARM64_INS_LDSMAXAL, + ARM64_INS_LDSMAXALB, + ARM64_INS_LDSMAXALH, + ARM64_INS_LDSMAXB, + ARM64_INS_LDSMAXH, + ARM64_INS_LDSMAXL, + ARM64_INS_LDSMAXLB, + ARM64_INS_LDSMAXLH, + ARM64_INS_LDSMIN, + ARM64_INS_LDSMINA, + ARM64_INS_LDSMINAB, + ARM64_INS_LDSMINAH, + ARM64_INS_LDSMINAL, + ARM64_INS_LDSMINALB, + ARM64_INS_LDSMINALH, + ARM64_INS_LDSMINB, + ARM64_INS_LDSMINH, + ARM64_INS_LDSMINL, + ARM64_INS_LDSMINLB, + ARM64_INS_LDSMINLH, + ARM64_INS_LDTR, + ARM64_INS_LDTRB, + ARM64_INS_LDTRH, + ARM64_INS_LDTRSB, + ARM64_INS_LDTRSH, + ARM64_INS_LDTRSW, + ARM64_INS_LDUMAX, + ARM64_INS_LDUMAXA, + ARM64_INS_LDUMAXAB, + ARM64_INS_LDUMAXAH, + ARM64_INS_LDUMAXAL, + ARM64_INS_LDUMAXALB, + ARM64_INS_LDUMAXALH, + ARM64_INS_LDUMAXB, + ARM64_INS_LDUMAXH, + ARM64_INS_LDUMAXL, + ARM64_INS_LDUMAXLB, + ARM64_INS_LDUMAXLH, + ARM64_INS_LDUMIN, + ARM64_INS_LDUMINA, + ARM64_INS_LDUMINAB, + ARM64_INS_LDUMINAH, + ARM64_INS_LDUMINAL, + ARM64_INS_LDUMINALB, + ARM64_INS_LDUMINALH, + ARM64_INS_LDUMINB, + ARM64_INS_LDUMINH, + ARM64_INS_LDUMINL, + ARM64_INS_LDUMINLB, + ARM64_INS_LDUMINLH, + ARM64_INS_LDUR, + ARM64_INS_LDURB, + ARM64_INS_LDURH, + ARM64_INS_LDURSB, + ARM64_INS_LDURSH, + ARM64_INS_LDURSW, + ARM64_INS_LDXP, + ARM64_INS_LDXR, + ARM64_INS_LDXRB, + ARM64_INS_LDXRH, + ARM64_INS_LSL, + ARM64_INS_LSLR, + ARM64_INS_LSLV, + ARM64_INS_LSR, + ARM64_INS_LSRR, + ARM64_INS_LSRV, + ARM64_INS_MAD, + ARM64_INS_MADD, + ARM64_INS_MLA, + ARM64_INS_MLS, + ARM64_INS_MNEG, + ARM64_INS_MOV, + ARM64_INS_MOVI, + ARM64_INS_MOVK, + ARM64_INS_MOVN, + ARM64_INS_MOVPRFX, + ARM64_INS_MOVS, + ARM64_INS_MOVZ, + ARM64_INS_MRS, + ARM64_INS_MSB, + ARM64_INS_MSR, + ARM64_INS_MSUB, + ARM64_INS_MUL, + ARM64_INS_MVN, + ARM64_INS_MVNI, + ARM64_INS_NAND, + ARM64_INS_NANDS, + ARM64_INS_NEG, + ARM64_INS_NEGS, + ARM64_INS_NGC, + ARM64_INS_NGCS, + ARM64_INS_NOP, + ARM64_INS_NOR, + ARM64_INS_NORS, + ARM64_INS_NOT, + ARM64_INS_NOTS, + ARM64_INS_ORN, + ARM64_INS_ORNS, + ARM64_INS_ORR, + ARM64_INS_ORRS, + ARM64_INS_ORV, + ARM64_INS_PACDA, + ARM64_INS_PACDB, + ARM64_INS_PACDZA, + ARM64_INS_PACDZB, + ARM64_INS_PACGA, + ARM64_INS_PACIA, + ARM64_INS_PACIA1716, + ARM64_INS_PACIASP, + ARM64_INS_PACIAZ, + ARM64_INS_PACIB, + ARM64_INS_PACIB1716, + ARM64_INS_PACIBSP, + ARM64_INS_PACIBZ, + ARM64_INS_PACIZA, + ARM64_INS_PACIZB, + ARM64_INS_PFALSE, + ARM64_INS_PFIRST, + ARM64_INS_PMUL, + ARM64_INS_PMULL, + ARM64_INS_PMULL2, + ARM64_INS_PNEXT, + ARM64_INS_PRFB, + ARM64_INS_PRFD, + ARM64_INS_PRFH, + ARM64_INS_PRFM, + ARM64_INS_PRFUM, + ARM64_INS_PRFW, + ARM64_INS_PSB, + ARM64_INS_PTEST, + ARM64_INS_PTRUE, + ARM64_INS_PTRUES, + ARM64_INS_PUNPKHI, + ARM64_INS_PUNPKLO, + ARM64_INS_RADDHN, + ARM64_INS_RADDHN2, + ARM64_INS_RAX1, + ARM64_INS_RBIT, + ARM64_INS_RDFFR, + ARM64_INS_RDFFRS, + ARM64_INS_RDVL, + ARM64_INS_RET, + ARM64_INS_RETAA, + ARM64_INS_RETAB, + ARM64_INS_REV, + ARM64_INS_REV16, + ARM64_INS_REV32, + ARM64_INS_REV64, + ARM64_INS_REVB, + ARM64_INS_REVH, + ARM64_INS_REVW, + ARM64_INS_RMIF, + ARM64_INS_ROR, + ARM64_INS_RORV, + ARM64_INS_RSHRN, + ARM64_INS_RSHRN2, + ARM64_INS_RSUBHN, + ARM64_INS_RSUBHN2, + ARM64_INS_SABA, + ARM64_INS_SABAL, + ARM64_INS_SABAL2, + ARM64_INS_SABD, + ARM64_INS_SABDL, + ARM64_INS_SABDL2, + ARM64_INS_SADALP, + ARM64_INS_SADDL, + ARM64_INS_SADDL2, + ARM64_INS_SADDLP, + ARM64_INS_SADDLV, + ARM64_INS_SADDV, + ARM64_INS_SADDW, + ARM64_INS_SADDW2, + ARM64_INS_SBC, + ARM64_INS_SBCS, + ARM64_INS_SBFM, + ARM64_INS_SCVTF, + ARM64_INS_SDIV, + ARM64_INS_SDIVR, + ARM64_INS_SDOT, + ARM64_INS_SEL, + ARM64_INS_SETF16, + ARM64_INS_SETF8, + ARM64_INS_SETFFR, + ARM64_INS_SEV, + ARM64_INS_SEVL, + ARM64_INS_SHA1C, + ARM64_INS_SHA1H, + ARM64_INS_SHA1M, + ARM64_INS_SHA1P, + ARM64_INS_SHA1SU0, + ARM64_INS_SHA1SU1, + ARM64_INS_SHA256H, + ARM64_INS_SHA256H2, + ARM64_INS_SHA256SU0, + ARM64_INS_SHA256SU1, + ARM64_INS_SHA512H, + ARM64_INS_SHA512H2, + ARM64_INS_SHA512SU0, + ARM64_INS_SHA512SU1, + ARM64_INS_SHADD, + ARM64_INS_SHL, + ARM64_INS_SHLL, + ARM64_INS_SHLL2, + ARM64_INS_SHRN, + ARM64_INS_SHRN2, + ARM64_INS_SHSUB, + ARM64_INS_SLI, + ARM64_INS_SM3PARTW1, + ARM64_INS_SM3PARTW2, + ARM64_INS_SM3SS1, + ARM64_INS_SM3TT1A, + ARM64_INS_SM3TT1B, + ARM64_INS_SM3TT2A, + ARM64_INS_SM3TT2B, + ARM64_INS_SM4E, + ARM64_INS_SM4EKEY, + ARM64_INS_SMADDL, + ARM64_INS_SMAX, + ARM64_INS_SMAXP, + ARM64_INS_SMAXV, + ARM64_INS_SMC, + ARM64_INS_SMIN, + ARM64_INS_SMINP, + ARM64_INS_SMINV, + ARM64_INS_SMLAL, + ARM64_INS_SMLAL2, + ARM64_INS_SMLSL, + ARM64_INS_SMLSL2, + ARM64_INS_SMNEGL, + ARM64_INS_SMOV, + ARM64_INS_SMSUBL, + ARM64_INS_SMULH, + ARM64_INS_SMULL, + ARM64_INS_SMULL2, + ARM64_INS_SPLICE, + ARM64_INS_SQABS, + ARM64_INS_SQADD, + ARM64_INS_SQDECB, + ARM64_INS_SQDECD, + ARM64_INS_SQDECH, + ARM64_INS_SQDECP, + ARM64_INS_SQDECW, + ARM64_INS_SQDMLAL, + ARM64_INS_SQDMLAL2, + ARM64_INS_SQDMLSL, + ARM64_INS_SQDMLSL2, + ARM64_INS_SQDMULH, + ARM64_INS_SQDMULL, + ARM64_INS_SQDMULL2, + ARM64_INS_SQINCB, + ARM64_INS_SQINCD, + ARM64_INS_SQINCH, + ARM64_INS_SQINCP, + ARM64_INS_SQINCW, + ARM64_INS_SQNEG, + ARM64_INS_SQRDMLAH, + ARM64_INS_SQRDMLSH, + ARM64_INS_SQRDMULH, + ARM64_INS_SQRSHL, + ARM64_INS_SQRSHRN, + ARM64_INS_SQRSHRN2, + ARM64_INS_SQRSHRUN, + ARM64_INS_SQRSHRUN2, + ARM64_INS_SQSHL, + ARM64_INS_SQSHLU, + ARM64_INS_SQSHRN, + ARM64_INS_SQSHRN2, + ARM64_INS_SQSHRUN, + ARM64_INS_SQSHRUN2, + ARM64_INS_SQSUB, + ARM64_INS_SQXTN, + ARM64_INS_SQXTN2, + ARM64_INS_SQXTUN, + ARM64_INS_SQXTUN2, + ARM64_INS_SRHADD, + ARM64_INS_SRI, + ARM64_INS_SRSHL, + ARM64_INS_SRSHR, + ARM64_INS_SRSRA, + ARM64_INS_SSHL, + ARM64_INS_SSHLL, + ARM64_INS_SSHLL2, + ARM64_INS_SSHR, + ARM64_INS_SSRA, + ARM64_INS_SSUBL, + ARM64_INS_SSUBL2, + ARM64_INS_SSUBW, + ARM64_INS_SSUBW2, + ARM64_INS_ST1, + ARM64_INS_ST1B, + ARM64_INS_ST1D, + ARM64_INS_ST1H, + ARM64_INS_ST1W, + ARM64_INS_ST2, + ARM64_INS_ST2B, + ARM64_INS_ST2D, + ARM64_INS_ST2H, + ARM64_INS_ST2W, + ARM64_INS_ST3, + ARM64_INS_ST3B, + ARM64_INS_ST3D, + ARM64_INS_ST3H, + ARM64_INS_ST3W, + ARM64_INS_ST4, + ARM64_INS_ST4B, + ARM64_INS_ST4D, + ARM64_INS_ST4H, + ARM64_INS_ST4W, + ARM64_INS_STADD, + ARM64_INS_STADDB, + ARM64_INS_STADDH, + ARM64_INS_STADDL, + ARM64_INS_STADDLB, + ARM64_INS_STADDLH, + ARM64_INS_STCLR, + ARM64_INS_STCLRB, + ARM64_INS_STCLRH, + ARM64_INS_STCLRL, + ARM64_INS_STCLRLB, + ARM64_INS_STCLRLH, + ARM64_INS_STEOR, + ARM64_INS_STEORB, + ARM64_INS_STEORH, + ARM64_INS_STEORL, + ARM64_INS_STEORLB, + ARM64_INS_STEORLH, + ARM64_INS_STLLR, + ARM64_INS_STLLRB, + ARM64_INS_STLLRH, + ARM64_INS_STLR, + ARM64_INS_STLRB, + ARM64_INS_STLRH, + ARM64_INS_STLUR, + ARM64_INS_STLURB, + ARM64_INS_STLURH, + ARM64_INS_STLXP, + ARM64_INS_STLXR, + ARM64_INS_STLXRB, + ARM64_INS_STLXRH, + ARM64_INS_STNP, + ARM64_INS_STNT1B, + ARM64_INS_STNT1D, + ARM64_INS_STNT1H, + ARM64_INS_STNT1W, + ARM64_INS_STP, + ARM64_INS_STR, + ARM64_INS_STRB, + ARM64_INS_STRH, + ARM64_INS_STSET, + ARM64_INS_STSETB, + ARM64_INS_STSETH, + ARM64_INS_STSETL, + ARM64_INS_STSETLB, + ARM64_INS_STSETLH, + ARM64_INS_STSMAX, + ARM64_INS_STSMAXB, + ARM64_INS_STSMAXH, + ARM64_INS_STSMAXL, + ARM64_INS_STSMAXLB, + ARM64_INS_STSMAXLH, + ARM64_INS_STSMIN, + ARM64_INS_STSMINB, + ARM64_INS_STSMINH, + ARM64_INS_STSMINL, + ARM64_INS_STSMINLB, + ARM64_INS_STSMINLH, + ARM64_INS_STTR, + ARM64_INS_STTRB, + ARM64_INS_STTRH, + ARM64_INS_STUMAX, + ARM64_INS_STUMAXB, + ARM64_INS_STUMAXH, + ARM64_INS_STUMAXL, + ARM64_INS_STUMAXLB, + ARM64_INS_STUMAXLH, + ARM64_INS_STUMIN, + ARM64_INS_STUMINB, + ARM64_INS_STUMINH, + ARM64_INS_STUMINL, + ARM64_INS_STUMINLB, + ARM64_INS_STUMINLH, + ARM64_INS_STUR, + ARM64_INS_STURB, + ARM64_INS_STURH, + ARM64_INS_STXP, + ARM64_INS_STXR, + ARM64_INS_STXRB, + ARM64_INS_STXRH, + ARM64_INS_SUB, + ARM64_INS_SUBHN, + ARM64_INS_SUBHN2, + ARM64_INS_SUBR, + ARM64_INS_SUBS, + ARM64_INS_SUNPKHI, + ARM64_INS_SUNPKLO, + ARM64_INS_SUQADD, + ARM64_INS_SVC, + ARM64_INS_SWP, + ARM64_INS_SWPA, + ARM64_INS_SWPAB, + ARM64_INS_SWPAH, + ARM64_INS_SWPAL, + ARM64_INS_SWPALB, + ARM64_INS_SWPALH, + ARM64_INS_SWPB, + ARM64_INS_SWPH, + ARM64_INS_SWPL, + ARM64_INS_SWPLB, + ARM64_INS_SWPLH, + ARM64_INS_SXTB, + ARM64_INS_SXTH, + ARM64_INS_SXTL, + ARM64_INS_SXTL2, + ARM64_INS_SXTW, + ARM64_INS_SYS, + ARM64_INS_SYSL, + ARM64_INS_TBL, + ARM64_INS_TBNZ, + ARM64_INS_TBX, + ARM64_INS_TBZ, + ARM64_INS_TRN1, + ARM64_INS_TRN2, + ARM64_INS_TSB, + ARM64_INS_TST, + ARM64_INS_UABA, + ARM64_INS_UABAL, + ARM64_INS_UABAL2, + ARM64_INS_UABD, + ARM64_INS_UABDL, + ARM64_INS_UABDL2, + ARM64_INS_UADALP, + ARM64_INS_UADDL, + ARM64_INS_UADDL2, + ARM64_INS_UADDLP, + ARM64_INS_UADDLV, + ARM64_INS_UADDV, + ARM64_INS_UADDW, + ARM64_INS_UADDW2, + ARM64_INS_UBFM, + ARM64_INS_UCVTF, + ARM64_INS_UDIV, + ARM64_INS_UDIVR, + ARM64_INS_UDOT, + ARM64_INS_UHADD, + ARM64_INS_UHSUB, + ARM64_INS_UMADDL, + ARM64_INS_UMAX, + ARM64_INS_UMAXP, + ARM64_INS_UMAXV, + ARM64_INS_UMIN, + ARM64_INS_UMINP, + ARM64_INS_UMINV, + ARM64_INS_UMLAL, + ARM64_INS_UMLAL2, + ARM64_INS_UMLSL, + ARM64_INS_UMLSL2, + ARM64_INS_UMNEGL, + ARM64_INS_UMOV, + ARM64_INS_UMSUBL, + ARM64_INS_UMULH, + ARM64_INS_UMULL, + ARM64_INS_UMULL2, + ARM64_INS_UQADD, + ARM64_INS_UQDECB, + ARM64_INS_UQDECD, + ARM64_INS_UQDECH, + ARM64_INS_UQDECP, + ARM64_INS_UQDECW, + ARM64_INS_UQINCB, + ARM64_INS_UQINCD, + ARM64_INS_UQINCH, + ARM64_INS_UQINCP, + ARM64_INS_UQINCW, + ARM64_INS_UQRSHL, + ARM64_INS_UQRSHRN, + ARM64_INS_UQRSHRN2, + ARM64_INS_UQSHL, + ARM64_INS_UQSHRN, + ARM64_INS_UQSHRN2, + ARM64_INS_UQSUB, + ARM64_INS_UQXTN, + ARM64_INS_UQXTN2, + ARM64_INS_URECPE, + ARM64_INS_URHADD, + ARM64_INS_URSHL, + ARM64_INS_URSHR, + ARM64_INS_URSQRTE, + ARM64_INS_URSRA, + ARM64_INS_USHL, + ARM64_INS_USHLL, + ARM64_INS_USHLL2, + ARM64_INS_USHR, + ARM64_INS_USQADD, + ARM64_INS_USRA, + ARM64_INS_USUBL, + ARM64_INS_USUBL2, + ARM64_INS_USUBW, + ARM64_INS_USUBW2, + ARM64_INS_UUNPKHI, + ARM64_INS_UUNPKLO, + ARM64_INS_UXTB, + ARM64_INS_UXTH, + ARM64_INS_UXTL, + ARM64_INS_UXTL2, + ARM64_INS_UXTW, + ARM64_INS_UZP1, + ARM64_INS_UZP2, + ARM64_INS_WFE, + ARM64_INS_WFI, + ARM64_INS_WHILELE, + ARM64_INS_WHILELO, + ARM64_INS_WHILELS, + ARM64_INS_WHILELT, + ARM64_INS_WRFFR, + ARM64_INS_XAR, + ARM64_INS_XPACD, + ARM64_INS_XPACI, + ARM64_INS_XPACLRI, + ARM64_INS_XTN, + ARM64_INS_XTN2, + ARM64_INS_YIELD, + ARM64_INS_ZIP1, + ARM64_INS_ZIP2, + + // alias insn + ARM64_INS_SBFIZ, + ARM64_INS_UBFIZ, + ARM64_INS_SBFX, + ARM64_INS_UBFX, + ARM64_INS_BFI, + ARM64_INS_BFXIL, + ARM64_INS_IC, + ARM64_INS_DC, + ARM64_INS_AT, + ARM64_INS_TLBI, + + ARM64_INS_ENDING, // <-- mark the end of the list of insn +} arm64_insn; + +/// Group of ARM64 instructions +typedef enum arm64_insn_group { + ARM64_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + // Generic groups + // all jump instructions (conditional+direct+indirect jumps) + ARM64_GRP_JUMP, ///< = CS_GRP_JUMP + ARM64_GRP_CALL, + ARM64_GRP_RET, + ARM64_GRP_INT, + ARM64_GRP_PRIVILEGE = 6, ///< = CS_GRP_PRIVILEGE + ARM64_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE + ARM64_GRP_PAC, + + // Architecture-specific groups + ARM64_GRP_CRYPTO = 128, + ARM64_GRP_FPARMV8, + ARM64_GRP_NEON, + ARM64_GRP_CRC, + ARM64_GRP_AES, + ARM64_GRP_DOTPROD, + ARM64_GRP_FULLFP16, + ARM64_GRP_LSE, + ARM64_GRP_RCPC, + ARM64_GRP_RDM, + ARM64_GRP_SHA2, + ARM64_GRP_SHA3, + ARM64_GRP_SM4, + ARM64_GRP_SVE, + ARM64_GRP_V8_1A, + ARM64_GRP_V8_3A, + ARM64_GRP_V8_4A, + + ARM64_GRP_ENDING, // <-- mark the end of the list of groups +} arm64_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_M68K_H +#define CAPSTONE_M68K_H + +/* Capstone Disassembly Engine */ +/* By Daniel Collin , 2015-2016 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +#define M68K_OPERAND_COUNT 4 + +/// M68K registers and special registers +typedef enum m68k_reg { + M68K_REG_INVALID = 0, + + M68K_REG_D0, + M68K_REG_D1, + M68K_REG_D2, + M68K_REG_D3, + M68K_REG_D4, + M68K_REG_D5, + M68K_REG_D6, + M68K_REG_D7, + + M68K_REG_A0, + M68K_REG_A1, + M68K_REG_A2, + M68K_REG_A3, + M68K_REG_A4, + M68K_REG_A5, + M68K_REG_A6, + M68K_REG_A7, + + M68K_REG_FP0, + M68K_REG_FP1, + M68K_REG_FP2, + M68K_REG_FP3, + M68K_REG_FP4, + M68K_REG_FP5, + M68K_REG_FP6, + M68K_REG_FP7, + + M68K_REG_PC, + + M68K_REG_SR, + M68K_REG_CCR, + M68K_REG_SFC, + M68K_REG_DFC, + M68K_REG_USP, + M68K_REG_VBR, + M68K_REG_CACR, + M68K_REG_CAAR, + M68K_REG_MSP, + M68K_REG_ISP, + M68K_REG_TC, + M68K_REG_ITT0, + M68K_REG_ITT1, + M68K_REG_DTT0, + M68K_REG_DTT1, + M68K_REG_MMUSR, + M68K_REG_URP, + M68K_REG_SRP, + + M68K_REG_FPCR, + M68K_REG_FPSR, + M68K_REG_FPIAR, + + M68K_REG_ENDING, // <-- mark the end of the list of registers +} m68k_reg; + +/// M68K Addressing Modes +typedef enum m68k_address_mode { + M68K_AM_NONE = 0, ///< No address mode. + + M68K_AM_REG_DIRECT_DATA, ///< Register Direct - Data + M68K_AM_REG_DIRECT_ADDR, ///< Register Direct - Address + + M68K_AM_REGI_ADDR, ///< Register Indirect - Address + M68K_AM_REGI_ADDR_POST_INC, ///< Register Indirect - Address with Postincrement + M68K_AM_REGI_ADDR_PRE_DEC, ///< Register Indirect - Address with Predecrement + M68K_AM_REGI_ADDR_DISP, ///< Register Indirect - Address with Displacement + + M68K_AM_AREGI_INDEX_8_BIT_DISP, ///< Address Register Indirect With Index- 8-bit displacement + M68K_AM_AREGI_INDEX_BASE_DISP, ///< Address Register Indirect With Index- Base displacement + + M68K_AM_MEMI_POST_INDEX, ///< Memory indirect - Postindex + M68K_AM_MEMI_PRE_INDEX, ///< Memory indirect - Preindex + + M68K_AM_PCI_DISP, ///< Program Counter Indirect - with Displacement + + M68K_AM_PCI_INDEX_8_BIT_DISP, ///< Program Counter Indirect with Index - with 8-Bit Displacement + M68K_AM_PCI_INDEX_BASE_DISP, ///< Program Counter Indirect with Index - with Base Displacement + + M68K_AM_PC_MEMI_POST_INDEX, ///< Program Counter Memory Indirect - Postindexed + M68K_AM_PC_MEMI_PRE_INDEX, ///< Program Counter Memory Indirect - Preindexed + + M68K_AM_ABSOLUTE_DATA_SHORT, ///< Absolute Data Addressing - Short + M68K_AM_ABSOLUTE_DATA_LONG, ///< Absolute Data Addressing - Long + M68K_AM_IMMEDIATE, ///< Immediate value + + M68K_AM_BRANCH_DISPLACEMENT, ///< Address as displacement from (PC+2) used by branches +} m68k_address_mode; + +/// Operand type for instruction's operands +typedef enum m68k_op_type { + M68K_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + M68K_OP_REG, ///< = CS_OP_REG (Register operand). + M68K_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + M68K_OP_MEM, ///< = CS_OP_MEM (Memory operand). + M68K_OP_FP_SINGLE, ///< single precision Floating-Point operand + M68K_OP_FP_DOUBLE, ///< double precision Floating-Point operand + M68K_OP_REG_BITS, ///< Register bits move + M68K_OP_REG_PAIR, ///< Register pair in the same op (upper 4 bits for first reg, lower for second) + M68K_OP_BR_DISP, ///< Branch displacement +} m68k_op_type; + +/// Instruction's operand referring to memory +/// This is associated with M68K_OP_MEM operand type above +typedef struct m68k_op_mem { + m68k_reg base_reg; ///< base register (or M68K_REG_INVALID if irrelevant) + m68k_reg index_reg; ///< index register (or M68K_REG_INVALID if irrelevant) + m68k_reg in_base_reg; ///< indirect base register (or M68K_REG_INVALID if irrelevant) + uint32_t in_disp; ///< indirect displacement + uint32_t out_disp; ///< other displacement + int16_t disp; ///< displacement value + uint8_t scale; ///< scale for index register + uint8_t bitfield; ///< set to true if the two values below should be used + uint8_t width; ///< used for bf* instructions + uint8_t offset; ///< used for bf* instructions + uint8_t index_size; ///< 0 = w, 1 = l +} m68k_op_mem; + +/// Operand type for instruction's operands +typedef enum m68k_op_br_disp_size { + M68K_OP_BR_DISP_SIZE_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + M68K_OP_BR_DISP_SIZE_BYTE = 1, ///< signed 8-bit displacement + M68K_OP_BR_DISP_SIZE_WORD = 2, ///< signed 16-bit displacement + M68K_OP_BR_DISP_SIZE_LONG = 4, ///< signed 32-bit displacement +} m68k_op_br_disp_size; + +typedef struct m68k_op_br_disp { + int32_t disp; ///< displacement value + uint8_t disp_size; ///< Size from m68k_op_br_disp_size type above +} m68k_op_br_disp; + +/// Register pair in one operand. +typedef struct cs_m68k_op_reg_pair { + m68k_reg reg_0; + m68k_reg reg_1; +} cs_m68k_op_reg_pair; + +/// Instruction operand +typedef struct cs_m68k_op { + union { + uint64_t imm; ///< immediate value for IMM operand + double dimm; ///< double imm + float simm; ///< float imm + m68k_reg reg; ///< register value for REG operand + cs_m68k_op_reg_pair reg_pair; ///< register pair in one operand + }; + + m68k_op_mem mem; ///< data when operand is targeting memory + m68k_op_br_disp br_disp; ///< data when operand is a branch displacement + uint32_t register_bits; ///< register bits for movem etc. (always in d0-d7, a0-a7, fp0 - fp7 order) + m68k_op_type type; + m68k_address_mode address_mode; ///< M68K addressing mode for this op +} cs_m68k_op; + +/// Operation size of the CPU instructions +typedef enum m68k_cpu_size { + M68K_CPU_SIZE_NONE = 0, ///< unsized or unspecified + M68K_CPU_SIZE_BYTE = 1, ///< 1 byte in size + M68K_CPU_SIZE_WORD = 2, ///< 2 bytes in size + M68K_CPU_SIZE_LONG = 4, ///< 4 bytes in size +} m68k_cpu_size; + +/// Operation size of the FPU instructions (Notice that FPU instruction can also use CPU sizes if needed) +typedef enum m68k_fpu_size { + M68K_FPU_SIZE_NONE = 0, ///< unsized like fsave/frestore + M68K_FPU_SIZE_SINGLE = 4, ///< 4 byte in size (single float) + M68K_FPU_SIZE_DOUBLE = 8, ///< 8 byte in size (double) + M68K_FPU_SIZE_EXTENDED = 12, ///< 12 byte in size (extended real format) +} m68k_fpu_size; + +/// Type of size that is being used for the current instruction +typedef enum m68k_size_type { + M68K_SIZE_TYPE_INVALID = 0, + + M68K_SIZE_TYPE_CPU, + M68K_SIZE_TYPE_FPU, +} m68k_size_type; + +/// Operation size of the current instruction (NOT the actually size of instruction) +typedef struct m68k_op_size { + m68k_size_type type; + union { + m68k_cpu_size cpu_size; + m68k_fpu_size fpu_size; + }; +} m68k_op_size; + +/// The M68K instruction and it's operands +typedef struct cs_m68k { + // Number of operands of this instruction or 0 when instruction has no operand. + cs_m68k_op operands[M68K_OPERAND_COUNT]; ///< operands for this instruction. + m68k_op_size op_size; ///< size of data operand works on in bytes (.b, .w, .l, etc) + uint8_t op_count; ///< number of operands for the instruction +} cs_m68k; + +/// M68K instruction +typedef enum m68k_insn { + M68K_INS_INVALID = 0, + + M68K_INS_ABCD, + M68K_INS_ADD, + M68K_INS_ADDA, + M68K_INS_ADDI, + M68K_INS_ADDQ, + M68K_INS_ADDX, + M68K_INS_AND, + M68K_INS_ANDI, + M68K_INS_ASL, + M68K_INS_ASR, + M68K_INS_BHS, + M68K_INS_BLO, + M68K_INS_BHI, + M68K_INS_BLS, + M68K_INS_BCC, + M68K_INS_BCS, + M68K_INS_BNE, + M68K_INS_BEQ, + M68K_INS_BVC, + M68K_INS_BVS, + M68K_INS_BPL, + M68K_INS_BMI, + M68K_INS_BGE, + M68K_INS_BLT, + M68K_INS_BGT, + M68K_INS_BLE, + M68K_INS_BRA, + M68K_INS_BSR, + M68K_INS_BCHG, + M68K_INS_BCLR, + M68K_INS_BSET, + M68K_INS_BTST, + M68K_INS_BFCHG, + M68K_INS_BFCLR, + M68K_INS_BFEXTS, + M68K_INS_BFEXTU, + M68K_INS_BFFFO, + M68K_INS_BFINS, + M68K_INS_BFSET, + M68K_INS_BFTST, + M68K_INS_BKPT, + M68K_INS_CALLM, + M68K_INS_CAS, + M68K_INS_CAS2, + M68K_INS_CHK, + M68K_INS_CHK2, + M68K_INS_CLR, + M68K_INS_CMP, + M68K_INS_CMPA, + M68K_INS_CMPI, + M68K_INS_CMPM, + M68K_INS_CMP2, + M68K_INS_CINVL, + M68K_INS_CINVP, + M68K_INS_CINVA, + M68K_INS_CPUSHL, + M68K_INS_CPUSHP, + M68K_INS_CPUSHA, + M68K_INS_DBT, + M68K_INS_DBF, + M68K_INS_DBHI, + M68K_INS_DBLS, + M68K_INS_DBCC, + M68K_INS_DBCS, + M68K_INS_DBNE, + M68K_INS_DBEQ, + M68K_INS_DBVC, + M68K_INS_DBVS, + M68K_INS_DBPL, + M68K_INS_DBMI, + M68K_INS_DBGE, + M68K_INS_DBLT, + M68K_INS_DBGT, + M68K_INS_DBLE, + M68K_INS_DBRA, + M68K_INS_DIVS, + M68K_INS_DIVSL, + M68K_INS_DIVU, + M68K_INS_DIVUL, + M68K_INS_EOR, + M68K_INS_EORI, + M68K_INS_EXG, + M68K_INS_EXT, + M68K_INS_EXTB, + M68K_INS_FABS, + M68K_INS_FSABS, + M68K_INS_FDABS, + M68K_INS_FACOS, + M68K_INS_FADD, + M68K_INS_FSADD, + M68K_INS_FDADD, + M68K_INS_FASIN, + M68K_INS_FATAN, + M68K_INS_FATANH, + M68K_INS_FBF, + M68K_INS_FBEQ, + M68K_INS_FBOGT, + M68K_INS_FBOGE, + M68K_INS_FBOLT, + M68K_INS_FBOLE, + M68K_INS_FBOGL, + M68K_INS_FBOR, + M68K_INS_FBUN, + M68K_INS_FBUEQ, + M68K_INS_FBUGT, + M68K_INS_FBUGE, + M68K_INS_FBULT, + M68K_INS_FBULE, + M68K_INS_FBNE, + M68K_INS_FBT, + M68K_INS_FBSF, + M68K_INS_FBSEQ, + M68K_INS_FBGT, + M68K_INS_FBGE, + M68K_INS_FBLT, + M68K_INS_FBLE, + M68K_INS_FBGL, + M68K_INS_FBGLE, + M68K_INS_FBNGLE, + M68K_INS_FBNGL, + M68K_INS_FBNLE, + M68K_INS_FBNLT, + M68K_INS_FBNGE, + M68K_INS_FBNGT, + M68K_INS_FBSNE, + M68K_INS_FBST, + M68K_INS_FCMP, + M68K_INS_FCOS, + M68K_INS_FCOSH, + M68K_INS_FDBF, + M68K_INS_FDBEQ, + M68K_INS_FDBOGT, + M68K_INS_FDBOGE, + M68K_INS_FDBOLT, + M68K_INS_FDBOLE, + M68K_INS_FDBOGL, + M68K_INS_FDBOR, + M68K_INS_FDBUN, + M68K_INS_FDBUEQ, + M68K_INS_FDBUGT, + M68K_INS_FDBUGE, + M68K_INS_FDBULT, + M68K_INS_FDBULE, + M68K_INS_FDBNE, + M68K_INS_FDBT, + M68K_INS_FDBSF, + M68K_INS_FDBSEQ, + M68K_INS_FDBGT, + M68K_INS_FDBGE, + M68K_INS_FDBLT, + M68K_INS_FDBLE, + M68K_INS_FDBGL, + M68K_INS_FDBGLE, + M68K_INS_FDBNGLE, + M68K_INS_FDBNGL, + M68K_INS_FDBNLE, + M68K_INS_FDBNLT, + M68K_INS_FDBNGE, + M68K_INS_FDBNGT, + M68K_INS_FDBSNE, + M68K_INS_FDBST, + M68K_INS_FDIV, + M68K_INS_FSDIV, + M68K_INS_FDDIV, + M68K_INS_FETOX, + M68K_INS_FETOXM1, + M68K_INS_FGETEXP, + M68K_INS_FGETMAN, + M68K_INS_FINT, + M68K_INS_FINTRZ, + M68K_INS_FLOG10, + M68K_INS_FLOG2, + M68K_INS_FLOGN, + M68K_INS_FLOGNP1, + M68K_INS_FMOD, + M68K_INS_FMOVE, + M68K_INS_FSMOVE, + M68K_INS_FDMOVE, + M68K_INS_FMOVECR, + M68K_INS_FMOVEM, + M68K_INS_FMUL, + M68K_INS_FSMUL, + M68K_INS_FDMUL, + M68K_INS_FNEG, + M68K_INS_FSNEG, + M68K_INS_FDNEG, + M68K_INS_FNOP, + M68K_INS_FREM, + M68K_INS_FRESTORE, + M68K_INS_FSAVE, + M68K_INS_FSCALE, + M68K_INS_FSGLDIV, + M68K_INS_FSGLMUL, + M68K_INS_FSIN, + M68K_INS_FSINCOS, + M68K_INS_FSINH, + M68K_INS_FSQRT, + M68K_INS_FSSQRT, + M68K_INS_FDSQRT, + M68K_INS_FSF, + M68K_INS_FSBEQ, + M68K_INS_FSOGT, + M68K_INS_FSOGE, + M68K_INS_FSOLT, + M68K_INS_FSOLE, + M68K_INS_FSOGL, + M68K_INS_FSOR, + M68K_INS_FSUN, + M68K_INS_FSUEQ, + M68K_INS_FSUGT, + M68K_INS_FSUGE, + M68K_INS_FSULT, + M68K_INS_FSULE, + M68K_INS_FSNE, + M68K_INS_FST, + M68K_INS_FSSF, + M68K_INS_FSSEQ, + M68K_INS_FSGT, + M68K_INS_FSGE, + M68K_INS_FSLT, + M68K_INS_FSLE, + M68K_INS_FSGL, + M68K_INS_FSGLE, + M68K_INS_FSNGLE, + M68K_INS_FSNGL, + M68K_INS_FSNLE, + M68K_INS_FSNLT, + M68K_INS_FSNGE, + M68K_INS_FSNGT, + M68K_INS_FSSNE, + M68K_INS_FSST, + M68K_INS_FSUB, + M68K_INS_FSSUB, + M68K_INS_FDSUB, + M68K_INS_FTAN, + M68K_INS_FTANH, + M68K_INS_FTENTOX, + M68K_INS_FTRAPF, + M68K_INS_FTRAPEQ, + M68K_INS_FTRAPOGT, + M68K_INS_FTRAPOGE, + M68K_INS_FTRAPOLT, + M68K_INS_FTRAPOLE, + M68K_INS_FTRAPOGL, + M68K_INS_FTRAPOR, + M68K_INS_FTRAPUN, + M68K_INS_FTRAPUEQ, + M68K_INS_FTRAPUGT, + M68K_INS_FTRAPUGE, + M68K_INS_FTRAPULT, + M68K_INS_FTRAPULE, + M68K_INS_FTRAPNE, + M68K_INS_FTRAPT, + M68K_INS_FTRAPSF, + M68K_INS_FTRAPSEQ, + M68K_INS_FTRAPGT, + M68K_INS_FTRAPGE, + M68K_INS_FTRAPLT, + M68K_INS_FTRAPLE, + M68K_INS_FTRAPGL, + M68K_INS_FTRAPGLE, + M68K_INS_FTRAPNGLE, + M68K_INS_FTRAPNGL, + M68K_INS_FTRAPNLE, + M68K_INS_FTRAPNLT, + M68K_INS_FTRAPNGE, + M68K_INS_FTRAPNGT, + M68K_INS_FTRAPSNE, + M68K_INS_FTRAPST, + M68K_INS_FTST, + M68K_INS_FTWOTOX, + M68K_INS_HALT, + M68K_INS_ILLEGAL, + M68K_INS_JMP, + M68K_INS_JSR, + M68K_INS_LEA, + M68K_INS_LINK, + M68K_INS_LPSTOP, + M68K_INS_LSL, + M68K_INS_LSR, + M68K_INS_MOVE, + M68K_INS_MOVEA, + M68K_INS_MOVEC, + M68K_INS_MOVEM, + M68K_INS_MOVEP, + M68K_INS_MOVEQ, + M68K_INS_MOVES, + M68K_INS_MOVE16, + M68K_INS_MULS, + M68K_INS_MULU, + M68K_INS_NBCD, + M68K_INS_NEG, + M68K_INS_NEGX, + M68K_INS_NOP, + M68K_INS_NOT, + M68K_INS_OR, + M68K_INS_ORI, + M68K_INS_PACK, + M68K_INS_PEA, + M68K_INS_PFLUSH, + M68K_INS_PFLUSHA, + M68K_INS_PFLUSHAN, + M68K_INS_PFLUSHN, + M68K_INS_PLOADR, + M68K_INS_PLOADW, + M68K_INS_PLPAR, + M68K_INS_PLPAW, + M68K_INS_PMOVE, + M68K_INS_PMOVEFD, + M68K_INS_PTESTR, + M68K_INS_PTESTW, + M68K_INS_PULSE, + M68K_INS_REMS, + M68K_INS_REMU, + M68K_INS_RESET, + M68K_INS_ROL, + M68K_INS_ROR, + M68K_INS_ROXL, + M68K_INS_ROXR, + M68K_INS_RTD, + M68K_INS_RTE, + M68K_INS_RTM, + M68K_INS_RTR, + M68K_INS_RTS, + M68K_INS_SBCD, + M68K_INS_ST, + M68K_INS_SF, + M68K_INS_SHI, + M68K_INS_SLS, + M68K_INS_SCC, + M68K_INS_SHS, + M68K_INS_SCS, + M68K_INS_SLO, + M68K_INS_SNE, + M68K_INS_SEQ, + M68K_INS_SVC, + M68K_INS_SVS, + M68K_INS_SPL, + M68K_INS_SMI, + M68K_INS_SGE, + M68K_INS_SLT, + M68K_INS_SGT, + M68K_INS_SLE, + M68K_INS_STOP, + M68K_INS_SUB, + M68K_INS_SUBA, + M68K_INS_SUBI, + M68K_INS_SUBQ, + M68K_INS_SUBX, + M68K_INS_SWAP, + M68K_INS_TAS, + M68K_INS_TRAP, + M68K_INS_TRAPV, + M68K_INS_TRAPT, + M68K_INS_TRAPF, + M68K_INS_TRAPHI, + M68K_INS_TRAPLS, + M68K_INS_TRAPCC, + M68K_INS_TRAPHS, + M68K_INS_TRAPCS, + M68K_INS_TRAPLO, + M68K_INS_TRAPNE, + M68K_INS_TRAPEQ, + M68K_INS_TRAPVC, + M68K_INS_TRAPVS, + M68K_INS_TRAPPL, + M68K_INS_TRAPMI, + M68K_INS_TRAPGE, + M68K_INS_TRAPLT, + M68K_INS_TRAPGT, + M68K_INS_TRAPLE, + M68K_INS_TST, + M68K_INS_UNLK, + M68K_INS_UNPK, + M68K_INS_ENDING, // <-- mark the end of the list of instructions +} m68k_insn; + +/// Group of M68K instructions +typedef enum m68k_group_type { + M68K_GRP_INVALID = 0, ///< CS_GRUP_INVALID + M68K_GRP_JUMP, ///< = CS_GRP_JUMP + M68K_GRP_RET = 3, ///< = CS_GRP_RET + M68K_GRP_IRET = 5, ///< = CS_GRP_IRET + M68K_GRP_BRANCH_RELATIVE = 7, ///< = CS_GRP_BRANCH_RELATIVE + + M68K_GRP_ENDING,// <-- mark the end of the list of groups +} m68k_group_type; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_MIPS_H +#define CAPSTONE_MIPS_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2013-2015 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +// GCC MIPS toolchain has a default macro called "mips" which breaks +// compilation +#undef mips + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// Operand type for instruction's operands +typedef enum mips_op_type { + MIPS_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + MIPS_OP_REG, ///< = CS_OP_REG (Register operand). + MIPS_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + MIPS_OP_MEM, ///< = CS_OP_MEM (Memory operand). +} mips_op_type; + +/// MIPS registers +typedef enum mips_reg { + MIPS_REG_INVALID = 0, + // General purpose registers + MIPS_REG_PC, + + MIPS_REG_0, + MIPS_REG_1, + MIPS_REG_2, + MIPS_REG_3, + MIPS_REG_4, + MIPS_REG_5, + MIPS_REG_6, + MIPS_REG_7, + MIPS_REG_8, + MIPS_REG_9, + MIPS_REG_10, + MIPS_REG_11, + MIPS_REG_12, + MIPS_REG_13, + MIPS_REG_14, + MIPS_REG_15, + MIPS_REG_16, + MIPS_REG_17, + MIPS_REG_18, + MIPS_REG_19, + MIPS_REG_20, + MIPS_REG_21, + MIPS_REG_22, + MIPS_REG_23, + MIPS_REG_24, + MIPS_REG_25, + MIPS_REG_26, + MIPS_REG_27, + MIPS_REG_28, + MIPS_REG_29, + MIPS_REG_30, + MIPS_REG_31, + + // DSP registers + MIPS_REG_DSPCCOND, + MIPS_REG_DSPCARRY, + MIPS_REG_DSPEFI, + MIPS_REG_DSPOUTFLAG, + MIPS_REG_DSPOUTFLAG16_19, + MIPS_REG_DSPOUTFLAG20, + MIPS_REG_DSPOUTFLAG21, + MIPS_REG_DSPOUTFLAG22, + MIPS_REG_DSPOUTFLAG23, + MIPS_REG_DSPPOS, + MIPS_REG_DSPSCOUNT, + + // ACC registers + MIPS_REG_AC0, + MIPS_REG_AC1, + MIPS_REG_AC2, + MIPS_REG_AC3, + + // COP registers + MIPS_REG_CC0, + MIPS_REG_CC1, + MIPS_REG_CC2, + MIPS_REG_CC3, + MIPS_REG_CC4, + MIPS_REG_CC5, + MIPS_REG_CC6, + MIPS_REG_CC7, + + // FPU registers + MIPS_REG_F0, + MIPS_REG_F1, + MIPS_REG_F2, + MIPS_REG_F3, + MIPS_REG_F4, + MIPS_REG_F5, + MIPS_REG_F6, + MIPS_REG_F7, + MIPS_REG_F8, + MIPS_REG_F9, + MIPS_REG_F10, + MIPS_REG_F11, + MIPS_REG_F12, + MIPS_REG_F13, + MIPS_REG_F14, + MIPS_REG_F15, + MIPS_REG_F16, + MIPS_REG_F17, + MIPS_REG_F18, + MIPS_REG_F19, + MIPS_REG_F20, + MIPS_REG_F21, + MIPS_REG_F22, + MIPS_REG_F23, + MIPS_REG_F24, + MIPS_REG_F25, + MIPS_REG_F26, + MIPS_REG_F27, + MIPS_REG_F28, + MIPS_REG_F29, + MIPS_REG_F30, + MIPS_REG_F31, + + MIPS_REG_FCC0, + MIPS_REG_FCC1, + MIPS_REG_FCC2, + MIPS_REG_FCC3, + MIPS_REG_FCC4, + MIPS_REG_FCC5, + MIPS_REG_FCC6, + MIPS_REG_FCC7, + + // AFPR128 + MIPS_REG_W0, + MIPS_REG_W1, + MIPS_REG_W2, + MIPS_REG_W3, + MIPS_REG_W4, + MIPS_REG_W5, + MIPS_REG_W6, + MIPS_REG_W7, + MIPS_REG_W8, + MIPS_REG_W9, + MIPS_REG_W10, + MIPS_REG_W11, + MIPS_REG_W12, + MIPS_REG_W13, + MIPS_REG_W14, + MIPS_REG_W15, + MIPS_REG_W16, + MIPS_REG_W17, + MIPS_REG_W18, + MIPS_REG_W19, + MIPS_REG_W20, + MIPS_REG_W21, + MIPS_REG_W22, + MIPS_REG_W23, + MIPS_REG_W24, + MIPS_REG_W25, + MIPS_REG_W26, + MIPS_REG_W27, + MIPS_REG_W28, + MIPS_REG_W29, + MIPS_REG_W30, + MIPS_REG_W31, + + MIPS_REG_HI, + MIPS_REG_LO, + + MIPS_REG_P0, + MIPS_REG_P1, + MIPS_REG_P2, + + MIPS_REG_MPL0, + MIPS_REG_MPL1, + MIPS_REG_MPL2, + + MIPS_REG_ENDING, // <-- mark the end of the list or registers + + // alias registers + MIPS_REG_ZERO = MIPS_REG_0, + MIPS_REG_AT = MIPS_REG_1, + MIPS_REG_V0 = MIPS_REG_2, + MIPS_REG_V1 = MIPS_REG_3, + MIPS_REG_A0 = MIPS_REG_4, + MIPS_REG_A1 = MIPS_REG_5, + MIPS_REG_A2 = MIPS_REG_6, + MIPS_REG_A3 = MIPS_REG_7, + MIPS_REG_T0 = MIPS_REG_8, + MIPS_REG_T1 = MIPS_REG_9, + MIPS_REG_T2 = MIPS_REG_10, + MIPS_REG_T3 = MIPS_REG_11, + MIPS_REG_T4 = MIPS_REG_12, + MIPS_REG_T5 = MIPS_REG_13, + MIPS_REG_T6 = MIPS_REG_14, + MIPS_REG_T7 = MIPS_REG_15, + MIPS_REG_S0 = MIPS_REG_16, + MIPS_REG_S1 = MIPS_REG_17, + MIPS_REG_S2 = MIPS_REG_18, + MIPS_REG_S3 = MIPS_REG_19, + MIPS_REG_S4 = MIPS_REG_20, + MIPS_REG_S5 = MIPS_REG_21, + MIPS_REG_S6 = MIPS_REG_22, + MIPS_REG_S7 = MIPS_REG_23, + MIPS_REG_T8 = MIPS_REG_24, + MIPS_REG_T9 = MIPS_REG_25, + MIPS_REG_K0 = MIPS_REG_26, + MIPS_REG_K1 = MIPS_REG_27, + MIPS_REG_GP = MIPS_REG_28, + MIPS_REG_SP = MIPS_REG_29, + MIPS_REG_FP = MIPS_REG_30, MIPS_REG_S8 = MIPS_REG_30, + MIPS_REG_RA = MIPS_REG_31, + + MIPS_REG_HI0 = MIPS_REG_AC0, + MIPS_REG_HI1 = MIPS_REG_AC1, + MIPS_REG_HI2 = MIPS_REG_AC2, + MIPS_REG_HI3 = MIPS_REG_AC3, + + MIPS_REG_LO0 = MIPS_REG_HI0, + MIPS_REG_LO1 = MIPS_REG_HI1, + MIPS_REG_LO2 = MIPS_REG_HI2, + MIPS_REG_LO3 = MIPS_REG_HI3, +} mips_reg; + +/// Instruction's operand referring to memory +/// This is associated with MIPS_OP_MEM operand type above +typedef struct mips_op_mem { + mips_reg base; ///< base register + int64_t disp; ///< displacement/offset value +} mips_op_mem; + +/// Instruction operand +typedef struct cs_mips_op { + mips_op_type type; ///< operand type + union { + mips_reg reg; ///< register id for REG operand + int64_t imm; ///< immediate value for IMM operand + mips_op_mem mem; ///< base/index/scale/disp value for MEM operand + }; +} cs_mips_op; + +/// Instruction structure +typedef struct cs_mips { + /// Number of operands of this instruction, + /// or 0 when instruction has no operand. + uint8_t op_count; + cs_mips_op operands[10]; ///< operands for this instruction. +} cs_mips; + +/// MIPS instruction +typedef enum mips_insn { + MIPS_INS_INVALID = 0, + + MIPS_INS_ABSQ_S, + MIPS_INS_ADD, + MIPS_INS_ADDIUPC, + MIPS_INS_ADDIUR1SP, + MIPS_INS_ADDIUR2, + MIPS_INS_ADDIUS5, + MIPS_INS_ADDIUSP, + MIPS_INS_ADDQH, + MIPS_INS_ADDQH_R, + MIPS_INS_ADDQ, + MIPS_INS_ADDQ_S, + MIPS_INS_ADDSC, + MIPS_INS_ADDS_A, + MIPS_INS_ADDS_S, + MIPS_INS_ADDS_U, + MIPS_INS_ADDU16, + MIPS_INS_ADDUH, + MIPS_INS_ADDUH_R, + MIPS_INS_ADDU, + MIPS_INS_ADDU_S, + MIPS_INS_ADDVI, + MIPS_INS_ADDV, + MIPS_INS_ADDWC, + MIPS_INS_ADD_A, + MIPS_INS_ADDI, + MIPS_INS_ADDIU, + MIPS_INS_ALIGN, + MIPS_INS_ALUIPC, + MIPS_INS_AND, + MIPS_INS_AND16, + MIPS_INS_ANDI16, + MIPS_INS_ANDI, + MIPS_INS_APPEND, + MIPS_INS_ASUB_S, + MIPS_INS_ASUB_U, + MIPS_INS_AUI, + MIPS_INS_AUIPC, + MIPS_INS_AVER_S, + MIPS_INS_AVER_U, + MIPS_INS_AVE_S, + MIPS_INS_AVE_U, + MIPS_INS_B16, + MIPS_INS_BADDU, + MIPS_INS_BAL, + MIPS_INS_BALC, + MIPS_INS_BALIGN, + MIPS_INS_BBIT0, + MIPS_INS_BBIT032, + MIPS_INS_BBIT1, + MIPS_INS_BBIT132, + MIPS_INS_BC, + MIPS_INS_BC0F, + MIPS_INS_BC0FL, + MIPS_INS_BC0T, + MIPS_INS_BC0TL, + MIPS_INS_BC1EQZ, + MIPS_INS_BC1F, + MIPS_INS_BC1FL, + MIPS_INS_BC1NEZ, + MIPS_INS_BC1T, + MIPS_INS_BC1TL, + MIPS_INS_BC2EQZ, + MIPS_INS_BC2F, + MIPS_INS_BC2FL, + MIPS_INS_BC2NEZ, + MIPS_INS_BC2T, + MIPS_INS_BC2TL, + MIPS_INS_BC3F, + MIPS_INS_BC3FL, + MIPS_INS_BC3T, + MIPS_INS_BC3TL, + MIPS_INS_BCLRI, + MIPS_INS_BCLR, + MIPS_INS_BEQ, + MIPS_INS_BEQC, + MIPS_INS_BEQL, + MIPS_INS_BEQZ16, + MIPS_INS_BEQZALC, + MIPS_INS_BEQZC, + MIPS_INS_BGEC, + MIPS_INS_BGEUC, + MIPS_INS_BGEZ, + MIPS_INS_BGEZAL, + MIPS_INS_BGEZALC, + MIPS_INS_BGEZALL, + MIPS_INS_BGEZALS, + MIPS_INS_BGEZC, + MIPS_INS_BGEZL, + MIPS_INS_BGTZ, + MIPS_INS_BGTZALC, + MIPS_INS_BGTZC, + MIPS_INS_BGTZL, + MIPS_INS_BINSLI, + MIPS_INS_BINSL, + MIPS_INS_BINSRI, + MIPS_INS_BINSR, + MIPS_INS_BITREV, + MIPS_INS_BITSWAP, + MIPS_INS_BLEZ, + MIPS_INS_BLEZALC, + MIPS_INS_BLEZC, + MIPS_INS_BLEZL, + MIPS_INS_BLTC, + MIPS_INS_BLTUC, + MIPS_INS_BLTZ, + MIPS_INS_BLTZAL, + MIPS_INS_BLTZALC, + MIPS_INS_BLTZALL, + MIPS_INS_BLTZALS, + MIPS_INS_BLTZC, + MIPS_INS_BLTZL, + MIPS_INS_BMNZI, + MIPS_INS_BMNZ, + MIPS_INS_BMZI, + MIPS_INS_BMZ, + MIPS_INS_BNE, + MIPS_INS_BNEC, + MIPS_INS_BNEGI, + MIPS_INS_BNEG, + MIPS_INS_BNEL, + MIPS_INS_BNEZ16, + MIPS_INS_BNEZALC, + MIPS_INS_BNEZC, + MIPS_INS_BNVC, + MIPS_INS_BNZ, + MIPS_INS_BOVC, + MIPS_INS_BPOSGE32, + MIPS_INS_BREAK, + MIPS_INS_BREAK16, + MIPS_INS_BSELI, + MIPS_INS_BSEL, + MIPS_INS_BSETI, + MIPS_INS_BSET, + MIPS_INS_BZ, + MIPS_INS_BEQZ, + MIPS_INS_B, + MIPS_INS_BNEZ, + MIPS_INS_BTEQZ, + MIPS_INS_BTNEZ, + MIPS_INS_CACHE, + MIPS_INS_CEIL, + MIPS_INS_CEQI, + MIPS_INS_CEQ, + MIPS_INS_CFC1, + MIPS_INS_CFCMSA, + MIPS_INS_CINS, + MIPS_INS_CINS32, + MIPS_INS_CLASS, + MIPS_INS_CLEI_S, + MIPS_INS_CLEI_U, + MIPS_INS_CLE_S, + MIPS_INS_CLE_U, + MIPS_INS_CLO, + MIPS_INS_CLTI_S, + MIPS_INS_CLTI_U, + MIPS_INS_CLT_S, + MIPS_INS_CLT_U, + MIPS_INS_CLZ, + MIPS_INS_CMPGDU, + MIPS_INS_CMPGU, + MIPS_INS_CMPU, + MIPS_INS_CMP, + MIPS_INS_COPY_S, + MIPS_INS_COPY_U, + MIPS_INS_CTC1, + MIPS_INS_CTCMSA, + MIPS_INS_CVT, + MIPS_INS_C, + MIPS_INS_CMPI, + MIPS_INS_DADD, + MIPS_INS_DADDI, + MIPS_INS_DADDIU, + MIPS_INS_DADDU, + MIPS_INS_DAHI, + MIPS_INS_DALIGN, + MIPS_INS_DATI, + MIPS_INS_DAUI, + MIPS_INS_DBITSWAP, + MIPS_INS_DCLO, + MIPS_INS_DCLZ, + MIPS_INS_DDIV, + MIPS_INS_DDIVU, + MIPS_INS_DERET, + MIPS_INS_DEXT, + MIPS_INS_DEXTM, + MIPS_INS_DEXTU, + MIPS_INS_DI, + MIPS_INS_DINS, + MIPS_INS_DINSM, + MIPS_INS_DINSU, + MIPS_INS_DIV, + MIPS_INS_DIVU, + MIPS_INS_DIV_S, + MIPS_INS_DIV_U, + MIPS_INS_DLSA, + MIPS_INS_DMFC0, + MIPS_INS_DMFC1, + MIPS_INS_DMFC2, + MIPS_INS_DMOD, + MIPS_INS_DMODU, + MIPS_INS_DMTC0, + MIPS_INS_DMTC1, + MIPS_INS_DMTC2, + MIPS_INS_DMUH, + MIPS_INS_DMUHU, + MIPS_INS_DMUL, + MIPS_INS_DMULT, + MIPS_INS_DMULTU, + MIPS_INS_DMULU, + MIPS_INS_DOTP_S, + MIPS_INS_DOTP_U, + MIPS_INS_DPADD_S, + MIPS_INS_DPADD_U, + MIPS_INS_DPAQX_SA, + MIPS_INS_DPAQX_S, + MIPS_INS_DPAQ_SA, + MIPS_INS_DPAQ_S, + MIPS_INS_DPAU, + MIPS_INS_DPAX, + MIPS_INS_DPA, + MIPS_INS_DPOP, + MIPS_INS_DPSQX_SA, + MIPS_INS_DPSQX_S, + MIPS_INS_DPSQ_SA, + MIPS_INS_DPSQ_S, + MIPS_INS_DPSUB_S, + MIPS_INS_DPSUB_U, + MIPS_INS_DPSU, + MIPS_INS_DPSX, + MIPS_INS_DPS, + MIPS_INS_DROTR, + MIPS_INS_DROTR32, + MIPS_INS_DROTRV, + MIPS_INS_DSBH, + MIPS_INS_DSHD, + MIPS_INS_DSLL, + MIPS_INS_DSLL32, + MIPS_INS_DSLLV, + MIPS_INS_DSRA, + MIPS_INS_DSRA32, + MIPS_INS_DSRAV, + MIPS_INS_DSRL, + MIPS_INS_DSRL32, + MIPS_INS_DSRLV, + MIPS_INS_DSUB, + MIPS_INS_DSUBU, + MIPS_INS_EHB, + MIPS_INS_EI, + MIPS_INS_ERET, + MIPS_INS_EXT, + MIPS_INS_EXTP, + MIPS_INS_EXTPDP, + MIPS_INS_EXTPDPV, + MIPS_INS_EXTPV, + MIPS_INS_EXTRV_RS, + MIPS_INS_EXTRV_R, + MIPS_INS_EXTRV_S, + MIPS_INS_EXTRV, + MIPS_INS_EXTR_RS, + MIPS_INS_EXTR_R, + MIPS_INS_EXTR_S, + MIPS_INS_EXTR, + MIPS_INS_EXTS, + MIPS_INS_EXTS32, + MIPS_INS_ABS, + MIPS_INS_FADD, + MIPS_INS_FCAF, + MIPS_INS_FCEQ, + MIPS_INS_FCLASS, + MIPS_INS_FCLE, + MIPS_INS_FCLT, + MIPS_INS_FCNE, + MIPS_INS_FCOR, + MIPS_INS_FCUEQ, + MIPS_INS_FCULE, + MIPS_INS_FCULT, + MIPS_INS_FCUNE, + MIPS_INS_FCUN, + MIPS_INS_FDIV, + MIPS_INS_FEXDO, + MIPS_INS_FEXP2, + MIPS_INS_FEXUPL, + MIPS_INS_FEXUPR, + MIPS_INS_FFINT_S, + MIPS_INS_FFINT_U, + MIPS_INS_FFQL, + MIPS_INS_FFQR, + MIPS_INS_FILL, + MIPS_INS_FLOG2, + MIPS_INS_FLOOR, + MIPS_INS_FMADD, + MIPS_INS_FMAX_A, + MIPS_INS_FMAX, + MIPS_INS_FMIN_A, + MIPS_INS_FMIN, + MIPS_INS_MOV, + MIPS_INS_FMSUB, + MIPS_INS_FMUL, + MIPS_INS_MUL, + MIPS_INS_NEG, + MIPS_INS_FRCP, + MIPS_INS_FRINT, + MIPS_INS_FRSQRT, + MIPS_INS_FSAF, + MIPS_INS_FSEQ, + MIPS_INS_FSLE, + MIPS_INS_FSLT, + MIPS_INS_FSNE, + MIPS_INS_FSOR, + MIPS_INS_FSQRT, + MIPS_INS_SQRT, + MIPS_INS_FSUB, + MIPS_INS_SUB, + MIPS_INS_FSUEQ, + MIPS_INS_FSULE, + MIPS_INS_FSULT, + MIPS_INS_FSUNE, + MIPS_INS_FSUN, + MIPS_INS_FTINT_S, + MIPS_INS_FTINT_U, + MIPS_INS_FTQ, + MIPS_INS_FTRUNC_S, + MIPS_INS_FTRUNC_U, + MIPS_INS_HADD_S, + MIPS_INS_HADD_U, + MIPS_INS_HSUB_S, + MIPS_INS_HSUB_U, + MIPS_INS_ILVEV, + MIPS_INS_ILVL, + MIPS_INS_ILVOD, + MIPS_INS_ILVR, + MIPS_INS_INS, + MIPS_INS_INSERT, + MIPS_INS_INSV, + MIPS_INS_INSVE, + MIPS_INS_J, + MIPS_INS_JAL, + MIPS_INS_JALR, + MIPS_INS_JALRS16, + MIPS_INS_JALRS, + MIPS_INS_JALS, + MIPS_INS_JALX, + MIPS_INS_JIALC, + MIPS_INS_JIC, + MIPS_INS_JR, + MIPS_INS_JR16, + MIPS_INS_JRADDIUSP, + MIPS_INS_JRC, + MIPS_INS_JALRC, + MIPS_INS_LB, + MIPS_INS_LBU16, + MIPS_INS_LBUX, + MIPS_INS_LBU, + MIPS_INS_LD, + MIPS_INS_LDC1, + MIPS_INS_LDC2, + MIPS_INS_LDC3, + MIPS_INS_LDI, + MIPS_INS_LDL, + MIPS_INS_LDPC, + MIPS_INS_LDR, + MIPS_INS_LDXC1, + MIPS_INS_LH, + MIPS_INS_LHU16, + MIPS_INS_LHX, + MIPS_INS_LHU, + MIPS_INS_LI16, + MIPS_INS_LL, + MIPS_INS_LLD, + MIPS_INS_LSA, + MIPS_INS_LUXC1, + MIPS_INS_LUI, + MIPS_INS_LW, + MIPS_INS_LW16, + MIPS_INS_LWC1, + MIPS_INS_LWC2, + MIPS_INS_LWC3, + MIPS_INS_LWL, + MIPS_INS_LWM16, + MIPS_INS_LWM32, + MIPS_INS_LWPC, + MIPS_INS_LWP, + MIPS_INS_LWR, + MIPS_INS_LWUPC, + MIPS_INS_LWU, + MIPS_INS_LWX, + MIPS_INS_LWXC1, + MIPS_INS_LWXS, + MIPS_INS_LI, + MIPS_INS_MADD, + MIPS_INS_MADDF, + MIPS_INS_MADDR_Q, + MIPS_INS_MADDU, + MIPS_INS_MADDV, + MIPS_INS_MADD_Q, + MIPS_INS_MAQ_SA, + MIPS_INS_MAQ_S, + MIPS_INS_MAXA, + MIPS_INS_MAXI_S, + MIPS_INS_MAXI_U, + MIPS_INS_MAX_A, + MIPS_INS_MAX, + MIPS_INS_MAX_S, + MIPS_INS_MAX_U, + MIPS_INS_MFC0, + MIPS_INS_MFC1, + MIPS_INS_MFC2, + MIPS_INS_MFHC1, + MIPS_INS_MFHI, + MIPS_INS_MFLO, + MIPS_INS_MINA, + MIPS_INS_MINI_S, + MIPS_INS_MINI_U, + MIPS_INS_MIN_A, + MIPS_INS_MIN, + MIPS_INS_MIN_S, + MIPS_INS_MIN_U, + MIPS_INS_MOD, + MIPS_INS_MODSUB, + MIPS_INS_MODU, + MIPS_INS_MOD_S, + MIPS_INS_MOD_U, + MIPS_INS_MOVE, + MIPS_INS_MOVEP, + MIPS_INS_MOVF, + MIPS_INS_MOVN, + MIPS_INS_MOVT, + MIPS_INS_MOVZ, + MIPS_INS_MSUB, + MIPS_INS_MSUBF, + MIPS_INS_MSUBR_Q, + MIPS_INS_MSUBU, + MIPS_INS_MSUBV, + MIPS_INS_MSUB_Q, + MIPS_INS_MTC0, + MIPS_INS_MTC1, + MIPS_INS_MTC2, + MIPS_INS_MTHC1, + MIPS_INS_MTHI, + MIPS_INS_MTHLIP, + MIPS_INS_MTLO, + MIPS_INS_MTM0, + MIPS_INS_MTM1, + MIPS_INS_MTM2, + MIPS_INS_MTP0, + MIPS_INS_MTP1, + MIPS_INS_MTP2, + MIPS_INS_MUH, + MIPS_INS_MUHU, + MIPS_INS_MULEQ_S, + MIPS_INS_MULEU_S, + MIPS_INS_MULQ_RS, + MIPS_INS_MULQ_S, + MIPS_INS_MULR_Q, + MIPS_INS_MULSAQ_S, + MIPS_INS_MULSA, + MIPS_INS_MULT, + MIPS_INS_MULTU, + MIPS_INS_MULU, + MIPS_INS_MULV, + MIPS_INS_MUL_Q, + MIPS_INS_MUL_S, + MIPS_INS_NLOC, + MIPS_INS_NLZC, + MIPS_INS_NMADD, + MIPS_INS_NMSUB, + MIPS_INS_NOR, + MIPS_INS_NORI, + MIPS_INS_NOT16, + MIPS_INS_NOT, + MIPS_INS_OR, + MIPS_INS_OR16, + MIPS_INS_ORI, + MIPS_INS_PACKRL, + MIPS_INS_PAUSE, + MIPS_INS_PCKEV, + MIPS_INS_PCKOD, + MIPS_INS_PCNT, + MIPS_INS_PICK, + MIPS_INS_POP, + MIPS_INS_PRECEQU, + MIPS_INS_PRECEQ, + MIPS_INS_PRECEU, + MIPS_INS_PRECRQU_S, + MIPS_INS_PRECRQ, + MIPS_INS_PRECRQ_RS, + MIPS_INS_PRECR, + MIPS_INS_PRECR_SRA, + MIPS_INS_PRECR_SRA_R, + MIPS_INS_PREF, + MIPS_INS_PREPEND, + MIPS_INS_RADDU, + MIPS_INS_RDDSP, + MIPS_INS_RDHWR, + MIPS_INS_REPLV, + MIPS_INS_REPL, + MIPS_INS_RINT, + MIPS_INS_ROTR, + MIPS_INS_ROTRV, + MIPS_INS_ROUND, + MIPS_INS_SAT_S, + MIPS_INS_SAT_U, + MIPS_INS_SB, + MIPS_INS_SB16, + MIPS_INS_SC, + MIPS_INS_SCD, + MIPS_INS_SD, + MIPS_INS_SDBBP, + MIPS_INS_SDBBP16, + MIPS_INS_SDC1, + MIPS_INS_SDC2, + MIPS_INS_SDC3, + MIPS_INS_SDL, + MIPS_INS_SDR, + MIPS_INS_SDXC1, + MIPS_INS_SEB, + MIPS_INS_SEH, + MIPS_INS_SELEQZ, + MIPS_INS_SELNEZ, + MIPS_INS_SEL, + MIPS_INS_SEQ, + MIPS_INS_SEQI, + MIPS_INS_SH, + MIPS_INS_SH16, + MIPS_INS_SHF, + MIPS_INS_SHILO, + MIPS_INS_SHILOV, + MIPS_INS_SHLLV, + MIPS_INS_SHLLV_S, + MIPS_INS_SHLL, + MIPS_INS_SHLL_S, + MIPS_INS_SHRAV, + MIPS_INS_SHRAV_R, + MIPS_INS_SHRA, + MIPS_INS_SHRA_R, + MIPS_INS_SHRLV, + MIPS_INS_SHRL, + MIPS_INS_SLDI, + MIPS_INS_SLD, + MIPS_INS_SLL, + MIPS_INS_SLL16, + MIPS_INS_SLLI, + MIPS_INS_SLLV, + MIPS_INS_SLT, + MIPS_INS_SLTI, + MIPS_INS_SLTIU, + MIPS_INS_SLTU, + MIPS_INS_SNE, + MIPS_INS_SNEI, + MIPS_INS_SPLATI, + MIPS_INS_SPLAT, + MIPS_INS_SRA, + MIPS_INS_SRAI, + MIPS_INS_SRARI, + MIPS_INS_SRAR, + MIPS_INS_SRAV, + MIPS_INS_SRL, + MIPS_INS_SRL16, + MIPS_INS_SRLI, + MIPS_INS_SRLRI, + MIPS_INS_SRLR, + MIPS_INS_SRLV, + MIPS_INS_SSNOP, + MIPS_INS_ST, + MIPS_INS_SUBQH, + MIPS_INS_SUBQH_R, + MIPS_INS_SUBQ, + MIPS_INS_SUBQ_S, + MIPS_INS_SUBSUS_U, + MIPS_INS_SUBSUU_S, + MIPS_INS_SUBS_S, + MIPS_INS_SUBS_U, + MIPS_INS_SUBU16, + MIPS_INS_SUBUH, + MIPS_INS_SUBUH_R, + MIPS_INS_SUBU, + MIPS_INS_SUBU_S, + MIPS_INS_SUBVI, + MIPS_INS_SUBV, + MIPS_INS_SUXC1, + MIPS_INS_SW, + MIPS_INS_SW16, + MIPS_INS_SWC1, + MIPS_INS_SWC2, + MIPS_INS_SWC3, + MIPS_INS_SWL, + MIPS_INS_SWM16, + MIPS_INS_SWM32, + MIPS_INS_SWP, + MIPS_INS_SWR, + MIPS_INS_SWXC1, + MIPS_INS_SYNC, + MIPS_INS_SYNCI, + MIPS_INS_SYSCALL, + MIPS_INS_TEQ, + MIPS_INS_TEQI, + MIPS_INS_TGE, + MIPS_INS_TGEI, + MIPS_INS_TGEIU, + MIPS_INS_TGEU, + MIPS_INS_TLBP, + MIPS_INS_TLBR, + MIPS_INS_TLBWI, + MIPS_INS_TLBWR, + MIPS_INS_TLT, + MIPS_INS_TLTI, + MIPS_INS_TLTIU, + MIPS_INS_TLTU, + MIPS_INS_TNE, + MIPS_INS_TNEI, + MIPS_INS_TRUNC, + MIPS_INS_V3MULU, + MIPS_INS_VMM0, + MIPS_INS_VMULU, + MIPS_INS_VSHF, + MIPS_INS_WAIT, + MIPS_INS_WRDSP, + MIPS_INS_WSBH, + MIPS_INS_XOR, + MIPS_INS_XOR16, + MIPS_INS_XORI, + + //> some alias instructions + MIPS_INS_NOP, + MIPS_INS_NEGU, + + //> special instructions + MIPS_INS_JALR_HB, // jump and link with Hazard Barrier + MIPS_INS_JR_HB, // jump register with Hazard Barrier + + MIPS_INS_ENDING, +} mips_insn; + +/// Group of MIPS instructions +typedef enum mips_insn_group { + MIPS_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + // Generic groups + // all jump instructions (conditional+direct+indirect jumps) + MIPS_GRP_JUMP, ///< = CS_GRP_JUMP + // all call instructions + MIPS_GRP_CALL, ///< = CS_GRP_CALL + // all return instructions + MIPS_GRP_RET, ///< = CS_GRP_RET + // all interrupt instructions (int+syscall) + MIPS_GRP_INT, ///< = CS_GRP_INT + // all interrupt return instructions + MIPS_GRP_IRET, ///< = CS_GRP_IRET + // all privileged instructions + MIPS_GRP_PRIVILEGE, ///< = CS_GRP_PRIVILEGE + // all relative branching instructions + MIPS_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE + + // Architecture-specific groups + MIPS_GRP_BITCOUNT = 128, + MIPS_GRP_DSP, + MIPS_GRP_DSPR2, + MIPS_GRP_FPIDX, + MIPS_GRP_MSA, + MIPS_GRP_MIPS32R2, + MIPS_GRP_MIPS64, + MIPS_GRP_MIPS64R2, + MIPS_GRP_SEINREG, + MIPS_GRP_STDENC, + MIPS_GRP_SWAP, + MIPS_GRP_MICROMIPS, + MIPS_GRP_MIPS16MODE, + MIPS_GRP_FP64BIT, + MIPS_GRP_NONANSFPMATH, + MIPS_GRP_NOTFP64BIT, + MIPS_GRP_NOTINMICROMIPS, + MIPS_GRP_NOTNACL, + MIPS_GRP_NOTMIPS32R6, + MIPS_GRP_NOTMIPS64R6, + MIPS_GRP_CNMIPS, + MIPS_GRP_MIPS32, + MIPS_GRP_MIPS32R6, + MIPS_GRP_MIPS64R6, + MIPS_GRP_MIPS2, + MIPS_GRP_MIPS3, + MIPS_GRP_MIPS3_32, + MIPS_GRP_MIPS3_32R2, + MIPS_GRP_MIPS4_32, + MIPS_GRP_MIPS4_32R2, + MIPS_GRP_MIPS5_32R2, + MIPS_GRP_GP32BIT, + MIPS_GRP_GP64BIT, + + MIPS_GRP_ENDING, +} mips_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_PPC_H +#define CAPSTONE_PPC_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2013-2015 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// PPC branch codes for some branch instructions +typedef enum ppc_bc { + PPC_BC_INVALID = 0, + PPC_BC_LT = (0 << 5) | 12, + PPC_BC_LE = (1 << 5) | 4, + PPC_BC_EQ = (2 << 5) | 12, + PPC_BC_GE = (0 << 5) | 4, + PPC_BC_GT = (1 << 5) | 12, + PPC_BC_NE = (2 << 5) | 4, + PPC_BC_UN = (3 << 5) | 12, + PPC_BC_NU = (3 << 5) | 4, + + // extra conditions + PPC_BC_SO = (4 << 5) | 12, ///< summary overflow + PPC_BC_NS = (4 << 5) | 4, ///< not summary overflow +} ppc_bc; + +/// PPC branch hint for some branch instructions +typedef enum ppc_bh { + PPC_BH_INVALID = 0, ///< no hint + PPC_BH_PLUS, ///< PLUS hint + PPC_BH_MINUS, ///< MINUS hint +} ppc_bh; + +/// Operand type for instruction's operands +typedef enum ppc_op_type { + PPC_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + PPC_OP_REG, ///< = CS_OP_REG (Register operand). + PPC_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + PPC_OP_MEM, ///< = CS_OP_MEM (Memory operand). + PPC_OP_CRX = 64, ///< Condition Register field +} ppc_op_type; + +/// PPC registers +typedef enum ppc_reg { + PPC_REG_INVALID = 0, + + PPC_REG_CARRY = 2, + PPC_REG_CTR = 3, + PPC_REG_LR = 5, + PPC_REG_RM = 6, + PPC_REG_VRSAVE = 8, + PPC_REG_XER = 9, + PPC_REG_ZERO = 10, + PPC_REG_CR0 = 12, + PPC_REG_CR1 = 13, + PPC_REG_CR2 = 14, + PPC_REG_CR3 = 15, + PPC_REG_CR4 = 16, + PPC_REG_CR5 = 17, + PPC_REG_CR6 = 18, + PPC_REG_CR7 = 19, + PPC_REG_CTR8 = 20, + PPC_REG_F0 = 21, + PPC_REG_F1 = 22, + PPC_REG_F2 = 23, + PPC_REG_F3 = 24, + PPC_REG_F4 = 25, + PPC_REG_F5 = 26, + PPC_REG_F6 = 27, + PPC_REG_F7 = 28, + PPC_REG_F8 = 29, + PPC_REG_F9 = 30, + PPC_REG_F10 = 31, + PPC_REG_F11 = 32, + PPC_REG_F12 = 33, + PPC_REG_F13 = 34, + PPC_REG_F14 = 35, + PPC_REG_F15 = 36, + PPC_REG_F16 = 37, + PPC_REG_F17 = 38, + PPC_REG_F18 = 39, + PPC_REG_F19 = 40, + PPC_REG_F20 = 41, + PPC_REG_F21 = 42, + PPC_REG_F22 = 43, + PPC_REG_F23 = 44, + PPC_REG_F24 = 45, + PPC_REG_F25 = 46, + PPC_REG_F26 = 47, + PPC_REG_F27 = 48, + PPC_REG_F28 = 49, + PPC_REG_F29 = 50, + PPC_REG_F30 = 51, + PPC_REG_F31 = 52, + PPC_REG_LR8 = 54, + PPC_REG_Q0 = 55, + PPC_REG_Q1 = 56, + PPC_REG_Q2 = 57, + PPC_REG_Q3 = 58, + PPC_REG_Q4 = 59, + PPC_REG_Q5 = 60, + PPC_REG_Q6 = 61, + PPC_REG_Q7 = 62, + PPC_REG_Q8 = 63, + PPC_REG_Q9 = 64, + PPC_REG_Q10 = 65, + PPC_REG_Q11 = 66, + PPC_REG_Q12 = 67, + PPC_REG_Q13 = 68, + PPC_REG_Q14 = 69, + PPC_REG_Q15 = 70, + PPC_REG_Q16 = 71, + PPC_REG_Q17 = 72, + PPC_REG_Q18 = 73, + PPC_REG_Q19 = 74, + PPC_REG_Q20 = 75, + PPC_REG_Q21 = 76, + PPC_REG_Q22 = 77, + PPC_REG_Q23 = 78, + PPC_REG_Q24 = 79, + PPC_REG_Q25 = 80, + PPC_REG_Q26 = 81, + PPC_REG_Q27 = 82, + PPC_REG_Q28 = 83, + PPC_REG_Q29 = 84, + PPC_REG_Q30 = 85, + PPC_REG_Q31 = 86, + PPC_REG_R0 = 87, + PPC_REG_R1 = 88, + PPC_REG_R2 = 89, + PPC_REG_R3 = 90, + PPC_REG_R4 = 91, + PPC_REG_R5 = 92, + PPC_REG_R6 = 93, + PPC_REG_R7 = 94, + PPC_REG_R8 = 95, + PPC_REG_R9 = 96, + PPC_REG_R10 = 97, + PPC_REG_R11 = 98, + PPC_REG_R12 = 99, + PPC_REG_R13 = 100, + PPC_REG_R14 = 101, + PPC_REG_R15 = 102, + PPC_REG_R16 = 103, + PPC_REG_R17 = 104, + PPC_REG_R18 = 105, + PPC_REG_R19 = 106, + PPC_REG_R20 = 107, + PPC_REG_R21 = 108, + PPC_REG_R22 = 109, + PPC_REG_R23 = 110, + PPC_REG_R24 = 111, + PPC_REG_R25 = 112, + PPC_REG_R26 = 113, + PPC_REG_R27 = 114, + PPC_REG_R28 = 115, + PPC_REG_R29 = 116, + PPC_REG_R30 = 117, + PPC_REG_R31 = 118, + PPC_REG_V0 = 151, + PPC_REG_V1 = 152, + PPC_REG_V2 = 153, + PPC_REG_V3 = 154, + PPC_REG_V4 = 155, + PPC_REG_V5 = 156, + PPC_REG_V6 = 157, + PPC_REG_V7 = 158, + PPC_REG_V8 = 159, + PPC_REG_V9 = 160, + PPC_REG_V10 = 161, + PPC_REG_V11 = 162, + PPC_REG_V12 = 163, + PPC_REG_V13 = 164, + PPC_REG_V14 = 165, + PPC_REG_V15 = 166, + PPC_REG_V16 = 167, + PPC_REG_V17 = 168, + PPC_REG_V18 = 169, + PPC_REG_V19 = 170, + PPC_REG_V20 = 171, + PPC_REG_V21 = 172, + PPC_REG_V22 = 173, + PPC_REG_V23 = 174, + PPC_REG_V24 = 175, + PPC_REG_V25 = 176, + PPC_REG_V26 = 177, + PPC_REG_V27 = 178, + PPC_REG_V28 = 179, + PPC_REG_V29 = 180, + PPC_REG_V30 = 181, + PPC_REG_V31 = 182, + PPC_REG_VS0 = 215, + PPC_REG_VS1 = 216, + PPC_REG_VS2 = 217, + PPC_REG_VS3 = 218, + PPC_REG_VS4 = 219, + PPC_REG_VS5 = 220, + PPC_REG_VS6 = 221, + PPC_REG_VS7 = 222, + PPC_REG_VS8 = 223, + PPC_REG_VS9 = 224, + PPC_REG_VS10 = 225, + PPC_REG_VS11 = 226, + PPC_REG_VS12 = 227, + PPC_REG_VS13 = 228, + PPC_REG_VS14 = 229, + PPC_REG_VS15 = 230, + PPC_REG_VS16 = 231, + PPC_REG_VS17 = 232, + PPC_REG_VS18 = 233, + PPC_REG_VS19 = 234, + PPC_REG_VS20 = 235, + PPC_REG_VS21 = 236, + PPC_REG_VS22 = 237, + PPC_REG_VS23 = 238, + PPC_REG_VS24 = 239, + PPC_REG_VS25 = 240, + PPC_REG_VS26 = 241, + PPC_REG_VS27 = 242, + PPC_REG_VS28 = 243, + PPC_REG_VS29 = 244, + PPC_REG_VS30 = 245, + PPC_REG_VS31 = 246, + PPC_REG_VS32 = 247, + PPC_REG_VS33 = 248, + PPC_REG_VS34 = 249, + PPC_REG_VS35 = 250, + PPC_REG_VS36 = 251, + PPC_REG_VS37 = 252, + PPC_REG_VS38 = 253, + PPC_REG_VS39 = 254, + PPC_REG_VS40 = 255, + PPC_REG_VS41 = 256, + PPC_REG_VS42 = 257, + PPC_REG_VS43 = 258, + PPC_REG_VS44 = 259, + PPC_REG_VS45 = 260, + PPC_REG_VS46 = 261, + PPC_REG_VS47 = 262, + PPC_REG_VS48 = 263, + PPC_REG_VS49 = 264, + PPC_REG_VS50 = 265, + PPC_REG_VS51 = 266, + PPC_REG_VS52 = 267, + PPC_REG_VS53 = 268, + PPC_REG_VS54 = 269, + PPC_REG_VS55 = 270, + PPC_REG_VS56 = 271, + PPC_REG_VS57 = 272, + PPC_REG_VS58 = 273, + PPC_REG_VS59 = 274, + PPC_REG_VS60 = 275, + PPC_REG_VS61 = 276, + PPC_REG_VS62 = 277, + PPC_REG_VS63 = 278, + + PPC_REG_CR0EQ = 312, + PPC_REG_CR1EQ = 313, + PPC_REG_CR2EQ = 314, + PPC_REG_CR3EQ = 315, + PPC_REG_CR4EQ = 316, + PPC_REG_CR5EQ = 317, + PPC_REG_CR6EQ = 318, + PPC_REG_CR7EQ = 319, + PPC_REG_CR0GT = 320, + PPC_REG_CR1GT = 321, + PPC_REG_CR2GT = 322, + PPC_REG_CR3GT = 323, + PPC_REG_CR4GT = 324, + PPC_REG_CR5GT = 325, + PPC_REG_CR6GT = 326, + PPC_REG_CR7GT = 327, + PPC_REG_CR0LT = 328, + PPC_REG_CR1LT = 329, + PPC_REG_CR2LT = 330, + PPC_REG_CR3LT = 331, + PPC_REG_CR4LT = 332, + PPC_REG_CR5LT = 333, + PPC_REG_CR6LT = 334, + PPC_REG_CR7LT = 335, + PPC_REG_CR0UN = 336, + PPC_REG_CR1UN = 337, + PPC_REG_CR2UN = 338, + PPC_REG_CR3UN = 339, + PPC_REG_CR4UN = 340, + PPC_REG_CR5UN = 341, + PPC_REG_CR6UN = 342, + PPC_REG_CR7UN = 343, + + PPC_REG_ENDING, // <-- mark the end of the list of registers +} ppc_reg; + +/// Instruction's operand referring to memory +/// This is associated with PPC_OP_MEM operand type above +typedef struct ppc_op_mem { + ppc_reg base; ///< base register + int32_t disp; ///< displacement/offset value +} ppc_op_mem; + +typedef struct ppc_op_crx { + unsigned int scale; + ppc_reg reg; + ppc_bc cond; +} ppc_op_crx; + +/// Instruction operand +typedef struct cs_ppc_op { + ppc_op_type type; ///< operand type + union { + ppc_reg reg; ///< register value for REG operand + int64_t imm; ///< immediate value for IMM operand + ppc_op_mem mem; ///< base/disp value for MEM operand + ppc_op_crx crx; ///< operand with condition register + }; +} cs_ppc_op; + +/// Instruction structure +typedef struct cs_ppc { + /// branch code for branch instructions + ppc_bc bc; + + /// branch hint for branch instructions + ppc_bh bh; + + /// if update_cr0 = True, then this 'dot' insn updates CR0 + bool update_cr0; + + /// Number of operands of this instruction, + /// or 0 when instruction has no operand. + uint8_t op_count; + cs_ppc_op operands[8]; ///< operands for this instruction. +} cs_ppc; + +/// PPC instruction +typedef enum ppc_insn { + PPC_INS_INVALID = 0, + + PPC_INS_ADD, + PPC_INS_ADDC, + PPC_INS_ADDE, + PPC_INS_ADDI, + PPC_INS_ADDIC, + PPC_INS_ADDIS, + PPC_INS_ADDME, + PPC_INS_ADDPCIS, + PPC_INS_ADDZE, + PPC_INS_AND, + PPC_INS_ANDC, + PPC_INS_ANDI, + PPC_INS_ANDIS, + PPC_INS_ATTN, + PPC_INS_B, + PPC_INS_BA, + PPC_INS_BC, + PPC_INS_BCA, + PPC_INS_BCCTR, + PPC_INS_BCCTRL, + PPC_INS_BCDCFN, + PPC_INS_BCDCFSQ, + PPC_INS_BCDCFZ, + PPC_INS_BCDCPSGN, + PPC_INS_BCDCTN, + PPC_INS_BCDCTSQ, + PPC_INS_BCDCTZ, + PPC_INS_BCDS, + PPC_INS_BCDSETSGN, + PPC_INS_BCDSR, + PPC_INS_BCDTRUNC, + PPC_INS_BCDUS, + PPC_INS_BCDUTRUNC, + PPC_INS_BCL, + PPC_INS_BCLA, + PPC_INS_BCLR, + PPC_INS_BCLRL, + PPC_INS_BCTR, + PPC_INS_BCTRL, + PPC_INS_BDNZ, + PPC_INS_BDNZA, + PPC_INS_BDNZF, + PPC_INS_BDNZFA, + PPC_INS_BDNZFL, + PPC_INS_BDNZFLA, + PPC_INS_BDNZFLR, + PPC_INS_BDNZFLRL, + PPC_INS_BDNZL, + PPC_INS_BDNZLA, + PPC_INS_BDNZLR, + PPC_INS_BDNZLRL, + PPC_INS_BDNZT, + PPC_INS_BDNZTA, + PPC_INS_BDNZTL, + PPC_INS_BDNZTLA, + PPC_INS_BDNZTLR, + PPC_INS_BDNZTLRL, + PPC_INS_BDZ, + PPC_INS_BDZA, + PPC_INS_BDZF, + PPC_INS_BDZFA, + PPC_INS_BDZFL, + PPC_INS_BDZFLA, + PPC_INS_BDZFLR, + PPC_INS_BDZFLRL, + PPC_INS_BDZL, + PPC_INS_BDZLA, + PPC_INS_BDZLR, + PPC_INS_BDZLRL, + PPC_INS_BDZT, + PPC_INS_BDZTA, + PPC_INS_BDZTL, + PPC_INS_BDZTLA, + PPC_INS_BDZTLR, + PPC_INS_BDZTLRL, + PPC_INS_BEQ, + PPC_INS_BEQA, + PPC_INS_BEQCTR, + PPC_INS_BEQCTRL, + PPC_INS_BEQL, + PPC_INS_BEQLA, + PPC_INS_BEQLR, + PPC_INS_BEQLRL, + PPC_INS_BF, + PPC_INS_BFA, + PPC_INS_BFCTR, + PPC_INS_BFCTRL, + PPC_INS_BFL, + PPC_INS_BFLA, + PPC_INS_BFLR, + PPC_INS_BFLRL, + PPC_INS_BGE, + PPC_INS_BGEA, + PPC_INS_BGECTR, + PPC_INS_BGECTRL, + PPC_INS_BGEL, + PPC_INS_BGELA, + PPC_INS_BGELR, + PPC_INS_BGELRL, + PPC_INS_BGT, + PPC_INS_BGTA, + PPC_INS_BGTCTR, + PPC_INS_BGTCTRL, + PPC_INS_BGTL, + PPC_INS_BGTLA, + PPC_INS_BGTLR, + PPC_INS_BGTLRL, + PPC_INS_BL, + PPC_INS_BLA, + PPC_INS_BLE, + PPC_INS_BLEA, + PPC_INS_BLECTR, + PPC_INS_BLECTRL, + PPC_INS_BLEL, + PPC_INS_BLELA, + PPC_INS_BLELR, + PPC_INS_BLELRL, + PPC_INS_BLR, + PPC_INS_BLRL, + PPC_INS_BLT, + PPC_INS_BLTA, + PPC_INS_BLTCTR, + PPC_INS_BLTCTRL, + PPC_INS_BLTL, + PPC_INS_BLTLA, + PPC_INS_BLTLR, + PPC_INS_BLTLRL, + PPC_INS_BNE, + PPC_INS_BNEA, + PPC_INS_BNECTR, + PPC_INS_BNECTRL, + PPC_INS_BNEL, + PPC_INS_BNELA, + PPC_INS_BNELR, + PPC_INS_BNELRL, + PPC_INS_BNG, + PPC_INS_BNGA, + PPC_INS_BNGCTR, + PPC_INS_BNGCTRL, + PPC_INS_BNGL, + PPC_INS_BNGLA, + PPC_INS_BNGLR, + PPC_INS_BNGLRL, + PPC_INS_BNL, + PPC_INS_BNLA, + PPC_INS_BNLCTR, + PPC_INS_BNLCTRL, + PPC_INS_BNLL, + PPC_INS_BNLLA, + PPC_INS_BNLLR, + PPC_INS_BNLLRL, + PPC_INS_BNS, + PPC_INS_BNSA, + PPC_INS_BNSCTR, + PPC_INS_BNSCTRL, + PPC_INS_BNSL, + PPC_INS_BNSLA, + PPC_INS_BNSLR, + PPC_INS_BNSLRL, + PPC_INS_BNU, + PPC_INS_BNUA, + PPC_INS_BNUCTR, + PPC_INS_BNUCTRL, + PPC_INS_BNUL, + PPC_INS_BNULA, + PPC_INS_BNULR, + PPC_INS_BNULRL, + PPC_INS_BPERMD, + PPC_INS_BRINC, + PPC_INS_BSO, + PPC_INS_BSOA, + PPC_INS_BSOCTR, + PPC_INS_BSOCTRL, + PPC_INS_BSOL, + PPC_INS_BSOLA, + PPC_INS_BSOLR, + PPC_INS_BSOLRL, + PPC_INS_BT, + PPC_INS_BTA, + PPC_INS_BTCTR, + PPC_INS_BTCTRL, + PPC_INS_BTL, + PPC_INS_BTLA, + PPC_INS_BTLR, + PPC_INS_BTLRL, + PPC_INS_BUN, + PPC_INS_BUNA, + PPC_INS_BUNCTR, + PPC_INS_BUNCTRL, + PPC_INS_BUNL, + PPC_INS_BUNLA, + PPC_INS_BUNLR, + PPC_INS_BUNLRL, + PPC_INS_CLRBHRB, + PPC_INS_CLRLDI, + PPC_INS_CLRLSLDI, + PPC_INS_CLRLSLWI, + PPC_INS_CLRLWI, + PPC_INS_CLRRDI, + PPC_INS_CLRRWI, + PPC_INS_CMP, + PPC_INS_CMPB, + PPC_INS_CMPD, + PPC_INS_CMPDI, + PPC_INS_CMPEQB, + PPC_INS_CMPI, + PPC_INS_CMPL, + PPC_INS_CMPLD, + PPC_INS_CMPLDI, + PPC_INS_CMPLI, + PPC_INS_CMPLW, + PPC_INS_CMPLWI, + PPC_INS_CMPRB, + PPC_INS_CMPW, + PPC_INS_CMPWI, + PPC_INS_CNTLZD, + PPC_INS_CNTLZW, + PPC_INS_CNTTZD, + PPC_INS_CNTTZW, + PPC_INS_COPY, + PPC_INS_COPY_FIRST, + PPC_INS_CP_ABORT, + PPC_INS_CRAND, + PPC_INS_CRANDC, + PPC_INS_CRCLR, + PPC_INS_CREQV, + PPC_INS_CRMOVE, + PPC_INS_CRNAND, + PPC_INS_CRNOR, + PPC_INS_CRNOT, + PPC_INS_CROR, + PPC_INS_CRORC, + PPC_INS_CRSET, + PPC_INS_CRXOR, + PPC_INS_DARN, + PPC_INS_DCBA, + PPC_INS_DCBF, + PPC_INS_DCBFEP, + PPC_INS_DCBFL, + PPC_INS_DCBFLP, + PPC_INS_DCBI, + PPC_INS_DCBST, + PPC_INS_DCBSTEP, + PPC_INS_DCBT, + PPC_INS_DCBTCT, + PPC_INS_DCBTDS, + PPC_INS_DCBTEP, + PPC_INS_DCBTST, + PPC_INS_DCBTSTCT, + PPC_INS_DCBTSTDS, + PPC_INS_DCBTSTEP, + PPC_INS_DCBTSTT, + PPC_INS_DCBTT, + PPC_INS_DCBZ, + PPC_INS_DCBZEP, + PPC_INS_DCBZL, + PPC_INS_DCBZLEP, + PPC_INS_DCCCI, + PPC_INS_DCI, + PPC_INS_DIVD, + PPC_INS_DIVDE, + PPC_INS_DIVDEU, + PPC_INS_DIVDU, + PPC_INS_DIVW, + PPC_INS_DIVWE, + PPC_INS_DIVWEU, + PPC_INS_DIVWU, + PPC_INS_DSS, + PPC_INS_DSSALL, + PPC_INS_DST, + PPC_INS_DSTST, + PPC_INS_DSTSTT, + PPC_INS_DSTT, + PPC_INS_EFDABS, + PPC_INS_EFDADD, + PPC_INS_EFDCFS, + PPC_INS_EFDCFSF, + PPC_INS_EFDCFSI, + PPC_INS_EFDCFSID, + PPC_INS_EFDCFUF, + PPC_INS_EFDCFUI, + PPC_INS_EFDCFUID, + PPC_INS_EFDCMPEQ, + PPC_INS_EFDCMPGT, + PPC_INS_EFDCMPLT, + PPC_INS_EFDCTSF, + PPC_INS_EFDCTSI, + PPC_INS_EFDCTSIDZ, + PPC_INS_EFDCTSIZ, + PPC_INS_EFDCTUF, + PPC_INS_EFDCTUI, + PPC_INS_EFDCTUIDZ, + PPC_INS_EFDCTUIZ, + PPC_INS_EFDDIV, + PPC_INS_EFDMUL, + PPC_INS_EFDNABS, + PPC_INS_EFDNEG, + PPC_INS_EFDSUB, + PPC_INS_EFDTSTEQ, + PPC_INS_EFDTSTGT, + PPC_INS_EFDTSTLT, + PPC_INS_EFSABS, + PPC_INS_EFSADD, + PPC_INS_EFSCFD, + PPC_INS_EFSCFSF, + PPC_INS_EFSCFSI, + PPC_INS_EFSCFUF, + PPC_INS_EFSCFUI, + PPC_INS_EFSCMPEQ, + PPC_INS_EFSCMPGT, + PPC_INS_EFSCMPLT, + PPC_INS_EFSCTSF, + PPC_INS_EFSCTSI, + PPC_INS_EFSCTSIZ, + PPC_INS_EFSCTUF, + PPC_INS_EFSCTUI, + PPC_INS_EFSCTUIZ, + PPC_INS_EFSDIV, + PPC_INS_EFSMUL, + PPC_INS_EFSNABS, + PPC_INS_EFSNEG, + PPC_INS_EFSSUB, + PPC_INS_EFSTSTEQ, + PPC_INS_EFSTSTGT, + PPC_INS_EFSTSTLT, + PPC_INS_EIEIO, + PPC_INS_EQV, + PPC_INS_EVABS, + PPC_INS_EVADDIW, + PPC_INS_EVADDSMIAAW, + PPC_INS_EVADDSSIAAW, + PPC_INS_EVADDUMIAAW, + PPC_INS_EVADDUSIAAW, + PPC_INS_EVADDW, + PPC_INS_EVAND, + PPC_INS_EVANDC, + PPC_INS_EVCMPEQ, + PPC_INS_EVCMPGTS, + PPC_INS_EVCMPGTU, + PPC_INS_EVCMPLTS, + PPC_INS_EVCMPLTU, + PPC_INS_EVCNTLSW, + PPC_INS_EVCNTLZW, + PPC_INS_EVDIVWS, + PPC_INS_EVDIVWU, + PPC_INS_EVEQV, + PPC_INS_EVEXTSB, + PPC_INS_EVEXTSH, + PPC_INS_EVFSABS, + PPC_INS_EVFSADD, + PPC_INS_EVFSCFSF, + PPC_INS_EVFSCFSI, + PPC_INS_EVFSCFUF, + PPC_INS_EVFSCFUI, + PPC_INS_EVFSCMPEQ, + PPC_INS_EVFSCMPGT, + PPC_INS_EVFSCMPLT, + PPC_INS_EVFSCTSF, + PPC_INS_EVFSCTSI, + PPC_INS_EVFSCTSIZ, + PPC_INS_EVFSCTUI, + PPC_INS_EVFSDIV, + PPC_INS_EVFSMUL, + PPC_INS_EVFSNABS, + PPC_INS_EVFSNEG, + PPC_INS_EVFSSUB, + PPC_INS_EVFSTSTEQ, + PPC_INS_EVFSTSTGT, + PPC_INS_EVFSTSTLT, + PPC_INS_EVLDD, + PPC_INS_EVLDDX, + PPC_INS_EVLDH, + PPC_INS_EVLDHX, + PPC_INS_EVLDW, + PPC_INS_EVLDWX, + PPC_INS_EVLHHESPLAT, + PPC_INS_EVLHHESPLATX, + PPC_INS_EVLHHOSSPLAT, + PPC_INS_EVLHHOSSPLATX, + PPC_INS_EVLHHOUSPLAT, + PPC_INS_EVLHHOUSPLATX, + PPC_INS_EVLWHE, + PPC_INS_EVLWHEX, + PPC_INS_EVLWHOS, + PPC_INS_EVLWHOSX, + PPC_INS_EVLWHOU, + PPC_INS_EVLWHOUX, + PPC_INS_EVLWHSPLAT, + PPC_INS_EVLWHSPLATX, + PPC_INS_EVLWWSPLAT, + PPC_INS_EVLWWSPLATX, + PPC_INS_EVMERGEHI, + PPC_INS_EVMERGEHILO, + PPC_INS_EVMERGELO, + PPC_INS_EVMERGELOHI, + PPC_INS_EVMHEGSMFAA, + PPC_INS_EVMHEGSMFAN, + PPC_INS_EVMHEGSMIAA, + PPC_INS_EVMHEGSMIAN, + PPC_INS_EVMHEGUMIAA, + PPC_INS_EVMHEGUMIAN, + PPC_INS_EVMHESMF, + PPC_INS_EVMHESMFA, + PPC_INS_EVMHESMFAAW, + PPC_INS_EVMHESMFANW, + PPC_INS_EVMHESMI, + PPC_INS_EVMHESMIA, + PPC_INS_EVMHESMIAAW, + PPC_INS_EVMHESMIANW, + PPC_INS_EVMHESSF, + PPC_INS_EVMHESSFA, + PPC_INS_EVMHESSFAAW, + PPC_INS_EVMHESSFANW, + PPC_INS_EVMHESSIAAW, + PPC_INS_EVMHESSIANW, + PPC_INS_EVMHEUMI, + PPC_INS_EVMHEUMIA, + PPC_INS_EVMHEUMIAAW, + PPC_INS_EVMHEUMIANW, + PPC_INS_EVMHEUSIAAW, + PPC_INS_EVMHEUSIANW, + PPC_INS_EVMHOGSMFAA, + PPC_INS_EVMHOGSMFAN, + PPC_INS_EVMHOGSMIAA, + PPC_INS_EVMHOGSMIAN, + PPC_INS_EVMHOGUMIAA, + PPC_INS_EVMHOGUMIAN, + PPC_INS_EVMHOSMF, + PPC_INS_EVMHOSMFA, + PPC_INS_EVMHOSMFAAW, + PPC_INS_EVMHOSMFANW, + PPC_INS_EVMHOSMI, + PPC_INS_EVMHOSMIA, + PPC_INS_EVMHOSMIAAW, + PPC_INS_EVMHOSMIANW, + PPC_INS_EVMHOSSF, + PPC_INS_EVMHOSSFA, + PPC_INS_EVMHOSSFAAW, + PPC_INS_EVMHOSSFANW, + PPC_INS_EVMHOSSIAAW, + PPC_INS_EVMHOSSIANW, + PPC_INS_EVMHOUMI, + PPC_INS_EVMHOUMIA, + PPC_INS_EVMHOUMIAAW, + PPC_INS_EVMHOUMIANW, + PPC_INS_EVMHOUSIAAW, + PPC_INS_EVMHOUSIANW, + PPC_INS_EVMRA, + PPC_INS_EVMWHSMF, + PPC_INS_EVMWHSMFA, + PPC_INS_EVMWHSMI, + PPC_INS_EVMWHSMIA, + PPC_INS_EVMWHSSF, + PPC_INS_EVMWHSSFA, + PPC_INS_EVMWHUMI, + PPC_INS_EVMWHUMIA, + PPC_INS_EVMWLSMIAAW, + PPC_INS_EVMWLSMIANW, + PPC_INS_EVMWLSSIAAW, + PPC_INS_EVMWLSSIANW, + PPC_INS_EVMWLUMI, + PPC_INS_EVMWLUMIA, + PPC_INS_EVMWLUMIAAW, + PPC_INS_EVMWLUMIANW, + PPC_INS_EVMWLUSIAAW, + PPC_INS_EVMWLUSIANW, + PPC_INS_EVMWSMF, + PPC_INS_EVMWSMFA, + PPC_INS_EVMWSMFAA, + PPC_INS_EVMWSMFAN, + PPC_INS_EVMWSMI, + PPC_INS_EVMWSMIA, + PPC_INS_EVMWSMIAA, + PPC_INS_EVMWSMIAN, + PPC_INS_EVMWSSF, + PPC_INS_EVMWSSFA, + PPC_INS_EVMWSSFAA, + PPC_INS_EVMWSSFAN, + PPC_INS_EVMWUMI, + PPC_INS_EVMWUMIA, + PPC_INS_EVMWUMIAA, + PPC_INS_EVMWUMIAN, + PPC_INS_EVNAND, + PPC_INS_EVNEG, + PPC_INS_EVNOR, + PPC_INS_EVOR, + PPC_INS_EVORC, + PPC_INS_EVRLW, + PPC_INS_EVRLWI, + PPC_INS_EVRNDW, + PPC_INS_EVSEL, + PPC_INS_EVSLW, + PPC_INS_EVSLWI, + PPC_INS_EVSPLATFI, + PPC_INS_EVSPLATI, + PPC_INS_EVSRWIS, + PPC_INS_EVSRWIU, + PPC_INS_EVSRWS, + PPC_INS_EVSRWU, + PPC_INS_EVSTDD, + PPC_INS_EVSTDDX, + PPC_INS_EVSTDH, + PPC_INS_EVSTDHX, + PPC_INS_EVSTDW, + PPC_INS_EVSTDWX, + PPC_INS_EVSTWHE, + PPC_INS_EVSTWHEX, + PPC_INS_EVSTWHO, + PPC_INS_EVSTWHOX, + PPC_INS_EVSTWWE, + PPC_INS_EVSTWWEX, + PPC_INS_EVSTWWO, + PPC_INS_EVSTWWOX, + PPC_INS_EVSUBFSMIAAW, + PPC_INS_EVSUBFSSIAAW, + PPC_INS_EVSUBFUMIAAW, + PPC_INS_EVSUBFUSIAAW, + PPC_INS_EVSUBFW, + PPC_INS_EVSUBIFW, + PPC_INS_EVXOR, + PPC_INS_EXTLDI, + PPC_INS_EXTLWI, + PPC_INS_EXTRDI, + PPC_INS_EXTRWI, + PPC_INS_EXTSB, + PPC_INS_EXTSH, + PPC_INS_EXTSW, + PPC_INS_EXTSWSLI, + PPC_INS_FABS, + PPC_INS_FADD, + PPC_INS_FADDS, + PPC_INS_FCFID, + PPC_INS_FCFIDS, + PPC_INS_FCFIDU, + PPC_INS_FCFIDUS, + PPC_INS_FCMPU, + PPC_INS_FCPSGN, + PPC_INS_FCTID, + PPC_INS_FCTIDU, + PPC_INS_FCTIDUZ, + PPC_INS_FCTIDZ, + PPC_INS_FCTIW, + PPC_INS_FCTIWU, + PPC_INS_FCTIWUZ, + PPC_INS_FCTIWZ, + PPC_INS_FDIV, + PPC_INS_FDIVS, + PPC_INS_FMADD, + PPC_INS_FMADDS, + PPC_INS_FMR, + PPC_INS_FMSUB, + PPC_INS_FMSUBS, + PPC_INS_FMUL, + PPC_INS_FMULS, + PPC_INS_FNABS, + PPC_INS_FNEG, + PPC_INS_FNMADD, + PPC_INS_FNMADDS, + PPC_INS_FNMSUB, + PPC_INS_FNMSUBS, + PPC_INS_FRE, + PPC_INS_FRES, + PPC_INS_FRIM, + PPC_INS_FRIN, + PPC_INS_FRIP, + PPC_INS_FRIZ, + PPC_INS_FRSP, + PPC_INS_FRSQRTE, + PPC_INS_FRSQRTES, + PPC_INS_FSEL, + PPC_INS_FSQRT, + PPC_INS_FSQRTS, + PPC_INS_FSUB, + PPC_INS_FSUBS, + PPC_INS_FTDIV, + PPC_INS_FTSQRT, + PPC_INS_HRFID, + PPC_INS_ICBI, + PPC_INS_ICBIEP, + PPC_INS_ICBLC, + PPC_INS_ICBLQ, + PPC_INS_ICBT, + PPC_INS_ICBTLS, + PPC_INS_ICCCI, + PPC_INS_ICI, + PPC_INS_INSLWI, + PPC_INS_INSRDI, + PPC_INS_INSRWI, + PPC_INS_ISEL, + PPC_INS_ISYNC, + PPC_INS_LA, + PPC_INS_LBARX, + PPC_INS_LBEPX, + PPC_INS_LBZ, + PPC_INS_LBZCIX, + PPC_INS_LBZU, + PPC_INS_LBZUX, + PPC_INS_LBZX, + PPC_INS_LD, + PPC_INS_LDARX, + PPC_INS_LDAT, + PPC_INS_LDBRX, + PPC_INS_LDCIX, + PPC_INS_LDMX, + PPC_INS_LDU, + PPC_INS_LDUX, + PPC_INS_LDX, + PPC_INS_LFD, + PPC_INS_LFDEPX, + PPC_INS_LFDU, + PPC_INS_LFDUX, + PPC_INS_LFDX, + PPC_INS_LFIWAX, + PPC_INS_LFIWZX, + PPC_INS_LFS, + PPC_INS_LFSU, + PPC_INS_LFSUX, + PPC_INS_LFSX, + PPC_INS_LHA, + PPC_INS_LHARX, + PPC_INS_LHAU, + PPC_INS_LHAUX, + PPC_INS_LHAX, + PPC_INS_LHBRX, + PPC_INS_LHEPX, + PPC_INS_LHZ, + PPC_INS_LHZCIX, + PPC_INS_LHZU, + PPC_INS_LHZUX, + PPC_INS_LHZX, + PPC_INS_LI, + PPC_INS_LIS, + PPC_INS_LMW, + PPC_INS_LNIA, + PPC_INS_LSWI, + PPC_INS_LVEBX, + PPC_INS_LVEHX, + PPC_INS_LVEWX, + PPC_INS_LVSL, + PPC_INS_LVSR, + PPC_INS_LVX, + PPC_INS_LVXL, + PPC_INS_LWA, + PPC_INS_LWARX, + PPC_INS_LWAT, + PPC_INS_LWAUX, + PPC_INS_LWAX, + PPC_INS_LWBRX, + PPC_INS_LWEPX, + PPC_INS_LWSYNC, + PPC_INS_LWZ, + PPC_INS_LWZCIX, + PPC_INS_LWZU, + PPC_INS_LWZUX, + PPC_INS_LWZX, + PPC_INS_LXSD, + PPC_INS_LXSDX, + PPC_INS_LXSIBZX, + PPC_INS_LXSIHZX, + PPC_INS_LXSIWAX, + PPC_INS_LXSIWZX, + PPC_INS_LXSSP, + PPC_INS_LXSSPX, + PPC_INS_LXV, + PPC_INS_LXVB16X, + PPC_INS_LXVD2X, + PPC_INS_LXVDSX, + PPC_INS_LXVH8X, + PPC_INS_LXVL, + PPC_INS_LXVLL, + PPC_INS_LXVW4X, + PPC_INS_LXVWSX, + PPC_INS_LXVX, + PPC_INS_MADDHD, + PPC_INS_MADDHDU, + PPC_INS_MADDLD, + PPC_INS_MBAR, + PPC_INS_MCRF, + PPC_INS_MCRFS, + PPC_INS_MCRXRX, + PPC_INS_MFAMR, + PPC_INS_MFASR, + PPC_INS_MFBHRBE, + PPC_INS_MFBR0, + PPC_INS_MFBR1, + PPC_INS_MFBR2, + PPC_INS_MFBR3, + PPC_INS_MFBR4, + PPC_INS_MFBR5, + PPC_INS_MFBR6, + PPC_INS_MFBR7, + PPC_INS_MFCFAR, + PPC_INS_MFCR, + PPC_INS_MFCTR, + PPC_INS_MFDAR, + PPC_INS_MFDBATL, + PPC_INS_MFDBATU, + PPC_INS_MFDCCR, + PPC_INS_MFDCR, + PPC_INS_MFDEAR, + PPC_INS_MFDEC, + PPC_INS_MFDSCR, + PPC_INS_MFDSISR, + PPC_INS_MFESR, + PPC_INS_MFFPRD, + PPC_INS_MFFS, + PPC_INS_MFFSCDRN, + PPC_INS_MFFSCDRNI, + PPC_INS_MFFSCE, + PPC_INS_MFFSCRN, + PPC_INS_MFFSCRNI, + PPC_INS_MFFSL, + PPC_INS_MFIBATL, + PPC_INS_MFIBATU, + PPC_INS_MFICCR, + PPC_INS_MFLR, + PPC_INS_MFMSR, + PPC_INS_MFOCRF, + PPC_INS_MFPID, + PPC_INS_MFPMR, + PPC_INS_MFPVR, + PPC_INS_MFRTCL, + PPC_INS_MFRTCU, + PPC_INS_MFSDR1, + PPC_INS_MFSPEFSCR, + PPC_INS_MFSPR, + PPC_INS_MFSPRG, + PPC_INS_MFSPRG0, + PPC_INS_MFSPRG1, + PPC_INS_MFSPRG2, + PPC_INS_MFSPRG3, + PPC_INS_MFSPRG4, + PPC_INS_MFSPRG5, + PPC_INS_MFSPRG6, + PPC_INS_MFSPRG7, + PPC_INS_MFSR, + PPC_INS_MFSRIN, + PPC_INS_MFSRR0, + PPC_INS_MFSRR1, + PPC_INS_MFSRR2, + PPC_INS_MFSRR3, + PPC_INS_MFTB, + PPC_INS_MFTBHI, + PPC_INS_MFTBL, + PPC_INS_MFTBLO, + PPC_INS_MFTBU, + PPC_INS_MFTCR, + PPC_INS_MFVRD, + PPC_INS_MFVRSAVE, + PPC_INS_MFVSCR, + PPC_INS_MFVSRD, + PPC_INS_MFVSRLD, + PPC_INS_MFVSRWZ, + PPC_INS_MFXER, + PPC_INS_MODSD, + PPC_INS_MODSW, + PPC_INS_MODUD, + PPC_INS_MODUW, + PPC_INS_MR, + PPC_INS_MSGSYNC, + PPC_INS_MSYNC, + PPC_INS_MTAMR, + PPC_INS_MTASR, + PPC_INS_MTBR0, + PPC_INS_MTBR1, + PPC_INS_MTBR2, + PPC_INS_MTBR3, + PPC_INS_MTBR4, + PPC_INS_MTBR5, + PPC_INS_MTBR6, + PPC_INS_MTBR7, + PPC_INS_MTCFAR, + PPC_INS_MTCR, + PPC_INS_MTCRF, + PPC_INS_MTCTR, + PPC_INS_MTDAR, + PPC_INS_MTDBATL, + PPC_INS_MTDBATU, + PPC_INS_MTDCCR, + PPC_INS_MTDCR, + PPC_INS_MTDEAR, + PPC_INS_MTDEC, + PPC_INS_MTDSCR, + PPC_INS_MTDSISR, + PPC_INS_MTESR, + PPC_INS_MTFSB0, + PPC_INS_MTFSB1, + PPC_INS_MTFSF, + PPC_INS_MTFSFI, + PPC_INS_MTIBATL, + PPC_INS_MTIBATU, + PPC_INS_MTICCR, + PPC_INS_MTLR, + PPC_INS_MTMSR, + PPC_INS_MTMSRD, + PPC_INS_MTOCRF, + PPC_INS_MTPID, + PPC_INS_MTPMR, + PPC_INS_MTSDR1, + PPC_INS_MTSPEFSCR, + PPC_INS_MTSPR, + PPC_INS_MTSPRG, + PPC_INS_MTSPRG0, + PPC_INS_MTSPRG1, + PPC_INS_MTSPRG2, + PPC_INS_MTSPRG3, + PPC_INS_MTSPRG4, + PPC_INS_MTSPRG5, + PPC_INS_MTSPRG6, + PPC_INS_MTSPRG7, + PPC_INS_MTSR, + PPC_INS_MTSRIN, + PPC_INS_MTSRR0, + PPC_INS_MTSRR1, + PPC_INS_MTSRR2, + PPC_INS_MTSRR3, + PPC_INS_MTTBHI, + PPC_INS_MTTBL, + PPC_INS_MTTBLO, + PPC_INS_MTTBU, + PPC_INS_MTTCR, + PPC_INS_MTVRSAVE, + PPC_INS_MTVSCR, + PPC_INS_MTVSRD, + PPC_INS_MTVSRDD, + PPC_INS_MTVSRWA, + PPC_INS_MTVSRWS, + PPC_INS_MTVSRWZ, + PPC_INS_MTXER, + PPC_INS_MULHD, + PPC_INS_MULHDU, + PPC_INS_MULHW, + PPC_INS_MULHWU, + PPC_INS_MULLD, + PPC_INS_MULLI, + PPC_INS_MULLW, + PPC_INS_NAND, + PPC_INS_NAP, + PPC_INS_NEG, + PPC_INS_NOP, + PPC_INS_NOR, + PPC_INS_NOT, + PPC_INS_OR, + PPC_INS_ORC, + PPC_INS_ORI, + PPC_INS_ORIS, + PPC_INS_PASTE, + PPC_INS_PASTE_LAST, + PPC_INS_POPCNTB, + PPC_INS_POPCNTD, + PPC_INS_POPCNTW, + PPC_INS_PTESYNC, + PPC_INS_QVALIGNI, + PPC_INS_QVESPLATI, + PPC_INS_QVFABS, + PPC_INS_QVFADD, + PPC_INS_QVFADDS, + PPC_INS_QVFAND, + PPC_INS_QVFANDC, + PPC_INS_QVFCFID, + PPC_INS_QVFCFIDS, + PPC_INS_QVFCFIDU, + PPC_INS_QVFCFIDUS, + PPC_INS_QVFCLR, + PPC_INS_QVFCMPEQ, + PPC_INS_QVFCMPGT, + PPC_INS_QVFCMPLT, + PPC_INS_QVFCPSGN, + PPC_INS_QVFCTFB, + PPC_INS_QVFCTID, + PPC_INS_QVFCTIDU, + PPC_INS_QVFCTIDUZ, + PPC_INS_QVFCTIDZ, + PPC_INS_QVFCTIW, + PPC_INS_QVFCTIWU, + PPC_INS_QVFCTIWUZ, + PPC_INS_QVFCTIWZ, + PPC_INS_QVFEQU, + PPC_INS_QVFLOGICAL, + PPC_INS_QVFMADD, + PPC_INS_QVFMADDS, + PPC_INS_QVFMR, + PPC_INS_QVFMSUB, + PPC_INS_QVFMSUBS, + PPC_INS_QVFMUL, + PPC_INS_QVFMULS, + PPC_INS_QVFNABS, + PPC_INS_QVFNAND, + PPC_INS_QVFNEG, + PPC_INS_QVFNMADD, + PPC_INS_QVFNMADDS, + PPC_INS_QVFNMSUB, + PPC_INS_QVFNMSUBS, + PPC_INS_QVFNOR, + PPC_INS_QVFNOT, + PPC_INS_QVFOR, + PPC_INS_QVFORC, + PPC_INS_QVFPERM, + PPC_INS_QVFRE, + PPC_INS_QVFRES, + PPC_INS_QVFRIM, + PPC_INS_QVFRIN, + PPC_INS_QVFRIP, + PPC_INS_QVFRIZ, + PPC_INS_QVFRSP, + PPC_INS_QVFRSQRTE, + PPC_INS_QVFRSQRTES, + PPC_INS_QVFSEL, + PPC_INS_QVFSET, + PPC_INS_QVFSUB, + PPC_INS_QVFSUBS, + PPC_INS_QVFTSTNAN, + PPC_INS_QVFXMADD, + PPC_INS_QVFXMADDS, + PPC_INS_QVFXMUL, + PPC_INS_QVFXMULS, + PPC_INS_QVFXOR, + PPC_INS_QVFXXCPNMADD, + PPC_INS_QVFXXCPNMADDS, + PPC_INS_QVFXXMADD, + PPC_INS_QVFXXMADDS, + PPC_INS_QVFXXNPMADD, + PPC_INS_QVFXXNPMADDS, + PPC_INS_QVGPCI, + PPC_INS_QVLFCDUX, + PPC_INS_QVLFCDUXA, + PPC_INS_QVLFCDX, + PPC_INS_QVLFCDXA, + PPC_INS_QVLFCSUX, + PPC_INS_QVLFCSUXA, + PPC_INS_QVLFCSX, + PPC_INS_QVLFCSXA, + PPC_INS_QVLFDUX, + PPC_INS_QVLFDUXA, + PPC_INS_QVLFDX, + PPC_INS_QVLFDXA, + PPC_INS_QVLFIWAX, + PPC_INS_QVLFIWAXA, + PPC_INS_QVLFIWZX, + PPC_INS_QVLFIWZXA, + PPC_INS_QVLFSUX, + PPC_INS_QVLFSUXA, + PPC_INS_QVLFSX, + PPC_INS_QVLFSXA, + PPC_INS_QVLPCLDX, + PPC_INS_QVLPCLSX, + PPC_INS_QVLPCRDX, + PPC_INS_QVLPCRSX, + PPC_INS_QVSTFCDUX, + PPC_INS_QVSTFCDUXA, + PPC_INS_QVSTFCDUXI, + PPC_INS_QVSTFCDUXIA, + PPC_INS_QVSTFCDX, + PPC_INS_QVSTFCDXA, + PPC_INS_QVSTFCDXI, + PPC_INS_QVSTFCDXIA, + PPC_INS_QVSTFCSUX, + PPC_INS_QVSTFCSUXA, + PPC_INS_QVSTFCSUXI, + PPC_INS_QVSTFCSUXIA, + PPC_INS_QVSTFCSX, + PPC_INS_QVSTFCSXA, + PPC_INS_QVSTFCSXI, + PPC_INS_QVSTFCSXIA, + PPC_INS_QVSTFDUX, + PPC_INS_QVSTFDUXA, + PPC_INS_QVSTFDUXI, + PPC_INS_QVSTFDUXIA, + PPC_INS_QVSTFDX, + PPC_INS_QVSTFDXA, + PPC_INS_QVSTFDXI, + PPC_INS_QVSTFDXIA, + PPC_INS_QVSTFIWX, + PPC_INS_QVSTFIWXA, + PPC_INS_QVSTFSUX, + PPC_INS_QVSTFSUXA, + PPC_INS_QVSTFSUXI, + PPC_INS_QVSTFSUXIA, + PPC_INS_QVSTFSX, + PPC_INS_QVSTFSXA, + PPC_INS_QVSTFSXI, + PPC_INS_QVSTFSXIA, + PPC_INS_RFCI, + PPC_INS_RFDI, + PPC_INS_RFEBB, + PPC_INS_RFI, + PPC_INS_RFID, + PPC_INS_RFMCI, + PPC_INS_RLDCL, + PPC_INS_RLDCR, + PPC_INS_RLDIC, + PPC_INS_RLDICL, + PPC_INS_RLDICR, + PPC_INS_RLDIMI, + PPC_INS_RLWIMI, + PPC_INS_RLWINM, + PPC_INS_RLWNM, + PPC_INS_ROTLD, + PPC_INS_ROTLDI, + PPC_INS_ROTLW, + PPC_INS_ROTLWI, + PPC_INS_ROTRDI, + PPC_INS_ROTRWI, + PPC_INS_SC, + PPC_INS_SETB, + PPC_INS_SLBIA, + PPC_INS_SLBIE, + PPC_INS_SLBIEG, + PPC_INS_SLBMFEE, + PPC_INS_SLBMFEV, + PPC_INS_SLBMTE, + PPC_INS_SLBSYNC, + PPC_INS_SLD, + PPC_INS_SLDI, + PPC_INS_SLW, + PPC_INS_SLWI, + PPC_INS_SRAD, + PPC_INS_SRADI, + PPC_INS_SRAW, + PPC_INS_SRAWI, + PPC_INS_SRD, + PPC_INS_SRDI, + PPC_INS_SRW, + PPC_INS_SRWI, + PPC_INS_STB, + PPC_INS_STBCIX, + PPC_INS_STBCX, + PPC_INS_STBEPX, + PPC_INS_STBU, + PPC_INS_STBUX, + PPC_INS_STBX, + PPC_INS_STD, + PPC_INS_STDAT, + PPC_INS_STDBRX, + PPC_INS_STDCIX, + PPC_INS_STDCX, + PPC_INS_STDU, + PPC_INS_STDUX, + PPC_INS_STDX, + PPC_INS_STFD, + PPC_INS_STFDEPX, + PPC_INS_STFDU, + PPC_INS_STFDUX, + PPC_INS_STFDX, + PPC_INS_STFIWX, + PPC_INS_STFS, + PPC_INS_STFSU, + PPC_INS_STFSUX, + PPC_INS_STFSX, + PPC_INS_STH, + PPC_INS_STHBRX, + PPC_INS_STHCIX, + PPC_INS_STHCX, + PPC_INS_STHEPX, + PPC_INS_STHU, + PPC_INS_STHUX, + PPC_INS_STHX, + PPC_INS_STMW, + PPC_INS_STOP, + PPC_INS_STSWI, + PPC_INS_STVEBX, + PPC_INS_STVEHX, + PPC_INS_STVEWX, + PPC_INS_STVX, + PPC_INS_STVXL, + PPC_INS_STW, + PPC_INS_STWAT, + PPC_INS_STWBRX, + PPC_INS_STWCIX, + PPC_INS_STWCX, + PPC_INS_STWEPX, + PPC_INS_STWU, + PPC_INS_STWUX, + PPC_INS_STWX, + PPC_INS_STXSD, + PPC_INS_STXSDX, + PPC_INS_STXSIBX, + PPC_INS_STXSIHX, + PPC_INS_STXSIWX, + PPC_INS_STXSSP, + PPC_INS_STXSSPX, + PPC_INS_STXV, + PPC_INS_STXVB16X, + PPC_INS_STXVD2X, + PPC_INS_STXVH8X, + PPC_INS_STXVL, + PPC_INS_STXVLL, + PPC_INS_STXVW4X, + PPC_INS_STXVX, + PPC_INS_SUB, + PPC_INS_SUBC, + PPC_INS_SUBF, + PPC_INS_SUBFC, + PPC_INS_SUBFE, + PPC_INS_SUBFIC, + PPC_INS_SUBFME, + PPC_INS_SUBFZE, + PPC_INS_SUBI, + PPC_INS_SUBIC, + PPC_INS_SUBIS, + PPC_INS_SUBPCIS, + PPC_INS_SYNC, + PPC_INS_TABORT, + PPC_INS_TABORTDC, + PPC_INS_TABORTDCI, + PPC_INS_TABORTWC, + PPC_INS_TABORTWCI, + PPC_INS_TBEGIN, + PPC_INS_TCHECK, + PPC_INS_TD, + PPC_INS_TDEQ, + PPC_INS_TDEQI, + PPC_INS_TDGE, + PPC_INS_TDGEI, + PPC_INS_TDGT, + PPC_INS_TDGTI, + PPC_INS_TDI, + PPC_INS_TDLE, + PPC_INS_TDLEI, + PPC_INS_TDLGE, + PPC_INS_TDLGEI, + PPC_INS_TDLGT, + PPC_INS_TDLGTI, + PPC_INS_TDLLE, + PPC_INS_TDLLEI, + PPC_INS_TDLLT, + PPC_INS_TDLLTI, + PPC_INS_TDLNG, + PPC_INS_TDLNGI, + PPC_INS_TDLNL, + PPC_INS_TDLNLI, + PPC_INS_TDLT, + PPC_INS_TDLTI, + PPC_INS_TDNE, + PPC_INS_TDNEI, + PPC_INS_TDNG, + PPC_INS_TDNGI, + PPC_INS_TDNL, + PPC_INS_TDNLI, + PPC_INS_TDU, + PPC_INS_TDUI, + PPC_INS_TEND, + PPC_INS_TLBIA, + PPC_INS_TLBIE, + PPC_INS_TLBIEL, + PPC_INS_TLBIVAX, + PPC_INS_TLBLD, + PPC_INS_TLBLI, + PPC_INS_TLBRE, + PPC_INS_TLBREHI, + PPC_INS_TLBRELO, + PPC_INS_TLBSX, + PPC_INS_TLBSYNC, + PPC_INS_TLBWE, + PPC_INS_TLBWEHI, + PPC_INS_TLBWELO, + PPC_INS_TRAP, + PPC_INS_TRECHKPT, + PPC_INS_TRECLAIM, + PPC_INS_TSR, + PPC_INS_TW, + PPC_INS_TWEQ, + PPC_INS_TWEQI, + PPC_INS_TWGE, + PPC_INS_TWGEI, + PPC_INS_TWGT, + PPC_INS_TWGTI, + PPC_INS_TWI, + PPC_INS_TWLE, + PPC_INS_TWLEI, + PPC_INS_TWLGE, + PPC_INS_TWLGEI, + PPC_INS_TWLGT, + PPC_INS_TWLGTI, + PPC_INS_TWLLE, + PPC_INS_TWLLEI, + PPC_INS_TWLLT, + PPC_INS_TWLLTI, + PPC_INS_TWLNG, + PPC_INS_TWLNGI, + PPC_INS_TWLNL, + PPC_INS_TWLNLI, + PPC_INS_TWLT, + PPC_INS_TWLTI, + PPC_INS_TWNE, + PPC_INS_TWNEI, + PPC_INS_TWNG, + PPC_INS_TWNGI, + PPC_INS_TWNL, + PPC_INS_TWNLI, + PPC_INS_TWU, + PPC_INS_TWUI, + PPC_INS_VABSDUB, + PPC_INS_VABSDUH, + PPC_INS_VABSDUW, + PPC_INS_VADDCUQ, + PPC_INS_VADDCUW, + PPC_INS_VADDECUQ, + PPC_INS_VADDEUQM, + PPC_INS_VADDFP, + PPC_INS_VADDSBS, + PPC_INS_VADDSHS, + PPC_INS_VADDSWS, + PPC_INS_VADDUBM, + PPC_INS_VADDUBS, + PPC_INS_VADDUDM, + PPC_INS_VADDUHM, + PPC_INS_VADDUHS, + PPC_INS_VADDUQM, + PPC_INS_VADDUWM, + PPC_INS_VADDUWS, + PPC_INS_VAND, + PPC_INS_VANDC, + PPC_INS_VAVGSB, + PPC_INS_VAVGSH, + PPC_INS_VAVGSW, + PPC_INS_VAVGUB, + PPC_INS_VAVGUH, + PPC_INS_VAVGUW, + PPC_INS_VBPERMD, + PPC_INS_VBPERMQ, + PPC_INS_VCFSX, + PPC_INS_VCFUX, + PPC_INS_VCIPHER, + PPC_INS_VCIPHERLAST, + PPC_INS_VCLZB, + PPC_INS_VCLZD, + PPC_INS_VCLZH, + PPC_INS_VCLZLSBB, + PPC_INS_VCLZW, + PPC_INS_VCMPBFP, + PPC_INS_VCMPEQFP, + PPC_INS_VCMPEQUB, + PPC_INS_VCMPEQUD, + PPC_INS_VCMPEQUH, + PPC_INS_VCMPEQUW, + PPC_INS_VCMPGEFP, + PPC_INS_VCMPGTFP, + PPC_INS_VCMPGTSB, + PPC_INS_VCMPGTSD, + PPC_INS_VCMPGTSH, + PPC_INS_VCMPGTSW, + PPC_INS_VCMPGTUB, + PPC_INS_VCMPGTUD, + PPC_INS_VCMPGTUH, + PPC_INS_VCMPGTUW, + PPC_INS_VCMPNEB, + PPC_INS_VCMPNEH, + PPC_INS_VCMPNEW, + PPC_INS_VCMPNEZB, + PPC_INS_VCMPNEZH, + PPC_INS_VCMPNEZW, + PPC_INS_VCTSXS, + PPC_INS_VCTUXS, + PPC_INS_VCTZB, + PPC_INS_VCTZD, + PPC_INS_VCTZH, + PPC_INS_VCTZLSBB, + PPC_INS_VCTZW, + PPC_INS_VEQV, + PPC_INS_VEXPTEFP, + PPC_INS_VEXTRACTD, + PPC_INS_VEXTRACTUB, + PPC_INS_VEXTRACTUH, + PPC_INS_VEXTRACTUW, + PPC_INS_VEXTSB2D, + PPC_INS_VEXTSB2W, + PPC_INS_VEXTSH2D, + PPC_INS_VEXTSH2W, + PPC_INS_VEXTSW2D, + PPC_INS_VEXTUBLX, + PPC_INS_VEXTUBRX, + PPC_INS_VEXTUHLX, + PPC_INS_VEXTUHRX, + PPC_INS_VEXTUWLX, + PPC_INS_VEXTUWRX, + PPC_INS_VGBBD, + PPC_INS_VINSERTB, + PPC_INS_VINSERTD, + PPC_INS_VINSERTH, + PPC_INS_VINSERTW, + PPC_INS_VLOGEFP, + PPC_INS_VMADDFP, + PPC_INS_VMAXFP, + PPC_INS_VMAXSB, + PPC_INS_VMAXSD, + PPC_INS_VMAXSH, + PPC_INS_VMAXSW, + PPC_INS_VMAXUB, + PPC_INS_VMAXUD, + PPC_INS_VMAXUH, + PPC_INS_VMAXUW, + PPC_INS_VMHADDSHS, + PPC_INS_VMHRADDSHS, + PPC_INS_VMINFP, + PPC_INS_VMINSB, + PPC_INS_VMINSD, + PPC_INS_VMINSH, + PPC_INS_VMINSW, + PPC_INS_VMINUB, + PPC_INS_VMINUD, + PPC_INS_VMINUH, + PPC_INS_VMINUW, + PPC_INS_VMLADDUHM, + PPC_INS_VMR, + PPC_INS_VMRGEW, + PPC_INS_VMRGHB, + PPC_INS_VMRGHH, + PPC_INS_VMRGHW, + PPC_INS_VMRGLB, + PPC_INS_VMRGLH, + PPC_INS_VMRGLW, + PPC_INS_VMRGOW, + PPC_INS_VMSUMMBM, + PPC_INS_VMSUMSHM, + PPC_INS_VMSUMSHS, + PPC_INS_VMSUMUBM, + PPC_INS_VMSUMUHM, + PPC_INS_VMSUMUHS, + PPC_INS_VMUL10CUQ, + PPC_INS_VMUL10ECUQ, + PPC_INS_VMUL10EUQ, + PPC_INS_VMUL10UQ, + PPC_INS_VMULESB, + PPC_INS_VMULESH, + PPC_INS_VMULESW, + PPC_INS_VMULEUB, + PPC_INS_VMULEUH, + PPC_INS_VMULEUW, + PPC_INS_VMULOSB, + PPC_INS_VMULOSH, + PPC_INS_VMULOSW, + PPC_INS_VMULOUB, + PPC_INS_VMULOUH, + PPC_INS_VMULOUW, + PPC_INS_VMULUWM, + PPC_INS_VNAND, + PPC_INS_VNCIPHER, + PPC_INS_VNCIPHERLAST, + PPC_INS_VNEGD, + PPC_INS_VNEGW, + PPC_INS_VNMSUBFP, + PPC_INS_VNOR, + PPC_INS_VNOT, + PPC_INS_VOR, + PPC_INS_VORC, + PPC_INS_VPERM, + PPC_INS_VPERMR, + PPC_INS_VPERMXOR, + PPC_INS_VPKPX, + PPC_INS_VPKSDSS, + PPC_INS_VPKSDUS, + PPC_INS_VPKSHSS, + PPC_INS_VPKSHUS, + PPC_INS_VPKSWSS, + PPC_INS_VPKSWUS, + PPC_INS_VPKUDUM, + PPC_INS_VPKUDUS, + PPC_INS_VPKUHUM, + PPC_INS_VPKUHUS, + PPC_INS_VPKUWUM, + PPC_INS_VPKUWUS, + PPC_INS_VPMSUMB, + PPC_INS_VPMSUMD, + PPC_INS_VPMSUMH, + PPC_INS_VPMSUMW, + PPC_INS_VPOPCNTB, + PPC_INS_VPOPCNTD, + PPC_INS_VPOPCNTH, + PPC_INS_VPOPCNTW, + PPC_INS_VPRTYBD, + PPC_INS_VPRTYBQ, + PPC_INS_VPRTYBW, + PPC_INS_VREFP, + PPC_INS_VRFIM, + PPC_INS_VRFIN, + PPC_INS_VRFIP, + PPC_INS_VRFIZ, + PPC_INS_VRLB, + PPC_INS_VRLD, + PPC_INS_VRLDMI, + PPC_INS_VRLDNM, + PPC_INS_VRLH, + PPC_INS_VRLW, + PPC_INS_VRLWMI, + PPC_INS_VRLWNM, + PPC_INS_VRSQRTEFP, + PPC_INS_VSBOX, + PPC_INS_VSEL, + PPC_INS_VSHASIGMAD, + PPC_INS_VSHASIGMAW, + PPC_INS_VSL, + PPC_INS_VSLB, + PPC_INS_VSLD, + PPC_INS_VSLDOI, + PPC_INS_VSLH, + PPC_INS_VSLO, + PPC_INS_VSLV, + PPC_INS_VSLW, + PPC_INS_VSPLTB, + PPC_INS_VSPLTH, + PPC_INS_VSPLTISB, + PPC_INS_VSPLTISH, + PPC_INS_VSPLTISW, + PPC_INS_VSPLTW, + PPC_INS_VSR, + PPC_INS_VSRAB, + PPC_INS_VSRAD, + PPC_INS_VSRAH, + PPC_INS_VSRAW, + PPC_INS_VSRB, + PPC_INS_VSRD, + PPC_INS_VSRH, + PPC_INS_VSRO, + PPC_INS_VSRV, + PPC_INS_VSRW, + PPC_INS_VSUBCUQ, + PPC_INS_VSUBCUW, + PPC_INS_VSUBECUQ, + PPC_INS_VSUBEUQM, + PPC_INS_VSUBFP, + PPC_INS_VSUBSBS, + PPC_INS_VSUBSHS, + PPC_INS_VSUBSWS, + PPC_INS_VSUBUBM, + PPC_INS_VSUBUBS, + PPC_INS_VSUBUDM, + PPC_INS_VSUBUHM, + PPC_INS_VSUBUHS, + PPC_INS_VSUBUQM, + PPC_INS_VSUBUWM, + PPC_INS_VSUBUWS, + PPC_INS_VSUM2SWS, + PPC_INS_VSUM4SBS, + PPC_INS_VSUM4SHS, + PPC_INS_VSUM4UBS, + PPC_INS_VSUMSWS, + PPC_INS_VUPKHPX, + PPC_INS_VUPKHSB, + PPC_INS_VUPKHSH, + PPC_INS_VUPKHSW, + PPC_INS_VUPKLPX, + PPC_INS_VUPKLSB, + PPC_INS_VUPKLSH, + PPC_INS_VUPKLSW, + PPC_INS_VXOR, + PPC_INS_WAIT, + PPC_INS_WAITIMPL, + PPC_INS_WAITRSV, + PPC_INS_WRTEE, + PPC_INS_WRTEEI, + PPC_INS_XNOP, + PPC_INS_XOR, + PPC_INS_XORI, + PPC_INS_XORIS, + PPC_INS_XSABSDP, + PPC_INS_XSABSQP, + PPC_INS_XSADDDP, + PPC_INS_XSADDQP, + PPC_INS_XSADDQPO, + PPC_INS_XSADDSP, + PPC_INS_XSCMPEQDP, + PPC_INS_XSCMPEXPDP, + PPC_INS_XSCMPEXPQP, + PPC_INS_XSCMPGEDP, + PPC_INS_XSCMPGTDP, + PPC_INS_XSCMPODP, + PPC_INS_XSCMPOQP, + PPC_INS_XSCMPUDP, + PPC_INS_XSCMPUQP, + PPC_INS_XSCPSGNDP, + PPC_INS_XSCPSGNQP, + PPC_INS_XSCVDPHP, + PPC_INS_XSCVDPQP, + PPC_INS_XSCVDPSP, + PPC_INS_XSCVDPSPN, + PPC_INS_XSCVDPSXDS, + PPC_INS_XSCVDPSXWS, + PPC_INS_XSCVDPUXDS, + PPC_INS_XSCVDPUXWS, + PPC_INS_XSCVHPDP, + PPC_INS_XSCVQPDP, + PPC_INS_XSCVQPDPO, + PPC_INS_XSCVQPSDZ, + PPC_INS_XSCVQPSWZ, + PPC_INS_XSCVQPUDZ, + PPC_INS_XSCVQPUWZ, + PPC_INS_XSCVSDQP, + PPC_INS_XSCVSPDP, + PPC_INS_XSCVSPDPN, + PPC_INS_XSCVSXDDP, + PPC_INS_XSCVSXDSP, + PPC_INS_XSCVUDQP, + PPC_INS_XSCVUXDDP, + PPC_INS_XSCVUXDSP, + PPC_INS_XSDIVDP, + PPC_INS_XSDIVQP, + PPC_INS_XSDIVQPO, + PPC_INS_XSDIVSP, + PPC_INS_XSIEXPDP, + PPC_INS_XSIEXPQP, + PPC_INS_XSMADDADP, + PPC_INS_XSMADDASP, + PPC_INS_XSMADDMDP, + PPC_INS_XSMADDMSP, + PPC_INS_XSMADDQP, + PPC_INS_XSMADDQPO, + PPC_INS_XSMAXCDP, + PPC_INS_XSMAXDP, + PPC_INS_XSMAXJDP, + PPC_INS_XSMINCDP, + PPC_INS_XSMINDP, + PPC_INS_XSMINJDP, + PPC_INS_XSMSUBADP, + PPC_INS_XSMSUBASP, + PPC_INS_XSMSUBMDP, + PPC_INS_XSMSUBMSP, + PPC_INS_XSMSUBQP, + PPC_INS_XSMSUBQPO, + PPC_INS_XSMULDP, + PPC_INS_XSMULQP, + PPC_INS_XSMULQPO, + PPC_INS_XSMULSP, + PPC_INS_XSNABSDP, + PPC_INS_XSNABSQP, + PPC_INS_XSNEGDP, + PPC_INS_XSNEGQP, + PPC_INS_XSNMADDADP, + PPC_INS_XSNMADDASP, + PPC_INS_XSNMADDMDP, + PPC_INS_XSNMADDMSP, + PPC_INS_XSNMADDQP, + PPC_INS_XSNMADDQPO, + PPC_INS_XSNMSUBADP, + PPC_INS_XSNMSUBASP, + PPC_INS_XSNMSUBMDP, + PPC_INS_XSNMSUBMSP, + PPC_INS_XSNMSUBQP, + PPC_INS_XSNMSUBQPO, + PPC_INS_XSRDPI, + PPC_INS_XSRDPIC, + PPC_INS_XSRDPIM, + PPC_INS_XSRDPIP, + PPC_INS_XSRDPIZ, + PPC_INS_XSREDP, + PPC_INS_XSRESP, + PPC_INS_XSRQPI, + PPC_INS_XSRQPIX, + PPC_INS_XSRQPXP, + PPC_INS_XSRSP, + PPC_INS_XSRSQRTEDP, + PPC_INS_XSRSQRTESP, + PPC_INS_XSSQRTDP, + PPC_INS_XSSQRTQP, + PPC_INS_XSSQRTQPO, + PPC_INS_XSSQRTSP, + PPC_INS_XSSUBDP, + PPC_INS_XSSUBQP, + PPC_INS_XSSUBQPO, + PPC_INS_XSSUBSP, + PPC_INS_XSTDIVDP, + PPC_INS_XSTSQRTDP, + PPC_INS_XSTSTDCDP, + PPC_INS_XSTSTDCQP, + PPC_INS_XSTSTDCSP, + PPC_INS_XSXEXPDP, + PPC_INS_XSXEXPQP, + PPC_INS_XSXSIGDP, + PPC_INS_XSXSIGQP, + PPC_INS_XVABSDP, + PPC_INS_XVABSSP, + PPC_INS_XVADDDP, + PPC_INS_XVADDSP, + PPC_INS_XVCMPEQDP, + PPC_INS_XVCMPEQSP, + PPC_INS_XVCMPGEDP, + PPC_INS_XVCMPGESP, + PPC_INS_XVCMPGTDP, + PPC_INS_XVCMPGTSP, + PPC_INS_XVCPSGNDP, + PPC_INS_XVCPSGNSP, + PPC_INS_XVCVDPSP, + PPC_INS_XVCVDPSXDS, + PPC_INS_XVCVDPSXWS, + PPC_INS_XVCVDPUXDS, + PPC_INS_XVCVDPUXWS, + PPC_INS_XVCVHPSP, + PPC_INS_XVCVSPDP, + PPC_INS_XVCVSPHP, + PPC_INS_XVCVSPSXDS, + PPC_INS_XVCVSPSXWS, + PPC_INS_XVCVSPUXDS, + PPC_INS_XVCVSPUXWS, + PPC_INS_XVCVSXDDP, + PPC_INS_XVCVSXDSP, + PPC_INS_XVCVSXWDP, + PPC_INS_XVCVSXWSP, + PPC_INS_XVCVUXDDP, + PPC_INS_XVCVUXDSP, + PPC_INS_XVCVUXWDP, + PPC_INS_XVCVUXWSP, + PPC_INS_XVDIVDP, + PPC_INS_XVDIVSP, + PPC_INS_XVIEXPDP, + PPC_INS_XVIEXPSP, + PPC_INS_XVMADDADP, + PPC_INS_XVMADDASP, + PPC_INS_XVMADDMDP, + PPC_INS_XVMADDMSP, + PPC_INS_XVMAXDP, + PPC_INS_XVMAXSP, + PPC_INS_XVMINDP, + PPC_INS_XVMINSP, + PPC_INS_XVMOVDP, + PPC_INS_XVMOVSP, + PPC_INS_XVMSUBADP, + PPC_INS_XVMSUBASP, + PPC_INS_XVMSUBMDP, + PPC_INS_XVMSUBMSP, + PPC_INS_XVMULDP, + PPC_INS_XVMULSP, + PPC_INS_XVNABSDP, + PPC_INS_XVNABSSP, + PPC_INS_XVNEGDP, + PPC_INS_XVNEGSP, + PPC_INS_XVNMADDADP, + PPC_INS_XVNMADDASP, + PPC_INS_XVNMADDMDP, + PPC_INS_XVNMADDMSP, + PPC_INS_XVNMSUBADP, + PPC_INS_XVNMSUBASP, + PPC_INS_XVNMSUBMDP, + PPC_INS_XVNMSUBMSP, + PPC_INS_XVRDPI, + PPC_INS_XVRDPIC, + PPC_INS_XVRDPIM, + PPC_INS_XVRDPIP, + PPC_INS_XVRDPIZ, + PPC_INS_XVREDP, + PPC_INS_XVRESP, + PPC_INS_XVRSPI, + PPC_INS_XVRSPIC, + PPC_INS_XVRSPIM, + PPC_INS_XVRSPIP, + PPC_INS_XVRSPIZ, + PPC_INS_XVRSQRTEDP, + PPC_INS_XVRSQRTESP, + PPC_INS_XVSQRTDP, + PPC_INS_XVSQRTSP, + PPC_INS_XVSUBDP, + PPC_INS_XVSUBSP, + PPC_INS_XVTDIVDP, + PPC_INS_XVTDIVSP, + PPC_INS_XVTSQRTDP, + PPC_INS_XVTSQRTSP, + PPC_INS_XVTSTDCDP, + PPC_INS_XVTSTDCSP, + PPC_INS_XVXEXPDP, + PPC_INS_XVXEXPSP, + PPC_INS_XVXSIGDP, + PPC_INS_XVXSIGSP, + PPC_INS_XXBRD, + PPC_INS_XXBRH, + PPC_INS_XXBRQ, + PPC_INS_XXBRW, + PPC_INS_XXEXTRACTUW, + PPC_INS_XXINSERTW, + PPC_INS_XXLAND, + PPC_INS_XXLANDC, + PPC_INS_XXLEQV, + PPC_INS_XXLNAND, + PPC_INS_XXLNOR, + PPC_INS_XXLOR, + PPC_INS_XXLORC, + PPC_INS_XXLXOR, + PPC_INS_XXMRGHD, + PPC_INS_XXMRGHW, + PPC_INS_XXMRGLD, + PPC_INS_XXMRGLW, + PPC_INS_XXPERM, + PPC_INS_XXPERMDI, + PPC_INS_XXPERMR, + PPC_INS_XXSEL, + PPC_INS_XXSLDWI, + PPC_INS_XXSPLTD, + PPC_INS_XXSPLTIB, + PPC_INS_XXSPLTW, + PPC_INS_XXSWAPD, + PPC_INS_ENDING, // <-- mark the end of the list of instructions +} ppc_insn; + +/// Group of PPC instructions +typedef enum ppc_insn_group { + PPC_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + // Generic groups + // all jump instructions (conditional+direct+indirect jumps) + PPC_GRP_JUMP, ///< = CS_GRP_JUMP + + // Architecture-specific groups + PPC_GRP_ALTIVEC = 128, + PPC_GRP_MODE32, + PPC_GRP_MODE64, + PPC_GRP_BOOKE, + PPC_GRP_NOTBOOKE, + PPC_GRP_SPE, + PPC_GRP_VSX, + PPC_GRP_E500, + PPC_GRP_PPC4XX, + PPC_GRP_PPC6XX, + PPC_GRP_ICBT, + PPC_GRP_P8ALTIVEC, + PPC_GRP_P8VECTOR, + PPC_GRP_QPX, + + PPC_GRP_ENDING, // <-- mark the end of the list of groups +} ppc_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_SPARC_H +#define CAPSTONE_SPARC_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2014-2015 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +// GCC SPARC toolchain has a default macro called "sparc" which breaks +// compilation +#undef sparc + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// Enums corresponding to Sparc condition codes, both icc's and fcc's. +typedef enum sparc_cc { + SPARC_CC_INVALID = 0, ///< invalid CC (default) + // Integer condition codes + SPARC_CC_ICC_A = 8+256, ///< Always + SPARC_CC_ICC_N = 0+256, ///< Never + SPARC_CC_ICC_NE = 9+256, ///< Not Equal + SPARC_CC_ICC_E = 1+256, ///< Equal + SPARC_CC_ICC_G = 10+256, ///< Greater + SPARC_CC_ICC_LE = 2+256, ///< Less or Equal + SPARC_CC_ICC_GE = 11+256, ///< Greater or Equal + SPARC_CC_ICC_L = 3+256, ///< Less + SPARC_CC_ICC_GU = 12+256, ///< Greater Unsigned + SPARC_CC_ICC_LEU = 4+256, ///< Less or Equal Unsigned + SPARC_CC_ICC_CC = 13+256, ///< Carry Clear/Great or Equal Unsigned + SPARC_CC_ICC_CS = 5+256, ///< Carry Set/Less Unsigned + SPARC_CC_ICC_POS = 14+256, ///< Positive + SPARC_CC_ICC_NEG = 6+256, ///< Negative + SPARC_CC_ICC_VC = 15+256, ///< Overflow Clear + SPARC_CC_ICC_VS = 7+256, ///< Overflow Set + + // Floating condition codes + SPARC_CC_FCC_A = 8+16+256, ///< Always + SPARC_CC_FCC_N = 0+16+256, ///< Never + SPARC_CC_FCC_U = 7+16+256, ///< Unordered + SPARC_CC_FCC_G = 6+16+256, ///< Greater + SPARC_CC_FCC_UG = 5+16+256, ///< Unordered or Greater + SPARC_CC_FCC_L = 4+16+256, ///< Less + SPARC_CC_FCC_UL = 3+16+256, ///< Unordered or Less + SPARC_CC_FCC_LG = 2+16+256, ///< Less or Greater + SPARC_CC_FCC_NE = 1+16+256, ///< Not Equal + SPARC_CC_FCC_E = 9+16+256, ///< Equal + SPARC_CC_FCC_UE = 10+16+256, ///< Unordered or Equal + SPARC_CC_FCC_GE = 11+16+256, ///< Greater or Equal + SPARC_CC_FCC_UGE = 12+16+256, ///< Unordered or Greater or Equal + SPARC_CC_FCC_LE = 13+16+256, ///< Less or Equal + SPARC_CC_FCC_ULE = 14+16+256, ///< Unordered or Less or Equal + SPARC_CC_FCC_O = 15+16+256, ///< Ordered +} sparc_cc; + +/// Branch hint +typedef enum sparc_hint { + SPARC_HINT_INVALID = 0, ///< no hint + SPARC_HINT_A = 1 << 0, ///< annul delay slot instruction + SPARC_HINT_PT = 1 << 1, ///< branch taken + SPARC_HINT_PN = 1 << 2, ///< branch NOT taken +} sparc_hint; + +/// Operand type for instruction's operands +typedef enum sparc_op_type { + SPARC_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + SPARC_OP_REG, ///< = CS_OP_REG (Register operand). + SPARC_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + SPARC_OP_MEM, ///< = CS_OP_MEM (Memory operand). +} sparc_op_type; + +/// SPARC registers +typedef enum sparc_reg { + SPARC_REG_INVALID = 0, + + SPARC_REG_F0, + SPARC_REG_F1, + SPARC_REG_F2, + SPARC_REG_F3, + SPARC_REG_F4, + SPARC_REG_F5, + SPARC_REG_F6, + SPARC_REG_F7, + SPARC_REG_F8, + SPARC_REG_F9, + SPARC_REG_F10, + SPARC_REG_F11, + SPARC_REG_F12, + SPARC_REG_F13, + SPARC_REG_F14, + SPARC_REG_F15, + SPARC_REG_F16, + SPARC_REG_F17, + SPARC_REG_F18, + SPARC_REG_F19, + SPARC_REG_F20, + SPARC_REG_F21, + SPARC_REG_F22, + SPARC_REG_F23, + SPARC_REG_F24, + SPARC_REG_F25, + SPARC_REG_F26, + SPARC_REG_F27, + SPARC_REG_F28, + SPARC_REG_F29, + SPARC_REG_F30, + SPARC_REG_F31, + SPARC_REG_F32, + SPARC_REG_F34, + SPARC_REG_F36, + SPARC_REG_F38, + SPARC_REG_F40, + SPARC_REG_F42, + SPARC_REG_F44, + SPARC_REG_F46, + SPARC_REG_F48, + SPARC_REG_F50, + SPARC_REG_F52, + SPARC_REG_F54, + SPARC_REG_F56, + SPARC_REG_F58, + SPARC_REG_F60, + SPARC_REG_F62, + SPARC_REG_FCC0, // Floating condition codes + SPARC_REG_FCC1, + SPARC_REG_FCC2, + SPARC_REG_FCC3, + SPARC_REG_FP, + SPARC_REG_G0, + SPARC_REG_G1, + SPARC_REG_G2, + SPARC_REG_G3, + SPARC_REG_G4, + SPARC_REG_G5, + SPARC_REG_G6, + SPARC_REG_G7, + SPARC_REG_I0, + SPARC_REG_I1, + SPARC_REG_I2, + SPARC_REG_I3, + SPARC_REG_I4, + SPARC_REG_I5, + SPARC_REG_I7, + SPARC_REG_ICC, // Integer condition codes + SPARC_REG_L0, + SPARC_REG_L1, + SPARC_REG_L2, + SPARC_REG_L3, + SPARC_REG_L4, + SPARC_REG_L5, + SPARC_REG_L6, + SPARC_REG_L7, + SPARC_REG_O0, + SPARC_REG_O1, + SPARC_REG_O2, + SPARC_REG_O3, + SPARC_REG_O4, + SPARC_REG_O5, + SPARC_REG_O7, + SPARC_REG_SP, + SPARC_REG_Y, + + // special register + SPARC_REG_XCC, + + SPARC_REG_ENDING, // <-- mark the end of the list of registers + + // extras + SPARC_REG_O6 = SPARC_REG_SP, + SPARC_REG_I6 = SPARC_REG_FP, +} sparc_reg; + +/// Instruction's operand referring to memory +/// This is associated with SPARC_OP_MEM operand type above +typedef struct sparc_op_mem { + uint8_t base; ///< base register, can be safely interpreted as + ///< a value of type `sparc_reg`, but it is only + ///< one byte wide + uint8_t index; ///< index register, same conditions apply here + int32_t disp; ///< displacement/offset value +} sparc_op_mem; + +/// Instruction operand +typedef struct cs_sparc_op { + sparc_op_type type; ///< operand type + union { + sparc_reg reg; ///< register value for REG operand + int64_t imm; ///< immediate value for IMM operand + sparc_op_mem mem; ///< base/disp value for MEM operand + }; +} cs_sparc_op; + +/// Instruction structure +typedef struct cs_sparc { + sparc_cc cc; ///< code condition for this insn + sparc_hint hint; ///< branch hint: encoding as bitwise OR of sparc_hint. + /// Number of operands of this instruction, + /// or 0 when instruction has no operand. + uint8_t op_count; + cs_sparc_op operands[4]; ///< operands for this instruction. +} cs_sparc; + +/// SPARC instruction +typedef enum sparc_insn { + SPARC_INS_INVALID = 0, + + SPARC_INS_ADDCC, + SPARC_INS_ADDX, + SPARC_INS_ADDXCC, + SPARC_INS_ADDXC, + SPARC_INS_ADDXCCC, + SPARC_INS_ADD, + SPARC_INS_ALIGNADDR, + SPARC_INS_ALIGNADDRL, + SPARC_INS_ANDCC, + SPARC_INS_ANDNCC, + SPARC_INS_ANDN, + SPARC_INS_AND, + SPARC_INS_ARRAY16, + SPARC_INS_ARRAY32, + SPARC_INS_ARRAY8, + SPARC_INS_B, + SPARC_INS_JMP, + SPARC_INS_BMASK, + SPARC_INS_FB, + SPARC_INS_BRGEZ, + SPARC_INS_BRGZ, + SPARC_INS_BRLEZ, + SPARC_INS_BRLZ, + SPARC_INS_BRNZ, + SPARC_INS_BRZ, + SPARC_INS_BSHUFFLE, + SPARC_INS_CALL, + SPARC_INS_CASX, + SPARC_INS_CAS, + SPARC_INS_CMASK16, + SPARC_INS_CMASK32, + SPARC_INS_CMASK8, + SPARC_INS_CMP, + SPARC_INS_EDGE16, + SPARC_INS_EDGE16L, + SPARC_INS_EDGE16LN, + SPARC_INS_EDGE16N, + SPARC_INS_EDGE32, + SPARC_INS_EDGE32L, + SPARC_INS_EDGE32LN, + SPARC_INS_EDGE32N, + SPARC_INS_EDGE8, + SPARC_INS_EDGE8L, + SPARC_INS_EDGE8LN, + SPARC_INS_EDGE8N, + SPARC_INS_FABSD, + SPARC_INS_FABSQ, + SPARC_INS_FABSS, + SPARC_INS_FADDD, + SPARC_INS_FADDQ, + SPARC_INS_FADDS, + SPARC_INS_FALIGNDATA, + SPARC_INS_FAND, + SPARC_INS_FANDNOT1, + SPARC_INS_FANDNOT1S, + SPARC_INS_FANDNOT2, + SPARC_INS_FANDNOT2S, + SPARC_INS_FANDS, + SPARC_INS_FCHKSM16, + SPARC_INS_FCMPD, + SPARC_INS_FCMPEQ16, + SPARC_INS_FCMPEQ32, + SPARC_INS_FCMPGT16, + SPARC_INS_FCMPGT32, + SPARC_INS_FCMPLE16, + SPARC_INS_FCMPLE32, + SPARC_INS_FCMPNE16, + SPARC_INS_FCMPNE32, + SPARC_INS_FCMPQ, + SPARC_INS_FCMPS, + SPARC_INS_FDIVD, + SPARC_INS_FDIVQ, + SPARC_INS_FDIVS, + SPARC_INS_FDMULQ, + SPARC_INS_FDTOI, + SPARC_INS_FDTOQ, + SPARC_INS_FDTOS, + SPARC_INS_FDTOX, + SPARC_INS_FEXPAND, + SPARC_INS_FHADDD, + SPARC_INS_FHADDS, + SPARC_INS_FHSUBD, + SPARC_INS_FHSUBS, + SPARC_INS_FITOD, + SPARC_INS_FITOQ, + SPARC_INS_FITOS, + SPARC_INS_FLCMPD, + SPARC_INS_FLCMPS, + SPARC_INS_FLUSHW, + SPARC_INS_FMEAN16, + SPARC_INS_FMOVD, + SPARC_INS_FMOVQ, + SPARC_INS_FMOVRDGEZ, + SPARC_INS_FMOVRQGEZ, + SPARC_INS_FMOVRSGEZ, + SPARC_INS_FMOVRDGZ, + SPARC_INS_FMOVRQGZ, + SPARC_INS_FMOVRSGZ, + SPARC_INS_FMOVRDLEZ, + SPARC_INS_FMOVRQLEZ, + SPARC_INS_FMOVRSLEZ, + SPARC_INS_FMOVRDLZ, + SPARC_INS_FMOVRQLZ, + SPARC_INS_FMOVRSLZ, + SPARC_INS_FMOVRDNZ, + SPARC_INS_FMOVRQNZ, + SPARC_INS_FMOVRSNZ, + SPARC_INS_FMOVRDZ, + SPARC_INS_FMOVRQZ, + SPARC_INS_FMOVRSZ, + SPARC_INS_FMOVS, + SPARC_INS_FMUL8SUX16, + SPARC_INS_FMUL8ULX16, + SPARC_INS_FMUL8X16, + SPARC_INS_FMUL8X16AL, + SPARC_INS_FMUL8X16AU, + SPARC_INS_FMULD, + SPARC_INS_FMULD8SUX16, + SPARC_INS_FMULD8ULX16, + SPARC_INS_FMULQ, + SPARC_INS_FMULS, + SPARC_INS_FNADDD, + SPARC_INS_FNADDS, + SPARC_INS_FNAND, + SPARC_INS_FNANDS, + SPARC_INS_FNEGD, + SPARC_INS_FNEGQ, + SPARC_INS_FNEGS, + SPARC_INS_FNHADDD, + SPARC_INS_FNHADDS, + SPARC_INS_FNOR, + SPARC_INS_FNORS, + SPARC_INS_FNOT1, + SPARC_INS_FNOT1S, + SPARC_INS_FNOT2, + SPARC_INS_FNOT2S, + SPARC_INS_FONE, + SPARC_INS_FONES, + SPARC_INS_FOR, + SPARC_INS_FORNOT1, + SPARC_INS_FORNOT1S, + SPARC_INS_FORNOT2, + SPARC_INS_FORNOT2S, + SPARC_INS_FORS, + SPARC_INS_FPACK16, + SPARC_INS_FPACK32, + SPARC_INS_FPACKFIX, + SPARC_INS_FPADD16, + SPARC_INS_FPADD16S, + SPARC_INS_FPADD32, + SPARC_INS_FPADD32S, + SPARC_INS_FPADD64, + SPARC_INS_FPMERGE, + SPARC_INS_FPSUB16, + SPARC_INS_FPSUB16S, + SPARC_INS_FPSUB32, + SPARC_INS_FPSUB32S, + SPARC_INS_FQTOD, + SPARC_INS_FQTOI, + SPARC_INS_FQTOS, + SPARC_INS_FQTOX, + SPARC_INS_FSLAS16, + SPARC_INS_FSLAS32, + SPARC_INS_FSLL16, + SPARC_INS_FSLL32, + SPARC_INS_FSMULD, + SPARC_INS_FSQRTD, + SPARC_INS_FSQRTQ, + SPARC_INS_FSQRTS, + SPARC_INS_FSRA16, + SPARC_INS_FSRA32, + SPARC_INS_FSRC1, + SPARC_INS_FSRC1S, + SPARC_INS_FSRC2, + SPARC_INS_FSRC2S, + SPARC_INS_FSRL16, + SPARC_INS_FSRL32, + SPARC_INS_FSTOD, + SPARC_INS_FSTOI, + SPARC_INS_FSTOQ, + SPARC_INS_FSTOX, + SPARC_INS_FSUBD, + SPARC_INS_FSUBQ, + SPARC_INS_FSUBS, + SPARC_INS_FXNOR, + SPARC_INS_FXNORS, + SPARC_INS_FXOR, + SPARC_INS_FXORS, + SPARC_INS_FXTOD, + SPARC_INS_FXTOQ, + SPARC_INS_FXTOS, + SPARC_INS_FZERO, + SPARC_INS_FZEROS, + SPARC_INS_JMPL, + SPARC_INS_LDD, + SPARC_INS_LD, + SPARC_INS_LDQ, + SPARC_INS_LDSB, + SPARC_INS_LDSH, + SPARC_INS_LDSW, + SPARC_INS_LDUB, + SPARC_INS_LDUH, + SPARC_INS_LDX, + SPARC_INS_LZCNT, + SPARC_INS_MEMBAR, + SPARC_INS_MOVDTOX, + SPARC_INS_MOV, + SPARC_INS_MOVRGEZ, + SPARC_INS_MOVRGZ, + SPARC_INS_MOVRLEZ, + SPARC_INS_MOVRLZ, + SPARC_INS_MOVRNZ, + SPARC_INS_MOVRZ, + SPARC_INS_MOVSTOSW, + SPARC_INS_MOVSTOUW, + SPARC_INS_MULX, + SPARC_INS_NOP, + SPARC_INS_ORCC, + SPARC_INS_ORNCC, + SPARC_INS_ORN, + SPARC_INS_OR, + SPARC_INS_PDIST, + SPARC_INS_PDISTN, + SPARC_INS_POPC, + SPARC_INS_RD, + SPARC_INS_RESTORE, + SPARC_INS_RETT, + SPARC_INS_SAVE, + SPARC_INS_SDIVCC, + SPARC_INS_SDIVX, + SPARC_INS_SDIV, + SPARC_INS_SETHI, + SPARC_INS_SHUTDOWN, + SPARC_INS_SIAM, + SPARC_INS_SLLX, + SPARC_INS_SLL, + SPARC_INS_SMULCC, + SPARC_INS_SMUL, + SPARC_INS_SRAX, + SPARC_INS_SRA, + SPARC_INS_SRLX, + SPARC_INS_SRL, + SPARC_INS_STBAR, + SPARC_INS_STB, + SPARC_INS_STD, + SPARC_INS_ST, + SPARC_INS_STH, + SPARC_INS_STQ, + SPARC_INS_STX, + SPARC_INS_SUBCC, + SPARC_INS_SUBX, + SPARC_INS_SUBXCC, + SPARC_INS_SUB, + SPARC_INS_SWAP, + SPARC_INS_TADDCCTV, + SPARC_INS_TADDCC, + SPARC_INS_T, + SPARC_INS_TSUBCCTV, + SPARC_INS_TSUBCC, + SPARC_INS_UDIVCC, + SPARC_INS_UDIVX, + SPARC_INS_UDIV, + SPARC_INS_UMULCC, + SPARC_INS_UMULXHI, + SPARC_INS_UMUL, + SPARC_INS_UNIMP, + SPARC_INS_FCMPED, + SPARC_INS_FCMPEQ, + SPARC_INS_FCMPES, + SPARC_INS_WR, + SPARC_INS_XMULX, + SPARC_INS_XMULXHI, + SPARC_INS_XNORCC, + SPARC_INS_XNOR, + SPARC_INS_XORCC, + SPARC_INS_XOR, + + // alias instructions + SPARC_INS_RET, + SPARC_INS_RETL, + + SPARC_INS_ENDING, // <-- mark the end of the list of instructions +} sparc_insn; + +/// Group of SPARC instructions +typedef enum sparc_insn_group { + SPARC_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + // Generic groups + // all jump instructions (conditional+direct+indirect jumps) + SPARC_GRP_JUMP, ///< = CS_GRP_JUMP + + // Architecture-specific groups + SPARC_GRP_HARDQUAD = 128, + SPARC_GRP_V9, + SPARC_GRP_VIS, + SPARC_GRP_VIS2, + SPARC_GRP_VIS3, + SPARC_GRP_32BIT, + SPARC_GRP_64BIT, + + SPARC_GRP_ENDING, // <-- mark the end of the list of groups +} sparc_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_SYSTEMZ_H +#define CAPSTONE_SYSTEMZ_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2014-2015 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// Enums corresponding to SystemZ condition codes +typedef enum sysz_cc { + SYSZ_CC_INVALID = 0, ///< invalid CC (default) + + SYSZ_CC_O, + SYSZ_CC_H, + SYSZ_CC_NLE, + SYSZ_CC_L, + SYSZ_CC_NHE, + SYSZ_CC_LH, + SYSZ_CC_NE, + SYSZ_CC_E, + SYSZ_CC_NLH, + SYSZ_CC_HE, + SYSZ_CC_NL, + SYSZ_CC_LE, + SYSZ_CC_NH, + SYSZ_CC_NO, +} sysz_cc; + +/// Operand type for instruction's operands +typedef enum sysz_op_type { + SYSZ_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + SYSZ_OP_REG, ///< = CS_OP_REG (Register operand). + SYSZ_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + SYSZ_OP_MEM, ///< = CS_OP_MEM (Memory operand). + SYSZ_OP_ACREG = 64, ///< Access register operand. +} sysz_op_type; + +/// SystemZ registers +typedef enum sysz_reg { + SYSZ_REG_INVALID = 0, + + SYSZ_REG_0, + SYSZ_REG_1, + SYSZ_REG_2, + SYSZ_REG_3, + SYSZ_REG_4, + SYSZ_REG_5, + SYSZ_REG_6, + SYSZ_REG_7, + SYSZ_REG_8, + SYSZ_REG_9, + SYSZ_REG_10, + SYSZ_REG_11, + SYSZ_REG_12, + SYSZ_REG_13, + SYSZ_REG_14, + SYSZ_REG_15, + SYSZ_REG_CC, + SYSZ_REG_F0, + SYSZ_REG_F1, + SYSZ_REG_F2, + SYSZ_REG_F3, + SYSZ_REG_F4, + SYSZ_REG_F5, + SYSZ_REG_F6, + SYSZ_REG_F7, + SYSZ_REG_F8, + SYSZ_REG_F9, + SYSZ_REG_F10, + SYSZ_REG_F11, + SYSZ_REG_F12, + SYSZ_REG_F13, + SYSZ_REG_F14, + SYSZ_REG_F15, + + SYSZ_REG_R0L, + + SYSZ_REG_A0, + SYSZ_REG_A1, + SYSZ_REG_A2, + SYSZ_REG_A3, + SYSZ_REG_A4, + SYSZ_REG_A5, + SYSZ_REG_A6, + SYSZ_REG_A7, + SYSZ_REG_A8, + SYSZ_REG_A9, + SYSZ_REG_A10, + SYSZ_REG_A11, + SYSZ_REG_A12, + SYSZ_REG_A13, + SYSZ_REG_A14, + SYSZ_REG_A15, + SYSZ_REG_C0, + SYSZ_REG_C1, + SYSZ_REG_C2, + SYSZ_REG_C3, + SYSZ_REG_C4, + SYSZ_REG_C5, + SYSZ_REG_C6, + SYSZ_REG_C7, + SYSZ_REG_C8, + SYSZ_REG_C9, + SYSZ_REG_C10, + SYSZ_REG_C11, + SYSZ_REG_C12, + SYSZ_REG_C13, + SYSZ_REG_C14, + SYSZ_REG_C15, + SYSZ_REG_V0, + SYSZ_REG_V1, + SYSZ_REG_V2, + SYSZ_REG_V3, + SYSZ_REG_V4, + SYSZ_REG_V5, + SYSZ_REG_V6, + SYSZ_REG_V7, + SYSZ_REG_V8, + SYSZ_REG_V9, + SYSZ_REG_V10, + SYSZ_REG_V11, + SYSZ_REG_V12, + SYSZ_REG_V13, + SYSZ_REG_V14, + SYSZ_REG_V15, + SYSZ_REG_V16, + SYSZ_REG_V17, + SYSZ_REG_V18, + SYSZ_REG_V19, + SYSZ_REG_V20, + SYSZ_REG_V21, + SYSZ_REG_V22, + SYSZ_REG_V23, + SYSZ_REG_V24, + SYSZ_REG_V25, + SYSZ_REG_V26, + SYSZ_REG_V27, + SYSZ_REG_V28, + SYSZ_REG_V29, + SYSZ_REG_V30, + SYSZ_REG_V31, + SYSZ_REG_F16, + SYSZ_REG_F17, + SYSZ_REG_F18, + SYSZ_REG_F19, + SYSZ_REG_F20, + SYSZ_REG_F21, + SYSZ_REG_F22, + SYSZ_REG_F23, + SYSZ_REG_F24, + SYSZ_REG_F25, + SYSZ_REG_F26, + SYSZ_REG_F27, + SYSZ_REG_F28, + SYSZ_REG_F29, + SYSZ_REG_F30, + SYSZ_REG_F31, + SYSZ_REG_F0Q, + SYSZ_REG_F4Q, + + SYSZ_REG_ENDING, +} sysz_reg; + +/// Instruction's operand referring to memory +/// This is associated with SYSZ_OP_MEM operand type above +typedef struct sysz_op_mem { + uint8_t base; ///< base register, can be safely interpreted as + ///< a value of type `sysz_reg`, but it is only + ///< one byte wide + uint8_t index; ///< index register, same conditions apply here + uint64_t length; ///< BDLAddr operand + int64_t disp; ///< displacement/offset value +} sysz_op_mem; + +/// Instruction operand +typedef struct cs_sysz_op { + sysz_op_type type; ///< operand type + union { + sysz_reg reg; ///< register value for REG operand + int64_t imm; ///< immediate value for IMM operand + sysz_op_mem mem; ///< base/disp value for MEM operand + }; +} cs_sysz_op; + +// Instruction structure +typedef struct cs_sysz { + sysz_cc cc; ///< Code condition + /// Number of operands of this instruction, + /// or 0 when instruction has no operand. + uint8_t op_count; + cs_sysz_op operands[6]; ///< operands for this instruction. +} cs_sysz; + +/// SystemZ instruction +typedef enum sysz_insn { + SYSZ_INS_INVALID = 0, + + SYSZ_INS_A, + SYSZ_INS_ADB, + SYSZ_INS_ADBR, + SYSZ_INS_AEB, + SYSZ_INS_AEBR, + SYSZ_INS_AFI, + SYSZ_INS_AG, + SYSZ_INS_AGF, + SYSZ_INS_AGFI, + SYSZ_INS_AGFR, + SYSZ_INS_AGHI, + SYSZ_INS_AGHIK, + SYSZ_INS_AGR, + SYSZ_INS_AGRK, + SYSZ_INS_AGSI, + SYSZ_INS_AH, + SYSZ_INS_AHI, + SYSZ_INS_AHIK, + SYSZ_INS_AHY, + SYSZ_INS_AIH, + SYSZ_INS_AL, + SYSZ_INS_ALC, + SYSZ_INS_ALCG, + SYSZ_INS_ALCGR, + SYSZ_INS_ALCR, + SYSZ_INS_ALFI, + SYSZ_INS_ALG, + SYSZ_INS_ALGF, + SYSZ_INS_ALGFI, + SYSZ_INS_ALGFR, + SYSZ_INS_ALGHSIK, + SYSZ_INS_ALGR, + SYSZ_INS_ALGRK, + SYSZ_INS_ALHSIK, + SYSZ_INS_ALR, + SYSZ_INS_ALRK, + SYSZ_INS_ALY, + SYSZ_INS_AR, + SYSZ_INS_ARK, + SYSZ_INS_ASI, + SYSZ_INS_AXBR, + SYSZ_INS_AY, + SYSZ_INS_BCR, + SYSZ_INS_BRC, + SYSZ_INS_BRCL, + SYSZ_INS_CGIJ, + SYSZ_INS_CGRJ, + SYSZ_INS_CIJ, + SYSZ_INS_CLGIJ, + SYSZ_INS_CLGRJ, + SYSZ_INS_CLIJ, + SYSZ_INS_CLRJ, + SYSZ_INS_CRJ, + SYSZ_INS_BER, + SYSZ_INS_JE, + SYSZ_INS_JGE, + SYSZ_INS_LOCE, + SYSZ_INS_LOCGE, + SYSZ_INS_LOCGRE, + SYSZ_INS_LOCRE, + SYSZ_INS_STOCE, + SYSZ_INS_STOCGE, + SYSZ_INS_BHR, + SYSZ_INS_BHER, + SYSZ_INS_JHE, + SYSZ_INS_JGHE, + SYSZ_INS_LOCHE, + SYSZ_INS_LOCGHE, + SYSZ_INS_LOCGRHE, + SYSZ_INS_LOCRHE, + SYSZ_INS_STOCHE, + SYSZ_INS_STOCGHE, + SYSZ_INS_JH, + SYSZ_INS_JGH, + SYSZ_INS_LOCH, + SYSZ_INS_LOCGH, + SYSZ_INS_LOCGRH, + SYSZ_INS_LOCRH, + SYSZ_INS_STOCH, + SYSZ_INS_STOCGH, + SYSZ_INS_CGIJNLH, + SYSZ_INS_CGRJNLH, + SYSZ_INS_CIJNLH, + SYSZ_INS_CLGIJNLH, + SYSZ_INS_CLGRJNLH, + SYSZ_INS_CLIJNLH, + SYSZ_INS_CLRJNLH, + SYSZ_INS_CRJNLH, + SYSZ_INS_CGIJE, + SYSZ_INS_CGRJE, + SYSZ_INS_CIJE, + SYSZ_INS_CLGIJE, + SYSZ_INS_CLGRJE, + SYSZ_INS_CLIJE, + SYSZ_INS_CLRJE, + SYSZ_INS_CRJE, + SYSZ_INS_CGIJNLE, + SYSZ_INS_CGRJNLE, + SYSZ_INS_CIJNLE, + SYSZ_INS_CLGIJNLE, + SYSZ_INS_CLGRJNLE, + SYSZ_INS_CLIJNLE, + SYSZ_INS_CLRJNLE, + SYSZ_INS_CRJNLE, + SYSZ_INS_CGIJH, + SYSZ_INS_CGRJH, + SYSZ_INS_CIJH, + SYSZ_INS_CLGIJH, + SYSZ_INS_CLGRJH, + SYSZ_INS_CLIJH, + SYSZ_INS_CLRJH, + SYSZ_INS_CRJH, + SYSZ_INS_CGIJNL, + SYSZ_INS_CGRJNL, + SYSZ_INS_CIJNL, + SYSZ_INS_CLGIJNL, + SYSZ_INS_CLGRJNL, + SYSZ_INS_CLIJNL, + SYSZ_INS_CLRJNL, + SYSZ_INS_CRJNL, + SYSZ_INS_CGIJHE, + SYSZ_INS_CGRJHE, + SYSZ_INS_CIJHE, + SYSZ_INS_CLGIJHE, + SYSZ_INS_CLGRJHE, + SYSZ_INS_CLIJHE, + SYSZ_INS_CLRJHE, + SYSZ_INS_CRJHE, + SYSZ_INS_CGIJNHE, + SYSZ_INS_CGRJNHE, + SYSZ_INS_CIJNHE, + SYSZ_INS_CLGIJNHE, + SYSZ_INS_CLGRJNHE, + SYSZ_INS_CLIJNHE, + SYSZ_INS_CLRJNHE, + SYSZ_INS_CRJNHE, + SYSZ_INS_CGIJL, + SYSZ_INS_CGRJL, + SYSZ_INS_CIJL, + SYSZ_INS_CLGIJL, + SYSZ_INS_CLGRJL, + SYSZ_INS_CLIJL, + SYSZ_INS_CLRJL, + SYSZ_INS_CRJL, + SYSZ_INS_CGIJNH, + SYSZ_INS_CGRJNH, + SYSZ_INS_CIJNH, + SYSZ_INS_CLGIJNH, + SYSZ_INS_CLGRJNH, + SYSZ_INS_CLIJNH, + SYSZ_INS_CLRJNH, + SYSZ_INS_CRJNH, + SYSZ_INS_CGIJLE, + SYSZ_INS_CGRJLE, + SYSZ_INS_CIJLE, + SYSZ_INS_CLGIJLE, + SYSZ_INS_CLGRJLE, + SYSZ_INS_CLIJLE, + SYSZ_INS_CLRJLE, + SYSZ_INS_CRJLE, + SYSZ_INS_CGIJNE, + SYSZ_INS_CGRJNE, + SYSZ_INS_CIJNE, + SYSZ_INS_CLGIJNE, + SYSZ_INS_CLGRJNE, + SYSZ_INS_CLIJNE, + SYSZ_INS_CLRJNE, + SYSZ_INS_CRJNE, + SYSZ_INS_CGIJLH, + SYSZ_INS_CGRJLH, + SYSZ_INS_CIJLH, + SYSZ_INS_CLGIJLH, + SYSZ_INS_CLGRJLH, + SYSZ_INS_CLIJLH, + SYSZ_INS_CLRJLH, + SYSZ_INS_CRJLH, + SYSZ_INS_BLR, + SYSZ_INS_BLER, + SYSZ_INS_JLE, + SYSZ_INS_JGLE, + SYSZ_INS_LOCLE, + SYSZ_INS_LOCGLE, + SYSZ_INS_LOCGRLE, + SYSZ_INS_LOCRLE, + SYSZ_INS_STOCLE, + SYSZ_INS_STOCGLE, + SYSZ_INS_BLHR, + SYSZ_INS_JLH, + SYSZ_INS_JGLH, + SYSZ_INS_LOCLH, + SYSZ_INS_LOCGLH, + SYSZ_INS_LOCGRLH, + SYSZ_INS_LOCRLH, + SYSZ_INS_STOCLH, + SYSZ_INS_STOCGLH, + SYSZ_INS_JL, + SYSZ_INS_JGL, + SYSZ_INS_LOCL, + SYSZ_INS_LOCGL, + SYSZ_INS_LOCGRL, + SYSZ_INS_LOCRL, + SYSZ_INS_LOC, + SYSZ_INS_LOCG, + SYSZ_INS_LOCGR, + SYSZ_INS_LOCR, + SYSZ_INS_STOCL, + SYSZ_INS_STOCGL, + SYSZ_INS_BNER, + SYSZ_INS_JNE, + SYSZ_INS_JGNE, + SYSZ_INS_LOCNE, + SYSZ_INS_LOCGNE, + SYSZ_INS_LOCGRNE, + SYSZ_INS_LOCRNE, + SYSZ_INS_STOCNE, + SYSZ_INS_STOCGNE, + SYSZ_INS_BNHR, + SYSZ_INS_BNHER, + SYSZ_INS_JNHE, + SYSZ_INS_JGNHE, + SYSZ_INS_LOCNHE, + SYSZ_INS_LOCGNHE, + SYSZ_INS_LOCGRNHE, + SYSZ_INS_LOCRNHE, + SYSZ_INS_STOCNHE, + SYSZ_INS_STOCGNHE, + SYSZ_INS_JNH, + SYSZ_INS_JGNH, + SYSZ_INS_LOCNH, + SYSZ_INS_LOCGNH, + SYSZ_INS_LOCGRNH, + SYSZ_INS_LOCRNH, + SYSZ_INS_STOCNH, + SYSZ_INS_STOCGNH, + SYSZ_INS_BNLR, + SYSZ_INS_BNLER, + SYSZ_INS_JNLE, + SYSZ_INS_JGNLE, + SYSZ_INS_LOCNLE, + SYSZ_INS_LOCGNLE, + SYSZ_INS_LOCGRNLE, + SYSZ_INS_LOCRNLE, + SYSZ_INS_STOCNLE, + SYSZ_INS_STOCGNLE, + SYSZ_INS_BNLHR, + SYSZ_INS_JNLH, + SYSZ_INS_JGNLH, + SYSZ_INS_LOCNLH, + SYSZ_INS_LOCGNLH, + SYSZ_INS_LOCGRNLH, + SYSZ_INS_LOCRNLH, + SYSZ_INS_STOCNLH, + SYSZ_INS_STOCGNLH, + SYSZ_INS_JNL, + SYSZ_INS_JGNL, + SYSZ_INS_LOCNL, + SYSZ_INS_LOCGNL, + SYSZ_INS_LOCGRNL, + SYSZ_INS_LOCRNL, + SYSZ_INS_STOCNL, + SYSZ_INS_STOCGNL, + SYSZ_INS_BNOR, + SYSZ_INS_JNO, + SYSZ_INS_JGNO, + SYSZ_INS_LOCNO, + SYSZ_INS_LOCGNO, + SYSZ_INS_LOCGRNO, + SYSZ_INS_LOCRNO, + SYSZ_INS_STOCNO, + SYSZ_INS_STOCGNO, + SYSZ_INS_BOR, + SYSZ_INS_JO, + SYSZ_INS_JGO, + SYSZ_INS_LOCO, + SYSZ_INS_LOCGO, + SYSZ_INS_LOCGRO, + SYSZ_INS_LOCRO, + SYSZ_INS_STOCO, + SYSZ_INS_STOCGO, + SYSZ_INS_STOC, + SYSZ_INS_STOCG, + SYSZ_INS_BASR, + SYSZ_INS_BR, + SYSZ_INS_BRAS, + SYSZ_INS_BRASL, + SYSZ_INS_J, + SYSZ_INS_JG, + SYSZ_INS_BRCT, + SYSZ_INS_BRCTG, + SYSZ_INS_C, + SYSZ_INS_CDB, + SYSZ_INS_CDBR, + SYSZ_INS_CDFBR, + SYSZ_INS_CDGBR, + SYSZ_INS_CDLFBR, + SYSZ_INS_CDLGBR, + SYSZ_INS_CEB, + SYSZ_INS_CEBR, + SYSZ_INS_CEFBR, + SYSZ_INS_CEGBR, + SYSZ_INS_CELFBR, + SYSZ_INS_CELGBR, + SYSZ_INS_CFDBR, + SYSZ_INS_CFEBR, + SYSZ_INS_CFI, + SYSZ_INS_CFXBR, + SYSZ_INS_CG, + SYSZ_INS_CGDBR, + SYSZ_INS_CGEBR, + SYSZ_INS_CGF, + SYSZ_INS_CGFI, + SYSZ_INS_CGFR, + SYSZ_INS_CGFRL, + SYSZ_INS_CGH, + SYSZ_INS_CGHI, + SYSZ_INS_CGHRL, + SYSZ_INS_CGHSI, + SYSZ_INS_CGR, + SYSZ_INS_CGRL, + SYSZ_INS_CGXBR, + SYSZ_INS_CH, + SYSZ_INS_CHF, + SYSZ_INS_CHHSI, + SYSZ_INS_CHI, + SYSZ_INS_CHRL, + SYSZ_INS_CHSI, + SYSZ_INS_CHY, + SYSZ_INS_CIH, + SYSZ_INS_CL, + SYSZ_INS_CLC, + SYSZ_INS_CLFDBR, + SYSZ_INS_CLFEBR, + SYSZ_INS_CLFHSI, + SYSZ_INS_CLFI, + SYSZ_INS_CLFXBR, + SYSZ_INS_CLG, + SYSZ_INS_CLGDBR, + SYSZ_INS_CLGEBR, + SYSZ_INS_CLGF, + SYSZ_INS_CLGFI, + SYSZ_INS_CLGFR, + SYSZ_INS_CLGFRL, + SYSZ_INS_CLGHRL, + SYSZ_INS_CLGHSI, + SYSZ_INS_CLGR, + SYSZ_INS_CLGRL, + SYSZ_INS_CLGXBR, + SYSZ_INS_CLHF, + SYSZ_INS_CLHHSI, + SYSZ_INS_CLHRL, + SYSZ_INS_CLI, + SYSZ_INS_CLIH, + SYSZ_INS_CLIY, + SYSZ_INS_CLR, + SYSZ_INS_CLRL, + SYSZ_INS_CLST, + SYSZ_INS_CLY, + SYSZ_INS_CPSDR, + SYSZ_INS_CR, + SYSZ_INS_CRL, + SYSZ_INS_CS, + SYSZ_INS_CSG, + SYSZ_INS_CSY, + SYSZ_INS_CXBR, + SYSZ_INS_CXFBR, + SYSZ_INS_CXGBR, + SYSZ_INS_CXLFBR, + SYSZ_INS_CXLGBR, + SYSZ_INS_CY, + SYSZ_INS_DDB, + SYSZ_INS_DDBR, + SYSZ_INS_DEB, + SYSZ_INS_DEBR, + SYSZ_INS_DL, + SYSZ_INS_DLG, + SYSZ_INS_DLGR, + SYSZ_INS_DLR, + SYSZ_INS_DSG, + SYSZ_INS_DSGF, + SYSZ_INS_DSGFR, + SYSZ_INS_DSGR, + SYSZ_INS_DXBR, + SYSZ_INS_EAR, + SYSZ_INS_FIDBR, + SYSZ_INS_FIDBRA, + SYSZ_INS_FIEBR, + SYSZ_INS_FIEBRA, + SYSZ_INS_FIXBR, + SYSZ_INS_FIXBRA, + SYSZ_INS_FLOGR, + SYSZ_INS_IC, + SYSZ_INS_ICY, + SYSZ_INS_IIHF, + SYSZ_INS_IIHH, + SYSZ_INS_IIHL, + SYSZ_INS_IILF, + SYSZ_INS_IILH, + SYSZ_INS_IILL, + SYSZ_INS_IPM, + SYSZ_INS_L, + SYSZ_INS_LA, + SYSZ_INS_LAA, + SYSZ_INS_LAAG, + SYSZ_INS_LAAL, + SYSZ_INS_LAALG, + SYSZ_INS_LAN, + SYSZ_INS_LANG, + SYSZ_INS_LAO, + SYSZ_INS_LAOG, + SYSZ_INS_LARL, + SYSZ_INS_LAX, + SYSZ_INS_LAXG, + SYSZ_INS_LAY, + SYSZ_INS_LB, + SYSZ_INS_LBH, + SYSZ_INS_LBR, + SYSZ_INS_LCDBR, + SYSZ_INS_LCEBR, + SYSZ_INS_LCGFR, + SYSZ_INS_LCGR, + SYSZ_INS_LCR, + SYSZ_INS_LCXBR, + SYSZ_INS_LD, + SYSZ_INS_LDEB, + SYSZ_INS_LDEBR, + SYSZ_INS_LDGR, + SYSZ_INS_LDR, + SYSZ_INS_LDXBR, + SYSZ_INS_LDXBRA, + SYSZ_INS_LDY, + SYSZ_INS_LE, + SYSZ_INS_LEDBR, + SYSZ_INS_LEDBRA, + SYSZ_INS_LER, + SYSZ_INS_LEXBR, + SYSZ_INS_LEXBRA, + SYSZ_INS_LEY, + SYSZ_INS_LFH, + SYSZ_INS_LG, + SYSZ_INS_LGB, + SYSZ_INS_LGBR, + SYSZ_INS_LGDR, + SYSZ_INS_LGF, + SYSZ_INS_LGFI, + SYSZ_INS_LGFR, + SYSZ_INS_LGFRL, + SYSZ_INS_LGH, + SYSZ_INS_LGHI, + SYSZ_INS_LGHR, + SYSZ_INS_LGHRL, + SYSZ_INS_LGR, + SYSZ_INS_LGRL, + SYSZ_INS_LH, + SYSZ_INS_LHH, + SYSZ_INS_LHI, + SYSZ_INS_LHR, + SYSZ_INS_LHRL, + SYSZ_INS_LHY, + SYSZ_INS_LLC, + SYSZ_INS_LLCH, + SYSZ_INS_LLCR, + SYSZ_INS_LLGC, + SYSZ_INS_LLGCR, + SYSZ_INS_LLGF, + SYSZ_INS_LLGFR, + SYSZ_INS_LLGFRL, + SYSZ_INS_LLGH, + SYSZ_INS_LLGHR, + SYSZ_INS_LLGHRL, + SYSZ_INS_LLH, + SYSZ_INS_LLHH, + SYSZ_INS_LLHR, + SYSZ_INS_LLHRL, + SYSZ_INS_LLIHF, + SYSZ_INS_LLIHH, + SYSZ_INS_LLIHL, + SYSZ_INS_LLILF, + SYSZ_INS_LLILH, + SYSZ_INS_LLILL, + SYSZ_INS_LMG, + SYSZ_INS_LNDBR, + SYSZ_INS_LNEBR, + SYSZ_INS_LNGFR, + SYSZ_INS_LNGR, + SYSZ_INS_LNR, + SYSZ_INS_LNXBR, + SYSZ_INS_LPDBR, + SYSZ_INS_LPEBR, + SYSZ_INS_LPGFR, + SYSZ_INS_LPGR, + SYSZ_INS_LPR, + SYSZ_INS_LPXBR, + SYSZ_INS_LR, + SYSZ_INS_LRL, + SYSZ_INS_LRV, + SYSZ_INS_LRVG, + SYSZ_INS_LRVGR, + SYSZ_INS_LRVR, + SYSZ_INS_LT, + SYSZ_INS_LTDBR, + SYSZ_INS_LTEBR, + SYSZ_INS_LTG, + SYSZ_INS_LTGF, + SYSZ_INS_LTGFR, + SYSZ_INS_LTGR, + SYSZ_INS_LTR, + SYSZ_INS_LTXBR, + SYSZ_INS_LXDB, + SYSZ_INS_LXDBR, + SYSZ_INS_LXEB, + SYSZ_INS_LXEBR, + SYSZ_INS_LXR, + SYSZ_INS_LY, + SYSZ_INS_LZDR, + SYSZ_INS_LZER, + SYSZ_INS_LZXR, + SYSZ_INS_MADB, + SYSZ_INS_MADBR, + SYSZ_INS_MAEB, + SYSZ_INS_MAEBR, + SYSZ_INS_MDB, + SYSZ_INS_MDBR, + SYSZ_INS_MDEB, + SYSZ_INS_MDEBR, + SYSZ_INS_MEEB, + SYSZ_INS_MEEBR, + SYSZ_INS_MGHI, + SYSZ_INS_MH, + SYSZ_INS_MHI, + SYSZ_INS_MHY, + SYSZ_INS_MLG, + SYSZ_INS_MLGR, + SYSZ_INS_MS, + SYSZ_INS_MSDB, + SYSZ_INS_MSDBR, + SYSZ_INS_MSEB, + SYSZ_INS_MSEBR, + SYSZ_INS_MSFI, + SYSZ_INS_MSG, + SYSZ_INS_MSGF, + SYSZ_INS_MSGFI, + SYSZ_INS_MSGFR, + SYSZ_INS_MSGR, + SYSZ_INS_MSR, + SYSZ_INS_MSY, + SYSZ_INS_MVC, + SYSZ_INS_MVGHI, + SYSZ_INS_MVHHI, + SYSZ_INS_MVHI, + SYSZ_INS_MVI, + SYSZ_INS_MVIY, + SYSZ_INS_MVST, + SYSZ_INS_MXBR, + SYSZ_INS_MXDB, + SYSZ_INS_MXDBR, + SYSZ_INS_N, + SYSZ_INS_NC, + SYSZ_INS_NG, + SYSZ_INS_NGR, + SYSZ_INS_NGRK, + SYSZ_INS_NI, + SYSZ_INS_NIHF, + SYSZ_INS_NIHH, + SYSZ_INS_NIHL, + SYSZ_INS_NILF, + SYSZ_INS_NILH, + SYSZ_INS_NILL, + SYSZ_INS_NIY, + SYSZ_INS_NR, + SYSZ_INS_NRK, + SYSZ_INS_NY, + SYSZ_INS_O, + SYSZ_INS_OC, + SYSZ_INS_OG, + SYSZ_INS_OGR, + SYSZ_INS_OGRK, + SYSZ_INS_OI, + SYSZ_INS_OIHF, + SYSZ_INS_OIHH, + SYSZ_INS_OIHL, + SYSZ_INS_OILF, + SYSZ_INS_OILH, + SYSZ_INS_OILL, + SYSZ_INS_OIY, + SYSZ_INS_OR, + SYSZ_INS_ORK, + SYSZ_INS_OY, + SYSZ_INS_PFD, + SYSZ_INS_PFDRL, + SYSZ_INS_RISBG, + SYSZ_INS_RISBHG, + SYSZ_INS_RISBLG, + SYSZ_INS_RLL, + SYSZ_INS_RLLG, + SYSZ_INS_RNSBG, + SYSZ_INS_ROSBG, + SYSZ_INS_RXSBG, + SYSZ_INS_S, + SYSZ_INS_SDB, + SYSZ_INS_SDBR, + SYSZ_INS_SEB, + SYSZ_INS_SEBR, + SYSZ_INS_SG, + SYSZ_INS_SGF, + SYSZ_INS_SGFR, + SYSZ_INS_SGR, + SYSZ_INS_SGRK, + SYSZ_INS_SH, + SYSZ_INS_SHY, + SYSZ_INS_SL, + SYSZ_INS_SLB, + SYSZ_INS_SLBG, + SYSZ_INS_SLBR, + SYSZ_INS_SLFI, + SYSZ_INS_SLG, + SYSZ_INS_SLBGR, + SYSZ_INS_SLGF, + SYSZ_INS_SLGFI, + SYSZ_INS_SLGFR, + SYSZ_INS_SLGR, + SYSZ_INS_SLGRK, + SYSZ_INS_SLL, + SYSZ_INS_SLLG, + SYSZ_INS_SLLK, + SYSZ_INS_SLR, + SYSZ_INS_SLRK, + SYSZ_INS_SLY, + SYSZ_INS_SQDB, + SYSZ_INS_SQDBR, + SYSZ_INS_SQEB, + SYSZ_INS_SQEBR, + SYSZ_INS_SQXBR, + SYSZ_INS_SR, + SYSZ_INS_SRA, + SYSZ_INS_SRAG, + SYSZ_INS_SRAK, + SYSZ_INS_SRK, + SYSZ_INS_SRL, + SYSZ_INS_SRLG, + SYSZ_INS_SRLK, + SYSZ_INS_SRST, + SYSZ_INS_ST, + SYSZ_INS_STC, + SYSZ_INS_STCH, + SYSZ_INS_STCY, + SYSZ_INS_STD, + SYSZ_INS_STDY, + SYSZ_INS_STE, + SYSZ_INS_STEY, + SYSZ_INS_STFH, + SYSZ_INS_STG, + SYSZ_INS_STGRL, + SYSZ_INS_STH, + SYSZ_INS_STHH, + SYSZ_INS_STHRL, + SYSZ_INS_STHY, + SYSZ_INS_STMG, + SYSZ_INS_STRL, + SYSZ_INS_STRV, + SYSZ_INS_STRVG, + SYSZ_INS_STY, + SYSZ_INS_SXBR, + SYSZ_INS_SY, + SYSZ_INS_TM, + SYSZ_INS_TMHH, + SYSZ_INS_TMHL, + SYSZ_INS_TMLH, + SYSZ_INS_TMLL, + SYSZ_INS_TMY, + SYSZ_INS_X, + SYSZ_INS_XC, + SYSZ_INS_XG, + SYSZ_INS_XGR, + SYSZ_INS_XGRK, + SYSZ_INS_XI, + SYSZ_INS_XIHF, + SYSZ_INS_XILF, + SYSZ_INS_XIY, + SYSZ_INS_XR, + SYSZ_INS_XRK, + SYSZ_INS_XY, + SYSZ_INS_AD, + SYSZ_INS_ADR, + SYSZ_INS_ADTR, + SYSZ_INS_ADTRA, + SYSZ_INS_AE, + SYSZ_INS_AER, + SYSZ_INS_AGH, + SYSZ_INS_AHHHR, + SYSZ_INS_AHHLR, + SYSZ_INS_ALGSI, + SYSZ_INS_ALHHHR, + SYSZ_INS_ALHHLR, + SYSZ_INS_ALSI, + SYSZ_INS_ALSIH, + SYSZ_INS_ALSIHN, + SYSZ_INS_AP, + SYSZ_INS_AU, + SYSZ_INS_AUR, + SYSZ_INS_AW, + SYSZ_INS_AWR, + SYSZ_INS_AXR, + SYSZ_INS_AXTR, + SYSZ_INS_AXTRA, + SYSZ_INS_B, + SYSZ_INS_BAKR, + SYSZ_INS_BAL, + SYSZ_INS_BALR, + SYSZ_INS_BAS, + SYSZ_INS_BASSM, + SYSZ_INS_BC, + SYSZ_INS_BCT, + SYSZ_INS_BCTG, + SYSZ_INS_BCTGR, + SYSZ_INS_BCTR, + SYSZ_INS_BE, + SYSZ_INS_BH, + SYSZ_INS_BHE, + SYSZ_INS_BI, + SYSZ_INS_BIC, + SYSZ_INS_BIE, + SYSZ_INS_BIH, + SYSZ_INS_BIHE, + SYSZ_INS_BIL, + SYSZ_INS_BILE, + SYSZ_INS_BILH, + SYSZ_INS_BIM, + SYSZ_INS_BINE, + SYSZ_INS_BINH, + SYSZ_INS_BINHE, + SYSZ_INS_BINL, + SYSZ_INS_BINLE, + SYSZ_INS_BINLH, + SYSZ_INS_BINM, + SYSZ_INS_BINO, + SYSZ_INS_BINP, + SYSZ_INS_BINZ, + SYSZ_INS_BIO, + SYSZ_INS_BIP, + SYSZ_INS_BIZ, + SYSZ_INS_BL, + SYSZ_INS_BLE, + SYSZ_INS_BLH, + SYSZ_INS_BM, + SYSZ_INS_BMR, + SYSZ_INS_BNE, + SYSZ_INS_BNH, + SYSZ_INS_BNHE, + SYSZ_INS_BNL, + SYSZ_INS_BNLE, + SYSZ_INS_BNLH, + SYSZ_INS_BNM, + SYSZ_INS_BNMR, + SYSZ_INS_BNO, + SYSZ_INS_BNP, + SYSZ_INS_BNPR, + SYSZ_INS_BNZ, + SYSZ_INS_BNZR, + SYSZ_INS_BO, + SYSZ_INS_BP, + SYSZ_INS_BPP, + SYSZ_INS_BPR, + SYSZ_INS_BPRP, + SYSZ_INS_BRCTH, + SYSZ_INS_BRXH, + SYSZ_INS_BRXHG, + SYSZ_INS_BRXLE, + SYSZ_INS_BRXLG, + SYSZ_INS_BSA, + SYSZ_INS_BSG, + SYSZ_INS_BSM, + SYSZ_INS_BXH, + SYSZ_INS_BXHG, + SYSZ_INS_BXLE, + SYSZ_INS_BXLEG, + SYSZ_INS_BZ, + SYSZ_INS_BZR, + SYSZ_INS_CD, + SYSZ_INS_CDFBRA, + SYSZ_INS_CDFR, + SYSZ_INS_CDFTR, + SYSZ_INS_CDGBRA, + SYSZ_INS_CDGR, + SYSZ_INS_CDGTR, + SYSZ_INS_CDGTRA, + SYSZ_INS_CDLFTR, + SYSZ_INS_CDLGTR, + SYSZ_INS_CDPT, + SYSZ_INS_CDR, + SYSZ_INS_CDS, + SYSZ_INS_CDSG, + SYSZ_INS_CDSTR, + SYSZ_INS_CDSY, + SYSZ_INS_CDTR, + SYSZ_INS_CDUTR, + SYSZ_INS_CDZT, + SYSZ_INS_CE, + SYSZ_INS_CEDTR, + SYSZ_INS_CEFBRA, + SYSZ_INS_CEFR, + SYSZ_INS_CEGBRA, + SYSZ_INS_CEGR, + SYSZ_INS_CER, + SYSZ_INS_CEXTR, + SYSZ_INS_CFC, + SYSZ_INS_CFDBRA, + SYSZ_INS_CFDR, + SYSZ_INS_CFDTR, + SYSZ_INS_CFEBRA, + SYSZ_INS_CFER, + SYSZ_INS_CFXBRA, + SYSZ_INS_CFXR, + SYSZ_INS_CFXTR, + SYSZ_INS_CGDBRA, + SYSZ_INS_CGDR, + SYSZ_INS_CGDTR, + SYSZ_INS_CGDTRA, + SYSZ_INS_CGEBRA, + SYSZ_INS_CGER, + SYSZ_INS_CGIB, + SYSZ_INS_CGIBE, + SYSZ_INS_CGIBH, + SYSZ_INS_CGIBHE, + SYSZ_INS_CGIBL, + SYSZ_INS_CGIBLE, + SYSZ_INS_CGIBLH, + SYSZ_INS_CGIBNE, + SYSZ_INS_CGIBNH, + SYSZ_INS_CGIBNHE, + SYSZ_INS_CGIBNL, + SYSZ_INS_CGIBNLE, + SYSZ_INS_CGIBNLH, + SYSZ_INS_CGIT, + SYSZ_INS_CGITE, + SYSZ_INS_CGITH, + SYSZ_INS_CGITHE, + SYSZ_INS_CGITL, + SYSZ_INS_CGITLE, + SYSZ_INS_CGITLH, + SYSZ_INS_CGITNE, + SYSZ_INS_CGITNH, + SYSZ_INS_CGITNHE, + SYSZ_INS_CGITNL, + SYSZ_INS_CGITNLE, + SYSZ_INS_CGITNLH, + SYSZ_INS_CGRB, + SYSZ_INS_CGRBE, + SYSZ_INS_CGRBH, + SYSZ_INS_CGRBHE, + SYSZ_INS_CGRBL, + SYSZ_INS_CGRBLE, + SYSZ_INS_CGRBLH, + SYSZ_INS_CGRBNE, + SYSZ_INS_CGRBNH, + SYSZ_INS_CGRBNHE, + SYSZ_INS_CGRBNL, + SYSZ_INS_CGRBNLE, + SYSZ_INS_CGRBNLH, + SYSZ_INS_CGRT, + SYSZ_INS_CGRTE, + SYSZ_INS_CGRTH, + SYSZ_INS_CGRTHE, + SYSZ_INS_CGRTL, + SYSZ_INS_CGRTLE, + SYSZ_INS_CGRTLH, + SYSZ_INS_CGRTNE, + SYSZ_INS_CGRTNH, + SYSZ_INS_CGRTNHE, + SYSZ_INS_CGRTNL, + SYSZ_INS_CGRTNLE, + SYSZ_INS_CGRTNLH, + SYSZ_INS_CGXBRA, + SYSZ_INS_CGXR, + SYSZ_INS_CGXTR, + SYSZ_INS_CGXTRA, + SYSZ_INS_CHHR, + SYSZ_INS_CHLR, + SYSZ_INS_CIB, + SYSZ_INS_CIBE, + SYSZ_INS_CIBH, + SYSZ_INS_CIBHE, + SYSZ_INS_CIBL, + SYSZ_INS_CIBLE, + SYSZ_INS_CIBLH, + SYSZ_INS_CIBNE, + SYSZ_INS_CIBNH, + SYSZ_INS_CIBNHE, + SYSZ_INS_CIBNL, + SYSZ_INS_CIBNLE, + SYSZ_INS_CIBNLH, + SYSZ_INS_CIT, + SYSZ_INS_CITE, + SYSZ_INS_CITH, + SYSZ_INS_CITHE, + SYSZ_INS_CITL, + SYSZ_INS_CITLE, + SYSZ_INS_CITLH, + SYSZ_INS_CITNE, + SYSZ_INS_CITNH, + SYSZ_INS_CITNHE, + SYSZ_INS_CITNL, + SYSZ_INS_CITNLE, + SYSZ_INS_CITNLH, + SYSZ_INS_CKSM, + SYSZ_INS_CLCL, + SYSZ_INS_CLCLE, + SYSZ_INS_CLCLU, + SYSZ_INS_CLFDTR, + SYSZ_INS_CLFIT, + SYSZ_INS_CLFITE, + SYSZ_INS_CLFITH, + SYSZ_INS_CLFITHE, + SYSZ_INS_CLFITL, + SYSZ_INS_CLFITLE, + SYSZ_INS_CLFITLH, + SYSZ_INS_CLFITNE, + SYSZ_INS_CLFITNH, + SYSZ_INS_CLFITNHE, + SYSZ_INS_CLFITNL, + SYSZ_INS_CLFITNLE, + SYSZ_INS_CLFITNLH, + SYSZ_INS_CLFXTR, + SYSZ_INS_CLGDTR, + SYSZ_INS_CLGIB, + SYSZ_INS_CLGIBE, + SYSZ_INS_CLGIBH, + SYSZ_INS_CLGIBHE, + SYSZ_INS_CLGIBL, + SYSZ_INS_CLGIBLE, + SYSZ_INS_CLGIBLH, + SYSZ_INS_CLGIBNE, + SYSZ_INS_CLGIBNH, + SYSZ_INS_CLGIBNHE, + SYSZ_INS_CLGIBNL, + SYSZ_INS_CLGIBNLE, + SYSZ_INS_CLGIBNLH, + SYSZ_INS_CLGIT, + SYSZ_INS_CLGITE, + SYSZ_INS_CLGITH, + SYSZ_INS_CLGITHE, + SYSZ_INS_CLGITL, + SYSZ_INS_CLGITLE, + SYSZ_INS_CLGITLH, + SYSZ_INS_CLGITNE, + SYSZ_INS_CLGITNH, + SYSZ_INS_CLGITNHE, + SYSZ_INS_CLGITNL, + SYSZ_INS_CLGITNLE, + SYSZ_INS_CLGITNLH, + SYSZ_INS_CLGRB, + SYSZ_INS_CLGRBE, + SYSZ_INS_CLGRBH, + SYSZ_INS_CLGRBHE, + SYSZ_INS_CLGRBL, + SYSZ_INS_CLGRBLE, + SYSZ_INS_CLGRBLH, + SYSZ_INS_CLGRBNE, + SYSZ_INS_CLGRBNH, + SYSZ_INS_CLGRBNHE, + SYSZ_INS_CLGRBNL, + SYSZ_INS_CLGRBNLE, + SYSZ_INS_CLGRBNLH, + SYSZ_INS_CLGRT, + SYSZ_INS_CLGRTE, + SYSZ_INS_CLGRTH, + SYSZ_INS_CLGRTHE, + SYSZ_INS_CLGRTL, + SYSZ_INS_CLGRTLE, + SYSZ_INS_CLGRTLH, + SYSZ_INS_CLGRTNE, + SYSZ_INS_CLGRTNH, + SYSZ_INS_CLGRTNHE, + SYSZ_INS_CLGRTNL, + SYSZ_INS_CLGRTNLE, + SYSZ_INS_CLGRTNLH, + SYSZ_INS_CLGT, + SYSZ_INS_CLGTE, + SYSZ_INS_CLGTH, + SYSZ_INS_CLGTHE, + SYSZ_INS_CLGTL, + SYSZ_INS_CLGTLE, + SYSZ_INS_CLGTLH, + SYSZ_INS_CLGTNE, + SYSZ_INS_CLGTNH, + SYSZ_INS_CLGTNHE, + SYSZ_INS_CLGTNL, + SYSZ_INS_CLGTNLE, + SYSZ_INS_CLGTNLH, + SYSZ_INS_CLGXTR, + SYSZ_INS_CLHHR, + SYSZ_INS_CLHLR, + SYSZ_INS_CLIB, + SYSZ_INS_CLIBE, + SYSZ_INS_CLIBH, + SYSZ_INS_CLIBHE, + SYSZ_INS_CLIBL, + SYSZ_INS_CLIBLE, + SYSZ_INS_CLIBLH, + SYSZ_INS_CLIBNE, + SYSZ_INS_CLIBNH, + SYSZ_INS_CLIBNHE, + SYSZ_INS_CLIBNL, + SYSZ_INS_CLIBNLE, + SYSZ_INS_CLIBNLH, + SYSZ_INS_CLM, + SYSZ_INS_CLMH, + SYSZ_INS_CLMY, + SYSZ_INS_CLRB, + SYSZ_INS_CLRBE, + SYSZ_INS_CLRBH, + SYSZ_INS_CLRBHE, + SYSZ_INS_CLRBL, + SYSZ_INS_CLRBLE, + SYSZ_INS_CLRBLH, + SYSZ_INS_CLRBNE, + SYSZ_INS_CLRBNH, + SYSZ_INS_CLRBNHE, + SYSZ_INS_CLRBNL, + SYSZ_INS_CLRBNLE, + SYSZ_INS_CLRBNLH, + SYSZ_INS_CLRT, + SYSZ_INS_CLRTE, + SYSZ_INS_CLRTH, + SYSZ_INS_CLRTHE, + SYSZ_INS_CLRTL, + SYSZ_INS_CLRTLE, + SYSZ_INS_CLRTLH, + SYSZ_INS_CLRTNE, + SYSZ_INS_CLRTNH, + SYSZ_INS_CLRTNHE, + SYSZ_INS_CLRTNL, + SYSZ_INS_CLRTNLE, + SYSZ_INS_CLRTNLH, + SYSZ_INS_CLT, + SYSZ_INS_CLTE, + SYSZ_INS_CLTH, + SYSZ_INS_CLTHE, + SYSZ_INS_CLTL, + SYSZ_INS_CLTLE, + SYSZ_INS_CLTLH, + SYSZ_INS_CLTNE, + SYSZ_INS_CLTNH, + SYSZ_INS_CLTNHE, + SYSZ_INS_CLTNL, + SYSZ_INS_CLTNLE, + SYSZ_INS_CLTNLH, + SYSZ_INS_CMPSC, + SYSZ_INS_CP, + SYSZ_INS_CPDT, + SYSZ_INS_CPXT, + SYSZ_INS_CPYA, + SYSZ_INS_CRB, + SYSZ_INS_CRBE, + SYSZ_INS_CRBH, + SYSZ_INS_CRBHE, + SYSZ_INS_CRBL, + SYSZ_INS_CRBLE, + SYSZ_INS_CRBLH, + SYSZ_INS_CRBNE, + SYSZ_INS_CRBNH, + SYSZ_INS_CRBNHE, + SYSZ_INS_CRBNL, + SYSZ_INS_CRBNLE, + SYSZ_INS_CRBNLH, + SYSZ_INS_CRDTE, + SYSZ_INS_CRT, + SYSZ_INS_CRTE, + SYSZ_INS_CRTH, + SYSZ_INS_CRTHE, + SYSZ_INS_CRTL, + SYSZ_INS_CRTLE, + SYSZ_INS_CRTLH, + SYSZ_INS_CRTNE, + SYSZ_INS_CRTNH, + SYSZ_INS_CRTNHE, + SYSZ_INS_CRTNL, + SYSZ_INS_CRTNLE, + SYSZ_INS_CRTNLH, + SYSZ_INS_CSCH, + SYSZ_INS_CSDTR, + SYSZ_INS_CSP, + SYSZ_INS_CSPG, + SYSZ_INS_CSST, + SYSZ_INS_CSXTR, + SYSZ_INS_CU12, + SYSZ_INS_CU14, + SYSZ_INS_CU21, + SYSZ_INS_CU24, + SYSZ_INS_CU41, + SYSZ_INS_CU42, + SYSZ_INS_CUDTR, + SYSZ_INS_CUSE, + SYSZ_INS_CUTFU, + SYSZ_INS_CUUTF, + SYSZ_INS_CUXTR, + SYSZ_INS_CVB, + SYSZ_INS_CVBG, + SYSZ_INS_CVBY, + SYSZ_INS_CVD, + SYSZ_INS_CVDG, + SYSZ_INS_CVDY, + SYSZ_INS_CXFBRA, + SYSZ_INS_CXFR, + SYSZ_INS_CXFTR, + SYSZ_INS_CXGBRA, + SYSZ_INS_CXGR, + SYSZ_INS_CXGTR, + SYSZ_INS_CXGTRA, + SYSZ_INS_CXLFTR, + SYSZ_INS_CXLGTR, + SYSZ_INS_CXPT, + SYSZ_INS_CXR, + SYSZ_INS_CXSTR, + SYSZ_INS_CXTR, + SYSZ_INS_CXUTR, + SYSZ_INS_CXZT, + SYSZ_INS_CZDT, + SYSZ_INS_CZXT, + SYSZ_INS_D, + SYSZ_INS_DD, + SYSZ_INS_DDR, + SYSZ_INS_DDTR, + SYSZ_INS_DDTRA, + SYSZ_INS_DE, + SYSZ_INS_DER, + SYSZ_INS_DIAG, + SYSZ_INS_DIDBR, + SYSZ_INS_DIEBR, + SYSZ_INS_DP, + SYSZ_INS_DR, + SYSZ_INS_DXR, + SYSZ_INS_DXTR, + SYSZ_INS_DXTRA, + SYSZ_INS_ECAG, + SYSZ_INS_ECCTR, + SYSZ_INS_ECPGA, + SYSZ_INS_ECTG, + SYSZ_INS_ED, + SYSZ_INS_EDMK, + SYSZ_INS_EEDTR, + SYSZ_INS_EEXTR, + SYSZ_INS_EFPC, + SYSZ_INS_EPAIR, + SYSZ_INS_EPAR, + SYSZ_INS_EPCTR, + SYSZ_INS_EPSW, + SYSZ_INS_EREG, + SYSZ_INS_EREGG, + SYSZ_INS_ESAIR, + SYSZ_INS_ESAR, + SYSZ_INS_ESDTR, + SYSZ_INS_ESEA, + SYSZ_INS_ESTA, + SYSZ_INS_ESXTR, + SYSZ_INS_ETND, + SYSZ_INS_EX, + SYSZ_INS_EXRL, + SYSZ_INS_FIDR, + SYSZ_INS_FIDTR, + SYSZ_INS_FIER, + SYSZ_INS_FIXR, + SYSZ_INS_FIXTR, + SYSZ_INS_HDR, + SYSZ_INS_HER, + SYSZ_INS_HSCH, + SYSZ_INS_IAC, + SYSZ_INS_ICM, + SYSZ_INS_ICMH, + SYSZ_INS_ICMY, + SYSZ_INS_IDTE, + SYSZ_INS_IEDTR, + SYSZ_INS_IEXTR, + SYSZ_INS_IPK, + SYSZ_INS_IPTE, + SYSZ_INS_IRBM, + SYSZ_INS_ISKE, + SYSZ_INS_IVSK, + SYSZ_INS_JGM, + SYSZ_INS_JGNM, + SYSZ_INS_JGNP, + SYSZ_INS_JGNZ, + SYSZ_INS_JGP, + SYSZ_INS_JGZ, + SYSZ_INS_JM, + SYSZ_INS_JNM, + SYSZ_INS_JNP, + SYSZ_INS_JNZ, + SYSZ_INS_JP, + SYSZ_INS_JZ, + SYSZ_INS_KDB, + SYSZ_INS_KDBR, + SYSZ_INS_KDTR, + SYSZ_INS_KEB, + SYSZ_INS_KEBR, + SYSZ_INS_KIMD, + SYSZ_INS_KLMD, + SYSZ_INS_KM, + SYSZ_INS_KMA, + SYSZ_INS_KMAC, + SYSZ_INS_KMC, + SYSZ_INS_KMCTR, + SYSZ_INS_KMF, + SYSZ_INS_KMO, + SYSZ_INS_KXBR, + SYSZ_INS_KXTR, + SYSZ_INS_LAE, + SYSZ_INS_LAEY, + SYSZ_INS_LAM, + SYSZ_INS_LAMY, + SYSZ_INS_LASP, + SYSZ_INS_LAT, + SYSZ_INS_LCBB, + SYSZ_INS_LCCTL, + SYSZ_INS_LCDFR, + SYSZ_INS_LCDR, + SYSZ_INS_LCER, + SYSZ_INS_LCTL, + SYSZ_INS_LCTLG, + SYSZ_INS_LCXR, + SYSZ_INS_LDE, + SYSZ_INS_LDER, + SYSZ_INS_LDETR, + SYSZ_INS_LDXR, + SYSZ_INS_LDXTR, + SYSZ_INS_LEDR, + SYSZ_INS_LEDTR, + SYSZ_INS_LEXR, + SYSZ_INS_LFAS, + SYSZ_INS_LFHAT, + SYSZ_INS_LFPC, + SYSZ_INS_LGAT, + SYSZ_INS_LGG, + SYSZ_INS_LGSC, + SYSZ_INS_LLGFAT, + SYSZ_INS_LLGFSG, + SYSZ_INS_LLGT, + SYSZ_INS_LLGTAT, + SYSZ_INS_LLGTR, + SYSZ_INS_LLZRGF, + SYSZ_INS_LM, + SYSZ_INS_LMD, + SYSZ_INS_LMH, + SYSZ_INS_LMY, + SYSZ_INS_LNDFR, + SYSZ_INS_LNDR, + SYSZ_INS_LNER, + SYSZ_INS_LNXR, + SYSZ_INS_LOCFH, + SYSZ_INS_LOCFHE, + SYSZ_INS_LOCFHH, + SYSZ_INS_LOCFHHE, + SYSZ_INS_LOCFHL, + SYSZ_INS_LOCFHLE, + SYSZ_INS_LOCFHLH, + SYSZ_INS_LOCFHM, + SYSZ_INS_LOCFHNE, + SYSZ_INS_LOCFHNH, + SYSZ_INS_LOCFHNHE, + SYSZ_INS_LOCFHNL, + SYSZ_INS_LOCFHNLE, + SYSZ_INS_LOCFHNLH, + SYSZ_INS_LOCFHNM, + SYSZ_INS_LOCFHNO, + SYSZ_INS_LOCFHNP, + SYSZ_INS_LOCFHNZ, + SYSZ_INS_LOCFHO, + SYSZ_INS_LOCFHP, + SYSZ_INS_LOCFHR, + SYSZ_INS_LOCFHRE, + SYSZ_INS_LOCFHRH, + SYSZ_INS_LOCFHRHE, + SYSZ_INS_LOCFHRL, + SYSZ_INS_LOCFHRLE, + SYSZ_INS_LOCFHRLH, + SYSZ_INS_LOCFHRM, + SYSZ_INS_LOCFHRNE, + SYSZ_INS_LOCFHRNH, + SYSZ_INS_LOCFHRNHE, + SYSZ_INS_LOCFHRNL, + SYSZ_INS_LOCFHRNLE, + SYSZ_INS_LOCFHRNLH, + SYSZ_INS_LOCFHRNM, + SYSZ_INS_LOCFHRNO, + SYSZ_INS_LOCFHRNP, + SYSZ_INS_LOCFHRNZ, + SYSZ_INS_LOCFHRO, + SYSZ_INS_LOCFHRP, + SYSZ_INS_LOCFHRZ, + SYSZ_INS_LOCFHZ, + SYSZ_INS_LOCGHI, + SYSZ_INS_LOCGHIE, + SYSZ_INS_LOCGHIH, + SYSZ_INS_LOCGHIHE, + SYSZ_INS_LOCGHIL, + SYSZ_INS_LOCGHILE, + SYSZ_INS_LOCGHILH, + SYSZ_INS_LOCGHIM, + SYSZ_INS_LOCGHINE, + SYSZ_INS_LOCGHINH, + SYSZ_INS_LOCGHINHE, + SYSZ_INS_LOCGHINL, + SYSZ_INS_LOCGHINLE, + SYSZ_INS_LOCGHINLH, + SYSZ_INS_LOCGHINM, + SYSZ_INS_LOCGHINO, + SYSZ_INS_LOCGHINP, + SYSZ_INS_LOCGHINZ, + SYSZ_INS_LOCGHIO, + SYSZ_INS_LOCGHIP, + SYSZ_INS_LOCGHIZ, + SYSZ_INS_LOCGM, + SYSZ_INS_LOCGNM, + SYSZ_INS_LOCGNP, + SYSZ_INS_LOCGNZ, + SYSZ_INS_LOCGP, + SYSZ_INS_LOCGRM, + SYSZ_INS_LOCGRNM, + SYSZ_INS_LOCGRNP, + SYSZ_INS_LOCGRNZ, + SYSZ_INS_LOCGRP, + SYSZ_INS_LOCGRZ, + SYSZ_INS_LOCGZ, + SYSZ_INS_LOCHHI, + SYSZ_INS_LOCHHIE, + SYSZ_INS_LOCHHIH, + SYSZ_INS_LOCHHIHE, + SYSZ_INS_LOCHHIL, + SYSZ_INS_LOCHHILE, + SYSZ_INS_LOCHHILH, + SYSZ_INS_LOCHHIM, + SYSZ_INS_LOCHHINE, + SYSZ_INS_LOCHHINH, + SYSZ_INS_LOCHHINHE, + SYSZ_INS_LOCHHINL, + SYSZ_INS_LOCHHINLE, + SYSZ_INS_LOCHHINLH, + SYSZ_INS_LOCHHINM, + SYSZ_INS_LOCHHINO, + SYSZ_INS_LOCHHINP, + SYSZ_INS_LOCHHINZ, + SYSZ_INS_LOCHHIO, + SYSZ_INS_LOCHHIP, + SYSZ_INS_LOCHHIZ, + SYSZ_INS_LOCHI, + SYSZ_INS_LOCHIE, + SYSZ_INS_LOCHIH, + SYSZ_INS_LOCHIHE, + SYSZ_INS_LOCHIL, + SYSZ_INS_LOCHILE, + SYSZ_INS_LOCHILH, + SYSZ_INS_LOCHIM, + SYSZ_INS_LOCHINE, + SYSZ_INS_LOCHINH, + SYSZ_INS_LOCHINHE, + SYSZ_INS_LOCHINL, + SYSZ_INS_LOCHINLE, + SYSZ_INS_LOCHINLH, + SYSZ_INS_LOCHINM, + SYSZ_INS_LOCHINO, + SYSZ_INS_LOCHINP, + SYSZ_INS_LOCHINZ, + SYSZ_INS_LOCHIO, + SYSZ_INS_LOCHIP, + SYSZ_INS_LOCHIZ, + SYSZ_INS_LOCM, + SYSZ_INS_LOCNM, + SYSZ_INS_LOCNP, + SYSZ_INS_LOCNZ, + SYSZ_INS_LOCP, + SYSZ_INS_LOCRM, + SYSZ_INS_LOCRNM, + SYSZ_INS_LOCRNP, + SYSZ_INS_LOCRNZ, + SYSZ_INS_LOCRP, + SYSZ_INS_LOCRZ, + SYSZ_INS_LOCZ, + SYSZ_INS_LPCTL, + SYSZ_INS_LPD, + SYSZ_INS_LPDFR, + SYSZ_INS_LPDG, + SYSZ_INS_LPDR, + SYSZ_INS_LPER, + SYSZ_INS_LPP, + SYSZ_INS_LPQ, + SYSZ_INS_LPSW, + SYSZ_INS_LPSWE, + SYSZ_INS_LPTEA, + SYSZ_INS_LPXR, + SYSZ_INS_LRA, + SYSZ_INS_LRAG, + SYSZ_INS_LRAY, + SYSZ_INS_LRDR, + SYSZ_INS_LRER, + SYSZ_INS_LRVH, + SYSZ_INS_LSCTL, + SYSZ_INS_LTDR, + SYSZ_INS_LTDTR, + SYSZ_INS_LTER, + SYSZ_INS_LTXR, + SYSZ_INS_LTXTR, + SYSZ_INS_LURA, + SYSZ_INS_LURAG, + SYSZ_INS_LXD, + SYSZ_INS_LXDR, + SYSZ_INS_LXDTR, + SYSZ_INS_LXE, + SYSZ_INS_LXER, + SYSZ_INS_LZRF, + SYSZ_INS_LZRG, + SYSZ_INS_M, + SYSZ_INS_MAD, + SYSZ_INS_MADR, + SYSZ_INS_MAE, + SYSZ_INS_MAER, + SYSZ_INS_MAY, + SYSZ_INS_MAYH, + SYSZ_INS_MAYHR, + SYSZ_INS_MAYL, + SYSZ_INS_MAYLR, + SYSZ_INS_MAYR, + SYSZ_INS_MC, + SYSZ_INS_MD, + SYSZ_INS_MDE, + SYSZ_INS_MDER, + SYSZ_INS_MDR, + SYSZ_INS_MDTR, + SYSZ_INS_MDTRA, + SYSZ_INS_ME, + SYSZ_INS_MEE, + SYSZ_INS_MEER, + SYSZ_INS_MER, + SYSZ_INS_MFY, + SYSZ_INS_MG, + SYSZ_INS_MGH, + SYSZ_INS_MGRK, + SYSZ_INS_ML, + SYSZ_INS_MLR, + SYSZ_INS_MP, + SYSZ_INS_MR, + SYSZ_INS_MSC, + SYSZ_INS_MSCH, + SYSZ_INS_MSD, + SYSZ_INS_MSDR, + SYSZ_INS_MSE, + SYSZ_INS_MSER, + SYSZ_INS_MSGC, + SYSZ_INS_MSGRKC, + SYSZ_INS_MSRKC, + SYSZ_INS_MSTA, + SYSZ_INS_MVCDK, + SYSZ_INS_MVCIN, + SYSZ_INS_MVCK, + SYSZ_INS_MVCL, + SYSZ_INS_MVCLE, + SYSZ_INS_MVCLU, + SYSZ_INS_MVCOS, + SYSZ_INS_MVCP, + SYSZ_INS_MVCS, + SYSZ_INS_MVCSK, + SYSZ_INS_MVN, + SYSZ_INS_MVO, + SYSZ_INS_MVPG, + SYSZ_INS_MVZ, + SYSZ_INS_MXD, + SYSZ_INS_MXDR, + SYSZ_INS_MXR, + SYSZ_INS_MXTR, + SYSZ_INS_MXTRA, + SYSZ_INS_MY, + SYSZ_INS_MYH, + SYSZ_INS_MYHR, + SYSZ_INS_MYL, + SYSZ_INS_MYLR, + SYSZ_INS_MYR, + SYSZ_INS_NIAI, + SYSZ_INS_NTSTG, + SYSZ_INS_PACK, + SYSZ_INS_PALB, + SYSZ_INS_PC, + SYSZ_INS_PCC, + SYSZ_INS_PCKMO, + SYSZ_INS_PFMF, + SYSZ_INS_PFPO, + SYSZ_INS_PGIN, + SYSZ_INS_PGOUT, + SYSZ_INS_PKA, + SYSZ_INS_PKU, + SYSZ_INS_PLO, + SYSZ_INS_POPCNT, + SYSZ_INS_PPA, + SYSZ_INS_PPNO, + SYSZ_INS_PR, + SYSZ_INS_PRNO, + SYSZ_INS_PT, + SYSZ_INS_PTF, + SYSZ_INS_PTFF, + SYSZ_INS_PTI, + SYSZ_INS_PTLB, + SYSZ_INS_QADTR, + SYSZ_INS_QAXTR, + SYSZ_INS_QCTRI, + SYSZ_INS_QSI, + SYSZ_INS_RCHP, + SYSZ_INS_RISBGN, + SYSZ_INS_RP, + SYSZ_INS_RRBE, + SYSZ_INS_RRBM, + SYSZ_INS_RRDTR, + SYSZ_INS_RRXTR, + SYSZ_INS_RSCH, + SYSZ_INS_SAC, + SYSZ_INS_SACF, + SYSZ_INS_SAL, + SYSZ_INS_SAM24, + SYSZ_INS_SAM31, + SYSZ_INS_SAM64, + SYSZ_INS_SAR, + SYSZ_INS_SCCTR, + SYSZ_INS_SCHM, + SYSZ_INS_SCK, + SYSZ_INS_SCKC, + SYSZ_INS_SCKPF, + SYSZ_INS_SD, + SYSZ_INS_SDR, + SYSZ_INS_SDTR, + SYSZ_INS_SDTRA, + SYSZ_INS_SE, + SYSZ_INS_SER, + SYSZ_INS_SFASR, + SYSZ_INS_SFPC, + SYSZ_INS_SGH, + SYSZ_INS_SHHHR, + SYSZ_INS_SHHLR, + SYSZ_INS_SIE, + SYSZ_INS_SIGA, + SYSZ_INS_SIGP, + SYSZ_INS_SLA, + SYSZ_INS_SLAG, + SYSZ_INS_SLAK, + SYSZ_INS_SLDA, + SYSZ_INS_SLDL, + SYSZ_INS_SLDT, + SYSZ_INS_SLHHHR, + SYSZ_INS_SLHHLR, + SYSZ_INS_SLXT, + SYSZ_INS_SP, + SYSZ_INS_SPCTR, + SYSZ_INS_SPKA, + SYSZ_INS_SPM, + SYSZ_INS_SPT, + SYSZ_INS_SPX, + SYSZ_INS_SQD, + SYSZ_INS_SQDR, + SYSZ_INS_SQE, + SYSZ_INS_SQER, + SYSZ_INS_SQXR, + SYSZ_INS_SRDA, + SYSZ_INS_SRDL, + SYSZ_INS_SRDT, + SYSZ_INS_SRNM, + SYSZ_INS_SRNMB, + SYSZ_INS_SRNMT, + SYSZ_INS_SRP, + SYSZ_INS_SRSTU, + SYSZ_INS_SRXT, + SYSZ_INS_SSAIR, + SYSZ_INS_SSAR, + SYSZ_INS_SSCH, + SYSZ_INS_SSKE, + SYSZ_INS_SSM, + SYSZ_INS_STAM, + SYSZ_INS_STAMY, + SYSZ_INS_STAP, + SYSZ_INS_STCK, + SYSZ_INS_STCKC, + SYSZ_INS_STCKE, + SYSZ_INS_STCKF, + SYSZ_INS_STCM, + SYSZ_INS_STCMH, + SYSZ_INS_STCMY, + SYSZ_INS_STCPS, + SYSZ_INS_STCRW, + SYSZ_INS_STCTG, + SYSZ_INS_STCTL, + SYSZ_INS_STFL, + SYSZ_INS_STFLE, + SYSZ_INS_STFPC, + SYSZ_INS_STGSC, + SYSZ_INS_STIDP, + SYSZ_INS_STM, + SYSZ_INS_STMH, + SYSZ_INS_STMY, + SYSZ_INS_STNSM, + SYSZ_INS_STOCFH, + SYSZ_INS_STOCFHE, + SYSZ_INS_STOCFHH, + SYSZ_INS_STOCFHHE, + SYSZ_INS_STOCFHL, + SYSZ_INS_STOCFHLE, + SYSZ_INS_STOCFHLH, + SYSZ_INS_STOCFHM, + SYSZ_INS_STOCFHNE, + SYSZ_INS_STOCFHNH, + SYSZ_INS_STOCFHNHE, + SYSZ_INS_STOCFHNL, + SYSZ_INS_STOCFHNLE, + SYSZ_INS_STOCFHNLH, + SYSZ_INS_STOCFHNM, + SYSZ_INS_STOCFHNO, + SYSZ_INS_STOCFHNP, + SYSZ_INS_STOCFHNZ, + SYSZ_INS_STOCFHO, + SYSZ_INS_STOCFHP, + SYSZ_INS_STOCFHZ, + SYSZ_INS_STOCGM, + SYSZ_INS_STOCGNM, + SYSZ_INS_STOCGNP, + SYSZ_INS_STOCGNZ, + SYSZ_INS_STOCGP, + SYSZ_INS_STOCGZ, + SYSZ_INS_STOCM, + SYSZ_INS_STOCNM, + SYSZ_INS_STOCNP, + SYSZ_INS_STOCNZ, + SYSZ_INS_STOCP, + SYSZ_INS_STOCZ, + SYSZ_INS_STOSM, + SYSZ_INS_STPQ, + SYSZ_INS_STPT, + SYSZ_INS_STPX, + SYSZ_INS_STRAG, + SYSZ_INS_STRVH, + SYSZ_INS_STSCH, + SYSZ_INS_STSI, + SYSZ_INS_STURA, + SYSZ_INS_STURG, + SYSZ_INS_SU, + SYSZ_INS_SUR, + SYSZ_INS_SVC, + SYSZ_INS_SW, + SYSZ_INS_SWR, + SYSZ_INS_SXR, + SYSZ_INS_SXTR, + SYSZ_INS_SXTRA, + SYSZ_INS_TABORT, + SYSZ_INS_TAM, + SYSZ_INS_TAR, + SYSZ_INS_TB, + SYSZ_INS_TBDR, + SYSZ_INS_TBEDR, + SYSZ_INS_TBEGIN, + SYSZ_INS_TBEGINC, + SYSZ_INS_TCDB, + SYSZ_INS_TCEB, + SYSZ_INS_TCXB, + SYSZ_INS_TDCDT, + SYSZ_INS_TDCET, + SYSZ_INS_TDCXT, + SYSZ_INS_TDGDT, + SYSZ_INS_TDGET, + SYSZ_INS_TDGXT, + SYSZ_INS_TEND, + SYSZ_INS_THDER, + SYSZ_INS_THDR, + SYSZ_INS_TP, + SYSZ_INS_TPI, + SYSZ_INS_TPROT, + SYSZ_INS_TR, + SYSZ_INS_TRACE, + SYSZ_INS_TRACG, + SYSZ_INS_TRAP2, + SYSZ_INS_TRAP4, + SYSZ_INS_TRE, + SYSZ_INS_TROO, + SYSZ_INS_TROT, + SYSZ_INS_TRT, + SYSZ_INS_TRTE, + SYSZ_INS_TRTO, + SYSZ_INS_TRTR, + SYSZ_INS_TRTRE, + SYSZ_INS_TRTT, + SYSZ_INS_TS, + SYSZ_INS_TSCH, + SYSZ_INS_UNPK, + SYSZ_INS_UNPKA, + SYSZ_INS_UNPKU, + SYSZ_INS_UPT, + SYSZ_INS_VA, + SYSZ_INS_VAB, + SYSZ_INS_VAC, + SYSZ_INS_VACC, + SYSZ_INS_VACCB, + SYSZ_INS_VACCC, + SYSZ_INS_VACCCQ, + SYSZ_INS_VACCF, + SYSZ_INS_VACCG, + SYSZ_INS_VACCH, + SYSZ_INS_VACCQ, + SYSZ_INS_VACQ, + SYSZ_INS_VAF, + SYSZ_INS_VAG, + SYSZ_INS_VAH, + SYSZ_INS_VAP, + SYSZ_INS_VAQ, + SYSZ_INS_VAVG, + SYSZ_INS_VAVGB, + SYSZ_INS_VAVGF, + SYSZ_INS_VAVGG, + SYSZ_INS_VAVGH, + SYSZ_INS_VAVGL, + SYSZ_INS_VAVGLB, + SYSZ_INS_VAVGLF, + SYSZ_INS_VAVGLG, + SYSZ_INS_VAVGLH, + SYSZ_INS_VBPERM, + SYSZ_INS_VCDG, + SYSZ_INS_VCDGB, + SYSZ_INS_VCDLG, + SYSZ_INS_VCDLGB, + SYSZ_INS_VCEQ, + SYSZ_INS_VCEQB, + SYSZ_INS_VCEQBS, + SYSZ_INS_VCEQF, + SYSZ_INS_VCEQFS, + SYSZ_INS_VCEQG, + SYSZ_INS_VCEQGS, + SYSZ_INS_VCEQH, + SYSZ_INS_VCEQHS, + SYSZ_INS_VCGD, + SYSZ_INS_VCGDB, + SYSZ_INS_VCH, + SYSZ_INS_VCHB, + SYSZ_INS_VCHBS, + SYSZ_INS_VCHF, + SYSZ_INS_VCHFS, + SYSZ_INS_VCHG, + SYSZ_INS_VCHGS, + SYSZ_INS_VCHH, + SYSZ_INS_VCHHS, + SYSZ_INS_VCHL, + SYSZ_INS_VCHLB, + SYSZ_INS_VCHLBS, + SYSZ_INS_VCHLF, + SYSZ_INS_VCHLFS, + SYSZ_INS_VCHLG, + SYSZ_INS_VCHLGS, + SYSZ_INS_VCHLH, + SYSZ_INS_VCHLHS, + SYSZ_INS_VCKSM, + SYSZ_INS_VCLGD, + SYSZ_INS_VCLGDB, + SYSZ_INS_VCLZ, + SYSZ_INS_VCLZB, + SYSZ_INS_VCLZF, + SYSZ_INS_VCLZG, + SYSZ_INS_VCLZH, + SYSZ_INS_VCP, + SYSZ_INS_VCTZ, + SYSZ_INS_VCTZB, + SYSZ_INS_VCTZF, + SYSZ_INS_VCTZG, + SYSZ_INS_VCTZH, + SYSZ_INS_VCVB, + SYSZ_INS_VCVBG, + SYSZ_INS_VCVD, + SYSZ_INS_VCVDG, + SYSZ_INS_VDP, + SYSZ_INS_VEC, + SYSZ_INS_VECB, + SYSZ_INS_VECF, + SYSZ_INS_VECG, + SYSZ_INS_VECH, + SYSZ_INS_VECL, + SYSZ_INS_VECLB, + SYSZ_INS_VECLF, + SYSZ_INS_VECLG, + SYSZ_INS_VECLH, + SYSZ_INS_VERIM, + SYSZ_INS_VERIMB, + SYSZ_INS_VERIMF, + SYSZ_INS_VERIMG, + SYSZ_INS_VERIMH, + SYSZ_INS_VERLL, + SYSZ_INS_VERLLB, + SYSZ_INS_VERLLF, + SYSZ_INS_VERLLG, + SYSZ_INS_VERLLH, + SYSZ_INS_VERLLV, + SYSZ_INS_VERLLVB, + SYSZ_INS_VERLLVF, + SYSZ_INS_VERLLVG, + SYSZ_INS_VERLLVH, + SYSZ_INS_VESL, + SYSZ_INS_VESLB, + SYSZ_INS_VESLF, + SYSZ_INS_VESLG, + SYSZ_INS_VESLH, + SYSZ_INS_VESLV, + SYSZ_INS_VESLVB, + SYSZ_INS_VESLVF, + SYSZ_INS_VESLVG, + SYSZ_INS_VESLVH, + SYSZ_INS_VESRA, + SYSZ_INS_VESRAB, + SYSZ_INS_VESRAF, + SYSZ_INS_VESRAG, + SYSZ_INS_VESRAH, + SYSZ_INS_VESRAV, + SYSZ_INS_VESRAVB, + SYSZ_INS_VESRAVF, + SYSZ_INS_VESRAVG, + SYSZ_INS_VESRAVH, + SYSZ_INS_VESRL, + SYSZ_INS_VESRLB, + SYSZ_INS_VESRLF, + SYSZ_INS_VESRLG, + SYSZ_INS_VESRLH, + SYSZ_INS_VESRLV, + SYSZ_INS_VESRLVB, + SYSZ_INS_VESRLVF, + SYSZ_INS_VESRLVG, + SYSZ_INS_VESRLVH, + SYSZ_INS_VFA, + SYSZ_INS_VFADB, + SYSZ_INS_VFAE, + SYSZ_INS_VFAEB, + SYSZ_INS_VFAEBS, + SYSZ_INS_VFAEF, + SYSZ_INS_VFAEFS, + SYSZ_INS_VFAEH, + SYSZ_INS_VFAEHS, + SYSZ_INS_VFAEZB, + SYSZ_INS_VFAEZBS, + SYSZ_INS_VFAEZF, + SYSZ_INS_VFAEZFS, + SYSZ_INS_VFAEZH, + SYSZ_INS_VFAEZHS, + SYSZ_INS_VFASB, + SYSZ_INS_VFCE, + SYSZ_INS_VFCEDB, + SYSZ_INS_VFCEDBS, + SYSZ_INS_VFCESB, + SYSZ_INS_VFCESBS, + SYSZ_INS_VFCH, + SYSZ_INS_VFCHDB, + SYSZ_INS_VFCHDBS, + SYSZ_INS_VFCHE, + SYSZ_INS_VFCHEDB, + SYSZ_INS_VFCHEDBS, + SYSZ_INS_VFCHESB, + SYSZ_INS_VFCHESBS, + SYSZ_INS_VFCHSB, + SYSZ_INS_VFCHSBS, + SYSZ_INS_VFD, + SYSZ_INS_VFDDB, + SYSZ_INS_VFDSB, + SYSZ_INS_VFEE, + SYSZ_INS_VFEEB, + SYSZ_INS_VFEEBS, + SYSZ_INS_VFEEF, + SYSZ_INS_VFEEFS, + SYSZ_INS_VFEEH, + SYSZ_INS_VFEEHS, + SYSZ_INS_VFEEZB, + SYSZ_INS_VFEEZBS, + SYSZ_INS_VFEEZF, + SYSZ_INS_VFEEZFS, + SYSZ_INS_VFEEZH, + SYSZ_INS_VFEEZHS, + SYSZ_INS_VFENE, + SYSZ_INS_VFENEB, + SYSZ_INS_VFENEBS, + SYSZ_INS_VFENEF, + SYSZ_INS_VFENEFS, + SYSZ_INS_VFENEH, + SYSZ_INS_VFENEHS, + SYSZ_INS_VFENEZB, + SYSZ_INS_VFENEZBS, + SYSZ_INS_VFENEZF, + SYSZ_INS_VFENEZFS, + SYSZ_INS_VFENEZH, + SYSZ_INS_VFENEZHS, + SYSZ_INS_VFI, + SYSZ_INS_VFIDB, + SYSZ_INS_VFISB, + SYSZ_INS_VFKEDB, + SYSZ_INS_VFKEDBS, + SYSZ_INS_VFKESB, + SYSZ_INS_VFKESBS, + SYSZ_INS_VFKHDB, + SYSZ_INS_VFKHDBS, + SYSZ_INS_VFKHEDB, + SYSZ_INS_VFKHEDBS, + SYSZ_INS_VFKHESB, + SYSZ_INS_VFKHESBS, + SYSZ_INS_VFKHSB, + SYSZ_INS_VFKHSBS, + SYSZ_INS_VFLCDB, + SYSZ_INS_VFLCSB, + SYSZ_INS_VFLL, + SYSZ_INS_VFLLS, + SYSZ_INS_VFLNDB, + SYSZ_INS_VFLNSB, + SYSZ_INS_VFLPDB, + SYSZ_INS_VFLPSB, + SYSZ_INS_VFLR, + SYSZ_INS_VFLRD, + SYSZ_INS_VFM, + SYSZ_INS_VFMA, + SYSZ_INS_VFMADB, + SYSZ_INS_VFMASB, + SYSZ_INS_VFMAX, + SYSZ_INS_VFMAXDB, + SYSZ_INS_VFMAXSB, + SYSZ_INS_VFMDB, + SYSZ_INS_VFMIN, + SYSZ_INS_VFMINDB, + SYSZ_INS_VFMINSB, + SYSZ_INS_VFMS, + SYSZ_INS_VFMSB, + SYSZ_INS_VFMSDB, + SYSZ_INS_VFMSSB, + SYSZ_INS_VFNMA, + SYSZ_INS_VFNMADB, + SYSZ_INS_VFNMASB, + SYSZ_INS_VFNMS, + SYSZ_INS_VFNMSDB, + SYSZ_INS_VFNMSSB, + SYSZ_INS_VFPSO, + SYSZ_INS_VFPSODB, + SYSZ_INS_VFPSOSB, + SYSZ_INS_VFS, + SYSZ_INS_VFSDB, + SYSZ_INS_VFSQ, + SYSZ_INS_VFSQDB, + SYSZ_INS_VFSQSB, + SYSZ_INS_VFSSB, + SYSZ_INS_VFTCI, + SYSZ_INS_VFTCIDB, + SYSZ_INS_VFTCISB, + SYSZ_INS_VGBM, + SYSZ_INS_VGEF, + SYSZ_INS_VGEG, + SYSZ_INS_VGFM, + SYSZ_INS_VGFMA, + SYSZ_INS_VGFMAB, + SYSZ_INS_VGFMAF, + SYSZ_INS_VGFMAG, + SYSZ_INS_VGFMAH, + SYSZ_INS_VGFMB, + SYSZ_INS_VGFMF, + SYSZ_INS_VGFMG, + SYSZ_INS_VGFMH, + SYSZ_INS_VGM, + SYSZ_INS_VGMB, + SYSZ_INS_VGMF, + SYSZ_INS_VGMG, + SYSZ_INS_VGMH, + SYSZ_INS_VISTR, + SYSZ_INS_VISTRB, + SYSZ_INS_VISTRBS, + SYSZ_INS_VISTRF, + SYSZ_INS_VISTRFS, + SYSZ_INS_VISTRH, + SYSZ_INS_VISTRHS, + SYSZ_INS_VL, + SYSZ_INS_VLBB, + SYSZ_INS_VLC, + SYSZ_INS_VLCB, + SYSZ_INS_VLCF, + SYSZ_INS_VLCG, + SYSZ_INS_VLCH, + SYSZ_INS_VLDE, + SYSZ_INS_VLDEB, + SYSZ_INS_VLEB, + SYSZ_INS_VLED, + SYSZ_INS_VLEDB, + SYSZ_INS_VLEF, + SYSZ_INS_VLEG, + SYSZ_INS_VLEH, + SYSZ_INS_VLEIB, + SYSZ_INS_VLEIF, + SYSZ_INS_VLEIG, + SYSZ_INS_VLEIH, + SYSZ_INS_VLGV, + SYSZ_INS_VLGVB, + SYSZ_INS_VLGVF, + SYSZ_INS_VLGVG, + SYSZ_INS_VLGVH, + SYSZ_INS_VLIP, + SYSZ_INS_VLL, + SYSZ_INS_VLLEZ, + SYSZ_INS_VLLEZB, + SYSZ_INS_VLLEZF, + SYSZ_INS_VLLEZG, + SYSZ_INS_VLLEZH, + SYSZ_INS_VLLEZLF, + SYSZ_INS_VLM, + SYSZ_INS_VLP, + SYSZ_INS_VLPB, + SYSZ_INS_VLPF, + SYSZ_INS_VLPG, + SYSZ_INS_VLPH, + SYSZ_INS_VLR, + SYSZ_INS_VLREP, + SYSZ_INS_VLREPB, + SYSZ_INS_VLREPF, + SYSZ_INS_VLREPG, + SYSZ_INS_VLREPH, + SYSZ_INS_VLRL, + SYSZ_INS_VLRLR, + SYSZ_INS_VLVG, + SYSZ_INS_VLVGB, + SYSZ_INS_VLVGF, + SYSZ_INS_VLVGG, + SYSZ_INS_VLVGH, + SYSZ_INS_VLVGP, + SYSZ_INS_VMAE, + SYSZ_INS_VMAEB, + SYSZ_INS_VMAEF, + SYSZ_INS_VMAEH, + SYSZ_INS_VMAH, + SYSZ_INS_VMAHB, + SYSZ_INS_VMAHF, + SYSZ_INS_VMAHH, + SYSZ_INS_VMAL, + SYSZ_INS_VMALB, + SYSZ_INS_VMALE, + SYSZ_INS_VMALEB, + SYSZ_INS_VMALEF, + SYSZ_INS_VMALEH, + SYSZ_INS_VMALF, + SYSZ_INS_VMALH, + SYSZ_INS_VMALHB, + SYSZ_INS_VMALHF, + SYSZ_INS_VMALHH, + SYSZ_INS_VMALHW, + SYSZ_INS_VMALO, + SYSZ_INS_VMALOB, + SYSZ_INS_VMALOF, + SYSZ_INS_VMALOH, + SYSZ_INS_VMAO, + SYSZ_INS_VMAOB, + SYSZ_INS_VMAOF, + SYSZ_INS_VMAOH, + SYSZ_INS_VME, + SYSZ_INS_VMEB, + SYSZ_INS_VMEF, + SYSZ_INS_VMEH, + SYSZ_INS_VMH, + SYSZ_INS_VMHB, + SYSZ_INS_VMHF, + SYSZ_INS_VMHH, + SYSZ_INS_VML, + SYSZ_INS_VMLB, + SYSZ_INS_VMLE, + SYSZ_INS_VMLEB, + SYSZ_INS_VMLEF, + SYSZ_INS_VMLEH, + SYSZ_INS_VMLF, + SYSZ_INS_VMLH, + SYSZ_INS_VMLHB, + SYSZ_INS_VMLHF, + SYSZ_INS_VMLHH, + SYSZ_INS_VMLHW, + SYSZ_INS_VMLO, + SYSZ_INS_VMLOB, + SYSZ_INS_VMLOF, + SYSZ_INS_VMLOH, + SYSZ_INS_VMN, + SYSZ_INS_VMNB, + SYSZ_INS_VMNF, + SYSZ_INS_VMNG, + SYSZ_INS_VMNH, + SYSZ_INS_VMNL, + SYSZ_INS_VMNLB, + SYSZ_INS_VMNLF, + SYSZ_INS_VMNLG, + SYSZ_INS_VMNLH, + SYSZ_INS_VMO, + SYSZ_INS_VMOB, + SYSZ_INS_VMOF, + SYSZ_INS_VMOH, + SYSZ_INS_VMP, + SYSZ_INS_VMRH, + SYSZ_INS_VMRHB, + SYSZ_INS_VMRHF, + SYSZ_INS_VMRHG, + SYSZ_INS_VMRHH, + SYSZ_INS_VMRL, + SYSZ_INS_VMRLB, + SYSZ_INS_VMRLF, + SYSZ_INS_VMRLG, + SYSZ_INS_VMRLH, + SYSZ_INS_VMSL, + SYSZ_INS_VMSLG, + SYSZ_INS_VMSP, + SYSZ_INS_VMX, + SYSZ_INS_VMXB, + SYSZ_INS_VMXF, + SYSZ_INS_VMXG, + SYSZ_INS_VMXH, + SYSZ_INS_VMXL, + SYSZ_INS_VMXLB, + SYSZ_INS_VMXLF, + SYSZ_INS_VMXLG, + SYSZ_INS_VMXLH, + SYSZ_INS_VN, + SYSZ_INS_VNC, + SYSZ_INS_VNN, + SYSZ_INS_VNO, + SYSZ_INS_VNX, + SYSZ_INS_VO, + SYSZ_INS_VOC, + SYSZ_INS_VONE, + SYSZ_INS_VPDI, + SYSZ_INS_VPERM, + SYSZ_INS_VPK, + SYSZ_INS_VPKF, + SYSZ_INS_VPKG, + SYSZ_INS_VPKH, + SYSZ_INS_VPKLS, + SYSZ_INS_VPKLSF, + SYSZ_INS_VPKLSFS, + SYSZ_INS_VPKLSG, + SYSZ_INS_VPKLSGS, + SYSZ_INS_VPKLSH, + SYSZ_INS_VPKLSHS, + SYSZ_INS_VPKS, + SYSZ_INS_VPKSF, + SYSZ_INS_VPKSFS, + SYSZ_INS_VPKSG, + SYSZ_INS_VPKSGS, + SYSZ_INS_VPKSH, + SYSZ_INS_VPKSHS, + SYSZ_INS_VPKZ, + SYSZ_INS_VPOPCT, + SYSZ_INS_VPOPCTB, + SYSZ_INS_VPOPCTF, + SYSZ_INS_VPOPCTG, + SYSZ_INS_VPOPCTH, + SYSZ_INS_VPSOP, + SYSZ_INS_VREP, + SYSZ_INS_VREPB, + SYSZ_INS_VREPF, + SYSZ_INS_VREPG, + SYSZ_INS_VREPH, + SYSZ_INS_VREPI, + SYSZ_INS_VREPIB, + SYSZ_INS_VREPIF, + SYSZ_INS_VREPIG, + SYSZ_INS_VREPIH, + SYSZ_INS_VRP, + SYSZ_INS_VS, + SYSZ_INS_VSB, + SYSZ_INS_VSBCBI, + SYSZ_INS_VSBCBIQ, + SYSZ_INS_VSBI, + SYSZ_INS_VSBIQ, + SYSZ_INS_VSCBI, + SYSZ_INS_VSCBIB, + SYSZ_INS_VSCBIF, + SYSZ_INS_VSCBIG, + SYSZ_INS_VSCBIH, + SYSZ_INS_VSCBIQ, + SYSZ_INS_VSCEF, + SYSZ_INS_VSCEG, + SYSZ_INS_VSDP, + SYSZ_INS_VSEG, + SYSZ_INS_VSEGB, + SYSZ_INS_VSEGF, + SYSZ_INS_VSEGH, + SYSZ_INS_VSEL, + SYSZ_INS_VSF, + SYSZ_INS_VSG, + SYSZ_INS_VSH, + SYSZ_INS_VSL, + SYSZ_INS_VSLB, + SYSZ_INS_VSLDB, + SYSZ_INS_VSP, + SYSZ_INS_VSQ, + SYSZ_INS_VSRA, + SYSZ_INS_VSRAB, + SYSZ_INS_VSRL, + SYSZ_INS_VSRLB, + SYSZ_INS_VSRP, + SYSZ_INS_VST, + SYSZ_INS_VSTEB, + SYSZ_INS_VSTEF, + SYSZ_INS_VSTEG, + SYSZ_INS_VSTEH, + SYSZ_INS_VSTL, + SYSZ_INS_VSTM, + SYSZ_INS_VSTRC, + SYSZ_INS_VSTRCB, + SYSZ_INS_VSTRCBS, + SYSZ_INS_VSTRCF, + SYSZ_INS_VSTRCFS, + SYSZ_INS_VSTRCH, + SYSZ_INS_VSTRCHS, + SYSZ_INS_VSTRCZB, + SYSZ_INS_VSTRCZBS, + SYSZ_INS_VSTRCZF, + SYSZ_INS_VSTRCZFS, + SYSZ_INS_VSTRCZH, + SYSZ_INS_VSTRCZHS, + SYSZ_INS_VSTRL, + SYSZ_INS_VSTRLR, + SYSZ_INS_VSUM, + SYSZ_INS_VSUMB, + SYSZ_INS_VSUMG, + SYSZ_INS_VSUMGF, + SYSZ_INS_VSUMGH, + SYSZ_INS_VSUMH, + SYSZ_INS_VSUMQ, + SYSZ_INS_VSUMQF, + SYSZ_INS_VSUMQG, + SYSZ_INS_VTM, + SYSZ_INS_VTP, + SYSZ_INS_VUPH, + SYSZ_INS_VUPHB, + SYSZ_INS_VUPHF, + SYSZ_INS_VUPHH, + SYSZ_INS_VUPKZ, + SYSZ_INS_VUPL, + SYSZ_INS_VUPLB, + SYSZ_INS_VUPLF, + SYSZ_INS_VUPLH, + SYSZ_INS_VUPLHB, + SYSZ_INS_VUPLHF, + SYSZ_INS_VUPLHH, + SYSZ_INS_VUPLHW, + SYSZ_INS_VUPLL, + SYSZ_INS_VUPLLB, + SYSZ_INS_VUPLLF, + SYSZ_INS_VUPLLH, + SYSZ_INS_VX, + SYSZ_INS_VZERO, + SYSZ_INS_WCDGB, + SYSZ_INS_WCDLGB, + SYSZ_INS_WCGDB, + SYSZ_INS_WCLGDB, + SYSZ_INS_WFADB, + SYSZ_INS_WFASB, + SYSZ_INS_WFAXB, + SYSZ_INS_WFC, + SYSZ_INS_WFCDB, + SYSZ_INS_WFCEDB, + SYSZ_INS_WFCEDBS, + SYSZ_INS_WFCESB, + SYSZ_INS_WFCESBS, + SYSZ_INS_WFCEXB, + SYSZ_INS_WFCEXBS, + SYSZ_INS_WFCHDB, + SYSZ_INS_WFCHDBS, + SYSZ_INS_WFCHEDB, + SYSZ_INS_WFCHEDBS, + SYSZ_INS_WFCHESB, + SYSZ_INS_WFCHESBS, + SYSZ_INS_WFCHEXB, + SYSZ_INS_WFCHEXBS, + SYSZ_INS_WFCHSB, + SYSZ_INS_WFCHSBS, + SYSZ_INS_WFCHXB, + SYSZ_INS_WFCHXBS, + SYSZ_INS_WFCSB, + SYSZ_INS_WFCXB, + SYSZ_INS_WFDDB, + SYSZ_INS_WFDSB, + SYSZ_INS_WFDXB, + SYSZ_INS_WFIDB, + SYSZ_INS_WFISB, + SYSZ_INS_WFIXB, + SYSZ_INS_WFK, + SYSZ_INS_WFKDB, + SYSZ_INS_WFKEDB, + SYSZ_INS_WFKEDBS, + SYSZ_INS_WFKESB, + SYSZ_INS_WFKESBS, + SYSZ_INS_WFKEXB, + SYSZ_INS_WFKEXBS, + SYSZ_INS_WFKHDB, + SYSZ_INS_WFKHDBS, + SYSZ_INS_WFKHEDB, + SYSZ_INS_WFKHEDBS, + SYSZ_INS_WFKHESB, + SYSZ_INS_WFKHESBS, + SYSZ_INS_WFKHEXB, + SYSZ_INS_WFKHEXBS, + SYSZ_INS_WFKHSB, + SYSZ_INS_WFKHSBS, + SYSZ_INS_WFKHXB, + SYSZ_INS_WFKHXBS, + SYSZ_INS_WFKSB, + SYSZ_INS_WFKXB, + SYSZ_INS_WFLCDB, + SYSZ_INS_WFLCSB, + SYSZ_INS_WFLCXB, + SYSZ_INS_WFLLD, + SYSZ_INS_WFLLS, + SYSZ_INS_WFLNDB, + SYSZ_INS_WFLNSB, + SYSZ_INS_WFLNXB, + SYSZ_INS_WFLPDB, + SYSZ_INS_WFLPSB, + SYSZ_INS_WFLPXB, + SYSZ_INS_WFLRD, + SYSZ_INS_WFLRX, + SYSZ_INS_WFMADB, + SYSZ_INS_WFMASB, + SYSZ_INS_WFMAXB, + SYSZ_INS_WFMAXDB, + SYSZ_INS_WFMAXSB, + SYSZ_INS_WFMAXXB, + SYSZ_INS_WFMDB, + SYSZ_INS_WFMINDB, + SYSZ_INS_WFMINSB, + SYSZ_INS_WFMINXB, + SYSZ_INS_WFMSB, + SYSZ_INS_WFMSDB, + SYSZ_INS_WFMSSB, + SYSZ_INS_WFMSXB, + SYSZ_INS_WFMXB, + SYSZ_INS_WFNMADB, + SYSZ_INS_WFNMASB, + SYSZ_INS_WFNMAXB, + SYSZ_INS_WFNMSDB, + SYSZ_INS_WFNMSSB, + SYSZ_INS_WFNMSXB, + SYSZ_INS_WFPSODB, + SYSZ_INS_WFPSOSB, + SYSZ_INS_WFPSOXB, + SYSZ_INS_WFSDB, + SYSZ_INS_WFSQDB, + SYSZ_INS_WFSQSB, + SYSZ_INS_WFSQXB, + SYSZ_INS_WFSSB, + SYSZ_INS_WFSXB, + SYSZ_INS_WFTCIDB, + SYSZ_INS_WFTCISB, + SYSZ_INS_WFTCIXB, + SYSZ_INS_WLDEB, + SYSZ_INS_WLEDB, + SYSZ_INS_XSCH, + SYSZ_INS_ZAP, + + SYSZ_INS_ENDING, // <-- mark the end of the list of instructions +} sysz_insn; + +/// Group of SystemZ instructions +typedef enum sysz_insn_group { + SYSZ_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + // Generic groups + // all jump instructions (conditional+direct+indirect jumps) + SYSZ_GRP_JUMP, ///< = CS_GRP_JUMP + + // Architecture-specific groups + SYSZ_GRP_DISTINCTOPS = 128, + SYSZ_GRP_FPEXTENSION, + SYSZ_GRP_HIGHWORD, + SYSZ_GRP_INTERLOCKEDACCESS1, + SYSZ_GRP_LOADSTOREONCOND, + SYSZ_GRP_DFPPACKEDCONVERSION, + SYSZ_GRP_DFPZONEDCONVERSION, + SYSZ_GRP_ENHANCEDDAT2, + SYSZ_GRP_EXECUTIONHINT, + SYSZ_GRP_GUARDEDSTORAGE, + SYSZ_GRP_INSERTREFERENCEBITSMULTIPLE, + SYSZ_GRP_LOADANDTRAP, + SYSZ_GRP_LOADANDZERORIGHTMOSTBYTE, + SYSZ_GRP_LOADSTOREONCOND2, + SYSZ_GRP_MESSAGESECURITYASSIST3, + SYSZ_GRP_MESSAGESECURITYASSIST4, + SYSZ_GRP_MESSAGESECURITYASSIST5, + SYSZ_GRP_MESSAGESECURITYASSIST7, + SYSZ_GRP_MESSAGESECURITYASSIST8, + SYSZ_GRP_MISCELLANEOUSEXTENSIONS, + SYSZ_GRP_MISCELLANEOUSEXTENSIONS2, + SYSZ_GRP_NOVECTOR, + SYSZ_GRP_POPULATIONCOUNT, + SYSZ_GRP_PROCESSORASSIST, + SYSZ_GRP_RESETREFERENCEBITSMULTIPLE, + SYSZ_GRP_TRANSACTIONALEXECUTION, + SYSZ_GRP_VECTOR, + SYSZ_GRP_VECTORENHANCEMENTS1, + SYSZ_GRP_VECTORPACKEDDECIMAL, + + SYSZ_GRP_ENDING, // <-- mark the end of the list of groups +} sysz_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_X86_H +#define CAPSTONE_X86_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2013-2015 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/// Calculate relative address for X86-64, given cs_insn structure +#define X86_REL_ADDR(insn) (((insn).detail->x86.operands[0].type == X86_OP_IMM) \ + ? (uint64_t)((insn).detail->x86.operands[0].imm) \ + : (((insn).address + (insn).size) + (uint64_t)(insn).detail->x86.disp)) + +/// X86 registers +typedef enum x86_reg { + X86_REG_INVALID = 0, + X86_REG_AH, X86_REG_AL, X86_REG_AX, X86_REG_BH, X86_REG_BL, + X86_REG_BP, X86_REG_BPL, X86_REG_BX, X86_REG_CH, X86_REG_CL, + X86_REG_CS, X86_REG_CX, X86_REG_DH, X86_REG_DI, X86_REG_DIL, + X86_REG_DL, X86_REG_DS, X86_REG_DX, X86_REG_EAX, X86_REG_EBP, + X86_REG_EBX, X86_REG_ECX, X86_REG_EDI, X86_REG_EDX, X86_REG_EFLAGS, + X86_REG_EIP, X86_REG_EIZ, X86_REG_ES, X86_REG_ESI, X86_REG_ESP, + X86_REG_FPSW, X86_REG_FS, X86_REG_GS, X86_REG_IP, X86_REG_RAX, + X86_REG_RBP, X86_REG_RBX, X86_REG_RCX, X86_REG_RDI, X86_REG_RDX, + X86_REG_RIP, X86_REG_RIZ, X86_REG_RSI, X86_REG_RSP, X86_REG_SI, + X86_REG_SIL, X86_REG_SP, X86_REG_SPL, X86_REG_SS, X86_REG_CR0, + X86_REG_CR1, X86_REG_CR2, X86_REG_CR3, X86_REG_CR4, X86_REG_CR5, + X86_REG_CR6, X86_REG_CR7, X86_REG_CR8, X86_REG_CR9, X86_REG_CR10, + X86_REG_CR11, X86_REG_CR12, X86_REG_CR13, X86_REG_CR14, X86_REG_CR15, + X86_REG_DR0, X86_REG_DR1, X86_REG_DR2, X86_REG_DR3, X86_REG_DR4, + X86_REG_DR5, X86_REG_DR6, X86_REG_DR7, X86_REG_DR8, X86_REG_DR9, + X86_REG_DR10, X86_REG_DR11, X86_REG_DR12, X86_REG_DR13, X86_REG_DR14, + X86_REG_DR15, X86_REG_FP0, X86_REG_FP1, X86_REG_FP2, X86_REG_FP3, + X86_REG_FP4, X86_REG_FP5, X86_REG_FP6, X86_REG_FP7, + X86_REG_K0, X86_REG_K1, X86_REG_K2, X86_REG_K3, X86_REG_K4, + X86_REG_K5, X86_REG_K6, X86_REG_K7, X86_REG_MM0, X86_REG_MM1, + X86_REG_MM2, X86_REG_MM3, X86_REG_MM4, X86_REG_MM5, X86_REG_MM6, + X86_REG_MM7, X86_REG_R8, X86_REG_R9, X86_REG_R10, X86_REG_R11, + X86_REG_R12, X86_REG_R13, X86_REG_R14, X86_REG_R15, + X86_REG_ST0, X86_REG_ST1, X86_REG_ST2, X86_REG_ST3, + X86_REG_ST4, X86_REG_ST5, X86_REG_ST6, X86_REG_ST7, + X86_REG_XMM0, X86_REG_XMM1, X86_REG_XMM2, X86_REG_XMM3, X86_REG_XMM4, + X86_REG_XMM5, X86_REG_XMM6, X86_REG_XMM7, X86_REG_XMM8, X86_REG_XMM9, + X86_REG_XMM10, X86_REG_XMM11, X86_REG_XMM12, X86_REG_XMM13, X86_REG_XMM14, + X86_REG_XMM15, X86_REG_XMM16, X86_REG_XMM17, X86_REG_XMM18, X86_REG_XMM19, + X86_REG_XMM20, X86_REG_XMM21, X86_REG_XMM22, X86_REG_XMM23, X86_REG_XMM24, + X86_REG_XMM25, X86_REG_XMM26, X86_REG_XMM27, X86_REG_XMM28, X86_REG_XMM29, + X86_REG_XMM30, X86_REG_XMM31, X86_REG_YMM0, X86_REG_YMM1, X86_REG_YMM2, + X86_REG_YMM3, X86_REG_YMM4, X86_REG_YMM5, X86_REG_YMM6, X86_REG_YMM7, + X86_REG_YMM8, X86_REG_YMM9, X86_REG_YMM10, X86_REG_YMM11, X86_REG_YMM12, + X86_REG_YMM13, X86_REG_YMM14, X86_REG_YMM15, X86_REG_YMM16, X86_REG_YMM17, + X86_REG_YMM18, X86_REG_YMM19, X86_REG_YMM20, X86_REG_YMM21, X86_REG_YMM22, + X86_REG_YMM23, X86_REG_YMM24, X86_REG_YMM25, X86_REG_YMM26, X86_REG_YMM27, + X86_REG_YMM28, X86_REG_YMM29, X86_REG_YMM30, X86_REG_YMM31, X86_REG_ZMM0, + X86_REG_ZMM1, X86_REG_ZMM2, X86_REG_ZMM3, X86_REG_ZMM4, X86_REG_ZMM5, + X86_REG_ZMM6, X86_REG_ZMM7, X86_REG_ZMM8, X86_REG_ZMM9, X86_REG_ZMM10, + X86_REG_ZMM11, X86_REG_ZMM12, X86_REG_ZMM13, X86_REG_ZMM14, X86_REG_ZMM15, + X86_REG_ZMM16, X86_REG_ZMM17, X86_REG_ZMM18, X86_REG_ZMM19, X86_REG_ZMM20, + X86_REG_ZMM21, X86_REG_ZMM22, X86_REG_ZMM23, X86_REG_ZMM24, X86_REG_ZMM25, + X86_REG_ZMM26, X86_REG_ZMM27, X86_REG_ZMM28, X86_REG_ZMM29, X86_REG_ZMM30, + X86_REG_ZMM31, X86_REG_R8B, X86_REG_R9B, X86_REG_R10B, X86_REG_R11B, + X86_REG_R12B, X86_REG_R13B, X86_REG_R14B, X86_REG_R15B, X86_REG_R8D, + X86_REG_R9D, X86_REG_R10D, X86_REG_R11D, X86_REG_R12D, X86_REG_R13D, + X86_REG_R14D, X86_REG_R15D, X86_REG_R8W, X86_REG_R9W, X86_REG_R10W, + X86_REG_R11W, X86_REG_R12W, X86_REG_R13W, X86_REG_R14W, X86_REG_R15W, + X86_REG_BND0, X86_REG_BND1, X86_REG_BND2, X86_REG_BND3, + + X86_REG_ENDING // <-- mark the end of the list of registers +} x86_reg; + +// Sub-flags of EFLAGS +#define X86_EFLAGS_MODIFY_AF (1ULL << 0) +#define X86_EFLAGS_MODIFY_CF (1ULL << 1) +#define X86_EFLAGS_MODIFY_SF (1ULL << 2) +#define X86_EFLAGS_MODIFY_ZF (1ULL << 3) +#define X86_EFLAGS_MODIFY_PF (1ULL << 4) +#define X86_EFLAGS_MODIFY_OF (1ULL << 5) +#define X86_EFLAGS_MODIFY_TF (1ULL << 6) +#define X86_EFLAGS_MODIFY_IF (1ULL << 7) +#define X86_EFLAGS_MODIFY_DF (1ULL << 8) +#define X86_EFLAGS_MODIFY_NT (1ULL << 9) +#define X86_EFLAGS_MODIFY_RF (1ULL << 10) +#define X86_EFLAGS_PRIOR_OF (1ULL << 11) +#define X86_EFLAGS_PRIOR_SF (1ULL << 12) +#define X86_EFLAGS_PRIOR_ZF (1ULL << 13) +#define X86_EFLAGS_PRIOR_AF (1ULL << 14) +#define X86_EFLAGS_PRIOR_PF (1ULL << 15) +#define X86_EFLAGS_PRIOR_CF (1ULL << 16) +#define X86_EFLAGS_PRIOR_TF (1ULL << 17) +#define X86_EFLAGS_PRIOR_IF (1ULL << 18) +#define X86_EFLAGS_PRIOR_DF (1ULL << 19) +#define X86_EFLAGS_PRIOR_NT (1ULL << 20) +#define X86_EFLAGS_RESET_OF (1ULL << 21) +#define X86_EFLAGS_RESET_CF (1ULL << 22) +#define X86_EFLAGS_RESET_DF (1ULL << 23) +#define X86_EFLAGS_RESET_IF (1ULL << 24) +#define X86_EFLAGS_RESET_SF (1ULL << 25) +#define X86_EFLAGS_RESET_AF (1ULL << 26) +#define X86_EFLAGS_RESET_TF (1ULL << 27) +#define X86_EFLAGS_RESET_NT (1ULL << 28) +#define X86_EFLAGS_RESET_PF (1ULL << 29) +#define X86_EFLAGS_SET_CF (1ULL << 30) +#define X86_EFLAGS_SET_DF (1ULL << 31) +#define X86_EFLAGS_SET_IF (1ULL << 32) +#define X86_EFLAGS_TEST_OF (1ULL << 33) +#define X86_EFLAGS_TEST_SF (1ULL << 34) +#define X86_EFLAGS_TEST_ZF (1ULL << 35) +#define X86_EFLAGS_TEST_PF (1ULL << 36) +#define X86_EFLAGS_TEST_CF (1ULL << 37) +#define X86_EFLAGS_TEST_NT (1ULL << 38) +#define X86_EFLAGS_TEST_DF (1ULL << 39) +#define X86_EFLAGS_UNDEFINED_OF (1ULL << 40) +#define X86_EFLAGS_UNDEFINED_SF (1ULL << 41) +#define X86_EFLAGS_UNDEFINED_ZF (1ULL << 42) +#define X86_EFLAGS_UNDEFINED_PF (1ULL << 43) +#define X86_EFLAGS_UNDEFINED_AF (1ULL << 44) +#define X86_EFLAGS_UNDEFINED_CF (1ULL << 45) +#define X86_EFLAGS_RESET_RF (1ULL << 46) +#define X86_EFLAGS_TEST_RF (1ULL << 47) +#define X86_EFLAGS_TEST_IF (1ULL << 48) +#define X86_EFLAGS_TEST_TF (1ULL << 49) +#define X86_EFLAGS_TEST_AF (1ULL << 50) +#define X86_EFLAGS_RESET_ZF (1ULL << 51) +#define X86_EFLAGS_SET_OF (1ULL << 52) +#define X86_EFLAGS_SET_SF (1ULL << 53) +#define X86_EFLAGS_SET_ZF (1ULL << 54) +#define X86_EFLAGS_SET_AF (1ULL << 55) +#define X86_EFLAGS_SET_PF (1ULL << 56) +#define X86_EFLAGS_RESET_0F (1ULL << 57) +#define X86_EFLAGS_RESET_AC (1ULL << 58) + +#define X86_FPU_FLAGS_MODIFY_C0 (1ULL << 0) +#define X86_FPU_FLAGS_MODIFY_C1 (1ULL << 1) +#define X86_FPU_FLAGS_MODIFY_C2 (1ULL << 2) +#define X86_FPU_FLAGS_MODIFY_C3 (1ULL << 3) +#define X86_FPU_FLAGS_RESET_C0 (1ULL << 4) +#define X86_FPU_FLAGS_RESET_C1 (1ULL << 5) +#define X86_FPU_FLAGS_RESET_C2 (1ULL << 6) +#define X86_FPU_FLAGS_RESET_C3 (1ULL << 7) +#define X86_FPU_FLAGS_SET_C0 (1ULL << 8) +#define X86_FPU_FLAGS_SET_C1 (1ULL << 9) +#define X86_FPU_FLAGS_SET_C2 (1ULL << 10) +#define X86_FPU_FLAGS_SET_C3 (1ULL << 11) +#define X86_FPU_FLAGS_UNDEFINED_C0 (1ULL << 12) +#define X86_FPU_FLAGS_UNDEFINED_C1 (1ULL << 13) +#define X86_FPU_FLAGS_UNDEFINED_C2 (1ULL << 14) +#define X86_FPU_FLAGS_UNDEFINED_C3 (1ULL << 15) +#define X86_FPU_FLAGS_TEST_C0 (1ULL << 16) +#define X86_FPU_FLAGS_TEST_C1 (1ULL << 17) +#define X86_FPU_FLAGS_TEST_C2 (1ULL << 18) +#define X86_FPU_FLAGS_TEST_C3 (1ULL << 19) + + +/// Operand type for instruction's operands +typedef enum x86_op_type { + X86_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + X86_OP_REG, ///< = CS_OP_REG (Register operand). + X86_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + X86_OP_MEM, ///< = CS_OP_MEM (Memory operand). +} x86_op_type; + +/// XOP Code Condition type +typedef enum x86_xop_cc { + X86_XOP_CC_INVALID = 0, ///< Uninitialized. + X86_XOP_CC_LT, + X86_XOP_CC_LE, + X86_XOP_CC_GT, + X86_XOP_CC_GE, + X86_XOP_CC_EQ, + X86_XOP_CC_NEQ, + X86_XOP_CC_FALSE, + X86_XOP_CC_TRUE, +} x86_xop_cc; + +/// AVX broadcast type +typedef enum x86_avx_bcast { + X86_AVX_BCAST_INVALID = 0, ///< Uninitialized. + X86_AVX_BCAST_2, ///< AVX512 broadcast type {1to2} + X86_AVX_BCAST_4, ///< AVX512 broadcast type {1to4} + X86_AVX_BCAST_8, ///< AVX512 broadcast type {1to8} + X86_AVX_BCAST_16, ///< AVX512 broadcast type {1to16} +} x86_avx_bcast; + +/// SSE Code Condition type +typedef enum x86_sse_cc { + X86_SSE_CC_INVALID = 0, ///< Uninitialized. + X86_SSE_CC_EQ, + X86_SSE_CC_LT, + X86_SSE_CC_LE, + X86_SSE_CC_UNORD, + X86_SSE_CC_NEQ, + X86_SSE_CC_NLT, + X86_SSE_CC_NLE, + X86_SSE_CC_ORD, +} x86_sse_cc; + +/// AVX Code Condition type +typedef enum x86_avx_cc { + X86_AVX_CC_INVALID = 0, ///< Uninitialized. + X86_AVX_CC_EQ, + X86_AVX_CC_LT, + X86_AVX_CC_LE, + X86_AVX_CC_UNORD, + X86_AVX_CC_NEQ, + X86_AVX_CC_NLT, + X86_AVX_CC_NLE, + X86_AVX_CC_ORD, + X86_AVX_CC_EQ_UQ, + X86_AVX_CC_NGE, + X86_AVX_CC_NGT, + X86_AVX_CC_FALSE, + X86_AVX_CC_NEQ_OQ, + X86_AVX_CC_GE, + X86_AVX_CC_GT, + X86_AVX_CC_TRUE, + X86_AVX_CC_EQ_OS, + X86_AVX_CC_LT_OQ, + X86_AVX_CC_LE_OQ, + X86_AVX_CC_UNORD_S, + X86_AVX_CC_NEQ_US, + X86_AVX_CC_NLT_UQ, + X86_AVX_CC_NLE_UQ, + X86_AVX_CC_ORD_S, + X86_AVX_CC_EQ_US, + X86_AVX_CC_NGE_UQ, + X86_AVX_CC_NGT_UQ, + X86_AVX_CC_FALSE_OS, + X86_AVX_CC_NEQ_OS, + X86_AVX_CC_GE_OQ, + X86_AVX_CC_GT_OQ, + X86_AVX_CC_TRUE_US, +} x86_avx_cc; + +/// AVX static rounding mode type +typedef enum x86_avx_rm { + X86_AVX_RM_INVALID = 0, ///< Uninitialized. + X86_AVX_RM_RN, ///< Round to nearest + X86_AVX_RM_RD, ///< Round down + X86_AVX_RM_RU, ///< Round up + X86_AVX_RM_RZ, ///< Round toward zero +} x86_avx_rm; + +/// Instruction prefixes - to be used in cs_x86.prefix[] +typedef enum x86_prefix { + X86_PREFIX_LOCK = 0xf0, ///< lock (cs_x86.prefix[0] + X86_PREFIX_REP = 0xf3, ///< rep (cs_x86.prefix[0] + X86_PREFIX_REPE = 0xf3, ///< repe/repz (cs_x86.prefix[0] + X86_PREFIX_REPNE = 0xf2, ///< repne/repnz (cs_x86.prefix[0] + + X86_PREFIX_CS = 0x2e, ///< segment override CS (cs_x86.prefix[1] + X86_PREFIX_SS = 0x36, ///< segment override SS (cs_x86.prefix[1] + X86_PREFIX_DS = 0x3e, ///< segment override DS (cs_x86.prefix[1] + X86_PREFIX_ES = 0x26, ///< segment override ES (cs_x86.prefix[1] + X86_PREFIX_FS = 0x64, ///< segment override FS (cs_x86.prefix[1] + X86_PREFIX_GS = 0x65, ///< segment override GS (cs_x86.prefix[1] + + X86_PREFIX_OPSIZE = 0x66, ///< operand-size override (cs_x86.prefix[2] + X86_PREFIX_ADDRSIZE = 0x67, ///< address-size override (cs_x86.prefix[3] +} x86_prefix; + +/// Instruction's operand referring to memory +/// This is associated with X86_OP_MEM operand type above +typedef struct x86_op_mem { + x86_reg segment; ///< segment register (or X86_REG_INVALID if irrelevant) + x86_reg base; ///< base register (or X86_REG_INVALID if irrelevant) + x86_reg index; ///< index register (or X86_REG_INVALID if irrelevant) + int scale; ///< scale for index register + int64_t disp; ///< displacement value +} x86_op_mem; + +/// Instruction operand +typedef struct cs_x86_op { + x86_op_type type; ///< operand type + union { + x86_reg reg; ///< register value for REG operand + int64_t imm; ///< immediate value for IMM operand + x86_op_mem mem; ///< base/index/scale/disp value for MEM operand + }; + + /// size of this operand (in bytes). + uint8_t size; + + /// How is this operand accessed? (READ, WRITE or READ|WRITE) + /// This field is combined of cs_ac_type. + /// NOTE: this field is irrelevant if engine is compiled in DIET mode. + uint8_t access; + + /// AVX broadcast type, or 0 if irrelevant + x86_avx_bcast avx_bcast; + + /// AVX zero opmask {z} + bool avx_zero_opmask; +} cs_x86_op; + +typedef struct cs_x86_encoding { + /// ModR/M offset, or 0 when irrelevant + uint8_t modrm_offset; + + /// Displacement offset, or 0 when irrelevant. + uint8_t disp_offset; + uint8_t disp_size; + + /// Immediate offset, or 0 when irrelevant. + uint8_t imm_offset; + uint8_t imm_size; +} cs_x86_encoding; + +/// Instruction structure +typedef struct cs_x86 { + /// Instruction prefix, which can be up to 4 bytes. + /// A prefix byte gets value 0 when irrelevant. + /// prefix[0] indicates REP/REPNE/LOCK prefix (See X86_PREFIX_REP/REPNE/LOCK above) + /// prefix[1] indicates segment override (irrelevant for x86_64): + /// See X86_PREFIX_CS/SS/DS/ES/FS/GS above. + /// prefix[2] indicates operand-size override (X86_PREFIX_OPSIZE) + /// prefix[3] indicates address-size override (X86_PREFIX_ADDRSIZE) + uint8_t prefix[4]; + + /// Instruction opcode, which can be from 1 to 4 bytes in size. + /// This contains VEX opcode as well. + /// An trailing opcode byte gets value 0 when irrelevant. + uint8_t opcode[4]; + + /// REX prefix: only a non-zero value is relevant for x86_64 + uint8_t rex; + + /// Address size, which can be overridden with above prefix[5]. + uint8_t addr_size; + + /// ModR/M byte + uint8_t modrm; + + /// SIB value, or 0 when irrelevant. + uint8_t sib; + + /// Displacement value, valid if encoding.disp_offset != 0 + int64_t disp; + + /// SIB index register, or X86_REG_INVALID when irrelevant. + x86_reg sib_index; + /// SIB scale, only applicable if sib_index is valid. + int8_t sib_scale; + /// SIB base register, or X86_REG_INVALID when irrelevant. + x86_reg sib_base; + + /// XOP Code Condition + x86_xop_cc xop_cc; + + /// SSE Code Condition + x86_sse_cc sse_cc; + + /// AVX Code Condition + x86_avx_cc avx_cc; + + /// AVX Suppress all Exception + bool avx_sae; + + /// AVX static rounding mode + x86_avx_rm avx_rm; + + + union { + /// EFLAGS updated by this instruction. + /// This can be formed from OR combination of X86_EFLAGS_* symbols in x86.h + uint64_t eflags; + /// FPU_FLAGS updated by this instruction. + /// This can be formed from OR combination of X86_FPU_FLAGS_* symbols in x86.h + uint64_t fpu_flags; + }; + + /// Number of operands of this instruction, + /// or 0 when instruction has no operand. + uint8_t op_count; + + cs_x86_op operands[8]; ///< operands for this instruction. + + cs_x86_encoding encoding; ///< encoding information +} cs_x86; + +/// X86 instructions +typedef enum x86_insn { + X86_INS_INVALID = 0, + + X86_INS_AAA, + X86_INS_AAD, + X86_INS_AAM, + X86_INS_AAS, + X86_INS_FABS, + X86_INS_ADC, + X86_INS_ADCX, + X86_INS_ADD, + X86_INS_ADDPD, + X86_INS_ADDPS, + X86_INS_ADDSD, + X86_INS_ADDSS, + X86_INS_ADDSUBPD, + X86_INS_ADDSUBPS, + X86_INS_FADD, + X86_INS_FIADD, + X86_INS_ADOX, + X86_INS_AESDECLAST, + X86_INS_AESDEC, + X86_INS_AESENCLAST, + X86_INS_AESENC, + X86_INS_AESIMC, + X86_INS_AESKEYGENASSIST, + X86_INS_AND, + X86_INS_ANDN, + X86_INS_ANDNPD, + X86_INS_ANDNPS, + X86_INS_ANDPD, + X86_INS_ANDPS, + X86_INS_ARPL, + X86_INS_BEXTR, + X86_INS_BLCFILL, + X86_INS_BLCI, + X86_INS_BLCIC, + X86_INS_BLCMSK, + X86_INS_BLCS, + X86_INS_BLENDPD, + X86_INS_BLENDPS, + X86_INS_BLENDVPD, + X86_INS_BLENDVPS, + X86_INS_BLSFILL, + X86_INS_BLSI, + X86_INS_BLSIC, + X86_INS_BLSMSK, + X86_INS_BLSR, + X86_INS_BNDCL, + X86_INS_BNDCN, + X86_INS_BNDCU, + X86_INS_BNDLDX, + X86_INS_BNDMK, + X86_INS_BNDMOV, + X86_INS_BNDSTX, + X86_INS_BOUND, + X86_INS_BSF, + X86_INS_BSR, + X86_INS_BSWAP, + X86_INS_BT, + X86_INS_BTC, + X86_INS_BTR, + X86_INS_BTS, + X86_INS_BZHI, + X86_INS_CALL, + X86_INS_CBW, + X86_INS_CDQ, + X86_INS_CDQE, + X86_INS_FCHS, + X86_INS_CLAC, + X86_INS_CLC, + X86_INS_CLD, + X86_INS_CLDEMOTE, + X86_INS_CLFLUSH, + X86_INS_CLFLUSHOPT, + X86_INS_CLGI, + X86_INS_CLI, + X86_INS_CLRSSBSY, + X86_INS_CLTS, + X86_INS_CLWB, + X86_INS_CLZERO, + X86_INS_CMC, + X86_INS_CMOVA, + X86_INS_CMOVAE, + X86_INS_CMOVB, + X86_INS_CMOVBE, + X86_INS_FCMOVBE, + X86_INS_FCMOVB, + X86_INS_CMOVE, + X86_INS_FCMOVE, + X86_INS_CMOVG, + X86_INS_CMOVGE, + X86_INS_CMOVL, + X86_INS_CMOVLE, + X86_INS_FCMOVNBE, + X86_INS_FCMOVNB, + X86_INS_CMOVNE, + X86_INS_FCMOVNE, + X86_INS_CMOVNO, + X86_INS_CMOVNP, + X86_INS_FCMOVNU, + X86_INS_FCMOVNP, + X86_INS_CMOVNS, + X86_INS_CMOVO, + X86_INS_CMOVP, + X86_INS_FCMOVU, + X86_INS_CMOVS, + X86_INS_CMP, + X86_INS_CMPPD, + X86_INS_CMPPS, + X86_INS_CMPSB, + X86_INS_CMPSD, + X86_INS_CMPSQ, + X86_INS_CMPSS, + X86_INS_CMPSW, + X86_INS_CMPXCHG16B, + X86_INS_CMPXCHG, + X86_INS_CMPXCHG8B, + X86_INS_COMISD, + X86_INS_COMISS, + X86_INS_FCOMP, + X86_INS_FCOMPI, + X86_INS_FCOMI, + X86_INS_FCOM, + X86_INS_FCOS, + X86_INS_CPUID, + X86_INS_CQO, + X86_INS_CRC32, + X86_INS_CVTDQ2PD, + X86_INS_CVTDQ2PS, + X86_INS_CVTPD2DQ, + X86_INS_CVTPD2PS, + X86_INS_CVTPS2DQ, + X86_INS_CVTPS2PD, + X86_INS_CVTSD2SI, + X86_INS_CVTSD2SS, + X86_INS_CVTSI2SD, + X86_INS_CVTSI2SS, + X86_INS_CVTSS2SD, + X86_INS_CVTSS2SI, + X86_INS_CVTTPD2DQ, + X86_INS_CVTTPS2DQ, + X86_INS_CVTTSD2SI, + X86_INS_CVTTSS2SI, + X86_INS_CWD, + X86_INS_CWDE, + X86_INS_DAA, + X86_INS_DAS, + X86_INS_DATA16, + X86_INS_DEC, + X86_INS_DIV, + X86_INS_DIVPD, + X86_INS_DIVPS, + X86_INS_FDIVR, + X86_INS_FIDIVR, + X86_INS_FDIVRP, + X86_INS_DIVSD, + X86_INS_DIVSS, + X86_INS_FDIV, + X86_INS_FIDIV, + X86_INS_FDIVP, + X86_INS_DPPD, + X86_INS_DPPS, + X86_INS_ENCLS, + X86_INS_ENCLU, + X86_INS_ENCLV, + X86_INS_ENDBR32, + X86_INS_ENDBR64, + X86_INS_ENTER, + X86_INS_EXTRACTPS, + X86_INS_EXTRQ, + X86_INS_F2XM1, + X86_INS_LCALL, + X86_INS_LJMP, + X86_INS_JMP, + X86_INS_FBLD, + X86_INS_FBSTP, + X86_INS_FCOMPP, + X86_INS_FDECSTP, + X86_INS_FDISI8087_NOP, + X86_INS_FEMMS, + X86_INS_FENI8087_NOP, + X86_INS_FFREE, + X86_INS_FFREEP, + X86_INS_FICOM, + X86_INS_FICOMP, + X86_INS_FINCSTP, + X86_INS_FLDCW, + X86_INS_FLDENV, + X86_INS_FLDL2E, + X86_INS_FLDL2T, + X86_INS_FLDLG2, + X86_INS_FLDLN2, + X86_INS_FLDPI, + X86_INS_FNCLEX, + X86_INS_FNINIT, + X86_INS_FNOP, + X86_INS_FNSTCW, + X86_INS_FNSTSW, + X86_INS_FPATAN, + X86_INS_FSTPNCE, + X86_INS_FPREM, + X86_INS_FPREM1, + X86_INS_FPTAN, + X86_INS_FRNDINT, + X86_INS_FRSTOR, + X86_INS_FNSAVE, + X86_INS_FSCALE, + X86_INS_FSETPM, + X86_INS_FSINCOS, + X86_INS_FNSTENV, + X86_INS_FXAM, + X86_INS_FXRSTOR, + X86_INS_FXRSTOR64, + X86_INS_FXSAVE, + X86_INS_FXSAVE64, + X86_INS_FXTRACT, + X86_INS_FYL2X, + X86_INS_FYL2XP1, + X86_INS_GETSEC, + X86_INS_GF2P8AFFINEINVQB, + X86_INS_GF2P8AFFINEQB, + X86_INS_GF2P8MULB, + X86_INS_HADDPD, + X86_INS_HADDPS, + X86_INS_HLT, + X86_INS_HSUBPD, + X86_INS_HSUBPS, + X86_INS_IDIV, + X86_INS_FILD, + X86_INS_IMUL, + X86_INS_IN, + X86_INS_INC, + X86_INS_INCSSPD, + X86_INS_INCSSPQ, + X86_INS_INSB, + X86_INS_INSERTPS, + X86_INS_INSERTQ, + X86_INS_INSD, + X86_INS_INSW, + X86_INS_INT, + X86_INS_INT1, + X86_INS_INT3, + X86_INS_INTO, + X86_INS_INVD, + X86_INS_INVEPT, + X86_INS_INVLPG, + X86_INS_INVLPGA, + X86_INS_INVPCID, + X86_INS_INVVPID, + X86_INS_IRET, + X86_INS_IRETD, + X86_INS_IRETQ, + X86_INS_FISTTP, + X86_INS_FIST, + X86_INS_FISTP, + X86_INS_JAE, + X86_INS_JA, + X86_INS_JBE, + X86_INS_JB, + X86_INS_JCXZ, + X86_INS_JECXZ, + X86_INS_JE, + X86_INS_JGE, + X86_INS_JG, + X86_INS_JLE, + X86_INS_JL, + X86_INS_JNE, + X86_INS_JNO, + X86_INS_JNP, + X86_INS_JNS, + X86_INS_JO, + X86_INS_JP, + X86_INS_JRCXZ, + X86_INS_JS, + X86_INS_KADDB, + X86_INS_KADDD, + X86_INS_KADDQ, + X86_INS_KADDW, + X86_INS_KANDB, + X86_INS_KANDD, + X86_INS_KANDNB, + X86_INS_KANDND, + X86_INS_KANDNQ, + X86_INS_KANDNW, + X86_INS_KANDQ, + X86_INS_KANDW, + X86_INS_KMOVB, + X86_INS_KMOVD, + X86_INS_KMOVQ, + X86_INS_KMOVW, + X86_INS_KNOTB, + X86_INS_KNOTD, + X86_INS_KNOTQ, + X86_INS_KNOTW, + X86_INS_KORB, + X86_INS_KORD, + X86_INS_KORQ, + X86_INS_KORTESTB, + X86_INS_KORTESTD, + X86_INS_KORTESTQ, + X86_INS_KORTESTW, + X86_INS_KORW, + X86_INS_KSHIFTLB, + X86_INS_KSHIFTLD, + X86_INS_KSHIFTLQ, + X86_INS_KSHIFTLW, + X86_INS_KSHIFTRB, + X86_INS_KSHIFTRD, + X86_INS_KSHIFTRQ, + X86_INS_KSHIFTRW, + X86_INS_KTESTB, + X86_INS_KTESTD, + X86_INS_KTESTQ, + X86_INS_KTESTW, + X86_INS_KUNPCKBW, + X86_INS_KUNPCKDQ, + X86_INS_KUNPCKWD, + X86_INS_KXNORB, + X86_INS_KXNORD, + X86_INS_KXNORQ, + X86_INS_KXNORW, + X86_INS_KXORB, + X86_INS_KXORD, + X86_INS_KXORQ, + X86_INS_KXORW, + X86_INS_LAHF, + X86_INS_LAR, + X86_INS_LDDQU, + X86_INS_LDMXCSR, + X86_INS_LDS, + X86_INS_FLDZ, + X86_INS_FLD1, + X86_INS_FLD, + X86_INS_LEA, + X86_INS_LEAVE, + X86_INS_LES, + X86_INS_LFENCE, + X86_INS_LFS, + X86_INS_LGDT, + X86_INS_LGS, + X86_INS_LIDT, + X86_INS_LLDT, + X86_INS_LLWPCB, + X86_INS_LMSW, + X86_INS_LOCK, + X86_INS_LODSB, + X86_INS_LODSD, + X86_INS_LODSQ, + X86_INS_LODSW, + X86_INS_LOOP, + X86_INS_LOOPE, + X86_INS_LOOPNE, + X86_INS_RETF, + X86_INS_RETFQ, + X86_INS_LSL, + X86_INS_LSS, + X86_INS_LTR, + X86_INS_LWPINS, + X86_INS_LWPVAL, + X86_INS_LZCNT, + X86_INS_MASKMOVDQU, + X86_INS_MAXPD, + X86_INS_MAXPS, + X86_INS_MAXSD, + X86_INS_MAXSS, + X86_INS_MFENCE, + X86_INS_MINPD, + X86_INS_MINPS, + X86_INS_MINSD, + X86_INS_MINSS, + X86_INS_CVTPD2PI, + X86_INS_CVTPI2PD, + X86_INS_CVTPI2PS, + X86_INS_CVTPS2PI, + X86_INS_CVTTPD2PI, + X86_INS_CVTTPS2PI, + X86_INS_EMMS, + X86_INS_MASKMOVQ, + X86_INS_MOVD, + X86_INS_MOVQ, + X86_INS_MOVDQ2Q, + X86_INS_MOVNTQ, + X86_INS_MOVQ2DQ, + X86_INS_PABSB, + X86_INS_PABSD, + X86_INS_PABSW, + X86_INS_PACKSSDW, + X86_INS_PACKSSWB, + X86_INS_PACKUSWB, + X86_INS_PADDB, + X86_INS_PADDD, + X86_INS_PADDQ, + X86_INS_PADDSB, + X86_INS_PADDSW, + X86_INS_PADDUSB, + X86_INS_PADDUSW, + X86_INS_PADDW, + X86_INS_PALIGNR, + X86_INS_PANDN, + X86_INS_PAND, + X86_INS_PAVGB, + X86_INS_PAVGW, + X86_INS_PCMPEQB, + X86_INS_PCMPEQD, + X86_INS_PCMPEQW, + X86_INS_PCMPGTB, + X86_INS_PCMPGTD, + X86_INS_PCMPGTW, + X86_INS_PEXTRW, + X86_INS_PHADDD, + X86_INS_PHADDSW, + X86_INS_PHADDW, + X86_INS_PHSUBD, + X86_INS_PHSUBSW, + X86_INS_PHSUBW, + X86_INS_PINSRW, + X86_INS_PMADDUBSW, + X86_INS_PMADDWD, + X86_INS_PMAXSW, + X86_INS_PMAXUB, + X86_INS_PMINSW, + X86_INS_PMINUB, + X86_INS_PMOVMSKB, + X86_INS_PMULHRSW, + X86_INS_PMULHUW, + X86_INS_PMULHW, + X86_INS_PMULLW, + X86_INS_PMULUDQ, + X86_INS_POR, + X86_INS_PSADBW, + X86_INS_PSHUFB, + X86_INS_PSHUFW, + X86_INS_PSIGNB, + X86_INS_PSIGND, + X86_INS_PSIGNW, + X86_INS_PSLLD, + X86_INS_PSLLQ, + X86_INS_PSLLW, + X86_INS_PSRAD, + X86_INS_PSRAW, + X86_INS_PSRLD, + X86_INS_PSRLQ, + X86_INS_PSRLW, + X86_INS_PSUBB, + X86_INS_PSUBD, + X86_INS_PSUBQ, + X86_INS_PSUBSB, + X86_INS_PSUBSW, + X86_INS_PSUBUSB, + X86_INS_PSUBUSW, + X86_INS_PSUBW, + X86_INS_PUNPCKHBW, + X86_INS_PUNPCKHDQ, + X86_INS_PUNPCKHWD, + X86_INS_PUNPCKLBW, + X86_INS_PUNPCKLDQ, + X86_INS_PUNPCKLWD, + X86_INS_PXOR, + X86_INS_MONITORX, + X86_INS_MONITOR, + X86_INS_MONTMUL, + X86_INS_MOV, + X86_INS_MOVABS, + X86_INS_MOVAPD, + X86_INS_MOVAPS, + X86_INS_MOVBE, + X86_INS_MOVDDUP, + X86_INS_MOVDIR64B, + X86_INS_MOVDIRI, + X86_INS_MOVDQA, + X86_INS_MOVDQU, + X86_INS_MOVHLPS, + X86_INS_MOVHPD, + X86_INS_MOVHPS, + X86_INS_MOVLHPS, + X86_INS_MOVLPD, + X86_INS_MOVLPS, + X86_INS_MOVMSKPD, + X86_INS_MOVMSKPS, + X86_INS_MOVNTDQA, + X86_INS_MOVNTDQ, + X86_INS_MOVNTI, + X86_INS_MOVNTPD, + X86_INS_MOVNTPS, + X86_INS_MOVNTSD, + X86_INS_MOVNTSS, + X86_INS_MOVSB, + X86_INS_MOVSD, + X86_INS_MOVSHDUP, + X86_INS_MOVSLDUP, + X86_INS_MOVSQ, + X86_INS_MOVSS, + X86_INS_MOVSW, + X86_INS_MOVSX, + X86_INS_MOVSXD, + X86_INS_MOVUPD, + X86_INS_MOVUPS, + X86_INS_MOVZX, + X86_INS_MPSADBW, + X86_INS_MUL, + X86_INS_MULPD, + X86_INS_MULPS, + X86_INS_MULSD, + X86_INS_MULSS, + X86_INS_MULX, + X86_INS_FMUL, + X86_INS_FIMUL, + X86_INS_FMULP, + X86_INS_MWAITX, + X86_INS_MWAIT, + X86_INS_NEG, + X86_INS_NOP, + X86_INS_NOT, + X86_INS_OR, + X86_INS_ORPD, + X86_INS_ORPS, + X86_INS_OUT, + X86_INS_OUTSB, + X86_INS_OUTSD, + X86_INS_OUTSW, + X86_INS_PACKUSDW, + X86_INS_PAUSE, + X86_INS_PAVGUSB, + X86_INS_PBLENDVB, + X86_INS_PBLENDW, + X86_INS_PCLMULQDQ, + X86_INS_PCMPEQQ, + X86_INS_PCMPESTRI, + X86_INS_PCMPESTRM, + X86_INS_PCMPGTQ, + X86_INS_PCMPISTRI, + X86_INS_PCMPISTRM, + X86_INS_PCONFIG, + X86_INS_PDEP, + X86_INS_PEXT, + X86_INS_PEXTRB, + X86_INS_PEXTRD, + X86_INS_PEXTRQ, + X86_INS_PF2ID, + X86_INS_PF2IW, + X86_INS_PFACC, + X86_INS_PFADD, + X86_INS_PFCMPEQ, + X86_INS_PFCMPGE, + X86_INS_PFCMPGT, + X86_INS_PFMAX, + X86_INS_PFMIN, + X86_INS_PFMUL, + X86_INS_PFNACC, + X86_INS_PFPNACC, + X86_INS_PFRCPIT1, + X86_INS_PFRCPIT2, + X86_INS_PFRCP, + X86_INS_PFRSQIT1, + X86_INS_PFRSQRT, + X86_INS_PFSUBR, + X86_INS_PFSUB, + X86_INS_PHMINPOSUW, + X86_INS_PI2FD, + X86_INS_PI2FW, + X86_INS_PINSRB, + X86_INS_PINSRD, + X86_INS_PINSRQ, + X86_INS_PMAXSB, + X86_INS_PMAXSD, + X86_INS_PMAXUD, + X86_INS_PMAXUW, + X86_INS_PMINSB, + X86_INS_PMINSD, + X86_INS_PMINUD, + X86_INS_PMINUW, + X86_INS_PMOVSXBD, + X86_INS_PMOVSXBQ, + X86_INS_PMOVSXBW, + X86_INS_PMOVSXDQ, + X86_INS_PMOVSXWD, + X86_INS_PMOVSXWQ, + X86_INS_PMOVZXBD, + X86_INS_PMOVZXBQ, + X86_INS_PMOVZXBW, + X86_INS_PMOVZXDQ, + X86_INS_PMOVZXWD, + X86_INS_PMOVZXWQ, + X86_INS_PMULDQ, + X86_INS_PMULHRW, + X86_INS_PMULLD, + X86_INS_POP, + X86_INS_POPAW, + X86_INS_POPAL, + X86_INS_POPCNT, + X86_INS_POPF, + X86_INS_POPFD, + X86_INS_POPFQ, + X86_INS_PREFETCH, + X86_INS_PREFETCHNTA, + X86_INS_PREFETCHT0, + X86_INS_PREFETCHT1, + X86_INS_PREFETCHT2, + X86_INS_PREFETCHW, + X86_INS_PREFETCHWT1, + X86_INS_PSHUFD, + X86_INS_PSHUFHW, + X86_INS_PSHUFLW, + X86_INS_PSLLDQ, + X86_INS_PSRLDQ, + X86_INS_PSWAPD, + X86_INS_PTEST, + X86_INS_PTWRITE, + X86_INS_PUNPCKHQDQ, + X86_INS_PUNPCKLQDQ, + X86_INS_PUSH, + X86_INS_PUSHAW, + X86_INS_PUSHAL, + X86_INS_PUSHF, + X86_INS_PUSHFD, + X86_INS_PUSHFQ, + X86_INS_RCL, + X86_INS_RCPPS, + X86_INS_RCPSS, + X86_INS_RCR, + X86_INS_RDFSBASE, + X86_INS_RDGSBASE, + X86_INS_RDMSR, + X86_INS_RDPID, + X86_INS_RDPKRU, + X86_INS_RDPMC, + X86_INS_RDRAND, + X86_INS_RDSEED, + X86_INS_RDSSPD, + X86_INS_RDSSPQ, + X86_INS_RDTSC, + X86_INS_RDTSCP, + X86_INS_REPNE, + X86_INS_REP, + X86_INS_RET, + X86_INS_REX64, + X86_INS_ROL, + X86_INS_ROR, + X86_INS_RORX, + X86_INS_ROUNDPD, + X86_INS_ROUNDPS, + X86_INS_ROUNDSD, + X86_INS_ROUNDSS, + X86_INS_RSM, + X86_INS_RSQRTPS, + X86_INS_RSQRTSS, + X86_INS_RSTORSSP, + X86_INS_SAHF, + X86_INS_SAL, + X86_INS_SALC, + X86_INS_SAR, + X86_INS_SARX, + X86_INS_SAVEPREVSSP, + X86_INS_SBB, + X86_INS_SCASB, + X86_INS_SCASD, + X86_INS_SCASQ, + X86_INS_SCASW, + X86_INS_SETAE, + X86_INS_SETA, + X86_INS_SETBE, + X86_INS_SETB, + X86_INS_SETE, + X86_INS_SETGE, + X86_INS_SETG, + X86_INS_SETLE, + X86_INS_SETL, + X86_INS_SETNE, + X86_INS_SETNO, + X86_INS_SETNP, + X86_INS_SETNS, + X86_INS_SETO, + X86_INS_SETP, + X86_INS_SETSSBSY, + X86_INS_SETS, + X86_INS_SFENCE, + X86_INS_SGDT, + X86_INS_SHA1MSG1, + X86_INS_SHA1MSG2, + X86_INS_SHA1NEXTE, + X86_INS_SHA1RNDS4, + X86_INS_SHA256MSG1, + X86_INS_SHA256MSG2, + X86_INS_SHA256RNDS2, + X86_INS_SHL, + X86_INS_SHLD, + X86_INS_SHLX, + X86_INS_SHR, + X86_INS_SHRD, + X86_INS_SHRX, + X86_INS_SHUFPD, + X86_INS_SHUFPS, + X86_INS_SIDT, + X86_INS_FSIN, + X86_INS_SKINIT, + X86_INS_SLDT, + X86_INS_SLWPCB, + X86_INS_SMSW, + X86_INS_SQRTPD, + X86_INS_SQRTPS, + X86_INS_SQRTSD, + X86_INS_SQRTSS, + X86_INS_FSQRT, + X86_INS_STAC, + X86_INS_STC, + X86_INS_STD, + X86_INS_STGI, + X86_INS_STI, + X86_INS_STMXCSR, + X86_INS_STOSB, + X86_INS_STOSD, + X86_INS_STOSQ, + X86_INS_STOSW, + X86_INS_STR, + X86_INS_FST, + X86_INS_FSTP, + X86_INS_SUB, + X86_INS_SUBPD, + X86_INS_SUBPS, + X86_INS_FSUBR, + X86_INS_FISUBR, + X86_INS_FSUBRP, + X86_INS_SUBSD, + X86_INS_SUBSS, + X86_INS_FSUB, + X86_INS_FISUB, + X86_INS_FSUBP, + X86_INS_SWAPGS, + X86_INS_SYSCALL, + X86_INS_SYSENTER, + X86_INS_SYSEXIT, + X86_INS_SYSEXITQ, + X86_INS_SYSRET, + X86_INS_SYSRETQ, + X86_INS_T1MSKC, + X86_INS_TEST, + X86_INS_TPAUSE, + X86_INS_FTST, + X86_INS_TZCNT, + X86_INS_TZMSK, + X86_INS_UCOMISD, + X86_INS_UCOMISS, + X86_INS_FUCOMPI, + X86_INS_FUCOMI, + X86_INS_FUCOMPP, + X86_INS_FUCOMP, + X86_INS_FUCOM, + X86_INS_UD0, + X86_INS_UD1, + X86_INS_UD2, + X86_INS_UMONITOR, + X86_INS_UMWAIT, + X86_INS_UNPCKHPD, + X86_INS_UNPCKHPS, + X86_INS_UNPCKLPD, + X86_INS_UNPCKLPS, + X86_INS_V4FMADDPS, + X86_INS_V4FMADDSS, + X86_INS_V4FNMADDPS, + X86_INS_V4FNMADDSS, + X86_INS_VADDPD, + X86_INS_VADDPS, + X86_INS_VADDSD, + X86_INS_VADDSS, + X86_INS_VADDSUBPD, + X86_INS_VADDSUBPS, + X86_INS_VAESDECLAST, + X86_INS_VAESDEC, + X86_INS_VAESENCLAST, + X86_INS_VAESENC, + X86_INS_VAESIMC, + X86_INS_VAESKEYGENASSIST, + X86_INS_VALIGND, + X86_INS_VALIGNQ, + X86_INS_VANDNPD, + X86_INS_VANDNPS, + X86_INS_VANDPD, + X86_INS_VANDPS, + X86_INS_VBLENDMPD, + X86_INS_VBLENDMPS, + X86_INS_VBLENDPD, + X86_INS_VBLENDPS, + X86_INS_VBLENDVPD, + X86_INS_VBLENDVPS, + X86_INS_VBROADCASTF128, + X86_INS_VBROADCASTF32X2, + X86_INS_VBROADCASTF32X4, + X86_INS_VBROADCASTF32X8, + X86_INS_VBROADCASTF64X2, + X86_INS_VBROADCASTF64X4, + X86_INS_VBROADCASTI128, + X86_INS_VBROADCASTI32X2, + X86_INS_VBROADCASTI32X4, + X86_INS_VBROADCASTI32X8, + X86_INS_VBROADCASTI64X2, + X86_INS_VBROADCASTI64X4, + X86_INS_VBROADCASTSD, + X86_INS_VBROADCASTSS, + X86_INS_VCMP, + X86_INS_VCMPPD, + X86_INS_VCMPPS, + X86_INS_VCMPSD, + X86_INS_VCMPSS, + X86_INS_VCOMISD, + X86_INS_VCOMISS, + X86_INS_VCOMPRESSPD, + X86_INS_VCOMPRESSPS, + X86_INS_VCVTDQ2PD, + X86_INS_VCVTDQ2PS, + X86_INS_VCVTPD2DQ, + X86_INS_VCVTPD2PS, + X86_INS_VCVTPD2QQ, + X86_INS_VCVTPD2UDQ, + X86_INS_VCVTPD2UQQ, + X86_INS_VCVTPH2PS, + X86_INS_VCVTPS2DQ, + X86_INS_VCVTPS2PD, + X86_INS_VCVTPS2PH, + X86_INS_VCVTPS2QQ, + X86_INS_VCVTPS2UDQ, + X86_INS_VCVTPS2UQQ, + X86_INS_VCVTQQ2PD, + X86_INS_VCVTQQ2PS, + X86_INS_VCVTSD2SI, + X86_INS_VCVTSD2SS, + X86_INS_VCVTSD2USI, + X86_INS_VCVTSI2SD, + X86_INS_VCVTSI2SS, + X86_INS_VCVTSS2SD, + X86_INS_VCVTSS2SI, + X86_INS_VCVTSS2USI, + X86_INS_VCVTTPD2DQ, + X86_INS_VCVTTPD2QQ, + X86_INS_VCVTTPD2UDQ, + X86_INS_VCVTTPD2UQQ, + X86_INS_VCVTTPS2DQ, + X86_INS_VCVTTPS2QQ, + X86_INS_VCVTTPS2UDQ, + X86_INS_VCVTTPS2UQQ, + X86_INS_VCVTTSD2SI, + X86_INS_VCVTTSD2USI, + X86_INS_VCVTTSS2SI, + X86_INS_VCVTTSS2USI, + X86_INS_VCVTUDQ2PD, + X86_INS_VCVTUDQ2PS, + X86_INS_VCVTUQQ2PD, + X86_INS_VCVTUQQ2PS, + X86_INS_VCVTUSI2SD, + X86_INS_VCVTUSI2SS, + X86_INS_VDBPSADBW, + X86_INS_VDIVPD, + X86_INS_VDIVPS, + X86_INS_VDIVSD, + X86_INS_VDIVSS, + X86_INS_VDPPD, + X86_INS_VDPPS, + X86_INS_VERR, + X86_INS_VERW, + X86_INS_VEXP2PD, + X86_INS_VEXP2PS, + X86_INS_VEXPANDPD, + X86_INS_VEXPANDPS, + X86_INS_VEXTRACTF128, + X86_INS_VEXTRACTF32X4, + X86_INS_VEXTRACTF32X8, + X86_INS_VEXTRACTF64X2, + X86_INS_VEXTRACTF64X4, + X86_INS_VEXTRACTI128, + X86_INS_VEXTRACTI32X4, + X86_INS_VEXTRACTI32X8, + X86_INS_VEXTRACTI64X2, + X86_INS_VEXTRACTI64X4, + X86_INS_VEXTRACTPS, + X86_INS_VFIXUPIMMPD, + X86_INS_VFIXUPIMMPS, + X86_INS_VFIXUPIMMSD, + X86_INS_VFIXUPIMMSS, + X86_INS_VFMADD132PD, + X86_INS_VFMADD132PS, + X86_INS_VFMADD132SD, + X86_INS_VFMADD132SS, + X86_INS_VFMADD213PD, + X86_INS_VFMADD213PS, + X86_INS_VFMADD213SD, + X86_INS_VFMADD213SS, + X86_INS_VFMADD231PD, + X86_INS_VFMADD231PS, + X86_INS_VFMADD231SD, + X86_INS_VFMADD231SS, + X86_INS_VFMADDPD, + X86_INS_VFMADDPS, + X86_INS_VFMADDSD, + X86_INS_VFMADDSS, + X86_INS_VFMADDSUB132PD, + X86_INS_VFMADDSUB132PS, + X86_INS_VFMADDSUB213PD, + X86_INS_VFMADDSUB213PS, + X86_INS_VFMADDSUB231PD, + X86_INS_VFMADDSUB231PS, + X86_INS_VFMADDSUBPD, + X86_INS_VFMADDSUBPS, + X86_INS_VFMSUB132PD, + X86_INS_VFMSUB132PS, + X86_INS_VFMSUB132SD, + X86_INS_VFMSUB132SS, + X86_INS_VFMSUB213PD, + X86_INS_VFMSUB213PS, + X86_INS_VFMSUB213SD, + X86_INS_VFMSUB213SS, + X86_INS_VFMSUB231PD, + X86_INS_VFMSUB231PS, + X86_INS_VFMSUB231SD, + X86_INS_VFMSUB231SS, + X86_INS_VFMSUBADD132PD, + X86_INS_VFMSUBADD132PS, + X86_INS_VFMSUBADD213PD, + X86_INS_VFMSUBADD213PS, + X86_INS_VFMSUBADD231PD, + X86_INS_VFMSUBADD231PS, + X86_INS_VFMSUBADDPD, + X86_INS_VFMSUBADDPS, + X86_INS_VFMSUBPD, + X86_INS_VFMSUBPS, + X86_INS_VFMSUBSD, + X86_INS_VFMSUBSS, + X86_INS_VFNMADD132PD, + X86_INS_VFNMADD132PS, + X86_INS_VFNMADD132SD, + X86_INS_VFNMADD132SS, + X86_INS_VFNMADD213PD, + X86_INS_VFNMADD213PS, + X86_INS_VFNMADD213SD, + X86_INS_VFNMADD213SS, + X86_INS_VFNMADD231PD, + X86_INS_VFNMADD231PS, + X86_INS_VFNMADD231SD, + X86_INS_VFNMADD231SS, + X86_INS_VFNMADDPD, + X86_INS_VFNMADDPS, + X86_INS_VFNMADDSD, + X86_INS_VFNMADDSS, + X86_INS_VFNMSUB132PD, + X86_INS_VFNMSUB132PS, + X86_INS_VFNMSUB132SD, + X86_INS_VFNMSUB132SS, + X86_INS_VFNMSUB213PD, + X86_INS_VFNMSUB213PS, + X86_INS_VFNMSUB213SD, + X86_INS_VFNMSUB213SS, + X86_INS_VFNMSUB231PD, + X86_INS_VFNMSUB231PS, + X86_INS_VFNMSUB231SD, + X86_INS_VFNMSUB231SS, + X86_INS_VFNMSUBPD, + X86_INS_VFNMSUBPS, + X86_INS_VFNMSUBSD, + X86_INS_VFNMSUBSS, + X86_INS_VFPCLASSPD, + X86_INS_VFPCLASSPS, + X86_INS_VFPCLASSSD, + X86_INS_VFPCLASSSS, + X86_INS_VFRCZPD, + X86_INS_VFRCZPS, + X86_INS_VFRCZSD, + X86_INS_VFRCZSS, + X86_INS_VGATHERDPD, + X86_INS_VGATHERDPS, + X86_INS_VGATHERPF0DPD, + X86_INS_VGATHERPF0DPS, + X86_INS_VGATHERPF0QPD, + X86_INS_VGATHERPF0QPS, + X86_INS_VGATHERPF1DPD, + X86_INS_VGATHERPF1DPS, + X86_INS_VGATHERPF1QPD, + X86_INS_VGATHERPF1QPS, + X86_INS_VGATHERQPD, + X86_INS_VGATHERQPS, + X86_INS_VGETEXPPD, + X86_INS_VGETEXPPS, + X86_INS_VGETEXPSD, + X86_INS_VGETEXPSS, + X86_INS_VGETMANTPD, + X86_INS_VGETMANTPS, + X86_INS_VGETMANTSD, + X86_INS_VGETMANTSS, + X86_INS_VGF2P8AFFINEINVQB, + X86_INS_VGF2P8AFFINEQB, + X86_INS_VGF2P8MULB, + X86_INS_VHADDPD, + X86_INS_VHADDPS, + X86_INS_VHSUBPD, + X86_INS_VHSUBPS, + X86_INS_VINSERTF128, + X86_INS_VINSERTF32X4, + X86_INS_VINSERTF32X8, + X86_INS_VINSERTF64X2, + X86_INS_VINSERTF64X4, + X86_INS_VINSERTI128, + X86_INS_VINSERTI32X4, + X86_INS_VINSERTI32X8, + X86_INS_VINSERTI64X2, + X86_INS_VINSERTI64X4, + X86_INS_VINSERTPS, + X86_INS_VLDDQU, + X86_INS_VLDMXCSR, + X86_INS_VMASKMOVDQU, + X86_INS_VMASKMOVPD, + X86_INS_VMASKMOVPS, + X86_INS_VMAXPD, + X86_INS_VMAXPS, + X86_INS_VMAXSD, + X86_INS_VMAXSS, + X86_INS_VMCALL, + X86_INS_VMCLEAR, + X86_INS_VMFUNC, + X86_INS_VMINPD, + X86_INS_VMINPS, + X86_INS_VMINSD, + X86_INS_VMINSS, + X86_INS_VMLAUNCH, + X86_INS_VMLOAD, + X86_INS_VMMCALL, + X86_INS_VMOVQ, + X86_INS_VMOVAPD, + X86_INS_VMOVAPS, + X86_INS_VMOVDDUP, + X86_INS_VMOVD, + X86_INS_VMOVDQA32, + X86_INS_VMOVDQA64, + X86_INS_VMOVDQA, + X86_INS_VMOVDQU16, + X86_INS_VMOVDQU32, + X86_INS_VMOVDQU64, + X86_INS_VMOVDQU8, + X86_INS_VMOVDQU, + X86_INS_VMOVHLPS, + X86_INS_VMOVHPD, + X86_INS_VMOVHPS, + X86_INS_VMOVLHPS, + X86_INS_VMOVLPD, + X86_INS_VMOVLPS, + X86_INS_VMOVMSKPD, + X86_INS_VMOVMSKPS, + X86_INS_VMOVNTDQA, + X86_INS_VMOVNTDQ, + X86_INS_VMOVNTPD, + X86_INS_VMOVNTPS, + X86_INS_VMOVSD, + X86_INS_VMOVSHDUP, + X86_INS_VMOVSLDUP, + X86_INS_VMOVSS, + X86_INS_VMOVUPD, + X86_INS_VMOVUPS, + X86_INS_VMPSADBW, + X86_INS_VMPTRLD, + X86_INS_VMPTRST, + X86_INS_VMREAD, + X86_INS_VMRESUME, + X86_INS_VMRUN, + X86_INS_VMSAVE, + X86_INS_VMULPD, + X86_INS_VMULPS, + X86_INS_VMULSD, + X86_INS_VMULSS, + X86_INS_VMWRITE, + X86_INS_VMXOFF, + X86_INS_VMXON, + X86_INS_VORPD, + X86_INS_VORPS, + X86_INS_VP4DPWSSDS, + X86_INS_VP4DPWSSD, + X86_INS_VPABSB, + X86_INS_VPABSD, + X86_INS_VPABSQ, + X86_INS_VPABSW, + X86_INS_VPACKSSDW, + X86_INS_VPACKSSWB, + X86_INS_VPACKUSDW, + X86_INS_VPACKUSWB, + X86_INS_VPADDB, + X86_INS_VPADDD, + X86_INS_VPADDQ, + X86_INS_VPADDSB, + X86_INS_VPADDSW, + X86_INS_VPADDUSB, + X86_INS_VPADDUSW, + X86_INS_VPADDW, + X86_INS_VPALIGNR, + X86_INS_VPANDD, + X86_INS_VPANDND, + X86_INS_VPANDNQ, + X86_INS_VPANDN, + X86_INS_VPANDQ, + X86_INS_VPAND, + X86_INS_VPAVGB, + X86_INS_VPAVGW, + X86_INS_VPBLENDD, + X86_INS_VPBLENDMB, + X86_INS_VPBLENDMD, + X86_INS_VPBLENDMQ, + X86_INS_VPBLENDMW, + X86_INS_VPBLENDVB, + X86_INS_VPBLENDW, + X86_INS_VPBROADCASTB, + X86_INS_VPBROADCASTD, + X86_INS_VPBROADCASTMB2Q, + X86_INS_VPBROADCASTMW2D, + X86_INS_VPBROADCASTQ, + X86_INS_VPBROADCASTW, + X86_INS_VPCLMULQDQ, + X86_INS_VPCMOV, + X86_INS_VPCMP, + X86_INS_VPCMPB, + X86_INS_VPCMPD, + X86_INS_VPCMPEQB, + X86_INS_VPCMPEQD, + X86_INS_VPCMPEQQ, + X86_INS_VPCMPEQW, + X86_INS_VPCMPESTRI, + X86_INS_VPCMPESTRM, + X86_INS_VPCMPGTB, + X86_INS_VPCMPGTD, + X86_INS_VPCMPGTQ, + X86_INS_VPCMPGTW, + X86_INS_VPCMPISTRI, + X86_INS_VPCMPISTRM, + X86_INS_VPCMPQ, + X86_INS_VPCMPUB, + X86_INS_VPCMPUD, + X86_INS_VPCMPUQ, + X86_INS_VPCMPUW, + X86_INS_VPCMPW, + X86_INS_VPCOM, + X86_INS_VPCOMB, + X86_INS_VPCOMD, + X86_INS_VPCOMPRESSB, + X86_INS_VPCOMPRESSD, + X86_INS_VPCOMPRESSQ, + X86_INS_VPCOMPRESSW, + X86_INS_VPCOMQ, + X86_INS_VPCOMUB, + X86_INS_VPCOMUD, + X86_INS_VPCOMUQ, + X86_INS_VPCOMUW, + X86_INS_VPCOMW, + X86_INS_VPCONFLICTD, + X86_INS_VPCONFLICTQ, + X86_INS_VPDPBUSDS, + X86_INS_VPDPBUSD, + X86_INS_VPDPWSSDS, + X86_INS_VPDPWSSD, + X86_INS_VPERM2F128, + X86_INS_VPERM2I128, + X86_INS_VPERMB, + X86_INS_VPERMD, + X86_INS_VPERMI2B, + X86_INS_VPERMI2D, + X86_INS_VPERMI2PD, + X86_INS_VPERMI2PS, + X86_INS_VPERMI2Q, + X86_INS_VPERMI2W, + X86_INS_VPERMIL2PD, + X86_INS_VPERMILPD, + X86_INS_VPERMIL2PS, + X86_INS_VPERMILPS, + X86_INS_VPERMPD, + X86_INS_VPERMPS, + X86_INS_VPERMQ, + X86_INS_VPERMT2B, + X86_INS_VPERMT2D, + X86_INS_VPERMT2PD, + X86_INS_VPERMT2PS, + X86_INS_VPERMT2Q, + X86_INS_VPERMT2W, + X86_INS_VPERMW, + X86_INS_VPEXPANDB, + X86_INS_VPEXPANDD, + X86_INS_VPEXPANDQ, + X86_INS_VPEXPANDW, + X86_INS_VPEXTRB, + X86_INS_VPEXTRD, + X86_INS_VPEXTRQ, + X86_INS_VPEXTRW, + X86_INS_VPGATHERDD, + X86_INS_VPGATHERDQ, + X86_INS_VPGATHERQD, + X86_INS_VPGATHERQQ, + X86_INS_VPHADDBD, + X86_INS_VPHADDBQ, + X86_INS_VPHADDBW, + X86_INS_VPHADDDQ, + X86_INS_VPHADDD, + X86_INS_VPHADDSW, + X86_INS_VPHADDUBD, + X86_INS_VPHADDUBQ, + X86_INS_VPHADDUBW, + X86_INS_VPHADDUDQ, + X86_INS_VPHADDUWD, + X86_INS_VPHADDUWQ, + X86_INS_VPHADDWD, + X86_INS_VPHADDWQ, + X86_INS_VPHADDW, + X86_INS_VPHMINPOSUW, + X86_INS_VPHSUBBW, + X86_INS_VPHSUBDQ, + X86_INS_VPHSUBD, + X86_INS_VPHSUBSW, + X86_INS_VPHSUBWD, + X86_INS_VPHSUBW, + X86_INS_VPINSRB, + X86_INS_VPINSRD, + X86_INS_VPINSRQ, + X86_INS_VPINSRW, + X86_INS_VPLZCNTD, + X86_INS_VPLZCNTQ, + X86_INS_VPMACSDD, + X86_INS_VPMACSDQH, + X86_INS_VPMACSDQL, + X86_INS_VPMACSSDD, + X86_INS_VPMACSSDQH, + X86_INS_VPMACSSDQL, + X86_INS_VPMACSSWD, + X86_INS_VPMACSSWW, + X86_INS_VPMACSWD, + X86_INS_VPMACSWW, + X86_INS_VPMADCSSWD, + X86_INS_VPMADCSWD, + X86_INS_VPMADD52HUQ, + X86_INS_VPMADD52LUQ, + X86_INS_VPMADDUBSW, + X86_INS_VPMADDWD, + X86_INS_VPMASKMOVD, + X86_INS_VPMASKMOVQ, + X86_INS_VPMAXSB, + X86_INS_VPMAXSD, + X86_INS_VPMAXSQ, + X86_INS_VPMAXSW, + X86_INS_VPMAXUB, + X86_INS_VPMAXUD, + X86_INS_VPMAXUQ, + X86_INS_VPMAXUW, + X86_INS_VPMINSB, + X86_INS_VPMINSD, + X86_INS_VPMINSQ, + X86_INS_VPMINSW, + X86_INS_VPMINUB, + X86_INS_VPMINUD, + X86_INS_VPMINUQ, + X86_INS_VPMINUW, + X86_INS_VPMOVB2M, + X86_INS_VPMOVD2M, + X86_INS_VPMOVDB, + X86_INS_VPMOVDW, + X86_INS_VPMOVM2B, + X86_INS_VPMOVM2D, + X86_INS_VPMOVM2Q, + X86_INS_VPMOVM2W, + X86_INS_VPMOVMSKB, + X86_INS_VPMOVQ2M, + X86_INS_VPMOVQB, + X86_INS_VPMOVQD, + X86_INS_VPMOVQW, + X86_INS_VPMOVSDB, + X86_INS_VPMOVSDW, + X86_INS_VPMOVSQB, + X86_INS_VPMOVSQD, + X86_INS_VPMOVSQW, + X86_INS_VPMOVSWB, + X86_INS_VPMOVSXBD, + X86_INS_VPMOVSXBQ, + X86_INS_VPMOVSXBW, + X86_INS_VPMOVSXDQ, + X86_INS_VPMOVSXWD, + X86_INS_VPMOVSXWQ, + X86_INS_VPMOVUSDB, + X86_INS_VPMOVUSDW, + X86_INS_VPMOVUSQB, + X86_INS_VPMOVUSQD, + X86_INS_VPMOVUSQW, + X86_INS_VPMOVUSWB, + X86_INS_VPMOVW2M, + X86_INS_VPMOVWB, + X86_INS_VPMOVZXBD, + X86_INS_VPMOVZXBQ, + X86_INS_VPMOVZXBW, + X86_INS_VPMOVZXDQ, + X86_INS_VPMOVZXWD, + X86_INS_VPMOVZXWQ, + X86_INS_VPMULDQ, + X86_INS_VPMULHRSW, + X86_INS_VPMULHUW, + X86_INS_VPMULHW, + X86_INS_VPMULLD, + X86_INS_VPMULLQ, + X86_INS_VPMULLW, + X86_INS_VPMULTISHIFTQB, + X86_INS_VPMULUDQ, + X86_INS_VPOPCNTB, + X86_INS_VPOPCNTD, + X86_INS_VPOPCNTQ, + X86_INS_VPOPCNTW, + X86_INS_VPORD, + X86_INS_VPORQ, + X86_INS_VPOR, + X86_INS_VPPERM, + X86_INS_VPROLD, + X86_INS_VPROLQ, + X86_INS_VPROLVD, + X86_INS_VPROLVQ, + X86_INS_VPRORD, + X86_INS_VPRORQ, + X86_INS_VPRORVD, + X86_INS_VPRORVQ, + X86_INS_VPROTB, + X86_INS_VPROTD, + X86_INS_VPROTQ, + X86_INS_VPROTW, + X86_INS_VPSADBW, + X86_INS_VPSCATTERDD, + X86_INS_VPSCATTERDQ, + X86_INS_VPSCATTERQD, + X86_INS_VPSCATTERQQ, + X86_INS_VPSHAB, + X86_INS_VPSHAD, + X86_INS_VPSHAQ, + X86_INS_VPSHAW, + X86_INS_VPSHLB, + X86_INS_VPSHLDD, + X86_INS_VPSHLDQ, + X86_INS_VPSHLDVD, + X86_INS_VPSHLDVQ, + X86_INS_VPSHLDVW, + X86_INS_VPSHLDW, + X86_INS_VPSHLD, + X86_INS_VPSHLQ, + X86_INS_VPSHLW, + X86_INS_VPSHRDD, + X86_INS_VPSHRDQ, + X86_INS_VPSHRDVD, + X86_INS_VPSHRDVQ, + X86_INS_VPSHRDVW, + X86_INS_VPSHRDW, + X86_INS_VPSHUFBITQMB, + X86_INS_VPSHUFB, + X86_INS_VPSHUFD, + X86_INS_VPSHUFHW, + X86_INS_VPSHUFLW, + X86_INS_VPSIGNB, + X86_INS_VPSIGND, + X86_INS_VPSIGNW, + X86_INS_VPSLLDQ, + X86_INS_VPSLLD, + X86_INS_VPSLLQ, + X86_INS_VPSLLVD, + X86_INS_VPSLLVQ, + X86_INS_VPSLLVW, + X86_INS_VPSLLW, + X86_INS_VPSRAD, + X86_INS_VPSRAQ, + X86_INS_VPSRAVD, + X86_INS_VPSRAVQ, + X86_INS_VPSRAVW, + X86_INS_VPSRAW, + X86_INS_VPSRLDQ, + X86_INS_VPSRLD, + X86_INS_VPSRLQ, + X86_INS_VPSRLVD, + X86_INS_VPSRLVQ, + X86_INS_VPSRLVW, + X86_INS_VPSRLW, + X86_INS_VPSUBB, + X86_INS_VPSUBD, + X86_INS_VPSUBQ, + X86_INS_VPSUBSB, + X86_INS_VPSUBSW, + X86_INS_VPSUBUSB, + X86_INS_VPSUBUSW, + X86_INS_VPSUBW, + X86_INS_VPTERNLOGD, + X86_INS_VPTERNLOGQ, + X86_INS_VPTESTMB, + X86_INS_VPTESTMD, + X86_INS_VPTESTMQ, + X86_INS_VPTESTMW, + X86_INS_VPTESTNMB, + X86_INS_VPTESTNMD, + X86_INS_VPTESTNMQ, + X86_INS_VPTESTNMW, + X86_INS_VPTEST, + X86_INS_VPUNPCKHBW, + X86_INS_VPUNPCKHDQ, + X86_INS_VPUNPCKHQDQ, + X86_INS_VPUNPCKHWD, + X86_INS_VPUNPCKLBW, + X86_INS_VPUNPCKLDQ, + X86_INS_VPUNPCKLQDQ, + X86_INS_VPUNPCKLWD, + X86_INS_VPXORD, + X86_INS_VPXORQ, + X86_INS_VPXOR, + X86_INS_VRANGEPD, + X86_INS_VRANGEPS, + X86_INS_VRANGESD, + X86_INS_VRANGESS, + X86_INS_VRCP14PD, + X86_INS_VRCP14PS, + X86_INS_VRCP14SD, + X86_INS_VRCP14SS, + X86_INS_VRCP28PD, + X86_INS_VRCP28PS, + X86_INS_VRCP28SD, + X86_INS_VRCP28SS, + X86_INS_VRCPPS, + X86_INS_VRCPSS, + X86_INS_VREDUCEPD, + X86_INS_VREDUCEPS, + X86_INS_VREDUCESD, + X86_INS_VREDUCESS, + X86_INS_VRNDSCALEPD, + X86_INS_VRNDSCALEPS, + X86_INS_VRNDSCALESD, + X86_INS_VRNDSCALESS, + X86_INS_VROUNDPD, + X86_INS_VROUNDPS, + X86_INS_VROUNDSD, + X86_INS_VROUNDSS, + X86_INS_VRSQRT14PD, + X86_INS_VRSQRT14PS, + X86_INS_VRSQRT14SD, + X86_INS_VRSQRT14SS, + X86_INS_VRSQRT28PD, + X86_INS_VRSQRT28PS, + X86_INS_VRSQRT28SD, + X86_INS_VRSQRT28SS, + X86_INS_VRSQRTPS, + X86_INS_VRSQRTSS, + X86_INS_VSCALEFPD, + X86_INS_VSCALEFPS, + X86_INS_VSCALEFSD, + X86_INS_VSCALEFSS, + X86_INS_VSCATTERDPD, + X86_INS_VSCATTERDPS, + X86_INS_VSCATTERPF0DPD, + X86_INS_VSCATTERPF0DPS, + X86_INS_VSCATTERPF0QPD, + X86_INS_VSCATTERPF0QPS, + X86_INS_VSCATTERPF1DPD, + X86_INS_VSCATTERPF1DPS, + X86_INS_VSCATTERPF1QPD, + X86_INS_VSCATTERPF1QPS, + X86_INS_VSCATTERQPD, + X86_INS_VSCATTERQPS, + X86_INS_VSHUFF32X4, + X86_INS_VSHUFF64X2, + X86_INS_VSHUFI32X4, + X86_INS_VSHUFI64X2, + X86_INS_VSHUFPD, + X86_INS_VSHUFPS, + X86_INS_VSQRTPD, + X86_INS_VSQRTPS, + X86_INS_VSQRTSD, + X86_INS_VSQRTSS, + X86_INS_VSTMXCSR, + X86_INS_VSUBPD, + X86_INS_VSUBPS, + X86_INS_VSUBSD, + X86_INS_VSUBSS, + X86_INS_VTESTPD, + X86_INS_VTESTPS, + X86_INS_VUCOMISD, + X86_INS_VUCOMISS, + X86_INS_VUNPCKHPD, + X86_INS_VUNPCKHPS, + X86_INS_VUNPCKLPD, + X86_INS_VUNPCKLPS, + X86_INS_VXORPD, + X86_INS_VXORPS, + X86_INS_VZEROALL, + X86_INS_VZEROUPPER, + X86_INS_WAIT, + X86_INS_WBINVD, + X86_INS_WBNOINVD, + X86_INS_WRFSBASE, + X86_INS_WRGSBASE, + X86_INS_WRMSR, + X86_INS_WRPKRU, + X86_INS_WRSSD, + X86_INS_WRSSQ, + X86_INS_WRUSSD, + X86_INS_WRUSSQ, + X86_INS_XABORT, + X86_INS_XACQUIRE, + X86_INS_XADD, + X86_INS_XBEGIN, + X86_INS_XCHG, + X86_INS_FXCH, + X86_INS_XCRYPTCBC, + X86_INS_XCRYPTCFB, + X86_INS_XCRYPTCTR, + X86_INS_XCRYPTECB, + X86_INS_XCRYPTOFB, + X86_INS_XEND, + X86_INS_XGETBV, + X86_INS_XLATB, + X86_INS_XOR, + X86_INS_XORPD, + X86_INS_XORPS, + X86_INS_XRELEASE, + X86_INS_XRSTOR, + X86_INS_XRSTOR64, + X86_INS_XRSTORS, + X86_INS_XRSTORS64, + X86_INS_XSAVE, + X86_INS_XSAVE64, + X86_INS_XSAVEC, + X86_INS_XSAVEC64, + X86_INS_XSAVEOPT, + X86_INS_XSAVEOPT64, + X86_INS_XSAVES, + X86_INS_XSAVES64, + X86_INS_XSETBV, + X86_INS_XSHA1, + X86_INS_XSHA256, + X86_INS_XSTORE, + X86_INS_XTEST, + + X86_INS_ENDING, // mark the end of the list of insn +} x86_insn; + +/// Group of X86 instructions +typedef enum x86_insn_group { + X86_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + // Generic groups + // all jump instructions (conditional+direct+indirect jumps) + X86_GRP_JUMP, ///< = CS_GRP_JUMP + // all call instructions + X86_GRP_CALL, ///< = CS_GRP_CALL + // all return instructions + X86_GRP_RET, ///< = CS_GRP_RET + // all interrupt instructions (int+syscall) + X86_GRP_INT, ///< = CS_GRP_INT + // all interrupt return instructions + X86_GRP_IRET, ///< = CS_GRP_IRET + // all privileged instructions + X86_GRP_PRIVILEGE, ///< = CS_GRP_PRIVILEGE + // all relative branching instructions + X86_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE + + // Architecture-specific groups + X86_GRP_VM = 128, ///< all virtualization instructions (VT-x + AMD-V) + X86_GRP_3DNOW, + X86_GRP_AES, + X86_GRP_ADX, + X86_GRP_AVX, + X86_GRP_AVX2, + X86_GRP_AVX512, + X86_GRP_BMI, + X86_GRP_BMI2, + X86_GRP_CMOV, + X86_GRP_F16C, + X86_GRP_FMA, + X86_GRP_FMA4, + X86_GRP_FSGSBASE, + X86_GRP_HLE, + X86_GRP_MMX, + X86_GRP_MODE32, + X86_GRP_MODE64, + X86_GRP_RTM, + X86_GRP_SHA, + X86_GRP_SSE1, + X86_GRP_SSE2, + X86_GRP_SSE3, + X86_GRP_SSE41, + X86_GRP_SSE42, + X86_GRP_SSE4A, + X86_GRP_SSSE3, + X86_GRP_PCLMUL, + X86_GRP_XOP, + X86_GRP_CDI, + X86_GRP_ERI, + X86_GRP_TBM, + X86_GRP_16BITMODE, + X86_GRP_NOT64BITMODE, + X86_GRP_SGX, + X86_GRP_DQI, + X86_GRP_BWI, + X86_GRP_PFI, + X86_GRP_VLX, + X86_GRP_SMAP, + X86_GRP_NOVLX, + X86_GRP_FPU, + + X86_GRP_ENDING +} x86_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_XCORE_H +#define CAPSTONE_XCORE_H + +/* Capstone Disassembly Engine */ +/* By Nguyen Anh Quynh , 2014-2015 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// Operand type for instruction's operands +typedef enum xcore_op_type { + XCORE_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + XCORE_OP_REG, ///< = CS_OP_REG (Register operand). + XCORE_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + XCORE_OP_MEM, ///< = CS_OP_MEM (Memory operand). +} xcore_op_type; + +/// XCore registers +typedef enum xcore_reg { + XCORE_REG_INVALID = 0, + + XCORE_REG_CP, + XCORE_REG_DP, + XCORE_REG_LR, + XCORE_REG_SP, + XCORE_REG_R0, + XCORE_REG_R1, + XCORE_REG_R2, + XCORE_REG_R3, + XCORE_REG_R4, + XCORE_REG_R5, + XCORE_REG_R6, + XCORE_REG_R7, + XCORE_REG_R8, + XCORE_REG_R9, + XCORE_REG_R10, + XCORE_REG_R11, + + // pseudo registers + XCORE_REG_PC, ///< pc + + // internal thread registers + // see The-XMOS-XS1-Architecture(X7879A).pdf + XCORE_REG_SCP, ///< save pc + XCORE_REG_SSR, //< save status + XCORE_REG_ET, //< exception type + XCORE_REG_ED, //< exception data + XCORE_REG_SED, //< save exception data + XCORE_REG_KEP, //< kernel entry pointer + XCORE_REG_KSP, //< kernel stack pointer + XCORE_REG_ID, //< thread ID + + XCORE_REG_ENDING, // <-- mark the end of the list of registers +} xcore_reg; + +/// Instruction's operand referring to memory +/// This is associated with XCORE_OP_MEM operand type above +typedef struct xcore_op_mem { + uint8_t base; ///< base register, can be safely interpreted as + ///< a value of type `xcore_reg`, but it is only + ///< one byte wide + uint8_t index; ///< index register, same conditions apply here + int32_t disp; ///< displacement/offset value + int direct; ///< +1: forward, -1: backward +} xcore_op_mem; + +/// Instruction operand +typedef struct cs_xcore_op { + xcore_op_type type; ///< operand type + union { + xcore_reg reg; ///< register value for REG operand + int32_t imm; ///< immediate value for IMM operand + xcore_op_mem mem; ///< base/disp value for MEM operand + }; +} cs_xcore_op; + +/// Instruction structure +typedef struct cs_xcore { + /// Number of operands of this instruction, + /// or 0 when instruction has no operand. + uint8_t op_count; + cs_xcore_op operands[8]; ///< operands for this instruction. +} cs_xcore; + +/// XCore instruction +typedef enum xcore_insn { + XCORE_INS_INVALID = 0, + + XCORE_INS_ADD, + XCORE_INS_ANDNOT, + XCORE_INS_AND, + XCORE_INS_ASHR, + XCORE_INS_BAU, + XCORE_INS_BITREV, + XCORE_INS_BLA, + XCORE_INS_BLAT, + XCORE_INS_BL, + XCORE_INS_BF, + XCORE_INS_BT, + XCORE_INS_BU, + XCORE_INS_BRU, + XCORE_INS_BYTEREV, + XCORE_INS_CHKCT, + XCORE_INS_CLRE, + XCORE_INS_CLRPT, + XCORE_INS_CLRSR, + XCORE_INS_CLZ, + XCORE_INS_CRC8, + XCORE_INS_CRC32, + XCORE_INS_DCALL, + XCORE_INS_DENTSP, + XCORE_INS_DGETREG, + XCORE_INS_DIVS, + XCORE_INS_DIVU, + XCORE_INS_DRESTSP, + XCORE_INS_DRET, + XCORE_INS_ECALLF, + XCORE_INS_ECALLT, + XCORE_INS_EDU, + XCORE_INS_EEF, + XCORE_INS_EET, + XCORE_INS_EEU, + XCORE_INS_ENDIN, + XCORE_INS_ENTSP, + XCORE_INS_EQ, + XCORE_INS_EXTDP, + XCORE_INS_EXTSP, + XCORE_INS_FREER, + XCORE_INS_FREET, + XCORE_INS_GETD, + XCORE_INS_GET, + XCORE_INS_GETN, + XCORE_INS_GETR, + XCORE_INS_GETSR, + XCORE_INS_GETST, + XCORE_INS_GETTS, + XCORE_INS_INCT, + XCORE_INS_INIT, + XCORE_INS_INPW, + XCORE_INS_INSHR, + XCORE_INS_INT, + XCORE_INS_IN, + XCORE_INS_KCALL, + XCORE_INS_KENTSP, + XCORE_INS_KRESTSP, + XCORE_INS_KRET, + XCORE_INS_LADD, + XCORE_INS_LD16S, + XCORE_INS_LD8U, + XCORE_INS_LDA16, + XCORE_INS_LDAP, + XCORE_INS_LDAW, + XCORE_INS_LDC, + XCORE_INS_LDW, + XCORE_INS_LDIVU, + XCORE_INS_LMUL, + XCORE_INS_LSS, + XCORE_INS_LSUB, + XCORE_INS_LSU, + XCORE_INS_MACCS, + XCORE_INS_MACCU, + XCORE_INS_MJOIN, + XCORE_INS_MKMSK, + XCORE_INS_MSYNC, + XCORE_INS_MUL, + XCORE_INS_NEG, + XCORE_INS_NOT, + XCORE_INS_OR, + XCORE_INS_OUTCT, + XCORE_INS_OUTPW, + XCORE_INS_OUTSHR, + XCORE_INS_OUTT, + XCORE_INS_OUT, + XCORE_INS_PEEK, + XCORE_INS_REMS, + XCORE_INS_REMU, + XCORE_INS_RETSP, + XCORE_INS_SETCLK, + XCORE_INS_SET, + XCORE_INS_SETC, + XCORE_INS_SETD, + XCORE_INS_SETEV, + XCORE_INS_SETN, + XCORE_INS_SETPSC, + XCORE_INS_SETPT, + XCORE_INS_SETRDY, + XCORE_INS_SETSR, + XCORE_INS_SETTW, + XCORE_INS_SETV, + XCORE_INS_SEXT, + XCORE_INS_SHL, + XCORE_INS_SHR, + XCORE_INS_SSYNC, + XCORE_INS_ST16, + XCORE_INS_ST8, + XCORE_INS_STW, + XCORE_INS_SUB, + XCORE_INS_SYNCR, + XCORE_INS_TESTCT, + XCORE_INS_TESTLCL, + XCORE_INS_TESTWCT, + XCORE_INS_TSETMR, + XCORE_INS_START, + XCORE_INS_WAITEF, + XCORE_INS_WAITET, + XCORE_INS_WAITEU, + XCORE_INS_XOR, + XCORE_INS_ZEXT, + + XCORE_INS_ENDING, // <-- mark the end of the list of instructions +} xcore_insn; + +/// Group of XCore instructions +typedef enum xcore_insn_group { + XCORE_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + // Generic groups + // all jump instructions (conditional+direct+indirect jumps) + XCORE_GRP_JUMP, ///< = CS_GRP_JUMP + + XCORE_GRP_ENDING, // <-- mark the end of the list of groups +} xcore_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +/* Capstone Disassembly Engine */ +/* TMS320C64x Backend by Fotis Loukos 2016 */ + +#ifndef CAPSTONE_TMS320C64X_H +#define CAPSTONE_TMS320C64X_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +typedef enum tms320c64x_op_type { + TMS320C64X_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + TMS320C64X_OP_REG, ///< = CS_OP_REG (Register operand). + TMS320C64X_OP_IMM, ///< = CS_OP_IMM (Immediate operand). + TMS320C64X_OP_MEM, ///< = CS_OP_MEM (Memory operand). + TMS320C64X_OP_REGPAIR = 64, ///< Register pair for double word ops +} tms320c64x_op_type; + +typedef enum tms320c64x_mem_disp { + TMS320C64X_MEM_DISP_INVALID = 0, + TMS320C64X_MEM_DISP_CONSTANT, + TMS320C64X_MEM_DISP_REGISTER, +} tms320c64x_mem_disp; + +typedef enum tms320c64x_mem_dir { + TMS320C64X_MEM_DIR_INVALID = 0, + TMS320C64X_MEM_DIR_FW, + TMS320C64X_MEM_DIR_BW, +} tms320c64x_mem_dir; + +typedef enum tms320c64x_mem_mod { + TMS320C64X_MEM_MOD_INVALID = 0, + TMS320C64X_MEM_MOD_NO, + TMS320C64X_MEM_MOD_PRE, + TMS320C64X_MEM_MOD_POST, +} tms320c64x_mem_mod; + +typedef struct tms320c64x_op_mem { + unsigned int base; ///< base register + unsigned int disp; ///< displacement/offset value + unsigned int unit; ///< unit of base and offset register + unsigned int scaled; ///< offset scaled + unsigned int disptype; ///< displacement type + unsigned int direction; ///< direction + unsigned int modify; ///< modification +} tms320c64x_op_mem; + +typedef struct cs_tms320c64x_op { + tms320c64x_op_type type; ///< operand type + union { + unsigned int reg; ///< register value for REG operand or first register for REGPAIR operand + int32_t imm; ///< immediate value for IMM operand + tms320c64x_op_mem mem; ///< base/disp value for MEM operand + }; +} cs_tms320c64x_op; + +typedef struct cs_tms320c64x { + uint8_t op_count; + cs_tms320c64x_op operands[8]; ///< operands for this instruction. + struct { + unsigned int reg; + unsigned int zero; + } condition; + struct { + unsigned int unit; + unsigned int side; + unsigned int crosspath; + } funit; + unsigned int parallel; +} cs_tms320c64x; + +typedef enum tms320c64x_reg { + TMS320C64X_REG_INVALID = 0, + + TMS320C64X_REG_AMR, + TMS320C64X_REG_CSR, + TMS320C64X_REG_DIER, + TMS320C64X_REG_DNUM, + TMS320C64X_REG_ECR, + TMS320C64X_REG_GFPGFR, + TMS320C64X_REG_GPLYA, + TMS320C64X_REG_GPLYB, + TMS320C64X_REG_ICR, + TMS320C64X_REG_IER, + TMS320C64X_REG_IERR, + TMS320C64X_REG_ILC, + TMS320C64X_REG_IRP, + TMS320C64X_REG_ISR, + TMS320C64X_REG_ISTP, + TMS320C64X_REG_ITSR, + TMS320C64X_REG_NRP, + TMS320C64X_REG_NTSR, + TMS320C64X_REG_REP, + TMS320C64X_REG_RILC, + TMS320C64X_REG_SSR, + TMS320C64X_REG_TSCH, + TMS320C64X_REG_TSCL, + TMS320C64X_REG_TSR, + TMS320C64X_REG_A0, + TMS320C64X_REG_A1, + TMS320C64X_REG_A2, + TMS320C64X_REG_A3, + TMS320C64X_REG_A4, + TMS320C64X_REG_A5, + TMS320C64X_REG_A6, + TMS320C64X_REG_A7, + TMS320C64X_REG_A8, + TMS320C64X_REG_A9, + TMS320C64X_REG_A10, + TMS320C64X_REG_A11, + TMS320C64X_REG_A12, + TMS320C64X_REG_A13, + TMS320C64X_REG_A14, + TMS320C64X_REG_A15, + TMS320C64X_REG_A16, + TMS320C64X_REG_A17, + TMS320C64X_REG_A18, + TMS320C64X_REG_A19, + TMS320C64X_REG_A20, + TMS320C64X_REG_A21, + TMS320C64X_REG_A22, + TMS320C64X_REG_A23, + TMS320C64X_REG_A24, + TMS320C64X_REG_A25, + TMS320C64X_REG_A26, + TMS320C64X_REG_A27, + TMS320C64X_REG_A28, + TMS320C64X_REG_A29, + TMS320C64X_REG_A30, + TMS320C64X_REG_A31, + TMS320C64X_REG_B0, + TMS320C64X_REG_B1, + TMS320C64X_REG_B2, + TMS320C64X_REG_B3, + TMS320C64X_REG_B4, + TMS320C64X_REG_B5, + TMS320C64X_REG_B6, + TMS320C64X_REG_B7, + TMS320C64X_REG_B8, + TMS320C64X_REG_B9, + TMS320C64X_REG_B10, + TMS320C64X_REG_B11, + TMS320C64X_REG_B12, + TMS320C64X_REG_B13, + TMS320C64X_REG_B14, + TMS320C64X_REG_B15, + TMS320C64X_REG_B16, + TMS320C64X_REG_B17, + TMS320C64X_REG_B18, + TMS320C64X_REG_B19, + TMS320C64X_REG_B20, + TMS320C64X_REG_B21, + TMS320C64X_REG_B22, + TMS320C64X_REG_B23, + TMS320C64X_REG_B24, + TMS320C64X_REG_B25, + TMS320C64X_REG_B26, + TMS320C64X_REG_B27, + TMS320C64X_REG_B28, + TMS320C64X_REG_B29, + TMS320C64X_REG_B30, + TMS320C64X_REG_B31, + TMS320C64X_REG_PCE1, + + TMS320C64X_REG_ENDING, // <-- mark the end of the list of registers + + // Alias registers + TMS320C64X_REG_EFR = TMS320C64X_REG_ECR, + TMS320C64X_REG_IFR = TMS320C64X_REG_ISR, +} tms320c64x_reg; + +typedef enum tms320c64x_insn { + TMS320C64X_INS_INVALID = 0, + + TMS320C64X_INS_ABS, + TMS320C64X_INS_ABS2, + TMS320C64X_INS_ADD, + TMS320C64X_INS_ADD2, + TMS320C64X_INS_ADD4, + TMS320C64X_INS_ADDAB, + TMS320C64X_INS_ADDAD, + TMS320C64X_INS_ADDAH, + TMS320C64X_INS_ADDAW, + TMS320C64X_INS_ADDK, + TMS320C64X_INS_ADDKPC, + TMS320C64X_INS_ADDU, + TMS320C64X_INS_AND, + TMS320C64X_INS_ANDN, + TMS320C64X_INS_AVG2, + TMS320C64X_INS_AVGU4, + TMS320C64X_INS_B, + TMS320C64X_INS_BDEC, + TMS320C64X_INS_BITC4, + TMS320C64X_INS_BNOP, + TMS320C64X_INS_BPOS, + TMS320C64X_INS_CLR, + TMS320C64X_INS_CMPEQ, + TMS320C64X_INS_CMPEQ2, + TMS320C64X_INS_CMPEQ4, + TMS320C64X_INS_CMPGT, + TMS320C64X_INS_CMPGT2, + TMS320C64X_INS_CMPGTU4, + TMS320C64X_INS_CMPLT, + TMS320C64X_INS_CMPLTU, + TMS320C64X_INS_DEAL, + TMS320C64X_INS_DOTP2, + TMS320C64X_INS_DOTPN2, + TMS320C64X_INS_DOTPNRSU2, + TMS320C64X_INS_DOTPRSU2, + TMS320C64X_INS_DOTPSU4, + TMS320C64X_INS_DOTPU4, + TMS320C64X_INS_EXT, + TMS320C64X_INS_EXTU, + TMS320C64X_INS_GMPGTU, + TMS320C64X_INS_GMPY4, + TMS320C64X_INS_LDB, + TMS320C64X_INS_LDBU, + TMS320C64X_INS_LDDW, + TMS320C64X_INS_LDH, + TMS320C64X_INS_LDHU, + TMS320C64X_INS_LDNDW, + TMS320C64X_INS_LDNW, + TMS320C64X_INS_LDW, + TMS320C64X_INS_LMBD, + TMS320C64X_INS_MAX2, + TMS320C64X_INS_MAXU4, + TMS320C64X_INS_MIN2, + TMS320C64X_INS_MINU4, + TMS320C64X_INS_MPY, + TMS320C64X_INS_MPY2, + TMS320C64X_INS_MPYH, + TMS320C64X_INS_MPYHI, + TMS320C64X_INS_MPYHIR, + TMS320C64X_INS_MPYHL, + TMS320C64X_INS_MPYHLU, + TMS320C64X_INS_MPYHSLU, + TMS320C64X_INS_MPYHSU, + TMS320C64X_INS_MPYHU, + TMS320C64X_INS_MPYHULS, + TMS320C64X_INS_MPYHUS, + TMS320C64X_INS_MPYLH, + TMS320C64X_INS_MPYLHU, + TMS320C64X_INS_MPYLI, + TMS320C64X_INS_MPYLIR, + TMS320C64X_INS_MPYLSHU, + TMS320C64X_INS_MPYLUHS, + TMS320C64X_INS_MPYSU, + TMS320C64X_INS_MPYSU4, + TMS320C64X_INS_MPYU, + TMS320C64X_INS_MPYU4, + TMS320C64X_INS_MPYUS, + TMS320C64X_INS_MVC, + TMS320C64X_INS_MVD, + TMS320C64X_INS_MVK, + TMS320C64X_INS_MVKL, + TMS320C64X_INS_MVKLH, + TMS320C64X_INS_NOP, + TMS320C64X_INS_NORM, + TMS320C64X_INS_OR, + TMS320C64X_INS_PACK2, + TMS320C64X_INS_PACKH2, + TMS320C64X_INS_PACKH4, + TMS320C64X_INS_PACKHL2, + TMS320C64X_INS_PACKL4, + TMS320C64X_INS_PACKLH2, + TMS320C64X_INS_ROTL, + TMS320C64X_INS_SADD, + TMS320C64X_INS_SADD2, + TMS320C64X_INS_SADDU4, + TMS320C64X_INS_SADDUS2, + TMS320C64X_INS_SAT, + TMS320C64X_INS_SET, + TMS320C64X_INS_SHFL, + TMS320C64X_INS_SHL, + TMS320C64X_INS_SHLMB, + TMS320C64X_INS_SHR, + TMS320C64X_INS_SHR2, + TMS320C64X_INS_SHRMB, + TMS320C64X_INS_SHRU, + TMS320C64X_INS_SHRU2, + TMS320C64X_INS_SMPY, + TMS320C64X_INS_SMPY2, + TMS320C64X_INS_SMPYH, + TMS320C64X_INS_SMPYHL, + TMS320C64X_INS_SMPYLH, + TMS320C64X_INS_SPACK2, + TMS320C64X_INS_SPACKU4, + TMS320C64X_INS_SSHL, + TMS320C64X_INS_SSHVL, + TMS320C64X_INS_SSHVR, + TMS320C64X_INS_SSUB, + TMS320C64X_INS_STB, + TMS320C64X_INS_STDW, + TMS320C64X_INS_STH, + TMS320C64X_INS_STNDW, + TMS320C64X_INS_STNW, + TMS320C64X_INS_STW, + TMS320C64X_INS_SUB, + TMS320C64X_INS_SUB2, + TMS320C64X_INS_SUB4, + TMS320C64X_INS_SUBAB, + TMS320C64X_INS_SUBABS4, + TMS320C64X_INS_SUBAH, + TMS320C64X_INS_SUBAW, + TMS320C64X_INS_SUBC, + TMS320C64X_INS_SUBU, + TMS320C64X_INS_SWAP4, + TMS320C64X_INS_UNPKHU4, + TMS320C64X_INS_UNPKLU4, + TMS320C64X_INS_XOR, + TMS320C64X_INS_XPND2, + TMS320C64X_INS_XPND4, + // Aliases + TMS320C64X_INS_IDLE, + TMS320C64X_INS_MV, + TMS320C64X_INS_NEG, + TMS320C64X_INS_NOT, + TMS320C64X_INS_SWAP2, + TMS320C64X_INS_ZERO, + + TMS320C64X_INS_ENDING, // <-- mark the end of the list of instructions +} tms320c64x_insn; + +typedef enum tms320c64x_insn_group { + TMS320C64X_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + TMS320C64X_GRP_JUMP, ///< = CS_GRP_JUMP + + TMS320C64X_GRP_FUNIT_D = 128, + TMS320C64X_GRP_FUNIT_L, + TMS320C64X_GRP_FUNIT_M, + TMS320C64X_GRP_FUNIT_S, + TMS320C64X_GRP_FUNIT_NO, + + TMS320C64X_GRP_ENDING, // <-- mark the end of the list of groups +} tms320c64x_insn_group; + +typedef enum tms320c64x_funit { + TMS320C64X_FUNIT_INVALID = 0, + TMS320C64X_FUNIT_D, + TMS320C64X_FUNIT_L, + TMS320C64X_FUNIT_M, + TMS320C64X_FUNIT_S, + TMS320C64X_FUNIT_NO +} tms320c64x_funit; + +#ifdef __cplusplus +} +#endif + +#endif + +#ifndef CAPSTONE_M680X_H +#define CAPSTONE_M680X_H + +/* Capstone Disassembly Engine */ +/* M680X Backend by Wolfgang Schwotzer 2017 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +#define M680X_OPERAND_COUNT 9 + +/// M680X registers and special registers +typedef enum m680x_reg { + M680X_REG_INVALID = 0, + + M680X_REG_A, ///< M6800/1/2/3/9, HD6301/9 + M680X_REG_B, ///< M6800/1/2/3/9, HD6301/9 + M680X_REG_E, ///< HD6309 + M680X_REG_F, ///< HD6309 + M680X_REG_0, ///< HD6309 + + M680X_REG_D, ///< M6801/3/9, HD6301/9 + M680X_REG_W, ///< HD6309 + + M680X_REG_CC, ///< M6800/1/2/3/9, M6301/9 + M680X_REG_DP, ///< M6809/M6309 + M680X_REG_MD, ///< M6309 + + M680X_REG_HX, ///< M6808 + M680X_REG_H, ///< M6808 + M680X_REG_X, ///< M6800/1/2/3/9, M6301/9 + M680X_REG_Y, ///< M6809/M6309 + M680X_REG_S, ///< M6809/M6309 + M680X_REG_U, ///< M6809/M6309 + M680X_REG_V, ///< M6309 + + M680X_REG_Q, ///< M6309 + + M680X_REG_PC, ///< M6800/1/2/3/9, M6301/9 + + M680X_REG_TMP2, ///< CPU12 + M680X_REG_TMP3, ///< CPU12 + + M680X_REG_ENDING, ///< <-- mark the end of the list of registers +} m680x_reg; + +/// Operand type for instruction's operands +typedef enum m680x_op_type { + M680X_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). + M680X_OP_REGISTER, ///< = Register operand. + M680X_OP_IMMEDIATE, ///< = Immediate operand. + M680X_OP_INDEXED, ///< = Indexed addressing operand. + M680X_OP_EXTENDED, ///< = Extended addressing operand. + M680X_OP_DIRECT, ///< = Direct addressing operand. + M680X_OP_RELATIVE, ///< = Relative addressing operand. + M680X_OP_CONSTANT, ///< = constant operand (Displayed as number only). + ///< Used e.g. for a bit index or page number. +} m680x_op_type; + +// Supported bit values for mem.idx.offset_bits +#define M680X_OFFSET_NONE 0 +#define M680X_OFFSET_BITS_5 5 +#define M680X_OFFSET_BITS_8 8 +#define M680X_OFFSET_BITS_9 9 +#define M680X_OFFSET_BITS_16 16 + +// Supported bit flags for mem.idx.flags +// These flags can be combined +#define M680X_IDX_INDIRECT 1 +#define M680X_IDX_NO_COMMA 2 +#define M680X_IDX_POST_INC_DEC 4 + +/// Instruction's operand referring to indexed addressing +typedef struct m680x_op_idx { + m680x_reg base_reg; ///< base register (or M680X_REG_INVALID if + ///< irrelevant) + m680x_reg offset_reg; ///< offset register (or M680X_REG_INVALID if + ///< irrelevant) + int16_t offset; ///< 5-,8- or 16-bit offset. See also offset_bits. + uint16_t offset_addr; ///< = offset addr. if base_reg == M680X_REG_PC. + ///< calculated as offset + PC + uint8_t offset_bits; ///< offset width in bits for indexed addressing + int8_t inc_dec; ///< inc. or dec. value: + ///< 0: no inc-/decrement + ///< 1 .. 8: increment by 1 .. 8 + ///< -1 .. -8: decrement by 1 .. 8 + ///< if flag M680X_IDX_POST_INC_DEC set it is post + ///< inc-/decrement otherwise pre inc-/decrement + uint8_t flags; ///< 8-bit flags (see above) +} m680x_op_idx; + +/// Instruction's memory operand referring to relative addressing (Bcc/LBcc) +typedef struct m680x_op_rel { + uint16_t address; ///< The absolute address. + ///< calculated as PC + offset. PC is the first + ///< address after the instruction. + int16_t offset; ///< the offset/displacement value +} m680x_op_rel; + +/// Instruction's operand referring to extended addressing +typedef struct m680x_op_ext { + uint16_t address; ///< The absolute address + bool indirect; ///< true if extended indirect addressing +} m680x_op_ext; + +/// Instruction operand +typedef struct cs_m680x_op { + m680x_op_type type; + union { + int32_t imm; ///< immediate value for IMM operand + m680x_reg reg; ///< register value for REG operand + m680x_op_idx idx; ///< Indexed addressing operand + m680x_op_rel rel; ///< Relative address. operand (Bcc/LBcc) + m680x_op_ext ext; ///< Extended address + uint8_t direct_addr; ///<, 2013-2018 */ + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// Instruction structure +typedef struct cs_evm { + unsigned char pop; ///< number of items popped from the stack + unsigned char push; ///< number of items pushed into the stack + unsigned int fee; ///< gas fee for the instruction +} cs_evm; + +/// EVM instruction +typedef enum evm_insn { + EVM_INS_STOP = 0, + EVM_INS_ADD = 1, + EVM_INS_MUL = 2, + EVM_INS_SUB = 3, + EVM_INS_DIV = 4, + EVM_INS_SDIV = 5, + EVM_INS_MOD = 6, + EVM_INS_SMOD = 7, + EVM_INS_ADDMOD = 8, + EVM_INS_MULMOD = 9, + EVM_INS_EXP = 10, + EVM_INS_SIGNEXTEND = 11, + EVM_INS_LT = 16, + EVM_INS_GT = 17, + EVM_INS_SLT = 18, + EVM_INS_SGT = 19, + EVM_INS_EQ = 20, + EVM_INS_ISZERO = 21, + EVM_INS_AND = 22, + EVM_INS_OR = 23, + EVM_INS_XOR = 24, + EVM_INS_NOT = 25, + EVM_INS_BYTE = 26, + EVM_INS_SHA3 = 32, + EVM_INS_ADDRESS = 48, + EVM_INS_BALANCE = 49, + EVM_INS_ORIGIN = 50, + EVM_INS_CALLER = 51, + EVM_INS_CALLVALUE = 52, + EVM_INS_CALLDATALOAD = 53, + EVM_INS_CALLDATASIZE = 54, + EVM_INS_CALLDATACOPY = 55, + EVM_INS_CODESIZE = 56, + EVM_INS_CODECOPY = 57, + EVM_INS_GASPRICE = 58, + EVM_INS_EXTCODESIZE = 59, + EVM_INS_EXTCODECOPY = 60, + EVM_INS_RETURNDATASIZE = 61, + EVM_INS_RETURNDATACOPY = 62, + EVM_INS_BLOCKHASH = 64, + EVM_INS_COINBASE = 65, + EVM_INS_TIMESTAMP = 66, + EVM_INS_NUMBER = 67, + EVM_INS_DIFFICULTY = 68, + EVM_INS_GASLIMIT = 69, + EVM_INS_POP = 80, + EVM_INS_MLOAD = 81, + EVM_INS_MSTORE = 82, + EVM_INS_MSTORE8 = 83, + EVM_INS_SLOAD = 84, + EVM_INS_SSTORE = 85, + EVM_INS_JUMP = 86, + EVM_INS_JUMPI = 87, + EVM_INS_PC = 88, + EVM_INS_MSIZE = 89, + EVM_INS_GAS = 90, + EVM_INS_JUMPDEST = 91, + EVM_INS_PUSH1 = 96, + EVM_INS_PUSH2 = 97, + EVM_INS_PUSH3 = 98, + EVM_INS_PUSH4 = 99, + EVM_INS_PUSH5 = 100, + EVM_INS_PUSH6 = 101, + EVM_INS_PUSH7 = 102, + EVM_INS_PUSH8 = 103, + EVM_INS_PUSH9 = 104, + EVM_INS_PUSH10 = 105, + EVM_INS_PUSH11 = 106, + EVM_INS_PUSH12 = 107, + EVM_INS_PUSH13 = 108, + EVM_INS_PUSH14 = 109, + EVM_INS_PUSH15 = 110, + EVM_INS_PUSH16 = 111, + EVM_INS_PUSH17 = 112, + EVM_INS_PUSH18 = 113, + EVM_INS_PUSH19 = 114, + EVM_INS_PUSH20 = 115, + EVM_INS_PUSH21 = 116, + EVM_INS_PUSH22 = 117, + EVM_INS_PUSH23 = 118, + EVM_INS_PUSH24 = 119, + EVM_INS_PUSH25 = 120, + EVM_INS_PUSH26 = 121, + EVM_INS_PUSH27 = 122, + EVM_INS_PUSH28 = 123, + EVM_INS_PUSH29 = 124, + EVM_INS_PUSH30 = 125, + EVM_INS_PUSH31 = 126, + EVM_INS_PUSH32 = 127, + EVM_INS_DUP1 = 128, + EVM_INS_DUP2 = 129, + EVM_INS_DUP3 = 130, + EVM_INS_DUP4 = 131, + EVM_INS_DUP5 = 132, + EVM_INS_DUP6 = 133, + EVM_INS_DUP7 = 134, + EVM_INS_DUP8 = 135, + EVM_INS_DUP9 = 136, + EVM_INS_DUP10 = 137, + EVM_INS_DUP11 = 138, + EVM_INS_DUP12 = 139, + EVM_INS_DUP13 = 140, + EVM_INS_DUP14 = 141, + EVM_INS_DUP15 = 142, + EVM_INS_DUP16 = 143, + EVM_INS_SWAP1 = 144, + EVM_INS_SWAP2 = 145, + EVM_INS_SWAP3 = 146, + EVM_INS_SWAP4 = 147, + EVM_INS_SWAP5 = 148, + EVM_INS_SWAP6 = 149, + EVM_INS_SWAP7 = 150, + EVM_INS_SWAP8 = 151, + EVM_INS_SWAP9 = 152, + EVM_INS_SWAP10 = 153, + EVM_INS_SWAP11 = 154, + EVM_INS_SWAP12 = 155, + EVM_INS_SWAP13 = 156, + EVM_INS_SWAP14 = 157, + EVM_INS_SWAP15 = 158, + EVM_INS_SWAP16 = 159, + EVM_INS_LOG0 = 160, + EVM_INS_LOG1 = 161, + EVM_INS_LOG2 = 162, + EVM_INS_LOG3 = 163, + EVM_INS_LOG4 = 164, + EVM_INS_CREATE = 240, + EVM_INS_CALL = 241, + EVM_INS_CALLCODE = 242, + EVM_INS_RETURN = 243, + EVM_INS_DELEGATECALL = 244, + EVM_INS_CALLBLACKBOX = 245, + EVM_INS_STATICCALL = 250, + EVM_INS_REVERT = 253, + EVM_INS_SUICIDE = 255, + + EVM_INS_INVALID = 512, + EVM_INS_ENDING, // <-- mark the end of the list of instructions +} evm_insn; + +/// Group of EVM instructions +typedef enum evm_insn_group { + EVM_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + EVM_GRP_JUMP, ///< all jump instructions + + EVM_GRP_MATH = 8, ///< math instructions + EVM_GRP_STACK_WRITE, ///< instructions write to stack + EVM_GRP_STACK_READ, ///< instructions read from stack + EVM_GRP_MEM_WRITE, ///< instructions write to memory + EVM_GRP_MEM_READ, ///< instructions read from memory + EVM_GRP_STORE_WRITE, ///< instructions write to storage + EVM_GRP_STORE_READ, ///< instructions read from storage + EVM_GRP_HALT, ///< instructions halt execution + + EVM_GRP_ENDING, ///< <-- mark the end of the list of groups +} evm_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_RISCV_H +#define CAPSTONE_RISCV_H + +/* Capstone Disassembly Engine */ +/* RISC-V Backend By Rodrigo Cortes Porto & + Shawn Chang , HardenedLinux@2018 */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_MSC_VER) || !defined(_KERNEL_MODE) +#include +#endif + + +// GCC MIPS toolchain has a default macro called "mips" which breaks +// compilation +//#undef riscv + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +//> Operand type for instruction's operands +typedef enum riscv_op_type { + RISCV_OP_INVALID = 0, // = CS_OP_INVALID (Uninitialized). + RISCV_OP_REG, // = CS_OP_REG (Register operand). + RISCV_OP_IMM, // = CS_OP_IMM (Immediate operand). + RISCV_OP_MEM, // = CS_OP_MEM (Memory operand). +} riscv_op_type; + +// Instruction's operand referring to memory +// This is associated with RISCV_OP_MEM operand type above +typedef struct riscv_op_mem { + unsigned int base; // base register + int64_t disp; // displacement/offset value +} riscv_op_mem; + +// Instruction operand +typedef struct cs_riscv_op { + riscv_op_type type; // operand type + union { + unsigned int reg; // register value for REG operand + int64_t imm; // immediate value for IMM operand + riscv_op_mem mem; // base/disp value for MEM operand + }; +} cs_riscv_op; + +// Instruction structure +typedef struct cs_riscv { + // Does this instruction need effective address or not. + bool need_effective_addr; + // Number of operands of this instruction, + // or 0 when instruction has no operand. + uint8_t op_count; + cs_riscv_op operands[8]; // operands for this instruction. +} cs_riscv; + +//> RISCV registers +typedef enum riscv_reg { + RISCV_REG_INVALID = 0, + //> General purpose registers + RISCV_REG_X0, // "zero" + RISCV_REG_ZERO = RISCV_REG_X0, // "zero" + RISCV_REG_X1, // "ra" + RISCV_REG_RA = RISCV_REG_X1, // "ra" + RISCV_REG_X2, // "sp" + RISCV_REG_SP = RISCV_REG_X2, // "sp" + RISCV_REG_X3, // "gp" + RISCV_REG_GP = RISCV_REG_X3, // "gp" + RISCV_REG_X4, // "tp" + RISCV_REG_TP = RISCV_REG_X4, // "tp" + RISCV_REG_X5, // "t0" + RISCV_REG_T0 = RISCV_REG_X5, // "t0" + RISCV_REG_X6, // "t1" + RISCV_REG_T1 = RISCV_REG_X6, // "t1" + RISCV_REG_X7, // "t2" + RISCV_REG_T2 = RISCV_REG_X7, // "t2" + RISCV_REG_X8, // "s0/fp" + RISCV_REG_S0 = RISCV_REG_X8, // "s0" + RISCV_REG_FP = RISCV_REG_X8, // "fp" + RISCV_REG_X9, // "s1" + RISCV_REG_S1 = RISCV_REG_X9, // "s1" + RISCV_REG_X10, // "a0" + RISCV_REG_A0 = RISCV_REG_X10, // "a0" + RISCV_REG_X11, // "a1" + RISCV_REG_A1 = RISCV_REG_X11, // "a1" + RISCV_REG_X12, // "a2" + RISCV_REG_A2 = RISCV_REG_X12, // "a2" + RISCV_REG_X13, // "a3" + RISCV_REG_A3 = RISCV_REG_X13, // "a3" + RISCV_REG_X14, // "a4" + RISCV_REG_A4 = RISCV_REG_X14, // "a4" + RISCV_REG_X15, // "a5" + RISCV_REG_A5 = RISCV_REG_X15, // "a5" + RISCV_REG_X16, // "a6" + RISCV_REG_A6 = RISCV_REG_X16, // "a6" + RISCV_REG_X17, // "a7" + RISCV_REG_A7 = RISCV_REG_X17, // "a7" + RISCV_REG_X18, // "s2" + RISCV_REG_S2 = RISCV_REG_X18, // "s2" + RISCV_REG_X19, // "s3" + RISCV_REG_S3 = RISCV_REG_X19, // "s3" + RISCV_REG_X20, // "s4" + RISCV_REG_S4 = RISCV_REG_X20, // "s4" + RISCV_REG_X21, // "s5" + RISCV_REG_S5 = RISCV_REG_X21, // "s5" + RISCV_REG_X22, // "s6" + RISCV_REG_S6 = RISCV_REG_X22, // "s6" + RISCV_REG_X23, // "s7" + RISCV_REG_S7 = RISCV_REG_X23, // "s7" + RISCV_REG_X24, // "s8" + RISCV_REG_S8 = RISCV_REG_X24, // "s8" + RISCV_REG_X25, // "s9" + RISCV_REG_S9 = RISCV_REG_X25, // "s9" + RISCV_REG_X26, // "s10" + RISCV_REG_S10 = RISCV_REG_X26, // "s10" + RISCV_REG_X27, // "s11" + RISCV_REG_S11 = RISCV_REG_X27, // "s11" + RISCV_REG_X28, // "t3" + RISCV_REG_T3 = RISCV_REG_X28, // "t3" + RISCV_REG_X29, // "t4" + RISCV_REG_T4 = RISCV_REG_X29, // "t4" + RISCV_REG_X30, // "t5" + RISCV_REG_T5 = RISCV_REG_X30, // "t5" + RISCV_REG_X31, // "t6" + RISCV_REG_T6 = RISCV_REG_X31, // "t6" + + //> Floating-point registers + RISCV_REG_F0_32, // "ft0" + RISCV_REG_F0_64, // "ft0" + RISCV_REG_F1_32, // "ft1" + RISCV_REG_F1_64, // "ft1" + RISCV_REG_F2_32, // "ft2" + RISCV_REG_F2_64, // "ft2" + RISCV_REG_F3_32, // "ft3" + RISCV_REG_F3_64, // "ft3" + RISCV_REG_F4_32, // "ft4" + RISCV_REG_F4_64, // "ft4" + RISCV_REG_F5_32, // "ft5" + RISCV_REG_F5_64, // "ft5" + RISCV_REG_F6_32, // "ft6" + RISCV_REG_F6_64, // "ft6" + RISCV_REG_F7_32, // "ft7" + RISCV_REG_F7_64, // "ft7" + RISCV_REG_F8_32, // "fs0" + RISCV_REG_F8_64, // "fs0" + RISCV_REG_F9_32, // "fs1" + RISCV_REG_F9_64, // "fs1" + RISCV_REG_F10_32, // "fa0" + RISCV_REG_F10_64, // "fa0" + RISCV_REG_F11_32, // "fa1" + RISCV_REG_F11_64, // "fa1" + RISCV_REG_F12_32, // "fa2" + RISCV_REG_F12_64, // "fa2" + RISCV_REG_F13_32, // "fa3" + RISCV_REG_F13_64, // "fa3" + RISCV_REG_F14_32, // "fa4" + RISCV_REG_F14_64, // "fa4" + RISCV_REG_F15_32, // "fa5" + RISCV_REG_F15_64, // "fa5" + RISCV_REG_F16_32, // "fa6" + RISCV_REG_F16_64, // "fa6" + RISCV_REG_F17_32, // "fa7" + RISCV_REG_F17_64, // "fa7" + RISCV_REG_F18_32, // "fs2" + RISCV_REG_F18_64, // "fs2" + RISCV_REG_F19_32, // "fs3" + RISCV_REG_F19_64, // "fs3" + RISCV_REG_F20_32, // "fs4" + RISCV_REG_F20_64, // "fs4" + RISCV_REG_F21_32, // "fs5" + RISCV_REG_F21_64, // "fs5" + RISCV_REG_F22_32, // "fs6" + RISCV_REG_F22_64, // "fs6" + RISCV_REG_F23_32, // "fs7" + RISCV_REG_F23_64, // "fs7" + RISCV_REG_F24_32, // "fs8" + RISCV_REG_F24_64, // "fs8" + RISCV_REG_F25_32, // "fs9" + RISCV_REG_F25_64, // "fs9" + RISCV_REG_F26_32, // "fs10" + RISCV_REG_F26_64, // "fs10" + RISCV_REG_F27_32, // "fs11" + RISCV_REG_F27_64, // "fs11" + RISCV_REG_F28_32, // "ft8" + RISCV_REG_F28_64, // "ft8" + RISCV_REG_F29_32, // "ft9" + RISCV_REG_F29_64, // "ft9" + RISCV_REG_F30_32, // "ft10" + RISCV_REG_F30_64, // "ft10" + RISCV_REG_F31_32, // "ft11" + RISCV_REG_F31_64, // "ft11" + + RISCV_REG_ENDING, // <-- mark the end of the list or registers +} riscv_reg; + +//> RISCV instruction +typedef enum riscv_insn { + RISCV_INS_INVALID = 0, + + RISCV_INS_ADD, + RISCV_INS_ADDI, + RISCV_INS_ADDIW, + RISCV_INS_ADDW, + RISCV_INS_AMOADD_D, + RISCV_INS_AMOADD_D_AQ, + RISCV_INS_AMOADD_D_AQ_RL, + RISCV_INS_AMOADD_D_RL, + RISCV_INS_AMOADD_W, + RISCV_INS_AMOADD_W_AQ, + RISCV_INS_AMOADD_W_AQ_RL, + RISCV_INS_AMOADD_W_RL, + RISCV_INS_AMOAND_D, + RISCV_INS_AMOAND_D_AQ, + RISCV_INS_AMOAND_D_AQ_RL, + RISCV_INS_AMOAND_D_RL, + RISCV_INS_AMOAND_W, + RISCV_INS_AMOAND_W_AQ, + RISCV_INS_AMOAND_W_AQ_RL, + RISCV_INS_AMOAND_W_RL, + RISCV_INS_AMOMAXU_D, + RISCV_INS_AMOMAXU_D_AQ, + RISCV_INS_AMOMAXU_D_AQ_RL, + RISCV_INS_AMOMAXU_D_RL, + RISCV_INS_AMOMAXU_W, + RISCV_INS_AMOMAXU_W_AQ, + RISCV_INS_AMOMAXU_W_AQ_RL, + RISCV_INS_AMOMAXU_W_RL, + RISCV_INS_AMOMAX_D, + RISCV_INS_AMOMAX_D_AQ, + RISCV_INS_AMOMAX_D_AQ_RL, + RISCV_INS_AMOMAX_D_RL, + RISCV_INS_AMOMAX_W, + RISCV_INS_AMOMAX_W_AQ, + RISCV_INS_AMOMAX_W_AQ_RL, + RISCV_INS_AMOMAX_W_RL, + RISCV_INS_AMOMINU_D, + RISCV_INS_AMOMINU_D_AQ, + RISCV_INS_AMOMINU_D_AQ_RL, + RISCV_INS_AMOMINU_D_RL, + RISCV_INS_AMOMINU_W, + RISCV_INS_AMOMINU_W_AQ, + RISCV_INS_AMOMINU_W_AQ_RL, + RISCV_INS_AMOMINU_W_RL, + RISCV_INS_AMOMIN_D, + RISCV_INS_AMOMIN_D_AQ, + RISCV_INS_AMOMIN_D_AQ_RL, + RISCV_INS_AMOMIN_D_RL, + RISCV_INS_AMOMIN_W, + RISCV_INS_AMOMIN_W_AQ, + RISCV_INS_AMOMIN_W_AQ_RL, + RISCV_INS_AMOMIN_W_RL, + RISCV_INS_AMOOR_D, + RISCV_INS_AMOOR_D_AQ, + RISCV_INS_AMOOR_D_AQ_RL, + RISCV_INS_AMOOR_D_RL, + RISCV_INS_AMOOR_W, + RISCV_INS_AMOOR_W_AQ, + RISCV_INS_AMOOR_W_AQ_RL, + RISCV_INS_AMOOR_W_RL, + RISCV_INS_AMOSWAP_D, + RISCV_INS_AMOSWAP_D_AQ, + RISCV_INS_AMOSWAP_D_AQ_RL, + RISCV_INS_AMOSWAP_D_RL, + RISCV_INS_AMOSWAP_W, + RISCV_INS_AMOSWAP_W_AQ, + RISCV_INS_AMOSWAP_W_AQ_RL, + RISCV_INS_AMOSWAP_W_RL, + RISCV_INS_AMOXOR_D, + RISCV_INS_AMOXOR_D_AQ, + RISCV_INS_AMOXOR_D_AQ_RL, + RISCV_INS_AMOXOR_D_RL, + RISCV_INS_AMOXOR_W, + RISCV_INS_AMOXOR_W_AQ, + RISCV_INS_AMOXOR_W_AQ_RL, + RISCV_INS_AMOXOR_W_RL, + RISCV_INS_AND, + RISCV_INS_ANDI, + RISCV_INS_AUIPC, + RISCV_INS_BEQ, + RISCV_INS_BGE, + RISCV_INS_BGEU, + RISCV_INS_BLT, + RISCV_INS_BLTU, + RISCV_INS_BNE, + RISCV_INS_CSRRC, + RISCV_INS_CSRRCI, + RISCV_INS_CSRRS, + RISCV_INS_CSRRSI, + RISCV_INS_CSRRW, + RISCV_INS_CSRRWI, + RISCV_INS_C_ADD, + RISCV_INS_C_ADDI, + RISCV_INS_C_ADDI16SP, + RISCV_INS_C_ADDI4SPN, + RISCV_INS_C_ADDIW, + RISCV_INS_C_ADDW, + RISCV_INS_C_AND, + RISCV_INS_C_ANDI, + RISCV_INS_C_BEQZ, + RISCV_INS_C_BNEZ, + RISCV_INS_C_EBREAK, + RISCV_INS_C_FLD, + RISCV_INS_C_FLDSP, + RISCV_INS_C_FLW, + RISCV_INS_C_FLWSP, + RISCV_INS_C_FSD, + RISCV_INS_C_FSDSP, + RISCV_INS_C_FSW, + RISCV_INS_C_FSWSP, + RISCV_INS_C_J, + RISCV_INS_C_JAL, + RISCV_INS_C_JALR, + RISCV_INS_C_JR, + RISCV_INS_C_LD, + RISCV_INS_C_LDSP, + RISCV_INS_C_LI, + RISCV_INS_C_LUI, + RISCV_INS_C_LW, + RISCV_INS_C_LWSP, + RISCV_INS_C_MV, + RISCV_INS_C_NOP, + RISCV_INS_C_OR, + RISCV_INS_C_SD, + RISCV_INS_C_SDSP, + RISCV_INS_C_SLLI, + RISCV_INS_C_SRAI, + RISCV_INS_C_SRLI, + RISCV_INS_C_SUB, + RISCV_INS_C_SUBW, + RISCV_INS_C_SW, + RISCV_INS_C_SWSP, + RISCV_INS_C_UNIMP, + RISCV_INS_C_XOR, + RISCV_INS_DIV, + RISCV_INS_DIVU, + RISCV_INS_DIVUW, + RISCV_INS_DIVW, + RISCV_INS_EBREAK, + RISCV_INS_ECALL, + RISCV_INS_FADD_D, + RISCV_INS_FADD_S, + RISCV_INS_FCLASS_D, + RISCV_INS_FCLASS_S, + RISCV_INS_FCVT_D_L, + RISCV_INS_FCVT_D_LU, + RISCV_INS_FCVT_D_S, + RISCV_INS_FCVT_D_W, + RISCV_INS_FCVT_D_WU, + RISCV_INS_FCVT_LU_D, + RISCV_INS_FCVT_LU_S, + RISCV_INS_FCVT_L_D, + RISCV_INS_FCVT_L_S, + RISCV_INS_FCVT_S_D, + RISCV_INS_FCVT_S_L, + RISCV_INS_FCVT_S_LU, + RISCV_INS_FCVT_S_W, + RISCV_INS_FCVT_S_WU, + RISCV_INS_FCVT_WU_D, + RISCV_INS_FCVT_WU_S, + RISCV_INS_FCVT_W_D, + RISCV_INS_FCVT_W_S, + RISCV_INS_FDIV_D, + RISCV_INS_FDIV_S, + RISCV_INS_FENCE, + RISCV_INS_FENCE_I, + RISCV_INS_FENCE_TSO, + RISCV_INS_FEQ_D, + RISCV_INS_FEQ_S, + RISCV_INS_FLD, + RISCV_INS_FLE_D, + RISCV_INS_FLE_S, + RISCV_INS_FLT_D, + RISCV_INS_FLT_S, + RISCV_INS_FLW, + RISCV_INS_FMADD_D, + RISCV_INS_FMADD_S, + RISCV_INS_FMAX_D, + RISCV_INS_FMAX_S, + RISCV_INS_FMIN_D, + RISCV_INS_FMIN_S, + RISCV_INS_FMSUB_D, + RISCV_INS_FMSUB_S, + RISCV_INS_FMUL_D, + RISCV_INS_FMUL_S, + RISCV_INS_FMV_D_X, + RISCV_INS_FMV_W_X, + RISCV_INS_FMV_X_D, + RISCV_INS_FMV_X_W, + RISCV_INS_FNMADD_D, + RISCV_INS_FNMADD_S, + RISCV_INS_FNMSUB_D, + RISCV_INS_FNMSUB_S, + RISCV_INS_FSD, + RISCV_INS_FSGNJN_D, + RISCV_INS_FSGNJN_S, + RISCV_INS_FSGNJX_D, + RISCV_INS_FSGNJX_S, + RISCV_INS_FSGNJ_D, + RISCV_INS_FSGNJ_S, + RISCV_INS_FSQRT_D, + RISCV_INS_FSQRT_S, + RISCV_INS_FSUB_D, + RISCV_INS_FSUB_S, + RISCV_INS_FSW, + RISCV_INS_JAL, + RISCV_INS_JALR, + RISCV_INS_LB, + RISCV_INS_LBU, + RISCV_INS_LD, + RISCV_INS_LH, + RISCV_INS_LHU, + RISCV_INS_LR_D, + RISCV_INS_LR_D_AQ, + RISCV_INS_LR_D_AQ_RL, + RISCV_INS_LR_D_RL, + RISCV_INS_LR_W, + RISCV_INS_LR_W_AQ, + RISCV_INS_LR_W_AQ_RL, + RISCV_INS_LR_W_RL, + RISCV_INS_LUI, + RISCV_INS_LW, + RISCV_INS_LWU, + RISCV_INS_MRET, + RISCV_INS_MUL, + RISCV_INS_MULH, + RISCV_INS_MULHSU, + RISCV_INS_MULHU, + RISCV_INS_MULW, + RISCV_INS_OR, + RISCV_INS_ORI, + RISCV_INS_REM, + RISCV_INS_REMU, + RISCV_INS_REMUW, + RISCV_INS_REMW, + RISCV_INS_SB, + RISCV_INS_SC_D, + RISCV_INS_SC_D_AQ, + RISCV_INS_SC_D_AQ_RL, + RISCV_INS_SC_D_RL, + RISCV_INS_SC_W, + RISCV_INS_SC_W_AQ, + RISCV_INS_SC_W_AQ_RL, + RISCV_INS_SC_W_RL, + RISCV_INS_SD, + RISCV_INS_SFENCE_VMA, + RISCV_INS_SH, + RISCV_INS_SLL, + RISCV_INS_SLLI, + RISCV_INS_SLLIW, + RISCV_INS_SLLW, + RISCV_INS_SLT, + RISCV_INS_SLTI, + RISCV_INS_SLTIU, + RISCV_INS_SLTU, + RISCV_INS_SRA, + RISCV_INS_SRAI, + RISCV_INS_SRAIW, + RISCV_INS_SRAW, + RISCV_INS_SRET, + RISCV_INS_SRL, + RISCV_INS_SRLI, + RISCV_INS_SRLIW, + RISCV_INS_SRLW, + RISCV_INS_SUB, + RISCV_INS_SUBW, + RISCV_INS_SW, + RISCV_INS_UNIMP, + RISCV_INS_URET, + RISCV_INS_WFI, + RISCV_INS_XOR, + RISCV_INS_XORI, + + RISCV_INS_ENDING, +} riscv_insn; + +//> Group of RISCV instructions +typedef enum riscv_insn_group { + RISCV_GRP_INVALID = 0, // = CS_GRP_INVALID + RISCV_GRP_JUMP, + + RISCV_GRP_ISRV32 = 128, + RISCV_GRP_ISRV64, + RISCV_GRP_HASSTDEXTA, + RISCV_GRP_HASSTDEXTC, + RISCV_GRP_HASSTDEXTD, + RISCV_GRP_HASSTDEXTF, + RISCV_GRP_HASSTDEXTM, + /* + RISCV_GRP_ISRVA, + RISCV_GRP_ISRVC, + RISCV_GRP_ISRVD, + RISCV_GRP_ISRVCD, + RISCV_GRP_ISRVF, + RISCV_GRP_ISRV32C, + RISCV_GRP_ISRV32CF, + RISCV_GRP_ISRVM, + RISCV_GRP_ISRV64A, + RISCV_GRP_ISRV64C, + RISCV_GRP_ISRV64D, + RISCV_GRP_ISRV64F, + RISCV_GRP_ISRV64M, + */ + RISCV_GRP_ENDING, +} riscv_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif + +/* Capstone Disassembly Engine */ +/* By Spike , xwings 2019 */ + +#ifndef CAPSTONE_WASM_H +#define CAPSTONE_WASM_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +typedef enum wasm_op_type { + WASM_OP_INVALID = 0, + WASM_OP_NONE, + WASM_OP_INT7, + WASM_OP_VARUINT32, + WASM_OP_VARUINT64, + WASM_OP_UINT32, + WASM_OP_UINT64, + WASM_OP_IMM, + WASM_OP_BRTABLE, +} wasm_op_type; + +typedef struct cs_wasm_brtable { + uint32_t length; + uint64_t address; + uint32_t default_target; +} cs_wasm_brtable; + +typedef struct cs_wasm_op { + wasm_op_type type; + uint32_t size; + union { + int8_t int7; + uint32_t varuint32; + uint64_t varuint64; + uint32_t uint32; + uint64_t uint64; + uint32_t immediate[2]; + cs_wasm_brtable brtable; + }; +} cs_wasm_op; + +/// Instruction structure +typedef struct cs_wasm { + uint8_t op_count; + cs_wasm_op operands[2]; +} cs_wasm; + +/// WASM instruction +typedef enum wasm_insn { + WASM_INS_UNREACHABLE = 0x0, + WASM_INS_NOP = 0x1, + WASM_INS_BLOCK = 0x2, + WASM_INS_LOOP = 0x3, + WASM_INS_IF = 0x4, + WASM_INS_ELSE = 0x5, + WASM_INS_END = 0xb, + WASM_INS_BR = 0xc, + WASM_INS_BR_IF = 0xd, + WASM_INS_BR_TABLE = 0xe, + WASM_INS_RETURN = 0xf, + WASM_INS_CALL = 0x10, + WASM_INS_CALL_INDIRECT = 0x11, + WASM_INS_DROP = 0x1a, + WASM_INS_SELECT = 0x1b, + WASM_INS_GET_LOCAL = 0x20, + WASM_INS_SET_LOCAL = 0x21, + WASM_INS_TEE_LOCAL = 0x22, + WASM_INS_GET_GLOBAL = 0x23, + WASM_INS_SET_GLOBAL = 0x24, + WASM_INS_I32_LOAD = 0x28, + WASM_INS_I64_LOAD = 0x29, + WASM_INS_F32_LOAD = 0x2a, + WASM_INS_F64_LOAD = 0x2b, + WASM_INS_I32_LOAD8_S = 0x2c, + WASM_INS_I32_LOAD8_U = 0x2d, + WASM_INS_I32_LOAD16_S = 0x2e, + WASM_INS_I32_LOAD16_U = 0x2f, + WASM_INS_I64_LOAD8_S = 0x30, + WASM_INS_I64_LOAD8_U = 0x31, + WASM_INS_I64_LOAD16_S = 0x32, + WASM_INS_I64_LOAD16_U = 0x33, + WASM_INS_I64_LOAD32_S = 0x34, + WASM_INS_I64_LOAD32_U = 0x35, + WASM_INS_I32_STORE = 0x36, + WASM_INS_I64_STORE = 0x37, + WASM_INS_F32_STORE = 0x38, + WASM_INS_F64_STORE = 0x39, + WASM_INS_I32_STORE8 = 0x3a, + WASM_INS_I32_STORE16 = 0x3b, + WASM_INS_I64_STORE8 = 0x3c, + WASM_INS_I64_STORE16 = 0x3d, + WASM_INS_I64_STORE32 = 0x3e, + WASM_INS_CURRENT_MEMORY = 0x3f, + WASM_INS_GROW_MEMORY = 0x40, + WASM_INS_I32_CONST = 0x41, + WASM_INS_I64_CONST = 0x42, + WASM_INS_F32_CONST = 0x43, + WASM_INS_F64_CONST = 0x44, + WASM_INS_I32_EQZ = 0x45, + WASM_INS_I32_EQ = 0x46, + WASM_INS_I32_NE = 0x47, + WASM_INS_I32_LT_S = 0x48, + WASM_INS_I32_LT_U = 0x49, + WASM_INS_I32_GT_S = 0x4a, + WASM_INS_I32_GT_U = 0x4b, + WASM_INS_I32_LE_S = 0x4c, + WASM_INS_I32_LE_U = 0x4d, + WASM_INS_I32_GE_S = 0x4e, + WASM_INS_I32_GE_U = 0x4f, + WASM_INS_I64_EQZ = 0x50, + WASM_INS_I64_EQ = 0x51, + WASM_INS_I64_NE = 0x52, + WASM_INS_I64_LT_S = 0x53, + WASM_INS_I64_LT_U = 0x54, + WASN_INS_I64_GT_S = 0x55, + WASM_INS_I64_GT_U = 0x56, + WASM_INS_I64_LE_S = 0x57, + WASM_INS_I64_LE_U = 0x58, + WASM_INS_I64_GE_S = 0x59, + WASM_INS_I64_GE_U = 0x5a, + WASM_INS_F32_EQ = 0x5b, + WASM_INS_F32_NE = 0x5c, + WASM_INS_F32_LT = 0x5d, + WASM_INS_F32_GT = 0x5e, + WASM_INS_F32_LE = 0x5f, + WASM_INS_F32_GE = 0x60, + WASM_INS_F64_EQ = 0x61, + WASM_INS_F64_NE = 0x62, + WASM_INS_F64_LT = 0x63, + WASM_INS_F64_GT = 0x64, + WASM_INS_F64_LE = 0x65, + WASM_INS_F64_GE = 0x66, + WASM_INS_I32_CLZ = 0x67, + WASM_INS_I32_CTZ = 0x68, + WASM_INS_I32_POPCNT = 0x69, + WASM_INS_I32_ADD = 0x6a, + WASM_INS_I32_SUB = 0x6b, + WASM_INS_I32_MUL = 0x6c, + WASM_INS_I32_DIV_S = 0x6d, + WASM_INS_I32_DIV_U = 0x6e, + WASM_INS_I32_REM_S = 0x6f, + WASM_INS_I32_REM_U = 0x70, + WASM_INS_I32_AND = 0x71, + WASM_INS_I32_OR = 0x72, + WASM_INS_I32_XOR = 0x73, + WASM_INS_I32_SHL = 0x74, + WASM_INS_I32_SHR_S = 0x75, + WASM_INS_I32_SHR_U = 0x76, + WASM_INS_I32_ROTL = 0x77, + WASM_INS_I32_ROTR = 0x78, + WASM_INS_I64_CLZ = 0x79, + WASM_INS_I64_CTZ = 0x7a, + WASM_INS_I64_POPCNT = 0x7b, + WASM_INS_I64_ADD = 0x7c, + WASM_INS_I64_SUB = 0x7d, + WASM_INS_I64_MUL = 0x7e, + WASM_INS_I64_DIV_S = 0x7f, + WASM_INS_I64_DIV_U = 0x80, + WASM_INS_I64_REM_S = 0x81, + WASM_INS_I64_REM_U = 0x82, + WASM_INS_I64_AND = 0x83, + WASM_INS_I64_OR = 0x84, + WASM_INS_I64_XOR = 0x85, + WASM_INS_I64_SHL = 0x86, + WASM_INS_I64_SHR_S = 0x87, + WASM_INS_I64_SHR_U = 0x88, + WASM_INS_I64_ROTL = 0x89, + WASM_INS_I64_ROTR = 0x8a, + WASM_INS_F32_ABS = 0x8b, + WASM_INS_F32_NEG = 0x8c, + WASM_INS_F32_CEIL = 0x8d, + WASM_INS_F32_FLOOR = 0x8e, + WASM_INS_F32_TRUNC = 0x8f, + WASM_INS_F32_NEAREST = 0x90, + WASM_INS_F32_SQRT = 0x91, + WASM_INS_F32_ADD = 0x92, + WASM_INS_F32_SUB = 0x93, + WASM_INS_F32_MUL = 0x94, + WASM_INS_F32_DIV = 0x95, + WASM_INS_F32_MIN = 0x96, + WASM_INS_F32_MAX = 0x97, + WASM_INS_F32_COPYSIGN = 0x98, + WASM_INS_F64_ABS = 0x99, + WASM_INS_F64_NEG = 0x9a, + WASM_INS_F64_CEIL = 0x9b, + WASM_INS_F64_FLOOR = 0x9c, + WASM_INS_F64_TRUNC = 0x9d, + WASM_INS_F64_NEAREST = 0x9e, + WASM_INS_F64_SQRT = 0x9f, + WASM_INS_F64_ADD = 0xa0, + WASM_INS_F64_SUB = 0xa1, + WASM_INS_F64_MUL = 0xa2, + WASM_INS_F64_DIV = 0xa3, + WASM_INS_F64_MIN = 0xa4, + WASM_INS_F64_MAX = 0xa5, + WASM_INS_F64_COPYSIGN = 0xa6, + WASM_INS_I32_WARP_I64 = 0xa7, + WASP_INS_I32_TRUNC_S_F32 = 0xa8, + WASM_INS_I32_TRUNC_U_F32 = 0xa9, + WASM_INS_I32_TRUNC_S_F64 = 0xaa, + WASM_INS_I32_TRUNC_U_F64 = 0xab, + WASM_INS_I64_EXTEND_S_I32 = 0xac, + WASM_INS_I64_EXTEND_U_I32 = 0xad, + WASM_INS_I64_TRUNC_S_F32 = 0xae, + WASM_INS_I64_TRUNC_U_F32 = 0xaf, + WASM_INS_I64_TRUNC_S_F64 = 0xb0, + WASM_INS_I64_TRUNC_U_F64 = 0xb1, + WASM_INS_F32_CONVERT_S_I32 = 0xb2, + WASM_INS_F32_CONVERT_U_I32 = 0xb3, + WASM_INS_F32_CONVERT_S_I64 = 0xb4, + WASM_INS_F32_CONVERT_U_I64 = 0xb5, + WASM_INS_F32_DEMOTE_F64 = 0xb6, + WASM_INS_F64_CONVERT_S_I32 = 0xb7, + WASM_INS_F64_CONVERT_U_I32 = 0xb8, + WASM_INS_F64_CONVERT_S_I64 = 0xb9, + WASM_INS_F64_CONVERT_U_I64 = 0xba, + WASM_INS_F64_PROMOTE_F32 = 0xbb, + WASM_INS_I32_REINTERPRET_F32 = 0xbc, + WASM_INS_I64_REINTERPRET_F64 = 0xbd, + WASM_INS_F32_REINTERPRET_I32 = 0xbe, + WASM_INS_F64_REINTERPRET_I64 = 0xbf, + WASM_INS_INVALID = 512, + WASM_INS_ENDING, +} wasm_insn; + +/// Group of WASM instructions +typedef enum wasm_insn_group { + WASM_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + WASM_GRP_NUMBERIC = 8, + WASM_GRP_PARAMETRIC, + WASM_GRP_VARIABLE, + WASM_GRP_MEMORY, + WASM_GRP_CONTROL, + + WASM_GRP_ENDING, ///< <-- mark the end of the list of groups +} wasm_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif +#ifndef CAPSTONE_MOS65XX_H +#define CAPSTONE_MOS65XX_H + +/* Capstone Disassembly Engine */ +/* By Sebastian Macke , 2019 */ + +#ifndef CAPSTONE_BPF_H +#define CAPSTONE_BPF_H + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef _MSC_VER +#pragma warning(disable:4201) +#endif + +/// Operand type for instruction's operands +typedef enum bpf_op_type { + BPF_OP_INVALID = 0, + + BPF_OP_REG, + BPF_OP_IMM, + BPF_OP_OFF, + BPF_OP_MEM, + BPF_OP_MMEM, ///< M[k] in cBPF + BPF_OP_MSH, ///< corresponds to cBPF's BPF_MSH mode + BPF_OP_EXT, ///< cBPF's extension (not eBPF) +} bpf_op_type; + +/// BPF registers +typedef enum bpf_reg { + BPF_REG_INVALID = 0, + + ///< cBPF + BPF_REG_A, + BPF_REG_X, + + ///< eBPF + BPF_REG_R0, + BPF_REG_R1, + BPF_REG_R2, + BPF_REG_R3, + BPF_REG_R4, + BPF_REG_R5, + BPF_REG_R6, + BPF_REG_R7, + BPF_REG_R8, + BPF_REG_R9, + BPF_REG_R10, + + BPF_REG_ENDING, +} bpf_reg; + +/// Instruction's operand referring to memory +/// This is associated with BPF_OP_MEM operand type above +typedef struct bpf_op_mem { + bpf_reg base; ///< base register + uint32_t disp; ///< offset value +} bpf_op_mem; + +typedef enum bpf_ext_type { + BPF_EXT_INVALID = 0, + + BPF_EXT_LEN, +} bpf_ext_type; + +/// Instruction operand +typedef struct cs_bpf_op { + bpf_op_type type; + union { + uint8_t reg; ///< register value for REG operand + uint64_t imm; ///< immediate value IMM operand + uint32_t off; ///< offset value, used in jump & call + bpf_op_mem mem; ///< base/disp value for MEM operand + /* cBPF only */ + uint32_t mmem; ///< M[k] in cBPF + uint32_t msh; ///< corresponds to cBPF's BPF_MSH mode + uint32_t ext; ///< cBPF's extension (not eBPF) + }; + + /// How is this operand accessed? (READ, WRITE or READ|WRITE) + /// This field is combined of cs_ac_type. + /// NOTE: this field is irrelevant if engine is compiled in DIET mode. + uint8_t access; +} cs_bpf_op; + +/// Instruction structure +typedef struct cs_bpf { + uint8_t op_count; + cs_bpf_op operands[4]; +} cs_bpf; + +/// BPF instruction +typedef enum bpf_insn { + BPF_INS_INVALID = 0, + + ///< ALU + BPF_INS_ADD, + BPF_INS_SUB, + BPF_INS_MUL, + BPF_INS_DIV, + BPF_INS_OR, + BPF_INS_AND, + BPF_INS_LSH, + BPF_INS_RSH, + BPF_INS_NEG, + BPF_INS_MOD, + BPF_INS_XOR, + BPF_INS_MOV, ///< eBPF only + BPF_INS_ARSH, ///< eBPF only + + ///< ALU64, eBPF only + BPF_INS_ADD64, + BPF_INS_SUB64, + BPF_INS_MUL64, + BPF_INS_DIV64, + BPF_INS_OR64, + BPF_INS_AND64, + BPF_INS_LSH64, + BPF_INS_RSH64, + BPF_INS_NEG64, + BPF_INS_MOD64, + BPF_INS_XOR64, + BPF_INS_MOV64, + BPF_INS_ARSH64, + + ///< Byteswap, eBPF only + BPF_INS_LE16, + BPF_INS_LE32, + BPF_INS_LE64, + BPF_INS_BE16, + BPF_INS_BE32, + BPF_INS_BE64, + + ///< Load + BPF_INS_LDW, ///< eBPF only + BPF_INS_LDH, + BPF_INS_LDB, + BPF_INS_LDDW, ///< eBPF only: load 64-bit imm + BPF_INS_LDXW, ///< eBPF only + BPF_INS_LDXH, ///< eBPF only + BPF_INS_LDXB, ///< eBPF only + BPF_INS_LDXDW, ///< eBPF only + + ///< Store + BPF_INS_STW, ///< eBPF only + BPF_INS_STH, ///< eBPF only + BPF_INS_STB, ///< eBPF only + BPF_INS_STDW, ///< eBPF only + BPF_INS_STXW, ///< eBPF only + BPF_INS_STXH, ///< eBPF only + BPF_INS_STXB, ///< eBPF only + BPF_INS_STXDW, ///< eBPF only + BPF_INS_XADDW, ///< eBPF only + BPF_INS_XADDDW, ///< eBPF only + + ///< Jump + BPF_INS_JMP, + BPF_INS_JEQ, + BPF_INS_JGT, + BPF_INS_JGE, + BPF_INS_JSET, + BPF_INS_JNE, ///< eBPF only + BPF_INS_JSGT, ///< eBPF only + BPF_INS_JSGE, ///< eBPF only + BPF_INS_CALL, ///< eBPF only + BPF_INS_EXIT, ///< eBPF only + BPF_INS_JLT, ///< eBPF only + BPF_INS_JLE, ///< eBPF only + BPF_INS_JSLT, ///< eBPF only + BPF_INS_JSLE, ///< eBPF only + + ///< Return, cBPF only + BPF_INS_RET, + + ///< Misc, cBPF only + BPF_INS_TAX, + BPF_INS_TXA, + + BPF_INS_ENDING, + + // alias instructions + BPF_INS_LD = BPF_INS_LDW, ///< cBPF only + BPF_INS_LDX = BPF_INS_LDXW, ///< cBPF only + BPF_INS_ST = BPF_INS_STW, ///< cBPF only + BPF_INS_STX = BPF_INS_STXW, ///< cBPF only +} bpf_insn; + +/// Group of BPF instructions +typedef enum bpf_insn_group { + BPF_GRP_INVALID = 0, ///< = CS_GRP_INVALID + + BPF_GRP_LOAD, + BPF_GRP_STORE, + BPF_GRP_ALU, + BPF_GRP_JUMP, + BPF_GRP_CALL, ///< eBPF only + BPF_GRP_RETURN, + BPF_GRP_MISC, ///< cBPF only + + BPF_GRP_ENDING, +} bpf_insn_group; + +#ifdef __cplusplus +} +#endif + +#endif + +/// NOTE: All information in cs_detail is only available when CS_OPT_DETAIL = CS_OPT_ON +/// Initialized as memset(., 0, offsetof(cs_detail, ARCH)+sizeof(cs_ARCH)) +/// by ARCH_getInstruction in arch/ARCH/ARCHDisassembler.c +/// if cs_detail changes, in particular if a field is added after the union, +/// then update arch/ARCH/ARCHDisassembler.c accordingly +typedef struct cs_detail { + uint16_t regs_read[16]; ///< list of implicit registers read by this insn + uint8_t regs_read_count; ///< number of implicit registers read by this insn + + uint16_t regs_write[20]; ///< list of implicit registers modified by this insn + uint8_t regs_write_count; ///< number of implicit registers modified by this insn + + uint8_t groups[8]; ///< list of group this instruction belong to + uint8_t groups_count; ///< number of groups this insn belongs to + + /// Architecture-specific instruction info + union { + cs_x86 x86; ///< X86 architecture, including 16-bit, 32-bit & 64-bit mode + cs_arm64 arm64; ///< ARM64 architecture (aka AArch64) + cs_arm arm; ///< ARM architecture (including Thumb/Thumb2) + cs_m68k m68k; ///< M68K architecture + cs_mips mips; ///< MIPS architecture + cs_ppc ppc; ///< PowerPC architecture + cs_sparc sparc; ///< Sparc architecture + cs_sysz sysz; ///< SystemZ architecture + cs_xcore xcore; ///< XCore architecture + cs_tms320c64x tms320c64x; ///< TMS320C64x architecture + cs_m680x m680x; ///< M680X architecture + cs_evm evm; ///< Ethereum architecture + cs_mos65xx mos65xx; ///< MOS65XX architecture (including MOS6502) + cs_wasm wasm; ///< Web Assembly architecture + cs_bpf bpf; ///< Berkeley Packet Filter architecture (including eBPF) + cs_riscv riscv; ///< RISCV architecture + }; +} cs_detail; + +/// Detail information of disassembled instruction +typedef struct cs_insn { + /// Instruction ID (basically a numeric ID for the instruction mnemonic) + /// Find the instruction id in the '[ARCH]_insn' enum in the header file + /// of corresponding architecture, such as 'arm_insn' in arm.h for ARM, + /// 'x86_insn' in x86.h for X86, etc... + /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF + /// NOTE: in Skipdata mode, "data" instruction has 0 for this id field. + unsigned int id; + + /// Address (EIP) of this instruction + /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF + uint64_t address; + + /// Size of this instruction + /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF + uint16_t size; + + /// Machine bytes of this instruction, with number of bytes indicated by @size above + /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF + uint8_t bytes[24]; + + /// Ascii text of instruction mnemonic + /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF + char mnemonic[CS_MNEMONIC_SIZE]; + + /// Ascii text of instruction operands + /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF + char op_str[160]; + + /// Pointer to cs_detail. + /// NOTE: detail pointer is only valid when both requirements below are met: + /// (1) CS_OP_DETAIL = CS_OPT_ON + /// (2) Engine is not in Skipdata mode (CS_OP_SKIPDATA option set to CS_OPT_ON) + /// + /// NOTE 2: when in Skipdata mode, or when detail mode is OFF, even if this pointer + /// is not NULL, its content is still irrelevant. + cs_detail *detail; +} cs_insn; + + +/// Calculate the offset of a disassembled instruction in its buffer, given its position +/// in its array of disassembled insn +/// NOTE: this macro works with position (>=1), not index +#define CS_INSN_OFFSET(insns, post) (insns[post - 1].address - insns[0].address) + + +/// All type of errors encountered by Capstone API. +/// These are values returned by cs_errno() +typedef enum cs_err { + CS_ERR_OK = 0, ///< No error: everything was fine + CS_ERR_MEM, ///< Out-Of-Memory error: cs_open(), cs_disasm(), cs_disasm_iter() + CS_ERR_ARCH, ///< Unsupported architecture: cs_open() + CS_ERR_HANDLE, ///< Invalid handle: cs_op_count(), cs_op_index() + CS_ERR_CSH, ///< Invalid csh argument: cs_close(), cs_errno(), cs_option() + CS_ERR_MODE, ///< Invalid/unsupported mode: cs_open() + CS_ERR_OPTION, ///< Invalid/unsupported option: cs_option() + CS_ERR_DETAIL, ///< Information is unavailable because detail option is OFF + CS_ERR_MEMSETUP, ///< Dynamic memory management uninitialized (see CS_OPT_MEM) + CS_ERR_VERSION, ///< Unsupported version (bindings) + CS_ERR_DIET, ///< Access irrelevant data in "diet" engine + CS_ERR_SKIPDATA, ///< Access irrelevant data for "data" instruction in SKIPDATA mode + CS_ERR_X86_ATT, ///< X86 AT&T syntax is unsupported (opt-out at compile time) + CS_ERR_X86_INTEL, ///< X86 Intel syntax is unsupported (opt-out at compile time) + CS_ERR_X86_MASM, ///< X86 Masm syntax is unsupported (opt-out at compile time) +} cs_err; + +/** + Return combined API version & major and minor version numbers. + + @major: major number of API version + @minor: minor number of API version + + @return hexical number as (major << 8 | minor), which encodes both + major & minor versions. + NOTE: This returned value can be compared with version number made + with macro CS_MAKE_VERSION + + For example, second API version would return 1 in @major, and 1 in @minor + The return value would be 0x0101 + + NOTE: if you only care about returned value, but not major and minor values, + set both @major & @minor arguments to NULL. +*/ +CAPSTONE_EXPORT +unsigned int CAPSTONE_API cs_version(int *major, int *minor); + + +/** + This API can be used to either ask for archs supported by this library, + or check to see if the library was compile with 'diet' option (or called + in 'diet' mode). + + To check if a particular arch is supported by this library, set @query to + arch mode (CS_ARCH_* value). + To verify if this library supports all the archs, use CS_ARCH_ALL. + + To check if this library is in 'diet' mode, set @query to CS_SUPPORT_DIET. + + @return True if this library supports the given arch, or in 'diet' mode. +*/ +CAPSTONE_EXPORT +bool CAPSTONE_API cs_support(int query); + +/** + Initialize CS handle: this must be done before any usage of CS. + + @arch: architecture type (CS_ARCH_*) + @mode: hardware mode. This is combined of CS_MODE_* + @handle: pointer to handle, which will be updated at return time + + @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum + for detailed error). +*/ +CAPSTONE_EXPORT +cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle); + +/** + Close CS handle: MUST do to release the handle when it is not used anymore. + NOTE: this must be only called when there is no longer usage of Capstone, + not even access to cs_insn array. The reason is the this API releases some + cached memory, thus access to any Capstone API after cs_close() might crash + your application. + + In fact,this API invalidate @handle by ZERO out its value (i.e *handle = 0). + + @handle: pointer to a handle returned by cs_open() + + @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum + for detailed error). +*/ +CAPSTONE_EXPORT +cs_err CAPSTONE_API cs_close(csh *handle); + +/** + Set option for disassembling engine at runtime + + @handle: handle returned by cs_open() + @type: type of option to be set + @value: option value corresponding with @type + + @return: CS_ERR_OK on success, or other value on failure. + Refer to cs_err enum for detailed error. + + NOTE: in the case of CS_OPT_MEM, handle's value can be anything, + so that cs_option(handle, CS_OPT_MEM, value) can (i.e must) be called + even before cs_open() +*/ +CAPSTONE_EXPORT +cs_err CAPSTONE_API cs_option(csh handle, cs_opt_type type, size_t value); + +/** + Report the last error number when some API function fail. + Like glibc's errno, cs_errno might not retain its old value once accessed. + + @handle: handle returned by cs_open() + + @return: error code of cs_err enum type (CS_ERR_*, see above) +*/ +CAPSTONE_EXPORT +cs_err CAPSTONE_API cs_errno(csh handle); + + +/** + Return a string describing given error code. + + @code: error code (see CS_ERR_* above) + + @return: returns a pointer to a string that describes the error code + passed in the argument @code +*/ +CAPSTONE_EXPORT +const char * CAPSTONE_API cs_strerror(cs_err code); + +/** + Disassemble binary code, given the code buffer, size, address and number + of instructions to be decoded. + This API dynamically allocate memory to contain disassembled instruction. + Resulting instructions will be put into @*insn + + NOTE 1: this API will automatically determine memory needed to contain + output disassembled instructions in @insn. + + NOTE 2: caller must free the allocated memory itself to avoid memory leaking. + + NOTE 3: for system with scarce memory to be dynamically allocated such as + OS kernel or firmware, the API cs_disasm_iter() might be a better choice than + cs_disasm(). The reason is that with cs_disasm(), based on limited available + memory, we have to calculate in advance how many instructions to be disassembled, + which complicates things. This is especially troublesome for the case @count=0, + when cs_disasm() runs uncontrollably (until either end of input buffer, or + when it encounters an invalid instruction). + + @handle: handle returned by cs_open() + @code: buffer containing raw binary code to be disassembled. + @code_size: size of the above code buffer. + @address: address of the first instruction in given raw code buffer. + @insn: array of instructions filled in by this API. + NOTE: @insn will be allocated by this function, and should be freed + with cs_free() API. + @count: number of instructions to be disassembled, or 0 to get all of them + + @return: the number of successfully disassembled instructions, + or 0 if this function failed to disassemble the given code + + On failure, call cs_errno() for error code. +*/ +CAPSTONE_EXPORT +size_t CAPSTONE_API cs_disasm(csh handle, + const uint8_t *code, size_t code_size, + uint64_t address, + size_t count, + cs_insn **insn); + +/** + Free memory allocated by cs_malloc() or cs_disasm() (argument @insn) + + @insn: pointer returned by @insn argument in cs_disasm() or cs_malloc() + @count: number of cs_insn structures returned by cs_disasm(), or 1 + to free memory allocated by cs_malloc(). +*/ +CAPSTONE_EXPORT +void CAPSTONE_API cs_free(cs_insn *insn, size_t count); + + +/** + Allocate memory for 1 instruction to be used by cs_disasm_iter(). + + @handle: handle returned by cs_open() + + NOTE: when no longer in use, you can reclaim the memory allocated for + this instruction with cs_free(insn, 1) +*/ +CAPSTONE_EXPORT +cs_insn * CAPSTONE_API cs_malloc(csh handle); + +/** + Fast API to disassemble binary code, given the code buffer, size, address + and number of instructions to be decoded. + This API puts the resulting instruction into a given cache in @insn. + See tests/test_iter.c for sample code demonstrating this API. + + NOTE 1: this API will update @code, @size & @address to point to the next + instruction in the input buffer. Therefore, it is convenient to use + cs_disasm_iter() inside a loop to quickly iterate all the instructions. + While decoding one instruction at a time can also be achieved with + cs_disasm(count=1), some benchmarks shown that cs_disasm_iter() can be 30% + faster on random input. + + NOTE 2: the cache in @insn can be created with cs_malloc() API. + + NOTE 3: for system with scarce memory to be dynamically allocated such as + OS kernel or firmware, this API is recommended over cs_disasm(), which + allocates memory based on the number of instructions to be disassembled. + The reason is that with cs_disasm(), based on limited available memory, + we have to calculate in advance how many instructions to be disassembled, + which complicates things. This is especially troublesome for the case + @count=0, when cs_disasm() runs uncontrollably (until either end of input + buffer, or when it encounters an invalid instruction). + + @handle: handle returned by cs_open() + @code: buffer containing raw binary code to be disassembled + @size: size of above code + @address: address of the first insn in given raw code buffer + @insn: pointer to instruction to be filled in by this API. + + @return: true if this API successfully decode 1 instruction, + or false otherwise. + + On failure, call cs_errno() for error code. +*/ +CAPSTONE_EXPORT +bool CAPSTONE_API cs_disasm_iter(csh handle, + const uint8_t **code, size_t *size, + uint64_t *address, cs_insn *insn); + +/** + Return friendly name of register in a string. + Find the instruction id from header file of corresponding architecture (arm.h for ARM, + x86.h for X86, ...) + + WARN: when in 'diet' mode, this API is irrelevant because engine does not + store register name. + + @handle: handle returned by cs_open() + @reg_id: register id + + @return: string name of the register, or NULL if @reg_id is invalid. +*/ +CAPSTONE_EXPORT +const char * CAPSTONE_API cs_reg_name(csh handle, unsigned int reg_id); + +/** + Return friendly name of an instruction in a string. + Find the instruction id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) + + WARN: when in 'diet' mode, this API is irrelevant because the engine does not + store instruction name. + + @handle: handle returned by cs_open() + @insn_id: instruction id + + @return: string name of the instruction, or NULL if @insn_id is invalid. +*/ +CAPSTONE_EXPORT +const char * CAPSTONE_API cs_insn_name(csh handle, unsigned int insn_id); + +/** + Return friendly name of a group id (that an instruction can belong to) + Find the group id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) + + WARN: when in 'diet' mode, this API is irrelevant because the engine does not + store group name. + + @handle: handle returned by cs_open() + @group_id: group id + + @return: string name of the group, or NULL if @group_id is invalid. +*/ +CAPSTONE_EXPORT +const char * CAPSTONE_API cs_group_name(csh handle, unsigned int group_id); + +/** + Check if a disassembled instruction belong to a particular group. + Find the group id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) + Internally, this simply verifies if @group_id matches any member of insn->groups array. + + NOTE: this API is only valid when detail option is ON (which is OFF by default). + + WARN: when in 'diet' mode, this API is irrelevant because the engine does not + update @groups array. + + @handle: handle returned by cs_open() + @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() + @group_id: group that you want to check if this instruction belong to. + + @return: true if this instruction indeed belongs to the given group, or false otherwise. +*/ +CAPSTONE_EXPORT +bool CAPSTONE_API cs_insn_group(csh handle, const cs_insn *insn, unsigned int group_id); + +/** + Check if a disassembled instruction IMPLICITLY used a particular register. + Find the register id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) + Internally, this simply verifies if @reg_id matches any member of insn->regs_read array. + + NOTE: this API is only valid when detail option is ON (which is OFF by default) + + WARN: when in 'diet' mode, this API is irrelevant because the engine does not + update @regs_read array. + + @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() + @reg_id: register that you want to check if this instruction used it. + + @return: true if this instruction indeed implicitly used the given register, or false otherwise. +*/ +CAPSTONE_EXPORT +bool CAPSTONE_API cs_reg_read(csh handle, const cs_insn *insn, unsigned int reg_id); + +/** + Check if a disassembled instruction IMPLICITLY modified a particular register. + Find the register id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) + Internally, this simply verifies if @reg_id matches any member of insn->regs_write array. + + NOTE: this API is only valid when detail option is ON (which is OFF by default) + + WARN: when in 'diet' mode, this API is irrelevant because the engine does not + update @regs_write array. + + @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() + @reg_id: register that you want to check if this instruction modified it. + + @return: true if this instruction indeed implicitly modified the given register, or false otherwise. +*/ +CAPSTONE_EXPORT +bool CAPSTONE_API cs_reg_write(csh handle, const cs_insn *insn, unsigned int reg_id); + +/** + Count the number of operands of a given type. + Find the operand type in header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) + + NOTE: this API is only valid when detail option is ON (which is OFF by default) + + @handle: handle returned by cs_open() + @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() + @op_type: Operand type to be found. + + @return: number of operands of given type @op_type in instruction @insn, + or -1 on failure. +*/ +CAPSTONE_EXPORT +int CAPSTONE_API cs_op_count(csh handle, const cs_insn *insn, unsigned int op_type); + +/** + Retrieve the position of operand of given type in .operands[] array. + Later, the operand can be accessed using the returned position. + Find the operand type in header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) + + NOTE: this API is only valid when detail option is ON (which is OFF by default) + + @handle: handle returned by cs_open() + @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() + @op_type: Operand type to be found. + @position: position of the operand to be found. This must be in the range + [1, cs_op_count(handle, insn, op_type)] + + @return: index of operand of given type @op_type in .operands[] array + in instruction @insn, or -1 on failure. +*/ +CAPSTONE_EXPORT +int CAPSTONE_API cs_op_index(csh handle, const cs_insn *insn, unsigned int op_type, + unsigned int position); + +/// Type of array to keep the list of registers +typedef uint16_t cs_regs[64]; + +/** + Retrieve all the registers accessed by an instruction, either explicitly or + implicitly. + + WARN: when in 'diet' mode, this API is irrelevant because engine does not + store registers. + + @handle: handle returned by cs_open() + @insn: disassembled instruction structure returned from cs_disasm() or cs_disasm_iter() + @regs_read: on return, this array contains all registers read by instruction. + @regs_read_count: number of registers kept inside @regs_read array. + @regs_write: on return, this array contains all registers written by instruction. + @regs_write_count: number of registers kept inside @regs_write array. + + @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum + for detailed error). +*/ +CAPSTONE_EXPORT +cs_err CAPSTONE_API cs_regs_access(csh handle, const cs_insn *insn, + cs_regs regs_read, uint8_t *regs_read_count, + cs_regs regs_write, uint8_t *regs_write_count); + +#ifdef __cplusplus +} +#endif + +#endif +/* + * Copyright (C) 2009-2019 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_X86_WRITER_H__ +#define __GUM_X86_WRITER_H__ + + + +G_BEGIN_DECLS + +typedef struct _GumX86Writer GumX86Writer; +typedef guint GumCpuReg; +typedef guint GumPtrTarget; + +struct _GumX86Writer +{ + volatile gint ref_count; + + GumCpuType target_cpu; + GumAbiType target_abi; + + guint8 * base; + guint8 * code; + GumAddress pc; + + GumMetalHashTable * label_defs; + GumMetalArray label_refs; +}; + +enum _GumCpuReg +{ + /* 32 bit */ + GUM_REG_EAX = 0, + GUM_REG_ECX, + GUM_REG_EDX, + GUM_REG_EBX, + GUM_REG_ESP, + GUM_REG_EBP, + GUM_REG_ESI, + GUM_REG_EDI, + + GUM_REG_R8D, + GUM_REG_R9D, + GUM_REG_R10D, + GUM_REG_R11D, + GUM_REG_R12D, + GUM_REG_R13D, + GUM_REG_R14D, + GUM_REG_R15D, + + GUM_REG_EIP, + + /* 64 bit */ + GUM_REG_RAX, + GUM_REG_RCX, + GUM_REG_RDX, + GUM_REG_RBX, + GUM_REG_RSP, + GUM_REG_RBP, + GUM_REG_RSI, + GUM_REG_RDI, + + GUM_REG_R8, + GUM_REG_R9, + GUM_REG_R10, + GUM_REG_R11, + GUM_REG_R12, + GUM_REG_R13, + GUM_REG_R14, + GUM_REG_R15, + + GUM_REG_RIP, + + /* Meta */ + GUM_REG_XAX, + GUM_REG_XCX, + GUM_REG_XDX, + GUM_REG_XBX, + GUM_REG_XSP, + GUM_REG_XBP, + GUM_REG_XSI, + GUM_REG_XDI, + + GUM_REG_XIP, + + GUM_REG_NONE +}; + +enum _GumPtrTarget +{ + GUM_PTR_BYTE, + GUM_PTR_DWORD, + GUM_PTR_QWORD +}; + +GUM_API GumX86Writer * gum_x86_writer_new (gpointer code_address); +GUM_API GumX86Writer * gum_x86_writer_ref (GumX86Writer * writer); +GUM_API void gum_x86_writer_unref (GumX86Writer * writer); + +GUM_API void gum_x86_writer_init (GumX86Writer * writer, + gpointer code_address); +GUM_API void gum_x86_writer_clear (GumX86Writer * writer); + +GUM_API void gum_x86_writer_reset (GumX86Writer * writer, + gpointer code_address); +GUM_API void gum_x86_writer_set_target_cpu (GumX86Writer * self, + GumCpuType cpu_type); +GUM_API void gum_x86_writer_set_target_abi (GumX86Writer * self, + GumAbiType abi_type); + +GUM_API gpointer gum_x86_writer_cur (GumX86Writer * self); +GUM_API guint gum_x86_writer_offset (GumX86Writer * self); + +GUM_API gboolean gum_x86_writer_flush (GumX86Writer * self); + +GUM_API GumCpuReg gum_x86_writer_get_cpu_register_for_nth_argument ( + GumX86Writer * self, guint n); + +GUM_API gboolean gum_x86_writer_put_label (GumX86Writer * self, + gconstpointer id); + +GUM_API gboolean gum_x86_writer_can_branch_directly_between (GumAddress from, + GumAddress to); +GUM_API gboolean gum_x86_writer_put_call_address_with_arguments ( + GumX86Writer * self, GumCallingConvention conv, GumAddress func, + guint n_args, ...); +GUM_API gboolean gum_x86_writer_put_call_address_with_arguments_array ( + GumX86Writer * self, GumCallingConvention conv, GumAddress func, + guint n_args, const GumArgument * args); +GUM_API gboolean gum_x86_writer_put_call_address_with_aligned_arguments ( + GumX86Writer * self, GumCallingConvention conv, GumAddress func, + guint n_args, ...); +GUM_API gboolean gum_x86_writer_put_call_address_with_aligned_arguments_array ( + GumX86Writer * self, GumCallingConvention conv, GumAddress func, + guint n_args, const GumArgument * args); +GUM_API gboolean gum_x86_writer_put_call_reg_with_arguments ( + GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, + guint n_args, ...); +GUM_API gboolean gum_x86_writer_put_call_reg_with_arguments_array ( + GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, + guint n_args, const GumArgument * args); +GUM_API gboolean gum_x86_writer_put_call_reg_with_aligned_arguments ( + GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, + guint n_args, ...); +GUM_API gboolean gum_x86_writer_put_call_reg_with_aligned_arguments_array ( + GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, + guint n_args, const GumArgument * args); +GUM_API gboolean gum_x86_writer_put_call_reg_offset_ptr_with_arguments ( + GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, + gssize offset, guint n_args, ...); +GUM_API gboolean gum_x86_writer_put_call_reg_offset_ptr_with_arguments_array ( + GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, + gssize offset, guint n_args, const GumArgument * args); +GUM_API gboolean gum_x86_writer_put_call_reg_offset_ptr_with_aligned_arguments ( + GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, + gssize offset, guint n_args, ...); +GUM_API gboolean + gum_x86_writer_put_call_reg_offset_ptr_with_aligned_arguments_array ( + GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, + gssize offset, guint n_args, const GumArgument * args); +GUM_API gboolean gum_x86_writer_put_call_address (GumX86Writer * self, + GumAddress address); +GUM_API gboolean gum_x86_writer_put_call_reg (GumX86Writer * self, + GumCpuReg reg); +GUM_API gboolean gum_x86_writer_put_call_reg_offset_ptr (GumX86Writer * self, + GumCpuReg reg, gssize offset); +GUM_API gboolean gum_x86_writer_put_call_indirect (GumX86Writer * self, + GumAddress addr); +GUM_API gboolean gum_x86_writer_put_call_indirect_label (GumX86Writer * self, + gconstpointer label_id); +GUM_API void gum_x86_writer_put_call_near_label (GumX86Writer * self, + gconstpointer label_id); +GUM_API void gum_x86_writer_put_leave (GumX86Writer * self); +GUM_API void gum_x86_writer_put_ret (GumX86Writer * self); +GUM_API void gum_x86_writer_put_ret_imm (GumX86Writer * self, + guint16 imm_value); +GUM_API gboolean gum_x86_writer_put_jmp_address (GumX86Writer * self, + GumAddress address); +GUM_API void gum_x86_writer_put_jmp_short_label (GumX86Writer * self, + gconstpointer label_id); +GUM_API void gum_x86_writer_put_jmp_near_label (GumX86Writer * self, + gconstpointer label_id); +GUM_API gboolean gum_x86_writer_put_jmp_reg (GumX86Writer * self, + GumCpuReg reg); +GUM_API gboolean gum_x86_writer_put_jmp_reg_ptr (GumX86Writer * self, + GumCpuReg reg); +GUM_API gboolean gum_x86_writer_put_jmp_reg_offset_ptr (GumX86Writer * self, + GumCpuReg reg, gssize offset); +GUM_API gboolean gum_x86_writer_put_jmp_near_ptr (GumX86Writer * self, + GumAddress address); +GUM_API gboolean gum_x86_writer_put_jcc_short (GumX86Writer * self, + x86_insn instruction_id, gconstpointer target, GumBranchHint hint); +GUM_API gboolean gum_x86_writer_put_jcc_near (GumX86Writer * self, + x86_insn instruction_id, gconstpointer target, GumBranchHint hint); +GUM_API void gum_x86_writer_put_jcc_short_label (GumX86Writer * self, + x86_insn instruction_id, gconstpointer label_id, GumBranchHint hint); +GUM_API void gum_x86_writer_put_jcc_near_label (GumX86Writer * self, + x86_insn instruction_id, gconstpointer label_id, GumBranchHint hint); + +GUM_API gboolean gum_x86_writer_put_add_reg_imm (GumX86Writer * self, + GumCpuReg reg, gssize imm_value); +GUM_API gboolean gum_x86_writer_put_add_reg_reg (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_add_reg_near_ptr (GumX86Writer * self, + GumCpuReg dst_reg, GumAddress src_address); +GUM_API gboolean gum_x86_writer_put_sub_reg_imm (GumX86Writer * self, + GumCpuReg reg, gssize imm_value); +GUM_API gboolean gum_x86_writer_put_sub_reg_reg (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_sub_reg_near_ptr (GumX86Writer * self, + GumCpuReg dst_reg, GumAddress src_address); +GUM_API gboolean gum_x86_writer_put_inc_reg (GumX86Writer * self, + GumCpuReg reg); +GUM_API gboolean gum_x86_writer_put_dec_reg (GumX86Writer * self, + GumCpuReg reg); +GUM_API gboolean gum_x86_writer_put_inc_reg_ptr (GumX86Writer * self, + GumPtrTarget target, GumCpuReg reg); +GUM_API gboolean gum_x86_writer_put_dec_reg_ptr (GumX86Writer * self, + GumPtrTarget target, GumCpuReg reg); +GUM_API gboolean gum_x86_writer_put_lock_xadd_reg_ptr_reg (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_lock_cmpxchg_reg_ptr_reg ( + GumX86Writer * self, GumCpuReg dst_reg, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_lock_inc_imm32_ptr (GumX86Writer * self, + gpointer target); +GUM_API gboolean gum_x86_writer_put_lock_dec_imm32_ptr (GumX86Writer * self, + gpointer target); + +GUM_API gboolean gum_x86_writer_put_and_reg_reg (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_and_reg_u32 (GumX86Writer * self, + GumCpuReg reg, guint32 imm_value); +GUM_API gboolean gum_x86_writer_put_shl_reg_u8 (GumX86Writer * self, + GumCpuReg reg, guint8 imm_value); +GUM_API gboolean gum_x86_writer_put_shr_reg_u8 (GumX86Writer * self, + GumCpuReg reg, guint8 imm_value); +GUM_API gboolean gum_x86_writer_put_xor_reg_reg (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg); + +GUM_API gboolean gum_x86_writer_put_mov_reg_reg (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_mov_reg_u32 (GumX86Writer * self, + GumCpuReg dst_reg, guint32 imm_value); +GUM_API gboolean gum_x86_writer_put_mov_reg_u64 (GumX86Writer * self, + GumCpuReg dst_reg, guint64 imm_value); +GUM_API void gum_x86_writer_put_mov_reg_address (GumX86Writer * self, + GumCpuReg dst_reg, GumAddress address); +GUM_API void gum_x86_writer_put_mov_reg_ptr_u32 (GumX86Writer * self, + GumCpuReg dst_reg, guint32 imm_value); +GUM_API gboolean gum_x86_writer_put_mov_reg_offset_ptr_u32 (GumX86Writer * self, + GumCpuReg dst_reg, gssize dst_offset, guint32 imm_value); +GUM_API void gum_x86_writer_put_mov_reg_ptr_reg (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_mov_reg_offset_ptr_reg (GumX86Writer * self, + GumCpuReg dst_reg, gssize dst_offset, GumCpuReg src_reg); +GUM_API void gum_x86_writer_put_mov_reg_reg_ptr (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_mov_reg_reg_offset_ptr (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg, gssize src_offset); +GUM_API gboolean gum_x86_writer_put_mov_reg_base_index_scale_offset_ptr ( + GumX86Writer * self, GumCpuReg dst_reg, GumCpuReg base_reg, + GumCpuReg index_reg, guint8 scale, gssize offset); + +GUM_API gboolean gum_x86_writer_put_mov_reg_near_ptr (GumX86Writer * self, + GumCpuReg dst_reg, GumAddress src_address); +GUM_API gboolean gum_x86_writer_put_mov_near_ptr_reg (GumX86Writer * self, + GumAddress dst_address, GumCpuReg src_reg); + +GUM_API gboolean gum_x86_writer_put_mov_fs_u32_ptr_reg (GumX86Writer * self, + guint32 fs_offset, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_mov_reg_fs_u32_ptr (GumX86Writer * self, + GumCpuReg dst_reg, guint32 fs_offset); +GUM_API gboolean gum_x86_writer_put_mov_gs_u32_ptr_reg (GumX86Writer * self, + guint32 fs_offset, GumCpuReg src_reg); +GUM_API gboolean gum_x86_writer_put_mov_reg_gs_u32_ptr (GumX86Writer * self, + GumCpuReg dst_reg, guint32 fs_offset); + +GUM_API void gum_x86_writer_put_movq_xmm0_esp_offset_ptr (GumX86Writer * self, + gint8 offset); +GUM_API void gum_x86_writer_put_movq_eax_offset_ptr_xmm0 (GumX86Writer * self, + gint8 offset); +GUM_API void gum_x86_writer_put_movdqu_xmm0_esp_offset_ptr (GumX86Writer * self, + gint8 offset); +GUM_API void gum_x86_writer_put_movdqu_eax_offset_ptr_xmm0 (GumX86Writer * self, + gint8 offset); + +GUM_API gboolean gum_x86_writer_put_lea_reg_reg_offset (GumX86Writer * self, + GumCpuReg dst_reg, GumCpuReg src_reg, gssize src_offset); + +GUM_API gboolean gum_x86_writer_put_xchg_reg_reg_ptr (GumX86Writer * self, + GumCpuReg left_reg, GumCpuReg right_reg); + +GUM_API void gum_x86_writer_put_push_u32 (GumX86Writer * self, + guint32 imm_value); +GUM_API gboolean gum_x86_writer_put_push_near_ptr (GumX86Writer * self, + GumAddress address); +GUM_API gboolean gum_x86_writer_put_push_reg (GumX86Writer * self, + GumCpuReg reg); +GUM_API gboolean gum_x86_writer_put_pop_reg (GumX86Writer * self, + GumCpuReg reg); +GUM_API void gum_x86_writer_put_push_imm_ptr (GumX86Writer * self, + gconstpointer imm_ptr); +GUM_API void gum_x86_writer_put_pushax (GumX86Writer * self); +GUM_API void gum_x86_writer_put_popax (GumX86Writer * self); +GUM_API void gum_x86_writer_put_pushfx (GumX86Writer * self); +GUM_API void gum_x86_writer_put_popfx (GumX86Writer * self); + +GUM_API gboolean gum_x86_writer_put_test_reg_reg (GumX86Writer * self, + GumCpuReg reg_a, GumCpuReg reg_b); +GUM_API gboolean gum_x86_writer_put_test_reg_u32 (GumX86Writer * self, + GumCpuReg reg, guint32 imm_value); +GUM_API gboolean gum_x86_writer_put_cmp_reg_i32 (GumX86Writer * self, + GumCpuReg reg, gint32 imm_value); +GUM_API gboolean gum_x86_writer_put_cmp_reg_offset_ptr_reg (GumX86Writer * self, + GumCpuReg reg_a, gssize offset, GumCpuReg reg_b); +GUM_API void gum_x86_writer_put_cmp_imm_ptr_imm_u32 (GumX86Writer * self, + gconstpointer imm_ptr, guint32 imm_value); +GUM_API gboolean gum_x86_writer_put_cmp_reg_reg (GumX86Writer * self, + GumCpuReg reg_a, GumCpuReg reg_b); +GUM_API void gum_x86_writer_put_clc (GumX86Writer * self); +GUM_API void gum_x86_writer_put_stc (GumX86Writer * self); +GUM_API void gum_x86_writer_put_cld (GumX86Writer * self); +GUM_API void gum_x86_writer_put_std (GumX86Writer * self); + +GUM_API void gum_x86_writer_put_cpuid (GumX86Writer * self); +GUM_API void gum_x86_writer_put_lfence (GumX86Writer * self); +GUM_API void gum_x86_writer_put_rdtsc (GumX86Writer * self); +GUM_API void gum_x86_writer_put_pause (GumX86Writer * self); +GUM_API void gum_x86_writer_put_nop (GumX86Writer * self); +GUM_API void gum_x86_writer_put_breakpoint (GumX86Writer * self); +GUM_API void gum_x86_writer_put_padding (GumX86Writer * self, guint n); +GUM_API void gum_x86_writer_put_nop_padding (GumX86Writer * self, guint n); + +GUM_API void gum_x86_writer_put_u8 (GumX86Writer * self, guint8 value); +GUM_API void gum_x86_writer_put_s8 (GumX86Writer * self, gint8 value); +GUM_API void gum_x86_writer_put_bytes (GumX86Writer * self, const guint8 * data, + guint n); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2010-2020 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_ARM_WRITER_H__ +#define __GUM_ARM_WRITER_H__ + + +#define GUM_ARM_B_MAX_DISTANCE 0x01fffffc + +G_BEGIN_DECLS + +typedef struct _GumArmWriter GumArmWriter; + +struct _GumArmWriter +{ + volatile gint ref_count; + + GumOS target_os; + + guint32 * base; + guint32 * code; + GumAddress pc; + + GumMetalHashTable * label_defs; + GumMetalArray label_refs; + GumMetalArray literal_refs; + const guint32 * earliest_literal_insn; +}; + +GUM_API GumArmWriter * gum_arm_writer_new (gpointer code_address); +GUM_API GumArmWriter * gum_arm_writer_ref (GumArmWriter * writer); +GUM_API void gum_arm_writer_unref (GumArmWriter * writer); + +GUM_API void gum_arm_writer_init (GumArmWriter * writer, gpointer code_address); +GUM_API void gum_arm_writer_clear (GumArmWriter * writer); + +GUM_API void gum_arm_writer_reset (GumArmWriter * writer, + gpointer code_address); +GUM_API void gum_arm_writer_set_target_os (GumArmWriter * self, GumOS os); + +GUM_API gpointer gum_arm_writer_cur (GumArmWriter * self); +GUM_API guint gum_arm_writer_offset (GumArmWriter * self); +GUM_API void gum_arm_writer_skip (GumArmWriter * self, guint n_bytes); + +GUM_API gboolean gum_arm_writer_flush (GumArmWriter * self); + +GUM_API gboolean gum_arm_writer_put_label (GumArmWriter * self, + gconstpointer id); + +GUM_API void gum_arm_writer_put_call_address_with_arguments ( + GumArmWriter * self, GumAddress func, guint n_args, ...); +GUM_API void gum_arm_writer_put_call_address_with_arguments_array ( + GumArmWriter * self, GumAddress func, guint n_args, + const GumArgument * args); + +GUM_API void gum_arm_writer_put_branch_address (GumArmWriter * self, + GumAddress address); + +GUM_API gboolean gum_arm_writer_can_branch_directly_between ( + GumArmWriter * self, GumAddress from, GumAddress to); +GUM_API gboolean gum_arm_writer_put_b_imm (GumArmWriter * self, + GumAddress target); +GUM_API gboolean gum_arm_writer_put_b_cond_imm (GumArmWriter * self, + arm_cc cc, GumAddress target); +GUM_API void gum_arm_writer_put_b_label (GumArmWriter * self, + gconstpointer label_id); +GUM_API void gum_arm_writer_put_b_cond_label (GumArmWriter * self, + arm_cc cc, gconstpointer label_id); +GUM_API gboolean gum_arm_writer_put_bl_imm (GumArmWriter * self, + GumAddress target); +GUM_API gboolean gum_arm_writer_put_blx_imm (GumArmWriter * self, + GumAddress target); +GUM_API void gum_arm_writer_put_bl_label (GumArmWriter * self, + gconstpointer label_id); +GUM_API void gum_arm_writer_put_bx_reg (GumArmWriter * self, arm_reg reg); +GUM_API void gum_arm_writer_put_blx_reg (GumArmWriter * self, arm_reg reg); +GUM_API void gum_arm_writer_put_ret (GumArmWriter * self); + +GUM_API void gum_arm_writer_put_push_registers (GumArmWriter * self, guint n, + ...); +GUM_API void gum_arm_writer_put_pop_registers (GumArmWriter * self, guint n, + ...); + +GUM_API gboolean gum_arm_writer_put_ldr_reg_address (GumArmWriter * self, + arm_reg reg, GumAddress address); +GUM_API gboolean gum_arm_writer_put_ldr_reg_u32 (GumArmWriter * self, + arm_reg reg, guint32 val); +GUM_API gboolean gum_arm_writer_put_ldr_reg_reg_offset (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg, gssize src_offset); +GUM_API gboolean gum_arm_writer_put_ldr_cond_reg_reg_offset ( + GumArmWriter * self, arm_cc cc, arm_reg dst_reg, arm_reg src_reg, + gssize src_offset); +GUM_API void gum_arm_writer_put_ldmia_reg_mask (GumArmWriter * self, + arm_reg reg, guint16 mask); +GUM_API gboolean gum_arm_writer_put_str_reg_reg_offset ( + GumArmWriter * self, arm_reg src_reg, arm_reg dst_reg, + gssize dst_offset); +GUM_API gboolean gum_arm_writer_put_str_cond_reg_reg_offset ( + GumArmWriter * self, arm_cc cc, arm_reg src_reg, + arm_reg dst_reg, gssize dst_offset); +GUM_API void gum_arm_writer_put_mov_reg_reg (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg); +GUM_API void gum_arm_writer_put_mov_reg_reg_shift (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg, arm_shifter shift, + guint16 shift_value); +GUM_API void gum_arm_writer_put_mov_reg_cpsr (GumArmWriter * self, arm_reg reg); +GUM_API void gum_arm_writer_put_mov_cpsr_reg (GumArmWriter * self, arm_reg reg); +GUM_API void gum_arm_writer_put_add_reg_u16 (GumArmWriter * self, + arm_reg dst_reg, guint16 val); +GUM_API void gum_arm_writer_put_add_reg_u32 (GumArmWriter * self, + arm_reg dst_reg, guint32 val); +GUM_API void gum_arm_writer_put_add_reg_reg_imm (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg, guint32 imm_val); +GUM_API void gum_arm_writer_put_add_reg_reg_reg (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg1, arm_reg src_reg2); +GUM_API void gum_arm_writer_put_add_reg_reg_reg_shift (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg1, arm_reg src_reg2, arm_shifter shift, + guint16 shift_value); +GUM_API void gum_arm_writer_put_sub_reg_u16 (GumArmWriter * self, + arm_reg dst_reg, guint16 val); +GUM_API void gum_arm_writer_put_sub_reg_u32 (GumArmWriter * self, + arm_reg dst_reg, guint32 val); +GUM_API void gum_arm_writer_put_sub_reg_reg_imm (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg, guint32 imm_val); +GUM_API void gum_arm_writer_put_sub_reg_reg_reg (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg1, arm_reg src_reg2); +GUM_API void gum_arm_writer_put_rsb_reg_reg_imm (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg, guint32 imm_val); +GUM_API void gum_arm_writer_put_ands_reg_reg_imm (GumArmWriter * self, + arm_reg dst_reg, arm_reg src_reg, guint32 imm_val); +GUM_API void gum_arm_writer_put_cmp_reg_imm (GumArmWriter * self, + arm_reg dst_reg, guint32 imm_val); + +GUM_API void gum_arm_writer_put_nop (GumArmWriter * self); +GUM_API void gum_arm_writer_put_breakpoint (GumArmWriter * self); +GUM_API void gum_arm_writer_put_brk_imm (GumArmWriter * self, + guint16 imm); + +GUM_API void gum_arm_writer_put_instruction (GumArmWriter * self, guint32 insn); +GUM_API gboolean gum_arm_writer_put_bytes (GumArmWriter * self, + const guint8 * data, guint n); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2010-2019 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_THUMB_WRITER_H__ +#define __GUM_THUMB_WRITER_H__ + + +#define GUM_THUMB_B_MAX_DISTANCE 0x00fffffe + +G_BEGIN_DECLS + +typedef struct _GumThumbWriter GumThumbWriter; + +struct _GumThumbWriter +{ + volatile gint ref_count; + + GumOS target_os; + + guint16 * base; + guint16 * code; + GumAddress pc; + + GumMetalHashTable * label_defs; + GumMetalArray label_refs; + GumMetalArray literal_refs; + const guint16 * earliest_literal_insn; +}; + +GUM_API GumThumbWriter * gum_thumb_writer_new (gpointer code_address); +GUM_API GumThumbWriter * gum_thumb_writer_ref (GumThumbWriter * writer); +GUM_API void gum_thumb_writer_unref (GumThumbWriter * writer); + +GUM_API void gum_thumb_writer_init (GumThumbWriter * writer, + gpointer code_address); +GUM_API void gum_thumb_writer_clear (GumThumbWriter * writer); + +GUM_API void gum_thumb_writer_reset (GumThumbWriter * writer, + gpointer code_address); +GUM_API void gum_thumb_writer_set_target_os (GumThumbWriter * self, GumOS os); + +GUM_API gpointer gum_thumb_writer_cur (GumThumbWriter * self); +GUM_API guint gum_thumb_writer_offset (GumThumbWriter * self); +GUM_API void gum_thumb_writer_skip (GumThumbWriter * self, guint n_bytes); + +GUM_API gboolean gum_thumb_writer_flush (GumThumbWriter * self); + +GUM_API gboolean gum_thumb_writer_put_label (GumThumbWriter * self, + gconstpointer id); +GUM_API gboolean gum_thumb_writer_commit_label (GumThumbWriter * self, + gconstpointer id); + +GUM_API void gum_thumb_writer_put_call_address_with_arguments ( + GumThumbWriter * self, GumAddress func, guint n_args, ...); +GUM_API void gum_thumb_writer_put_call_address_with_arguments_array ( + GumThumbWriter * self, GumAddress func, guint n_args, + const GumArgument * args); +GUM_API void gum_thumb_writer_put_call_reg_with_arguments ( + GumThumbWriter * self, arm_reg reg, guint n_args, ...); +GUM_API void gum_thumb_writer_put_call_reg_with_arguments_array ( + GumThumbWriter * self, arm_reg reg, guint n_args, const GumArgument * args); + +GUM_API void gum_thumb_writer_put_branch_address (GumThumbWriter * self, + GumAddress address); + +GUM_API gboolean gum_thumb_writer_can_branch_directly_between ( + GumThumbWriter * self, GumAddress from, GumAddress to); +GUM_API void gum_thumb_writer_put_b_imm (GumThumbWriter * self, + GumAddress target); +GUM_API void gum_thumb_writer_put_b_label (GumThumbWriter * self, + gconstpointer label_id); +GUM_API void gum_thumb_writer_put_b_label_wide (GumThumbWriter * self, + gconstpointer label_id); +GUM_API void gum_thumb_writer_put_bx_reg (GumThumbWriter * self, arm_reg reg); +GUM_API void gum_thumb_writer_put_bl_imm (GumThumbWriter * self, + GumAddress target); +GUM_API void gum_thumb_writer_put_bl_label (GumThumbWriter * self, + gconstpointer label_id); +GUM_API void gum_thumb_writer_put_blx_imm (GumThumbWriter * self, + GumAddress target); +GUM_API void gum_thumb_writer_put_blx_reg (GumThumbWriter * self, arm_reg reg); +GUM_API void gum_thumb_writer_put_cmp_reg_imm (GumThumbWriter * self, + arm_reg reg, guint8 imm_value); +GUM_API void gum_thumb_writer_put_beq_label (GumThumbWriter * self, + gconstpointer label_id); +GUM_API void gum_thumb_writer_put_bne_label (GumThumbWriter * self, + gconstpointer label_id); +GUM_API void gum_thumb_writer_put_b_cond_label (GumThumbWriter * self, + arm_cc cc, gconstpointer label_id); +GUM_API void gum_thumb_writer_put_b_cond_label_wide (GumThumbWriter * self, + arm_cc cc, gconstpointer label_id); +GUM_API void gum_thumb_writer_put_cbz_reg_label (GumThumbWriter * self, + arm_reg reg, gconstpointer label_id); +GUM_API void gum_thumb_writer_put_cbnz_reg_label (GumThumbWriter * self, + arm_reg reg, gconstpointer label_id); + +GUM_API gboolean gum_thumb_writer_put_push_regs (GumThumbWriter * self, + guint n_regs, arm_reg first_reg, ...); +GUM_API gboolean gum_thumb_writer_put_push_regs_array (GumThumbWriter * self, + guint n_regs, const arm_reg * regs); +GUM_API gboolean gum_thumb_writer_put_pop_regs (GumThumbWriter * self, + guint n_regs, arm_reg first_reg, ...); +GUM_API gboolean gum_thumb_writer_put_pop_regs_array (GumThumbWriter * self, + guint n_regs, const arm_reg * regs); +GUM_API gboolean gum_thumb_writer_put_ldr_reg_address (GumThumbWriter * self, + arm_reg reg, GumAddress address); +GUM_API gboolean gum_thumb_writer_put_ldr_reg_u32 (GumThumbWriter * self, + arm_reg reg, guint32 val); +GUM_API void gum_thumb_writer_put_ldr_reg_reg (GumThumbWriter * self, + arm_reg dst_reg, arm_reg src_reg); +GUM_API gboolean gum_thumb_writer_put_ldr_reg_reg_offset (GumThumbWriter * self, + arm_reg dst_reg, arm_reg src_reg, gsize src_offset); +GUM_API void gum_thumb_writer_put_ldrb_reg_reg (GumThumbWriter * self, + arm_reg dst_reg, arm_reg src_reg); +void gum_thumb_writer_put_ldrh_reg_reg (GumThumbWriter * self, arm_reg dst_reg, + arm_reg src_reg); +GUM_API gboolean gum_thumb_writer_put_vldr_reg_reg_offset ( + GumThumbWriter * self, arm_reg dst_reg, arm_reg src_reg, gssize src_offset); +GUM_API void gum_thumb_writer_put_ldmia_reg_mask (GumThumbWriter * self, + arm_reg reg, guint16 mask); +GUM_API void gum_thumb_writer_put_str_reg_reg (GumThumbWriter * self, + arm_reg src_reg, arm_reg dst_reg); +GUM_API gboolean gum_thumb_writer_put_str_reg_reg_offset (GumThumbWriter * self, + arm_reg src_reg, arm_reg dst_reg, gsize dst_offset); +GUM_API void gum_thumb_writer_put_mov_reg_reg (GumThumbWriter * self, + arm_reg dst_reg, arm_reg src_reg); +GUM_API void gum_thumb_writer_put_mov_reg_u8 (GumThumbWriter * self, + arm_reg dst_reg, guint8 imm_value); +GUM_API void gum_thumb_writer_put_mov_reg_cpsr (GumThumbWriter * self, + arm_reg reg); +GUM_API void gum_thumb_writer_put_mov_cpsr_reg (GumThumbWriter * self, + arm_reg reg); +GUM_API gboolean gum_thumb_writer_put_add_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, gssize imm_value); +GUM_API void gum_thumb_writer_put_add_reg_reg (GumThumbWriter * self, + arm_reg dst_reg, arm_reg src_reg); +GUM_API void gum_thumb_writer_put_add_reg_reg_reg (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, arm_reg right_reg); +GUM_API gboolean gum_thumb_writer_put_add_reg_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, gssize right_value); +GUM_API gboolean gum_thumb_writer_put_sub_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, gssize imm_value); +GUM_API void gum_thumb_writer_put_sub_reg_reg (GumThumbWriter * self, + arm_reg dst_reg, arm_reg src_reg); +GUM_API void gum_thumb_writer_put_sub_reg_reg_reg (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, arm_reg right_reg); +GUM_API gboolean gum_thumb_writer_put_sub_reg_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, gssize right_value); +GUM_API gboolean gum_thumb_writer_put_and_reg_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, gssize right_value); +GUM_API gboolean gum_thumb_writer_put_or_reg_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, gssize right_value); +GUM_API gboolean gum_thumb_writer_put_lsl_reg_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, guint8 right_value); +GUM_API gboolean gum_thumb_writer_put_lsls_reg_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, guint8 right_value); +GUM_API gboolean gum_thumb_writer_put_lsrs_reg_reg_imm (GumThumbWriter * self, + arm_reg dst_reg, arm_reg left_reg, guint8 right_value); +GUM_API gboolean gum_thumb_writer_put_mrs_reg_reg (GumThumbWriter * self, + arm_reg dst_reg, arm_sysreg src_reg); +GUM_API gboolean gum_thumb_writer_put_msr_reg_reg (GumThumbWriter * self, + arm_sysreg dst_reg, arm_reg src_reg); + +GUM_API void gum_thumb_writer_put_nop (GumThumbWriter * self); +GUM_API void gum_thumb_writer_put_bkpt_imm (GumThumbWriter * self, guint8 imm); +GUM_API void gum_thumb_writer_put_breakpoint (GumThumbWriter * self); + +GUM_API void gum_thumb_writer_put_instruction (GumThumbWriter * self, + guint16 insn); +GUM_API void gum_thumb_writer_put_instruction_wide (GumThumbWriter * self, + guint16 upper, guint16 lower); +GUM_API gboolean gum_thumb_writer_put_bytes (GumThumbWriter * self, + const guint8 * data, guint n); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2014-2020 Ole André Vadla Ravnås + * Copyright (C) 2017 Antonio Ken Iannillo + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_ARM64_WRITER_H__ +#define __GUM_ARM64_WRITER_H__ + + +#define GUM_ARM64_ADRP_MAX_DISTANCE 0xfffff000 +#define GUM_ARM64_B_MAX_DISTANCE 0x07fffffc + +G_BEGIN_DECLS + +typedef struct _GumArm64Writer GumArm64Writer; +typedef guint GumArm64IndexMode; + +struct _GumArm64Writer +{ + volatile gint ref_count; + + GumOS target_os; + GumPtrauthSupport ptrauth_support; + GumAddress (* sign) (GumAddress value); + + guint32 * base; + guint32 * code; + GumAddress pc; + + GumMetalHashTable * label_defs; + GumMetalArray label_refs; + GumMetalArray literal_refs; + const guint32 * earliest_literal_insn; +}; + +enum _GumArm64IndexMode +{ + GUM_INDEX_POST_ADJUST = 1, + GUM_INDEX_SIGNED_OFFSET = 2, + GUM_INDEX_PRE_ADJUST = 3, +}; + +GUM_API GumArm64Writer * gum_arm64_writer_new (gpointer code_address); +GUM_API GumArm64Writer * gum_arm64_writer_ref (GumArm64Writer * writer); +GUM_API void gum_arm64_writer_unref (GumArm64Writer * writer); + +GUM_API void gum_arm64_writer_init (GumArm64Writer * writer, + gpointer code_address); +GUM_API void gum_arm64_writer_clear (GumArm64Writer * writer); + +GUM_API void gum_arm64_writer_reset (GumArm64Writer * writer, + gpointer code_address); + +GUM_API gpointer gum_arm64_writer_cur (GumArm64Writer * self); +GUM_API guint gum_arm64_writer_offset (GumArm64Writer * self); +GUM_API void gum_arm64_writer_skip (GumArm64Writer * self, guint n_bytes); + +GUM_API gboolean gum_arm64_writer_flush (GumArm64Writer * self); + +GUM_API gboolean gum_arm64_writer_put_label (GumArm64Writer * self, + gconstpointer id); + +GUM_API void gum_arm64_writer_put_call_address_with_arguments ( + GumArm64Writer * self, GumAddress func, guint n_args, ...); +GUM_API void gum_arm64_writer_put_call_address_with_arguments_array ( + GumArm64Writer * self, GumAddress func, guint n_args, + const GumArgument * args); +GUM_API void gum_arm64_writer_put_call_reg_with_arguments ( + GumArm64Writer * self, arm64_reg reg, guint n_args, ...); +GUM_API void gum_arm64_writer_put_call_reg_with_arguments_array ( + GumArm64Writer * self, arm64_reg reg, guint n_args, + const GumArgument * args); + +GUM_API void gum_arm64_writer_put_branch_address (GumArm64Writer * self, + GumAddress address); + +GUM_API gboolean gum_arm64_writer_can_branch_directly_between ( + GumArm64Writer * self, GumAddress from, GumAddress to); +GUM_API gboolean gum_arm64_writer_put_b_imm (GumArm64Writer * self, + GumAddress address); +GUM_API void gum_arm64_writer_put_b_label (GumArm64Writer * self, + gconstpointer label_id); +GUM_API void gum_arm64_writer_put_b_cond_label (GumArm64Writer * self, + arm64_cc cc, gconstpointer label_id); +GUM_API gboolean gum_arm64_writer_put_bl_imm (GumArm64Writer * self, + GumAddress address); +GUM_API void gum_arm64_writer_put_bl_label (GumArm64Writer * self, + gconstpointer label_id); +GUM_API gboolean gum_arm64_writer_put_br_reg (GumArm64Writer * self, + arm64_reg reg); +GUM_API gboolean gum_arm64_writer_put_br_reg_no_auth (GumArm64Writer * self, + arm64_reg reg); +GUM_API gboolean gum_arm64_writer_put_blr_reg (GumArm64Writer * self, + arm64_reg reg); +GUM_API gboolean gum_arm64_writer_put_blr_reg_no_auth (GumArm64Writer * self, + arm64_reg reg); +GUM_API void gum_arm64_writer_put_ret (GumArm64Writer * self); +GUM_API void gum_arm64_writer_put_cbz_reg_label (GumArm64Writer * self, + arm64_reg reg, gconstpointer label_id); +GUM_API void gum_arm64_writer_put_cbnz_reg_label (GumArm64Writer * self, + arm64_reg reg, gconstpointer label_id); +GUM_API void gum_arm64_writer_put_tbz_reg_imm_label (GumArm64Writer * self, + arm64_reg reg, guint bit, gconstpointer label_id); +GUM_API void gum_arm64_writer_put_tbnz_reg_imm_label (GumArm64Writer * self, + arm64_reg reg, guint bit, gconstpointer label_id); + +GUM_API gboolean gum_arm64_writer_put_push_reg_reg (GumArm64Writer * self, + arm64_reg reg_a, arm64_reg reg_b); +GUM_API gboolean gum_arm64_writer_put_pop_reg_reg (GumArm64Writer * self, + arm64_reg reg_a, arm64_reg reg_b); +GUM_API void gum_arm64_writer_put_push_all_x_registers (GumArm64Writer * self); +GUM_API void gum_arm64_writer_put_pop_all_x_registers (GumArm64Writer * self); +GUM_API void gum_arm64_writer_put_push_all_q_registers (GumArm64Writer * self); +GUM_API void gum_arm64_writer_put_pop_all_q_registers (GumArm64Writer * self); + +GUM_API gboolean gum_arm64_writer_put_ldr_reg_address (GumArm64Writer * self, + arm64_reg reg, GumAddress address); +GUM_API gboolean gum_arm64_writer_put_ldr_reg_u64 (GumArm64Writer * self, + arm64_reg reg, guint64 val); +GUM_API guint gum_arm64_writer_put_ldr_reg_ref (GumArm64Writer * self, + arm64_reg reg); +GUM_API void gum_arm64_writer_put_ldr_reg_value (GumArm64Writer * self, + guint ref, GumAddress value); +GUM_API gboolean gum_arm64_writer_put_ldr_reg_reg_offset (GumArm64Writer * self, + arm64_reg dst_reg, arm64_reg src_reg, gsize src_offset); +GUM_API gboolean gum_arm64_writer_put_ldrsw_reg_reg_offset ( + GumArm64Writer * self, arm64_reg dst_reg, arm64_reg src_reg, + gsize src_offset); +GUM_API gboolean gum_arm64_writer_put_adrp_reg_address (GumArm64Writer * self, + arm64_reg reg, GumAddress address); +GUM_API gboolean gum_arm64_writer_put_str_reg_reg_offset (GumArm64Writer * self, + arm64_reg src_reg, arm64_reg dst_reg, gsize dst_offset); +GUM_API gboolean gum_arm64_writer_put_ldp_reg_reg_reg_offset ( + GumArm64Writer * self, arm64_reg reg_a, arm64_reg reg_b, arm64_reg reg_src, + gssize src_offset, GumArm64IndexMode mode); +GUM_API gboolean gum_arm64_writer_put_stp_reg_reg_reg_offset ( + GumArm64Writer * self, arm64_reg reg_a, arm64_reg reg_b, arm64_reg reg_dst, + gssize dst_offset, GumArm64IndexMode mode); +GUM_API gboolean gum_arm64_writer_put_mov_reg_reg (GumArm64Writer * self, + arm64_reg dst_reg, arm64_reg src_reg); +GUM_API gboolean gum_arm64_writer_put_uxtw_reg_reg (GumArm64Writer * self, + arm64_reg dst_reg, arm64_reg src_reg); +GUM_API gboolean gum_arm64_writer_put_add_reg_reg_imm (GumArm64Writer * self, + arm64_reg dst_reg, arm64_reg left_reg, gsize right_value); +GUM_API gboolean gum_arm64_writer_put_add_reg_reg_reg (GumArm64Writer * self, + arm64_reg dst_reg, arm64_reg left_reg, arm64_reg right_reg); +GUM_API gboolean gum_arm64_writer_put_sub_reg_reg_imm (GumArm64Writer * self, + arm64_reg dst_reg, arm64_reg left_reg, gsize right_value); +GUM_API gboolean gum_arm64_writer_put_sub_reg_reg_reg (GumArm64Writer * self, + arm64_reg dst_reg, arm64_reg left_reg, arm64_reg right_reg); +GUM_API gboolean gum_arm64_writer_put_and_reg_reg_imm (GumArm64Writer * self, + arm64_reg dst_reg, arm64_reg left_reg, gsize right_value); +GUM_API gboolean gum_arm64_writer_put_tst_reg_imm (GumArm64Writer * self, + arm64_reg reg, guint64 imm_value); +GUM_API gboolean gum_arm64_writer_put_cmp_reg_reg (GumArm64Writer * self, + arm64_reg reg_a, arm64_reg reg_b); + +GUM_API gboolean gum_arm64_writer_put_xpaci_reg (GumArm64Writer * self, + arm64_reg reg); + +GUM_API void gum_arm64_writer_put_nop (GumArm64Writer * self); +GUM_API void gum_arm64_writer_put_brk_imm (GumArm64Writer * self, guint16 imm); + +GUM_API void gum_arm64_writer_put_instruction (GumArm64Writer * self, + guint32 insn); +GUM_API gboolean gum_arm64_writer_put_bytes (GumArm64Writer * self, + const guint8 * data, guint n); + +GUM_API GumAddress gum_arm64_writer_sign (GumArm64Writer * self, + GumAddress value); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2014-2019 Ole André Vadla Ravnås + * Copyright (C) 2019 Jon Wilson + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_MIPS_WRITER_H__ +#define __GUM_MIPS_WRITER_H__ + + +#define GUM_MIPS_J_MAX_DISTANCE (1 << 28) + +G_BEGIN_DECLS + +typedef struct _GumMipsWriter GumMipsWriter; + +struct _GumMipsWriter +{ + volatile gint ref_count; + + guint32 * base; + guint32 * code; + GumAddress pc; + + GumMetalHashTable * label_defs; + GumMetalArray label_refs; +}; + +GUM_API GumMipsWriter * gum_mips_writer_new (gpointer code_address); +GUM_API GumMipsWriter * gum_mips_writer_ref (GumMipsWriter * writer); +GUM_API void gum_mips_writer_unref (GumMipsWriter * writer); + +GUM_API void gum_mips_writer_init (GumMipsWriter * writer, + gpointer code_address); +GUM_API void gum_mips_writer_clear (GumMipsWriter * writer); + +GUM_API void gum_mips_writer_reset (GumMipsWriter * writer, + gpointer code_address); + +GUM_API gpointer gum_mips_writer_cur (GumMipsWriter * self); +GUM_API guint gum_mips_writer_offset (GumMipsWriter * self); +GUM_API void gum_mips_writer_skip (GumMipsWriter * self, guint n_bytes); + +GUM_API gboolean gum_mips_writer_flush (GumMipsWriter * self); + +GUM_API gboolean gum_mips_writer_put_label (GumMipsWriter * self, + gconstpointer id); + +GUM_API void gum_mips_writer_put_call_address_with_arguments ( + GumMipsWriter * self, GumAddress func, guint n_args, ...); +GUM_API void gum_mips_writer_put_call_address_with_arguments_array ( + GumMipsWriter * self, GumAddress func, guint n_args, + const GumArgument * args); +GUM_API void gum_mips_writer_put_call_reg_with_arguments (GumMipsWriter * self, + mips_reg reg, guint n_args, ...); +GUM_API void gum_mips_writer_put_call_reg_with_arguments_array ( + GumMipsWriter * self, mips_reg reg, guint n_args, const GumArgument * args); + +GUM_API gboolean gum_mips_writer_can_branch_directly_between (GumAddress from, + GumAddress to); +GUM_API gboolean gum_mips_writer_put_j_address (GumMipsWriter * self, + GumAddress address); +GUM_API gboolean gum_mips_writer_put_j_address_without_nop ( + GumMipsWriter * self, GumAddress address); +GUM_API void gum_mips_writer_put_j_label (GumMipsWriter * self, + gconstpointer label_id); +GUM_API void gum_mips_writer_put_jr_reg (GumMipsWriter * self, mips_reg reg); +GUM_API void gum_mips_writer_put_jal_address (GumMipsWriter * self, + guint32 address); +GUM_API void gum_mips_writer_put_jalr_reg (GumMipsWriter * self, mips_reg reg); +GUM_API void gum_mips_writer_put_b_offset (GumMipsWriter * self, gint32 offset); +GUM_API void gum_mips_writer_put_beq_reg_reg_label (GumMipsWriter * self, + mips_reg right_reg, mips_reg left_reg, gconstpointer label_id); +GUM_API void gum_mips_writer_put_ret (GumMipsWriter * self); + +GUM_API void gum_mips_writer_put_la_reg_address (GumMipsWriter * self, + mips_reg reg, GumAddress address); +GUM_API void gum_mips_writer_put_lui_reg_imm (GumMipsWriter * self, + mips_reg reg, guint imm); +GUM_API void gum_mips_writer_put_dsll_reg_reg (GumMipsWriter * self, + mips_reg dst_reg, mips_reg src_reg, guint amount); +GUM_API void gum_mips_writer_put_ori_reg_reg_imm (GumMipsWriter * self, + mips_reg rt, mips_reg rs, guint imm); +GUM_API void gum_mips_writer_put_ld_reg_reg_offset (GumMipsWriter * self, + mips_reg dst_reg, mips_reg src_reg, gsize src_offset); +GUM_API void gum_mips_writer_put_lw_reg_reg_offset (GumMipsWriter * self, + mips_reg dst_reg, mips_reg src_reg, gsize src_offset); +GUM_API void gum_mips_writer_put_sw_reg_reg_offset (GumMipsWriter * self, + mips_reg src_reg, mips_reg dst_reg, gsize dst_offset); +GUM_API void gum_mips_writer_put_move_reg_reg (GumMipsWriter * self, + mips_reg dst_reg, mips_reg src_reg); +GUM_API void gum_mips_writer_put_addu_reg_reg_reg (GumMipsWriter * self, + mips_reg dst_reg, mips_reg left_reg, mips_reg right_reg); +GUM_API void gum_mips_writer_put_addi_reg_reg_imm (GumMipsWriter * self, + mips_reg dst_reg, mips_reg left_reg, gint32 imm); +GUM_API void gum_mips_writer_put_addi_reg_imm (GumMipsWriter * self, + mips_reg dst_reg, gint32 imm); +GUM_API void gum_mips_writer_put_sub_reg_reg_imm (GumMipsWriter * self, + mips_reg dst_reg, mips_reg left_reg, gint32 imm); + +GUM_API void gum_mips_writer_put_push_reg (GumMipsWriter * self, mips_reg reg); +GUM_API void gum_mips_writer_put_pop_reg (GumMipsWriter * self, mips_reg reg); + +GUM_API void gum_mips_writer_put_mfhi_reg (GumMipsWriter * self, mips_reg reg); +GUM_API void gum_mips_writer_put_mflo_reg (GumMipsWriter * self, mips_reg reg); +GUM_API void gum_mips_writer_put_mthi_reg (GumMipsWriter * self, mips_reg reg); +GUM_API void gum_mips_writer_put_mtlo_reg (GumMipsWriter * self, mips_reg reg); + +GUM_API void gum_mips_writer_put_nop (GumMipsWriter * self); +GUM_API void gum_mips_writer_put_break (GumMipsWriter * self); + +GUM_API void gum_mips_writer_put_prologue_trampoline (GumMipsWriter * self, + mips_reg reg, GumAddress address); + +GUM_API void gum_mips_writer_put_instruction (GumMipsWriter * self, + guint32 insn); +GUM_API gboolean gum_mips_writer_put_bytes (GumMipsWriter * self, + const guint8 * data, guint n); + +G_END_DECLS + +#endif + +G_BEGIN_DECLS + +#define GUM_TYPE_STALKER (gum_stalker_get_type ()) +G_DECLARE_FINAL_TYPE (GumStalker, gum_stalker, GUM, STALKER, GObject) + +#define GUM_TYPE_STALKER_TRANSFORMER (gum_stalker_transformer_get_type ()) +G_DECLARE_INTERFACE (GumStalkerTransformer, gum_stalker_transformer, GUM, + STALKER_TRANSFORMER, GObject) + +#define GUM_TYPE_DEFAULT_STALKER_TRANSFORMER \ + (gum_default_stalker_transformer_get_type ()) +G_DECLARE_FINAL_TYPE (GumDefaultStalkerTransformer, + gum_default_stalker_transformer, GUM, DEFAULT_STALKER_TRANSFORMER, + GObject) + +#define GUM_TYPE_CALLBACK_STALKER_TRANSFORMER \ + (gum_callback_stalker_transformer_get_type ()) +G_DECLARE_FINAL_TYPE (GumCallbackStalkerTransformer, + gum_callback_stalker_transformer, GUM, CALLBACK_STALKER_TRANSFORMER, + GObject) + +typedef struct _GumStalkerIterator GumStalkerIterator; +typedef struct _GumStalkerOutput GumStalkerOutput; +typedef union _GumStalkerWriter GumStalkerWriter; +typedef void (* GumStalkerTransformerCallback) (GumStalkerIterator * iterator, + GumStalkerOutput * output, gpointer user_data); +typedef void (* GumStalkerCallout) (GumCpuContext * cpu_context, + gpointer user_data); + +typedef guint GumProbeId; +typedef struct _GumCallSite GumCallSite; +typedef void (* GumCallProbeCallback) (GumCallSite * site, gpointer user_data); + +struct _GumStalkerTransformerInterface +{ + GTypeInterface parent; + + void (* transform_block) (GumStalkerTransformer * self, + GumStalkerIterator * iterator, GumStalkerOutput * output); +}; + +union _GumStalkerWriter +{ + gpointer instance; + GumX86Writer * x86; + GumArmWriter * arm; + GumThumbWriter * thumb; + GumArm64Writer * arm64; + GumMipsWriter * mips; +}; + +struct _GumStalkerOutput +{ + GumStalkerWriter writer; + GumInstructionEncoding encoding; +}; + +struct _GumCallSite +{ + gpointer block_address; + gpointer stack_data; + GumCpuContext * cpu_context; +}; + +GUM_API gboolean gum_stalker_is_supported (void); + +GUM_API GumStalker * gum_stalker_new (void); + +GUM_API void gum_stalker_exclude (GumStalker * self, + const GumMemoryRange * range); + +GUM_API gint gum_stalker_get_trust_threshold (GumStalker * self); +GUM_API void gum_stalker_set_trust_threshold (GumStalker * self, + gint trust_threshold); + +GUM_API void gum_stalker_flush (GumStalker * self); +GUM_API void gum_stalker_stop (GumStalker * self); +GUM_API gboolean gum_stalker_garbage_collect (GumStalker * self); + +GUM_API void gum_stalker_follow_me (GumStalker * self, + GumStalkerTransformer * transformer, GumEventSink * sink); +GUM_API void gum_stalker_unfollow_me (GumStalker * self); +GUM_API gboolean gum_stalker_is_following_me (GumStalker * self); + +GUM_API void gum_stalker_follow (GumStalker * self, GumThreadId thread_id, + GumStalkerTransformer * transformer, GumEventSink * sink); +GUM_API void gum_stalker_unfollow (GumStalker * self, GumThreadId thread_id); + +GUM_API void gum_stalker_activate (GumStalker * self, gconstpointer target); +GUM_API void gum_stalker_deactivate (GumStalker * self); + +GUM_API GumProbeId gum_stalker_add_call_probe (GumStalker * self, + gpointer target_address, GumCallProbeCallback callback, gpointer data, + GDestroyNotify notify); +GUM_API void gum_stalker_remove_call_probe (GumStalker * self, + GumProbeId id); + +#define gum_call_site_get_nth_argument(s, n) \ + gum_cpu_context_get_nth_argument ((s)->cpu_context, n) +#define gum_call_site_replace_nth_argument(s, n, v) \ + gum_cpu_context_replace_nth_argument ((s)->cpu_context, n, v) + +GUM_API GumStalkerTransformer * gum_stalker_transformer_make_default (void); +GUM_API GumStalkerTransformer * gum_stalker_transformer_make_from_callback ( + GumStalkerTransformerCallback callback, gpointer data, + GDestroyNotify data_destroy); + +GUM_API void gum_stalker_transformer_transform_block ( + GumStalkerTransformer * self, GumStalkerIterator * iterator, + GumStalkerOutput * output); + +GUM_API gboolean gum_stalker_iterator_next (GumStalkerIterator * self, + const cs_insn ** insn); +GUM_API void gum_stalker_iterator_keep (GumStalkerIterator * self); +GUM_API void gum_stalker_iterator_put_callout (GumStalkerIterator * self, + GumStalkerCallout callout, gpointer data, GDestroyNotify data_destroy); + +GUM_API void gum_stalker_set_counters_enabled (gboolean enabled); +GUM_API void gum_stalker_dump_counters (void); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2008-2010 Ole André Vadla Ravnås + * Copyright (C) 2008 Christian Berentsen + * Copyright (C) 2020 Matt Oh + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_SYMBOL_UTIL_H__ +#define __GUM_SYMBOL_UTIL_H__ + + +typedef struct _GumDebugSymbolDetails GumDebugSymbolDetails; + +struct _GumDebugSymbolDetails +{ + GumAddress address; + gchar module_name[GUM_MAX_PATH + 1]; + gchar symbol_name[GUM_MAX_SYMBOL_NAME + 1]; + gchar file_name[GUM_MAX_PATH + 1]; + guint line_number; +}; + +G_BEGIN_DECLS + +GUM_API gboolean gum_symbol_details_from_address (gpointer address, + GumDebugSymbolDetails * details); +GUM_API gchar * gum_symbol_name_from_address (gpointer address); + +GUM_API gpointer gum_find_function (const gchar * name); +GUM_API GArray * gum_find_functions_named (const gchar * name); +GUM_API GArray * gum_find_functions_matching (const gchar * str); +GUM_API gboolean gum_load_symbols (const gchar * path); + +G_END_DECLS + +#endif +/* + * Copyright (C) 2010-2014 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_SYS_INTERNALS_H__ +#define __GUM_SYS_INTERNALS_H__ + + +#ifdef G_OS_WIN32 + +# if GLIB_SIZEOF_VOID_P == 4 +# define GUM_TEB_OFFSET_SELF 0x0018 +# define GUM_TEB_OFFSET_TID 0x0024 +# else +# define GUM_TEB_OFFSET_SELF 0x0030 +# define GUM_TEB_OFFSET_TID 0x0048 +# endif + +#endif + +#endif +/* + * Copyright (C) 2010-2017 Ole André Vadla Ravnås + * + * Licence: wxWindows Library Licence, Version 3.1 + */ + +#ifndef __GUM_TLS_H__ +#define __GUM_TLS_H__ + + +G_BEGIN_DECLS + +typedef gsize GumTlsKey; + +GUM_API GumTlsKey gum_tls_key_new (void); +GUM_API void gum_tls_key_free (GumTlsKey key); + +GUM_API gpointer gum_tls_key_get_value (GumTlsKey key); +GUM_API void gum_tls_key_set_value (GumTlsKey key, gpointer value); + +G_END_DECLS + +#endif + +G_BEGIN_DECLS + +GUM_API void gum_init (void); +GUM_API void gum_shutdown (void); +GUM_API void gum_deinit (void); + +GUM_API void gum_init_embedded (void); +GUM_API void gum_deinit_embedded (void); + +GUM_API void gum_prepare_to_fork (void); +GUM_API void gum_recover_from_fork_in_parent (void); +GUM_API void gum_recover_from_fork_in_child (void); + +G_END_DECLS + +#endif diff --git a/utils/afl_frida/android/libfrida-gum.a b/utils/afl_frida/android/libfrida-gum.a new file mode 100644 index 00000000..2da655c8 Binary files /dev/null and b/utils/afl_frida/android/libfrida-gum.a differ -- cgit 1.4.1 From 868ef6c10c8137e0085789452a84435cd6b72f2f Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Thu, 14 Jan 2021 14:16:17 +0800 Subject: android: afl_frida: get target lib/function from command line --- utils/afl_frida/afl-frida.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/utils/afl_frida/afl-frida.c b/utils/afl_frida/afl-frida.c index b5b8196d..89a5b932 100644 --- a/utils/afl_frida/afl-frida.c +++ b/utils/afl_frida/afl-frida.c @@ -153,7 +153,7 @@ static int enumerate_ranges(const GumRangeDetails *details, } -int main() { +int main(int argc, char** argv) { #ifndef __APPLE__ (void)personality(ADDR_NO_RANDOMIZE); // disable ASLR @@ -164,17 +164,32 @@ int main() { // If there is just one function, then there is nothing to change // or add here. - void *dl = dlopen(TARGET_LIBRARY, RTLD_LAZY); + void *dl = NULL; + if (argc > 2) { + dl = dlopen(argv[1], RTLD_LAZY); + } else { + dl = dlopen(TARGET_LIBRARY, RTLD_LAZY); + } if (!dl) { - fprintf(stderr, "Could not load %s\n", TARGET_LIBRARY); + if (argc > 2) + fprintf(stderr, "Could not load %s\n", argv[1]); + else + fprintf(stderr, "Could not load %s\n", TARGET_LIBRARY); exit(-1); } - if (!(o_function = dlsym(dl, TARGET_FUNCTION))) { + if (argc > 2) + o_function = dlsym(dl, argv[2]); + else + o_function = dlsym(dl, TARGET_FUNCTION); + if (!o_function) { - fprintf(stderr, "Could not find function %s\n", TARGET_FUNCTION); + if (argc > 2) + fprintf(stderr, "Could not find function %s\n", argv[2]); + else + fprintf(stderr, "Could not find function %s\n", TARGET_FUNCTION); exit(-1); } -- cgit 1.4.1 From 6dc20fc298c28658ea988a74eb7d400115a3f78a Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Thu, 14 Jan 2021 21:47:00 +0800 Subject: afl_frida: fix target lib --- utils/afl_frida/afl-frida.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/utils/afl_frida/afl-frida.c b/utils/afl_frida/afl-frida.c index 89a5b932..4a99d6ed 100644 --- a/utils/afl_frida/afl-frida.c +++ b/utils/afl_frida/afl-frida.c @@ -206,9 +206,17 @@ int main(int argc, char** argv) { GumStalker *stalker = gum_stalker_new(); - GumAddress base_address = gum_module_find_base_address(TARGET_LIBRARY); + GumAddress base_address; + if (argc > 2) + base_address = gum_module_find_base_address(argv[1]); + else + base_address = gum_module_find_base_address(TARGET_LIBRARY); GumMemoryRange code_range; - gum_module_enumerate_ranges(TARGET_LIBRARY, GUM_PAGE_RX, enumerate_ranges, + if (argc > 2) + gum_module_enumerate_ranges(argv[1], GUM_PAGE_RX, enumerate_ranges, + &code_range); + else + gum_module_enumerate_ranges(TARGET_LIBRARY, GUM_PAGE_RX, enumerate_ranges, &code_range); guint64 code_start = code_range.base_address; @@ -219,7 +227,11 @@ int main(int argc, char** argv) { base_address, code_start, code_end); if (!code_start || !code_end) { - fprintf(stderr, "Error: no valid memory address found for %s\n", + if (argc > 2) + fprintf(stderr, "Error: no valid memory address found for %s\n", + argv[1]); + else + fprintf(stderr, "Error: no valid memory address found for %s\n", TARGET_LIBRARY); exit(-1); -- cgit 1.4.1 From 1e2da1dfb9ca44e70416601ed5ab94ad79ce2994 Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Sat, 16 Jan 2021 13:31:11 +0800 Subject: android: port libfuzzer-mutator --- Android.bp | 14 ++++++++++++++ custom_mutators/Android.bp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 custom_mutators/Android.bp diff --git a/Android.bp b/Android.bp index 1ac9e565..bd23d1d1 100644 --- a/Android.bp +++ b/Android.bp @@ -190,6 +190,16 @@ cc_library_static { ], } +cc_library_headers { + name: "libafl_headers", + vendor_available: true, + host_supported: true, + + export_include_dirs: [ + "include", + ], +} + cc_prebuilt_library_static { name: "libfrida-gum", compile_multilib: "64", @@ -255,3 +265,7 @@ cc_binary { "utils/afl_frida/android", ], } + +subdirs = [ + "custom_mutators", +] diff --git a/custom_mutators/Android.bp b/custom_mutators/Android.bp new file mode 100644 index 00000000..f2ac14b5 --- /dev/null +++ b/custom_mutators/Android.bp @@ -0,0 +1,44 @@ +cc_library_shared { + name: "libfuzzer-mutator", + vendor_available: true, + host_supported: true, + + cflags: [ + "-g", + "-O0", + "-funroll-loops", + "-fPIC", + "-fpermissive", + "-std=c++11", + ], + + srcs: [ + "libfuzzer/FuzzerCrossOver.cpp", + "libfuzzer/FuzzerDataFlowTrace.cpp", + "libfuzzer/FuzzerDriver.cpp", + "libfuzzer/FuzzerExtFunctionsDlsym.cpp", + "libfuzzer/FuzzerExtFunctionsWeak.cpp", + "libfuzzer/FuzzerExtFunctionsWindows.cpp", + "libfuzzer/FuzzerExtraCounters.cpp", + "libfuzzer/FuzzerFork.cpp", + "libfuzzer/FuzzerIO.cpp", + "libfuzzer/FuzzerIOPosix.cpp", + "libfuzzer/FuzzerIOWindows.cpp", + "libfuzzer/FuzzerLoop.cpp", + "libfuzzer/FuzzerMerge.cpp", + "libfuzzer/FuzzerMutate.cpp", + "libfuzzer/FuzzerSHA1.cpp", + "libfuzzer/FuzzerTracePC.cpp", + "libfuzzer/FuzzerUtil.cpp", + "libfuzzer/FuzzerUtilDarwin.cpp", + "libfuzzer/FuzzerUtilFuchsia.cpp", + "libfuzzer/FuzzerUtilLinux.cpp", + "libfuzzer/FuzzerUtilPosix.cpp", + "libfuzzer/FuzzerUtilWindows.cpp", + "libfuzzer/libfuzzer.cpp", + ], + + header_libs: [ + "libafl_headers", + ], +} -- cgit 1.4.1 From 9d9e148e5cb9e9118289a1d52e0b7aeff040b8bb Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Sat, 16 Jan 2021 15:00:35 +0800 Subject: android: build custom mutators for symcc, radamsa --- custom_mutators/Android.bp | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/custom_mutators/Android.bp b/custom_mutators/Android.bp index f2ac14b5..11690443 100644 --- a/custom_mutators/Android.bp +++ b/custom_mutators/Android.bp @@ -42,3 +42,70 @@ cc_library_shared { "libafl_headers", ], } + +/*cc_library_shared { + name: "honggfuzz-mutator", + vendor_available: true, + host_supported: true, + + cflags: [ + "-g", + "-O0", + "-funroll-loops", + "-fPIC", + "-Wl,-Bsymbolic", + ], + + srcs: [ + "honggfuzz/honggfuzz.c", + "honggfuzz/mangle.c", +// "../src/afl-perfomance.c", + ], + + header_libs: [ + "libafl_headers", + ], +}*/ + +cc_library_shared { + name: "radamsa-mutator", + vendor_available: true, + host_supported: true, + + cflags: [ + "-g", + "-O0", + "-funroll-loops", + "-fPIC", + ], + + srcs: [ + "radamsa/libradamsa.c", + "radamsa/radamsa-mutator.c", + ], + + header_libs: [ + "libafl_headers", + ], +} + +cc_library_shared { + name: "symcc-mutator", + vendor_available: true, + host_supported: true, + + cflags: [ + "-g", + "-O0", + "-funroll-loops", + "-fPIC", + ], + + srcs: [ + "symcc/symcc.c", + ], + + header_libs: [ + "libafl_headers", + ], +} -- cgit 1.4.1 From 7ad8f6c7176c26c4fdbd80cec33f969235055839 Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Mon, 18 Jan 2021 11:05:57 +0800 Subject: android: Add libprotobuf aflpp custom_mutator example --- custom_mutators/Android.bp | 4 + .../libprotobuf-mutator-example/Android.bp | 32 ++++++ .../libprotobuf-mutator-example/README.md | 1 + .../lpm_aflpp_custom_mutator_input.cc | 118 +++++++++++++++++++++ .../lpm_aflpp_custom_mutator_input.h | 5 + .../libprotobuf-mutator-example/test.proto | 7 ++ custom_mutators/libprotobuf-mutator-example/vuln.c | 17 +++ 7 files changed, 184 insertions(+) create mode 100644 custom_mutators/libprotobuf-mutator-example/Android.bp create mode 100644 custom_mutators/libprotobuf-mutator-example/README.md create mode 100644 custom_mutators/libprotobuf-mutator-example/lpm_aflpp_custom_mutator_input.cc create mode 100644 custom_mutators/libprotobuf-mutator-example/lpm_aflpp_custom_mutator_input.h create mode 100644 custom_mutators/libprotobuf-mutator-example/test.proto create mode 100644 custom_mutators/libprotobuf-mutator-example/vuln.c diff --git a/custom_mutators/Android.bp b/custom_mutators/Android.bp index 11690443..89abc3e9 100644 --- a/custom_mutators/Android.bp +++ b/custom_mutators/Android.bp @@ -109,3 +109,7 @@ cc_library_shared { "libafl_headers", ], } + +subdirs = [ + "libprotobuf-mutator-example", +] diff --git a/custom_mutators/libprotobuf-mutator-example/Android.bp b/custom_mutators/libprotobuf-mutator-example/Android.bp new file mode 100644 index 00000000..01f1c23e --- /dev/null +++ b/custom_mutators/libprotobuf-mutator-example/Android.bp @@ -0,0 +1,32 @@ +cc_library_shared { + name: "libprotobuf-mutator-example-afl", + vendor_available: true, + host_supported: true, + + cflags: [ + "-g", + "-O0", + "-fPIC", + "-Wall", + ], + + srcs: [ + "lpm_aflpp_custom_mutator_input.cc", + "test.proto", + ], + + shared_libs: [ + "libprotobuf-cpp-full", + "libprotobuf-mutator", + ], +} + +cc_binary { + name: "libprotobuf-mutator-vuln", + vendor_available: true, + host_supported: true, + + srcs: [ + "vuln.c", + ], +} diff --git a/custom_mutators/libprotobuf-mutator-example/README.md b/custom_mutators/libprotobuf-mutator-example/README.md new file mode 100644 index 00000000..5a844c00 --- /dev/null +++ b/custom_mutators/libprotobuf-mutator-example/README.md @@ -0,0 +1 @@ +Ported from [https://github.com/bruce30262/libprotobuf-mutator_fuzzing_learning/tree/master/5_libprotobuf_aflpp_custom_mutator_input](https://github.com/bruce30262/libprotobuf-mutator_fuzzing_learning/tree/master/5_libprotobuf_aflpp_custom_mutator_input) diff --git a/custom_mutators/libprotobuf-mutator-example/lpm_aflpp_custom_mutator_input.cc b/custom_mutators/libprotobuf-mutator-example/lpm_aflpp_custom_mutator_input.cc new file mode 100644 index 00000000..e0273849 --- /dev/null +++ b/custom_mutators/libprotobuf-mutator-example/lpm_aflpp_custom_mutator_input.cc @@ -0,0 +1,118 @@ +#include "lpm_aflpp_custom_mutator_input.h" +#include +#include +#include + +using std::cin; +using std::cout; +using std::endl; + +std::string ProtoToData(const TEST &test_proto) { + std::stringstream all; + const auto &aa = test_proto.a(); + const auto &bb = test_proto.b(); + all.write((const char*)&aa, sizeof(aa)); + if(bb.size() != 0) { + all.write(bb.c_str(), bb.size()); + } + + std::string res = all.str(); + if (bb.size() != 0 && res.size() != 0) { + // set PROTO_FUZZER_DUMP_PATH env to dump the serialized protobuf + if (const char *dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { + std::ofstream of(dump_path); + of.write(res.data(), res.size()); + } + } + return res; +} + +/** + * Initialize this custom mutator + * + * @param[in] afl a pointer to the internal state object. Can be ignored for + * now. + * @param[in] seed A seed for this mutator - the same seed should always mutate + * in the same way. + * @return Pointer to the data object this custom mutator instance should use. + * There may be multiple instances of this mutator in one afl-fuzz run! + * Return NULL on error. + */ +extern "C" MyMutator *afl_custom_init(void *afl, unsigned int seed) { + MyMutator *mutator = new MyMutator(); + + mutator->RegisterPostProcessor( + TEST::descriptor(), + [](google::protobuf::Message* message, unsigned int seed) { + // libprotobuf-mutator's built-in mutator is kind of....crappy :P + // Even a dumb fuzz like `TEST.a = rand();` is better in this case... Q_Q + // We register a post processor to apply our dumb fuzz + + TEST *t = static_cast(message); + t->set_a(rand()); + }); + + srand(seed); + return mutator; +} + +/** + * Perform custom mutations on a given input + * + * @param[in] data pointer returned in afl_custom_init for this fuzz case + * @param[in] buf Pointer to input data to be mutated + * @param[in] buf_size Size of input data + * @param[out] out_buf the buffer we will work on. we can reuse *buf. NULL on + * error. + * @param[in] add_buf Buffer containing the additional test case + * @param[in] add_buf_size Size of the additional test case + * @param[in] max_size Maximum size of the mutated output. The mutation must not + * produce data larger than max_size. + * @return Size of the mutated output. + */ +extern "C" size_t afl_custom_fuzz(MyMutator *mutator, // return value from afl_custom_init + uint8_t *buf, size_t buf_size, // input data to be mutated + uint8_t **out_buf, // output buffer + uint8_t *add_buf, size_t add_buf_size, // add_buf can be NULL + size_t max_size) { + // This function can be named either "afl_custom_fuzz" or "afl_custom_mutator" + // A simple test shows that "buf" will be the content of the current test case + // "add_buf" will be the next test case ( from AFL++'s input queue ) + + TEST input; + // parse input data to TEST + // Notice that input data should be a serialized protobuf data + // Check ./in/ii and test_protobuf_serializer for more detail + bool parse_ok = input.ParseFromArray(buf, buf_size); + if(!parse_ok) { + // Invalid serialize protobuf data. Don't mutate. + // Return a dummy buffer. Also mutated_size = 0 + static uint8_t *dummy = new uint8_t[10]; // dummy buffer with no data + *out_buf = dummy; + return 0; + } + // mutate the protobuf + mutator->Mutate(&input, max_size); + + // Convert protobuf to raw data + const TEST *p = &input; + std::string s = ProtoToData(*p); + // Copy to a new buffer ( mutated_out ) + size_t mutated_size = s.size() <= max_size ? s.size() : max_size; // check if raw data's size is larger than max_size + uint8_t *mutated_out = new uint8_t[mutated_size+1]; + memcpy(mutated_out, s.c_str(), mutated_size); // copy the mutated data + // Assign the mutated data and return mutated_size + *out_buf = mutated_out; + return mutated_size; +} + +/** + * Deinitialize everything + * + * @param data The data ptr from afl_custom_init + */ +extern "C" void afl_custom_deinit(void *data) { + // Honestly I don't know what to do with this... + return; +} + diff --git a/custom_mutators/libprotobuf-mutator-example/lpm_aflpp_custom_mutator_input.h b/custom_mutators/libprotobuf-mutator-example/lpm_aflpp_custom_mutator_input.h new file mode 100644 index 00000000..ebd3ca65 --- /dev/null +++ b/custom_mutators/libprotobuf-mutator-example/lpm_aflpp_custom_mutator_input.h @@ -0,0 +1,5 @@ +#include +#include "test.pb.h" + +class MyMutator : public protobuf_mutator::Mutator { +}; diff --git a/custom_mutators/libprotobuf-mutator-example/test.proto b/custom_mutators/libprotobuf-mutator-example/test.proto new file mode 100644 index 00000000..e2256c6e --- /dev/null +++ b/custom_mutators/libprotobuf-mutator-example/test.proto @@ -0,0 +1,7 @@ +syntax = "proto2"; + +message TEST { + required uint32 a = 1; + required string b = 2; +} + diff --git a/custom_mutators/libprotobuf-mutator-example/vuln.c b/custom_mutators/libprotobuf-mutator-example/vuln.c new file mode 100644 index 00000000..8ffb7080 --- /dev/null +++ b/custom_mutators/libprotobuf-mutator-example/vuln.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + char str[100]={}; + read(0, str, 100); + int *ptr = NULL; + if( str[0] == '\x02' || str[0] == '\xe8') { + *ptr = 123; + } + return 0; +} + -- cgit 1.4.1 From ac1117ffaeec0bd3c593063a05d8aa000d162d47 Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Tue, 19 Jan 2021 09:44:59 +0800 Subject: android: Fix runtime for mutator --- Android.bp | 4 ++-- src/afl-cc.c | 14 ++++++++++---- src/afl-fuzz-mutators.c | 5 ++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Android.bp b/Android.bp index bd23d1d1..5d6f0433 100644 --- a/Android.bp +++ b/Android.bp @@ -135,6 +135,8 @@ cc_binary_host { "-DCLANGPP_BIN=\"prebuilts/clang/host/linux-x86/clang-r383902b/bin/clang++\"", "-DAFL_REAL_LD=\"prebuilts/clang/host/linux-x86/clang-r383902b/bin/ld.lld\"", "-DLLVM_LTO=1", + "-DLLVM_MAJOR=11", + "-DLLVM_MINOR=2", ], srcs: [ @@ -145,8 +147,6 @@ cc_binary_host { symlinks: [ "afl-clang-fast", "afl-clang-fast++", - "afl-clang-lto", - "afl-clang-lto++", ], } diff --git a/src/afl-cc.c b/src/afl-cc.c index 1379488e..f3dfd49f 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -586,6 +586,9 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (instrument_mode == INSTRUMENT_PCGUARD) { #if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0) +#ifdef __ANDROID__ + cc_params[cc_par_cnt++] = "-fsanitize-coverage=trace-pc-guard"; +#else if (have_instr_list) { if (!be_quiet) @@ -605,6 +608,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { } +#endif #else #if LLVM_MAJOR >= 4 if (!be_quiet) @@ -1034,6 +1038,10 @@ int main(int argc, char **argv, char **envp) { #endif +#ifdef __ANDROID__ + have_llvm = 1; +#endif + if ((ptr = find_object("afl-gcc-pass.so", argv[0])) != NULL) { have_gcc_plugin = 1; @@ -1807,11 +1815,8 @@ int main(int argc, char **argv, char **envp) { if (!be_quiet && cmplog_mode) printf("CmpLog mode by \n"); -#ifdef __ANDROID__ - ptr = find_object("afl-compiler-rt.so", argv[0]); -#else +#ifndef __ANDROID__ ptr = find_object("afl-compiler-rt.o", argv[0]); -#endif if (!ptr) { @@ -1824,6 +1829,7 @@ int main(int argc, char **argv, char **envp) { if (debug) { DEBUGF("rt=%s obj_path=%s\n", ptr, obj_path); } ck_free(ptr); +#endif edit_params(argc, argv, envp); diff --git a/src/afl-fuzz-mutators.c b/src/afl-fuzz-mutators.c index 089707b9..80df6d08 100644 --- a/src/afl-fuzz-mutators.c +++ b/src/afl-fuzz-mutators.c @@ -141,7 +141,10 @@ struct custom_mutator *load_custom_mutator(afl_state_t *afl, const char *fn) { struct custom_mutator *mutator = ck_alloc(sizeof(struct custom_mutator)); mutator->name = fn; - mutator->name_short = strrchr(fn, '/') + 1; + if (memchr(fn, '/', strlen(fn))) + mutator->name_short = strrchr(fn, '/') + 1; + else + mutator->name_short = strdup(fn); ACTF("Loading custom mutator library from '%s'...", fn); dh = dlopen(fn, RTLD_NOW); -- cgit 1.4.1 From f3ef91e8d6b20e5aa8f1c7ed32b662ec3a0e8c22 Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Tue, 19 Jan 2021 10:28:24 +0800 Subject: Migrates DebugLoc::get to DILocation::get - Refer to https://reviews.llvm.org/D93087 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9c0e3339..348577df 100644 --- a/README.md +++ b/README.md @@ -1107,7 +1107,7 @@ without feedback, bug reports, or patches from: Khaled Yakdan Kuang-che Wu Josephine Calliotte Konrad Welc Thomas Rooijakkers David Carlier - Ruben ten Hove + Ruben ten Hove Joey Jiao ``` Thank you! -- cgit 1.4.1 From bb9d27535018caf41557fa042884e3edf7836f8b Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Wed, 20 Jan 2021 14:26:02 +0800 Subject: afl_frida: Add AFL_FRIDA_TEST_INPUT env to debug input --- utils/afl_frida/afl-frida.c | 184 +++++++++++++++++++++++--------------------- 1 file changed, 96 insertions(+), 88 deletions(-) diff --git a/utils/afl_frida/afl-frida.c b/utils/afl_frida/afl-frida.c index 4a99d6ed..087f18e8 100644 --- a/utils/afl_frida/afl-frida.c +++ b/utils/afl_frida/afl-frida.c @@ -196,100 +196,108 @@ int main(int argc, char** argv) { // END STEP 2 - gum_init_embedded(); - if (!gum_stalker_is_supported()) { - - gum_deinit_embedded(); - return 1; - - } - - GumStalker *stalker = gum_stalker_new(); - - GumAddress base_address; - if (argc > 2) - base_address = gum_module_find_base_address(argv[1]); - else - base_address = gum_module_find_base_address(TARGET_LIBRARY); - GumMemoryRange code_range; - if (argc > 2) - gum_module_enumerate_ranges(argv[1], GUM_PAGE_RX, enumerate_ranges, - &code_range); - else - gum_module_enumerate_ranges(TARGET_LIBRARY, GUM_PAGE_RX, enumerate_ranges, - &code_range); - - guint64 code_start = code_range.base_address; - guint64 code_end = code_range.base_address + code_range.size; - range_t instr_range = {0, code_start, code_end}; - - printf("Frida instrumentation: base=0x%lx instrumenting=0x%lx-%lx\n", - base_address, code_start, code_end); - if (!code_start || !code_end) { - + if (!getenv("AFL_FRIDA_TEST_INPUT")) { + gum_init_embedded(); + if (!gum_stalker_is_supported()) { + + gum_deinit_embedded(); + return 1; + + } + + GumStalker *stalker = gum_stalker_new(); + + GumAddress base_address; if (argc > 2) - fprintf(stderr, "Error: no valid memory address found for %s\n", - argv[1]); + base_address = gum_module_find_base_address(argv[1]); else - fprintf(stderr, "Error: no valid memory address found for %s\n", - TARGET_LIBRARY); - exit(-1); - - } - - GumStalkerTransformer *transformer = - gum_stalker_transformer_make_from_callback(instr_basic_block, - &instr_range, NULL); - - // to ensure that the signatures are not optimized out - memcpy(__afl_area_ptr, (void *)AFL_PERSISTENT, sizeof(AFL_PERSISTENT) + 1); - memcpy(__afl_area_ptr + 32, (void *)AFL_DEFER_FORKSVR, - sizeof(AFL_DEFER_FORKSVR) + 1); - __afl_manual_init(); - - // - // any expensive target library initialization that has to be done just once - // - put that here - // - - gum_stalker_follow_me(stalker, transformer, NULL); - - while (__afl_persistent_loop(UINT32_MAX) != 0) { - - previous_pc = 0; // Required! - -#ifdef _DEBUG - fprintf(stderr, "CLIENT crc: %016llx len: %u\n", - hash64(__afl_fuzz_ptr, *__afl_fuzz_len), *__afl_fuzz_len); - fprintf(stderr, "RECV:"); - for (int i = 0; i < *__afl_fuzz_len; i++) - fprintf(stderr, "%02x", __afl_fuzz_ptr[i]); - fprintf(stderr, "\n"); -#endif - - // STEP 3: ensure the minimum length is present and setup the target - // function to fuzz. - - if (*__afl_fuzz_len > 0) { - - __afl_fuzz_ptr[*__afl_fuzz_len] = 0; // if you need to null terminate - (*o_function)(__afl_fuzz_ptr, *__afl_fuzz_len); - + base_address = gum_module_find_base_address(TARGET_LIBRARY); + GumMemoryRange code_range; + if (argc > 2) + gum_module_enumerate_ranges(argv[1], GUM_PAGE_RX, enumerate_ranges, + &code_range); + else + gum_module_enumerate_ranges(TARGET_LIBRARY, GUM_PAGE_RX, enumerate_ranges, + &code_range); + + guint64 code_start = code_range.base_address; + guint64 code_end = code_range.base_address + code_range.size; + range_t instr_range = {0, code_start, code_end}; + + printf("Frida instrumentation: base=0x%lx instrumenting=0x%lx-%lx\n", + base_address, code_start, code_end); + if (!code_start || !code_end) { + + if (argc > 2) + fprintf(stderr, "Error: no valid memory address found for %s\n", + argv[1]); + else + fprintf(stderr, "Error: no valid memory address found for %s\n", + TARGET_LIBRARY); + exit(-1); + } + + GumStalkerTransformer *transformer = + gum_stalker_transformer_make_from_callback(instr_basic_block, + &instr_range, NULL); + + // to ensure that the signatures are not optimized out + memcpy(__afl_area_ptr, (void *)AFL_PERSISTENT, sizeof(AFL_PERSISTENT) + 1); + memcpy(__afl_area_ptr + 32, (void *)AFL_DEFER_FORKSVR, + sizeof(AFL_DEFER_FORKSVR) + 1); + __afl_manual_init(); + + // + // any expensive target library initialization that has to be done just once + // - put that here + // + + gum_stalker_follow_me(stalker, transformer, NULL); + + while (__afl_persistent_loop(UINT32_MAX) != 0) { + + previous_pc = 0; // Required! + + #ifdef _DEBUG + fprintf(stderr, "CLIENT crc: %016llx len: %u\n", + hash64(__afl_fuzz_ptr, *__afl_fuzz_len), *__afl_fuzz_len); + fprintf(stderr, "RECV:"); + for (int i = 0; i < *__afl_fuzz_len; i++) + fprintf(stderr, "%02x", __afl_fuzz_ptr[i]); + fprintf(stderr, "\n"); + #endif + + // STEP 3: ensure the minimum length is present and setup the target + // function to fuzz. + + if (*__afl_fuzz_len > 0) { + + __afl_fuzz_ptr[*__afl_fuzz_len] = 0; // if you need to null terminate + (*o_function)(__afl_fuzz_ptr, *__afl_fuzz_len); + + } + + // END STEP 3 + + } + + gum_stalker_unfollow_me(stalker); + + while (gum_stalker_garbage_collect(stalker)) + g_usleep(10000); + + g_object_unref(stalker); + g_object_unref(transformer); + gum_deinit_embedded(); - // END STEP 3 - + } else { + char buf[8*1024] = {0}; + int count = read(0, buf, sizeof(buf)); + buf[8*1024-1] = '\0'; + (*o_function)(buf, count); } - gum_stalker_unfollow_me(stalker); - - while (gum_stalker_garbage_collect(stalker)) - g_usleep(10000); - - g_object_unref(stalker); - g_object_unref(transformer); - gum_deinit_embedded(); - return 0; } -- cgit 1.4.1 From 9dff3495d54c0bd3da59ef43ca25df06c6d9f2c2 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 20 Jan 2021 10:01:34 +0100 Subject: better cmp map fsrv fix --- src/afl-forkserver.c | 4 +++- src/afl-fuzz-cmplog.c | 2 ++ src/afl-fuzz.c | 14 -------------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c index 39f044f2..c1b3d02f 100644 --- a/src/afl-forkserver.c +++ b/src/afl-forkserver.c @@ -58,7 +58,9 @@ static list_t fsrv_list = {.element_prealloc_count = 0}; static void fsrv_exec_child(afl_forkserver_t *fsrv, char **argv) { - if (fsrv->qemu_mode) setenv("AFL_DISABLE_LLVM_INSTRUMENTATION", "1", 0); + if (fsrv->qemu_mode) { setenv("AFL_DISABLE_LLVM_INSTRUMENTATION", "1", 0); } + + unsetenv(CMPLOG_SHM_ENV_VAR); // we do not want that in non-cmplog fsrv execv(fsrv->target_path, argv); diff --git a/src/afl-fuzz-cmplog.c b/src/afl-fuzz-cmplog.c index 8ffc6e1b..27c6c413 100644 --- a/src/afl-fuzz-cmplog.c +++ b/src/afl-fuzz-cmplog.c @@ -33,6 +33,8 @@ void cmplog_exec_child(afl_forkserver_t *fsrv, char **argv) { setenv("___AFL_EINS_ZWEI_POLIZEI___", "1", 1); + if (fsrv->qemu_mode) { setenv("AFL_DISABLE_LLVM_INSTRUMENTATION", "1", 0); } + if (!fsrv->qemu_mode && argv[0] != fsrv->cmplog_binary) { argv[0] = fsrv->cmplog_binary; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 0f76e8a3..88c40ee8 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1515,21 +1515,7 @@ int main(int argc, char **argv_orig, char **envp) { } - u8 *save_env = NULL; - if (afl->cmplog_binary) { - - save_env = ck_strdup(getenv(CMPLOG_SHM_ENV_VAR)); - unsetenv(CMPLOG_SHM_ENV_VAR); // normal forkserver should not have this - - } - perform_dry_run(afl); - if (save_env) { - - setenv(CMPLOG_SHM_ENV_VAR, save_env, 1); // needed for at_exit() - ck_free(save_env); - - } /* if (!user_set_cache && afl->q_testcase_max_cache_size) { -- cgit 1.4.1 From 02079d8ef9c1661e4badd464ebcd7668e88118fc Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Wed, 20 Jan 2021 19:16:57 +0800 Subject: android: Remove frida-gum package --- utils/afl_frida/android/README.md | 1 + utils/afl_frida/android/frida-gum.h | 51342 ------------------------------- utils/afl_frida/android/libfrida-gum.a | Bin 41417006 -> 0 bytes 3 files changed, 1 insertion(+), 51342 deletions(-) create mode 100644 utils/afl_frida/android/README.md delete mode 100644 utils/afl_frida/android/frida-gum.h delete mode 100644 utils/afl_frida/android/libfrida-gum.a diff --git a/utils/afl_frida/android/README.md b/utils/afl_frida/android/README.md new file mode 100644 index 00000000..044b48a1 --- /dev/null +++ b/utils/afl_frida/android/README.md @@ -0,0 +1 @@ +For android, frida-gum package (ex. https://github.com/frida/frida/releases/download/14.2.6/frida-gum-devkit-14.2.6-android-arm64.tar.xz) is needed to be extracted in the directory. diff --git a/utils/afl_frida/android/frida-gum.h b/utils/afl_frida/android/frida-gum.h deleted file mode 100644 index 52176cbd..00000000 --- a/utils/afl_frida/android/frida-gum.h +++ /dev/null @@ -1,51342 +0,0 @@ -#ifndef GUM_STATIC -# define GUM_STATIC -#endif - -#ifndef __FRIDA_SYMBOL_MAPPINGS__ -#define __FRIDA_SYMBOL_MAPPINGS__ - -#define cs_close _frida_cs_close -#define cs_disasm _frida_cs_disasm -#define cs_disasm_iter _frida_cs_disasm_iter -#define cs_errno _frida_cs_errno -#define cs_free _frida_cs_free -#define cs_group_name _frida_cs_group_name -#define cs_insn_group _frida_cs_insn_group -#define cs_insn_name _frida_cs_insn_name -#define cs_malloc _frida_cs_malloc -#define cs_mem_calloc _frida_cs_mem_calloc -#define cs_mem_free _frida_cs_mem_free -#define cs_mem_malloc _frida_cs_mem_malloc -#define cs_mem_realloc _frida_cs_mem_realloc -#define cs_op_count _frida_cs_op_count -#define cs_op_index _frida_cs_op_index -#define cs_open _frida_cs_open -#define cs_option _frida_cs_option -#define cs_reg_name _frida_cs_reg_name -#define cs_reg_read _frida_cs_reg_read -#define cs_reg_write _frida_cs_reg_write -#define cs_regs_access _frida_cs_regs_access -#define cs_snprintf _frida_cs_snprintf -#define cs_strdup _frida_cs_strdup -#define cs_strerror _frida_cs_strerror -#define cs_support _frida_cs_support -#define cs_version _frida_cs_version -#define cs_vsnprintf _frida_cs_vsnprintf -#define g__inotify_lock_lock _frida_g__inotify_lock_lock -#define g_access _frida_g_access -#define g_action_activate _frida_g_action_activate -#define g_action_change_state _frida_g_action_change_state -#define g_action_get_enabled _frida_g_action_get_enabled -#define g_action_get_name _frida_g_action_get_name -#define g_action_get_parameter_type _frida_g_action_get_parameter_type -#define g_action_get_state _frida_g_action_get_state -#define g_action_get_state_hint _frida_g_action_get_state_hint -#define g_action_get_state_type _frida_g_action_get_state_type -#define g_action_get_type _frida_g_action_get_type -#define g_action_group_action_added _frida_g_action_group_action_added -#define g_action_group_action_enabled_changed _frida_g_action_group_action_enabled_changed -#define g_action_group_action_removed _frida_g_action_group_action_removed -#define g_action_group_action_state_changed _frida_g_action_group_action_state_changed -#define g_action_group_activate_action _frida_g_action_group_activate_action -#define g_action_group_change_action_state _frida_g_action_group_change_action_state -#define g_action_group_get_action_enabled _frida_g_action_group_get_action_enabled -#define g_action_group_get_action_parameter_type _frida_g_action_group_get_action_parameter_type -#define g_action_group_get_action_state _frida_g_action_group_get_action_state -#define g_action_group_get_action_state_hint _frida_g_action_group_get_action_state_hint -#define g_action_group_get_action_state_type _frida_g_action_group_get_action_state_type -#define g_action_group_get_type _frida_g_action_group_get_type -#define g_action_group_has_action _frida_g_action_group_has_action -#define g_action_group_list_actions _frida_g_action_group_list_actions -#define g_action_group_query_action _frida_g_action_group_query_action -#define g_action_map_add_action _frida_g_action_map_add_action -#define g_action_map_add_action_entries _frida_g_action_map_add_action_entries -#define g_action_map_get_type _frida_g_action_map_get_type -#define g_action_map_lookup_action _frida_g_action_map_lookup_action -#define g_action_map_remove_action _frida_g_action_map_remove_action -#define g_action_name_is_valid _frida_g_action_name_is_valid -#define g_action_parse_detailed_name _frida_g_action_parse_detailed_name -#define g_action_print_detailed_name _frida_g_action_print_detailed_name -#define g_allocator_free _frida_g_allocator_free -#define g_allocator_new _frida_g_allocator_new -#define g_app_info_add_supports_type _frida_g_app_info_add_supports_type -#define g_app_info_can_delete _frida_g_app_info_can_delete -#define g_app_info_can_remove_supports_type _frida_g_app_info_can_remove_supports_type -#define g_app_info_create_flags_get_type _frida_g_app_info_create_flags_get_type -#define g_app_info_create_from_commandline _frida_g_app_info_create_from_commandline -#define g_app_info_delete _frida_g_app_info_delete -#define g_app_info_dup _frida_g_app_info_dup -#define g_app_info_equal _frida_g_app_info_equal -#define g_app_info_get_all _frida_g_app_info_get_all -#define g_app_info_get_all_for_type _frida_g_app_info_get_all_for_type -#define g_app_info_get_commandline _frida_g_app_info_get_commandline -#define g_app_info_get_default_for_type _frida_g_app_info_get_default_for_type -#define g_app_info_get_default_for_uri_scheme _frida_g_app_info_get_default_for_uri_scheme -#define g_app_info_get_description _frida_g_app_info_get_description -#define g_app_info_get_display_name _frida_g_app_info_get_display_name -#define g_app_info_get_executable _frida_g_app_info_get_executable -#define g_app_info_get_fallback_for_type _frida_g_app_info_get_fallback_for_type -#define g_app_info_get_icon _frida_g_app_info_get_icon -#define g_app_info_get_id _frida_g_app_info_get_id -#define g_app_info_get_name _frida_g_app_info_get_name -#define g_app_info_get_recommended_for_type _frida_g_app_info_get_recommended_for_type -#define g_app_info_get_supported_types _frida_g_app_info_get_supported_types -#define g_app_info_get_type _frida_g_app_info_get_type -#define g_app_info_launch _frida_g_app_info_launch -#define g_app_info_launch_default_for_uri _frida_g_app_info_launch_default_for_uri -#define g_app_info_launch_default_for_uri_async _frida_g_app_info_launch_default_for_uri_async -#define g_app_info_launch_default_for_uri_finish _frida_g_app_info_launch_default_for_uri_finish -#define g_app_info_launch_uris _frida_g_app_info_launch_uris -#define g_app_info_launch_uris_async _frida_g_app_info_launch_uris_async -#define g_app_info_launch_uris_finish _frida_g_app_info_launch_uris_finish -#define g_app_info_monitor_fire _frida_g_app_info_monitor_fire -#define g_app_info_monitor_get _frida_g_app_info_monitor_get -#define g_app_info_monitor_get_type _frida_g_app_info_monitor_get_type -#define g_app_info_remove_supports_type _frida_g_app_info_remove_supports_type -#define g_app_info_reset_type_associations _frida_g_app_info_reset_type_associations -#define g_app_info_set_as_default_for_extension _frida_g_app_info_set_as_default_for_extension -#define g_app_info_set_as_default_for_type _frida_g_app_info_set_as_default_for_type -#define g_app_info_set_as_last_used_for_type _frida_g_app_info_set_as_last_used_for_type -#define g_app_info_should_show _frida_g_app_info_should_show -#define g_app_info_supports_files _frida_g_app_info_supports_files -#define g_app_info_supports_uris _frida_g_app_info_supports_uris -#define g_app_launch_context_get_display _frida_g_app_launch_context_get_display -#define g_app_launch_context_get_environment _frida_g_app_launch_context_get_environment -#define g_app_launch_context_get_startup_notify_id _frida_g_app_launch_context_get_startup_notify_id -#define g_app_launch_context_get_type _frida_g_app_launch_context_get_type -#define g_app_launch_context_launch_failed _frida_g_app_launch_context_launch_failed -#define g_app_launch_context_new _frida_g_app_launch_context_new -#define g_app_launch_context_setenv _frida_g_app_launch_context_setenv -#define g_app_launch_context_unsetenv _frida_g_app_launch_context_unsetenv -#define g_application_activate _frida_g_application_activate -#define g_application_add_main_option _frida_g_application_add_main_option -#define g_application_add_main_option_entries _frida_g_application_add_main_option_entries -#define g_application_add_option_group _frida_g_application_add_option_group -#define g_application_bind_busy_property _frida_g_application_bind_busy_property -#define g_application_command_line_create_file_for_arg _frida_g_application_command_line_create_file_for_arg -#define g_application_command_line_get_arguments _frida_g_application_command_line_get_arguments -#define g_application_command_line_get_cwd _frida_g_application_command_line_get_cwd -#define g_application_command_line_get_environ _frida_g_application_command_line_get_environ -#define g_application_command_line_get_exit_status _frida_g_application_command_line_get_exit_status -#define g_application_command_line_get_is_remote _frida_g_application_command_line_get_is_remote -#define g_application_command_line_get_options_dict _frida_g_application_command_line_get_options_dict -#define g_application_command_line_get_platform_data _frida_g_application_command_line_get_platform_data -#define g_application_command_line_get_stdin _frida_g_application_command_line_get_stdin -#define g_application_command_line_get_type _frida_g_application_command_line_get_type -#define g_application_command_line_getenv _frida_g_application_command_line_getenv -#define g_application_command_line_print _frida_g_application_command_line_print -#define g_application_command_line_printerr _frida_g_application_command_line_printerr -#define g_application_command_line_set_exit_status _frida_g_application_command_line_set_exit_status -#define g_application_flags_get_type _frida_g_application_flags_get_type -#define g_application_get_application_id _frida_g_application_get_application_id -#define g_application_get_dbus_connection _frida_g_application_get_dbus_connection -#define g_application_get_dbus_object_path _frida_g_application_get_dbus_object_path -#define g_application_get_default _frida_g_application_get_default -#define g_application_get_flags _frida_g_application_get_flags -#define g_application_get_inactivity_timeout _frida_g_application_get_inactivity_timeout -#define g_application_get_is_busy _frida_g_application_get_is_busy -#define g_application_get_is_registered _frida_g_application_get_is_registered -#define g_application_get_is_remote _frida_g_application_get_is_remote -#define g_application_get_resource_base_path _frida_g_application_get_resource_base_path -#define g_application_get_type _frida_g_application_get_type -#define g_application_hold _frida_g_application_hold -#define g_application_id_is_valid _frida_g_application_id_is_valid -#define g_application_impl_activate _frida_g_application_impl_activate -#define g_application_impl_command_line _frida_g_application_impl_command_line -#define g_application_impl_destroy _frida_g_application_impl_destroy -#define g_application_impl_flush _frida_g_application_impl_flush -#define g_application_impl_get_dbus_connection _frida_g_application_impl_get_dbus_connection -#define g_application_impl_get_dbus_object_path _frida_g_application_impl_get_dbus_object_path -#define g_application_impl_open _frida_g_application_impl_open -#define g_application_impl_register _frida_g_application_impl_register -#define g_application_impl_set_busy_state _frida_g_application_impl_set_busy_state -#define g_application_mark_busy _frida_g_application_mark_busy -#define g_application_new _frida_g_application_new -#define g_application_open _frida_g_application_open -#define g_application_quit _frida_g_application_quit -#define g_application_register _frida_g_application_register -#define g_application_release _frida_g_application_release -#define g_application_run _frida_g_application_run -#define g_application_send_notification _frida_g_application_send_notification -#define g_application_set_action_group _frida_g_application_set_action_group -#define g_application_set_application_id _frida_g_application_set_application_id -#define g_application_set_default _frida_g_application_set_default -#define g_application_set_flags _frida_g_application_set_flags -#define g_application_set_inactivity_timeout _frida_g_application_set_inactivity_timeout -#define g_application_set_option_context_description _frida_g_application_set_option_context_description -#define g_application_set_option_context_parameter_string _frida_g_application_set_option_context_parameter_string -#define g_application_set_option_context_summary _frida_g_application_set_option_context_summary -#define g_application_set_resource_base_path _frida_g_application_set_resource_base_path -#define g_application_unbind_busy_property _frida_g_application_unbind_busy_property -#define g_application_unmark_busy _frida_g_application_unmark_busy -#define g_application_withdraw_notification _frida_g_application_withdraw_notification -#define g_array_append_vals _frida_g_array_append_vals -#define g_array_binary_search _frida_g_array_binary_search -#define g_array_copy _frida_g_array_copy -#define g_array_free _frida_g_array_free -#define g_array_get_element_size _frida_g_array_get_element_size -#define g_array_get_type _frida_g_array_get_type -#define g_array_insert_vals _frida_g_array_insert_vals -#define g_array_new _frida_g_array_new -#define g_array_prepend_vals _frida_g_array_prepend_vals -#define g_array_ref _frida_g_array_ref -#define g_array_remove_index _frida_g_array_remove_index -#define g_array_remove_index_fast _frida_g_array_remove_index_fast -#define g_array_remove_range _frida_g_array_remove_range -#define g_array_set_clear_func _frida_g_array_set_clear_func -#define g_array_set_size _frida_g_array_set_size -#define g_array_sized_new _frida_g_array_sized_new -#define g_array_sort _frida_g_array_sort -#define g_array_sort_with_data _frida_g_array_sort_with_data -#define g_array_steal _frida_g_array_steal -#define g_array_unref _frida_g_array_unref -#define g_ascii_digit_value _frida_g_ascii_digit_value -#define g_ascii_dtostr _frida_g_ascii_dtostr -#define g_ascii_formatd _frida_g_ascii_formatd -#define g_ascii_strcasecmp _frida_g_ascii_strcasecmp -#define g_ascii_strdown _frida_g_ascii_strdown -#define g_ascii_string_to_signed _frida_g_ascii_string_to_signed -#define g_ascii_string_to_unsigned _frida_g_ascii_string_to_unsigned -#define g_ascii_strncasecmp _frida_g_ascii_strncasecmp -#define g_ascii_strtod _frida_g_ascii_strtod -#define g_ascii_strtoll _frida_g_ascii_strtoll -#define g_ascii_strtoull _frida_g_ascii_strtoull -#define g_ascii_strup _frida_g_ascii_strup -#define g_ascii_table _frida_g_ascii_table -#define g_ascii_tolower _frida_g_ascii_tolower -#define g_ascii_toupper _frida_g_ascii_toupper -#define g_ascii_xdigit_value _frida_g_ascii_xdigit_value -#define g_ask_password_flags_get_type _frida_g_ask_password_flags_get_type -#define g_assert_warning _frida_g_assert_warning -#define g_assertion_message _frida_g_assertion_message -#define g_assertion_message_cmpnum _frida_g_assertion_message_cmpnum -#define g_assertion_message_cmpstr _frida_g_assertion_message_cmpstr -#define g_assertion_message_cmpstrv _frida_g_assertion_message_cmpstrv -#define g_assertion_message_error _frida_g_assertion_message_error -#define g_assertion_message_expr _frida_g_assertion_message_expr -#define g_assertion_set_handler _frida_g_assertion_set_handler -#define g_async_initable_get_type _frida_g_async_initable_get_type -#define g_async_initable_init_async _frida_g_async_initable_init_async -#define g_async_initable_init_finish _frida_g_async_initable_init_finish -#define g_async_initable_new_async _frida_g_async_initable_new_async -#define g_async_initable_new_finish _frida_g_async_initable_new_finish -#define g_async_initable_new_valist_async _frida_g_async_initable_new_valist_async -#define g_async_initable_newv_async _frida_g_async_initable_newv_async -#define g_async_queue_length _frida_g_async_queue_length -#define g_async_queue_length_unlocked _frida_g_async_queue_length_unlocked -#define g_async_queue_lock _frida_g_async_queue_lock -#define g_async_queue_new _frida_g_async_queue_new -#define g_async_queue_new_full _frida_g_async_queue_new_full -#define g_async_queue_pop _frida_g_async_queue_pop -#define g_async_queue_pop_unlocked _frida_g_async_queue_pop_unlocked -#define g_async_queue_push _frida_g_async_queue_push -#define g_async_queue_push_front _frida_g_async_queue_push_front -#define g_async_queue_push_front_unlocked _frida_g_async_queue_push_front_unlocked -#define g_async_queue_push_sorted _frida_g_async_queue_push_sorted -#define g_async_queue_push_sorted_unlocked _frida_g_async_queue_push_sorted_unlocked -#define g_async_queue_push_unlocked _frida_g_async_queue_push_unlocked -#define g_async_queue_ref _frida_g_async_queue_ref -#define g_async_queue_ref_unlocked _frida_g_async_queue_ref_unlocked -#define g_async_queue_remove _frida_g_async_queue_remove -#define g_async_queue_remove_unlocked _frida_g_async_queue_remove_unlocked -#define g_async_queue_sort _frida_g_async_queue_sort -#define g_async_queue_sort_unlocked _frida_g_async_queue_sort_unlocked -#define g_async_queue_timed_pop _frida_g_async_queue_timed_pop -#define g_async_queue_timed_pop_unlocked _frida_g_async_queue_timed_pop_unlocked -#define g_async_queue_timeout_pop _frida_g_async_queue_timeout_pop -#define g_async_queue_timeout_pop_unlocked _frida_g_async_queue_timeout_pop_unlocked -#define g_async_queue_try_pop _frida_g_async_queue_try_pop -#define g_async_queue_try_pop_unlocked _frida_g_async_queue_try_pop_unlocked -#define g_async_queue_unlock _frida_g_async_queue_unlock -#define g_async_queue_unref _frida_g_async_queue_unref -#define g_async_queue_unref_and_unlock _frida_g_async_queue_unref_and_unlock -#define g_async_result_get_source_object _frida_g_async_result_get_source_object -#define g_async_result_get_type _frida_g_async_result_get_type -#define g_async_result_get_user_data _frida_g_async_result_get_user_data -#define g_async_result_is_tagged _frida_g_async_result_is_tagged -#define g_async_result_legacy_propagate_error _frida_g_async_result_legacy_propagate_error -#define g_atexit _frida_g_atexit -#define g_atomic_int_add _frida_g_atomic_int_add -#define g_atomic_int_and _frida_g_atomic_int_and -#define g_atomic_int_compare_and_exchange _frida_g_atomic_int_compare_and_exchange -#define g_atomic_int_dec_and_test _frida_g_atomic_int_dec_and_test -#define g_atomic_int_exchange_and_add _frida_g_atomic_int_exchange_and_add -#define g_atomic_int_get _frida_g_atomic_int_get -#define g_atomic_int_inc _frida_g_atomic_int_inc -#define g_atomic_int_or _frida_g_atomic_int_or -#define g_atomic_int_set _frida_g_atomic_int_set -#define g_atomic_int_xor _frida_g_atomic_int_xor -#define g_atomic_pointer_add _frida_g_atomic_pointer_add -#define g_atomic_pointer_and _frida_g_atomic_pointer_and -#define g_atomic_pointer_compare_and_exchange _frida_g_atomic_pointer_compare_and_exchange -#define g_atomic_pointer_get _frida_g_atomic_pointer_get -#define g_atomic_pointer_or _frida_g_atomic_pointer_or -#define g_atomic_pointer_set _frida_g_atomic_pointer_set -#define g_atomic_pointer_xor _frida_g_atomic_pointer_xor -#define g_atomic_rc_box_acquire _frida_g_atomic_rc_box_acquire -#define g_atomic_rc_box_alloc _frida_g_atomic_rc_box_alloc -#define g_atomic_rc_box_alloc0 _frida_g_atomic_rc_box_alloc0 -#define g_atomic_rc_box_dup _frida_g_atomic_rc_box_dup -#define g_atomic_rc_box_get_size _frida_g_atomic_rc_box_get_size -#define g_atomic_rc_box_release _frida_g_atomic_rc_box_release -#define g_atomic_rc_box_release_full _frida_g_atomic_rc_box_release_full -#define g_atomic_ref_count_compare _frida_g_atomic_ref_count_compare -#define g_atomic_ref_count_dec _frida_g_atomic_ref_count_dec -#define g_atomic_ref_count_inc _frida_g_atomic_ref_count_inc -#define g_atomic_ref_count_init _frida_g_atomic_ref_count_init -#define g_base64_decode _frida_g_base64_decode -#define g_base64_decode_inplace _frida_g_base64_decode_inplace -#define g_base64_decode_step _frida_g_base64_decode_step -#define g_base64_encode _frida_g_base64_encode -#define g_base64_encode_close _frida_g_base64_encode_close -#define g_base64_encode_step _frida_g_base64_encode_step -#define g_basename _frida_g_basename -#define g_binding_dup_source _frida_g_binding_dup_source -#define g_binding_dup_target _frida_g_binding_dup_target -#define g_binding_flags_get_type _frida_g_binding_flags_get_type -#define g_binding_get_flags _frida_g_binding_get_flags -#define g_binding_get_source _frida_g_binding_get_source -#define g_binding_get_source_property _frida_g_binding_get_source_property -#define g_binding_get_target _frida_g_binding_get_target -#define g_binding_get_target_property _frida_g_binding_get_target_property -#define g_binding_get_type _frida_g_binding_get_type -#define g_binding_unbind _frida_g_binding_unbind -#define g_bit_lock _frida_g_bit_lock -#define g_bit_nth_lsf _frida_g_bit_nth_lsf -#define g_bit_nth_msf _frida_g_bit_nth_msf -#define g_bit_storage _frida_g_bit_storage -#define g_bit_trylock _frida_g_bit_trylock -#define g_bit_unlock _frida_g_bit_unlock -#define g_blow_chunks _frida_g_blow_chunks -#define g_bookmark_file_add_application _frida_g_bookmark_file_add_application -#define g_bookmark_file_add_group _frida_g_bookmark_file_add_group -#define g_bookmark_file_error_quark _frida_g_bookmark_file_error_quark -#define g_bookmark_file_free _frida_g_bookmark_file_free -#define g_bookmark_file_get_added _frida_g_bookmark_file_get_added -#define g_bookmark_file_get_added_date_time _frida_g_bookmark_file_get_added_date_time -#define g_bookmark_file_get_app_info _frida_g_bookmark_file_get_app_info -#define g_bookmark_file_get_application_info _frida_g_bookmark_file_get_application_info -#define g_bookmark_file_get_applications _frida_g_bookmark_file_get_applications -#define g_bookmark_file_get_description _frida_g_bookmark_file_get_description -#define g_bookmark_file_get_groups _frida_g_bookmark_file_get_groups -#define g_bookmark_file_get_icon _frida_g_bookmark_file_get_icon -#define g_bookmark_file_get_is_private _frida_g_bookmark_file_get_is_private -#define g_bookmark_file_get_mime_type _frida_g_bookmark_file_get_mime_type -#define g_bookmark_file_get_modified _frida_g_bookmark_file_get_modified -#define g_bookmark_file_get_modified_date_time _frida_g_bookmark_file_get_modified_date_time -#define g_bookmark_file_get_size _frida_g_bookmark_file_get_size -#define g_bookmark_file_get_title _frida_g_bookmark_file_get_title -#define g_bookmark_file_get_uris _frida_g_bookmark_file_get_uris -#define g_bookmark_file_get_visited _frida_g_bookmark_file_get_visited -#define g_bookmark_file_get_visited_date_time _frida_g_bookmark_file_get_visited_date_time -#define g_bookmark_file_has_application _frida_g_bookmark_file_has_application -#define g_bookmark_file_has_group _frida_g_bookmark_file_has_group -#define g_bookmark_file_has_item _frida_g_bookmark_file_has_item -#define g_bookmark_file_load_from_data _frida_g_bookmark_file_load_from_data -#define g_bookmark_file_load_from_data_dirs _frida_g_bookmark_file_load_from_data_dirs -#define g_bookmark_file_load_from_file _frida_g_bookmark_file_load_from_file -#define g_bookmark_file_move_item _frida_g_bookmark_file_move_item -#define g_bookmark_file_new _frida_g_bookmark_file_new -#define g_bookmark_file_remove_application _frida_g_bookmark_file_remove_application -#define g_bookmark_file_remove_group _frida_g_bookmark_file_remove_group -#define g_bookmark_file_remove_item _frida_g_bookmark_file_remove_item -#define g_bookmark_file_set_added _frida_g_bookmark_file_set_added -#define g_bookmark_file_set_added_date_time _frida_g_bookmark_file_set_added_date_time -#define g_bookmark_file_set_app_info _frida_g_bookmark_file_set_app_info -#define g_bookmark_file_set_application_info _frida_g_bookmark_file_set_application_info -#define g_bookmark_file_set_description _frida_g_bookmark_file_set_description -#define g_bookmark_file_set_groups _frida_g_bookmark_file_set_groups -#define g_bookmark_file_set_icon _frida_g_bookmark_file_set_icon -#define g_bookmark_file_set_is_private _frida_g_bookmark_file_set_is_private -#define g_bookmark_file_set_mime_type _frida_g_bookmark_file_set_mime_type -#define g_bookmark_file_set_modified _frida_g_bookmark_file_set_modified -#define g_bookmark_file_set_modified_date_time _frida_g_bookmark_file_set_modified_date_time -#define g_bookmark_file_set_title _frida_g_bookmark_file_set_title -#define g_bookmark_file_set_visited _frida_g_bookmark_file_set_visited -#define g_bookmark_file_set_visited_date_time _frida_g_bookmark_file_set_visited_date_time -#define g_bookmark_file_to_data _frida_g_bookmark_file_to_data -#define g_bookmark_file_to_file _frida_g_bookmark_file_to_file -#define g_boxed_copy _frida_g_boxed_copy -#define g_boxed_free _frida_g_boxed_free -#define g_boxed_type_register_static _frida_g_boxed_type_register_static -#define g_buffered_input_stream_fill _frida_g_buffered_input_stream_fill -#define g_buffered_input_stream_fill_async _frida_g_buffered_input_stream_fill_async -#define g_buffered_input_stream_fill_finish _frida_g_buffered_input_stream_fill_finish -#define g_buffered_input_stream_get_available _frida_g_buffered_input_stream_get_available -#define g_buffered_input_stream_get_buffer_size _frida_g_buffered_input_stream_get_buffer_size -#define g_buffered_input_stream_get_type _frida_g_buffered_input_stream_get_type -#define g_buffered_input_stream_new _frida_g_buffered_input_stream_new -#define g_buffered_input_stream_new_sized _frida_g_buffered_input_stream_new_sized -#define g_buffered_input_stream_peek _frida_g_buffered_input_stream_peek -#define g_buffered_input_stream_peek_buffer _frida_g_buffered_input_stream_peek_buffer -#define g_buffered_input_stream_read_byte _frida_g_buffered_input_stream_read_byte -#define g_buffered_input_stream_set_buffer_size _frida_g_buffered_input_stream_set_buffer_size -#define g_buffered_output_stream_get_auto_grow _frida_g_buffered_output_stream_get_auto_grow -#define g_buffered_output_stream_get_buffer_size _frida_g_buffered_output_stream_get_buffer_size -#define g_buffered_output_stream_get_type _frida_g_buffered_output_stream_get_type -#define g_buffered_output_stream_new _frida_g_buffered_output_stream_new -#define g_buffered_output_stream_new_sized _frida_g_buffered_output_stream_new_sized -#define g_buffered_output_stream_set_auto_grow _frida_g_buffered_output_stream_set_auto_grow -#define g_buffered_output_stream_set_buffer_size _frida_g_buffered_output_stream_set_buffer_size -#define g_build_filename _frida_g_build_filename -#define g_build_filename_valist _frida_g_build_filename_valist -#define g_build_filenamev _frida_g_build_filenamev -#define g_build_path _frida_g_build_path -#define g_build_pathv _frida_g_build_pathv -#define g_bus_get _frida_g_bus_get -#define g_bus_get_finish _frida_g_bus_get_finish -#define g_bus_get_sync _frida_g_bus_get_sync -#define g_bus_name_owner_flags_get_type _frida_g_bus_name_owner_flags_get_type -#define g_bus_name_watcher_flags_get_type _frida_g_bus_name_watcher_flags_get_type -#define g_bus_own_name _frida_g_bus_own_name -#define g_bus_own_name_on_connection _frida_g_bus_own_name_on_connection -#define g_bus_own_name_on_connection_with_closures _frida_g_bus_own_name_on_connection_with_closures -#define g_bus_own_name_with_closures _frida_g_bus_own_name_with_closures -#define g_bus_type_get_type _frida_g_bus_type_get_type -#define g_bus_unown_name _frida_g_bus_unown_name -#define g_bus_unwatch_name _frida_g_bus_unwatch_name -#define g_bus_watch_name _frida_g_bus_watch_name -#define g_bus_watch_name_on_connection _frida_g_bus_watch_name_on_connection -#define g_bus_watch_name_on_connection_with_closures _frida_g_bus_watch_name_on_connection_with_closures -#define g_bus_watch_name_with_closures _frida_g_bus_watch_name_with_closures -#define g_byte_array_append _frida_g_byte_array_append -#define g_byte_array_free _frida_g_byte_array_free -#define g_byte_array_free_to_bytes _frida_g_byte_array_free_to_bytes -#define g_byte_array_get_type _frida_g_byte_array_get_type -#define g_byte_array_new _frida_g_byte_array_new -#define g_byte_array_new_take _frida_g_byte_array_new_take -#define g_byte_array_prepend _frida_g_byte_array_prepend -#define g_byte_array_ref _frida_g_byte_array_ref -#define g_byte_array_remove_index _frida_g_byte_array_remove_index -#define g_byte_array_remove_index_fast _frida_g_byte_array_remove_index_fast -#define g_byte_array_remove_range _frida_g_byte_array_remove_range -#define g_byte_array_set_size _frida_g_byte_array_set_size -#define g_byte_array_sized_new _frida_g_byte_array_sized_new -#define g_byte_array_sort _frida_g_byte_array_sort -#define g_byte_array_sort_with_data _frida_g_byte_array_sort_with_data -#define g_byte_array_steal _frida_g_byte_array_steal -#define g_byte_array_unref _frida_g_byte_array_unref -#define g_bytes_compare _frida_g_bytes_compare -#define g_bytes_equal _frida_g_bytes_equal -#define g_bytes_get_data _frida_g_bytes_get_data -#define g_bytes_get_size _frida_g_bytes_get_size -#define g_bytes_get_type _frida_g_bytes_get_type -#define g_bytes_hash _frida_g_bytes_hash -#define g_bytes_icon_get_bytes _frida_g_bytes_icon_get_bytes -#define g_bytes_icon_get_type _frida_g_bytes_icon_get_type -#define g_bytes_icon_new _frida_g_bytes_icon_new -#define g_bytes_new _frida_g_bytes_new -#define g_bytes_new_from_bytes _frida_g_bytes_new_from_bytes -#define g_bytes_new_static _frida_g_bytes_new_static -#define g_bytes_new_take _frida_g_bytes_new_take -#define g_bytes_new_with_free_func _frida_g_bytes_new_with_free_func -#define g_bytes_ref _frida_g_bytes_ref -#define g_bytes_unref _frida_g_bytes_unref -#define g_bytes_unref_to_array _frida_g_bytes_unref_to_array -#define g_bytes_unref_to_data _frida_g_bytes_unref_to_data -#define g_cache_destroy _frida_g_cache_destroy -#define g_cache_insert _frida_g_cache_insert -#define g_cache_key_foreach _frida_g_cache_key_foreach -#define g_cache_new _frida_g_cache_new -#define g_cache_remove _frida_g_cache_remove -#define g_cache_value_foreach _frida_g_cache_value_foreach -#define g_cancellable_cancel _frida_g_cancellable_cancel -#define g_cancellable_connect _frida_g_cancellable_connect -#define g_cancellable_disconnect _frida_g_cancellable_disconnect -#define g_cancellable_get_current _frida_g_cancellable_get_current -#define g_cancellable_get_fd _frida_g_cancellable_get_fd -#define g_cancellable_get_type _frida_g_cancellable_get_type -#define g_cancellable_is_cancelled _frida_g_cancellable_is_cancelled -#define g_cancellable_make_pollfd _frida_g_cancellable_make_pollfd -#define g_cancellable_new _frida_g_cancellable_new -#define g_cancellable_pop_current _frida_g_cancellable_pop_current -#define g_cancellable_push_current _frida_g_cancellable_push_current -#define g_cancellable_release_fd _frida_g_cancellable_release_fd -#define g_cancellable_reset _frida_g_cancellable_reset -#define g_cancellable_set_error_if_cancelled _frida_g_cancellable_set_error_if_cancelled -#define g_cancellable_source_new _frida_g_cancellable_source_new -#define g_canonicalize_filename _frida_g_canonicalize_filename -#define g_cclosure_marshal_BOOLEAN__BOXED_BOXED _frida_g_cclosure_marshal_BOOLEAN__BOXED_BOXED -#define g_cclosure_marshal_BOOLEAN__BOXED_BOXEDv _frida_g_cclosure_marshal_BOOLEAN__BOXED_BOXEDv -#define g_cclosure_marshal_BOOLEAN__FLAGS _frida_g_cclosure_marshal_BOOLEAN__FLAGS -#define g_cclosure_marshal_BOOLEAN__FLAGSv _frida_g_cclosure_marshal_BOOLEAN__FLAGSv -#define g_cclosure_marshal_STRING__OBJECT_POINTER _frida_g_cclosure_marshal_STRING__OBJECT_POINTER -#define g_cclosure_marshal_STRING__OBJECT_POINTERv _frida_g_cclosure_marshal_STRING__OBJECT_POINTERv -#define g_cclosure_marshal_VOID__BOOLEAN _frida_g_cclosure_marshal_VOID__BOOLEAN -#define g_cclosure_marshal_VOID__BOOLEANv _frida_g_cclosure_marshal_VOID__BOOLEANv -#define g_cclosure_marshal_VOID__BOXED _frida_g_cclosure_marshal_VOID__BOXED -#define g_cclosure_marshal_VOID__BOXEDv _frida_g_cclosure_marshal_VOID__BOXEDv -#define g_cclosure_marshal_VOID__CHAR _frida_g_cclosure_marshal_VOID__CHAR -#define g_cclosure_marshal_VOID__CHARv _frida_g_cclosure_marshal_VOID__CHARv -#define g_cclosure_marshal_VOID__DOUBLE _frida_g_cclosure_marshal_VOID__DOUBLE -#define g_cclosure_marshal_VOID__DOUBLEv _frida_g_cclosure_marshal_VOID__DOUBLEv -#define g_cclosure_marshal_VOID__ENUM _frida_g_cclosure_marshal_VOID__ENUM -#define g_cclosure_marshal_VOID__ENUMv _frida_g_cclosure_marshal_VOID__ENUMv -#define g_cclosure_marshal_VOID__FLAGS _frida_g_cclosure_marshal_VOID__FLAGS -#define g_cclosure_marshal_VOID__FLAGSv _frida_g_cclosure_marshal_VOID__FLAGSv -#define g_cclosure_marshal_VOID__FLOAT _frida_g_cclosure_marshal_VOID__FLOAT -#define g_cclosure_marshal_VOID__FLOATv _frida_g_cclosure_marshal_VOID__FLOATv -#define g_cclosure_marshal_VOID__INT _frida_g_cclosure_marshal_VOID__INT -#define g_cclosure_marshal_VOID__INTv _frida_g_cclosure_marshal_VOID__INTv -#define g_cclosure_marshal_VOID__LONG _frida_g_cclosure_marshal_VOID__LONG -#define g_cclosure_marshal_VOID__LONGv _frida_g_cclosure_marshal_VOID__LONGv -#define g_cclosure_marshal_VOID__OBJECT _frida_g_cclosure_marshal_VOID__OBJECT -#define g_cclosure_marshal_VOID__OBJECTv _frida_g_cclosure_marshal_VOID__OBJECTv -#define g_cclosure_marshal_VOID__PARAM _frida_g_cclosure_marshal_VOID__PARAM -#define g_cclosure_marshal_VOID__PARAMv _frida_g_cclosure_marshal_VOID__PARAMv -#define g_cclosure_marshal_VOID__POINTER _frida_g_cclosure_marshal_VOID__POINTER -#define g_cclosure_marshal_VOID__POINTERv _frida_g_cclosure_marshal_VOID__POINTERv -#define g_cclosure_marshal_VOID__STRING _frida_g_cclosure_marshal_VOID__STRING -#define g_cclosure_marshal_VOID__STRINGv _frida_g_cclosure_marshal_VOID__STRINGv -#define g_cclosure_marshal_VOID__UCHAR _frida_g_cclosure_marshal_VOID__UCHAR -#define g_cclosure_marshal_VOID__UCHARv _frida_g_cclosure_marshal_VOID__UCHARv -#define g_cclosure_marshal_VOID__UINT _frida_g_cclosure_marshal_VOID__UINT -#define g_cclosure_marshal_VOID__UINT_POINTER _frida_g_cclosure_marshal_VOID__UINT_POINTER -#define g_cclosure_marshal_VOID__UINT_POINTERv _frida_g_cclosure_marshal_VOID__UINT_POINTERv -#define g_cclosure_marshal_VOID__UINTv _frida_g_cclosure_marshal_VOID__UINTv -#define g_cclosure_marshal_VOID__ULONG _frida_g_cclosure_marshal_VOID__ULONG -#define g_cclosure_marshal_VOID__ULONGv _frida_g_cclosure_marshal_VOID__ULONGv -#define g_cclosure_marshal_VOID__VARIANT _frida_g_cclosure_marshal_VOID__VARIANT -#define g_cclosure_marshal_VOID__VARIANTv _frida_g_cclosure_marshal_VOID__VARIANTv -#define g_cclosure_marshal_VOID__VOID _frida_g_cclosure_marshal_VOID__VOID -#define g_cclosure_marshal_VOID__VOIDv _frida_g_cclosure_marshal_VOID__VOIDv -#define g_cclosure_marshal_generic _frida_g_cclosure_marshal_generic -#define g_cclosure_marshal_generic_va _frida_g_cclosure_marshal_generic_va -#define g_cclosure_new _frida_g_cclosure_new -#define g_cclosure_new_object _frida_g_cclosure_new_object -#define g_cclosure_new_object_swap _frida_g_cclosure_new_object_swap -#define g_cclosure_new_swap _frida_g_cclosure_new_swap -#define g_charset_converter_get_num_fallbacks _frida_g_charset_converter_get_num_fallbacks -#define g_charset_converter_get_type _frida_g_charset_converter_get_type -#define g_charset_converter_get_use_fallback _frida_g_charset_converter_get_use_fallback -#define g_charset_converter_new _frida_g_charset_converter_new -#define g_charset_converter_set_use_fallback _frida_g_charset_converter_set_use_fallback -#define g_chdir _frida_g_chdir -#define g_check_setuid _frida_g_check_setuid -#define g_checksum_copy _frida_g_checksum_copy -#define g_checksum_free _frida_g_checksum_free -#define g_checksum_get_digest _frida_g_checksum_get_digest -#define g_checksum_get_string _frida_g_checksum_get_string -#define g_checksum_get_type _frida_g_checksum_get_type -#define g_checksum_new _frida_g_checksum_new -#define g_checksum_reset _frida_g_checksum_reset -#define g_checksum_type_get_length _frida_g_checksum_type_get_length -#define g_checksum_update _frida_g_checksum_update -#define g_child_watch_add _frida_g_child_watch_add -#define g_child_watch_add_full _frida_g_child_watch_add_full -#define g_child_watch_funcs _frida_g_child_watch_funcs -#define g_child_watch_source_new _frida_g_child_watch_source_new -#define g_chmod _frida_g_chmod -#define g_clear_error _frida_g_clear_error -#define g_clear_handle_id _frida_g_clear_handle_id -#define g_clear_list _frida_g_clear_list -#define g_clear_object _frida_g_clear_object -#define g_clear_pointer _frida_g_clear_pointer -#define g_clear_signal_handler _frida_g_clear_signal_handler -#define g_clear_slist _frida_g_clear_slist -#define g_close _frida_g_close -#define g_closure_add_finalize_notifier _frida_g_closure_add_finalize_notifier -#define g_closure_add_invalidate_notifier _frida_g_closure_add_invalidate_notifier -#define g_closure_add_marshal_guards _frida_g_closure_add_marshal_guards -#define g_closure_get_type _frida_g_closure_get_type -#define g_closure_invalidate _frida_g_closure_invalidate -#define g_closure_invoke _frida_g_closure_invoke -#define g_closure_new_object _frida_g_closure_new_object -#define g_closure_new_simple _frida_g_closure_new_simple -#define g_closure_ref _frida_g_closure_ref -#define g_closure_remove_finalize_notifier _frida_g_closure_remove_finalize_notifier -#define g_closure_remove_invalidate_notifier _frida_g_closure_remove_invalidate_notifier -#define g_closure_set_marshal _frida_g_closure_set_marshal -#define g_closure_set_meta_marshal _frida_g_closure_set_meta_marshal -#define g_closure_sink _frida_g_closure_sink -#define g_closure_unref _frida_g_closure_unref -#define g_completion_add_items _frida_g_completion_add_items -#define g_completion_clear_items _frida_g_completion_clear_items -#define g_completion_complete _frida_g_completion_complete -#define g_completion_complete_utf8 _frida_g_completion_complete_utf8 -#define g_completion_free _frida_g_completion_free -#define g_completion_new _frida_g_completion_new -#define g_completion_remove_items _frida_g_completion_remove_items -#define g_completion_set_compare _frida_g_completion_set_compare -#define g_compute_checksum_for_bytes _frida_g_compute_checksum_for_bytes -#define g_compute_checksum_for_data _frida_g_compute_checksum_for_data -#define g_compute_checksum_for_string _frida_g_compute_checksum_for_string -#define g_compute_hmac_for_bytes _frida_g_compute_hmac_for_bytes -#define g_compute_hmac_for_data _frida_g_compute_hmac_for_data -#define g_compute_hmac_for_string _frida_g_compute_hmac_for_string -#define g_cond_broadcast _frida_g_cond_broadcast -#define g_cond_clear _frida_g_cond_clear -#define g_cond_free _frida_g_cond_free -#define g_cond_init _frida_g_cond_init -#define g_cond_new _frida_g_cond_new -#define g_cond_signal _frida_g_cond_signal -#define g_cond_timed_wait _frida_g_cond_timed_wait -#define g_cond_wait _frida_g_cond_wait -#define g_cond_wait_until _frida_g_cond_wait_until -#define g_content_type_can_be_executable _frida_g_content_type_can_be_executable -#define g_content_type_equals _frida_g_content_type_equals -#define g_content_type_from_mime_type _frida_g_content_type_from_mime_type -#define g_content_type_get_description _frida_g_content_type_get_description -#define g_content_type_get_generic_icon_name _frida_g_content_type_get_generic_icon_name -#define g_content_type_get_icon _frida_g_content_type_get_icon -#define g_content_type_get_mime_dirs _frida_g_content_type_get_mime_dirs -#define g_content_type_get_mime_type _frida_g_content_type_get_mime_type -#define g_content_type_get_symbolic_icon _frida_g_content_type_get_symbolic_icon -#define g_content_type_guess _frida_g_content_type_guess -#define g_content_type_guess_for_tree _frida_g_content_type_guess_for_tree -#define g_content_type_is_a _frida_g_content_type_is_a -#define g_content_type_is_mime_type _frida_g_content_type_is_mime_type -#define g_content_type_is_unknown _frida_g_content_type_is_unknown -#define g_content_type_set_mime_dirs _frida_g_content_type_set_mime_dirs -#define g_content_types_get_registered _frida_g_content_types_get_registered -#define g_context_specific_group_emit _frida_g_context_specific_group_emit -#define g_context_specific_group_get _frida_g_context_specific_group_get -#define g_context_specific_group_remove _frida_g_context_specific_group_remove -#define g_convert _frida_g_convert -#define g_convert_error_quark _frida_g_convert_error_quark -#define g_convert_with_fallback _frida_g_convert_with_fallback -#define g_convert_with_iconv _frida_g_convert_with_iconv -#define g_converter_convert _frida_g_converter_convert -#define g_converter_flags_get_type _frida_g_converter_flags_get_type -#define g_converter_get_type _frida_g_converter_get_type -#define g_converter_input_stream_get_converter _frida_g_converter_input_stream_get_converter -#define g_converter_input_stream_get_type _frida_g_converter_input_stream_get_type -#define g_converter_input_stream_new _frida_g_converter_input_stream_new -#define g_converter_output_stream_get_converter _frida_g_converter_output_stream_get_converter -#define g_converter_output_stream_get_type _frida_g_converter_output_stream_get_type -#define g_converter_output_stream_new _frida_g_converter_output_stream_new -#define g_converter_reset _frida_g_converter_reset -#define g_converter_result_get_type _frida_g_converter_result_get_type -#define g_creat _frida_g_creat -#define g_credentials_get_native _frida_g_credentials_get_native -#define g_credentials_get_type _frida_g_credentials_get_type -#define g_credentials_get_unix_pid _frida_g_credentials_get_unix_pid -#define g_credentials_get_unix_user _frida_g_credentials_get_unix_user -#define g_credentials_is_same_user _frida_g_credentials_is_same_user -#define g_credentials_new _frida_g_credentials_new -#define g_credentials_set_native _frida_g_credentials_set_native -#define g_credentials_set_unix_user _frida_g_credentials_set_unix_user -#define g_credentials_to_string _frida_g_credentials_to_string -#define g_credentials_type_get_type _frida_g_credentials_type_get_type -#define g_data_input_stream_get_byte_order _frida_g_data_input_stream_get_byte_order -#define g_data_input_stream_get_newline_type _frida_g_data_input_stream_get_newline_type -#define g_data_input_stream_get_type _frida_g_data_input_stream_get_type -#define g_data_input_stream_new _frida_g_data_input_stream_new -#define g_data_input_stream_read_byte _frida_g_data_input_stream_read_byte -#define g_data_input_stream_read_int16 _frida_g_data_input_stream_read_int16 -#define g_data_input_stream_read_int32 _frida_g_data_input_stream_read_int32 -#define g_data_input_stream_read_int64 _frida_g_data_input_stream_read_int64 -#define g_data_input_stream_read_line _frida_g_data_input_stream_read_line -#define g_data_input_stream_read_line_async _frida_g_data_input_stream_read_line_async -#define g_data_input_stream_read_line_finish _frida_g_data_input_stream_read_line_finish -#define g_data_input_stream_read_line_finish_utf8 _frida_g_data_input_stream_read_line_finish_utf8 -#define g_data_input_stream_read_line_utf8 _frida_g_data_input_stream_read_line_utf8 -#define g_data_input_stream_read_uint16 _frida_g_data_input_stream_read_uint16 -#define g_data_input_stream_read_uint32 _frida_g_data_input_stream_read_uint32 -#define g_data_input_stream_read_uint64 _frida_g_data_input_stream_read_uint64 -#define g_data_input_stream_read_until _frida_g_data_input_stream_read_until -#define g_data_input_stream_read_until_async _frida_g_data_input_stream_read_until_async -#define g_data_input_stream_read_until_finish _frida_g_data_input_stream_read_until_finish -#define g_data_input_stream_read_upto _frida_g_data_input_stream_read_upto -#define g_data_input_stream_read_upto_async _frida_g_data_input_stream_read_upto_async -#define g_data_input_stream_read_upto_finish _frida_g_data_input_stream_read_upto_finish -#define g_data_input_stream_set_byte_order _frida_g_data_input_stream_set_byte_order -#define g_data_input_stream_set_newline_type _frida_g_data_input_stream_set_newline_type -#define g_data_output_stream_get_byte_order _frida_g_data_output_stream_get_byte_order -#define g_data_output_stream_get_type _frida_g_data_output_stream_get_type -#define g_data_output_stream_new _frida_g_data_output_stream_new -#define g_data_output_stream_put_byte _frida_g_data_output_stream_put_byte -#define g_data_output_stream_put_int16 _frida_g_data_output_stream_put_int16 -#define g_data_output_stream_put_int32 _frida_g_data_output_stream_put_int32 -#define g_data_output_stream_put_int64 _frida_g_data_output_stream_put_int64 -#define g_data_output_stream_put_string _frida_g_data_output_stream_put_string -#define g_data_output_stream_put_uint16 _frida_g_data_output_stream_put_uint16 -#define g_data_output_stream_put_uint32 _frida_g_data_output_stream_put_uint32 -#define g_data_output_stream_put_uint64 _frida_g_data_output_stream_put_uint64 -#define g_data_output_stream_set_byte_order _frida_g_data_output_stream_set_byte_order -#define g_data_stream_byte_order_get_type _frida_g_data_stream_byte_order_get_type -#define g_data_stream_newline_type_get_type _frida_g_data_stream_newline_type_get_type -#define g_datagram_based_condition_check _frida_g_datagram_based_condition_check -#define g_datagram_based_condition_wait _frida_g_datagram_based_condition_wait -#define g_datagram_based_create_source _frida_g_datagram_based_create_source -#define g_datagram_based_get_type _frida_g_datagram_based_get_type -#define g_datagram_based_receive_messages _frida_g_datagram_based_receive_messages -#define g_datagram_based_send_messages _frida_g_datagram_based_send_messages -#define g_datalist_clear _frida_g_datalist_clear -#define g_datalist_foreach _frida_g_datalist_foreach -#define g_datalist_get_data _frida_g_datalist_get_data -#define g_datalist_get_flags _frida_g_datalist_get_flags -#define g_datalist_id_dup_data _frida_g_datalist_id_dup_data -#define g_datalist_id_get_data _frida_g_datalist_id_get_data -#define g_datalist_id_remove_no_notify _frida_g_datalist_id_remove_no_notify -#define g_datalist_id_replace_data _frida_g_datalist_id_replace_data -#define g_datalist_id_set_data_full _frida_g_datalist_id_set_data_full -#define g_datalist_init _frida_g_datalist_init -#define g_datalist_set_flags _frida_g_datalist_set_flags -#define g_datalist_unset_flags _frida_g_datalist_unset_flags -#define g_dataset_destroy _frida_g_dataset_destroy -#define g_dataset_foreach _frida_g_dataset_foreach -#define g_dataset_id_get_data _frida_g_dataset_id_get_data -#define g_dataset_id_remove_no_notify _frida_g_dataset_id_remove_no_notify -#define g_dataset_id_set_data_full _frida_g_dataset_id_set_data_full -#define g_date_add_days _frida_g_date_add_days -#define g_date_add_months _frida_g_date_add_months -#define g_date_add_years _frida_g_date_add_years -#define g_date_clamp _frida_g_date_clamp -#define g_date_clear _frida_g_date_clear -#define g_date_compare _frida_g_date_compare -#define g_date_copy _frida_g_date_copy -#define g_date_days_between _frida_g_date_days_between -#define g_date_free _frida_g_date_free -#define g_date_get_day _frida_g_date_get_day -#define g_date_get_day_of_year _frida_g_date_get_day_of_year -#define g_date_get_days_in_month _frida_g_date_get_days_in_month -#define g_date_get_iso8601_week_of_year _frida_g_date_get_iso8601_week_of_year -#define g_date_get_julian _frida_g_date_get_julian -#define g_date_get_monday_week_of_year _frida_g_date_get_monday_week_of_year -#define g_date_get_monday_weeks_in_year _frida_g_date_get_monday_weeks_in_year -#define g_date_get_month _frida_g_date_get_month -#define g_date_get_sunday_week_of_year _frida_g_date_get_sunday_week_of_year -#define g_date_get_sunday_weeks_in_year _frida_g_date_get_sunday_weeks_in_year -#define g_date_get_type _frida_g_date_get_type -#define g_date_get_weekday _frida_g_date_get_weekday -#define g_date_get_year _frida_g_date_get_year -#define g_date_is_first_of_month _frida_g_date_is_first_of_month -#define g_date_is_last_of_month _frida_g_date_is_last_of_month -#define g_date_is_leap_year _frida_g_date_is_leap_year -#define g_date_new _frida_g_date_new -#define g_date_new_dmy _frida_g_date_new_dmy -#define g_date_new_julian _frida_g_date_new_julian -#define g_date_order _frida_g_date_order -#define g_date_set_day _frida_g_date_set_day -#define g_date_set_dmy _frida_g_date_set_dmy -#define g_date_set_julian _frida_g_date_set_julian -#define g_date_set_month _frida_g_date_set_month -#define g_date_set_parse _frida_g_date_set_parse -#define g_date_set_time _frida_g_date_set_time -#define g_date_set_time_t _frida_g_date_set_time_t -#define g_date_set_time_val _frida_g_date_set_time_val -#define g_date_set_year _frida_g_date_set_year -#define g_date_strftime _frida_g_date_strftime -#define g_date_subtract_days _frida_g_date_subtract_days -#define g_date_subtract_months _frida_g_date_subtract_months -#define g_date_subtract_years _frida_g_date_subtract_years -#define g_date_time_add _frida_g_date_time_add -#define g_date_time_add_days _frida_g_date_time_add_days -#define g_date_time_add_full _frida_g_date_time_add_full -#define g_date_time_add_hours _frida_g_date_time_add_hours -#define g_date_time_add_minutes _frida_g_date_time_add_minutes -#define g_date_time_add_months _frida_g_date_time_add_months -#define g_date_time_add_seconds _frida_g_date_time_add_seconds -#define g_date_time_add_weeks _frida_g_date_time_add_weeks -#define g_date_time_add_years _frida_g_date_time_add_years -#define g_date_time_compare _frida_g_date_time_compare -#define g_date_time_difference _frida_g_date_time_difference -#define g_date_time_equal _frida_g_date_time_equal -#define g_date_time_format _frida_g_date_time_format -#define g_date_time_format_iso8601 _frida_g_date_time_format_iso8601 -#define g_date_time_get_day_of_month _frida_g_date_time_get_day_of_month -#define g_date_time_get_day_of_week _frida_g_date_time_get_day_of_week -#define g_date_time_get_day_of_year _frida_g_date_time_get_day_of_year -#define g_date_time_get_hour _frida_g_date_time_get_hour -#define g_date_time_get_microsecond _frida_g_date_time_get_microsecond -#define g_date_time_get_minute _frida_g_date_time_get_minute -#define g_date_time_get_month _frida_g_date_time_get_month -#define g_date_time_get_second _frida_g_date_time_get_second -#define g_date_time_get_seconds _frida_g_date_time_get_seconds -#define g_date_time_get_timezone _frida_g_date_time_get_timezone -#define g_date_time_get_timezone_abbreviation _frida_g_date_time_get_timezone_abbreviation -#define g_date_time_get_type _frida_g_date_time_get_type -#define g_date_time_get_utc_offset _frida_g_date_time_get_utc_offset -#define g_date_time_get_week_numbering_year _frida_g_date_time_get_week_numbering_year -#define g_date_time_get_week_of_year _frida_g_date_time_get_week_of_year -#define g_date_time_get_year _frida_g_date_time_get_year -#define g_date_time_get_ymd _frida_g_date_time_get_ymd -#define g_date_time_hash _frida_g_date_time_hash -#define g_date_time_is_daylight_savings _frida_g_date_time_is_daylight_savings -#define g_date_time_new _frida_g_date_time_new -#define g_date_time_new_from_iso8601 _frida_g_date_time_new_from_iso8601 -#define g_date_time_new_from_timeval_local _frida_g_date_time_new_from_timeval_local -#define g_date_time_new_from_timeval_utc _frida_g_date_time_new_from_timeval_utc -#define g_date_time_new_from_unix_local _frida_g_date_time_new_from_unix_local -#define g_date_time_new_from_unix_utc _frida_g_date_time_new_from_unix_utc -#define g_date_time_new_local _frida_g_date_time_new_local -#define g_date_time_new_now _frida_g_date_time_new_now -#define g_date_time_new_now_local _frida_g_date_time_new_now_local -#define g_date_time_new_now_utc _frida_g_date_time_new_now_utc -#define g_date_time_new_utc _frida_g_date_time_new_utc -#define g_date_time_ref _frida_g_date_time_ref -#define g_date_time_to_local _frida_g_date_time_to_local -#define g_date_time_to_timeval _frida_g_date_time_to_timeval -#define g_date_time_to_timezone _frida_g_date_time_to_timezone -#define g_date_time_to_unix _frida_g_date_time_to_unix -#define g_date_time_to_utc _frida_g_date_time_to_utc -#define g_date_time_unref _frida_g_date_time_unref -#define g_date_to_struct_tm _frida_g_date_to_struct_tm -#define g_date_valid _frida_g_date_valid -#define g_date_valid_day _frida_g_date_valid_day -#define g_date_valid_dmy _frida_g_date_valid_dmy -#define g_date_valid_julian _frida_g_date_valid_julian -#define g_date_valid_month _frida_g_date_valid_month -#define g_date_valid_weekday _frida_g_date_valid_weekday -#define g_date_valid_year _frida_g_date_valid_year -#define g_dbus_action_group_get _frida_g_dbus_action_group_get -#define g_dbus_action_group_get_type _frida_g_dbus_action_group_get_type -#define g_dbus_action_group_sync _frida_g_dbus_action_group_sync -#define g_dbus_address_escape_value _frida_g_dbus_address_escape_value -#define g_dbus_address_get_for_bus_sync _frida_g_dbus_address_get_for_bus_sync -#define g_dbus_address_get_stream _frida_g_dbus_address_get_stream -#define g_dbus_address_get_stream_finish _frida_g_dbus_address_get_stream_finish -#define g_dbus_address_get_stream_sync _frida_g_dbus_address_get_stream_sync -#define g_dbus_annotation_info_get_type _frida_g_dbus_annotation_info_get_type -#define g_dbus_annotation_info_lookup _frida_g_dbus_annotation_info_lookup -#define g_dbus_annotation_info_ref _frida_g_dbus_annotation_info_ref -#define g_dbus_annotation_info_unref _frida_g_dbus_annotation_info_unref -#define g_dbus_arg_info_get_type _frida_g_dbus_arg_info_get_type -#define g_dbus_arg_info_ref _frida_g_dbus_arg_info_ref -#define g_dbus_arg_info_unref _frida_g_dbus_arg_info_unref -#define g_dbus_auth_observer_allow_mechanism _frida_g_dbus_auth_observer_allow_mechanism -#define g_dbus_auth_observer_authorize_authenticated_peer _frida_g_dbus_auth_observer_authorize_authenticated_peer -#define g_dbus_auth_observer_get_type _frida_g_dbus_auth_observer_get_type -#define g_dbus_auth_observer_new _frida_g_dbus_auth_observer_new -#define g_dbus_call_flags_get_type _frida_g_dbus_call_flags_get_type -#define g_dbus_capability_flags_get_type _frida_g_dbus_capability_flags_get_type -#define g_dbus_connection_add_filter _frida_g_dbus_connection_add_filter -#define g_dbus_connection_call _frida_g_dbus_connection_call -#define g_dbus_connection_call_finish _frida_g_dbus_connection_call_finish -#define g_dbus_connection_call_sync _frida_g_dbus_connection_call_sync -#define g_dbus_connection_call_with_unix_fd_list _frida_g_dbus_connection_call_with_unix_fd_list -#define g_dbus_connection_call_with_unix_fd_list_finish _frida_g_dbus_connection_call_with_unix_fd_list_finish -#define g_dbus_connection_call_with_unix_fd_list_sync _frida_g_dbus_connection_call_with_unix_fd_list_sync -#define g_dbus_connection_close _frida_g_dbus_connection_close -#define g_dbus_connection_close_finish _frida_g_dbus_connection_close_finish -#define g_dbus_connection_close_sync _frida_g_dbus_connection_close_sync -#define g_dbus_connection_emit_signal _frida_g_dbus_connection_emit_signal -#define g_dbus_connection_export_action_group _frida_g_dbus_connection_export_action_group -#define g_dbus_connection_export_menu_model _frida_g_dbus_connection_export_menu_model -#define g_dbus_connection_flags_get_type _frida_g_dbus_connection_flags_get_type -#define g_dbus_connection_flush _frida_g_dbus_connection_flush -#define g_dbus_connection_flush_finish _frida_g_dbus_connection_flush_finish -#define g_dbus_connection_flush_sync _frida_g_dbus_connection_flush_sync -#define g_dbus_connection_get_capabilities _frida_g_dbus_connection_get_capabilities -#define g_dbus_connection_get_exit_on_close _frida_g_dbus_connection_get_exit_on_close -#define g_dbus_connection_get_flags _frida_g_dbus_connection_get_flags -#define g_dbus_connection_get_guid _frida_g_dbus_connection_get_guid -#define g_dbus_connection_get_last_serial _frida_g_dbus_connection_get_last_serial -#define g_dbus_connection_get_peer_credentials _frida_g_dbus_connection_get_peer_credentials -#define g_dbus_connection_get_stream _frida_g_dbus_connection_get_stream -#define g_dbus_connection_get_type _frida_g_dbus_connection_get_type -#define g_dbus_connection_get_unique_name _frida_g_dbus_connection_get_unique_name -#define g_dbus_connection_is_closed _frida_g_dbus_connection_is_closed -#define g_dbus_connection_new _frida_g_dbus_connection_new -#define g_dbus_connection_new_finish _frida_g_dbus_connection_new_finish -#define g_dbus_connection_new_for_address _frida_g_dbus_connection_new_for_address -#define g_dbus_connection_new_for_address_finish _frida_g_dbus_connection_new_for_address_finish -#define g_dbus_connection_new_for_address_sync _frida_g_dbus_connection_new_for_address_sync -#define g_dbus_connection_new_sync _frida_g_dbus_connection_new_sync -#define g_dbus_connection_register_object _frida_g_dbus_connection_register_object -#define g_dbus_connection_register_object_with_closures _frida_g_dbus_connection_register_object_with_closures -#define g_dbus_connection_register_subtree _frida_g_dbus_connection_register_subtree -#define g_dbus_connection_remove_filter _frida_g_dbus_connection_remove_filter -#define g_dbus_connection_send_message _frida_g_dbus_connection_send_message -#define g_dbus_connection_send_message_with_reply _frida_g_dbus_connection_send_message_with_reply -#define g_dbus_connection_send_message_with_reply_finish _frida_g_dbus_connection_send_message_with_reply_finish -#define g_dbus_connection_send_message_with_reply_sync _frida_g_dbus_connection_send_message_with_reply_sync -#define g_dbus_connection_set_exit_on_close _frida_g_dbus_connection_set_exit_on_close -#define g_dbus_connection_signal_subscribe _frida_g_dbus_connection_signal_subscribe -#define g_dbus_connection_signal_unsubscribe _frida_g_dbus_connection_signal_unsubscribe -#define g_dbus_connection_start_message_processing _frida_g_dbus_connection_start_message_processing -#define g_dbus_connection_unexport_action_group _frida_g_dbus_connection_unexport_action_group -#define g_dbus_connection_unexport_menu_model _frida_g_dbus_connection_unexport_menu_model -#define g_dbus_connection_unregister_object _frida_g_dbus_connection_unregister_object -#define g_dbus_connection_unregister_subtree _frida_g_dbus_connection_unregister_subtree -#define g_dbus_error_encode_gerror _frida_g_dbus_error_encode_gerror -#define g_dbus_error_get_remote_error _frida_g_dbus_error_get_remote_error -#define g_dbus_error_get_type _frida_g_dbus_error_get_type -#define g_dbus_error_is_remote_error _frida_g_dbus_error_is_remote_error -#define g_dbus_error_new_for_dbus_error _frida_g_dbus_error_new_for_dbus_error -#define g_dbus_error_quark _frida_g_dbus_error_quark -#define g_dbus_error_register_error _frida_g_dbus_error_register_error -#define g_dbus_error_register_error_domain _frida_g_dbus_error_register_error_domain -#define g_dbus_error_set_dbus_error _frida_g_dbus_error_set_dbus_error -#define g_dbus_error_set_dbus_error_valist _frida_g_dbus_error_set_dbus_error_valist -#define g_dbus_error_strip_remote_error _frida_g_dbus_error_strip_remote_error -#define g_dbus_error_unregister_error _frida_g_dbus_error_unregister_error -#define g_dbus_generate_guid _frida_g_dbus_generate_guid -#define g_dbus_gvalue_to_gvariant _frida_g_dbus_gvalue_to_gvariant -#define g_dbus_gvariant_to_gvalue _frida_g_dbus_gvariant_to_gvalue -#define g_dbus_interface_dup_object _frida_g_dbus_interface_dup_object -#define g_dbus_interface_get_info _frida_g_dbus_interface_get_info -#define g_dbus_interface_get_object _frida_g_dbus_interface_get_object -#define g_dbus_interface_get_type _frida_g_dbus_interface_get_type -#define g_dbus_interface_info_cache_build _frida_g_dbus_interface_info_cache_build -#define g_dbus_interface_info_cache_release _frida_g_dbus_interface_info_cache_release -#define g_dbus_interface_info_generate_xml _frida_g_dbus_interface_info_generate_xml -#define g_dbus_interface_info_get_type _frida_g_dbus_interface_info_get_type -#define g_dbus_interface_info_lookup_method _frida_g_dbus_interface_info_lookup_method -#define g_dbus_interface_info_lookup_property _frida_g_dbus_interface_info_lookup_property -#define g_dbus_interface_info_lookup_signal _frida_g_dbus_interface_info_lookup_signal -#define g_dbus_interface_info_ref _frida_g_dbus_interface_info_ref -#define g_dbus_interface_info_unref _frida_g_dbus_interface_info_unref -#define g_dbus_interface_set_object _frida_g_dbus_interface_set_object -#define g_dbus_interface_skeleton_export _frida_g_dbus_interface_skeleton_export -#define g_dbus_interface_skeleton_flags_get_type _frida_g_dbus_interface_skeleton_flags_get_type -#define g_dbus_interface_skeleton_flush _frida_g_dbus_interface_skeleton_flush -#define g_dbus_interface_skeleton_get_connection _frida_g_dbus_interface_skeleton_get_connection -#define g_dbus_interface_skeleton_get_connections _frida_g_dbus_interface_skeleton_get_connections -#define g_dbus_interface_skeleton_get_flags _frida_g_dbus_interface_skeleton_get_flags -#define g_dbus_interface_skeleton_get_info _frida_g_dbus_interface_skeleton_get_info -#define g_dbus_interface_skeleton_get_object_path _frida_g_dbus_interface_skeleton_get_object_path -#define g_dbus_interface_skeleton_get_properties _frida_g_dbus_interface_skeleton_get_properties -#define g_dbus_interface_skeleton_get_type _frida_g_dbus_interface_skeleton_get_type -#define g_dbus_interface_skeleton_get_vtable _frida_g_dbus_interface_skeleton_get_vtable -#define g_dbus_interface_skeleton_has_connection _frida_g_dbus_interface_skeleton_has_connection -#define g_dbus_interface_skeleton_set_flags _frida_g_dbus_interface_skeleton_set_flags -#define g_dbus_interface_skeleton_unexport _frida_g_dbus_interface_skeleton_unexport -#define g_dbus_interface_skeleton_unexport_from_connection _frida_g_dbus_interface_skeleton_unexport_from_connection -#define g_dbus_is_address _frida_g_dbus_is_address -#define g_dbus_is_guid _frida_g_dbus_is_guid -#define g_dbus_is_interface_name _frida_g_dbus_is_interface_name -#define g_dbus_is_member_name _frida_g_dbus_is_member_name -#define g_dbus_is_name _frida_g_dbus_is_name -#define g_dbus_is_supported_address _frida_g_dbus_is_supported_address -#define g_dbus_is_unique_name _frida_g_dbus_is_unique_name -#define g_dbus_menu_model_get _frida_g_dbus_menu_model_get -#define g_dbus_menu_model_get_type _frida_g_dbus_menu_model_get_type -#define g_dbus_message_byte_order_get_type _frida_g_dbus_message_byte_order_get_type -#define g_dbus_message_bytes_needed _frida_g_dbus_message_bytes_needed -#define g_dbus_message_copy _frida_g_dbus_message_copy -#define g_dbus_message_flags_get_type _frida_g_dbus_message_flags_get_type -#define g_dbus_message_get_arg0 _frida_g_dbus_message_get_arg0 -#define g_dbus_message_get_body _frida_g_dbus_message_get_body -#define g_dbus_message_get_byte_order _frida_g_dbus_message_get_byte_order -#define g_dbus_message_get_destination _frida_g_dbus_message_get_destination -#define g_dbus_message_get_error_name _frida_g_dbus_message_get_error_name -#define g_dbus_message_get_flags _frida_g_dbus_message_get_flags -#define g_dbus_message_get_header _frida_g_dbus_message_get_header -#define g_dbus_message_get_header_fields _frida_g_dbus_message_get_header_fields -#define g_dbus_message_get_interface _frida_g_dbus_message_get_interface -#define g_dbus_message_get_locked _frida_g_dbus_message_get_locked -#define g_dbus_message_get_member _frida_g_dbus_message_get_member -#define g_dbus_message_get_message_type _frida_g_dbus_message_get_message_type -#define g_dbus_message_get_num_unix_fds _frida_g_dbus_message_get_num_unix_fds -#define g_dbus_message_get_path _frida_g_dbus_message_get_path -#define g_dbus_message_get_reply_serial _frida_g_dbus_message_get_reply_serial -#define g_dbus_message_get_sender _frida_g_dbus_message_get_sender -#define g_dbus_message_get_serial _frida_g_dbus_message_get_serial -#define g_dbus_message_get_signature _frida_g_dbus_message_get_signature -#define g_dbus_message_get_type _frida_g_dbus_message_get_type -#define g_dbus_message_get_unix_fd_list _frida_g_dbus_message_get_unix_fd_list -#define g_dbus_message_header_field_get_type _frida_g_dbus_message_header_field_get_type -#define g_dbus_message_lock _frida_g_dbus_message_lock -#define g_dbus_message_new _frida_g_dbus_message_new -#define g_dbus_message_new_from_blob _frida_g_dbus_message_new_from_blob -#define g_dbus_message_new_method_call _frida_g_dbus_message_new_method_call -#define g_dbus_message_new_method_error _frida_g_dbus_message_new_method_error -#define g_dbus_message_new_method_error_literal _frida_g_dbus_message_new_method_error_literal -#define g_dbus_message_new_method_error_valist _frida_g_dbus_message_new_method_error_valist -#define g_dbus_message_new_method_reply _frida_g_dbus_message_new_method_reply -#define g_dbus_message_new_signal _frida_g_dbus_message_new_signal -#define g_dbus_message_print _frida_g_dbus_message_print -#define g_dbus_message_set_body _frida_g_dbus_message_set_body -#define g_dbus_message_set_byte_order _frida_g_dbus_message_set_byte_order -#define g_dbus_message_set_destination _frida_g_dbus_message_set_destination -#define g_dbus_message_set_error_name _frida_g_dbus_message_set_error_name -#define g_dbus_message_set_flags _frida_g_dbus_message_set_flags -#define g_dbus_message_set_header _frida_g_dbus_message_set_header -#define g_dbus_message_set_interface _frida_g_dbus_message_set_interface -#define g_dbus_message_set_member _frida_g_dbus_message_set_member -#define g_dbus_message_set_message_type _frida_g_dbus_message_set_message_type -#define g_dbus_message_set_num_unix_fds _frida_g_dbus_message_set_num_unix_fds -#define g_dbus_message_set_path _frida_g_dbus_message_set_path -#define g_dbus_message_set_reply_serial _frida_g_dbus_message_set_reply_serial -#define g_dbus_message_set_sender _frida_g_dbus_message_set_sender -#define g_dbus_message_set_serial _frida_g_dbus_message_set_serial -#define g_dbus_message_set_signature _frida_g_dbus_message_set_signature -#define g_dbus_message_set_unix_fd_list _frida_g_dbus_message_set_unix_fd_list -#define g_dbus_message_to_blob _frida_g_dbus_message_to_blob -#define g_dbus_message_to_gerror _frida_g_dbus_message_to_gerror -#define g_dbus_message_type_get_type _frida_g_dbus_message_type_get_type -#define g_dbus_method_info_get_type _frida_g_dbus_method_info_get_type -#define g_dbus_method_info_ref _frida_g_dbus_method_info_ref -#define g_dbus_method_info_unref _frida_g_dbus_method_info_unref -#define g_dbus_method_invocation_get_connection _frida_g_dbus_method_invocation_get_connection -#define g_dbus_method_invocation_get_interface_name _frida_g_dbus_method_invocation_get_interface_name -#define g_dbus_method_invocation_get_message _frida_g_dbus_method_invocation_get_message -#define g_dbus_method_invocation_get_method_info _frida_g_dbus_method_invocation_get_method_info -#define g_dbus_method_invocation_get_method_name _frida_g_dbus_method_invocation_get_method_name -#define g_dbus_method_invocation_get_object_path _frida_g_dbus_method_invocation_get_object_path -#define g_dbus_method_invocation_get_parameters _frida_g_dbus_method_invocation_get_parameters -#define g_dbus_method_invocation_get_property_info _frida_g_dbus_method_invocation_get_property_info -#define g_dbus_method_invocation_get_sender _frida_g_dbus_method_invocation_get_sender -#define g_dbus_method_invocation_get_type _frida_g_dbus_method_invocation_get_type -#define g_dbus_method_invocation_get_user_data _frida_g_dbus_method_invocation_get_user_data -#define g_dbus_method_invocation_return_dbus_error _frida_g_dbus_method_invocation_return_dbus_error -#define g_dbus_method_invocation_return_error _frida_g_dbus_method_invocation_return_error -#define g_dbus_method_invocation_return_error_literal _frida_g_dbus_method_invocation_return_error_literal -#define g_dbus_method_invocation_return_error_valist _frida_g_dbus_method_invocation_return_error_valist -#define g_dbus_method_invocation_return_gerror _frida_g_dbus_method_invocation_return_gerror -#define g_dbus_method_invocation_return_value _frida_g_dbus_method_invocation_return_value -#define g_dbus_method_invocation_return_value_with_unix_fd_list _frida_g_dbus_method_invocation_return_value_with_unix_fd_list -#define g_dbus_method_invocation_take_error _frida_g_dbus_method_invocation_take_error -#define g_dbus_node_info_generate_xml _frida_g_dbus_node_info_generate_xml -#define g_dbus_node_info_get_type _frida_g_dbus_node_info_get_type -#define g_dbus_node_info_lookup_interface _frida_g_dbus_node_info_lookup_interface -#define g_dbus_node_info_new_for_xml _frida_g_dbus_node_info_new_for_xml -#define g_dbus_node_info_ref _frida_g_dbus_node_info_ref -#define g_dbus_node_info_unref _frida_g_dbus_node_info_unref -#define g_dbus_object_get_interface _frida_g_dbus_object_get_interface -#define g_dbus_object_get_interfaces _frida_g_dbus_object_get_interfaces -#define g_dbus_object_get_object_path _frida_g_dbus_object_get_object_path -#define g_dbus_object_get_type _frida_g_dbus_object_get_type -#define g_dbus_object_manager_client_flags_get_type _frida_g_dbus_object_manager_client_flags_get_type -#define g_dbus_object_manager_client_get_connection _frida_g_dbus_object_manager_client_get_connection -#define g_dbus_object_manager_client_get_flags _frida_g_dbus_object_manager_client_get_flags -#define g_dbus_object_manager_client_get_name _frida_g_dbus_object_manager_client_get_name -#define g_dbus_object_manager_client_get_name_owner _frida_g_dbus_object_manager_client_get_name_owner -#define g_dbus_object_manager_client_get_type _frida_g_dbus_object_manager_client_get_type -#define g_dbus_object_manager_client_new _frida_g_dbus_object_manager_client_new -#define g_dbus_object_manager_client_new_finish _frida_g_dbus_object_manager_client_new_finish -#define g_dbus_object_manager_client_new_for_bus _frida_g_dbus_object_manager_client_new_for_bus -#define g_dbus_object_manager_client_new_for_bus_finish _frida_g_dbus_object_manager_client_new_for_bus_finish -#define g_dbus_object_manager_client_new_for_bus_sync _frida_g_dbus_object_manager_client_new_for_bus_sync -#define g_dbus_object_manager_client_new_sync _frida_g_dbus_object_manager_client_new_sync -#define g_dbus_object_manager_get_interface _frida_g_dbus_object_manager_get_interface -#define g_dbus_object_manager_get_object _frida_g_dbus_object_manager_get_object -#define g_dbus_object_manager_get_object_path _frida_g_dbus_object_manager_get_object_path -#define g_dbus_object_manager_get_objects _frida_g_dbus_object_manager_get_objects -#define g_dbus_object_manager_get_type _frida_g_dbus_object_manager_get_type -#define g_dbus_object_manager_server_export _frida_g_dbus_object_manager_server_export -#define g_dbus_object_manager_server_export_uniquely _frida_g_dbus_object_manager_server_export_uniquely -#define g_dbus_object_manager_server_get_connection _frida_g_dbus_object_manager_server_get_connection -#define g_dbus_object_manager_server_get_type _frida_g_dbus_object_manager_server_get_type -#define g_dbus_object_manager_server_is_exported _frida_g_dbus_object_manager_server_is_exported -#define g_dbus_object_manager_server_new _frida_g_dbus_object_manager_server_new -#define g_dbus_object_manager_server_set_connection _frida_g_dbus_object_manager_server_set_connection -#define g_dbus_object_manager_server_unexport _frida_g_dbus_object_manager_server_unexport -#define g_dbus_object_proxy_get_connection _frida_g_dbus_object_proxy_get_connection -#define g_dbus_object_proxy_get_type _frida_g_dbus_object_proxy_get_type -#define g_dbus_object_proxy_new _frida_g_dbus_object_proxy_new -#define g_dbus_object_skeleton_add_interface _frida_g_dbus_object_skeleton_add_interface -#define g_dbus_object_skeleton_flush _frida_g_dbus_object_skeleton_flush -#define g_dbus_object_skeleton_get_type _frida_g_dbus_object_skeleton_get_type -#define g_dbus_object_skeleton_new _frida_g_dbus_object_skeleton_new -#define g_dbus_object_skeleton_remove_interface _frida_g_dbus_object_skeleton_remove_interface -#define g_dbus_object_skeleton_remove_interface_by_name _frida_g_dbus_object_skeleton_remove_interface_by_name -#define g_dbus_object_skeleton_set_object_path _frida_g_dbus_object_skeleton_set_object_path -#define g_dbus_property_info_flags_get_type _frida_g_dbus_property_info_flags_get_type -#define g_dbus_property_info_get_type _frida_g_dbus_property_info_get_type -#define g_dbus_property_info_ref _frida_g_dbus_property_info_ref -#define g_dbus_property_info_unref _frida_g_dbus_property_info_unref -#define g_dbus_proxy_call _frida_g_dbus_proxy_call -#define g_dbus_proxy_call_finish _frida_g_dbus_proxy_call_finish -#define g_dbus_proxy_call_sync _frida_g_dbus_proxy_call_sync -#define g_dbus_proxy_call_with_unix_fd_list _frida_g_dbus_proxy_call_with_unix_fd_list -#define g_dbus_proxy_call_with_unix_fd_list_finish _frida_g_dbus_proxy_call_with_unix_fd_list_finish -#define g_dbus_proxy_call_with_unix_fd_list_sync _frida_g_dbus_proxy_call_with_unix_fd_list_sync -#define g_dbus_proxy_flags_get_type _frida_g_dbus_proxy_flags_get_type -#define g_dbus_proxy_get_cached_property _frida_g_dbus_proxy_get_cached_property -#define g_dbus_proxy_get_cached_property_names _frida_g_dbus_proxy_get_cached_property_names -#define g_dbus_proxy_get_connection _frida_g_dbus_proxy_get_connection -#define g_dbus_proxy_get_default_timeout _frida_g_dbus_proxy_get_default_timeout -#define g_dbus_proxy_get_flags _frida_g_dbus_proxy_get_flags -#define g_dbus_proxy_get_interface_info _frida_g_dbus_proxy_get_interface_info -#define g_dbus_proxy_get_interface_name _frida_g_dbus_proxy_get_interface_name -#define g_dbus_proxy_get_name _frida_g_dbus_proxy_get_name -#define g_dbus_proxy_get_name_owner _frida_g_dbus_proxy_get_name_owner -#define g_dbus_proxy_get_object_path _frida_g_dbus_proxy_get_object_path -#define g_dbus_proxy_get_type _frida_g_dbus_proxy_get_type -#define g_dbus_proxy_new _frida_g_dbus_proxy_new -#define g_dbus_proxy_new_finish _frida_g_dbus_proxy_new_finish -#define g_dbus_proxy_new_for_bus _frida_g_dbus_proxy_new_for_bus -#define g_dbus_proxy_new_for_bus_finish _frida_g_dbus_proxy_new_for_bus_finish -#define g_dbus_proxy_new_for_bus_sync _frida_g_dbus_proxy_new_for_bus_sync -#define g_dbus_proxy_new_sync _frida_g_dbus_proxy_new_sync -#define g_dbus_proxy_set_cached_property _frida_g_dbus_proxy_set_cached_property -#define g_dbus_proxy_set_default_timeout _frida_g_dbus_proxy_set_default_timeout -#define g_dbus_proxy_set_interface_info _frida_g_dbus_proxy_set_interface_info -#define g_dbus_send_message_flags_get_type _frida_g_dbus_send_message_flags_get_type -#define g_dbus_server_flags_get_type _frida_g_dbus_server_flags_get_type -#define g_dbus_server_get_client_address _frida_g_dbus_server_get_client_address -#define g_dbus_server_get_flags _frida_g_dbus_server_get_flags -#define g_dbus_server_get_guid _frida_g_dbus_server_get_guid -#define g_dbus_server_get_type _frida_g_dbus_server_get_type -#define g_dbus_server_is_active _frida_g_dbus_server_is_active -#define g_dbus_server_new_sync _frida_g_dbus_server_new_sync -#define g_dbus_server_start _frida_g_dbus_server_start -#define g_dbus_server_stop _frida_g_dbus_server_stop -#define g_dbus_signal_flags_get_type _frida_g_dbus_signal_flags_get_type -#define g_dbus_signal_info_get_type _frida_g_dbus_signal_info_get_type -#define g_dbus_signal_info_ref _frida_g_dbus_signal_info_ref -#define g_dbus_signal_info_unref _frida_g_dbus_signal_info_unref -#define g_dbus_subtree_flags_get_type _frida_g_dbus_subtree_flags_get_type -#define g_dcgettext _frida_g_dcgettext -#define g_delayed_settings_backend_apply _frida_g_delayed_settings_backend_apply -#define g_delayed_settings_backend_get_has_unapplied _frida_g_delayed_settings_backend_get_has_unapplied -#define g_delayed_settings_backend_get_type _frida_g_delayed_settings_backend_get_type -#define g_delayed_settings_backend_new _frida_g_delayed_settings_backend_new -#define g_delayed_settings_backend_revert _frida_g_delayed_settings_backend_revert -#define g_desktop_app_info_get_action_name _frida_g_desktop_app_info_get_action_name -#define g_desktop_app_info_get_boolean _frida_g_desktop_app_info_get_boolean -#define g_desktop_app_info_get_categories _frida_g_desktop_app_info_get_categories -#define g_desktop_app_info_get_filename _frida_g_desktop_app_info_get_filename -#define g_desktop_app_info_get_generic_name _frida_g_desktop_app_info_get_generic_name -#define g_desktop_app_info_get_implementations _frida_g_desktop_app_info_get_implementations -#define g_desktop_app_info_get_is_hidden _frida_g_desktop_app_info_get_is_hidden -#define g_desktop_app_info_get_keywords _frida_g_desktop_app_info_get_keywords -#define g_desktop_app_info_get_locale_string _frida_g_desktop_app_info_get_locale_string -#define g_desktop_app_info_get_nodisplay _frida_g_desktop_app_info_get_nodisplay -#define g_desktop_app_info_get_show_in _frida_g_desktop_app_info_get_show_in -#define g_desktop_app_info_get_startup_wm_class _frida_g_desktop_app_info_get_startup_wm_class -#define g_desktop_app_info_get_string _frida_g_desktop_app_info_get_string -#define g_desktop_app_info_get_string_list _frida_g_desktop_app_info_get_string_list -#define g_desktop_app_info_get_type _frida_g_desktop_app_info_get_type -#define g_desktop_app_info_has_key _frida_g_desktop_app_info_has_key -#define g_desktop_app_info_launch_action _frida_g_desktop_app_info_launch_action -#define g_desktop_app_info_launch_uris_as_manager _frida_g_desktop_app_info_launch_uris_as_manager -#define g_desktop_app_info_launch_uris_as_manager_with_fds _frida_g_desktop_app_info_launch_uris_as_manager_with_fds -#define g_desktop_app_info_list_actions _frida_g_desktop_app_info_list_actions -#define g_desktop_app_info_lookup_get_default_for_uri_scheme _frida_g_desktop_app_info_lookup_get_default_for_uri_scheme -#define g_desktop_app_info_lookup_get_type _frida_g_desktop_app_info_lookup_get_type -#define g_desktop_app_info_new _frida_g_desktop_app_info_new -#define g_desktop_app_info_new_from_filename _frida_g_desktop_app_info_new_from_filename -#define g_desktop_app_info_new_from_keyfile _frida_g_desktop_app_info_new_from_keyfile -#define g_desktop_app_info_search _frida_g_desktop_app_info_search -#define g_desktop_app_info_set_desktop_env _frida_g_desktop_app_info_set_desktop_env -#define g_dgettext _frida_g_dgettext -#define g_dir_close _frida_g_dir_close -#define g_dir_make_tmp _frida_g_dir_make_tmp -#define g_dir_new_from_dirp _frida_g_dir_new_from_dirp -#define g_dir_open _frida_g_dir_open -#define g_dir_open_with_errno _frida_g_dir_open_with_errno -#define g_dir_read_name _frida_g_dir_read_name -#define g_dir_rewind _frida_g_dir_rewind -#define g_direct_equal _frida_g_direct_equal -#define g_direct_hash _frida_g_direct_hash -#define g_dngettext _frida_g_dngettext -#define g_document_portal_add_documents _frida_g_document_portal_add_documents -#define g_double_equal _frida_g_double_equal -#define g_double_hash _frida_g_double_hash -#define g_dpgettext _frida_g_dpgettext -#define g_dpgettext2 _frida_g_dpgettext2 -#define g_drive_can_eject _frida_g_drive_can_eject -#define g_drive_can_poll_for_media _frida_g_drive_can_poll_for_media -#define g_drive_can_start _frida_g_drive_can_start -#define g_drive_can_start_degraded _frida_g_drive_can_start_degraded -#define g_drive_can_stop _frida_g_drive_can_stop -#define g_drive_eject _frida_g_drive_eject -#define g_drive_eject_finish _frida_g_drive_eject_finish -#define g_drive_eject_with_operation _frida_g_drive_eject_with_operation -#define g_drive_eject_with_operation_finish _frida_g_drive_eject_with_operation_finish -#define g_drive_enumerate_identifiers _frida_g_drive_enumerate_identifiers -#define g_drive_get_icon _frida_g_drive_get_icon -#define g_drive_get_identifier _frida_g_drive_get_identifier -#define g_drive_get_name _frida_g_drive_get_name -#define g_drive_get_sort_key _frida_g_drive_get_sort_key -#define g_drive_get_start_stop_type _frida_g_drive_get_start_stop_type -#define g_drive_get_symbolic_icon _frida_g_drive_get_symbolic_icon -#define g_drive_get_type _frida_g_drive_get_type -#define g_drive_get_volumes _frida_g_drive_get_volumes -#define g_drive_has_media _frida_g_drive_has_media -#define g_drive_has_volumes _frida_g_drive_has_volumes -#define g_drive_is_media_check_automatic _frida_g_drive_is_media_check_automatic -#define g_drive_is_media_removable _frida_g_drive_is_media_removable -#define g_drive_is_removable _frida_g_drive_is_removable -#define g_drive_poll_for_media _frida_g_drive_poll_for_media -#define g_drive_poll_for_media_finish _frida_g_drive_poll_for_media_finish -#define g_drive_start _frida_g_drive_start -#define g_drive_start_finish _frida_g_drive_start_finish -#define g_drive_start_flags_get_type _frida_g_drive_start_flags_get_type -#define g_drive_start_stop_type_get_type _frida_g_drive_start_stop_type_get_type -#define g_drive_stop _frida_g_drive_stop -#define g_drive_stop_finish _frida_g_drive_stop_finish -#define g_dtls_client_connection_get_accepted_cas _frida_g_dtls_client_connection_get_accepted_cas -#define g_dtls_client_connection_get_server_identity _frida_g_dtls_client_connection_get_server_identity -#define g_dtls_client_connection_get_type _frida_g_dtls_client_connection_get_type -#define g_dtls_client_connection_get_validation_flags _frida_g_dtls_client_connection_get_validation_flags -#define g_dtls_client_connection_new _frida_g_dtls_client_connection_new -#define g_dtls_client_connection_set_server_identity _frida_g_dtls_client_connection_set_server_identity -#define g_dtls_client_connection_set_validation_flags _frida_g_dtls_client_connection_set_validation_flags -#define g_dtls_connection_close _frida_g_dtls_connection_close -#define g_dtls_connection_close_async _frida_g_dtls_connection_close_async -#define g_dtls_connection_close_finish _frida_g_dtls_connection_close_finish -#define g_dtls_connection_emit_accept_certificate _frida_g_dtls_connection_emit_accept_certificate -#define g_dtls_connection_get_certificate _frida_g_dtls_connection_get_certificate -#define g_dtls_connection_get_channel_binding_data _frida_g_dtls_connection_get_channel_binding_data -#define g_dtls_connection_get_database _frida_g_dtls_connection_get_database -#define g_dtls_connection_get_interaction _frida_g_dtls_connection_get_interaction -#define g_dtls_connection_get_negotiated_protocol _frida_g_dtls_connection_get_negotiated_protocol -#define g_dtls_connection_get_peer_certificate _frida_g_dtls_connection_get_peer_certificate -#define g_dtls_connection_get_peer_certificate_errors _frida_g_dtls_connection_get_peer_certificate_errors -#define g_dtls_connection_get_rehandshake_mode _frida_g_dtls_connection_get_rehandshake_mode -#define g_dtls_connection_get_require_close_notify _frida_g_dtls_connection_get_require_close_notify -#define g_dtls_connection_get_type _frida_g_dtls_connection_get_type -#define g_dtls_connection_handshake _frida_g_dtls_connection_handshake -#define g_dtls_connection_handshake_async _frida_g_dtls_connection_handshake_async -#define g_dtls_connection_handshake_finish _frida_g_dtls_connection_handshake_finish -#define g_dtls_connection_set_advertised_protocols _frida_g_dtls_connection_set_advertised_protocols -#define g_dtls_connection_set_certificate _frida_g_dtls_connection_set_certificate -#define g_dtls_connection_set_database _frida_g_dtls_connection_set_database -#define g_dtls_connection_set_interaction _frida_g_dtls_connection_set_interaction -#define g_dtls_connection_set_rehandshake_mode _frida_g_dtls_connection_set_rehandshake_mode -#define g_dtls_connection_set_require_close_notify _frida_g_dtls_connection_set_require_close_notify -#define g_dtls_connection_shutdown _frida_g_dtls_connection_shutdown -#define g_dtls_connection_shutdown_async _frida_g_dtls_connection_shutdown_async -#define g_dtls_connection_shutdown_finish _frida_g_dtls_connection_shutdown_finish -#define g_dtls_server_connection_get_type _frida_g_dtls_server_connection_get_type -#define g_dtls_server_connection_new _frida_g_dtls_server_connection_new -#define g_emblem_get_icon _frida_g_emblem_get_icon -#define g_emblem_get_origin _frida_g_emblem_get_origin -#define g_emblem_get_type _frida_g_emblem_get_type -#define g_emblem_new _frida_g_emblem_new -#define g_emblem_new_with_origin _frida_g_emblem_new_with_origin -#define g_emblem_origin_get_type _frida_g_emblem_origin_get_type -#define g_emblemed_icon_add_emblem _frida_g_emblemed_icon_add_emblem -#define g_emblemed_icon_clear_emblems _frida_g_emblemed_icon_clear_emblems -#define g_emblemed_icon_get_emblems _frida_g_emblemed_icon_get_emblems -#define g_emblemed_icon_get_icon _frida_g_emblemed_icon_get_icon -#define g_emblemed_icon_get_type _frida_g_emblemed_icon_get_type -#define g_emblemed_icon_new _frida_g_emblemed_icon_new -#define g_enum_complete_type_info _frida_g_enum_complete_type_info -#define g_enum_get_value _frida_g_enum_get_value -#define g_enum_get_value_by_name _frida_g_enum_get_value_by_name -#define g_enum_get_value_by_nick _frida_g_enum_get_value_by_nick -#define g_enum_register_static _frida_g_enum_register_static -#define g_enum_to_string _frida_g_enum_to_string -#define g_environ_getenv _frida_g_environ_getenv -#define g_environ_setenv _frida_g_environ_setenv -#define g_environ_unsetenv _frida_g_environ_unsetenv -#define g_error_copy _frida_g_error_copy -#define g_error_free _frida_g_error_free -#define g_error_get_type _frida_g_error_get_type -#define g_error_matches _frida_g_error_matches -#define g_error_new _frida_g_error_new -#define g_error_new_literal _frida_g_error_new_literal -#define g_error_new_valist _frida_g_error_new_valist -#define g_fdo_notification_backend_get_type _frida_g_fdo_notification_backend_get_type -#define g_file_append_to _frida_g_file_append_to -#define g_file_append_to_async _frida_g_file_append_to_async -#define g_file_append_to_finish _frida_g_file_append_to_finish -#define g_file_attribute_info_flags_get_type _frida_g_file_attribute_info_flags_get_type -#define g_file_attribute_info_list_add _frida_g_file_attribute_info_list_add -#define g_file_attribute_info_list_dup _frida_g_file_attribute_info_list_dup -#define g_file_attribute_info_list_get_type _frida_g_file_attribute_info_list_get_type -#define g_file_attribute_info_list_lookup _frida_g_file_attribute_info_list_lookup -#define g_file_attribute_info_list_new _frida_g_file_attribute_info_list_new -#define g_file_attribute_info_list_ref _frida_g_file_attribute_info_list_ref -#define g_file_attribute_info_list_unref _frida_g_file_attribute_info_list_unref -#define g_file_attribute_matcher_enumerate_namespace _frida_g_file_attribute_matcher_enumerate_namespace -#define g_file_attribute_matcher_enumerate_next _frida_g_file_attribute_matcher_enumerate_next -#define g_file_attribute_matcher_get_type _frida_g_file_attribute_matcher_get_type -#define g_file_attribute_matcher_matches _frida_g_file_attribute_matcher_matches -#define g_file_attribute_matcher_matches_only _frida_g_file_attribute_matcher_matches_only -#define g_file_attribute_matcher_new _frida_g_file_attribute_matcher_new -#define g_file_attribute_matcher_ref _frida_g_file_attribute_matcher_ref -#define g_file_attribute_matcher_subtract _frida_g_file_attribute_matcher_subtract -#define g_file_attribute_matcher_to_string _frida_g_file_attribute_matcher_to_string -#define g_file_attribute_matcher_unref _frida_g_file_attribute_matcher_unref -#define g_file_attribute_status_get_type _frida_g_file_attribute_status_get_type -#define g_file_attribute_type_get_type _frida_g_file_attribute_type_get_type -#define g_file_build_attribute_list_for_copy _frida_g_file_build_attribute_list_for_copy -#define g_file_copy _frida_g_file_copy -#define g_file_copy_async _frida_g_file_copy_async -#define g_file_copy_attributes _frida_g_file_copy_attributes -#define g_file_copy_finish _frida_g_file_copy_finish -#define g_file_copy_flags_get_type _frida_g_file_copy_flags_get_type -#define g_file_create _frida_g_file_create -#define g_file_create_async _frida_g_file_create_async -#define g_file_create_finish _frida_g_file_create_finish -#define g_file_create_flags_get_type _frida_g_file_create_flags_get_type -#define g_file_create_readwrite _frida_g_file_create_readwrite -#define g_file_create_readwrite_async _frida_g_file_create_readwrite_async -#define g_file_create_readwrite_finish _frida_g_file_create_readwrite_finish -#define g_file_delete _frida_g_file_delete -#define g_file_delete_async _frida_g_file_delete_async -#define g_file_delete_finish _frida_g_file_delete_finish -#define g_file_descriptor_based_get_fd _frida_g_file_descriptor_based_get_fd -#define g_file_descriptor_based_get_type _frida_g_file_descriptor_based_get_type -#define g_file_dup _frida_g_file_dup -#define g_file_eject_mountable _frida_g_file_eject_mountable -#define g_file_eject_mountable_finish _frida_g_file_eject_mountable_finish -#define g_file_eject_mountable_with_operation _frida_g_file_eject_mountable_with_operation -#define g_file_eject_mountable_with_operation_finish _frida_g_file_eject_mountable_with_operation_finish -#define g_file_enumerate_children _frida_g_file_enumerate_children -#define g_file_enumerate_children_async _frida_g_file_enumerate_children_async -#define g_file_enumerate_children_finish _frida_g_file_enumerate_children_finish -#define g_file_enumerator_close _frida_g_file_enumerator_close -#define g_file_enumerator_close_async _frida_g_file_enumerator_close_async -#define g_file_enumerator_close_finish _frida_g_file_enumerator_close_finish -#define g_file_enumerator_get_child _frida_g_file_enumerator_get_child -#define g_file_enumerator_get_container _frida_g_file_enumerator_get_container -#define g_file_enumerator_get_type _frida_g_file_enumerator_get_type -#define g_file_enumerator_has_pending _frida_g_file_enumerator_has_pending -#define g_file_enumerator_is_closed _frida_g_file_enumerator_is_closed -#define g_file_enumerator_iterate _frida_g_file_enumerator_iterate -#define g_file_enumerator_next_file _frida_g_file_enumerator_next_file -#define g_file_enumerator_next_files_async _frida_g_file_enumerator_next_files_async -#define g_file_enumerator_next_files_finish _frida_g_file_enumerator_next_files_finish -#define g_file_enumerator_set_pending _frida_g_file_enumerator_set_pending -#define g_file_equal _frida_g_file_equal -#define g_file_error_from_errno _frida_g_file_error_from_errno -#define g_file_error_quark _frida_g_file_error_quark -#define g_file_find_enclosing_mount _frida_g_file_find_enclosing_mount -#define g_file_find_enclosing_mount_async _frida_g_file_find_enclosing_mount_async -#define g_file_find_enclosing_mount_finish _frida_g_file_find_enclosing_mount_finish -#define g_file_get_basename _frida_g_file_get_basename -#define g_file_get_child _frida_g_file_get_child -#define g_file_get_child_for_display_name _frida_g_file_get_child_for_display_name -#define g_file_get_contents _frida_g_file_get_contents -#define g_file_get_parent _frida_g_file_get_parent -#define g_file_get_parse_name _frida_g_file_get_parse_name -#define g_file_get_path _frida_g_file_get_path -#define g_file_get_relative_path _frida_g_file_get_relative_path -#define g_file_get_type _frida_g_file_get_type -#define g_file_get_uri _frida_g_file_get_uri -#define g_file_get_uri_scheme _frida_g_file_get_uri_scheme -#define g_file_has_parent _frida_g_file_has_parent -#define g_file_has_prefix _frida_g_file_has_prefix -#define g_file_has_uri_scheme _frida_g_file_has_uri_scheme -#define g_file_hash _frida_g_file_hash -#define g_file_icon_get_file _frida_g_file_icon_get_file -#define g_file_icon_get_type _frida_g_file_icon_get_type -#define g_file_icon_new _frida_g_file_icon_new -#define g_file_info_clear_status _frida_g_file_info_clear_status -#define g_file_info_copy_into _frida_g_file_info_copy_into -#define g_file_info_dup _frida_g_file_info_dup -#define g_file_info_get_attribute_as_string _frida_g_file_info_get_attribute_as_string -#define g_file_info_get_attribute_boolean _frida_g_file_info_get_attribute_boolean -#define g_file_info_get_attribute_byte_string _frida_g_file_info_get_attribute_byte_string -#define g_file_info_get_attribute_data _frida_g_file_info_get_attribute_data -#define g_file_info_get_attribute_int32 _frida_g_file_info_get_attribute_int32 -#define g_file_info_get_attribute_int64 _frida_g_file_info_get_attribute_int64 -#define g_file_info_get_attribute_object _frida_g_file_info_get_attribute_object -#define g_file_info_get_attribute_status _frida_g_file_info_get_attribute_status -#define g_file_info_get_attribute_string _frida_g_file_info_get_attribute_string -#define g_file_info_get_attribute_stringv _frida_g_file_info_get_attribute_stringv -#define g_file_info_get_attribute_type _frida_g_file_info_get_attribute_type -#define g_file_info_get_attribute_uint32 _frida_g_file_info_get_attribute_uint32 -#define g_file_info_get_attribute_uint64 _frida_g_file_info_get_attribute_uint64 -#define g_file_info_get_content_type _frida_g_file_info_get_content_type -#define g_file_info_get_deletion_date _frida_g_file_info_get_deletion_date -#define g_file_info_get_display_name _frida_g_file_info_get_display_name -#define g_file_info_get_edit_name _frida_g_file_info_get_edit_name -#define g_file_info_get_etag _frida_g_file_info_get_etag -#define g_file_info_get_file_type _frida_g_file_info_get_file_type -#define g_file_info_get_icon _frida_g_file_info_get_icon -#define g_file_info_get_is_backup _frida_g_file_info_get_is_backup -#define g_file_info_get_is_hidden _frida_g_file_info_get_is_hidden -#define g_file_info_get_is_symlink _frida_g_file_info_get_is_symlink -#define g_file_info_get_modification_date_time _frida_g_file_info_get_modification_date_time -#define g_file_info_get_modification_time _frida_g_file_info_get_modification_time -#define g_file_info_get_name _frida_g_file_info_get_name -#define g_file_info_get_size _frida_g_file_info_get_size -#define g_file_info_get_sort_order _frida_g_file_info_get_sort_order -#define g_file_info_get_symbolic_icon _frida_g_file_info_get_symbolic_icon -#define g_file_info_get_symlink_target _frida_g_file_info_get_symlink_target -#define g_file_info_get_type _frida_g_file_info_get_type -#define g_file_info_has_attribute _frida_g_file_info_has_attribute -#define g_file_info_has_namespace _frida_g_file_info_has_namespace -#define g_file_info_list_attributes _frida_g_file_info_list_attributes -#define g_file_info_new _frida_g_file_info_new -#define g_file_info_remove_attribute _frida_g_file_info_remove_attribute -#define g_file_info_set_attribute _frida_g_file_info_set_attribute -#define g_file_info_set_attribute_boolean _frida_g_file_info_set_attribute_boolean -#define g_file_info_set_attribute_byte_string _frida_g_file_info_set_attribute_byte_string -#define g_file_info_set_attribute_int32 _frida_g_file_info_set_attribute_int32 -#define g_file_info_set_attribute_int64 _frida_g_file_info_set_attribute_int64 -#define g_file_info_set_attribute_mask _frida_g_file_info_set_attribute_mask -#define g_file_info_set_attribute_object _frida_g_file_info_set_attribute_object -#define g_file_info_set_attribute_status _frida_g_file_info_set_attribute_status -#define g_file_info_set_attribute_string _frida_g_file_info_set_attribute_string -#define g_file_info_set_attribute_stringv _frida_g_file_info_set_attribute_stringv -#define g_file_info_set_attribute_uint32 _frida_g_file_info_set_attribute_uint32 -#define g_file_info_set_attribute_uint64 _frida_g_file_info_set_attribute_uint64 -#define g_file_info_set_content_type _frida_g_file_info_set_content_type -#define g_file_info_set_display_name _frida_g_file_info_set_display_name -#define g_file_info_set_edit_name _frida_g_file_info_set_edit_name -#define g_file_info_set_file_type _frida_g_file_info_set_file_type -#define g_file_info_set_icon _frida_g_file_info_set_icon -#define g_file_info_set_is_hidden _frida_g_file_info_set_is_hidden -#define g_file_info_set_is_symlink _frida_g_file_info_set_is_symlink -#define g_file_info_set_modification_date_time _frida_g_file_info_set_modification_date_time -#define g_file_info_set_modification_time _frida_g_file_info_set_modification_time -#define g_file_info_set_name _frida_g_file_info_set_name -#define g_file_info_set_size _frida_g_file_info_set_size -#define g_file_info_set_sort_order _frida_g_file_info_set_sort_order -#define g_file_info_set_symbolic_icon _frida_g_file_info_set_symbolic_icon -#define g_file_info_set_symlink_target _frida_g_file_info_set_symlink_target -#define g_file_info_unset_attribute_mask _frida_g_file_info_unset_attribute_mask -#define g_file_input_stream_get_type _frida_g_file_input_stream_get_type -#define g_file_input_stream_query_info _frida_g_file_input_stream_query_info -#define g_file_input_stream_query_info_async _frida_g_file_input_stream_query_info_async -#define g_file_input_stream_query_info_finish _frida_g_file_input_stream_query_info_finish -#define g_file_io_stream_get_etag _frida_g_file_io_stream_get_etag -#define g_file_io_stream_get_type _frida_g_file_io_stream_get_type -#define g_file_io_stream_query_info _frida_g_file_io_stream_query_info -#define g_file_io_stream_query_info_async _frida_g_file_io_stream_query_info_async -#define g_file_io_stream_query_info_finish _frida_g_file_io_stream_query_info_finish -#define g_file_is_native _frida_g_file_is_native -#define g_file_load_bytes _frida_g_file_load_bytes -#define g_file_load_bytes_async _frida_g_file_load_bytes_async -#define g_file_load_bytes_finish _frida_g_file_load_bytes_finish -#define g_file_load_contents _frida_g_file_load_contents -#define g_file_load_contents_async _frida_g_file_load_contents_async -#define g_file_load_contents_finish _frida_g_file_load_contents_finish -#define g_file_load_partial_contents_async _frida_g_file_load_partial_contents_async -#define g_file_load_partial_contents_finish _frida_g_file_load_partial_contents_finish -#define g_file_make_directory _frida_g_file_make_directory -#define g_file_make_directory_async _frida_g_file_make_directory_async -#define g_file_make_directory_finish _frida_g_file_make_directory_finish -#define g_file_make_directory_with_parents _frida_g_file_make_directory_with_parents -#define g_file_make_symbolic_link _frida_g_file_make_symbolic_link -#define g_file_measure_disk_usage _frida_g_file_measure_disk_usage -#define g_file_measure_disk_usage_async _frida_g_file_measure_disk_usage_async -#define g_file_measure_disk_usage_finish _frida_g_file_measure_disk_usage_finish -#define g_file_measure_flags_get_type _frida_g_file_measure_flags_get_type -#define g_file_monitor _frida_g_file_monitor -#define g_file_monitor_cancel _frida_g_file_monitor_cancel -#define g_file_monitor_directory _frida_g_file_monitor_directory -#define g_file_monitor_emit_event _frida_g_file_monitor_emit_event -#define g_file_monitor_event_get_type _frida_g_file_monitor_event_get_type -#define g_file_monitor_file _frida_g_file_monitor_file -#define g_file_monitor_flags_get_type _frida_g_file_monitor_flags_get_type -#define g_file_monitor_get_type _frida_g_file_monitor_get_type -#define g_file_monitor_is_cancelled _frida_g_file_monitor_is_cancelled -#define g_file_monitor_set_rate_limit _frida_g_file_monitor_set_rate_limit -#define g_file_monitor_source_handle_event _frida_g_file_monitor_source_handle_event -#define g_file_mount_enclosing_volume _frida_g_file_mount_enclosing_volume -#define g_file_mount_enclosing_volume_finish _frida_g_file_mount_enclosing_volume_finish -#define g_file_mount_mountable _frida_g_file_mount_mountable -#define g_file_mount_mountable_finish _frida_g_file_mount_mountable_finish -#define g_file_move _frida_g_file_move -#define g_file_new_build_filename _frida_g_file_new_build_filename -#define g_file_new_for_commandline_arg _frida_g_file_new_for_commandline_arg -#define g_file_new_for_commandline_arg_and_cwd _frida_g_file_new_for_commandline_arg_and_cwd -#define g_file_new_for_path _frida_g_file_new_for_path -#define g_file_new_for_uri _frida_g_file_new_for_uri -#define g_file_new_tmp _frida_g_file_new_tmp -#define g_file_open_readwrite _frida_g_file_open_readwrite -#define g_file_open_readwrite_async _frida_g_file_open_readwrite_async -#define g_file_open_readwrite_finish _frida_g_file_open_readwrite_finish -#define g_file_open_tmp _frida_g_file_open_tmp -#define g_file_output_stream_get_etag _frida_g_file_output_stream_get_etag -#define g_file_output_stream_get_type _frida_g_file_output_stream_get_type -#define g_file_output_stream_query_info _frida_g_file_output_stream_query_info -#define g_file_output_stream_query_info_async _frida_g_file_output_stream_query_info_async -#define g_file_output_stream_query_info_finish _frida_g_file_output_stream_query_info_finish -#define g_file_parse_name _frida_g_file_parse_name -#define g_file_peek_path _frida_g_file_peek_path -#define g_file_poll_mountable _frida_g_file_poll_mountable -#define g_file_poll_mountable_finish _frida_g_file_poll_mountable_finish -#define g_file_query_default_handler _frida_g_file_query_default_handler -#define g_file_query_default_handler_async _frida_g_file_query_default_handler_async -#define g_file_query_default_handler_finish _frida_g_file_query_default_handler_finish -#define g_file_query_exists _frida_g_file_query_exists -#define g_file_query_file_type _frida_g_file_query_file_type -#define g_file_query_filesystem_info _frida_g_file_query_filesystem_info -#define g_file_query_filesystem_info_async _frida_g_file_query_filesystem_info_async -#define g_file_query_filesystem_info_finish _frida_g_file_query_filesystem_info_finish -#define g_file_query_info _frida_g_file_query_info -#define g_file_query_info_async _frida_g_file_query_info_async -#define g_file_query_info_finish _frida_g_file_query_info_finish -#define g_file_query_info_flags_get_type _frida_g_file_query_info_flags_get_type -#define g_file_query_settable_attributes _frida_g_file_query_settable_attributes -#define g_file_query_writable_namespaces _frida_g_file_query_writable_namespaces -#define g_file_read _frida_g_file_read -#define g_file_read_async _frida_g_file_read_async -#define g_file_read_finish _frida_g_file_read_finish -#define g_file_read_link _frida_g_file_read_link -#define g_file_replace _frida_g_file_replace -#define g_file_replace_async _frida_g_file_replace_async -#define g_file_replace_contents _frida_g_file_replace_contents -#define g_file_replace_contents_async _frida_g_file_replace_contents_async -#define g_file_replace_contents_bytes_async _frida_g_file_replace_contents_bytes_async -#define g_file_replace_contents_finish _frida_g_file_replace_contents_finish -#define g_file_replace_finish _frida_g_file_replace_finish -#define g_file_replace_readwrite _frida_g_file_replace_readwrite -#define g_file_replace_readwrite_async _frida_g_file_replace_readwrite_async -#define g_file_replace_readwrite_finish _frida_g_file_replace_readwrite_finish -#define g_file_resolve_relative_path _frida_g_file_resolve_relative_path -#define g_file_set_attribute _frida_g_file_set_attribute -#define g_file_set_attribute_byte_string _frida_g_file_set_attribute_byte_string -#define g_file_set_attribute_int32 _frida_g_file_set_attribute_int32 -#define g_file_set_attribute_int64 _frida_g_file_set_attribute_int64 -#define g_file_set_attribute_string _frida_g_file_set_attribute_string -#define g_file_set_attribute_uint32 _frida_g_file_set_attribute_uint32 -#define g_file_set_attribute_uint64 _frida_g_file_set_attribute_uint64 -#define g_file_set_attributes_async _frida_g_file_set_attributes_async -#define g_file_set_attributes_finish _frida_g_file_set_attributes_finish -#define g_file_set_attributes_from_info _frida_g_file_set_attributes_from_info -#define g_file_set_contents _frida_g_file_set_contents -#define g_file_set_contents_full _frida_g_file_set_contents_full -#define g_file_set_display_name _frida_g_file_set_display_name -#define g_file_set_display_name_async _frida_g_file_set_display_name_async -#define g_file_set_display_name_finish _frida_g_file_set_display_name_finish -#define g_file_start_mountable _frida_g_file_start_mountable -#define g_file_start_mountable_finish _frida_g_file_start_mountable_finish -#define g_file_stop_mountable _frida_g_file_stop_mountable -#define g_file_stop_mountable_finish _frida_g_file_stop_mountable_finish -#define g_file_supports_thread_contexts _frida_g_file_supports_thread_contexts -#define g_file_test _frida_g_file_test -#define g_file_trash _frida_g_file_trash -#define g_file_trash_async _frida_g_file_trash_async -#define g_file_trash_finish _frida_g_file_trash_finish -#define g_file_type_get_type _frida_g_file_type_get_type -#define g_file_unmount_mountable _frida_g_file_unmount_mountable -#define g_file_unmount_mountable_finish _frida_g_file_unmount_mountable_finish -#define g_file_unmount_mountable_with_operation _frida_g_file_unmount_mountable_with_operation -#define g_file_unmount_mountable_with_operation_finish _frida_g_file_unmount_mountable_with_operation_finish -#define g_filename_completer_get_completion_suffix _frida_g_filename_completer_get_completion_suffix -#define g_filename_completer_get_completions _frida_g_filename_completer_get_completions -#define g_filename_completer_get_type _frida_g_filename_completer_get_type -#define g_filename_completer_new _frida_g_filename_completer_new -#define g_filename_completer_set_dirs_only _frida_g_filename_completer_set_dirs_only -#define g_filename_display_basename _frida_g_filename_display_basename -#define g_filename_display_name _frida_g_filename_display_name -#define g_filename_from_uri _frida_g_filename_from_uri -#define g_filename_from_utf8 _frida_g_filename_from_utf8 -#define g_filename_to_uri _frida_g_filename_to_uri -#define g_filename_to_utf8 _frida_g_filename_to_utf8 -#define g_filesystem_preview_type_get_type _frida_g_filesystem_preview_type_get_type -#define g_filter_input_stream_get_base_stream _frida_g_filter_input_stream_get_base_stream -#define g_filter_input_stream_get_close_base_stream _frida_g_filter_input_stream_get_close_base_stream -#define g_filter_input_stream_get_type _frida_g_filter_input_stream_get_type -#define g_filter_input_stream_set_close_base_stream _frida_g_filter_input_stream_set_close_base_stream -#define g_filter_output_stream_get_base_stream _frida_g_filter_output_stream_get_base_stream -#define g_filter_output_stream_get_close_base_stream _frida_g_filter_output_stream_get_close_base_stream -#define g_filter_output_stream_get_type _frida_g_filter_output_stream_get_type -#define g_filter_output_stream_set_close_base_stream _frida_g_filter_output_stream_set_close_base_stream -#define g_find_program_in_path _frida_g_find_program_in_path -#define g_flags_complete_type_info _frida_g_flags_complete_type_info -#define g_flags_get_first_value _frida_g_flags_get_first_value -#define g_flags_get_value_by_name _frida_g_flags_get_value_by_name -#define g_flags_get_value_by_nick _frida_g_flags_get_value_by_nick -#define g_flags_register_static _frida_g_flags_register_static -#define g_flags_to_string _frida_g_flags_to_string -#define g_fopen _frida_g_fopen -#define g_format_size _frida_g_format_size -#define g_format_size_for_display _frida_g_format_size_for_display -#define g_format_size_full _frida_g_format_size_full -#define g_fprintf _frida_g_fprintf -#define g_free _frida_g_free -#define g_freopen _frida_g_freopen -#define g_fsync _frida_g_fsync -#define g_get_application_name _frida_g_get_application_name -#define g_get_charset _frida_g_get_charset -#define g_get_codeset _frida_g_get_codeset -#define g_get_console_charset _frida_g_get_console_charset -#define g_get_current_dir _frida_g_get_current_dir -#define g_get_current_time _frida_g_get_current_time -#define g_get_environ _frida_g_get_environ -#define g_get_filename_charsets _frida_g_get_filename_charsets -#define g_get_home_dir _frida_g_get_home_dir -#define g_get_host_name _frida_g_get_host_name -#define g_get_language_names _frida_g_get_language_names -#define g_get_language_names_with_category _frida_g_get_language_names_with_category -#define g_get_locale_variants _frida_g_get_locale_variants -#define g_get_monotonic_time _frida_g_get_monotonic_time -#define g_get_num_processors _frida_g_get_num_processors -#define g_get_os_info _frida_g_get_os_info -#define g_get_prgname _frida_g_get_prgname -#define g_get_real_name _frida_g_get_real_name -#define g_get_real_time _frida_g_get_real_time -#define g_get_system_config_dirs _frida_g_get_system_config_dirs -#define g_get_system_data_dirs _frida_g_get_system_data_dirs -#define g_get_tmp_dir _frida_g_get_tmp_dir -#define g_get_user_cache_dir _frida_g_get_user_cache_dir -#define g_get_user_config_dir _frida_g_get_user_config_dir -#define g_get_user_data_dir _frida_g_get_user_data_dir -#define g_get_user_name _frida_g_get_user_name -#define g_get_user_runtime_dir _frida_g_get_user_runtime_dir -#define g_get_user_special_dir _frida_g_get_user_special_dir -#define g_get_worker_context _frida_g_get_worker_context -#define g_getenv _frida_g_getenv -#define g_gstring_get_type _frida_g_gstring_get_type -#define g_gtk_notification_backend_get_type _frida_g_gtk_notification_backend_get_type -#define g_gtype_get_type _frida_g_gtype_get_type -#define g_hash_table_add _frida_g_hash_table_add -#define g_hash_table_contains _frida_g_hash_table_contains -#define g_hash_table_destroy _frida_g_hash_table_destroy -#define g_hash_table_find _frida_g_hash_table_find -#define g_hash_table_foreach _frida_g_hash_table_foreach -#define g_hash_table_foreach_remove _frida_g_hash_table_foreach_remove -#define g_hash_table_foreach_steal _frida_g_hash_table_foreach_steal -#define g_hash_table_get_keys _frida_g_hash_table_get_keys -#define g_hash_table_get_keys_as_array _frida_g_hash_table_get_keys_as_array -#define g_hash_table_get_type _frida_g_hash_table_get_type -#define g_hash_table_get_values _frida_g_hash_table_get_values -#define g_hash_table_insert _frida_g_hash_table_insert -#define g_hash_table_iter_get_hash_table _frida_g_hash_table_iter_get_hash_table -#define g_hash_table_iter_init _frida_g_hash_table_iter_init -#define g_hash_table_iter_next _frida_g_hash_table_iter_next -#define g_hash_table_iter_remove _frida_g_hash_table_iter_remove -#define g_hash_table_iter_replace _frida_g_hash_table_iter_replace -#define g_hash_table_iter_steal _frida_g_hash_table_iter_steal -#define g_hash_table_lookup _frida_g_hash_table_lookup -#define g_hash_table_lookup_extended _frida_g_hash_table_lookup_extended -#define g_hash_table_new _frida_g_hash_table_new -#define g_hash_table_new_full _frida_g_hash_table_new_full -#define g_hash_table_ref _frida_g_hash_table_ref -#define g_hash_table_remove _frida_g_hash_table_remove -#define g_hash_table_remove_all _frida_g_hash_table_remove_all -#define g_hash_table_replace _frida_g_hash_table_replace -#define g_hash_table_size _frida_g_hash_table_size -#define g_hash_table_steal _frida_g_hash_table_steal -#define g_hash_table_steal_all _frida_g_hash_table_steal_all -#define g_hash_table_steal_extended _frida_g_hash_table_steal_extended -#define g_hash_table_unref _frida_g_hash_table_unref -#define g_hmac_copy _frida_g_hmac_copy -#define g_hmac_get_digest _frida_g_hmac_get_digest -#define g_hmac_get_string _frida_g_hmac_get_string -#define g_hmac_new _frida_g_hmac_new -#define g_hmac_ref _frida_g_hmac_ref -#define g_hmac_unref _frida_g_hmac_unref -#define g_hmac_update _frida_g_hmac_update -#define g_hook_alloc _frida_g_hook_alloc -#define g_hook_compare_ids _frida_g_hook_compare_ids -#define g_hook_destroy _frida_g_hook_destroy -#define g_hook_destroy_link _frida_g_hook_destroy_link -#define g_hook_find _frida_g_hook_find -#define g_hook_find_data _frida_g_hook_find_data -#define g_hook_find_func _frida_g_hook_find_func -#define g_hook_find_func_data _frida_g_hook_find_func_data -#define g_hook_first_valid _frida_g_hook_first_valid -#define g_hook_free _frida_g_hook_free -#define g_hook_get _frida_g_hook_get -#define g_hook_insert_before _frida_g_hook_insert_before -#define g_hook_insert_sorted _frida_g_hook_insert_sorted -#define g_hook_list_clear _frida_g_hook_list_clear -#define g_hook_list_init _frida_g_hook_list_init -#define g_hook_list_invoke _frida_g_hook_list_invoke -#define g_hook_list_invoke_check _frida_g_hook_list_invoke_check -#define g_hook_list_marshal _frida_g_hook_list_marshal -#define g_hook_list_marshal_check _frida_g_hook_list_marshal_check -#define g_hook_next_valid _frida_g_hook_next_valid -#define g_hook_prepend _frida_g_hook_prepend -#define g_hook_ref _frida_g_hook_ref -#define g_hook_unref _frida_g_hook_unref -#define g_hostname_is_ascii_encoded _frida_g_hostname_is_ascii_encoded -#define g_hostname_is_ip_address _frida_g_hostname_is_ip_address -#define g_hostname_is_non_ascii _frida_g_hostname_is_non_ascii -#define g_hostname_to_ascii _frida_g_hostname_to_ascii -#define g_hostname_to_unicode _frida_g_hostname_to_unicode -#define g_icon_deserialize _frida_g_icon_deserialize -#define g_icon_equal _frida_g_icon_equal -#define g_icon_get_type _frida_g_icon_get_type -#define g_icon_hash _frida_g_icon_hash -#define g_icon_new_for_string _frida_g_icon_new_for_string -#define g_icon_serialize _frida_g_icon_serialize -#define g_icon_to_string _frida_g_icon_to_string -#define g_iconv _frida_g_iconv -#define g_iconv_close _frida_g_iconv_close -#define g_iconv_open _frida_g_iconv_open -#define g_idle_add _frida_g_idle_add -#define g_idle_add_full _frida_g_idle_add_full -#define g_idle_funcs _frida_g_idle_funcs -#define g_idle_remove_by_data _frida_g_idle_remove_by_data -#define g_idle_source_new _frida_g_idle_source_new -#define g_inet_address_equal _frida_g_inet_address_equal -#define g_inet_address_get_family _frida_g_inet_address_get_family -#define g_inet_address_get_is_any _frida_g_inet_address_get_is_any -#define g_inet_address_get_is_link_local _frida_g_inet_address_get_is_link_local -#define g_inet_address_get_is_loopback _frida_g_inet_address_get_is_loopback -#define g_inet_address_get_is_mc_global _frida_g_inet_address_get_is_mc_global -#define g_inet_address_get_is_mc_link_local _frida_g_inet_address_get_is_mc_link_local -#define g_inet_address_get_is_mc_node_local _frida_g_inet_address_get_is_mc_node_local -#define g_inet_address_get_is_mc_org_local _frida_g_inet_address_get_is_mc_org_local -#define g_inet_address_get_is_mc_site_local _frida_g_inet_address_get_is_mc_site_local -#define g_inet_address_get_is_multicast _frida_g_inet_address_get_is_multicast -#define g_inet_address_get_is_site_local _frida_g_inet_address_get_is_site_local -#define g_inet_address_get_native_size _frida_g_inet_address_get_native_size -#define g_inet_address_get_type _frida_g_inet_address_get_type -#define g_inet_address_mask_equal _frida_g_inet_address_mask_equal -#define g_inet_address_mask_get_address _frida_g_inet_address_mask_get_address -#define g_inet_address_mask_get_family _frida_g_inet_address_mask_get_family -#define g_inet_address_mask_get_length _frida_g_inet_address_mask_get_length -#define g_inet_address_mask_get_type _frida_g_inet_address_mask_get_type -#define g_inet_address_mask_matches _frida_g_inet_address_mask_matches -#define g_inet_address_mask_new _frida_g_inet_address_mask_new -#define g_inet_address_mask_new_from_string _frida_g_inet_address_mask_new_from_string -#define g_inet_address_mask_to_string _frida_g_inet_address_mask_to_string -#define g_inet_address_new_any _frida_g_inet_address_new_any -#define g_inet_address_new_from_bytes _frida_g_inet_address_new_from_bytes -#define g_inet_address_new_from_string _frida_g_inet_address_new_from_string -#define g_inet_address_new_loopback _frida_g_inet_address_new_loopback -#define g_inet_address_to_bytes _frida_g_inet_address_to_bytes -#define g_inet_address_to_string _frida_g_inet_address_to_string -#define g_inet_socket_address_get_address _frida_g_inet_socket_address_get_address -#define g_inet_socket_address_get_flowinfo _frida_g_inet_socket_address_get_flowinfo -#define g_inet_socket_address_get_port _frida_g_inet_socket_address_get_port -#define g_inet_socket_address_get_scope_id _frida_g_inet_socket_address_get_scope_id -#define g_inet_socket_address_get_type _frida_g_inet_socket_address_get_type -#define g_inet_socket_address_new _frida_g_inet_socket_address_new -#define g_inet_socket_address_new_from_string _frida_g_inet_socket_address_new_from_string -#define g_initable_get_type _frida_g_initable_get_type -#define g_initable_init _frida_g_initable_init -#define g_initable_new _frida_g_initable_new -#define g_initable_new_valist _frida_g_initable_new_valist -#define g_initable_newv _frida_g_initable_newv -#define g_initially_unowned_get_type _frida_g_initially_unowned_get_type -#define g_inotify_file_monitor_get_type _frida_g_inotify_file_monitor_get_type -#define g_input_stream_async_close_is_via_threads _frida_g_input_stream_async_close_is_via_threads -#define g_input_stream_async_read_is_via_threads _frida_g_input_stream_async_read_is_via_threads -#define g_input_stream_clear_pending _frida_g_input_stream_clear_pending -#define g_input_stream_close _frida_g_input_stream_close -#define g_input_stream_close_async _frida_g_input_stream_close_async -#define g_input_stream_close_finish _frida_g_input_stream_close_finish -#define g_input_stream_get_type _frida_g_input_stream_get_type -#define g_input_stream_has_pending _frida_g_input_stream_has_pending -#define g_input_stream_is_closed _frida_g_input_stream_is_closed -#define g_input_stream_read _frida_g_input_stream_read -#define g_input_stream_read_all _frida_g_input_stream_read_all -#define g_input_stream_read_all_async _frida_g_input_stream_read_all_async -#define g_input_stream_read_all_finish _frida_g_input_stream_read_all_finish -#define g_input_stream_read_async _frida_g_input_stream_read_async -#define g_input_stream_read_bytes _frida_g_input_stream_read_bytes -#define g_input_stream_read_bytes_async _frida_g_input_stream_read_bytes_async -#define g_input_stream_read_bytes_finish _frida_g_input_stream_read_bytes_finish -#define g_input_stream_read_finish _frida_g_input_stream_read_finish -#define g_input_stream_set_pending _frida_g_input_stream_set_pending -#define g_input_stream_skip _frida_g_input_stream_skip -#define g_input_stream_skip_async _frida_g_input_stream_skip_async -#define g_input_stream_skip_finish _frida_g_input_stream_skip_finish -#define g_int64_equal _frida_g_int64_equal -#define g_int64_hash _frida_g_int64_hash -#define g_int_equal _frida_g_int_equal -#define g_int_hash _frida_g_int_hash -#define g_intern_static_string _frida_g_intern_static_string -#define g_intern_string _frida_g_intern_string -#define g_io_add_watch _frida_g_io_add_watch -#define g_io_add_watch_full _frida_g_io_add_watch_full -#define g_io_channel_close _frida_g_io_channel_close -#define g_io_channel_error_from_errno _frida_g_io_channel_error_from_errno -#define g_io_channel_error_quark _frida_g_io_channel_error_quark -#define g_io_channel_flush _frida_g_io_channel_flush -#define g_io_channel_get_buffer_condition _frida_g_io_channel_get_buffer_condition -#define g_io_channel_get_buffer_size _frida_g_io_channel_get_buffer_size -#define g_io_channel_get_buffered _frida_g_io_channel_get_buffered -#define g_io_channel_get_close_on_unref _frida_g_io_channel_get_close_on_unref -#define g_io_channel_get_encoding _frida_g_io_channel_get_encoding -#define g_io_channel_get_flags _frida_g_io_channel_get_flags -#define g_io_channel_get_line_term _frida_g_io_channel_get_line_term -#define g_io_channel_get_type _frida_g_io_channel_get_type -#define g_io_channel_init _frida_g_io_channel_init -#define g_io_channel_new_file _frida_g_io_channel_new_file -#define g_io_channel_read _frida_g_io_channel_read -#define g_io_channel_read_chars _frida_g_io_channel_read_chars -#define g_io_channel_read_line _frida_g_io_channel_read_line -#define g_io_channel_read_line_string _frida_g_io_channel_read_line_string -#define g_io_channel_read_to_end _frida_g_io_channel_read_to_end -#define g_io_channel_read_unichar _frida_g_io_channel_read_unichar -#define g_io_channel_ref _frida_g_io_channel_ref -#define g_io_channel_seek _frida_g_io_channel_seek -#define g_io_channel_seek_position _frida_g_io_channel_seek_position -#define g_io_channel_set_buffer_size _frida_g_io_channel_set_buffer_size -#define g_io_channel_set_buffered _frida_g_io_channel_set_buffered -#define g_io_channel_set_close_on_unref _frida_g_io_channel_set_close_on_unref -#define g_io_channel_set_encoding _frida_g_io_channel_set_encoding -#define g_io_channel_set_flags _frida_g_io_channel_set_flags -#define g_io_channel_set_line_term _frida_g_io_channel_set_line_term -#define g_io_channel_shutdown _frida_g_io_channel_shutdown -#define g_io_channel_unix_get_fd _frida_g_io_channel_unix_get_fd -#define g_io_channel_unix_new _frida_g_io_channel_unix_new -#define g_io_channel_unref _frida_g_io_channel_unref -#define g_io_channel_write _frida_g_io_channel_write -#define g_io_channel_write_chars _frida_g_io_channel_write_chars -#define g_io_channel_write_unichar _frida_g_io_channel_write_unichar -#define g_io_condition_get_type _frida_g_io_condition_get_type -#define g_io_create_watch _frida_g_io_create_watch -#define g_io_error_enum_get_type _frida_g_io_error_enum_get_type -#define g_io_error_from_errno _frida_g_io_error_from_errno -#define g_io_error_quark _frida_g_io_error_quark -#define g_io_extension_get_name _frida_g_io_extension_get_name -#define g_io_extension_get_priority _frida_g_io_extension_get_priority -#define g_io_extension_get_type _frida_g_io_extension_get_type -#define g_io_extension_point_get_extension_by_name _frida_g_io_extension_point_get_extension_by_name -#define g_io_extension_point_get_extensions _frida_g_io_extension_point_get_extensions -#define g_io_extension_point_get_required_type _frida_g_io_extension_point_get_required_type -#define g_io_extension_point_implement _frida_g_io_extension_point_implement -#define g_io_extension_point_lookup _frida_g_io_extension_point_lookup -#define g_io_extension_point_register _frida_g_io_extension_point_register -#define g_io_extension_point_set_required_type _frida_g_io_extension_point_set_required_type -#define g_io_extension_ref_class _frida_g_io_extension_ref_class -#define g_io_module_get_type _frida_g_io_module_get_type -#define g_io_module_new _frida_g_io_module_new -#define g_io_module_scope_block _frida_g_io_module_scope_block -#define g_io_module_scope_flags_get_type _frida_g_io_module_scope_flags_get_type -#define g_io_module_scope_free _frida_g_io_module_scope_free -#define g_io_module_scope_new _frida_g_io_module_scope_new -#define g_io_modules_load_all_in_directory _frida_g_io_modules_load_all_in_directory -#define g_io_modules_load_all_in_directory_with_scope _frida_g_io_modules_load_all_in_directory_with_scope -#define g_io_modules_scan_all_in_directory _frida_g_io_modules_scan_all_in_directory -#define g_io_modules_scan_all_in_directory_with_scope _frida_g_io_modules_scan_all_in_directory_with_scope -#define g_io_scheduler_cancel_all_jobs _frida_g_io_scheduler_cancel_all_jobs -#define g_io_scheduler_job_send_to_mainloop _frida_g_io_scheduler_job_send_to_mainloop -#define g_io_scheduler_job_send_to_mainloop_async _frida_g_io_scheduler_job_send_to_mainloop_async -#define g_io_scheduler_push_job _frida_g_io_scheduler_push_job -#define g_io_stream_clear_pending _frida_g_io_stream_clear_pending -#define g_io_stream_close _frida_g_io_stream_close -#define g_io_stream_close_async _frida_g_io_stream_close_async -#define g_io_stream_close_finish _frida_g_io_stream_close_finish -#define g_io_stream_get_input_stream _frida_g_io_stream_get_input_stream -#define g_io_stream_get_output_stream _frida_g_io_stream_get_output_stream -#define g_io_stream_get_type _frida_g_io_stream_get_type -#define g_io_stream_has_pending _frida_g_io_stream_has_pending -#define g_io_stream_is_closed _frida_g_io_stream_is_closed -#define g_io_stream_set_pending _frida_g_io_stream_set_pending -#define g_io_stream_splice_async _frida_g_io_stream_splice_async -#define g_io_stream_splice_finish _frida_g_io_stream_splice_finish -#define g_io_stream_splice_flags_get_type _frida_g_io_stream_splice_flags_get_type -#define g_io_watch_funcs _frida_g_io_watch_funcs -#define g_key_file_error_quark _frida_g_key_file_error_quark -#define g_key_file_free _frida_g_key_file_free -#define g_key_file_get_boolean _frida_g_key_file_get_boolean -#define g_key_file_get_boolean_list _frida_g_key_file_get_boolean_list -#define g_key_file_get_comment _frida_g_key_file_get_comment -#define g_key_file_get_double _frida_g_key_file_get_double -#define g_key_file_get_double_list _frida_g_key_file_get_double_list -#define g_key_file_get_groups _frida_g_key_file_get_groups -#define g_key_file_get_int64 _frida_g_key_file_get_int64 -#define g_key_file_get_integer _frida_g_key_file_get_integer -#define g_key_file_get_integer_list _frida_g_key_file_get_integer_list -#define g_key_file_get_keys _frida_g_key_file_get_keys -#define g_key_file_get_locale_for_key _frida_g_key_file_get_locale_for_key -#define g_key_file_get_locale_string _frida_g_key_file_get_locale_string -#define g_key_file_get_locale_string_list _frida_g_key_file_get_locale_string_list -#define g_key_file_get_start_group _frida_g_key_file_get_start_group -#define g_key_file_get_string _frida_g_key_file_get_string -#define g_key_file_get_string_list _frida_g_key_file_get_string_list -#define g_key_file_get_type _frida_g_key_file_get_type -#define g_key_file_get_uint64 _frida_g_key_file_get_uint64 -#define g_key_file_get_value _frida_g_key_file_get_value -#define g_key_file_has_group _frida_g_key_file_has_group -#define g_key_file_has_key _frida_g_key_file_has_key -#define g_key_file_load_from_bytes _frida_g_key_file_load_from_bytes -#define g_key_file_load_from_data _frida_g_key_file_load_from_data -#define g_key_file_load_from_data_dirs _frida_g_key_file_load_from_data_dirs -#define g_key_file_load_from_dirs _frida_g_key_file_load_from_dirs -#define g_key_file_load_from_file _frida_g_key_file_load_from_file -#define g_key_file_new _frida_g_key_file_new -#define g_key_file_ref _frida_g_key_file_ref -#define g_key_file_remove_comment _frida_g_key_file_remove_comment -#define g_key_file_remove_group _frida_g_key_file_remove_group -#define g_key_file_remove_key _frida_g_key_file_remove_key -#define g_key_file_save_to_file _frida_g_key_file_save_to_file -#define g_key_file_set_boolean _frida_g_key_file_set_boolean -#define g_key_file_set_boolean_list _frida_g_key_file_set_boolean_list -#define g_key_file_set_comment _frida_g_key_file_set_comment -#define g_key_file_set_double _frida_g_key_file_set_double -#define g_key_file_set_double_list _frida_g_key_file_set_double_list -#define g_key_file_set_int64 _frida_g_key_file_set_int64 -#define g_key_file_set_integer _frida_g_key_file_set_integer -#define g_key_file_set_integer_list _frida_g_key_file_set_integer_list -#define g_key_file_set_list_separator _frida_g_key_file_set_list_separator -#define g_key_file_set_locale_string _frida_g_key_file_set_locale_string -#define g_key_file_set_locale_string_list _frida_g_key_file_set_locale_string_list -#define g_key_file_set_string _frida_g_key_file_set_string -#define g_key_file_set_string_list _frida_g_key_file_set_string_list -#define g_key_file_set_uint64 _frida_g_key_file_set_uint64 -#define g_key_file_set_value _frida_g_key_file_set_value -#define g_key_file_to_data _frida_g_key_file_to_data -#define g_key_file_unref _frida_g_key_file_unref -#define g_keyfile_settings_backend_get_type _frida_g_keyfile_settings_backend_get_type -#define g_keyfile_settings_backend_new _frida_g_keyfile_settings_backend_new -#define g_libintl_bind_textdomain_codeset _frida_g_libintl_bind_textdomain_codeset -#define g_libintl_bindtextdomain _frida_g_libintl_bindtextdomain -#define g_libintl_dcgettext _frida_g_libintl_dcgettext -#define g_libintl_dcngettext _frida_g_libintl_dcngettext -#define g_libintl_dgettext _frida_g_libintl_dgettext -#define g_libintl_dngettext _frida_g_libintl_dngettext -#define g_libintl_gettext _frida_g_libintl_gettext -#define g_libintl_ngettext _frida_g_libintl_ngettext -#define g_libintl_textdomain _frida_g_libintl_textdomain -#define g_list_alloc _frida_g_list_alloc -#define g_list_append _frida_g_list_append -#define g_list_concat _frida_g_list_concat -#define g_list_copy _frida_g_list_copy -#define g_list_copy_deep _frida_g_list_copy_deep -#define g_list_delete_link _frida_g_list_delete_link -#define g_list_find _frida_g_list_find -#define g_list_find_custom _frida_g_list_find_custom -#define g_list_first _frida_g_list_first -#define g_list_foreach _frida_g_list_foreach -#define g_list_free _frida_g_list_free -#define g_list_free_1 _frida_g_list_free_1 -#define g_list_free_full _frida_g_list_free_full -#define g_list_index _frida_g_list_index -#define g_list_insert _frida_g_list_insert -#define g_list_insert_before _frida_g_list_insert_before -#define g_list_insert_before_link _frida_g_list_insert_before_link -#define g_list_insert_sorted _frida_g_list_insert_sorted -#define g_list_insert_sorted_with_data _frida_g_list_insert_sorted_with_data -#define g_list_last _frida_g_list_last -#define g_list_length _frida_g_list_length -#define g_list_model_get_item _frida_g_list_model_get_item -#define g_list_model_get_item_type _frida_g_list_model_get_item_type -#define g_list_model_get_n_items _frida_g_list_model_get_n_items -#define g_list_model_get_object _frida_g_list_model_get_object -#define g_list_model_get_type _frida_g_list_model_get_type -#define g_list_model_items_changed _frida_g_list_model_items_changed -#define g_list_nth _frida_g_list_nth -#define g_list_nth_data _frida_g_list_nth_data -#define g_list_nth_prev _frida_g_list_nth_prev -#define g_list_pop_allocator _frida_g_list_pop_allocator -#define g_list_position _frida_g_list_position -#define g_list_prepend _frida_g_list_prepend -#define g_list_push_allocator _frida_g_list_push_allocator -#define g_list_remove _frida_g_list_remove -#define g_list_remove_all _frida_g_list_remove_all -#define g_list_remove_link _frida_g_list_remove_link -#define g_list_reverse _frida_g_list_reverse -#define g_list_sort _frida_g_list_sort -#define g_list_sort_with_data _frida_g_list_sort_with_data -#define g_list_store_append _frida_g_list_store_append -#define g_list_store_find _frida_g_list_store_find -#define g_list_store_find_with_equal_func _frida_g_list_store_find_with_equal_func -#define g_list_store_get_type _frida_g_list_store_get_type -#define g_list_store_insert _frida_g_list_store_insert -#define g_list_store_insert_sorted _frida_g_list_store_insert_sorted -#define g_list_store_new _frida_g_list_store_new -#define g_list_store_remove _frida_g_list_store_remove -#define g_list_store_remove_all _frida_g_list_store_remove_all -#define g_list_store_sort _frida_g_list_store_sort -#define g_list_store_splice _frida_g_list_store_splice -#define g_listenv _frida_g_listenv -#define g_loadable_icon_get_type _frida_g_loadable_icon_get_type -#define g_loadable_icon_load _frida_g_loadable_icon_load -#define g_loadable_icon_load_async _frida_g_loadable_icon_load_async -#define g_loadable_icon_load_finish _frida_g_loadable_icon_load_finish -#define g_local_file_is_nfs_home _frida_g_local_file_is_nfs_home -#define g_local_file_monitor_get_type _frida_g_local_file_monitor_get_type -#define g_local_file_monitor_new_for_path _frida_g_local_file_monitor_new_for_path -#define g_local_file_monitor_new_in_worker _frida_g_local_file_monitor_new_in_worker -#define g_local_file_new_from_dirname_and_basename _frida_g_local_file_new_from_dirname_and_basename -#define g_locale_from_utf8 _frida_g_locale_from_utf8 -#define g_locale_to_utf8 _frida_g_locale_to_utf8 -#define g_log _frida_g_log -#define g_log_always_fatal _frida_g_log_always_fatal -#define g_log_default_handler _frida_g_log_default_handler -#define g_log_msg_prefix _frida_g_log_msg_prefix -#define g_log_remove_handler _frida_g_log_remove_handler -#define g_log_set_always_fatal _frida_g_log_set_always_fatal -#define g_log_set_default_handler _frida_g_log_set_default_handler -#define g_log_set_fatal_mask _frida_g_log_set_fatal_mask -#define g_log_set_handler _frida_g_log_set_handler -#define g_log_set_handler_full _frida_g_log_set_handler_full -#define g_log_set_writer_func _frida_g_log_set_writer_func -#define g_log_structured _frida_g_log_structured -#define g_log_structured_array _frida_g_log_structured_array -#define g_log_structured_standard _frida_g_log_structured_standard -#define g_log_variant _frida_g_log_variant -#define g_log_writer_default _frida_g_log_writer_default -#define g_log_writer_default_set_use_stderr _frida_g_log_writer_default_set_use_stderr -#define g_log_writer_default_would_drop _frida_g_log_writer_default_would_drop -#define g_log_writer_format_fields _frida_g_log_writer_format_fields -#define g_log_writer_is_journald _frida_g_log_writer_is_journald -#define g_log_writer_journald _frida_g_log_writer_journald -#define g_log_writer_standard_streams _frida_g_log_writer_standard_streams -#define g_log_writer_supports_color _frida_g_log_writer_supports_color -#define g_logv _frida_g_logv -#define g_lstat _frida_g_lstat -#define g_main_context_acquire _frida_g_main_context_acquire -#define g_main_context_add_poll _frida_g_main_context_add_poll -#define g_main_context_check _frida_g_main_context_check -#define g_main_context_default _frida_g_main_context_default -#define g_main_context_dispatch _frida_g_main_context_dispatch -#define g_main_context_find_source_by_funcs_user_data _frida_g_main_context_find_source_by_funcs_user_data -#define g_main_context_find_source_by_id _frida_g_main_context_find_source_by_id -#define g_main_context_find_source_by_user_data _frida_g_main_context_find_source_by_user_data -#define g_main_context_get_poll_func _frida_g_main_context_get_poll_func -#define g_main_context_get_thread_default _frida_g_main_context_get_thread_default -#define g_main_context_get_type _frida_g_main_context_get_type -#define g_main_context_invoke _frida_g_main_context_invoke -#define g_main_context_invoke_full _frida_g_main_context_invoke_full -#define g_main_context_is_owner _frida_g_main_context_is_owner -#define g_main_context_iteration _frida_g_main_context_iteration -#define g_main_context_new _frida_g_main_context_new -#define g_main_context_new_with_next_id _frida_g_main_context_new_with_next_id -#define g_main_context_pending _frida_g_main_context_pending -#define g_main_context_pop_thread_default _frida_g_main_context_pop_thread_default -#define g_main_context_prepare _frida_g_main_context_prepare -#define g_main_context_push_thread_default _frida_g_main_context_push_thread_default -#define g_main_context_query _frida_g_main_context_query -#define g_main_context_ref _frida_g_main_context_ref -#define g_main_context_ref_thread_default _frida_g_main_context_ref_thread_default -#define g_main_context_release _frida_g_main_context_release -#define g_main_context_remove_poll _frida_g_main_context_remove_poll -#define g_main_context_set_poll_func _frida_g_main_context_set_poll_func -#define g_main_context_unref _frida_g_main_context_unref -#define g_main_context_wait _frida_g_main_context_wait -#define g_main_context_wakeup _frida_g_main_context_wakeup -#define g_main_current_source _frida_g_main_current_source -#define g_main_depth _frida_g_main_depth -#define g_main_loop_get_context _frida_g_main_loop_get_context -#define g_main_loop_get_type _frida_g_main_loop_get_type -#define g_main_loop_is_running _frida_g_main_loop_is_running -#define g_main_loop_new _frida_g_main_loop_new -#define g_main_loop_quit _frida_g_main_loop_quit -#define g_main_loop_ref _frida_g_main_loop_ref -#define g_main_loop_run _frida_g_main_loop_run -#define g_main_loop_unref _frida_g_main_loop_unref -#define g_malloc _frida_g_malloc -#define g_malloc0 _frida_g_malloc0 -#define g_malloc0_n _frida_g_malloc0_n -#define g_malloc_n _frida_g_malloc_n -#define g_mapped_file_free _frida_g_mapped_file_free -#define g_mapped_file_get_bytes _frida_g_mapped_file_get_bytes -#define g_mapped_file_get_contents _frida_g_mapped_file_get_contents -#define g_mapped_file_get_length _frida_g_mapped_file_get_length -#define g_mapped_file_get_type _frida_g_mapped_file_get_type -#define g_mapped_file_new _frida_g_mapped_file_new -#define g_mapped_file_new_from_fd _frida_g_mapped_file_new_from_fd -#define g_mapped_file_ref _frida_g_mapped_file_ref -#define g_mapped_file_unref _frida_g_mapped_file_unref -#define g_markup_collect_attributes _frida_g_markup_collect_attributes -#define g_markup_error_quark _frida_g_markup_error_quark -#define g_markup_escape_text _frida_g_markup_escape_text -#define g_markup_parse_context_end_parse _frida_g_markup_parse_context_end_parse -#define g_markup_parse_context_free _frida_g_markup_parse_context_free -#define g_markup_parse_context_get_element _frida_g_markup_parse_context_get_element -#define g_markup_parse_context_get_element_stack _frida_g_markup_parse_context_get_element_stack -#define g_markup_parse_context_get_position _frida_g_markup_parse_context_get_position -#define g_markup_parse_context_get_type _frida_g_markup_parse_context_get_type -#define g_markup_parse_context_get_user_data _frida_g_markup_parse_context_get_user_data -#define g_markup_parse_context_new _frida_g_markup_parse_context_new -#define g_markup_parse_context_parse _frida_g_markup_parse_context_parse -#define g_markup_parse_context_pop _frida_g_markup_parse_context_pop -#define g_markup_parse_context_push _frida_g_markup_parse_context_push -#define g_markup_parse_context_ref _frida_g_markup_parse_context_ref -#define g_markup_parse_context_unref _frida_g_markup_parse_context_unref -#define g_markup_printf_escaped _frida_g_markup_printf_escaped -#define g_markup_vprintf_escaped _frida_g_markup_vprintf_escaped -#define g_match_info_expand_references _frida_g_match_info_expand_references -#define g_match_info_fetch _frida_g_match_info_fetch -#define g_match_info_fetch_all _frida_g_match_info_fetch_all -#define g_match_info_fetch_named _frida_g_match_info_fetch_named -#define g_match_info_fetch_named_pos _frida_g_match_info_fetch_named_pos -#define g_match_info_fetch_pos _frida_g_match_info_fetch_pos -#define g_match_info_free _frida_g_match_info_free -#define g_match_info_get_match_count _frida_g_match_info_get_match_count -#define g_match_info_get_regex _frida_g_match_info_get_regex -#define g_match_info_get_string _frida_g_match_info_get_string -#define g_match_info_get_type _frida_g_match_info_get_type -#define g_match_info_is_partial_match _frida_g_match_info_is_partial_match -#define g_match_info_matches _frida_g_match_info_matches -#define g_match_info_next _frida_g_match_info_next -#define g_match_info_ref _frida_g_match_info_ref -#define g_match_info_unref _frida_g_match_info_unref -#define g_mem_chunk_alloc _frida_g_mem_chunk_alloc -#define g_mem_chunk_alloc0 _frida_g_mem_chunk_alloc0 -#define g_mem_chunk_clean _frida_g_mem_chunk_clean -#define g_mem_chunk_destroy _frida_g_mem_chunk_destroy -#define g_mem_chunk_free _frida_g_mem_chunk_free -#define g_mem_chunk_info _frida_g_mem_chunk_info -#define g_mem_chunk_new _frida_g_mem_chunk_new -#define g_mem_chunk_print _frida_g_mem_chunk_print -#define g_mem_chunk_reset _frida_g_mem_chunk_reset -#define g_mem_gc_friendly _frida_g_mem_gc_friendly -#define g_mem_is_system_malloc _frida_g_mem_is_system_malloc -#define g_mem_profile _frida_g_mem_profile -#define g_mem_set_vtable _frida_g_mem_set_vtable -#define g_memdup _frida_g_memdup -#define g_memory_input_stream_add_bytes _frida_g_memory_input_stream_add_bytes -#define g_memory_input_stream_add_data _frida_g_memory_input_stream_add_data -#define g_memory_input_stream_get_type _frida_g_memory_input_stream_get_type -#define g_memory_input_stream_new _frida_g_memory_input_stream_new -#define g_memory_input_stream_new_from_bytes _frida_g_memory_input_stream_new_from_bytes -#define g_memory_input_stream_new_from_data _frida_g_memory_input_stream_new_from_data -#define g_memory_monitor_dbus_get_type _frida_g_memory_monitor_dbus_get_type -#define g_memory_monitor_dup_default _frida_g_memory_monitor_dup_default -#define g_memory_monitor_get_type _frida_g_memory_monitor_get_type -#define g_memory_monitor_portal_get_type _frida_g_memory_monitor_portal_get_type -#define g_memory_monitor_warning_level_get_type _frida_g_memory_monitor_warning_level_get_type -#define g_memory_output_stream_get_data _frida_g_memory_output_stream_get_data -#define g_memory_output_stream_get_data_size _frida_g_memory_output_stream_get_data_size -#define g_memory_output_stream_get_size _frida_g_memory_output_stream_get_size -#define g_memory_output_stream_get_type _frida_g_memory_output_stream_get_type -#define g_memory_output_stream_new _frida_g_memory_output_stream_new -#define g_memory_output_stream_new_resizable _frida_g_memory_output_stream_new_resizable -#define g_memory_output_stream_steal_as_bytes _frida_g_memory_output_stream_steal_as_bytes -#define g_memory_output_stream_steal_data _frida_g_memory_output_stream_steal_data -#define g_memory_settings_backend_get_type _frida_g_memory_settings_backend_get_type -#define g_memory_settings_backend_new _frida_g_memory_settings_backend_new -#define g_menu_append _frida_g_menu_append -#define g_menu_append_item _frida_g_menu_append_item -#define g_menu_append_section _frida_g_menu_append_section -#define g_menu_append_submenu _frida_g_menu_append_submenu -#define g_menu_attribute_iter_get_name _frida_g_menu_attribute_iter_get_name -#define g_menu_attribute_iter_get_next _frida_g_menu_attribute_iter_get_next -#define g_menu_attribute_iter_get_type _frida_g_menu_attribute_iter_get_type -#define g_menu_attribute_iter_get_value _frida_g_menu_attribute_iter_get_value -#define g_menu_attribute_iter_next _frida_g_menu_attribute_iter_next -#define g_menu_freeze _frida_g_menu_freeze -#define g_menu_get_type _frida_g_menu_get_type -#define g_menu_insert _frida_g_menu_insert -#define g_menu_insert_item _frida_g_menu_insert_item -#define g_menu_insert_section _frida_g_menu_insert_section -#define g_menu_insert_submenu _frida_g_menu_insert_submenu -#define g_menu_item_get_attribute _frida_g_menu_item_get_attribute -#define g_menu_item_get_attribute_value _frida_g_menu_item_get_attribute_value -#define g_menu_item_get_link _frida_g_menu_item_get_link -#define g_menu_item_get_type _frida_g_menu_item_get_type -#define g_menu_item_new _frida_g_menu_item_new -#define g_menu_item_new_from_model _frida_g_menu_item_new_from_model -#define g_menu_item_new_section _frida_g_menu_item_new_section -#define g_menu_item_new_submenu _frida_g_menu_item_new_submenu -#define g_menu_item_set_action_and_target _frida_g_menu_item_set_action_and_target -#define g_menu_item_set_action_and_target_value _frida_g_menu_item_set_action_and_target_value -#define g_menu_item_set_attribute _frida_g_menu_item_set_attribute -#define g_menu_item_set_attribute_value _frida_g_menu_item_set_attribute_value -#define g_menu_item_set_detailed_action _frida_g_menu_item_set_detailed_action -#define g_menu_item_set_icon _frida_g_menu_item_set_icon -#define g_menu_item_set_label _frida_g_menu_item_set_label -#define g_menu_item_set_link _frida_g_menu_item_set_link -#define g_menu_item_set_section _frida_g_menu_item_set_section -#define g_menu_item_set_submenu _frida_g_menu_item_set_submenu -#define g_menu_link_iter_get_name _frida_g_menu_link_iter_get_name -#define g_menu_link_iter_get_next _frida_g_menu_link_iter_get_next -#define g_menu_link_iter_get_type _frida_g_menu_link_iter_get_type -#define g_menu_link_iter_get_value _frida_g_menu_link_iter_get_value -#define g_menu_link_iter_next _frida_g_menu_link_iter_next -#define g_menu_model_get_item_attribute _frida_g_menu_model_get_item_attribute -#define g_menu_model_get_item_attribute_value _frida_g_menu_model_get_item_attribute_value -#define g_menu_model_get_item_link _frida_g_menu_model_get_item_link -#define g_menu_model_get_n_items _frida_g_menu_model_get_n_items -#define g_menu_model_get_type _frida_g_menu_model_get_type -#define g_menu_model_is_mutable _frida_g_menu_model_is_mutable -#define g_menu_model_items_changed _frida_g_menu_model_items_changed -#define g_menu_model_iterate_item_attributes _frida_g_menu_model_iterate_item_attributes -#define g_menu_model_iterate_item_links _frida_g_menu_model_iterate_item_links -#define g_menu_new _frida_g_menu_new -#define g_menu_prepend _frida_g_menu_prepend -#define g_menu_prepend_item _frida_g_menu_prepend_item -#define g_menu_prepend_section _frida_g_menu_prepend_section -#define g_menu_prepend_submenu _frida_g_menu_prepend_submenu -#define g_menu_remove _frida_g_menu_remove -#define g_menu_remove_all _frida_g_menu_remove_all -#define g_mkdir _frida_g_mkdir -#define g_mkdir_with_parents _frida_g_mkdir_with_parents -#define g_mkdtemp _frida_g_mkdtemp -#define g_mkdtemp_full _frida_g_mkdtemp_full -#define g_mkstemp _frida_g_mkstemp -#define g_mkstemp_full _frida_g_mkstemp_full -#define g_module_build_path _frida_g_module_build_path -#define g_module_close _frida_g_module_close -#define g_module_error _frida_g_module_error -#define g_module_make_resident _frida_g_module_make_resident -#define g_module_name _frida_g_module_name -#define g_module_open _frida_g_module_open -#define g_module_supported _frida_g_module_supported -#define g_module_symbol _frida_g_module_symbol -#define g_mount_can_eject _frida_g_mount_can_eject -#define g_mount_can_unmount _frida_g_mount_can_unmount -#define g_mount_eject _frida_g_mount_eject -#define g_mount_eject_finish _frida_g_mount_eject_finish -#define g_mount_eject_with_operation _frida_g_mount_eject_with_operation -#define g_mount_eject_with_operation_finish _frida_g_mount_eject_with_operation_finish -#define g_mount_get_default_location _frida_g_mount_get_default_location -#define g_mount_get_drive _frida_g_mount_get_drive -#define g_mount_get_icon _frida_g_mount_get_icon -#define g_mount_get_name _frida_g_mount_get_name -#define g_mount_get_root _frida_g_mount_get_root -#define g_mount_get_sort_key _frida_g_mount_get_sort_key -#define g_mount_get_symbolic_icon _frida_g_mount_get_symbolic_icon -#define g_mount_get_type _frida_g_mount_get_type -#define g_mount_get_uuid _frida_g_mount_get_uuid -#define g_mount_get_volume _frida_g_mount_get_volume -#define g_mount_guess_content_type _frida_g_mount_guess_content_type -#define g_mount_guess_content_type_finish _frida_g_mount_guess_content_type_finish -#define g_mount_guess_content_type_sync _frida_g_mount_guess_content_type_sync -#define g_mount_is_shadowed _frida_g_mount_is_shadowed -#define g_mount_mount_flags_get_type _frida_g_mount_mount_flags_get_type -#define g_mount_operation_get_anonymous _frida_g_mount_operation_get_anonymous -#define g_mount_operation_get_choice _frida_g_mount_operation_get_choice -#define g_mount_operation_get_domain _frida_g_mount_operation_get_domain -#define g_mount_operation_get_is_tcrypt_hidden_volume _frida_g_mount_operation_get_is_tcrypt_hidden_volume -#define g_mount_operation_get_is_tcrypt_system_volume _frida_g_mount_operation_get_is_tcrypt_system_volume -#define g_mount_operation_get_password _frida_g_mount_operation_get_password -#define g_mount_operation_get_password_save _frida_g_mount_operation_get_password_save -#define g_mount_operation_get_pim _frida_g_mount_operation_get_pim -#define g_mount_operation_get_type _frida_g_mount_operation_get_type -#define g_mount_operation_get_username _frida_g_mount_operation_get_username -#define g_mount_operation_new _frida_g_mount_operation_new -#define g_mount_operation_reply _frida_g_mount_operation_reply -#define g_mount_operation_result_get_type _frida_g_mount_operation_result_get_type -#define g_mount_operation_set_anonymous _frida_g_mount_operation_set_anonymous -#define g_mount_operation_set_choice _frida_g_mount_operation_set_choice -#define g_mount_operation_set_domain _frida_g_mount_operation_set_domain -#define g_mount_operation_set_is_tcrypt_hidden_volume _frida_g_mount_operation_set_is_tcrypt_hidden_volume -#define g_mount_operation_set_is_tcrypt_system_volume _frida_g_mount_operation_set_is_tcrypt_system_volume -#define g_mount_operation_set_password _frida_g_mount_operation_set_password -#define g_mount_operation_set_password_save _frida_g_mount_operation_set_password_save -#define g_mount_operation_set_pim _frida_g_mount_operation_set_pim -#define g_mount_operation_set_username _frida_g_mount_operation_set_username -#define g_mount_remount _frida_g_mount_remount -#define g_mount_remount_finish _frida_g_mount_remount_finish -#define g_mount_shadow _frida_g_mount_shadow -#define g_mount_unmount _frida_g_mount_unmount -#define g_mount_unmount_finish _frida_g_mount_unmount_finish -#define g_mount_unmount_flags_get_type _frida_g_mount_unmount_flags_get_type -#define g_mount_unmount_with_operation _frida_g_mount_unmount_with_operation -#define g_mount_unmount_with_operation_finish _frida_g_mount_unmount_with_operation_finish -#define g_mount_unshadow _frida_g_mount_unshadow -#define g_mutex_clear _frida_g_mutex_clear -#define g_mutex_free _frida_g_mutex_free -#define g_mutex_init _frida_g_mutex_init -#define g_mutex_lock _frida_g_mutex_lock -#define g_mutex_new _frida_g_mutex_new -#define g_mutex_trylock _frida_g_mutex_trylock -#define g_mutex_unlock _frida_g_mutex_unlock -#define g_native_socket_address_get_type _frida_g_native_socket_address_get_type -#define g_native_socket_address_new _frida_g_native_socket_address_new -#define g_native_volume_monitor_get_type _frida_g_native_volume_monitor_get_type -#define g_network_address_get_hostname _frida_g_network_address_get_hostname -#define g_network_address_get_port _frida_g_network_address_get_port -#define g_network_address_get_scheme _frida_g_network_address_get_scheme -#define g_network_address_get_type _frida_g_network_address_get_type -#define g_network_address_new _frida_g_network_address_new -#define g_network_address_new_loopback _frida_g_network_address_new_loopback -#define g_network_address_parse _frida_g_network_address_parse -#define g_network_address_parse_uri _frida_g_network_address_parse_uri -#define g_network_connectivity_get_type _frida_g_network_connectivity_get_type -#define g_network_monitor_base_add_network _frida_g_network_monitor_base_add_network -#define g_network_monitor_base_get_type _frida_g_network_monitor_base_get_type -#define g_network_monitor_base_remove_network _frida_g_network_monitor_base_remove_network -#define g_network_monitor_base_set_networks _frida_g_network_monitor_base_set_networks -#define g_network_monitor_can_reach _frida_g_network_monitor_can_reach -#define g_network_monitor_can_reach_async _frida_g_network_monitor_can_reach_async -#define g_network_monitor_can_reach_finish _frida_g_network_monitor_can_reach_finish -#define g_network_monitor_get_connectivity _frida_g_network_monitor_get_connectivity -#define g_network_monitor_get_default _frida_g_network_monitor_get_default -#define g_network_monitor_get_network_available _frida_g_network_monitor_get_network_available -#define g_network_monitor_get_network_metered _frida_g_network_monitor_get_network_metered -#define g_network_monitor_get_type _frida_g_network_monitor_get_type -#define g_network_monitor_portal_get_type _frida_g_network_monitor_portal_get_type -#define g_network_service_get_domain _frida_g_network_service_get_domain -#define g_network_service_get_protocol _frida_g_network_service_get_protocol -#define g_network_service_get_scheme _frida_g_network_service_get_scheme -#define g_network_service_get_service _frida_g_network_service_get_service -#define g_network_service_get_type _frida_g_network_service_get_type -#define g_network_service_new _frida_g_network_service_new -#define g_network_service_set_scheme _frida_g_network_service_set_scheme -#define g_networking_init _frida_g_networking_init -#define g_node_child_index _frida_g_node_child_index -#define g_node_child_position _frida_g_node_child_position -#define g_node_children_foreach _frida_g_node_children_foreach -#define g_node_copy _frida_g_node_copy -#define g_node_copy_deep _frida_g_node_copy_deep -#define g_node_depth _frida_g_node_depth -#define g_node_destroy _frida_g_node_destroy -#define g_node_find _frida_g_node_find -#define g_node_find_child _frida_g_node_find_child -#define g_node_first_sibling _frida_g_node_first_sibling -#define g_node_get_root _frida_g_node_get_root -#define g_node_insert _frida_g_node_insert -#define g_node_insert_after _frida_g_node_insert_after -#define g_node_insert_before _frida_g_node_insert_before -#define g_node_is_ancestor _frida_g_node_is_ancestor -#define g_node_last_child _frida_g_node_last_child -#define g_node_last_sibling _frida_g_node_last_sibling -#define g_node_max_height _frida_g_node_max_height -#define g_node_n_children _frida_g_node_n_children -#define g_node_n_nodes _frida_g_node_n_nodes -#define g_node_new _frida_g_node_new -#define g_node_nth_child _frida_g_node_nth_child -#define g_node_pop_allocator _frida_g_node_pop_allocator -#define g_node_prepend _frida_g_node_prepend -#define g_node_push_allocator _frida_g_node_push_allocator -#define g_node_reverse_children _frida_g_node_reverse_children -#define g_node_traverse _frida_g_node_traverse -#define g_node_unlink _frida_g_node_unlink -#define g_normalize_mode_get_type _frida_g_normalize_mode_get_type -#define g_notification_add_button _frida_g_notification_add_button -#define g_notification_add_button_with_target _frida_g_notification_add_button_with_target -#define g_notification_add_button_with_target_value _frida_g_notification_add_button_with_target_value -#define g_notification_backend_get_type _frida_g_notification_backend_get_type -#define g_notification_backend_new_default _frida_g_notification_backend_new_default -#define g_notification_backend_send_notification _frida_g_notification_backend_send_notification -#define g_notification_backend_withdraw_notification _frida_g_notification_backend_withdraw_notification -#define g_notification_get_body _frida_g_notification_get_body -#define g_notification_get_button _frida_g_notification_get_button -#define g_notification_get_button_with_action _frida_g_notification_get_button_with_action -#define g_notification_get_default_action _frida_g_notification_get_default_action -#define g_notification_get_icon _frida_g_notification_get_icon -#define g_notification_get_n_buttons _frida_g_notification_get_n_buttons -#define g_notification_get_priority _frida_g_notification_get_priority -#define g_notification_get_title _frida_g_notification_get_title -#define g_notification_get_type _frida_g_notification_get_type -#define g_notification_new _frida_g_notification_new -#define g_notification_priority_get_type _frida_g_notification_priority_get_type -#define g_notification_serialize _frida_g_notification_serialize -#define g_notification_set_body _frida_g_notification_set_body -#define g_notification_set_default_action _frida_g_notification_set_default_action -#define g_notification_set_default_action_and_target _frida_g_notification_set_default_action_and_target -#define g_notification_set_default_action_and_target_value _frida_g_notification_set_default_action_and_target_value -#define g_notification_set_icon _frida_g_notification_set_icon -#define g_notification_set_priority _frida_g_notification_set_priority -#define g_notification_set_title _frida_g_notification_set_title -#define g_notification_set_urgent _frida_g_notification_set_urgent -#define g_null_settings_backend_get_type _frida_g_null_settings_backend_get_type -#define g_null_settings_backend_new _frida_g_null_settings_backend_new -#define g_nullify_pointer _frida_g_nullify_pointer -#define g_number_parser_error_quark _frida_g_number_parser_error_quark -#define g_object_add_toggle_ref _frida_g_object_add_toggle_ref -#define g_object_add_weak_pointer _frida_g_object_add_weak_pointer -#define g_object_bind_property _frida_g_object_bind_property -#define g_object_bind_property_full _frida_g_object_bind_property_full -#define g_object_bind_property_with_closures _frida_g_object_bind_property_with_closures -#define g_object_class_find_property _frida_g_object_class_find_property -#define g_object_class_install_properties _frida_g_object_class_install_properties -#define g_object_class_install_property _frida_g_object_class_install_property -#define g_object_class_list_properties _frida_g_object_class_list_properties -#define g_object_class_override_property _frida_g_object_class_override_property -#define g_object_compat_control _frida_g_object_compat_control -#define g_object_connect _frida_g_object_connect -#define g_object_disconnect _frida_g_object_disconnect -#define g_object_dup_data _frida_g_object_dup_data -#define g_object_dup_qdata _frida_g_object_dup_qdata -#define g_object_force_floating _frida_g_object_force_floating -#define g_object_freeze_notify _frida_g_object_freeze_notify -#define g_object_get _frida_g_object_get -#define g_object_get_data _frida_g_object_get_data -#define g_object_get_property _frida_g_object_get_property -#define g_object_get_qdata _frida_g_object_get_qdata -#define g_object_get_type _frida_g_object_get_type -#define g_object_get_valist _frida_g_object_get_valist -#define g_object_getv _frida_g_object_getv -#define g_object_interface_find_property _frida_g_object_interface_find_property -#define g_object_interface_install_property _frida_g_object_interface_install_property -#define g_object_interface_list_properties _frida_g_object_interface_list_properties -#define g_object_is_floating _frida_g_object_is_floating -#define g_object_new _frida_g_object_new -#define g_object_new_valist _frida_g_object_new_valist -#define g_object_new_with_properties _frida_g_object_new_with_properties -#define g_object_newv _frida_g_object_newv -#define g_object_notify _frida_g_object_notify -#define g_object_notify_by_pspec _frida_g_object_notify_by_pspec -#define g_object_ref _frida_g_object_ref -#define g_object_ref_sink _frida_g_object_ref_sink -#define g_object_remove_toggle_ref _frida_g_object_remove_toggle_ref -#define g_object_remove_weak_pointer _frida_g_object_remove_weak_pointer -#define g_object_replace_data _frida_g_object_replace_data -#define g_object_replace_qdata _frida_g_object_replace_qdata -#define g_object_run_dispose _frida_g_object_run_dispose -#define g_object_set _frida_g_object_set -#define g_object_set_data _frida_g_object_set_data -#define g_object_set_data_full _frida_g_object_set_data_full -#define g_object_set_property _frida_g_object_set_property -#define g_object_set_qdata _frida_g_object_set_qdata -#define g_object_set_qdata_full _frida_g_object_set_qdata_full -#define g_object_set_valist _frida_g_object_set_valist -#define g_object_setv _frida_g_object_setv -#define g_object_steal_data _frida_g_object_steal_data -#define g_object_steal_qdata _frida_g_object_steal_qdata -#define g_object_thaw_notify _frida_g_object_thaw_notify -#define g_object_unref _frida_g_object_unref -#define g_object_watch_closure _frida_g_object_watch_closure -#define g_object_weak_ref _frida_g_object_weak_ref -#define g_object_weak_unref _frida_g_object_weak_unref -#define g_on_error_query _frida_g_on_error_query -#define g_on_error_stack_trace _frida_g_on_error_stack_trace -#define g_once_impl _frida_g_once_impl -#define g_once_init_enter _frida_g_once_init_enter -#define g_once_init_enter_impl _frida_g_once_init_enter_impl -#define g_once_init_leave _frida_g_once_init_leave -#define g_open _frida_g_open -#define g_openuri_portal_open_uri _frida_g_openuri_portal_open_uri -#define g_openuri_portal_open_uri_async _frida_g_openuri_portal_open_uri_async -#define g_openuri_portal_open_uri_finish _frida_g_openuri_portal_open_uri_finish -#define g_option_context_add_group _frida_g_option_context_add_group -#define g_option_context_add_main_entries _frida_g_option_context_add_main_entries -#define g_option_context_free _frida_g_option_context_free -#define g_option_context_get_description _frida_g_option_context_get_description -#define g_option_context_get_help _frida_g_option_context_get_help -#define g_option_context_get_help_enabled _frida_g_option_context_get_help_enabled -#define g_option_context_get_ignore_unknown_options _frida_g_option_context_get_ignore_unknown_options -#define g_option_context_get_main_group _frida_g_option_context_get_main_group -#define g_option_context_get_strict_posix _frida_g_option_context_get_strict_posix -#define g_option_context_get_summary _frida_g_option_context_get_summary -#define g_option_context_new _frida_g_option_context_new -#define g_option_context_parse _frida_g_option_context_parse -#define g_option_context_parse_strv _frida_g_option_context_parse_strv -#define g_option_context_set_description _frida_g_option_context_set_description -#define g_option_context_set_help_enabled _frida_g_option_context_set_help_enabled -#define g_option_context_set_ignore_unknown_options _frida_g_option_context_set_ignore_unknown_options -#define g_option_context_set_main_group _frida_g_option_context_set_main_group -#define g_option_context_set_strict_posix _frida_g_option_context_set_strict_posix -#define g_option_context_set_summary _frida_g_option_context_set_summary -#define g_option_context_set_translate_func _frida_g_option_context_set_translate_func -#define g_option_context_set_translation_domain _frida_g_option_context_set_translation_domain -#define g_option_error_quark _frida_g_option_error_quark -#define g_option_group_add_entries _frida_g_option_group_add_entries -#define g_option_group_free _frida_g_option_group_free -#define g_option_group_get_type _frida_g_option_group_get_type -#define g_option_group_new _frida_g_option_group_new -#define g_option_group_ref _frida_g_option_group_ref -#define g_option_group_set_error_hook _frida_g_option_group_set_error_hook -#define g_option_group_set_parse_hooks _frida_g_option_group_set_parse_hooks -#define g_option_group_set_translate_func _frida_g_option_group_set_translate_func -#define g_option_group_set_translation_domain _frida_g_option_group_set_translation_domain -#define g_option_group_unref _frida_g_option_group_unref -#define g_output_stream_async_close_is_via_threads _frida_g_output_stream_async_close_is_via_threads -#define g_output_stream_async_write_is_via_threads _frida_g_output_stream_async_write_is_via_threads -#define g_output_stream_async_writev_is_via_threads _frida_g_output_stream_async_writev_is_via_threads -#define g_output_stream_clear_pending _frida_g_output_stream_clear_pending -#define g_output_stream_close _frida_g_output_stream_close -#define g_output_stream_close_async _frida_g_output_stream_close_async -#define g_output_stream_close_finish _frida_g_output_stream_close_finish -#define g_output_stream_flush _frida_g_output_stream_flush -#define g_output_stream_flush_async _frida_g_output_stream_flush_async -#define g_output_stream_flush_finish _frida_g_output_stream_flush_finish -#define g_output_stream_get_type _frida_g_output_stream_get_type -#define g_output_stream_has_pending _frida_g_output_stream_has_pending -#define g_output_stream_is_closed _frida_g_output_stream_is_closed -#define g_output_stream_is_closing _frida_g_output_stream_is_closing -#define g_output_stream_printf _frida_g_output_stream_printf -#define g_output_stream_set_pending _frida_g_output_stream_set_pending -#define g_output_stream_splice _frida_g_output_stream_splice -#define g_output_stream_splice_async _frida_g_output_stream_splice_async -#define g_output_stream_splice_finish _frida_g_output_stream_splice_finish -#define g_output_stream_splice_flags_get_type _frida_g_output_stream_splice_flags_get_type -#define g_output_stream_vprintf _frida_g_output_stream_vprintf -#define g_output_stream_write _frida_g_output_stream_write -#define g_output_stream_write_all _frida_g_output_stream_write_all -#define g_output_stream_write_all_async _frida_g_output_stream_write_all_async -#define g_output_stream_write_all_finish _frida_g_output_stream_write_all_finish -#define g_output_stream_write_async _frida_g_output_stream_write_async -#define g_output_stream_write_bytes _frida_g_output_stream_write_bytes -#define g_output_stream_write_bytes_async _frida_g_output_stream_write_bytes_async -#define g_output_stream_write_bytes_finish _frida_g_output_stream_write_bytes_finish -#define g_output_stream_write_finish _frida_g_output_stream_write_finish -#define g_output_stream_writev _frida_g_output_stream_writev -#define g_output_stream_writev_all _frida_g_output_stream_writev_all -#define g_output_stream_writev_all_async _frida_g_output_stream_writev_all_async -#define g_output_stream_writev_all_finish _frida_g_output_stream_writev_all_finish -#define g_output_stream_writev_async _frida_g_output_stream_writev_async -#define g_output_stream_writev_finish _frida_g_output_stream_writev_finish -#define g_param_spec_boolean _frida_g_param_spec_boolean -#define g_param_spec_boxed _frida_g_param_spec_boxed -#define g_param_spec_char _frida_g_param_spec_char -#define g_param_spec_double _frida_g_param_spec_double -#define g_param_spec_enum _frida_g_param_spec_enum -#define g_param_spec_flags _frida_g_param_spec_flags -#define g_param_spec_float _frida_g_param_spec_float -#define g_param_spec_get_blurb _frida_g_param_spec_get_blurb -#define g_param_spec_get_default_value _frida_g_param_spec_get_default_value -#define g_param_spec_get_name _frida_g_param_spec_get_name -#define g_param_spec_get_name_quark _frida_g_param_spec_get_name_quark -#define g_param_spec_get_nick _frida_g_param_spec_get_nick -#define g_param_spec_get_qdata _frida_g_param_spec_get_qdata -#define g_param_spec_get_redirect_target _frida_g_param_spec_get_redirect_target -#define g_param_spec_gtype _frida_g_param_spec_gtype -#define g_param_spec_int _frida_g_param_spec_int -#define g_param_spec_int64 _frida_g_param_spec_int64 -#define g_param_spec_internal _frida_g_param_spec_internal -#define g_param_spec_is_valid_name _frida_g_param_spec_is_valid_name -#define g_param_spec_long _frida_g_param_spec_long -#define g_param_spec_object _frida_g_param_spec_object -#define g_param_spec_override _frida_g_param_spec_override -#define g_param_spec_param _frida_g_param_spec_param -#define g_param_spec_pointer _frida_g_param_spec_pointer -#define g_param_spec_pool_insert _frida_g_param_spec_pool_insert -#define g_param_spec_pool_list _frida_g_param_spec_pool_list -#define g_param_spec_pool_list_owned _frida_g_param_spec_pool_list_owned -#define g_param_spec_pool_lookup _frida_g_param_spec_pool_lookup -#define g_param_spec_pool_new _frida_g_param_spec_pool_new -#define g_param_spec_pool_remove _frida_g_param_spec_pool_remove -#define g_param_spec_ref _frida_g_param_spec_ref -#define g_param_spec_ref_sink _frida_g_param_spec_ref_sink -#define g_param_spec_set_qdata _frida_g_param_spec_set_qdata -#define g_param_spec_set_qdata_full _frida_g_param_spec_set_qdata_full -#define g_param_spec_sink _frida_g_param_spec_sink -#define g_param_spec_steal_qdata _frida_g_param_spec_steal_qdata -#define g_param_spec_string _frida_g_param_spec_string -#define g_param_spec_types _frida_g_param_spec_types -#define g_param_spec_uchar _frida_g_param_spec_uchar -#define g_param_spec_uint _frida_g_param_spec_uint -#define g_param_spec_uint64 _frida_g_param_spec_uint64 -#define g_param_spec_ulong _frida_g_param_spec_ulong -#define g_param_spec_unichar _frida_g_param_spec_unichar -#define g_param_spec_unref _frida_g_param_spec_unref -#define g_param_spec_value_array _frida_g_param_spec_value_array -#define g_param_spec_variant _frida_g_param_spec_variant -#define g_param_type_register_static _frida_g_param_type_register_static -#define g_param_value_convert _frida_g_param_value_convert -#define g_param_value_defaults _frida_g_param_value_defaults -#define g_param_value_set_default _frida_g_param_value_set_default -#define g_param_value_validate _frida_g_param_value_validate -#define g_param_values_cmp _frida_g_param_values_cmp -#define g_parse_debug_string _frida_g_parse_debug_string -#define g_password_save_get_type _frida_g_password_save_get_type -#define g_path_get_basename _frida_g_path_get_basename -#define g_path_get_dirname _frida_g_path_get_dirname -#define g_path_is_absolute _frida_g_path_is_absolute -#define g_path_skip_root _frida_g_path_skip_root -#define g_pattern_match _frida_g_pattern_match -#define g_pattern_match_simple _frida_g_pattern_match_simple -#define g_pattern_match_string _frida_g_pattern_match_string -#define g_pattern_spec_equal _frida_g_pattern_spec_equal -#define g_pattern_spec_free _frida_g_pattern_spec_free -#define g_pattern_spec_new _frida_g_pattern_spec_new -#define g_permission_acquire _frida_g_permission_acquire -#define g_permission_acquire_async _frida_g_permission_acquire_async -#define g_permission_acquire_finish _frida_g_permission_acquire_finish -#define g_permission_get_allowed _frida_g_permission_get_allowed -#define g_permission_get_can_acquire _frida_g_permission_get_can_acquire -#define g_permission_get_can_release _frida_g_permission_get_can_release -#define g_permission_get_type _frida_g_permission_get_type -#define g_permission_impl_update _frida_g_permission_impl_update -#define g_permission_release _frida_g_permission_release -#define g_permission_release_async _frida_g_permission_release_async -#define g_permission_release_finish _frida_g_permission_release_finish -#define g_platform_audit_set_fd_callbacks _frida_g_platform_audit_set_fd_callbacks -#define g_pointer_bit_lock _frida_g_pointer_bit_lock -#define g_pointer_bit_trylock _frida_g_pointer_bit_trylock -#define g_pointer_bit_unlock _frida_g_pointer_bit_unlock -#define g_pointer_type_register_static _frida_g_pointer_type_register_static -#define g_poll _frida_g_poll -#define g_pollable_input_stream_can_poll _frida_g_pollable_input_stream_can_poll -#define g_pollable_input_stream_create_source _frida_g_pollable_input_stream_create_source -#define g_pollable_input_stream_get_type _frida_g_pollable_input_stream_get_type -#define g_pollable_input_stream_is_readable _frida_g_pollable_input_stream_is_readable -#define g_pollable_input_stream_read_nonblocking _frida_g_pollable_input_stream_read_nonblocking -#define g_pollable_output_stream_can_poll _frida_g_pollable_output_stream_can_poll -#define g_pollable_output_stream_create_source _frida_g_pollable_output_stream_create_source -#define g_pollable_output_stream_get_type _frida_g_pollable_output_stream_get_type -#define g_pollable_output_stream_is_writable _frida_g_pollable_output_stream_is_writable -#define g_pollable_output_stream_write_nonblocking _frida_g_pollable_output_stream_write_nonblocking -#define g_pollable_output_stream_writev_nonblocking _frida_g_pollable_output_stream_writev_nonblocking -#define g_pollable_return_get_type _frida_g_pollable_return_get_type -#define g_pollable_source_new _frida_g_pollable_source_new -#define g_pollable_source_new_full _frida_g_pollable_source_new_full -#define g_pollable_stream_read _frida_g_pollable_stream_read -#define g_pollable_stream_write _frida_g_pollable_stream_write -#define g_pollable_stream_write_all _frida_g_pollable_stream_write_all -#define g_pollfd_get_type _frida_g_pollfd_get_type -#define g_portal_notification_backend_get_type _frida_g_portal_notification_backend_get_type -#define g_prefix_error _frida_g_prefix_error -#define g_print _frida_g_print -#define g_printerr _frida_g_printerr -#define g_printf _frida_g_printf -#define g_printf_string_upper_bound _frida_g_printf_string_upper_bound -#define g_private_get _frida_g_private_get -#define g_private_new _frida_g_private_new -#define g_private_replace _frida_g_private_replace -#define g_private_set _frida_g_private_set -#define g_private_set_alloc0 _frida_g_private_set_alloc0 -#define g_propagate_error _frida_g_propagate_error -#define g_propagate_prefixed_error _frida_g_propagate_prefixed_error -#define g_property_action_get_type _frida_g_property_action_get_type -#define g_property_action_new _frida_g_property_action_new -#define g_proxy_address_enumerator_get_type _frida_g_proxy_address_enumerator_get_type -#define g_proxy_address_get_destination_hostname _frida_g_proxy_address_get_destination_hostname -#define g_proxy_address_get_destination_port _frida_g_proxy_address_get_destination_port -#define g_proxy_address_get_destination_protocol _frida_g_proxy_address_get_destination_protocol -#define g_proxy_address_get_password _frida_g_proxy_address_get_password -#define g_proxy_address_get_protocol _frida_g_proxy_address_get_protocol -#define g_proxy_address_get_type _frida_g_proxy_address_get_type -#define g_proxy_address_get_uri _frida_g_proxy_address_get_uri -#define g_proxy_address_get_username _frida_g_proxy_address_get_username -#define g_proxy_address_new _frida_g_proxy_address_new -#define g_proxy_connect _frida_g_proxy_connect -#define g_proxy_connect_async _frida_g_proxy_connect_async -#define g_proxy_connect_finish _frida_g_proxy_connect_finish -#define g_proxy_get_default_for_protocol _frida_g_proxy_get_default_for_protocol -#define g_proxy_get_type _frida_g_proxy_get_type -#define g_proxy_resolver_get_default _frida_g_proxy_resolver_get_default -#define g_proxy_resolver_get_type _frida_g_proxy_resolver_get_type -#define g_proxy_resolver_is_supported _frida_g_proxy_resolver_is_supported -#define g_proxy_resolver_lookup _frida_g_proxy_resolver_lookup -#define g_proxy_resolver_lookup_async _frida_g_proxy_resolver_lookup_async -#define g_proxy_resolver_lookup_finish _frida_g_proxy_resolver_lookup_finish -#define g_proxy_resolver_portal_get_type _frida_g_proxy_resolver_portal_get_type -#define g_proxy_supports_hostname _frida_g_proxy_supports_hostname -#define g_ptr_array_add _frida_g_ptr_array_add -#define g_ptr_array_copy _frida_g_ptr_array_copy -#define g_ptr_array_extend _frida_g_ptr_array_extend -#define g_ptr_array_extend_and_steal _frida_g_ptr_array_extend_and_steal -#define g_ptr_array_find _frida_g_ptr_array_find -#define g_ptr_array_find_with_equal_func _frida_g_ptr_array_find_with_equal_func -#define g_ptr_array_foreach _frida_g_ptr_array_foreach -#define g_ptr_array_free _frida_g_ptr_array_free -#define g_ptr_array_get_type _frida_g_ptr_array_get_type -#define g_ptr_array_insert _frida_g_ptr_array_insert -#define g_ptr_array_new _frida_g_ptr_array_new -#define g_ptr_array_new_full _frida_g_ptr_array_new_full -#define g_ptr_array_new_with_free_func _frida_g_ptr_array_new_with_free_func -#define g_ptr_array_ref _frida_g_ptr_array_ref -#define g_ptr_array_remove _frida_g_ptr_array_remove -#define g_ptr_array_remove_fast _frida_g_ptr_array_remove_fast -#define g_ptr_array_remove_index _frida_g_ptr_array_remove_index -#define g_ptr_array_remove_index_fast _frida_g_ptr_array_remove_index_fast -#define g_ptr_array_remove_range _frida_g_ptr_array_remove_range -#define g_ptr_array_set_free_func _frida_g_ptr_array_set_free_func -#define g_ptr_array_set_size _frida_g_ptr_array_set_size -#define g_ptr_array_sized_new _frida_g_ptr_array_sized_new -#define g_ptr_array_sort _frida_g_ptr_array_sort -#define g_ptr_array_sort_with_data _frida_g_ptr_array_sort_with_data -#define g_ptr_array_steal _frida_g_ptr_array_steal -#define g_ptr_array_steal_index _frida_g_ptr_array_steal_index -#define g_ptr_array_steal_index_fast _frida_g_ptr_array_steal_index_fast -#define g_ptr_array_unref _frida_g_ptr_array_unref -#define g_qsort_with_data _frida_g_qsort_with_data -#define g_quark_from_static_string _frida_g_quark_from_static_string -#define g_quark_from_string _frida_g_quark_from_string -#define g_quark_init _frida_g_quark_init -#define g_quark_to_string _frida_g_quark_to_string -#define g_quark_try_string _frida_g_quark_try_string -#define g_queue_clear _frida_g_queue_clear -#define g_queue_clear_full _frida_g_queue_clear_full -#define g_queue_copy _frida_g_queue_copy -#define g_queue_delete_link _frida_g_queue_delete_link -#define g_queue_find _frida_g_queue_find -#define g_queue_find_custom _frida_g_queue_find_custom -#define g_queue_foreach _frida_g_queue_foreach -#define g_queue_free _frida_g_queue_free -#define g_queue_free_full _frida_g_queue_free_full -#define g_queue_get_length _frida_g_queue_get_length -#define g_queue_index _frida_g_queue_index -#define g_queue_init _frida_g_queue_init -#define g_queue_insert_after _frida_g_queue_insert_after -#define g_queue_insert_after_link _frida_g_queue_insert_after_link -#define g_queue_insert_before _frida_g_queue_insert_before -#define g_queue_insert_before_link _frida_g_queue_insert_before_link -#define g_queue_insert_sorted _frida_g_queue_insert_sorted -#define g_queue_is_empty _frida_g_queue_is_empty -#define g_queue_link_index _frida_g_queue_link_index -#define g_queue_new _frida_g_queue_new -#define g_queue_peek_head _frida_g_queue_peek_head -#define g_queue_peek_head_link _frida_g_queue_peek_head_link -#define g_queue_peek_nth _frida_g_queue_peek_nth -#define g_queue_peek_nth_link _frida_g_queue_peek_nth_link -#define g_queue_peek_tail _frida_g_queue_peek_tail -#define g_queue_peek_tail_link _frida_g_queue_peek_tail_link -#define g_queue_pop_head _frida_g_queue_pop_head -#define g_queue_pop_head_link _frida_g_queue_pop_head_link -#define g_queue_pop_nth _frida_g_queue_pop_nth -#define g_queue_pop_nth_link _frida_g_queue_pop_nth_link -#define g_queue_pop_tail _frida_g_queue_pop_tail -#define g_queue_pop_tail_link _frida_g_queue_pop_tail_link -#define g_queue_push_head _frida_g_queue_push_head -#define g_queue_push_head_link _frida_g_queue_push_head_link -#define g_queue_push_nth _frida_g_queue_push_nth -#define g_queue_push_nth_link _frida_g_queue_push_nth_link -#define g_queue_push_tail _frida_g_queue_push_tail -#define g_queue_push_tail_link _frida_g_queue_push_tail_link -#define g_queue_remove _frida_g_queue_remove -#define g_queue_remove_all _frida_g_queue_remove_all -#define g_queue_reverse _frida_g_queue_reverse -#define g_queue_sort _frida_g_queue_sort -#define g_queue_unlink _frida_g_queue_unlink -#define g_rand_copy _frida_g_rand_copy -#define g_rand_double _frida_g_rand_double -#define g_rand_double_range _frida_g_rand_double_range -#define g_rand_free _frida_g_rand_free -#define g_rand_int _frida_g_rand_int -#define g_rand_int_range _frida_g_rand_int_range -#define g_rand_new _frida_g_rand_new -#define g_rand_new_with_seed _frida_g_rand_new_with_seed -#define g_rand_new_with_seed_array _frida_g_rand_new_with_seed_array -#define g_rand_set_seed _frida_g_rand_set_seed -#define g_rand_set_seed_array _frida_g_rand_set_seed_array -#define g_random_double _frida_g_random_double -#define g_random_double_range _frida_g_random_double_range -#define g_random_int _frida_g_random_int -#define g_random_int_range _frida_g_random_int_range -#define g_random_set_seed _frida_g_random_set_seed -#define g_rc_box_acquire _frida_g_rc_box_acquire -#define g_rc_box_alloc _frida_g_rc_box_alloc -#define g_rc_box_alloc0 _frida_g_rc_box_alloc0 -#define g_rc_box_alloc_full _frida_g_rc_box_alloc_full -#define g_rc_box_dup _frida_g_rc_box_dup -#define g_rc_box_get_size _frida_g_rc_box_get_size -#define g_rc_box_release _frida_g_rc_box_release -#define g_rc_box_release_full _frida_g_rc_box_release_full -#define g_realloc _frida_g_realloc -#define g_realloc_n _frida_g_realloc_n -#define g_rec_mutex_clear _frida_g_rec_mutex_clear -#define g_rec_mutex_init _frida_g_rec_mutex_init -#define g_rec_mutex_lock _frida_g_rec_mutex_lock -#define g_rec_mutex_trylock _frida_g_rec_mutex_trylock -#define g_rec_mutex_unlock _frida_g_rec_mutex_unlock -#define g_ref_count_compare _frida_g_ref_count_compare -#define g_ref_count_dec _frida_g_ref_count_dec -#define g_ref_count_inc _frida_g_ref_count_inc -#define g_ref_count_init _frida_g_ref_count_init -#define g_ref_string_acquire _frida_g_ref_string_acquire -#define g_ref_string_length _frida_g_ref_string_length -#define g_ref_string_new _frida_g_ref_string_new -#define g_ref_string_new_intern _frida_g_ref_string_new_intern -#define g_ref_string_new_len _frida_g_ref_string_new_len -#define g_ref_string_release _frida_g_ref_string_release -#define g_regex_check_replacement _frida_g_regex_check_replacement -#define g_regex_error_quark _frida_g_regex_error_quark -#define g_regex_escape_nul _frida_g_regex_escape_nul -#define g_regex_escape_string _frida_g_regex_escape_string -#define g_regex_get_capture_count _frida_g_regex_get_capture_count -#define g_regex_get_compile_flags _frida_g_regex_get_compile_flags -#define g_regex_get_has_cr_or_lf _frida_g_regex_get_has_cr_or_lf -#define g_regex_get_match_flags _frida_g_regex_get_match_flags -#define g_regex_get_max_backref _frida_g_regex_get_max_backref -#define g_regex_get_max_lookbehind _frida_g_regex_get_max_lookbehind -#define g_regex_get_pattern _frida_g_regex_get_pattern -#define g_regex_get_string_number _frida_g_regex_get_string_number -#define g_regex_get_type _frida_g_regex_get_type -#define g_regex_match _frida_g_regex_match -#define g_regex_match_all _frida_g_regex_match_all -#define g_regex_match_all_full _frida_g_regex_match_all_full -#define g_regex_match_full _frida_g_regex_match_full -#define g_regex_match_simple _frida_g_regex_match_simple -#define g_regex_new _frida_g_regex_new -#define g_regex_ref _frida_g_regex_ref -#define g_regex_replace _frida_g_regex_replace -#define g_regex_replace_eval _frida_g_regex_replace_eval -#define g_regex_replace_literal _frida_g_regex_replace_literal -#define g_regex_split _frida_g_regex_split -#define g_regex_split_full _frida_g_regex_split_full -#define g_regex_split_simple _frida_g_regex_split_simple -#define g_regex_unref _frida_g_regex_unref -#define g_relation_count _frida_g_relation_count -#define g_relation_delete _frida_g_relation_delete -#define g_relation_destroy _frida_g_relation_destroy -#define g_relation_exists _frida_g_relation_exists -#define g_relation_index _frida_g_relation_index -#define g_relation_insert _frida_g_relation_insert -#define g_relation_new _frida_g_relation_new -#define g_relation_print _frida_g_relation_print -#define g_relation_select _frida_g_relation_select -#define g_reload_user_special_dirs_cache _frida_g_reload_user_special_dirs_cache -#define g_remote_action_group_activate_action_full _frida_g_remote_action_group_activate_action_full -#define g_remote_action_group_change_action_state_full _frida_g_remote_action_group_change_action_state_full -#define g_remote_action_group_get_type _frida_g_remote_action_group_get_type -#define g_remove _frida_g_remove -#define g_rename _frida_g_rename -#define g_resolver_error_get_type _frida_g_resolver_error_get_type -#define g_resolver_error_quark _frida_g_resolver_error_quark -#define g_resolver_free_addresses _frida_g_resolver_free_addresses -#define g_resolver_free_targets _frida_g_resolver_free_targets -#define g_resolver_get_default _frida_g_resolver_get_default -#define g_resolver_get_serial _frida_g_resolver_get_serial -#define g_resolver_get_type _frida_g_resolver_get_type -#define g_resolver_lookup_by_address _frida_g_resolver_lookup_by_address -#define g_resolver_lookup_by_address_async _frida_g_resolver_lookup_by_address_async -#define g_resolver_lookup_by_address_finish _frida_g_resolver_lookup_by_address_finish -#define g_resolver_lookup_by_name _frida_g_resolver_lookup_by_name -#define g_resolver_lookup_by_name_async _frida_g_resolver_lookup_by_name_async -#define g_resolver_lookup_by_name_finish _frida_g_resolver_lookup_by_name_finish -#define g_resolver_lookup_by_name_with_flags _frida_g_resolver_lookup_by_name_with_flags -#define g_resolver_lookup_by_name_with_flags_async _frida_g_resolver_lookup_by_name_with_flags_async -#define g_resolver_lookup_by_name_with_flags_finish _frida_g_resolver_lookup_by_name_with_flags_finish -#define g_resolver_lookup_records _frida_g_resolver_lookup_records -#define g_resolver_lookup_records_async _frida_g_resolver_lookup_records_async -#define g_resolver_lookup_records_finish _frida_g_resolver_lookup_records_finish -#define g_resolver_lookup_service _frida_g_resolver_lookup_service -#define g_resolver_lookup_service_async _frida_g_resolver_lookup_service_async -#define g_resolver_lookup_service_finish _frida_g_resolver_lookup_service_finish -#define g_resolver_name_lookup_flags_get_type _frida_g_resolver_name_lookup_flags_get_type -#define g_resolver_record_type_get_type _frida_g_resolver_record_type_get_type -#define g_resolver_set_default _frida_g_resolver_set_default -#define g_resource_enumerate_children _frida_g_resource_enumerate_children -#define g_resource_error_get_type _frida_g_resource_error_get_type -#define g_resource_error_quark _frida_g_resource_error_quark -#define g_resource_file_monitor_get_type _frida_g_resource_file_monitor_get_type -#define g_resource_flags_get_type _frida_g_resource_flags_get_type -#define g_resource_get_info _frida_g_resource_get_info -#define g_resource_get_type _frida_g_resource_get_type -#define g_resource_load _frida_g_resource_load -#define g_resource_lookup_data _frida_g_resource_lookup_data -#define g_resource_lookup_flags_get_type _frida_g_resource_lookup_flags_get_type -#define g_resource_new_from_data _frida_g_resource_new_from_data -#define g_resource_open_stream _frida_g_resource_open_stream -#define g_resource_ref _frida_g_resource_ref -#define g_resource_unref _frida_g_resource_unref -#define g_resources_enumerate_children _frida_g_resources_enumerate_children -#define g_resources_get_info _frida_g_resources_get_info -#define g_resources_lookup_data _frida_g_resources_lookup_data -#define g_resources_open_stream _frida_g_resources_open_stream -#define g_resources_register _frida_g_resources_register -#define g_resources_unregister _frida_g_resources_unregister -#define g_return_if_fail_warning _frida_g_return_if_fail_warning -#define g_rmdir _frida_g_rmdir -#define g_rw_lock_clear _frida_g_rw_lock_clear -#define g_rw_lock_init _frida_g_rw_lock_init -#define g_rw_lock_reader_lock _frida_g_rw_lock_reader_lock -#define g_rw_lock_reader_trylock _frida_g_rw_lock_reader_trylock -#define g_rw_lock_reader_unlock _frida_g_rw_lock_reader_unlock -#define g_rw_lock_writer_lock _frida_g_rw_lock_writer_lock -#define g_rw_lock_writer_trylock _frida_g_rw_lock_writer_trylock -#define g_rw_lock_writer_unlock _frida_g_rw_lock_writer_unlock -#define g_scanner_cur_line _frida_g_scanner_cur_line -#define g_scanner_cur_position _frida_g_scanner_cur_position -#define g_scanner_cur_token _frida_g_scanner_cur_token -#define g_scanner_cur_value _frida_g_scanner_cur_value -#define g_scanner_destroy _frida_g_scanner_destroy -#define g_scanner_eof _frida_g_scanner_eof -#define g_scanner_error _frida_g_scanner_error -#define g_scanner_get_next_token _frida_g_scanner_get_next_token -#define g_scanner_input_file _frida_g_scanner_input_file -#define g_scanner_input_text _frida_g_scanner_input_text -#define g_scanner_lookup_symbol _frida_g_scanner_lookup_symbol -#define g_scanner_new _frida_g_scanner_new -#define g_scanner_peek_next_token _frida_g_scanner_peek_next_token -#define g_scanner_scope_add_symbol _frida_g_scanner_scope_add_symbol -#define g_scanner_scope_foreach_symbol _frida_g_scanner_scope_foreach_symbol -#define g_scanner_scope_lookup_symbol _frida_g_scanner_scope_lookup_symbol -#define g_scanner_scope_remove_symbol _frida_g_scanner_scope_remove_symbol -#define g_scanner_set_scope _frida_g_scanner_set_scope -#define g_scanner_sync_file_offset _frida_g_scanner_sync_file_offset -#define g_scanner_unexp_token _frida_g_scanner_unexp_token -#define g_scanner_warn _frida_g_scanner_warn -#define g_seekable_can_seek _frida_g_seekable_can_seek -#define g_seekable_can_truncate _frida_g_seekable_can_truncate -#define g_seekable_get_type _frida_g_seekable_get_type -#define g_seekable_seek _frida_g_seekable_seek -#define g_seekable_tell _frida_g_seekable_tell -#define g_seekable_truncate _frida_g_seekable_truncate -#define g_sequence_append _frida_g_sequence_append -#define g_sequence_foreach _frida_g_sequence_foreach -#define g_sequence_foreach_range _frida_g_sequence_foreach_range -#define g_sequence_free _frida_g_sequence_free -#define g_sequence_get _frida_g_sequence_get -#define g_sequence_get_begin_iter _frida_g_sequence_get_begin_iter -#define g_sequence_get_end_iter _frida_g_sequence_get_end_iter -#define g_sequence_get_iter_at_pos _frida_g_sequence_get_iter_at_pos -#define g_sequence_get_length _frida_g_sequence_get_length -#define g_sequence_insert_before _frida_g_sequence_insert_before -#define g_sequence_insert_sorted _frida_g_sequence_insert_sorted -#define g_sequence_insert_sorted_iter _frida_g_sequence_insert_sorted_iter -#define g_sequence_is_empty _frida_g_sequence_is_empty -#define g_sequence_iter_compare _frida_g_sequence_iter_compare -#define g_sequence_iter_get_position _frida_g_sequence_iter_get_position -#define g_sequence_iter_get_sequence _frida_g_sequence_iter_get_sequence -#define g_sequence_iter_is_begin _frida_g_sequence_iter_is_begin -#define g_sequence_iter_is_end _frida_g_sequence_iter_is_end -#define g_sequence_iter_move _frida_g_sequence_iter_move -#define g_sequence_iter_next _frida_g_sequence_iter_next -#define g_sequence_iter_prev _frida_g_sequence_iter_prev -#define g_sequence_lookup _frida_g_sequence_lookup -#define g_sequence_lookup_iter _frida_g_sequence_lookup_iter -#define g_sequence_move _frida_g_sequence_move -#define g_sequence_move_range _frida_g_sequence_move_range -#define g_sequence_new _frida_g_sequence_new -#define g_sequence_prepend _frida_g_sequence_prepend -#define g_sequence_range_get_midpoint _frida_g_sequence_range_get_midpoint -#define g_sequence_remove _frida_g_sequence_remove -#define g_sequence_remove_range _frida_g_sequence_remove_range -#define g_sequence_search _frida_g_sequence_search -#define g_sequence_search_iter _frida_g_sequence_search_iter -#define g_sequence_set _frida_g_sequence_set -#define g_sequence_sort _frida_g_sequence_sort -#define g_sequence_sort_changed _frida_g_sequence_sort_changed -#define g_sequence_sort_changed_iter _frida_g_sequence_sort_changed_iter -#define g_sequence_sort_iter _frida_g_sequence_sort_iter -#define g_sequence_swap _frida_g_sequence_swap -#define g_set_application_name _frida_g_set_application_name -#define g_set_error _frida_g_set_error -#define g_set_error_literal _frida_g_set_error_literal -#define g_set_prgname _frida_g_set_prgname -#define g_set_print_handler _frida_g_set_print_handler -#define g_set_printerr_handler _frida_g_set_printerr_handler -#define g_set_user_dirs _frida_g_set_user_dirs -#define g_setenv _frida_g_setenv -#define g_settings_apply _frida_g_settings_apply -#define g_settings_backend_changed _frida_g_settings_backend_changed -#define g_settings_backend_changed_tree _frida_g_settings_backend_changed_tree -#define g_settings_backend_create_tree _frida_g_settings_backend_create_tree -#define g_settings_backend_flatten_tree _frida_g_settings_backend_flatten_tree -#define g_settings_backend_get_default _frida_g_settings_backend_get_default -#define g_settings_backend_get_permission _frida_g_settings_backend_get_permission -#define g_settings_backend_get_type _frida_g_settings_backend_get_type -#define g_settings_backend_get_writable _frida_g_settings_backend_get_writable -#define g_settings_backend_keys_changed _frida_g_settings_backend_keys_changed -#define g_settings_backend_path_changed _frida_g_settings_backend_path_changed -#define g_settings_backend_path_writable_changed _frida_g_settings_backend_path_writable_changed -#define g_settings_backend_read _frida_g_settings_backend_read -#define g_settings_backend_read_user_value _frida_g_settings_backend_read_user_value -#define g_settings_backend_reset _frida_g_settings_backend_reset -#define g_settings_backend_subscribe _frida_g_settings_backend_subscribe -#define g_settings_backend_sync_default _frida_g_settings_backend_sync_default -#define g_settings_backend_unsubscribe _frida_g_settings_backend_unsubscribe -#define g_settings_backend_unwatch _frida_g_settings_backend_unwatch -#define g_settings_backend_watch _frida_g_settings_backend_watch -#define g_settings_backend_writable_changed _frida_g_settings_backend_writable_changed -#define g_settings_backend_write _frida_g_settings_backend_write -#define g_settings_backend_write_tree _frida_g_settings_backend_write_tree -#define g_settings_bind _frida_g_settings_bind -#define g_settings_bind_flags_get_type _frida_g_settings_bind_flags_get_type -#define g_settings_bind_with_mapping _frida_g_settings_bind_with_mapping -#define g_settings_bind_writable _frida_g_settings_bind_writable -#define g_settings_create_action _frida_g_settings_create_action -#define g_settings_delay _frida_g_settings_delay -#define g_settings_get _frida_g_settings_get -#define g_settings_get_boolean _frida_g_settings_get_boolean -#define g_settings_get_child _frida_g_settings_get_child -#define g_settings_get_default_value _frida_g_settings_get_default_value -#define g_settings_get_double _frida_g_settings_get_double -#define g_settings_get_enum _frida_g_settings_get_enum -#define g_settings_get_flags _frida_g_settings_get_flags -#define g_settings_get_has_unapplied _frida_g_settings_get_has_unapplied -#define g_settings_get_int _frida_g_settings_get_int -#define g_settings_get_int64 _frida_g_settings_get_int64 -#define g_settings_get_mapped _frida_g_settings_get_mapped -#define g_settings_get_mapping _frida_g_settings_get_mapping -#define g_settings_get_range _frida_g_settings_get_range -#define g_settings_get_string _frida_g_settings_get_string -#define g_settings_get_strv _frida_g_settings_get_strv -#define g_settings_get_type _frida_g_settings_get_type -#define g_settings_get_uint _frida_g_settings_get_uint -#define g_settings_get_uint64 _frida_g_settings_get_uint64 -#define g_settings_get_user_value _frida_g_settings_get_user_value -#define g_settings_get_value _frida_g_settings_get_value -#define g_settings_is_writable _frida_g_settings_is_writable -#define g_settings_list_children _frida_g_settings_list_children -#define g_settings_list_keys _frida_g_settings_list_keys -#define g_settings_list_relocatable_schemas _frida_g_settings_list_relocatable_schemas -#define g_settings_list_schemas _frida_g_settings_list_schemas -#define g_settings_mapping_is_compatible _frida_g_settings_mapping_is_compatible -#define g_settings_new _frida_g_settings_new -#define g_settings_new_full _frida_g_settings_new_full -#define g_settings_new_with_backend _frida_g_settings_new_with_backend -#define g_settings_new_with_backend_and_path _frida_g_settings_new_with_backend_and_path -#define g_settings_new_with_path _frida_g_settings_new_with_path -#define g_settings_range_check _frida_g_settings_range_check -#define g_settings_reset _frida_g_settings_reset -#define g_settings_revert _frida_g_settings_revert -#define g_settings_schema_get_gettext_domain _frida_g_settings_schema_get_gettext_domain -#define g_settings_schema_get_id _frida_g_settings_schema_get_id -#define g_settings_schema_get_key _frida_g_settings_schema_get_key -#define g_settings_schema_get_path _frida_g_settings_schema_get_path -#define g_settings_schema_get_string _frida_g_settings_schema_get_string -#define g_settings_schema_get_type _frida_g_settings_schema_get_type -#define g_settings_schema_get_value _frida_g_settings_schema_get_value -#define g_settings_schema_has_key _frida_g_settings_schema_has_key -#define g_settings_schema_key_clear _frida_g_settings_schema_key_clear -#define g_settings_schema_key_from_enum _frida_g_settings_schema_key_from_enum -#define g_settings_schema_key_from_flags _frida_g_settings_schema_key_from_flags -#define g_settings_schema_key_get_default_value _frida_g_settings_schema_key_get_default_value -#define g_settings_schema_key_get_description _frida_g_settings_schema_key_get_description -#define g_settings_schema_key_get_name _frida_g_settings_schema_key_get_name -#define g_settings_schema_key_get_per_desktop_default _frida_g_settings_schema_key_get_per_desktop_default -#define g_settings_schema_key_get_range _frida_g_settings_schema_key_get_range -#define g_settings_schema_key_get_summary _frida_g_settings_schema_key_get_summary -#define g_settings_schema_key_get_translated_default _frida_g_settings_schema_key_get_translated_default -#define g_settings_schema_key_get_type _frida_g_settings_schema_key_get_type -#define g_settings_schema_key_get_value_type _frida_g_settings_schema_key_get_value_type -#define g_settings_schema_key_init _frida_g_settings_schema_key_init -#define g_settings_schema_key_range_check _frida_g_settings_schema_key_range_check -#define g_settings_schema_key_range_fixup _frida_g_settings_schema_key_range_fixup -#define g_settings_schema_key_ref _frida_g_settings_schema_key_ref -#define g_settings_schema_key_to_enum _frida_g_settings_schema_key_to_enum -#define g_settings_schema_key_to_flags _frida_g_settings_schema_key_to_flags -#define g_settings_schema_key_type_check _frida_g_settings_schema_key_type_check -#define g_settings_schema_key_unref _frida_g_settings_schema_key_unref -#define g_settings_schema_list _frida_g_settings_schema_list -#define g_settings_schema_list_children _frida_g_settings_schema_list_children -#define g_settings_schema_list_keys _frida_g_settings_schema_list_keys -#define g_settings_schema_ref _frida_g_settings_schema_ref -#define g_settings_schema_source_get_default _frida_g_settings_schema_source_get_default -#define g_settings_schema_source_get_type _frida_g_settings_schema_source_get_type -#define g_settings_schema_source_list_schemas _frida_g_settings_schema_source_list_schemas -#define g_settings_schema_source_lookup _frida_g_settings_schema_source_lookup -#define g_settings_schema_source_new_from_directory _frida_g_settings_schema_source_new_from_directory -#define g_settings_schema_source_ref _frida_g_settings_schema_source_ref -#define g_settings_schema_source_unref _frida_g_settings_schema_source_unref -#define g_settings_schema_unref _frida_g_settings_schema_unref -#define g_settings_set _frida_g_settings_set -#define g_settings_set_boolean _frida_g_settings_set_boolean -#define g_settings_set_double _frida_g_settings_set_double -#define g_settings_set_enum _frida_g_settings_set_enum -#define g_settings_set_flags _frida_g_settings_set_flags -#define g_settings_set_int _frida_g_settings_set_int -#define g_settings_set_int64 _frida_g_settings_set_int64 -#define g_settings_set_mapping _frida_g_settings_set_mapping -#define g_settings_set_string _frida_g_settings_set_string -#define g_settings_set_strv _frida_g_settings_set_strv -#define g_settings_set_uint _frida_g_settings_set_uint -#define g_settings_set_uint64 _frida_g_settings_set_uint64 -#define g_settings_set_value _frida_g_settings_set_value -#define g_settings_sync _frida_g_settings_sync -#define g_settings_unbind _frida_g_settings_unbind -#define g_shell_error_quark _frida_g_shell_error_quark -#define g_shell_parse_argv _frida_g_shell_parse_argv -#define g_shell_quote _frida_g_shell_quote -#define g_shell_unquote _frida_g_shell_unquote -#define g_signal_accumulator_first_wins _frida_g_signal_accumulator_first_wins -#define g_signal_accumulator_true_handled _frida_g_signal_accumulator_true_handled -#define g_signal_add_emission_hook _frida_g_signal_add_emission_hook -#define g_signal_chain_from_overridden _frida_g_signal_chain_from_overridden -#define g_signal_chain_from_overridden_handler _frida_g_signal_chain_from_overridden_handler -#define g_signal_connect_closure _frida_g_signal_connect_closure -#define g_signal_connect_closure_by_id _frida_g_signal_connect_closure_by_id -#define g_signal_connect_data _frida_g_signal_connect_data -#define g_signal_connect_object _frida_g_signal_connect_object -#define g_signal_emit _frida_g_signal_emit -#define g_signal_emit_by_name _frida_g_signal_emit_by_name -#define g_signal_emit_valist _frida_g_signal_emit_valist -#define g_signal_emitv _frida_g_signal_emitv -#define g_signal_get_invocation_hint _frida_g_signal_get_invocation_hint -#define g_signal_handler_block _frida_g_signal_handler_block -#define g_signal_handler_disconnect _frida_g_signal_handler_disconnect -#define g_signal_handler_find _frida_g_signal_handler_find -#define g_signal_handler_is_connected _frida_g_signal_handler_is_connected -#define g_signal_handler_unblock _frida_g_signal_handler_unblock -#define g_signal_handlers_block_matched _frida_g_signal_handlers_block_matched -#define g_signal_handlers_destroy _frida_g_signal_handlers_destroy -#define g_signal_handlers_disconnect_matched _frida_g_signal_handlers_disconnect_matched -#define g_signal_handlers_unblock_matched _frida_g_signal_handlers_unblock_matched -#define g_signal_has_handler_pending _frida_g_signal_has_handler_pending -#define g_signal_is_valid_name _frida_g_signal_is_valid_name -#define g_signal_list_ids _frida_g_signal_list_ids -#define g_signal_lookup _frida_g_signal_lookup -#define g_signal_name _frida_g_signal_name -#define g_signal_new _frida_g_signal_new -#define g_signal_new_class_handler _frida_g_signal_new_class_handler -#define g_signal_new_valist _frida_g_signal_new_valist -#define g_signal_newv _frida_g_signal_newv -#define g_signal_override_class_closure _frida_g_signal_override_class_closure -#define g_signal_override_class_handler _frida_g_signal_override_class_handler -#define g_signal_parse_name _frida_g_signal_parse_name -#define g_signal_query _frida_g_signal_query -#define g_signal_remove_emission_hook _frida_g_signal_remove_emission_hook -#define g_signal_set_va_marshaller _frida_g_signal_set_va_marshaller -#define g_signal_stop_emission _frida_g_signal_stop_emission -#define g_signal_stop_emission_by_name _frida_g_signal_stop_emission_by_name -#define g_signal_type_cclosure_new _frida_g_signal_type_cclosure_new -#define g_simple_action_get_type _frida_g_simple_action_get_type -#define g_simple_action_group_add_entries _frida_g_simple_action_group_add_entries -#define g_simple_action_group_get_type _frida_g_simple_action_group_get_type -#define g_simple_action_group_insert _frida_g_simple_action_group_insert -#define g_simple_action_group_lookup _frida_g_simple_action_group_lookup -#define g_simple_action_group_new _frida_g_simple_action_group_new -#define g_simple_action_group_remove _frida_g_simple_action_group_remove -#define g_simple_action_new _frida_g_simple_action_new -#define g_simple_action_new_stateful _frida_g_simple_action_new_stateful -#define g_simple_action_set_enabled _frida_g_simple_action_set_enabled -#define g_simple_action_set_state _frida_g_simple_action_set_state -#define g_simple_action_set_state_hint _frida_g_simple_action_set_state_hint -#define g_simple_async_report_error_in_idle _frida_g_simple_async_report_error_in_idle -#define g_simple_async_report_gerror_in_idle _frida_g_simple_async_report_gerror_in_idle -#define g_simple_async_report_take_gerror_in_idle _frida_g_simple_async_report_take_gerror_in_idle -#define g_simple_async_result_complete _frida_g_simple_async_result_complete -#define g_simple_async_result_complete_in_idle _frida_g_simple_async_result_complete_in_idle -#define g_simple_async_result_get_op_res_gboolean _frida_g_simple_async_result_get_op_res_gboolean -#define g_simple_async_result_get_op_res_gpointer _frida_g_simple_async_result_get_op_res_gpointer -#define g_simple_async_result_get_op_res_gssize _frida_g_simple_async_result_get_op_res_gssize -#define g_simple_async_result_get_source_tag _frida_g_simple_async_result_get_source_tag -#define g_simple_async_result_get_type _frida_g_simple_async_result_get_type -#define g_simple_async_result_is_valid _frida_g_simple_async_result_is_valid -#define g_simple_async_result_new _frida_g_simple_async_result_new -#define g_simple_async_result_new_error _frida_g_simple_async_result_new_error -#define g_simple_async_result_new_from_error _frida_g_simple_async_result_new_from_error -#define g_simple_async_result_new_take_error _frida_g_simple_async_result_new_take_error -#define g_simple_async_result_propagate_error _frida_g_simple_async_result_propagate_error -#define g_simple_async_result_run_in_thread _frida_g_simple_async_result_run_in_thread -#define g_simple_async_result_set_check_cancellable _frida_g_simple_async_result_set_check_cancellable -#define g_simple_async_result_set_error _frida_g_simple_async_result_set_error -#define g_simple_async_result_set_error_va _frida_g_simple_async_result_set_error_va -#define g_simple_async_result_set_from_error _frida_g_simple_async_result_set_from_error -#define g_simple_async_result_set_handle_cancellation _frida_g_simple_async_result_set_handle_cancellation -#define g_simple_async_result_set_op_res_gboolean _frida_g_simple_async_result_set_op_res_gboolean -#define g_simple_async_result_set_op_res_gpointer _frida_g_simple_async_result_set_op_res_gpointer -#define g_simple_async_result_set_op_res_gssize _frida_g_simple_async_result_set_op_res_gssize -#define g_simple_async_result_take_error _frida_g_simple_async_result_take_error -#define g_simple_io_stream_get_type _frida_g_simple_io_stream_get_type -#define g_simple_io_stream_new _frida_g_simple_io_stream_new -#define g_simple_permission_get_type _frida_g_simple_permission_get_type -#define g_simple_permission_new _frida_g_simple_permission_new -#define g_simple_proxy_resolver_get_type _frida_g_simple_proxy_resolver_get_type -#define g_simple_proxy_resolver_new _frida_g_simple_proxy_resolver_new -#define g_simple_proxy_resolver_set_default_proxy _frida_g_simple_proxy_resolver_set_default_proxy -#define g_simple_proxy_resolver_set_ignore_hosts _frida_g_simple_proxy_resolver_set_ignore_hosts -#define g_simple_proxy_resolver_set_uri_proxy _frida_g_simple_proxy_resolver_set_uri_proxy -#define g_slice_alloc _frida_g_slice_alloc -#define g_slice_alloc0 _frida_g_slice_alloc0 -#define g_slice_copy _frida_g_slice_copy -#define g_slice_free1 _frida_g_slice_free1 -#define g_slice_free_chain_with_offset _frida_g_slice_free_chain_with_offset -#define g_slice_get_config _frida_g_slice_get_config -#define g_slice_get_config_state _frida_g_slice_get_config_state -#define g_slice_set_config _frida_g_slice_set_config -#define g_slist_alloc _frida_g_slist_alloc -#define g_slist_append _frida_g_slist_append -#define g_slist_concat _frida_g_slist_concat -#define g_slist_copy _frida_g_slist_copy -#define g_slist_copy_deep _frida_g_slist_copy_deep -#define g_slist_delete_link _frida_g_slist_delete_link -#define g_slist_find _frida_g_slist_find -#define g_slist_find_custom _frida_g_slist_find_custom -#define g_slist_foreach _frida_g_slist_foreach -#define g_slist_free _frida_g_slist_free -#define g_slist_free_1 _frida_g_slist_free_1 -#define g_slist_free_full _frida_g_slist_free_full -#define g_slist_index _frida_g_slist_index -#define g_slist_insert _frida_g_slist_insert -#define g_slist_insert_before _frida_g_slist_insert_before -#define g_slist_insert_sorted _frida_g_slist_insert_sorted -#define g_slist_insert_sorted_with_data _frida_g_slist_insert_sorted_with_data -#define g_slist_last _frida_g_slist_last -#define g_slist_length _frida_g_slist_length -#define g_slist_nth _frida_g_slist_nth -#define g_slist_nth_data _frida_g_slist_nth_data -#define g_slist_pop_allocator _frida_g_slist_pop_allocator -#define g_slist_position _frida_g_slist_position -#define g_slist_prepend _frida_g_slist_prepend -#define g_slist_push_allocator _frida_g_slist_push_allocator -#define g_slist_remove _frida_g_slist_remove -#define g_slist_remove_all _frida_g_slist_remove_all -#define g_slist_remove_link _frida_g_slist_remove_link -#define g_slist_reverse _frida_g_slist_reverse -#define g_slist_sort _frida_g_slist_sort -#define g_slist_sort_with_data _frida_g_slist_sort_with_data -#define g_snprintf _frida_g_snprintf -#define g_socket _frida_g_socket -#define g_socket_accept _frida_g_socket_accept -#define g_socket_address_enumerator_get_type _frida_g_socket_address_enumerator_get_type -#define g_socket_address_enumerator_next _frida_g_socket_address_enumerator_next -#define g_socket_address_enumerator_next_async _frida_g_socket_address_enumerator_next_async -#define g_socket_address_enumerator_next_finish _frida_g_socket_address_enumerator_next_finish -#define g_socket_address_get_family _frida_g_socket_address_get_family -#define g_socket_address_get_native_size _frida_g_socket_address_get_native_size -#define g_socket_address_get_type _frida_g_socket_address_get_type -#define g_socket_address_new_from_native _frida_g_socket_address_new_from_native -#define g_socket_address_to_native _frida_g_socket_address_to_native -#define g_socket_bind _frida_g_socket_bind -#define g_socket_check_connect_result _frida_g_socket_check_connect_result -#define g_socket_client_add_application_proxy _frida_g_socket_client_add_application_proxy -#define g_socket_client_connect _frida_g_socket_client_connect -#define g_socket_client_connect_async _frida_g_socket_client_connect_async -#define g_socket_client_connect_finish _frida_g_socket_client_connect_finish -#define g_socket_client_connect_to_host _frida_g_socket_client_connect_to_host -#define g_socket_client_connect_to_host_async _frida_g_socket_client_connect_to_host_async -#define g_socket_client_connect_to_host_finish _frida_g_socket_client_connect_to_host_finish -#define g_socket_client_connect_to_service _frida_g_socket_client_connect_to_service -#define g_socket_client_connect_to_service_async _frida_g_socket_client_connect_to_service_async -#define g_socket_client_connect_to_service_finish _frida_g_socket_client_connect_to_service_finish -#define g_socket_client_connect_to_uri _frida_g_socket_client_connect_to_uri -#define g_socket_client_connect_to_uri_async _frida_g_socket_client_connect_to_uri_async -#define g_socket_client_connect_to_uri_finish _frida_g_socket_client_connect_to_uri_finish -#define g_socket_client_event_get_type _frida_g_socket_client_event_get_type -#define g_socket_client_get_enable_proxy _frida_g_socket_client_get_enable_proxy -#define g_socket_client_get_family _frida_g_socket_client_get_family -#define g_socket_client_get_local_address _frida_g_socket_client_get_local_address -#define g_socket_client_get_protocol _frida_g_socket_client_get_protocol -#define g_socket_client_get_proxy_resolver _frida_g_socket_client_get_proxy_resolver -#define g_socket_client_get_socket_type _frida_g_socket_client_get_socket_type -#define g_socket_client_get_timeout _frida_g_socket_client_get_timeout -#define g_socket_client_get_tls _frida_g_socket_client_get_tls -#define g_socket_client_get_tls_validation_flags _frida_g_socket_client_get_tls_validation_flags -#define g_socket_client_get_type _frida_g_socket_client_get_type -#define g_socket_client_new _frida_g_socket_client_new -#define g_socket_client_set_enable_proxy _frida_g_socket_client_set_enable_proxy -#define g_socket_client_set_family _frida_g_socket_client_set_family -#define g_socket_client_set_local_address _frida_g_socket_client_set_local_address -#define g_socket_client_set_protocol _frida_g_socket_client_set_protocol -#define g_socket_client_set_proxy_resolver _frida_g_socket_client_set_proxy_resolver -#define g_socket_client_set_socket_type _frida_g_socket_client_set_socket_type -#define g_socket_client_set_timeout _frida_g_socket_client_set_timeout -#define g_socket_client_set_tls _frida_g_socket_client_set_tls -#define g_socket_client_set_tls_validation_flags _frida_g_socket_client_set_tls_validation_flags -#define g_socket_close _frida_g_socket_close -#define g_socket_condition_check _frida_g_socket_condition_check -#define g_socket_condition_timed_wait _frida_g_socket_condition_timed_wait -#define g_socket_condition_wait _frida_g_socket_condition_wait -#define g_socket_connect _frida_g_socket_connect -#define g_socket_connectable_enumerate _frida_g_socket_connectable_enumerate -#define g_socket_connectable_get_type _frida_g_socket_connectable_get_type -#define g_socket_connectable_proxy_enumerate _frida_g_socket_connectable_proxy_enumerate -#define g_socket_connectable_to_string _frida_g_socket_connectable_to_string -#define g_socket_connection_connect _frida_g_socket_connection_connect -#define g_socket_connection_connect_async _frida_g_socket_connection_connect_async -#define g_socket_connection_connect_finish _frida_g_socket_connection_connect_finish -#define g_socket_connection_factory_create_connection _frida_g_socket_connection_factory_create_connection -#define g_socket_connection_factory_lookup_type _frida_g_socket_connection_factory_lookup_type -#define g_socket_connection_factory_register_type _frida_g_socket_connection_factory_register_type -#define g_socket_connection_get_local_address _frida_g_socket_connection_get_local_address -#define g_socket_connection_get_remote_address _frida_g_socket_connection_get_remote_address -#define g_socket_connection_get_socket _frida_g_socket_connection_get_socket -#define g_socket_connection_get_type _frida_g_socket_connection_get_type -#define g_socket_connection_is_connected _frida_g_socket_connection_is_connected -#define g_socket_connection_set_cached_remote_address _frida_g_socket_connection_set_cached_remote_address -#define g_socket_control_message_deserialize _frida_g_socket_control_message_deserialize -#define g_socket_control_message_get_level _frida_g_socket_control_message_get_level -#define g_socket_control_message_get_msg_type _frida_g_socket_control_message_get_msg_type -#define g_socket_control_message_get_size _frida_g_socket_control_message_get_size -#define g_socket_control_message_get_type _frida_g_socket_control_message_get_type -#define g_socket_control_message_serialize _frida_g_socket_control_message_serialize -#define g_socket_create_source _frida_g_socket_create_source -#define g_socket_family_get_type _frida_g_socket_family_get_type -#define g_socket_get_available_bytes _frida_g_socket_get_available_bytes -#define g_socket_get_blocking _frida_g_socket_get_blocking -#define g_socket_get_broadcast _frida_g_socket_get_broadcast -#define g_socket_get_credentials _frida_g_socket_get_credentials -#define g_socket_get_family _frida_g_socket_get_family -#define g_socket_get_fd _frida_g_socket_get_fd -#define g_socket_get_keepalive _frida_g_socket_get_keepalive -#define g_socket_get_listen_backlog _frida_g_socket_get_listen_backlog -#define g_socket_get_local_address _frida_g_socket_get_local_address -#define g_socket_get_multicast_loopback _frida_g_socket_get_multicast_loopback -#define g_socket_get_multicast_ttl _frida_g_socket_get_multicast_ttl -#define g_socket_get_option _frida_g_socket_get_option -#define g_socket_get_protocol _frida_g_socket_get_protocol -#define g_socket_get_remote_address _frida_g_socket_get_remote_address -#define g_socket_get_socket_type _frida_g_socket_get_socket_type -#define g_socket_get_timeout _frida_g_socket_get_timeout -#define g_socket_get_ttl _frida_g_socket_get_ttl -#define g_socket_get_type _frida_g_socket_get_type -#define g_socket_is_closed _frida_g_socket_is_closed -#define g_socket_is_connected _frida_g_socket_is_connected -#define g_socket_join_multicast_group _frida_g_socket_join_multicast_group -#define g_socket_join_multicast_group_ssm _frida_g_socket_join_multicast_group_ssm -#define g_socket_leave_multicast_group _frida_g_socket_leave_multicast_group -#define g_socket_leave_multicast_group_ssm _frida_g_socket_leave_multicast_group_ssm -#define g_socket_listen _frida_g_socket_listen -#define g_socket_listener_accept _frida_g_socket_listener_accept -#define g_socket_listener_accept_async _frida_g_socket_listener_accept_async -#define g_socket_listener_accept_finish _frida_g_socket_listener_accept_finish -#define g_socket_listener_accept_socket _frida_g_socket_listener_accept_socket -#define g_socket_listener_accept_socket_async _frida_g_socket_listener_accept_socket_async -#define g_socket_listener_accept_socket_finish _frida_g_socket_listener_accept_socket_finish -#define g_socket_listener_add_address _frida_g_socket_listener_add_address -#define g_socket_listener_add_any_inet_port _frida_g_socket_listener_add_any_inet_port -#define g_socket_listener_add_inet_port _frida_g_socket_listener_add_inet_port -#define g_socket_listener_add_socket _frida_g_socket_listener_add_socket -#define g_socket_listener_close _frida_g_socket_listener_close -#define g_socket_listener_event_get_type _frida_g_socket_listener_event_get_type -#define g_socket_listener_get_type _frida_g_socket_listener_get_type -#define g_socket_listener_new _frida_g_socket_listener_new -#define g_socket_listener_set_backlog _frida_g_socket_listener_set_backlog -#define g_socket_msg_flags_get_type _frida_g_socket_msg_flags_get_type -#define g_socket_new _frida_g_socket_new -#define g_socket_new_from_fd _frida_g_socket_new_from_fd -#define g_socket_protocol_get_type _frida_g_socket_protocol_get_type -#define g_socket_receive _frida_g_socket_receive -#define g_socket_receive_from _frida_g_socket_receive_from -#define g_socket_receive_message _frida_g_socket_receive_message -#define g_socket_receive_messages _frida_g_socket_receive_messages -#define g_socket_receive_with_blocking _frida_g_socket_receive_with_blocking -#define g_socket_send _frida_g_socket_send -#define g_socket_send_message _frida_g_socket_send_message -#define g_socket_send_message_with_timeout _frida_g_socket_send_message_with_timeout -#define g_socket_send_messages _frida_g_socket_send_messages -#define g_socket_send_to _frida_g_socket_send_to -#define g_socket_send_with_blocking _frida_g_socket_send_with_blocking -#define g_socket_service_get_type _frida_g_socket_service_get_type -#define g_socket_service_is_active _frida_g_socket_service_is_active -#define g_socket_service_new _frida_g_socket_service_new -#define g_socket_service_start _frida_g_socket_service_start -#define g_socket_service_stop _frida_g_socket_service_stop -#define g_socket_set_blocking _frida_g_socket_set_blocking -#define g_socket_set_broadcast _frida_g_socket_set_broadcast -#define g_socket_set_keepalive _frida_g_socket_set_keepalive -#define g_socket_set_listen_backlog _frida_g_socket_set_listen_backlog -#define g_socket_set_multicast_loopback _frida_g_socket_set_multicast_loopback -#define g_socket_set_multicast_ttl _frida_g_socket_set_multicast_ttl -#define g_socket_set_option _frida_g_socket_set_option -#define g_socket_set_timeout _frida_g_socket_set_timeout -#define g_socket_set_ttl _frida_g_socket_set_ttl -#define g_socket_shutdown _frida_g_socket_shutdown -#define g_socket_speaks_ipv4 _frida_g_socket_speaks_ipv4 -#define g_socket_type_get_type _frida_g_socket_type_get_type -#define g_source_add_child_source _frida_g_source_add_child_source -#define g_source_add_poll _frida_g_source_add_poll -#define g_source_add_unix_fd _frida_g_source_add_unix_fd -#define g_source_attach _frida_g_source_attach -#define g_source_destroy _frida_g_source_destroy -#define g_source_get_can_recurse _frida_g_source_get_can_recurse -#define g_source_get_context _frida_g_source_get_context -#define g_source_get_current_time _frida_g_source_get_current_time -#define g_source_get_id _frida_g_source_get_id -#define g_source_get_name _frida_g_source_get_name -#define g_source_get_priority _frida_g_source_get_priority -#define g_source_get_ready_time _frida_g_source_get_ready_time -#define g_source_get_time _frida_g_source_get_time -#define g_source_get_type _frida_g_source_get_type -#define g_source_is_destroyed _frida_g_source_is_destroyed -#define g_source_modify_unix_fd _frida_g_source_modify_unix_fd -#define g_source_new _frida_g_source_new -#define g_source_query_unix_fd _frida_g_source_query_unix_fd -#define g_source_ref _frida_g_source_ref -#define g_source_remove _frida_g_source_remove -#define g_source_remove_by_funcs_user_data _frida_g_source_remove_by_funcs_user_data -#define g_source_remove_by_user_data _frida_g_source_remove_by_user_data -#define g_source_remove_child_source _frida_g_source_remove_child_source -#define g_source_remove_poll _frida_g_source_remove_poll -#define g_source_remove_unix_fd _frida_g_source_remove_unix_fd -#define g_source_set_callback _frida_g_source_set_callback -#define g_source_set_callback_indirect _frida_g_source_set_callback_indirect -#define g_source_set_can_recurse _frida_g_source_set_can_recurse -#define g_source_set_closure _frida_g_source_set_closure -#define g_source_set_dispose_function _frida_g_source_set_dispose_function -#define g_source_set_dummy_callback _frida_g_source_set_dummy_callback -#define g_source_set_funcs _frida_g_source_set_funcs -#define g_source_set_name _frida_g_source_set_name -#define g_source_set_name_by_id _frida_g_source_set_name_by_id -#define g_source_set_priority _frida_g_source_set_priority -#define g_source_set_ready_time _frida_g_source_set_ready_time -#define g_source_unref _frida_g_source_unref -#define g_spaced_primes_closest _frida_g_spaced_primes_closest -#define g_spawn_async _frida_g_spawn_async -#define g_spawn_async_with_fds _frida_g_spawn_async_with_fds -#define g_spawn_async_with_pipes _frida_g_spawn_async_with_pipes -#define g_spawn_check_exit_status _frida_g_spawn_check_exit_status -#define g_spawn_close_pid _frida_g_spawn_close_pid -#define g_spawn_command_line_async _frida_g_spawn_command_line_async -#define g_spawn_command_line_sync _frida_g_spawn_command_line_sync -#define g_spawn_error_quark _frida_g_spawn_error_quark -#define g_spawn_exit_error_quark _frida_g_spawn_exit_error_quark -#define g_spawn_sync _frida_g_spawn_sync -#define g_sprintf _frida_g_sprintf -#define g_srv_target_copy _frida_g_srv_target_copy -#define g_srv_target_free _frida_g_srv_target_free -#define g_srv_target_get_hostname _frida_g_srv_target_get_hostname -#define g_srv_target_get_port _frida_g_srv_target_get_port -#define g_srv_target_get_priority _frida_g_srv_target_get_priority -#define g_srv_target_get_type _frida_g_srv_target_get_type -#define g_srv_target_get_weight _frida_g_srv_target_get_weight -#define g_srv_target_list_sort _frida_g_srv_target_list_sort -#define g_srv_target_new _frida_g_srv_target_new -#define g_stat _frida_g_stat -#define g_static_mutex_free _frida_g_static_mutex_free -#define g_static_mutex_get_mutex_impl _frida_g_static_mutex_get_mutex_impl -#define g_static_mutex_init _frida_g_static_mutex_init -#define g_static_private_free _frida_g_static_private_free -#define g_static_private_get _frida_g_static_private_get -#define g_static_private_init _frida_g_static_private_init -#define g_static_private_set _frida_g_static_private_set -#define g_static_rec_mutex_free _frida_g_static_rec_mutex_free -#define g_static_rec_mutex_init _frida_g_static_rec_mutex_init -#define g_static_rec_mutex_lock _frida_g_static_rec_mutex_lock -#define g_static_rec_mutex_lock_full _frida_g_static_rec_mutex_lock_full -#define g_static_rec_mutex_trylock _frida_g_static_rec_mutex_trylock -#define g_static_rec_mutex_unlock _frida_g_static_rec_mutex_unlock -#define g_static_rec_mutex_unlock_full _frida_g_static_rec_mutex_unlock_full -#define g_static_resource_fini _frida_g_static_resource_fini -#define g_static_resource_get_resource _frida_g_static_resource_get_resource -#define g_static_resource_init _frida_g_static_resource_init -#define g_static_rw_lock_free _frida_g_static_rw_lock_free -#define g_static_rw_lock_init _frida_g_static_rw_lock_init -#define g_static_rw_lock_reader_lock _frida_g_static_rw_lock_reader_lock -#define g_static_rw_lock_reader_trylock _frida_g_static_rw_lock_reader_trylock -#define g_static_rw_lock_reader_unlock _frida_g_static_rw_lock_reader_unlock -#define g_static_rw_lock_writer_lock _frida_g_static_rw_lock_writer_lock -#define g_static_rw_lock_writer_trylock _frida_g_static_rw_lock_writer_trylock -#define g_static_rw_lock_writer_unlock _frida_g_static_rw_lock_writer_unlock -#define g_stpcpy _frida_g_stpcpy -#define g_str_equal _frida_g_str_equal -#define g_str_has_prefix _frida_g_str_has_prefix -#define g_str_has_suffix _frida_g_str_has_suffix -#define g_str_hash _frida_g_str_hash -#define g_str_is_ascii _frida_g_str_is_ascii -#define g_str_match_string _frida_g_str_match_string -#define g_str_to_ascii _frida_g_str_to_ascii -#define g_str_tokenize_and_fold _frida_g_str_tokenize_and_fold -#define g_strcanon _frida_g_strcanon -#define g_strcasecmp _frida_g_strcasecmp -#define g_strchomp _frida_g_strchomp -#define g_strchug _frida_g_strchug -#define g_strcmp0 _frida_g_strcmp0 -#define g_strcompress _frida_g_strcompress -#define g_strconcat _frida_g_strconcat -#define g_strdelimit _frida_g_strdelimit -#define g_strdown _frida_g_strdown -#define g_strdup _frida_g_strdup -#define g_strdup_printf _frida_g_strdup_printf -#define g_strdup_value_contents _frida_g_strdup_value_contents -#define g_strdup_vprintf _frida_g_strdup_vprintf -#define g_strdupv _frida_g_strdupv -#define g_strerror _frida_g_strerror -#define g_strescape _frida_g_strescape -#define g_strfreev _frida_g_strfreev -#define g_string_append _frida_g_string_append -#define g_string_append_c _frida_g_string_append_c -#define g_string_append_len _frida_g_string_append_len -#define g_string_append_printf _frida_g_string_append_printf -#define g_string_append_unichar _frida_g_string_append_unichar -#define g_string_append_uri_escaped _frida_g_string_append_uri_escaped -#define g_string_append_vprintf _frida_g_string_append_vprintf -#define g_string_ascii_down _frida_g_string_ascii_down -#define g_string_ascii_up _frida_g_string_ascii_up -#define g_string_assign _frida_g_string_assign -#define g_string_chunk_clear _frida_g_string_chunk_clear -#define g_string_chunk_free _frida_g_string_chunk_free -#define g_string_chunk_insert _frida_g_string_chunk_insert -#define g_string_chunk_insert_const _frida_g_string_chunk_insert_const -#define g_string_chunk_insert_len _frida_g_string_chunk_insert_len -#define g_string_chunk_new _frida_g_string_chunk_new -#define g_string_down _frida_g_string_down -#define g_string_equal _frida_g_string_equal -#define g_string_erase _frida_g_string_erase -#define g_string_free _frida_g_string_free -#define g_string_free_to_bytes _frida_g_string_free_to_bytes -#define g_string_hash _frida_g_string_hash -#define g_string_insert _frida_g_string_insert -#define g_string_insert_c _frida_g_string_insert_c -#define g_string_insert_len _frida_g_string_insert_len -#define g_string_insert_unichar _frida_g_string_insert_unichar -#define g_string_new _frida_g_string_new -#define g_string_new_len _frida_g_string_new_len -#define g_string_overwrite _frida_g_string_overwrite -#define g_string_overwrite_len _frida_g_string_overwrite_len -#define g_string_prepend _frida_g_string_prepend -#define g_string_prepend_c _frida_g_string_prepend_c -#define g_string_prepend_len _frida_g_string_prepend_len -#define g_string_prepend_unichar _frida_g_string_prepend_unichar -#define g_string_printf _frida_g_string_printf -#define g_string_set_size _frida_g_string_set_size -#define g_string_sized_new _frida_g_string_sized_new -#define g_string_truncate _frida_g_string_truncate -#define g_string_up _frida_g_string_up -#define g_string_vprintf _frida_g_string_vprintf -#define g_strip_context _frida_g_strip_context -#define g_strjoin _frida_g_strjoin -#define g_strjoinv _frida_g_strjoinv -#define g_strlcat _frida_g_strlcat -#define g_strlcpy _frida_g_strlcpy -#define g_strncasecmp _frida_g_strncasecmp -#define g_strndup _frida_g_strndup -#define g_strnfill _frida_g_strnfill -#define g_strreverse _frida_g_strreverse -#define g_strrstr _frida_g_strrstr -#define g_strrstr_len _frida_g_strrstr_len -#define g_strsignal _frida_g_strsignal -#define g_strsplit _frida_g_strsplit -#define g_strsplit_set _frida_g_strsplit_set -#define g_strstr_len _frida_g_strstr_len -#define g_strtod _frida_g_strtod -#define g_strup _frida_g_strup -#define g_strv_builder_add _frida_g_strv_builder_add -#define g_strv_builder_end _frida_g_strv_builder_end -#define g_strv_builder_new _frida_g_strv_builder_new -#define g_strv_builder_ref _frida_g_strv_builder_ref -#define g_strv_builder_unref _frida_g_strv_builder_unref -#define g_strv_contains _frida_g_strv_contains -#define g_strv_equal _frida_g_strv_equal -#define g_strv_get_type _frida_g_strv_get_type -#define g_strv_length _frida_g_strv_length -#define g_subprocess_communicate _frida_g_subprocess_communicate -#define g_subprocess_communicate_async _frida_g_subprocess_communicate_async -#define g_subprocess_communicate_finish _frida_g_subprocess_communicate_finish -#define g_subprocess_communicate_utf8 _frida_g_subprocess_communicate_utf8 -#define g_subprocess_communicate_utf8_async _frida_g_subprocess_communicate_utf8_async -#define g_subprocess_communicate_utf8_finish _frida_g_subprocess_communicate_utf8_finish -#define g_subprocess_flags_get_type _frida_g_subprocess_flags_get_type -#define g_subprocess_force_exit _frida_g_subprocess_force_exit -#define g_subprocess_get_exit_status _frida_g_subprocess_get_exit_status -#define g_subprocess_get_identifier _frida_g_subprocess_get_identifier -#define g_subprocess_get_if_exited _frida_g_subprocess_get_if_exited -#define g_subprocess_get_if_signaled _frida_g_subprocess_get_if_signaled -#define g_subprocess_get_status _frida_g_subprocess_get_status -#define g_subprocess_get_stderr_pipe _frida_g_subprocess_get_stderr_pipe -#define g_subprocess_get_stdin_pipe _frida_g_subprocess_get_stdin_pipe -#define g_subprocess_get_stdout_pipe _frida_g_subprocess_get_stdout_pipe -#define g_subprocess_get_successful _frida_g_subprocess_get_successful -#define g_subprocess_get_term_sig _frida_g_subprocess_get_term_sig -#define g_subprocess_get_type _frida_g_subprocess_get_type -#define g_subprocess_launcher_close _frida_g_subprocess_launcher_close -#define g_subprocess_launcher_get_type _frida_g_subprocess_launcher_get_type -#define g_subprocess_launcher_getenv _frida_g_subprocess_launcher_getenv -#define g_subprocess_launcher_new _frida_g_subprocess_launcher_new -#define g_subprocess_launcher_set_child_setup _frida_g_subprocess_launcher_set_child_setup -#define g_subprocess_launcher_set_cwd _frida_g_subprocess_launcher_set_cwd -#define g_subprocess_launcher_set_environ _frida_g_subprocess_launcher_set_environ -#define g_subprocess_launcher_set_flags _frida_g_subprocess_launcher_set_flags -#define g_subprocess_launcher_set_stderr_file_path _frida_g_subprocess_launcher_set_stderr_file_path -#define g_subprocess_launcher_set_stdin_file_path _frida_g_subprocess_launcher_set_stdin_file_path -#define g_subprocess_launcher_set_stdout_file_path _frida_g_subprocess_launcher_set_stdout_file_path -#define g_subprocess_launcher_setenv _frida_g_subprocess_launcher_setenv -#define g_subprocess_launcher_spawn _frida_g_subprocess_launcher_spawn -#define g_subprocess_launcher_spawnv _frida_g_subprocess_launcher_spawnv -#define g_subprocess_launcher_take_fd _frida_g_subprocess_launcher_take_fd -#define g_subprocess_launcher_take_stderr_fd _frida_g_subprocess_launcher_take_stderr_fd -#define g_subprocess_launcher_take_stdin_fd _frida_g_subprocess_launcher_take_stdin_fd -#define g_subprocess_launcher_take_stdout_fd _frida_g_subprocess_launcher_take_stdout_fd -#define g_subprocess_launcher_unsetenv _frida_g_subprocess_launcher_unsetenv -#define g_subprocess_new _frida_g_subprocess_new -#define g_subprocess_newv _frida_g_subprocess_newv -#define g_subprocess_send_signal _frida_g_subprocess_send_signal -#define g_subprocess_set_launcher _frida_g_subprocess_set_launcher -#define g_subprocess_wait _frida_g_subprocess_wait -#define g_subprocess_wait_async _frida_g_subprocess_wait_async -#define g_subprocess_wait_check _frida_g_subprocess_wait_check -#define g_subprocess_wait_check_async _frida_g_subprocess_wait_check_async -#define g_subprocess_wait_check_finish _frida_g_subprocess_wait_check_finish -#define g_subprocess_wait_finish _frida_g_subprocess_wait_finish -#define g_system_thread_exit _frida_g_system_thread_exit -#define g_system_thread_free _frida_g_system_thread_free -#define g_system_thread_get_scheduler_settings _frida_g_system_thread_get_scheduler_settings -#define g_system_thread_new _frida_g_system_thread_new -#define g_system_thread_set_name _frida_g_system_thread_set_name -#define g_system_thread_wait _frida_g_system_thread_wait -#define g_task_attach_source _frida_g_task_attach_source -#define g_task_get_cancellable _frida_g_task_get_cancellable -#define g_task_get_check_cancellable _frida_g_task_get_check_cancellable -#define g_task_get_completed _frida_g_task_get_completed -#define g_task_get_context _frida_g_task_get_context -#define g_task_get_name _frida_g_task_get_name -#define g_task_get_priority _frida_g_task_get_priority -#define g_task_get_return_on_cancel _frida_g_task_get_return_on_cancel -#define g_task_get_source_object _frida_g_task_get_source_object -#define g_task_get_source_tag _frida_g_task_get_source_tag -#define g_task_get_task_data _frida_g_task_get_task_data -#define g_task_get_type _frida_g_task_get_type -#define g_task_had_error _frida_g_task_had_error -#define g_task_is_valid _frida_g_task_is_valid -#define g_task_new _frida_g_task_new -#define g_task_propagate_boolean _frida_g_task_propagate_boolean -#define g_task_propagate_int _frida_g_task_propagate_int -#define g_task_propagate_pointer _frida_g_task_propagate_pointer -#define g_task_propagate_value _frida_g_task_propagate_value -#define g_task_report_error _frida_g_task_report_error -#define g_task_report_new_error _frida_g_task_report_new_error -#define g_task_return_boolean _frida_g_task_return_boolean -#define g_task_return_error _frida_g_task_return_error -#define g_task_return_error_if_cancelled _frida_g_task_return_error_if_cancelled -#define g_task_return_int _frida_g_task_return_int -#define g_task_return_new_error _frida_g_task_return_new_error -#define g_task_return_pointer _frida_g_task_return_pointer -#define g_task_return_value _frida_g_task_return_value -#define g_task_run_in_thread _frida_g_task_run_in_thread -#define g_task_run_in_thread_sync _frida_g_task_run_in_thread_sync -#define g_task_set_check_cancellable _frida_g_task_set_check_cancellable -#define g_task_set_name _frida_g_task_set_name -#define g_task_set_priority _frida_g_task_set_priority -#define g_task_set_return_on_cancel _frida_g_task_set_return_on_cancel -#define g_task_set_source_tag _frida_g_task_set_source_tag -#define g_task_set_task_data _frida_g_task_set_task_data -#define g_tcp_connection_get_graceful_disconnect _frida_g_tcp_connection_get_graceful_disconnect -#define g_tcp_connection_get_type _frida_g_tcp_connection_get_type -#define g_tcp_connection_set_graceful_disconnect _frida_g_tcp_connection_set_graceful_disconnect -#define g_tcp_wrapper_connection_get_base_io_stream _frida_g_tcp_wrapper_connection_get_base_io_stream -#define g_tcp_wrapper_connection_get_type _frida_g_tcp_wrapper_connection_get_type -#define g_tcp_wrapper_connection_new _frida_g_tcp_wrapper_connection_new -#define g_test_add_data_func _frida_g_test_add_data_func -#define g_test_add_data_func_full _frida_g_test_add_data_func_full -#define g_test_add_func _frida_g_test_add_func -#define g_test_add_vtable _frida_g_test_add_vtable -#define g_test_assert_expected_messages_internal _frida_g_test_assert_expected_messages_internal -#define g_test_bug _frida_g_test_bug -#define g_test_bug_base _frida_g_test_bug_base -#define g_test_build_filename _frida_g_test_build_filename -#define g_test_config_vars _frida_g_test_config_vars -#define g_test_create_case _frida_g_test_create_case -#define g_test_create_suite _frida_g_test_create_suite -#define g_test_dbus_add_service_dir _frida_g_test_dbus_add_service_dir -#define g_test_dbus_down _frida_g_test_dbus_down -#define g_test_dbus_flags_get_type _frida_g_test_dbus_flags_get_type -#define g_test_dbus_get_bus_address _frida_g_test_dbus_get_bus_address -#define g_test_dbus_get_flags _frida_g_test_dbus_get_flags -#define g_test_dbus_get_type _frida_g_test_dbus_get_type -#define g_test_dbus_new _frida_g_test_dbus_new -#define g_test_dbus_stop _frida_g_test_dbus_stop -#define g_test_dbus_unset _frida_g_test_dbus_unset -#define g_test_dbus_up _frida_g_test_dbus_up -#define g_test_expect_message _frida_g_test_expect_message -#define g_test_fail _frida_g_test_fail -#define g_test_failed _frida_g_test_failed -#define g_test_get_dir _frida_g_test_get_dir -#define g_test_get_filename _frida_g_test_get_filename -#define g_test_get_root _frida_g_test_get_root -#define g_test_incomplete _frida_g_test_incomplete -#define g_test_init _frida_g_test_init -#define g_test_log_buffer_free _frida_g_test_log_buffer_free -#define g_test_log_buffer_new _frida_g_test_log_buffer_new -#define g_test_log_buffer_pop _frida_g_test_log_buffer_pop -#define g_test_log_buffer_push _frida_g_test_log_buffer_push -#define g_test_log_msg_free _frida_g_test_log_msg_free -#define g_test_log_set_fatal_handler _frida_g_test_log_set_fatal_handler -#define g_test_log_type_name _frida_g_test_log_type_name -#define g_test_maximized_result _frida_g_test_maximized_result -#define g_test_message _frida_g_test_message -#define g_test_minimized_result _frida_g_test_minimized_result -#define g_test_queue_destroy _frida_g_test_queue_destroy -#define g_test_queue_free _frida_g_test_queue_free -#define g_test_rand_double _frida_g_test_rand_double -#define g_test_rand_double_range _frida_g_test_rand_double_range -#define g_test_rand_int _frida_g_test_rand_int -#define g_test_rand_int_range _frida_g_test_rand_int_range -#define g_test_run _frida_g_test_run -#define g_test_run_suite _frida_g_test_run_suite -#define g_test_set_nonfatal_assertions _frida_g_test_set_nonfatal_assertions -#define g_test_skip _frida_g_test_skip -#define g_test_subprocess _frida_g_test_subprocess -#define g_test_suite_add _frida_g_test_suite_add -#define g_test_suite_add_suite _frida_g_test_suite_add_suite -#define g_test_summary _frida_g_test_summary -#define g_test_timer_elapsed _frida_g_test_timer_elapsed -#define g_test_timer_last _frida_g_test_timer_last -#define g_test_timer_start _frida_g_test_timer_start -#define g_test_trap_assertions _frida_g_test_trap_assertions -#define g_test_trap_fork _frida_g_test_trap_fork -#define g_test_trap_has_passed _frida_g_test_trap_has_passed -#define g_test_trap_reached_timeout _frida_g_test_trap_reached_timeout -#define g_test_trap_subprocess _frida_g_test_trap_subprocess -#define g_themed_icon_append_name _frida_g_themed_icon_append_name -#define g_themed_icon_get_names _frida_g_themed_icon_get_names -#define g_themed_icon_get_type _frida_g_themed_icon_get_type -#define g_themed_icon_new _frida_g_themed_icon_new -#define g_themed_icon_new_from_names _frida_g_themed_icon_new_from_names -#define g_themed_icon_new_with_default_fallbacks _frida_g_themed_icon_new_with_default_fallbacks -#define g_themed_icon_prepend_name _frida_g_themed_icon_prepend_name -#define g_thread_create _frida_g_thread_create -#define g_thread_create_full _frida_g_thread_create_full -#define g_thread_error_quark _frida_g_thread_error_quark -#define g_thread_exit _frida_g_thread_exit -#define g_thread_foreach _frida_g_thread_foreach -#define g_thread_functions_for_glib_use _frida_g_thread_functions_for_glib_use -#define g_thread_garbage_collect _frida_g_thread_garbage_collect -#define g_thread_get_initialized _frida_g_thread_get_initialized -#define g_thread_get_scheduler_settings _frida_g_thread_get_scheduler_settings -#define g_thread_get_type _frida_g_thread_get_type -#define g_thread_gettime _frida_g_thread_gettime -#define g_thread_init_glib _frida_g_thread_init_glib -#define g_thread_join _frida_g_thread_join -#define g_thread_lifetime_beacon_check _frida_g_thread_lifetime_beacon_check -#define g_thread_lifetime_beacon_free _frida_g_thread_lifetime_beacon_free -#define g_thread_lifetime_beacon_new _frida_g_thread_lifetime_beacon_new -#define g_thread_n_created _frida_g_thread_n_created -#define g_thread_new _frida_g_thread_new -#define g_thread_new_internal _frida_g_thread_new_internal -#define g_thread_perform_cleanup _frida_g_thread_perform_cleanup -#define g_thread_pool_free _frida_g_thread_pool_free -#define g_thread_pool_get_max_idle_time _frida_g_thread_pool_get_max_idle_time -#define g_thread_pool_get_max_threads _frida_g_thread_pool_get_max_threads -#define g_thread_pool_get_max_unused_threads _frida_g_thread_pool_get_max_unused_threads -#define g_thread_pool_get_num_threads _frida_g_thread_pool_get_num_threads -#define g_thread_pool_get_num_unused_threads _frida_g_thread_pool_get_num_unused_threads -#define g_thread_pool_move_to_front _frida_g_thread_pool_move_to_front -#define g_thread_pool_new _frida_g_thread_pool_new -#define g_thread_pool_push _frida_g_thread_pool_push -#define g_thread_pool_set_max_idle_time _frida_g_thread_pool_set_max_idle_time -#define g_thread_pool_set_max_threads _frida_g_thread_pool_set_max_threads -#define g_thread_pool_set_max_unused_threads _frida_g_thread_pool_set_max_unused_threads -#define g_thread_pool_set_sort_function _frida_g_thread_pool_set_sort_function -#define g_thread_pool_stop_unused_threads _frida_g_thread_pool_stop_unused_threads -#define g_thread_pool_unprocessed _frida_g_thread_pool_unprocessed -#define g_thread_private_destroy_later _frida_g_thread_private_destroy_later -#define g_thread_proxy _frida_g_thread_proxy -#define g_thread_ref _frida_g_thread_ref -#define g_thread_schedule_cleanup _frida_g_thread_schedule_cleanup -#define g_thread_self _frida_g_thread_self -#define g_thread_set_callbacks _frida_g_thread_set_callbacks -#define g_thread_set_garbage_handler _frida_g_thread_set_garbage_handler -#define g_thread_set_priority _frida_g_thread_set_priority -#define g_thread_try_new _frida_g_thread_try_new -#define g_thread_unref _frida_g_thread_unref -#define g_thread_use_default_impl _frida_g_thread_use_default_impl -#define g_thread_yield _frida_g_thread_yield -#define g_threaded_resolver_get_type _frida_g_threaded_resolver_get_type -#define g_threaded_socket_service_get_type _frida_g_threaded_socket_service_get_type -#define g_threaded_socket_service_new _frida_g_threaded_socket_service_new -#define g_threads_got_initialized _frida_g_threads_got_initialized -#define g_time_val_add _frida_g_time_val_add -#define g_time_val_from_iso8601 _frida_g_time_val_from_iso8601 -#define g_time_val_to_iso8601 _frida_g_time_val_to_iso8601 -#define g_time_zone_adjust_time _frida_g_time_zone_adjust_time -#define g_time_zone_find_interval _frida_g_time_zone_find_interval -#define g_time_zone_get_abbreviation _frida_g_time_zone_get_abbreviation -#define g_time_zone_get_identifier _frida_g_time_zone_get_identifier -#define g_time_zone_get_offset _frida_g_time_zone_get_offset -#define g_time_zone_get_type _frida_g_time_zone_get_type -#define g_time_zone_is_dst _frida_g_time_zone_is_dst -#define g_time_zone_new _frida_g_time_zone_new -#define g_time_zone_new_identifier _frida_g_time_zone_new_identifier -#define g_time_zone_new_local _frida_g_time_zone_new_local -#define g_time_zone_new_offset _frida_g_time_zone_new_offset -#define g_time_zone_new_utc _frida_g_time_zone_new_utc -#define g_time_zone_ref _frida_g_time_zone_ref -#define g_time_zone_unref _frida_g_time_zone_unref -#define g_timeout_add _frida_g_timeout_add -#define g_timeout_add_full _frida_g_timeout_add_full -#define g_timeout_add_seconds _frida_g_timeout_add_seconds -#define g_timeout_add_seconds_full _frida_g_timeout_add_seconds_full -#define g_timeout_funcs _frida_g_timeout_funcs -#define g_timeout_source_new _frida_g_timeout_source_new -#define g_timeout_source_new_seconds _frida_g_timeout_source_new_seconds -#define g_timer_continue _frida_g_timer_continue -#define g_timer_destroy _frida_g_timer_destroy -#define g_timer_elapsed _frida_g_timer_elapsed -#define g_timer_is_active _frida_g_timer_is_active -#define g_timer_new _frida_g_timer_new -#define g_timer_reset _frida_g_timer_reset -#define g_timer_start _frida_g_timer_start -#define g_timer_stop _frida_g_timer_stop -#define g_tinylist_foreach _frida_g_tinylist_foreach -#define g_tinylist_free _frida_g_tinylist_free -#define g_tinylist_prepend _frida_g_tinylist_prepend -#define g_tinylist_remove _frida_g_tinylist_remove -#define g_tls_authentication_mode_get_type _frida_g_tls_authentication_mode_get_type -#define g_tls_backend_get_certificate_type _frida_g_tls_backend_get_certificate_type -#define g_tls_backend_get_client_connection_type _frida_g_tls_backend_get_client_connection_type -#define g_tls_backend_get_default _frida_g_tls_backend_get_default -#define g_tls_backend_get_default_database _frida_g_tls_backend_get_default_database -#define g_tls_backend_get_dtls_client_connection_type _frida_g_tls_backend_get_dtls_client_connection_type -#define g_tls_backend_get_dtls_server_connection_type _frida_g_tls_backend_get_dtls_server_connection_type -#define g_tls_backend_get_file_database_type _frida_g_tls_backend_get_file_database_type -#define g_tls_backend_get_server_connection_type _frida_g_tls_backend_get_server_connection_type -#define g_tls_backend_get_type _frida_g_tls_backend_get_type -#define g_tls_backend_set_default_database _frida_g_tls_backend_set_default_database -#define g_tls_backend_supports_dtls _frida_g_tls_backend_supports_dtls -#define g_tls_backend_supports_tls _frida_g_tls_backend_supports_tls -#define g_tls_certificate_flags_get_type _frida_g_tls_certificate_flags_get_type -#define g_tls_certificate_get_issuer _frida_g_tls_certificate_get_issuer -#define g_tls_certificate_get_type _frida_g_tls_certificate_get_type -#define g_tls_certificate_is_same _frida_g_tls_certificate_is_same -#define g_tls_certificate_list_new_from_file _frida_g_tls_certificate_list_new_from_file -#define g_tls_certificate_new_from_file _frida_g_tls_certificate_new_from_file -#define g_tls_certificate_new_from_files _frida_g_tls_certificate_new_from_files -#define g_tls_certificate_new_from_pem _frida_g_tls_certificate_new_from_pem -#define g_tls_certificate_new_from_pkcs11_uris _frida_g_tls_certificate_new_from_pkcs11_uris -#define g_tls_certificate_request_flags_get_type _frida_g_tls_certificate_request_flags_get_type -#define g_tls_certificate_verify _frida_g_tls_certificate_verify -#define g_tls_channel_binding_error_get_type _frida_g_tls_channel_binding_error_get_type -#define g_tls_channel_binding_error_quark _frida_g_tls_channel_binding_error_quark -#define g_tls_channel_binding_type_get_type _frida_g_tls_channel_binding_type_get_type -#define g_tls_client_connection_copy_session_state _frida_g_tls_client_connection_copy_session_state -#define g_tls_client_connection_get_accepted_cas _frida_g_tls_client_connection_get_accepted_cas -#define g_tls_client_connection_get_server_identity _frida_g_tls_client_connection_get_server_identity -#define g_tls_client_connection_get_type _frida_g_tls_client_connection_get_type -#define g_tls_client_connection_get_use_ssl3 _frida_g_tls_client_connection_get_use_ssl3 -#define g_tls_client_connection_get_validation_flags _frida_g_tls_client_connection_get_validation_flags -#define g_tls_client_connection_new _frida_g_tls_client_connection_new -#define g_tls_client_connection_set_server_identity _frida_g_tls_client_connection_set_server_identity -#define g_tls_client_connection_set_use_ssl3 _frida_g_tls_client_connection_set_use_ssl3 -#define g_tls_client_connection_set_validation_flags _frida_g_tls_client_connection_set_validation_flags -#define g_tls_connection_emit_accept_certificate _frida_g_tls_connection_emit_accept_certificate -#define g_tls_connection_get_certificate _frida_g_tls_connection_get_certificate -#define g_tls_connection_get_channel_binding_data _frida_g_tls_connection_get_channel_binding_data -#define g_tls_connection_get_database _frida_g_tls_connection_get_database -#define g_tls_connection_get_interaction _frida_g_tls_connection_get_interaction -#define g_tls_connection_get_negotiated_protocol _frida_g_tls_connection_get_negotiated_protocol -#define g_tls_connection_get_peer_certificate _frida_g_tls_connection_get_peer_certificate -#define g_tls_connection_get_peer_certificate_errors _frida_g_tls_connection_get_peer_certificate_errors -#define g_tls_connection_get_rehandshake_mode _frida_g_tls_connection_get_rehandshake_mode -#define g_tls_connection_get_require_close_notify _frida_g_tls_connection_get_require_close_notify -#define g_tls_connection_get_type _frida_g_tls_connection_get_type -#define g_tls_connection_get_use_system_certdb _frida_g_tls_connection_get_use_system_certdb -#define g_tls_connection_handshake _frida_g_tls_connection_handshake -#define g_tls_connection_handshake_async _frida_g_tls_connection_handshake_async -#define g_tls_connection_handshake_finish _frida_g_tls_connection_handshake_finish -#define g_tls_connection_set_advertised_protocols _frida_g_tls_connection_set_advertised_protocols -#define g_tls_connection_set_certificate _frida_g_tls_connection_set_certificate -#define g_tls_connection_set_database _frida_g_tls_connection_set_database -#define g_tls_connection_set_interaction _frida_g_tls_connection_set_interaction -#define g_tls_connection_set_rehandshake_mode _frida_g_tls_connection_set_rehandshake_mode -#define g_tls_connection_set_require_close_notify _frida_g_tls_connection_set_require_close_notify -#define g_tls_connection_set_use_system_certdb _frida_g_tls_connection_set_use_system_certdb -#define g_tls_database_create_certificate_handle _frida_g_tls_database_create_certificate_handle -#define g_tls_database_get_type _frida_g_tls_database_get_type -#define g_tls_database_lookup_certificate_for_handle _frida_g_tls_database_lookup_certificate_for_handle -#define g_tls_database_lookup_certificate_for_handle_async _frida_g_tls_database_lookup_certificate_for_handle_async -#define g_tls_database_lookup_certificate_for_handle_finish _frida_g_tls_database_lookup_certificate_for_handle_finish -#define g_tls_database_lookup_certificate_issuer _frida_g_tls_database_lookup_certificate_issuer -#define g_tls_database_lookup_certificate_issuer_async _frida_g_tls_database_lookup_certificate_issuer_async -#define g_tls_database_lookup_certificate_issuer_finish _frida_g_tls_database_lookup_certificate_issuer_finish -#define g_tls_database_lookup_certificates_issued_by _frida_g_tls_database_lookup_certificates_issued_by -#define g_tls_database_lookup_certificates_issued_by_async _frida_g_tls_database_lookup_certificates_issued_by_async -#define g_tls_database_lookup_certificates_issued_by_finish _frida_g_tls_database_lookup_certificates_issued_by_finish -#define g_tls_database_lookup_flags_get_type _frida_g_tls_database_lookup_flags_get_type -#define g_tls_database_verify_chain _frida_g_tls_database_verify_chain -#define g_tls_database_verify_chain_async _frida_g_tls_database_verify_chain_async -#define g_tls_database_verify_chain_finish _frida_g_tls_database_verify_chain_finish -#define g_tls_database_verify_flags_get_type _frida_g_tls_database_verify_flags_get_type -#define g_tls_error_get_type _frida_g_tls_error_get_type -#define g_tls_error_quark _frida_g_tls_error_quark -#define g_tls_file_database_get_type _frida_g_tls_file_database_get_type -#define g_tls_file_database_new _frida_g_tls_file_database_new -#define g_tls_interaction_ask_password _frida_g_tls_interaction_ask_password -#define g_tls_interaction_ask_password_async _frida_g_tls_interaction_ask_password_async -#define g_tls_interaction_ask_password_finish _frida_g_tls_interaction_ask_password_finish -#define g_tls_interaction_get_type _frida_g_tls_interaction_get_type -#define g_tls_interaction_invoke_ask_password _frida_g_tls_interaction_invoke_ask_password -#define g_tls_interaction_invoke_request_certificate _frida_g_tls_interaction_invoke_request_certificate -#define g_tls_interaction_request_certificate _frida_g_tls_interaction_request_certificate -#define g_tls_interaction_request_certificate_async _frida_g_tls_interaction_request_certificate_async -#define g_tls_interaction_request_certificate_finish _frida_g_tls_interaction_request_certificate_finish -#define g_tls_interaction_result_get_type _frida_g_tls_interaction_result_get_type -#define g_tls_password_flags_get_type _frida_g_tls_password_flags_get_type -#define g_tls_password_get_description _frida_g_tls_password_get_description -#define g_tls_password_get_flags _frida_g_tls_password_get_flags -#define g_tls_password_get_type _frida_g_tls_password_get_type -#define g_tls_password_get_value _frida_g_tls_password_get_value -#define g_tls_password_get_warning _frida_g_tls_password_get_warning -#define g_tls_password_new _frida_g_tls_password_new -#define g_tls_password_set_description _frida_g_tls_password_set_description -#define g_tls_password_set_flags _frida_g_tls_password_set_flags -#define g_tls_password_set_value _frida_g_tls_password_set_value -#define g_tls_password_set_value_full _frida_g_tls_password_set_value_full -#define g_tls_password_set_warning _frida_g_tls_password_set_warning -#define g_tls_rehandshake_mode_get_type _frida_g_tls_rehandshake_mode_get_type -#define g_tls_server_connection_get_type _frida_g_tls_server_connection_get_type -#define g_tls_server_connection_new _frida_g_tls_server_connection_new -#define g_trace_define_int64_counter _frida_g_trace_define_int64_counter -#define g_trace_mark _frida_g_trace_mark -#define g_trace_set_int64_counter _frida_g_trace_set_int64_counter -#define g_trash_portal_trash_file _frida_g_trash_portal_trash_file -#define g_trash_stack_height _frida_g_trash_stack_height -#define g_trash_stack_peek _frida_g_trash_stack_peek -#define g_trash_stack_pop _frida_g_trash_stack_pop -#define g_trash_stack_push _frida_g_trash_stack_push -#define g_tree_destroy _frida_g_tree_destroy -#define g_tree_foreach _frida_g_tree_foreach -#define g_tree_foreach_node _frida_g_tree_foreach_node -#define g_tree_get_type _frida_g_tree_get_type -#define g_tree_height _frida_g_tree_height -#define g_tree_insert _frida_g_tree_insert -#define g_tree_insert_node _frida_g_tree_insert_node -#define g_tree_lookup _frida_g_tree_lookup -#define g_tree_lookup_extended _frida_g_tree_lookup_extended -#define g_tree_lookup_node _frida_g_tree_lookup_node -#define g_tree_lower_bound _frida_g_tree_lower_bound -#define g_tree_new _frida_g_tree_new -#define g_tree_new_full _frida_g_tree_new_full -#define g_tree_new_with_data _frida_g_tree_new_with_data -#define g_tree_nnodes _frida_g_tree_nnodes -#define g_tree_node_first _frida_g_tree_node_first -#define g_tree_node_key _frida_g_tree_node_key -#define g_tree_node_last _frida_g_tree_node_last -#define g_tree_node_next _frida_g_tree_node_next -#define g_tree_node_previous _frida_g_tree_node_previous -#define g_tree_node_value _frida_g_tree_node_value -#define g_tree_ref _frida_g_tree_ref -#define g_tree_remove _frida_g_tree_remove -#define g_tree_replace _frida_g_tree_replace -#define g_tree_replace_node _frida_g_tree_replace_node -#define g_tree_search _frida_g_tree_search -#define g_tree_search_node _frida_g_tree_search_node -#define g_tree_steal _frida_g_tree_steal -#define g_tree_traverse _frida_g_tree_traverse -#define g_tree_unref _frida_g_tree_unref -#define g_tree_upper_bound _frida_g_tree_upper_bound -#define g_try_malloc _frida_g_try_malloc -#define g_try_malloc0 _frida_g_try_malloc0 -#define g_try_malloc0_n _frida_g_try_malloc0_n -#define g_try_malloc_n _frida_g_try_malloc_n -#define g_try_realloc _frida_g_try_realloc -#define g_try_realloc_n _frida_g_try_realloc_n -#define g_tuples_destroy _frida_g_tuples_destroy -#define g_tuples_index _frida_g_tuples_index -#define g_type_add_class_cache_func _frida_g_type_add_class_cache_func -#define g_type_add_class_private _frida_g_type_add_class_private -#define g_type_add_instance_private _frida_g_type_add_instance_private -#define g_type_add_interface_check _frida_g_type_add_interface_check -#define g_type_add_interface_dynamic _frida_g_type_add_interface_dynamic -#define g_type_add_interface_static _frida_g_type_add_interface_static -#define g_type_check_class_cast _frida_g_type_check_class_cast -#define g_type_check_class_is_a _frida_g_type_check_class_is_a -#define g_type_check_instance _frida_g_type_check_instance -#define g_type_check_instance_cast _frida_g_type_check_instance_cast -#define g_type_check_instance_is_a _frida_g_type_check_instance_is_a -#define g_type_check_instance_is_fundamentally_a _frida_g_type_check_instance_is_fundamentally_a -#define g_type_check_is_value_type _frida_g_type_check_is_value_type -#define g_type_check_value _frida_g_type_check_value -#define g_type_check_value_holds _frida_g_type_check_value_holds -#define g_type_children _frida_g_type_children -#define g_type_class_add_private _frida_g_type_class_add_private -#define g_type_class_adjust_private_offset _frida_g_type_class_adjust_private_offset -#define g_type_class_get_instance_private_offset _frida_g_type_class_get_instance_private_offset -#define g_type_class_get_private _frida_g_type_class_get_private -#define g_type_class_peek _frida_g_type_class_peek -#define g_type_class_peek_parent _frida_g_type_class_peek_parent -#define g_type_class_peek_static _frida_g_type_class_peek_static -#define g_type_class_ref _frida_g_type_class_ref -#define g_type_class_unref _frida_g_type_class_unref -#define g_type_class_unref_uncached _frida_g_type_class_unref_uncached -#define g_type_create_instance _frida_g_type_create_instance -#define g_type_default_interface_peek _frida_g_type_default_interface_peek -#define g_type_default_interface_ref _frida_g_type_default_interface_ref -#define g_type_default_interface_unref _frida_g_type_default_interface_unref -#define g_type_depth _frida_g_type_depth -#define g_type_ensure _frida_g_type_ensure -#define g_type_free_instance _frida_g_type_free_instance -#define g_type_from_name _frida_g_type_from_name -#define g_type_fundamental _frida_g_type_fundamental -#define g_type_fundamental_next _frida_g_type_fundamental_next -#define g_type_get_instance_count _frida_g_type_get_instance_count -#define g_type_get_plugin _frida_g_type_get_plugin -#define g_type_get_qdata _frida_g_type_get_qdata -#define g_type_get_type_registration_serial _frida_g_type_get_type_registration_serial -#define g_type_init _frida_g_type_init -#define g_type_init_with_debug_flags _frida_g_type_init_with_debug_flags -#define g_type_instance_get_private _frida_g_type_instance_get_private -#define g_type_interface_add_prerequisite _frida_g_type_interface_add_prerequisite -#define g_type_interface_get_plugin _frida_g_type_interface_get_plugin -#define g_type_interface_instantiatable_prerequisite _frida_g_type_interface_instantiatable_prerequisite -#define g_type_interface_peek _frida_g_type_interface_peek -#define g_type_interface_peek_parent _frida_g_type_interface_peek_parent -#define g_type_interface_prerequisites _frida_g_type_interface_prerequisites -#define g_type_interfaces _frida_g_type_interfaces -#define g_type_is_a _frida_g_type_is_a -#define g_type_module_add_interface _frida_g_type_module_add_interface -#define g_type_module_get_type _frida_g_type_module_get_type -#define g_type_module_register_enum _frida_g_type_module_register_enum -#define g_type_module_register_flags _frida_g_type_module_register_flags -#define g_type_module_register_type _frida_g_type_module_register_type -#define g_type_module_set_name _frida_g_type_module_set_name -#define g_type_module_unuse _frida_g_type_module_unuse -#define g_type_module_use _frida_g_type_module_use -#define g_type_name _frida_g_type_name -#define g_type_name_from_class _frida_g_type_name_from_class -#define g_type_name_from_instance _frida_g_type_name_from_instance -#define g_type_next_base _frida_g_type_next_base -#define g_type_parent _frida_g_type_parent -#define g_type_plugin_complete_interface_info _frida_g_type_plugin_complete_interface_info -#define g_type_plugin_complete_type_info _frida_g_type_plugin_complete_type_info -#define g_type_plugin_get_type _frida_g_type_plugin_get_type -#define g_type_plugin_unuse _frida_g_type_plugin_unuse -#define g_type_plugin_use _frida_g_type_plugin_use -#define g_type_qname _frida_g_type_qname -#define g_type_query _frida_g_type_query -#define g_type_register_dynamic _frida_g_type_register_dynamic -#define g_type_register_fundamental _frida_g_type_register_fundamental -#define g_type_register_static _frida_g_type_register_static -#define g_type_register_static_simple _frida_g_type_register_static_simple -#define g_type_remove_class_cache_func _frida_g_type_remove_class_cache_func -#define g_type_remove_interface_check _frida_g_type_remove_interface_check -#define g_type_set_qdata _frida_g_type_set_qdata -#define g_type_test_flags _frida_g_type_test_flags -#define g_type_value_table_peek _frida_g_type_value_table_peek -#define g_ucs4_to_utf16 _frida_g_ucs4_to_utf16 -#define g_ucs4_to_utf8 _frida_g_ucs4_to_utf8 -#define g_unichar_break_type _frida_g_unichar_break_type -#define g_unichar_combining_class _frida_g_unichar_combining_class -#define g_unichar_compose _frida_g_unichar_compose -#define g_unichar_decompose _frida_g_unichar_decompose -#define g_unichar_digit_value _frida_g_unichar_digit_value -#define g_unichar_fully_decompose _frida_g_unichar_fully_decompose -#define g_unichar_get_mirror_char _frida_g_unichar_get_mirror_char -#define g_unichar_get_script _frida_g_unichar_get_script -#define g_unichar_isalnum _frida_g_unichar_isalnum -#define g_unichar_isalpha _frida_g_unichar_isalpha -#define g_unichar_iscntrl _frida_g_unichar_iscntrl -#define g_unichar_isdefined _frida_g_unichar_isdefined -#define g_unichar_isdigit _frida_g_unichar_isdigit -#define g_unichar_isgraph _frida_g_unichar_isgraph -#define g_unichar_islower _frida_g_unichar_islower -#define g_unichar_ismark _frida_g_unichar_ismark -#define g_unichar_isprint _frida_g_unichar_isprint -#define g_unichar_ispunct _frida_g_unichar_ispunct -#define g_unichar_isspace _frida_g_unichar_isspace -#define g_unichar_istitle _frida_g_unichar_istitle -#define g_unichar_isupper _frida_g_unichar_isupper -#define g_unichar_iswide _frida_g_unichar_iswide -#define g_unichar_iswide_cjk _frida_g_unichar_iswide_cjk -#define g_unichar_isxdigit _frida_g_unichar_isxdigit -#define g_unichar_iszerowidth _frida_g_unichar_iszerowidth -#define g_unichar_to_utf8 _frida_g_unichar_to_utf8 -#define g_unichar_tolower _frida_g_unichar_tolower -#define g_unichar_totitle _frida_g_unichar_totitle -#define g_unichar_toupper _frida_g_unichar_toupper -#define g_unichar_type _frida_g_unichar_type -#define g_unichar_validate _frida_g_unichar_validate -#define g_unichar_xdigit_value _frida_g_unichar_xdigit_value -#define g_unicode_break_type_get_type _frida_g_unicode_break_type_get_type -#define g_unicode_canonical_decomposition _frida_g_unicode_canonical_decomposition -#define g_unicode_canonical_ordering _frida_g_unicode_canonical_ordering -#define g_unicode_script_from_iso15924 _frida_g_unicode_script_from_iso15924 -#define g_unicode_script_get_type _frida_g_unicode_script_get_type -#define g_unicode_script_to_iso15924 _frida_g_unicode_script_to_iso15924 -#define g_unicode_type_get_type _frida_g_unicode_type_get_type -#define g_unix_connection_get_type _frida_g_unix_connection_get_type -#define g_unix_connection_receive_credentials _frida_g_unix_connection_receive_credentials -#define g_unix_connection_receive_credentials_async _frida_g_unix_connection_receive_credentials_async -#define g_unix_connection_receive_credentials_finish _frida_g_unix_connection_receive_credentials_finish -#define g_unix_connection_receive_fd _frida_g_unix_connection_receive_fd -#define g_unix_connection_send_credentials _frida_g_unix_connection_send_credentials -#define g_unix_connection_send_credentials_async _frida_g_unix_connection_send_credentials_async -#define g_unix_connection_send_credentials_finish _frida_g_unix_connection_send_credentials_finish -#define g_unix_connection_send_fd _frida_g_unix_connection_send_fd -#define g_unix_credentials_message_get_credentials _frida_g_unix_credentials_message_get_credentials -#define g_unix_credentials_message_get_type _frida_g_unix_credentials_message_get_type -#define g_unix_credentials_message_is_supported _frida_g_unix_credentials_message_is_supported -#define g_unix_credentials_message_new _frida_g_unix_credentials_message_new -#define g_unix_credentials_message_new_with_credentials _frida_g_unix_credentials_message_new_with_credentials -#define g_unix_error_quark _frida_g_unix_error_quark -#define g_unix_fd_add _frida_g_unix_fd_add -#define g_unix_fd_add_full _frida_g_unix_fd_add_full -#define g_unix_fd_list_append _frida_g_unix_fd_list_append -#define g_unix_fd_list_get _frida_g_unix_fd_list_get -#define g_unix_fd_list_get_length _frida_g_unix_fd_list_get_length -#define g_unix_fd_list_get_type _frida_g_unix_fd_list_get_type -#define g_unix_fd_list_new _frida_g_unix_fd_list_new -#define g_unix_fd_list_new_from_array _frida_g_unix_fd_list_new_from_array -#define g_unix_fd_list_peek_fds _frida_g_unix_fd_list_peek_fds -#define g_unix_fd_list_steal_fds _frida_g_unix_fd_list_steal_fds -#define g_unix_fd_message_append_fd _frida_g_unix_fd_message_append_fd -#define g_unix_fd_message_get_fd_list _frida_g_unix_fd_message_get_fd_list -#define g_unix_fd_message_get_type _frida_g_unix_fd_message_get_type -#define g_unix_fd_message_new _frida_g_unix_fd_message_new -#define g_unix_fd_message_new_with_fd_list _frida_g_unix_fd_message_new_with_fd_list -#define g_unix_fd_message_steal_fds _frida_g_unix_fd_message_steal_fds -#define g_unix_fd_source_funcs _frida_g_unix_fd_source_funcs -#define g_unix_fd_source_new _frida_g_unix_fd_source_new -#define g_unix_get_passwd_entry _frida_g_unix_get_passwd_entry -#define g_unix_input_stream_get_close_fd _frida_g_unix_input_stream_get_close_fd -#define g_unix_input_stream_get_fd _frida_g_unix_input_stream_get_fd -#define g_unix_input_stream_get_type _frida_g_unix_input_stream_get_type -#define g_unix_input_stream_new _frida_g_unix_input_stream_new -#define g_unix_input_stream_set_close_fd _frida_g_unix_input_stream_set_close_fd -#define g_unix_is_mount_path_system_internal _frida_g_unix_is_mount_path_system_internal -#define g_unix_is_system_device_path _frida_g_unix_is_system_device_path -#define g_unix_is_system_fs_type _frida_g_unix_is_system_fs_type -#define g_unix_mount_at _frida_g_unix_mount_at -#define g_unix_mount_compare _frida_g_unix_mount_compare -#define g_unix_mount_copy _frida_g_unix_mount_copy -#define g_unix_mount_entry_get_type _frida_g_unix_mount_entry_get_type -#define g_unix_mount_for _frida_g_unix_mount_for -#define g_unix_mount_free _frida_g_unix_mount_free -#define g_unix_mount_get_device_path _frida_g_unix_mount_get_device_path -#define g_unix_mount_get_fs_type _frida_g_unix_mount_get_fs_type -#define g_unix_mount_get_mount_path _frida_g_unix_mount_get_mount_path -#define g_unix_mount_get_options _frida_g_unix_mount_get_options -#define g_unix_mount_get_root_path _frida_g_unix_mount_get_root_path -#define g_unix_mount_guess_can_eject _frida_g_unix_mount_guess_can_eject -#define g_unix_mount_guess_icon _frida_g_unix_mount_guess_icon -#define g_unix_mount_guess_name _frida_g_unix_mount_guess_name -#define g_unix_mount_guess_should_display _frida_g_unix_mount_guess_should_display -#define g_unix_mount_guess_symbolic_icon _frida_g_unix_mount_guess_symbolic_icon -#define g_unix_mount_is_readonly _frida_g_unix_mount_is_readonly -#define g_unix_mount_is_system_internal _frida_g_unix_mount_is_system_internal -#define g_unix_mount_monitor_get _frida_g_unix_mount_monitor_get -#define g_unix_mount_monitor_get_type _frida_g_unix_mount_monitor_get_type -#define g_unix_mount_monitor_new _frida_g_unix_mount_monitor_new -#define g_unix_mount_monitor_set_rate_limit _frida_g_unix_mount_monitor_set_rate_limit -#define g_unix_mount_point_at _frida_g_unix_mount_point_at -#define g_unix_mount_point_compare _frida_g_unix_mount_point_compare -#define g_unix_mount_point_copy _frida_g_unix_mount_point_copy -#define g_unix_mount_point_free _frida_g_unix_mount_point_free -#define g_unix_mount_point_get_device_path _frida_g_unix_mount_point_get_device_path -#define g_unix_mount_point_get_fs_type _frida_g_unix_mount_point_get_fs_type -#define g_unix_mount_point_get_mount_path _frida_g_unix_mount_point_get_mount_path -#define g_unix_mount_point_get_options _frida_g_unix_mount_point_get_options -#define g_unix_mount_point_get_type _frida_g_unix_mount_point_get_type -#define g_unix_mount_point_guess_can_eject _frida_g_unix_mount_point_guess_can_eject -#define g_unix_mount_point_guess_icon _frida_g_unix_mount_point_guess_icon -#define g_unix_mount_point_guess_name _frida_g_unix_mount_point_guess_name -#define g_unix_mount_point_guess_symbolic_icon _frida_g_unix_mount_point_guess_symbolic_icon -#define g_unix_mount_point_is_loopback _frida_g_unix_mount_point_is_loopback -#define g_unix_mount_point_is_readonly _frida_g_unix_mount_point_is_readonly -#define g_unix_mount_point_is_user_mountable _frida_g_unix_mount_point_is_user_mountable -#define g_unix_mount_points_changed_since _frida_g_unix_mount_points_changed_since -#define g_unix_mount_points_get _frida_g_unix_mount_points_get -#define g_unix_mounts_changed_since _frida_g_unix_mounts_changed_since -#define g_unix_mounts_get _frida_g_unix_mounts_get -#define g_unix_open_pipe _frida_g_unix_open_pipe -#define g_unix_output_stream_get_close_fd _frida_g_unix_output_stream_get_close_fd -#define g_unix_output_stream_get_fd _frida_g_unix_output_stream_get_fd -#define g_unix_output_stream_get_type _frida_g_unix_output_stream_get_type -#define g_unix_output_stream_new _frida_g_unix_output_stream_new -#define g_unix_output_stream_set_close_fd _frida_g_unix_output_stream_set_close_fd -#define g_unix_set_fd_nonblocking _frida_g_unix_set_fd_nonblocking -#define g_unix_signal_add _frida_g_unix_signal_add -#define g_unix_signal_add_full _frida_g_unix_signal_add_full -#define g_unix_signal_funcs _frida_g_unix_signal_funcs -#define g_unix_signal_source_new _frida_g_unix_signal_source_new -#define g_unix_socket_address_abstract_names_supported _frida_g_unix_socket_address_abstract_names_supported -#define g_unix_socket_address_get_address_type _frida_g_unix_socket_address_get_address_type -#define g_unix_socket_address_get_is_abstract _frida_g_unix_socket_address_get_is_abstract -#define g_unix_socket_address_get_path _frida_g_unix_socket_address_get_path -#define g_unix_socket_address_get_path_len _frida_g_unix_socket_address_get_path_len -#define g_unix_socket_address_get_type _frida_g_unix_socket_address_get_type -#define g_unix_socket_address_new _frida_g_unix_socket_address_new -#define g_unix_socket_address_new_abstract _frida_g_unix_socket_address_new_abstract -#define g_unix_socket_address_new_with_type _frida_g_unix_socket_address_new_with_type -#define g_unix_socket_address_type_get_type _frida_g_unix_socket_address_type_get_type -#define g_unlink _frida_g_unlink -#define g_unsetenv _frida_g_unsetenv -#define g_uri_build _frida_g_uri_build -#define g_uri_build_with_user _frida_g_uri_build_with_user -#define g_uri_error_quark _frida_g_uri_error_quark -#define g_uri_escape_bytes _frida_g_uri_escape_bytes -#define g_uri_escape_string _frida_g_uri_escape_string -#define g_uri_get_auth_params _frida_g_uri_get_auth_params -#define g_uri_get_flags _frida_g_uri_get_flags -#define g_uri_get_fragment _frida_g_uri_get_fragment -#define g_uri_get_host _frida_g_uri_get_host -#define g_uri_get_password _frida_g_uri_get_password -#define g_uri_get_path _frida_g_uri_get_path -#define g_uri_get_port _frida_g_uri_get_port -#define g_uri_get_query _frida_g_uri_get_query -#define g_uri_get_scheme _frida_g_uri_get_scheme -#define g_uri_get_type _frida_g_uri_get_type -#define g_uri_get_user _frida_g_uri_get_user -#define g_uri_get_userinfo _frida_g_uri_get_userinfo -#define g_uri_is_valid _frida_g_uri_is_valid -#define g_uri_join _frida_g_uri_join -#define g_uri_join_with_user _frida_g_uri_join_with_user -#define g_uri_list_extract_uris _frida_g_uri_list_extract_uris -#define g_uri_params_iter_init _frida_g_uri_params_iter_init -#define g_uri_params_iter_next _frida_g_uri_params_iter_next -#define g_uri_parse _frida_g_uri_parse -#define g_uri_parse_params _frida_g_uri_parse_params -#define g_uri_parse_relative _frida_g_uri_parse_relative -#define g_uri_parse_scheme _frida_g_uri_parse_scheme -#define g_uri_peek_scheme _frida_g_uri_peek_scheme -#define g_uri_ref _frida_g_uri_ref -#define g_uri_resolve_relative _frida_g_uri_resolve_relative -#define g_uri_split _frida_g_uri_split -#define g_uri_split_network _frida_g_uri_split_network -#define g_uri_split_with_user _frida_g_uri_split_with_user -#define g_uri_to_string _frida_g_uri_to_string -#define g_uri_to_string_partial _frida_g_uri_to_string_partial -#define g_uri_unescape_bytes _frida_g_uri_unescape_bytes -#define g_uri_unescape_segment _frida_g_uri_unescape_segment -#define g_uri_unescape_string _frida_g_uri_unescape_string -#define g_uri_unref _frida_g_uri_unref -#define g_usleep _frida_g_usleep -#define g_utf16_to_ucs4 _frida_g_utf16_to_ucs4 -#define g_utf16_to_utf8 _frida_g_utf16_to_utf8 -#define g_utf8_casefold _frida_g_utf8_casefold -#define g_utf8_collate _frida_g_utf8_collate -#define g_utf8_collate_key _frida_g_utf8_collate_key -#define g_utf8_collate_key_for_filename _frida_g_utf8_collate_key_for_filename -#define g_utf8_find_next_char _frida_g_utf8_find_next_char -#define g_utf8_find_prev_char _frida_g_utf8_find_prev_char -#define g_utf8_get_char _frida_g_utf8_get_char -#define g_utf8_get_char_validated _frida_g_utf8_get_char_validated -#define g_utf8_make_valid _frida_g_utf8_make_valid -#define g_utf8_normalize _frida_g_utf8_normalize -#define g_utf8_offset_to_pointer _frida_g_utf8_offset_to_pointer -#define g_utf8_pointer_to_offset _frida_g_utf8_pointer_to_offset -#define g_utf8_prev_char _frida_g_utf8_prev_char -#define g_utf8_skip _frida_g_utf8_skip -#define g_utf8_strchr _frida_g_utf8_strchr -#define g_utf8_strdown _frida_g_utf8_strdown -#define g_utf8_strlen _frida_g_utf8_strlen -#define g_utf8_strncpy _frida_g_utf8_strncpy -#define g_utf8_strrchr _frida_g_utf8_strrchr -#define g_utf8_strreverse _frida_g_utf8_strreverse -#define g_utf8_strup _frida_g_utf8_strup -#define g_utf8_substring _frida_g_utf8_substring -#define g_utf8_to_ucs4 _frida_g_utf8_to_ucs4 -#define g_utf8_to_ucs4_fast _frida_g_utf8_to_ucs4_fast -#define g_utf8_to_utf16 _frida_g_utf8_to_utf16 -#define g_utf8_validate _frida_g_utf8_validate -#define g_utf8_validate_len _frida_g_utf8_validate_len -#define g_utime _frida_g_utime -#define g_uuid_string_is_valid _frida_g_uuid_string_is_valid -#define g_uuid_string_random _frida_g_uuid_string_random -#define g_value_array_append _frida_g_value_array_append -#define g_value_array_copy _frida_g_value_array_copy -#define g_value_array_free _frida_g_value_array_free -#define g_value_array_get_nth _frida_g_value_array_get_nth -#define g_value_array_get_type _frida_g_value_array_get_type -#define g_value_array_insert _frida_g_value_array_insert -#define g_value_array_new _frida_g_value_array_new -#define g_value_array_prepend _frida_g_value_array_prepend -#define g_value_array_remove _frida_g_value_array_remove -#define g_value_array_sort _frida_g_value_array_sort -#define g_value_array_sort_with_data _frida_g_value_array_sort_with_data -#define g_value_copy _frida_g_value_copy -#define g_value_dup_boxed _frida_g_value_dup_boxed -#define g_value_dup_object _frida_g_value_dup_object -#define g_value_dup_param _frida_g_value_dup_param -#define g_value_dup_string _frida_g_value_dup_string -#define g_value_dup_variant _frida_g_value_dup_variant -#define g_value_fits_pointer _frida_g_value_fits_pointer -#define g_value_get_boolean _frida_g_value_get_boolean -#define g_value_get_boxed _frida_g_value_get_boxed -#define g_value_get_char _frida_g_value_get_char -#define g_value_get_double _frida_g_value_get_double -#define g_value_get_enum _frida_g_value_get_enum -#define g_value_get_flags _frida_g_value_get_flags -#define g_value_get_float _frida_g_value_get_float -#define g_value_get_gtype _frida_g_value_get_gtype -#define g_value_get_int _frida_g_value_get_int -#define g_value_get_int64 _frida_g_value_get_int64 -#define g_value_get_long _frida_g_value_get_long -#define g_value_get_object _frida_g_value_get_object -#define g_value_get_param _frida_g_value_get_param -#define g_value_get_pointer _frida_g_value_get_pointer -#define g_value_get_schar _frida_g_value_get_schar -#define g_value_get_string _frida_g_value_get_string -#define g_value_get_type _frida_g_value_get_type -#define g_value_get_uchar _frida_g_value_get_uchar -#define g_value_get_uint _frida_g_value_get_uint -#define g_value_get_uint64 _frida_g_value_get_uint64 -#define g_value_get_ulong _frida_g_value_get_ulong -#define g_value_get_variant _frida_g_value_get_variant -#define g_value_init _frida_g_value_init -#define g_value_init_from_instance _frida_g_value_init_from_instance -#define g_value_peek_pointer _frida_g_value_peek_pointer -#define g_value_register_transform_func _frida_g_value_register_transform_func -#define g_value_reset _frida_g_value_reset -#define g_value_set_boolean _frida_g_value_set_boolean -#define g_value_set_boxed _frida_g_value_set_boxed -#define g_value_set_boxed_take_ownership _frida_g_value_set_boxed_take_ownership -#define g_value_set_char _frida_g_value_set_char -#define g_value_set_double _frida_g_value_set_double -#define g_value_set_enum _frida_g_value_set_enum -#define g_value_set_flags _frida_g_value_set_flags -#define g_value_set_float _frida_g_value_set_float -#define g_value_set_gtype _frida_g_value_set_gtype -#define g_value_set_instance _frida_g_value_set_instance -#define g_value_set_int _frida_g_value_set_int -#define g_value_set_int64 _frida_g_value_set_int64 -#define g_value_set_interned_string _frida_g_value_set_interned_string -#define g_value_set_long _frida_g_value_set_long -#define g_value_set_object _frida_g_value_set_object -#define g_value_set_object_take_ownership _frida_g_value_set_object_take_ownership -#define g_value_set_param _frida_g_value_set_param -#define g_value_set_param_take_ownership _frida_g_value_set_param_take_ownership -#define g_value_set_pointer _frida_g_value_set_pointer -#define g_value_set_schar _frida_g_value_set_schar -#define g_value_set_static_boxed _frida_g_value_set_static_boxed -#define g_value_set_static_string _frida_g_value_set_static_string -#define g_value_set_string _frida_g_value_set_string -#define g_value_set_string_take_ownership _frida_g_value_set_string_take_ownership -#define g_value_set_uchar _frida_g_value_set_uchar -#define g_value_set_uint _frida_g_value_set_uint -#define g_value_set_uint64 _frida_g_value_set_uint64 -#define g_value_set_ulong _frida_g_value_set_ulong -#define g_value_set_variant _frida_g_value_set_variant -#define g_value_take_boxed _frida_g_value_take_boxed -#define g_value_take_object _frida_g_value_take_object -#define g_value_take_param _frida_g_value_take_param -#define g_value_take_string _frida_g_value_take_string -#define g_value_take_variant _frida_g_value_take_variant -#define g_value_transform _frida_g_value_transform -#define g_value_type_compatible _frida_g_value_type_compatible -#define g_value_type_transformable _frida_g_value_type_transformable -#define g_value_unset _frida_g_value_unset -#define g_variant_builder_add _frida_g_variant_builder_add -#define g_variant_builder_add_parsed _frida_g_variant_builder_add_parsed -#define g_variant_builder_add_value _frida_g_variant_builder_add_value -#define g_variant_builder_clear _frida_g_variant_builder_clear -#define g_variant_builder_close _frida_g_variant_builder_close -#define g_variant_builder_end _frida_g_variant_builder_end -#define g_variant_builder_get_type _frida_g_variant_builder_get_type -#define g_variant_builder_init _frida_g_variant_builder_init -#define g_variant_builder_new _frida_g_variant_builder_new -#define g_variant_builder_open _frida_g_variant_builder_open -#define g_variant_builder_ref _frida_g_variant_builder_ref -#define g_variant_builder_unref _frida_g_variant_builder_unref -#define g_variant_byteswap _frida_g_variant_byteswap -#define g_variant_check_format_string _frida_g_variant_check_format_string -#define g_variant_classify _frida_g_variant_classify -#define g_variant_compare _frida_g_variant_compare -#define g_variant_dict_clear _frida_g_variant_dict_clear -#define g_variant_dict_contains _frida_g_variant_dict_contains -#define g_variant_dict_end _frida_g_variant_dict_end -#define g_variant_dict_get_type _frida_g_variant_dict_get_type -#define g_variant_dict_init _frida_g_variant_dict_init -#define g_variant_dict_insert _frida_g_variant_dict_insert -#define g_variant_dict_insert_value _frida_g_variant_dict_insert_value -#define g_variant_dict_lookup _frida_g_variant_dict_lookup -#define g_variant_dict_lookup_value _frida_g_variant_dict_lookup_value -#define g_variant_dict_new _frida_g_variant_dict_new -#define g_variant_dict_ref _frida_g_variant_dict_ref -#define g_variant_dict_remove _frida_g_variant_dict_remove -#define g_variant_dict_unref _frida_g_variant_dict_unref -#define g_variant_dup_bytestring _frida_g_variant_dup_bytestring -#define g_variant_dup_bytestring_array _frida_g_variant_dup_bytestring_array -#define g_variant_dup_objv _frida_g_variant_dup_objv -#define g_variant_dup_string _frida_g_variant_dup_string -#define g_variant_dup_strv _frida_g_variant_dup_strv -#define g_variant_equal _frida_g_variant_equal -#define g_variant_format_string_scan _frida_g_variant_format_string_scan -#define g_variant_format_string_scan_type _frida_g_variant_format_string_scan_type -#define g_variant_get _frida_g_variant_get -#define g_variant_get_boolean _frida_g_variant_get_boolean -#define g_variant_get_byte _frida_g_variant_get_byte -#define g_variant_get_bytestring _frida_g_variant_get_bytestring -#define g_variant_get_bytestring_array _frida_g_variant_get_bytestring_array -#define g_variant_get_child _frida_g_variant_get_child -#define g_variant_get_child_value _frida_g_variant_get_child_value -#define g_variant_get_data _frida_g_variant_get_data -#define g_variant_get_data_as_bytes _frida_g_variant_get_data_as_bytes -#define g_variant_get_depth _frida_g_variant_get_depth -#define g_variant_get_double _frida_g_variant_get_double -#define g_variant_get_fixed_array _frida_g_variant_get_fixed_array -#define g_variant_get_gtype _frida_g_variant_get_gtype -#define g_variant_get_handle _frida_g_variant_get_handle -#define g_variant_get_int16 _frida_g_variant_get_int16 -#define g_variant_get_int32 _frida_g_variant_get_int32 -#define g_variant_get_int64 _frida_g_variant_get_int64 -#define g_variant_get_maybe _frida_g_variant_get_maybe -#define g_variant_get_normal_form _frida_g_variant_get_normal_form -#define g_variant_get_objv _frida_g_variant_get_objv -#define g_variant_get_size _frida_g_variant_get_size -#define g_variant_get_string _frida_g_variant_get_string -#define g_variant_get_strv _frida_g_variant_get_strv -#define g_variant_get_type _frida_g_variant_get_type -#define g_variant_get_type_info _frida_g_variant_get_type_info -#define g_variant_get_type_string _frida_g_variant_get_type_string -#define g_variant_get_uint16 _frida_g_variant_get_uint16 -#define g_variant_get_uint32 _frida_g_variant_get_uint32 -#define g_variant_get_uint64 _frida_g_variant_get_uint64 -#define g_variant_get_va _frida_g_variant_get_va -#define g_variant_get_variant _frida_g_variant_get_variant -#define g_variant_hash _frida_g_variant_hash -#define g_variant_is_container _frida_g_variant_is_container -#define g_variant_is_floating _frida_g_variant_is_floating -#define g_variant_is_normal_form _frida_g_variant_is_normal_form -#define g_variant_is_object_path _frida_g_variant_is_object_path -#define g_variant_is_of_type _frida_g_variant_is_of_type -#define g_variant_is_signature _frida_g_variant_is_signature -#define g_variant_is_trusted _frida_g_variant_is_trusted -#define g_variant_iter_copy _frida_g_variant_iter_copy -#define g_variant_iter_free _frida_g_variant_iter_free -#define g_variant_iter_init _frida_g_variant_iter_init -#define g_variant_iter_loop _frida_g_variant_iter_loop -#define g_variant_iter_n_children _frida_g_variant_iter_n_children -#define g_variant_iter_new _frida_g_variant_iter_new -#define g_variant_iter_next _frida_g_variant_iter_next -#define g_variant_iter_next_value _frida_g_variant_iter_next_value -#define g_variant_lookup _frida_g_variant_lookup -#define g_variant_lookup_value _frida_g_variant_lookup_value -#define g_variant_n_children _frida_g_variant_n_children -#define g_variant_new _frida_g_variant_new -#define g_variant_new_array _frida_g_variant_new_array -#define g_variant_new_boolean _frida_g_variant_new_boolean -#define g_variant_new_byte _frida_g_variant_new_byte -#define g_variant_new_bytestring _frida_g_variant_new_bytestring -#define g_variant_new_bytestring_array _frida_g_variant_new_bytestring_array -#define g_variant_new_dict_entry _frida_g_variant_new_dict_entry -#define g_variant_new_double _frida_g_variant_new_double -#define g_variant_new_fixed_array _frida_g_variant_new_fixed_array -#define g_variant_new_from_bytes _frida_g_variant_new_from_bytes -#define g_variant_new_from_children _frida_g_variant_new_from_children -#define g_variant_new_from_data _frida_g_variant_new_from_data -#define g_variant_new_handle _frida_g_variant_new_handle -#define g_variant_new_int16 _frida_g_variant_new_int16 -#define g_variant_new_int32 _frida_g_variant_new_int32 -#define g_variant_new_int64 _frida_g_variant_new_int64 -#define g_variant_new_maybe _frida_g_variant_new_maybe -#define g_variant_new_object_path _frida_g_variant_new_object_path -#define g_variant_new_objv _frida_g_variant_new_objv -#define g_variant_new_parsed _frida_g_variant_new_parsed -#define g_variant_new_parsed_va _frida_g_variant_new_parsed_va -#define g_variant_new_printf _frida_g_variant_new_printf -#define g_variant_new_signature _frida_g_variant_new_signature -#define g_variant_new_string _frida_g_variant_new_string -#define g_variant_new_strv _frida_g_variant_new_strv -#define g_variant_new_take_string _frida_g_variant_new_take_string -#define g_variant_new_tuple _frida_g_variant_new_tuple -#define g_variant_new_uint16 _frida_g_variant_new_uint16 -#define g_variant_new_uint32 _frida_g_variant_new_uint32 -#define g_variant_new_uint64 _frida_g_variant_new_uint64 -#define g_variant_new_va _frida_g_variant_new_va -#define g_variant_new_variant _frida_g_variant_new_variant -#define g_variant_parse _frida_g_variant_parse -#define g_variant_parse_error_print_context _frida_g_variant_parse_error_print_context -#define g_variant_parse_error_quark _frida_g_variant_parse_error_quark -#define g_variant_parser_get_error_quark _frida_g_variant_parser_get_error_quark -#define g_variant_print _frida_g_variant_print -#define g_variant_print_string _frida_g_variant_print_string -#define g_variant_ref _frida_g_variant_ref -#define g_variant_ref_sink _frida_g_variant_ref_sink -#define g_variant_serialised_byteswap _frida_g_variant_serialised_byteswap -#define g_variant_serialised_check _frida_g_variant_serialised_check -#define g_variant_serialised_get_child _frida_g_variant_serialised_get_child -#define g_variant_serialised_is_normal _frida_g_variant_serialised_is_normal -#define g_variant_serialised_n_children _frida_g_variant_serialised_n_children -#define g_variant_serialiser_is_object_path _frida_g_variant_serialiser_is_object_path -#define g_variant_serialiser_is_signature _frida_g_variant_serialiser_is_signature -#define g_variant_serialiser_is_string _frida_g_variant_serialiser_is_string -#define g_variant_serialiser_needed_size _frida_g_variant_serialiser_needed_size -#define g_variant_serialiser_serialise _frida_g_variant_serialiser_serialise -#define g_variant_store _frida_g_variant_store -#define g_variant_take_ref _frida_g_variant_take_ref -#define g_variant_type_checked_ _frida_g_variant_type_checked_ -#define g_variant_type_copy _frida_g_variant_type_copy -#define g_variant_type_dup_string _frida_g_variant_type_dup_string -#define g_variant_type_element _frida_g_variant_type_element -#define g_variant_type_equal _frida_g_variant_type_equal -#define g_variant_type_first _frida_g_variant_type_first -#define g_variant_type_free _frida_g_variant_type_free -#define g_variant_type_get_gtype _frida_g_variant_type_get_gtype -#define g_variant_type_get_string_length _frida_g_variant_type_get_string_length -#define g_variant_type_hash _frida_g_variant_type_hash -#define g_variant_type_info_assert_no_infos _frida_g_variant_type_info_assert_no_infos -#define g_variant_type_info_element _frida_g_variant_type_info_element -#define g_variant_type_info_get _frida_g_variant_type_info_get -#define g_variant_type_info_get_type_string _frida_g_variant_type_info_get_type_string -#define g_variant_type_info_member_info _frida_g_variant_type_info_member_info -#define g_variant_type_info_n_members _frida_g_variant_type_info_n_members -#define g_variant_type_info_query _frida_g_variant_type_info_query -#define g_variant_type_info_query_depth _frida_g_variant_type_info_query_depth -#define g_variant_type_info_query_element _frida_g_variant_type_info_query_element -#define g_variant_type_info_ref _frida_g_variant_type_info_ref -#define g_variant_type_info_unref _frida_g_variant_type_info_unref -#define g_variant_type_is_array _frida_g_variant_type_is_array -#define g_variant_type_is_basic _frida_g_variant_type_is_basic -#define g_variant_type_is_container _frida_g_variant_type_is_container -#define g_variant_type_is_definite _frida_g_variant_type_is_definite -#define g_variant_type_is_dict_entry _frida_g_variant_type_is_dict_entry -#define g_variant_type_is_maybe _frida_g_variant_type_is_maybe -#define g_variant_type_is_subtype_of _frida_g_variant_type_is_subtype_of -#define g_variant_type_is_tuple _frida_g_variant_type_is_tuple -#define g_variant_type_is_variant _frida_g_variant_type_is_variant -#define g_variant_type_key _frida_g_variant_type_key -#define g_variant_type_n_items _frida_g_variant_type_n_items -#define g_variant_type_new _frida_g_variant_type_new -#define g_variant_type_new_array _frida_g_variant_type_new_array -#define g_variant_type_new_dict_entry _frida_g_variant_type_new_dict_entry -#define g_variant_type_new_maybe _frida_g_variant_type_new_maybe -#define g_variant_type_new_tuple _frida_g_variant_type_new_tuple -#define g_variant_type_next _frida_g_variant_type_next -#define g_variant_type_peek_string _frida_g_variant_type_peek_string -#define g_variant_type_string_get_depth_ _frida_g_variant_type_string_get_depth_ -#define g_variant_type_string_is_valid _frida_g_variant_type_string_is_valid -#define g_variant_type_string_scan _frida_g_variant_type_string_scan -#define g_variant_type_value _frida_g_variant_type_value -#define g_variant_unref _frida_g_variant_unref -#define g_vasprintf _frida_g_vasprintf -#define g_vfprintf _frida_g_vfprintf -#define g_vfs_get_default _frida_g_vfs_get_default -#define g_vfs_get_file_for_path _frida_g_vfs_get_file_for_path -#define g_vfs_get_file_for_uri _frida_g_vfs_get_file_for_uri -#define g_vfs_get_local _frida_g_vfs_get_local -#define g_vfs_get_supported_uri_schemes _frida_g_vfs_get_supported_uri_schemes -#define g_vfs_get_type _frida_g_vfs_get_type -#define g_vfs_is_active _frida_g_vfs_is_active -#define g_vfs_parse_name _frida_g_vfs_parse_name -#define g_vfs_register_uri_scheme _frida_g_vfs_register_uri_scheme -#define g_vfs_unregister_uri_scheme _frida_g_vfs_unregister_uri_scheme -#define g_volume_can_eject _frida_g_volume_can_eject -#define g_volume_can_mount _frida_g_volume_can_mount -#define g_volume_eject _frida_g_volume_eject -#define g_volume_eject_finish _frida_g_volume_eject_finish -#define g_volume_eject_with_operation _frida_g_volume_eject_with_operation -#define g_volume_eject_with_operation_finish _frida_g_volume_eject_with_operation_finish -#define g_volume_enumerate_identifiers _frida_g_volume_enumerate_identifiers -#define g_volume_get_activation_root _frida_g_volume_get_activation_root -#define g_volume_get_drive _frida_g_volume_get_drive -#define g_volume_get_icon _frida_g_volume_get_icon -#define g_volume_get_identifier _frida_g_volume_get_identifier -#define g_volume_get_mount _frida_g_volume_get_mount -#define g_volume_get_name _frida_g_volume_get_name -#define g_volume_get_sort_key _frida_g_volume_get_sort_key -#define g_volume_get_symbolic_icon _frida_g_volume_get_symbolic_icon -#define g_volume_get_type _frida_g_volume_get_type -#define g_volume_get_uuid _frida_g_volume_get_uuid -#define g_volume_monitor_adopt_orphan_mount _frida_g_volume_monitor_adopt_orphan_mount -#define g_volume_monitor_get _frida_g_volume_monitor_get -#define g_volume_monitor_get_connected_drives _frida_g_volume_monitor_get_connected_drives -#define g_volume_monitor_get_mount_for_uuid _frida_g_volume_monitor_get_mount_for_uuid -#define g_volume_monitor_get_mounts _frida_g_volume_monitor_get_mounts -#define g_volume_monitor_get_type _frida_g_volume_monitor_get_type -#define g_volume_monitor_get_volume_for_uuid _frida_g_volume_monitor_get_volume_for_uuid -#define g_volume_monitor_get_volumes _frida_g_volume_monitor_get_volumes -#define g_volume_mount _frida_g_volume_mount -#define g_volume_mount_finish _frida_g_volume_mount_finish -#define g_volume_should_automount _frida_g_volume_should_automount -#define g_vprintf _frida_g_vprintf -#define g_vsnprintf _frida_g_vsnprintf -#define g_vsprintf _frida_g_vsprintf -#define g_wakeup_acknowledge _frida_g_wakeup_acknowledge -#define g_wakeup_free _frida_g_wakeup_free -#define g_wakeup_get_pollfd _frida_g_wakeup_get_pollfd -#define g_wakeup_new _frida_g_wakeup_new -#define g_wakeup_signal _frida_g_wakeup_signal -#define g_warn_message _frida_g_warn_message -#define g_weak_ref_clear _frida_g_weak_ref_clear -#define g_weak_ref_get _frida_g_weak_ref_get -#define g_weak_ref_init _frida_g_weak_ref_init -#define g_weak_ref_set _frida_g_weak_ref_set -#define g_zlib_compressor_format_get_type _frida_g_zlib_compressor_format_get_type -#define g_zlib_compressor_get_file_info _frida_g_zlib_compressor_get_file_info -#define g_zlib_compressor_get_type _frida_g_zlib_compressor_get_type -#define g_zlib_compressor_new _frida_g_zlib_compressor_new -#define g_zlib_compressor_set_file_info _frida_g_zlib_compressor_set_file_info -#define g_zlib_decompressor_get_file_info _frida_g_zlib_decompressor_get_file_info -#define g_zlib_decompressor_get_type _frida_g_zlib_decompressor_get_type -#define g_zlib_decompressor_new _frida_g_zlib_decompressor_new -#define gio_deinit _frida_gio_deinit -#define gio_init _frida_gio_init -#define gio_prepare_to_fork _frida_gio_prepare_to_fork -#define gio_recover_from_fork_in_child _frida_gio_recover_from_fork_in_child -#define gio_recover_from_fork_in_parent _frida_gio_recover_from_fork_in_parent -#define gio_shutdown _frida_gio_shutdown -#define glib__private__ _frida_glib__private__ -#define glib_binary_age _frida_glib_binary_age -#define glib_check_version _frida_glib_check_version -#define glib_deinit _frida_glib_deinit -#define glib_fd_callbacks _frida_glib_fd_callbacks -#define glib_gettext _frida_glib_gettext -#define glib_has_dconf_access_in_sandbox _frida_glib_has_dconf_access_in_sandbox -#define glib_init _frida_glib_init -#define glib_interface_age _frida_glib_interface_age -#define glib_major_version _frida_glib_major_version -#define glib_mem_profiler_table _frida_glib_mem_profiler_table -#define glib_mem_table _frida_glib_mem_table -#define glib_micro_version _frida_glib_micro_version -#define glib_minor_version _frida_glib_minor_version -#define glib_network_available_in_sandbox _frida_glib_network_available_in_sandbox -#define glib_on_error_halt _frida_glib_on_error_halt -#define glib_pgettext _frida_glib_pgettext -#define glib_prepare_to_fork _frida_glib_prepare_to_fork -#define glib_recover_from_fork_in_child _frida_glib_recover_from_fork_in_child -#define glib_recover_from_fork_in_parent _frida_glib_recover_from_fork_in_parent -#define glib_should_use_portal _frida_glib_should_use_portal -#define glib_shutdown _frida_glib_shutdown -#define glib_thread_callbacks _frida_glib_thread_callbacks -#define gobject_init _frida_gobject_init - -#endif - -/* - * Copyright (C) 2008-2019 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_H__ -#define __GUM_H__ - -/* - * Copyright (C) 2008-2020 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUMDEFS_H__ -#define __GUMDEFS_H__ - - -/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ - -#ifndef __GUM_ENUM_TYPES_H__ -#define __GUM_ENUM_TYPES_H__ - -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 1998, 1999, 2000 Tim Janik and Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __GLIB_GOBJECT_H__ -#define __GLIB_GOBJECT_H__ - -#define __GLIB_GOBJECT_H_INSIDE__ - -/* gbinding.h: Binding for object properties - * - * Copyright (C) 2010 Intel Corp. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - * - * Author: Emmanuele Bassi - */ - -#ifndef __G_BINDING_H__ -#define __G_BINDING_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_LIB_H__ -#define __G_LIB_H__ - -#define __GLIB_H_INSIDE__ - -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_ALLOCA_H__ -#define __G_ALLOCA_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_TYPES_H__ -#define __G_TYPES_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* glibconfig.h - * - * This is a generated file. Please modify 'glibconfig.h.in' - */ - -#ifndef __GLIBCONFIG_H__ -#define __GLIBCONFIG_H__ - -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -/* This file must not include any other glib header file and must thus - * not refer to variables from glibconfig.h - */ - -#ifndef __G_MACROS_H__ -#define __G_MACROS_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* We include stddef.h to get the system's definition of NULL - */ -#include - -#ifdef __GNUC__ -#define G_GNUC_CHECK_VERSION(major, minor) \ - ((__GNUC__ > (major)) || \ - ((__GNUC__ == (major)) && \ - (__GNUC_MINOR__ >= (minor)))) -#else -#define G_GNUC_CHECK_VERSION(major, minor) 0 -#endif - -/* Here we provide G_GNUC_EXTENSION as an alias for __extension__, - * where this is valid. This allows for warningless compilation of - * "long long" types even in the presence of '-ansi -pedantic'. - */ -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8) -#define G_GNUC_EXTENSION __extension__ -#else -#define G_GNUC_EXTENSION -#endif - -/* Every compiler that we target supports inlining, but some of them may - * complain about it if we don't say "__inline". If we have C99, or if - * we are using C++, then we can use "inline" directly. Unfortunately - * Visual Studio does not support __STDC_VERSION__, so we need to check - * whether we are on Visual Studio 2013 or earlier to see that we need to - * say "__inline" in C mode. - * Otherwise, we say "__inline" to avoid the warning. - */ -#define G_CAN_INLINE -#ifndef __cplusplus -# ifdef _MSC_VER -# if (_MSC_VER < 1900) -# define G_INLINE_DEFINE_NEEDED -# endif -# elif !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199900) -# define G_INLINE_DEFINE_NEEDED -# endif -#endif - -#ifdef G_INLINE_DEFINE_NEEDED -# undef inline -# define inline __inline -#endif - -#undef G_INLINE_DEFINE_NEEDED - -/** - * G_INLINE_FUNC: - * - * This macro used to be used to conditionally define inline functions - * in a compatible way before this feature was supported in all - * compilers. These days, GLib requires inlining support from the - * compiler, so your GLib-using programs can safely assume that the - * "inline" keyword works properly. - * - * Never use this macro anymore. Just say "static inline". - * - * Deprecated: 2.48: Use "static inline" instead - */ - -/* For historical reasons we need to continue to support those who - * define G_IMPLEMENT_INLINES to mean "don't implement this here". - */ -#ifdef G_IMPLEMENT_INLINES -# define G_INLINE_FUNC extern GLIB_DEPRECATED_MACRO_IN_2_48_FOR(static inline) -# undef G_CAN_INLINE -#else -# define G_INLINE_FUNC static inline GLIB_DEPRECATED_MACRO_IN_2_48_FOR(static inline) -#endif /* G_IMPLEMENT_INLINES */ - -/* Provide macros to feature the GCC function attribute. - */ - -/** - * G_GNUC_PURE: - * - * Expands to the GNU C `pure` function attribute if the compiler is gcc. - * Declaring a function as `pure` enables better optimization of calls to - * the function. A `pure` function has no effects except its return value - * and the return value depends only on the parameters and/or global - * variables. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * gboolean g_type_check_value (const GValue *value) G_GNUC_PURE; - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute) for more details. - */ - -/** - * G_GNUC_MALLOC: - * - * Expands to the - * [GNU C `malloc` function attribute](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-functions-that-behave-like-malloc) - * if the compiler is gcc. - * Declaring a function as `malloc` enables better optimization of the function, - * but must only be done if the allocation behaviour of the function is fully - * understood, otherwise miscompilation can result. - * - * A function can have the `malloc` attribute if it returns a pointer which is - * guaranteed to not alias with any other pointer valid when the function - * returns, and moreover no pointers to valid objects occur in any storage - * addressed by the returned pointer. - * - * In practice, this means that `G_GNUC_MALLOC` can be used with any function - * which returns unallocated or zeroed-out memory, but not with functions which - * return initialised structures containing other pointers, or with functions - * that reallocate memory. This definition changed in GLib 2.58 to match the - * stricter definition introduced around GCC 5. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); - * ]| - * - * See the - * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-functions-that-behave-like-malloc) - * for more details. - * - * Since: 2.6 - */ - -/** - * G_GNUC_NO_INLINE: - * - * Expands to the GNU C `noinline` function attribute if the compiler is gcc. - * If the compiler is not gcc, this macro expands to nothing. - * - * Declaring a function as `noinline` prevents the function from being - * considered for inlining. - * - * The attribute may be placed before the declaration or definition, - * right before the `static` keyword. - * - * |[ - * G_GNUC_NO_INLINE - * static int - * do_not_inline_this (void) - * { - * ... - * } - * ]| - * - * See the - * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute) - * for more details. - * - * Since: 2.58 - */ - -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) -#define G_GNUC_PURE __attribute__((__pure__)) -#define G_GNUC_MALLOC __attribute__((__malloc__)) -#define G_GNUC_NO_INLINE __attribute__((noinline)) -#else -#define G_GNUC_PURE -#define G_GNUC_MALLOC -#define G_GNUC_NO_INLINE -#endif - -/** - * G_GNUC_NULL_TERMINATED: - * - * Expands to the GNU C `sentinel` function attribute if the compiler is gcc. - * This function attribute only applies to variadic functions and instructs - * the compiler to check that the argument list is terminated with an - * explicit %NULL. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * gchar *g_strconcat (const gchar *string1, - * ...) G_GNUC_NULL_TERMINATED; - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-sentinel-function-attribute) for more details. - * - * Since: 2.8 - */ -#if __GNUC__ >= 4 -#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) -#else -#define G_GNUC_NULL_TERMINATED -#endif - -/* - * We can only use __typeof__ on GCC >= 4.8, and not when compiling C++. Since - * __typeof__ is used in a few places in GLib, provide a pre-processor symbol - * to factor the check out from callers. - * - * This symbol is private. - */ -#undef glib_typeof -#if !defined(__cplusplus) && \ - ((defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) || \ - defined(__clang__)) -#define glib_typeof(t) __typeof__ (t) -#endif - -/* - * Clang feature detection: http://clang.llvm.org/docs/LanguageExtensions.html - * These are not available on GCC, but since the pre-processor doesn't do - * operator short-circuiting, we can't use it in a statement or we'll get: - * - * error: missing binary operator before token "(" - * - * So we define it to 0 to satisfy the pre-processor. - */ - -#ifdef __has_attribute -#define g_macro__has_attribute __has_attribute -#else -#define g_macro__has_attribute(x) 0 -#endif - -#ifdef __has_feature -#define g_macro__has_feature __has_feature -#else -#define g_macro__has_feature(x) 0 -#endif - -#ifdef __has_builtin -#define g_macro__has_builtin __has_builtin -#else -#define g_macro__has_builtin(x) 0 -#endif - -/** - * G_GNUC_ALLOC_SIZE: - * @x: the index of the argument specifying the allocation size - * - * Expands to the GNU C `alloc_size` function attribute if the compiler - * is a new enough gcc. This attribute tells the compiler that the - * function returns a pointer to memory of a size that is specified - * by the @xth function parameter. - * - * Place the attribute after the function declaration, just before the - * semicolon. - * - * |[ - * gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute) for more details. - * - * Since: 2.18 - */ - -/** - * G_GNUC_ALLOC_SIZE2: - * @x: the index of the argument specifying one factor of the allocation size - * @y: the index of the argument specifying the second factor of the allocation size - * - * Expands to the GNU C `alloc_size` function attribute if the compiler is a - * new enough gcc. This attribute tells the compiler that the function returns - * a pointer to memory of a size that is specified by the product of two - * function parameters. - * - * Place the attribute after the function declaration, just before the - * semicolon. - * - * |[ - * gpointer g_malloc_n (gsize n_blocks, - * gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1, 2); - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alloc_005fsize-function-attribute) for more details. - * - * Since: 2.18 - */ -#if (!defined(__clang__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ - (defined(__clang__) && g_macro__has_attribute(__alloc_size__)) -#define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) -#define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y))) -#else -#define G_GNUC_ALLOC_SIZE(x) -#define G_GNUC_ALLOC_SIZE2(x,y) -#endif - -/** - * G_GNUC_PRINTF: - * @format_idx: the index of the argument corresponding to the - * format string (the arguments are numbered from 1) - * @arg_idx: the index of the first of the format arguments, or 0 if - * there are no format arguments - * - * Expands to the GNU C `format` function attribute if the compiler is gcc. - * This is used for declaring functions which take a variable number of - * arguments, with the same syntax as `printf()`. It allows the compiler - * to type-check the arguments passed to the function. - * - * Place the attribute after the function declaration, just before the - * semicolon. - * - * See the - * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) - * for more details. - * - * |[ - * gint g_snprintf (gchar *string, - * gulong n, - * gchar const *format, - * ...) G_GNUC_PRINTF (3, 4); - * ]| - */ - -/** - * G_GNUC_SCANF: - * @format_idx: the index of the argument corresponding to - * the format string (the arguments are numbered from 1) - * @arg_idx: the index of the first of the format arguments, or 0 if - * there are no format arguments - * - * Expands to the GNU C `format` function attribute if the compiler is gcc. - * This is used for declaring functions which take a variable number of - * arguments, with the same syntax as `scanf()`. It allows the compiler - * to type-check the arguments passed to the function. - * - * |[ - * int my_scanf (MyStream *stream, - * const char *format, - * ...) G_GNUC_SCANF (2, 3); - * int my_vscanf (MyStream *stream, - * const char *format, - * va_list ap) G_GNUC_SCANF (2, 0); - * ]| - * - * See the - * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) - * for details. - */ - -/** - * G_GNUC_STRFTIME: - * @format_idx: the index of the argument corresponding to - * the format string (the arguments are numbered from 1) - * - * Expands to the GNU C `strftime` format function attribute if the compiler - * is gcc. This is used for declaring functions which take a format argument - * which is passed to `strftime()` or an API implementing its formats. It allows - * the compiler check the format passed to the function. - * - * |[ - * gsize my_strftime (MyBuffer *buffer, - * const char *format, - * const struct tm *tm) G_GNUC_STRFTIME (2); - * ]| - * - * See the - * [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-3288) - * for details. - * - * Since: 2.60 - */ - -/** - * G_GNUC_FORMAT: - * @arg_idx: the index of the argument - * - * Expands to the GNU C `format_arg` function attribute if the compiler - * is gcc. This function attribute specifies that a function takes a - * format string for a `printf()`, `scanf()`, `strftime()` or `strfmon()` style - * function and modifies it, so that the result can be passed to a `printf()`, - * `scanf()`, `strftime()` or `strfmon()` style function (with the remaining - * arguments to the format function the same as they would have been - * for the unmodified string). - * - * Place the attribute after the function declaration, just before the - * semicolon. - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-Wformat-nonliteral-1) for more details. - * - * |[ - * gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2); - * ]| - */ - -/** - * G_GNUC_NORETURN: - * - * Expands to the GNU C `noreturn` function attribute if the compiler is gcc. - * It is used for declaring functions which never return. It enables - * optimization of the function, and avoids possible compiler warnings. - * - * Since 2.68, it is recommended that code uses %G_NORETURN instead of - * %G_GNUC_NORETURN, as that works on more platforms and compilers (in - * particular, MSVC and C++11) than %G_GNUC_NORETURN, which works with GCC and - * Clang only. %G_GNUC_NORETURN continues to work, so has not been deprecated - * yet. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * void g_abort (void) G_GNUC_NORETURN; - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute) for more details. - */ - -/** - * G_GNUC_CONST: - * - * Expands to the GNU C `const` function attribute if the compiler is gcc. - * Declaring a function as `const` enables better optimization of calls to - * the function. A `const` function doesn't examine any values except its - * parameters, and has no effects except its return value. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * gchar g_ascii_tolower (gchar c) G_GNUC_CONST; - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute) for more details. - * - * A function that has pointer arguments and examines the data pointed to - * must not be declared `const`. Likewise, a function that calls a non-`const` - * function usually must not be `const`. It doesn't make sense for a `const` - * function to return `void`. - */ - -/** - * G_GNUC_UNUSED: - * - * Expands to the GNU C `unused` function attribute if the compiler is gcc. - * It is used for declaring functions and arguments which may never be used. - * It avoids possible compiler warnings. - * - * For functions, place the attribute after the declaration, just before the - * semicolon. For arguments, place the attribute at the beginning of the - * argument declaration. - * - * |[ - * void my_unused_function (G_GNUC_UNUSED gint unused_argument, - * gint other_argument) G_GNUC_UNUSED; - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-unused-function-attribute) for more details. - */ - -/** - * G_GNUC_NO_INSTRUMENT: - * - * Expands to the GNU C `no_instrument_function` function attribute if the - * compiler is gcc. Functions with this attribute will not be instrumented - * for profiling, when the compiler is called with the - * `-finstrument-functions` option. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * int do_uninteresting_things (void) G_GNUC_NO_INSTRUMENT; - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005finstrument_005ffunction-function-attribute) for more details. - */ - -#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) -#if !defined (__clang__) && G_GNUC_CHECK_VERSION (4, 4) -#define G_GNUC_PRINTF( format_idx, arg_idx ) \ - __attribute__((__format__ (gnu_printf, format_idx, arg_idx))) -#define G_GNUC_SCANF( format_idx, arg_idx ) \ - __attribute__((__format__ (gnu_scanf, format_idx, arg_idx))) -#define G_GNUC_STRFTIME( format_idx ) \ - __attribute__((__format__ (gnu_strftime, format_idx, 0))) -#else -#define G_GNUC_PRINTF( format_idx, arg_idx ) \ - __attribute__((__format__ (__printf__, format_idx, arg_idx))) -#define G_GNUC_SCANF( format_idx, arg_idx ) \ - __attribute__((__format__ (__scanf__, format_idx, arg_idx))) -#define G_GNUC_STRFTIME( format_idx ) \ - __attribute__((__format__ (__strftime__, format_idx, 0))) -#endif -#define G_GNUC_FORMAT( arg_idx ) \ - __attribute__((__format_arg__ (arg_idx))) -#define G_GNUC_NORETURN \ - __attribute__((__noreturn__)) -#define G_GNUC_CONST \ - __attribute__((__const__)) -#define G_GNUC_UNUSED \ - __attribute__((__unused__)) -#define G_GNUC_NO_INSTRUMENT \ - __attribute__((__no_instrument_function__)) -#else /* !__GNUC__ */ -#define G_GNUC_PRINTF( format_idx, arg_idx ) -#define G_GNUC_SCANF( format_idx, arg_idx ) -#define G_GNUC_STRFTIME( format_idx ) -#define G_GNUC_FORMAT( arg_idx ) -/* NOTE: MSVC has __declspec(noreturn) but unlike GCC __attribute__, - * __declspec can only be placed at the start of the function prototype - * and not at the end, so we can't use it without breaking API. - */ -#define G_GNUC_NORETURN -#define G_GNUC_CONST -#define G_GNUC_UNUSED -#define G_GNUC_NO_INSTRUMENT -#endif /* !__GNUC__ */ - -/** - * G_GNUC_FALLTHROUGH: - * - * Expands to the GNU C `fallthrough` statement attribute if the compiler supports it. - * This allows declaring case statement to explicitly fall through in switch - * statements. To enable this feature, use `-Wimplicit-fallthrough` during - * compilation. - * - * Put the attribute right before the case statement you want to fall through - * to. - * - * |[ - * switch (foo) - * { - * case 1: - * g_message ("it's 1"); - * G_GNUC_FALLTHROUGH; - * case 2: - * g_message ("it's either 1 or 2"); - * break; - * } - * ]| - * - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#index-fallthrough-statement-attribute) for more details. - * - * Since: 2.60 - */ -#if __GNUC__ > 6 -#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) -#elif g_macro__has_attribute (fallthrough) -#define G_GNUC_FALLTHROUGH __attribute__((fallthrough)) -#else -#define G_GNUC_FALLTHROUGH -#endif /* __GNUC__ */ - -/** - * G_GNUC_DEPRECATED: - * - * Expands to the GNU C `deprecated` attribute if the compiler is gcc. - * It can be used to mark `typedef`s, variables and functions as deprecated. - * When called with the `-Wdeprecated-declarations` option, - * gcc will generate warnings when deprecated interfaces are used. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * int my_mistake (void) G_GNUC_DEPRECATED; - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-deprecated-function-attribute) for more details. - * - * Since: 2.2 - */ -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__) -#define G_GNUC_DEPRECATED __attribute__((__deprecated__)) -#else -#define G_GNUC_DEPRECATED -#endif /* __GNUC__ */ - -/** - * G_GNUC_DEPRECATED_FOR: - * @f: the intended replacement for the deprecated symbol, - * such as the name of a function - * - * Like %G_GNUC_DEPRECATED, but names the intended replacement for the - * deprecated symbol if the version of gcc in use is new enough to support - * custom deprecation messages. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * int my_mistake (void) G_GNUC_DEPRECATED_FOR(my_replacement); - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-deprecated-function-attribute) for more details. - * - * Note that if @f is a macro, it will be expanded in the warning message. - * You can enclose it in quotes to prevent this. (The quotes will show up - * in the warning, but it's better than showing the macro expansion.) - * - * Since: 2.26 - */ -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) -#define G_GNUC_DEPRECATED_FOR(f) \ - __attribute__((deprecated("Use " #f " instead"))) -#else -#define G_GNUC_DEPRECATED_FOR(f) G_GNUC_DEPRECATED -#endif /* __GNUC__ */ - -#ifdef __ICC -#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - _Pragma ("warning (push)") \ - _Pragma ("warning (disable:1478)") -#define G_GNUC_END_IGNORE_DEPRECATIONS \ - _Pragma ("warning (pop)") -#elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - _Pragma ("GCC diagnostic push") \ - _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#define G_GNUC_END_IGNORE_DEPRECATIONS \ - _Pragma ("GCC diagnostic pop") -#elif defined (_MSC_VER) && (_MSC_VER >= 1500) && !defined (__clang__) -#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - __pragma (warning (push)) \ - __pragma (warning (disable : 4996)) -#define G_GNUC_END_IGNORE_DEPRECATIONS \ - __pragma (warning (pop)) -#elif defined (__clang__) -#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#define G_GNUC_END_IGNORE_DEPRECATIONS \ - _Pragma("clang diagnostic pop") -#else -#define G_GNUC_BEGIN_IGNORE_DEPRECATIONS -#define G_GNUC_END_IGNORE_DEPRECATIONS -#endif - -/** - * G_GNUC_MAY_ALIAS: - * - * Expands to the GNU C `may_alias` type attribute if the compiler is gcc. - * Types with this attribute will not be subjected to type-based alias - * analysis, but are assumed to alias with any other type, just like `char`. - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-may_005falias-type-attribute) for details. - * - * Since: 2.14 - */ -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) -#define G_GNUC_MAY_ALIAS __attribute__((may_alias)) -#else -#define G_GNUC_MAY_ALIAS -#endif - -/** - * G_GNUC_WARN_UNUSED_RESULT: - * - * Expands to the GNU C `warn_unused_result` function attribute if the compiler - * is gcc. This function attribute makes the compiler emit a warning if the - * result of a function call is ignored. - * - * Place the attribute after the declaration, just before the semicolon. - * - * |[ - * GList *g_list_append (GList *list, - * gpointer data) G_GNUC_WARN_UNUSED_RESULT; - * ]| - * - * See the [GNU C documentation](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warn_005funused_005fresult-function-attribute) for more details. - * - * Since: 2.10 - */ -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -#define G_GNUC_WARN_UNUSED_RESULT -#endif /* __GNUC__ */ - -/** - * G_GNUC_FUNCTION: - * - * Expands to "" on all modern compilers, and to __FUNCTION__ on gcc - * version 2.x. Don't use it. - * - * Deprecated: 2.16: Use G_STRFUNC() instead - */ - -/** - * G_GNUC_PRETTY_FUNCTION: - * - * Expands to "" on all modern compilers, and to __PRETTY_FUNCTION__ - * on gcc version 2.x. Don't use it. - * - * Deprecated: 2.16: Use G_STRFUNC() instead - */ - -/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with - * macros, so we can refer to them as strings unconditionally. - * usage not-recommended since gcc-3.0 - * - * Mark them as deprecated since 2.26, since that’s when version macros were - * introduced. - */ -#if defined (__GNUC__) && (__GNUC__ < 3) -#define G_GNUC_FUNCTION __FUNCTION__ GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) -#define G_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__ GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) -#else /* !__GNUC__ */ -#define G_GNUC_FUNCTION "" GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) -#define G_GNUC_PRETTY_FUNCTION "" GLIB_DEPRECATED_MACRO_IN_2_26_FOR(G_STRFUNC) -#endif /* !__GNUC__ */ - -#if g_macro__has_feature(attribute_analyzer_noreturn) && defined(__clang_analyzer__) -#define G_ANALYZER_ANALYZING 1 -#define G_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) -#else -#define G_ANALYZER_ANALYZING 0 -#define G_ANALYZER_NORETURN -#endif - -#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string) -#define G_STRINGIFY_ARG(contents) #contents - -#ifndef __GI_SCANNER__ /* The static assert macro really confuses the introspection parser */ -#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 -#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2) -#if !defined(__cplusplus) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -#define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false") -#elif (defined(__cplusplus) && __cplusplus >= 201103L) || \ - (defined(__cplusplus) && defined (_MSC_VER) && (_MSC_VER >= 1600)) || \ - (defined (_MSC_VER) && (_MSC_VER >= 1800)) -#define G_STATIC_ASSERT(expr) static_assert (expr, "Expression evaluates to false") -#else -#ifdef __COUNTER__ -#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __COUNTER__)[(expr) ? 1 : -1] G_GNUC_UNUSED -#else -#define G_STATIC_ASSERT(expr) typedef char G_PASTE (_GStaticAssertCompileTimeAssertion_, __LINE__)[(expr) ? 1 : -1] G_GNUC_UNUSED -#endif -#endif /* __STDC_VERSION__ */ -#define G_STATIC_ASSERT_EXPR(expr) ((void) sizeof (char[(expr) ? 1 : -1])) -#endif /* !__GI_SCANNER__ */ - -/* Provide a string identifying the current code position */ -#if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__cplusplus) -#define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()" -#else -#define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) -#endif - -/* Provide a string identifying the current function, non-concatenatable */ -#if defined (__GNUC__) && defined (__cplusplus) -#define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__)) -#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define G_STRFUNC ((const char*) (__func__)) -#elif defined (__GNUC__) || (defined(_MSC_VER) && (_MSC_VER > 1300)) -#define G_STRFUNC ((const char*) (__FUNCTION__)) -#else -#define G_STRFUNC ((const char*) ("???")) -#endif - -/* Guard C code in headers, while including them from C++ */ -#ifdef __cplusplus -#define G_BEGIN_DECLS extern "C" { -#define G_END_DECLS } -#else -#define G_BEGIN_DECLS -#define G_END_DECLS -#endif - -/* Provide definitions for some commonly used macros. - * Some of them are only provided if they haven't already - * been defined. It is assumed that if they are already - * defined then the current definition is correct. - */ -#ifndef NULL -# ifdef __cplusplus -# define NULL (0L) -# else /* !__cplusplus */ -# define NULL ((void*) 0) -# endif /* !__cplusplus */ -#endif - -#ifndef FALSE -#define FALSE (0) -#endif - -#ifndef TRUE -#define TRUE (!FALSE) -#endif - -#undef MAX -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -#undef MIN -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) - -#undef ABS -#define ABS(a) (((a) < 0) ? -(a) : (a)) - -#undef CLAMP -#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x))) - -#define G_APPROX_VALUE(a, b, epsilon) \ - (((a) > (b) ? (a) - (b) : (b) - (a)) < (epsilon)) - -/* Count the number of elements in an array. The array must be defined - * as such; using this with a dynamically allocated array will give - * incorrect results. - */ -#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0])) - -/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT - */ -#define GPOINTER_TO_SIZE(p) ((gsize) (p)) -#define GSIZE_TO_POINTER(s) ((gpointer) (gsize) (s)) - -/* Provide convenience macros for handling structure - * fields through their offsets. - */ - -#if (defined(__GNUC__) && __GNUC__ >= 4) || defined (_MSC_VER) -#define G_STRUCT_OFFSET(struct_type, member) \ - ((glong) offsetof (struct_type, member)) -#else -#define G_STRUCT_OFFSET(struct_type, member) \ - ((glong) ((guint8*) &((struct_type*) 0)->member)) -#endif - -#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \ - ((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset))) -#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \ - (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset))) - -/* Provide simple macro statement wrappers: - * G_STMT_START { statements; } G_STMT_END; - * This can be used as a single statement, like: - * if (x) G_STMT_START { ... } G_STMT_END; else ... - * This intentionally does not use compiler extensions like GCC's '({...})' to - * avoid portability issue or side effects when compiled with different compilers. - * MSVC complains about "while(0)": C4127: "Conditional expression is constant", - * so we use __pragma to avoid the warning since the use here is intentional. - */ -#if !(defined (G_STMT_START) && defined (G_STMT_END)) -#define G_STMT_START do -#if defined (_MSC_VER) && (_MSC_VER >= 1500) -#define G_STMT_END \ - __pragma(warning(push)) \ - __pragma(warning(disable:4127)) \ - while(0) \ - __pragma(warning(pop)) -#else -#define G_STMT_END while (0) -#endif -#endif - -/* Provide G_ALIGNOF alignment macro. - * - * Note we cannot use the gcc __alignof__ operator here, as that returns the - * preferred alignment rather than the minimal alignment. See - * https://gitlab.gnome.org/GNOME/glib/merge_requests/538/diffs#note_390790. - */ - -/** - * G_ALIGNOF - * @type: a type-name - * - * Return the minimal alignment required by the platform ABI for values of the given - * type. The address of a variable or struct member of the given type must always be - * a multiple of this alignment. For example, most platforms require int variables - * to be aligned at a 4-byte boundary, so `G_ALIGNOF (int)` is 4 on most platforms. - * - * Note this is not necessarily the same as the value returned by GCC’s - * `__alignof__` operator, which returns the preferred alignment for a type. - * The preferred alignment may be a stricter alignment than the minimal - * alignment. - * - * Since: 2.60 - */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus) -#define G_ALIGNOF(type) _Alignof (type) -#else -#define G_ALIGNOF(type) (G_STRUCT_OFFSET (struct { char a; type b; }, b)) -#endif - -/** - * G_CONST_RETURN: - * - * If %G_DISABLE_CONST_RETURNS is defined, this macro expands - * to nothing. By default, the macro expands to const. The macro - * can be used in place of const for functions that return a value - * that should not be modified. The purpose of this macro is to allow - * us to turn on const for returned constant strings by default, while - * allowing programmers who find that annoying to turn it off. This macro - * should only be used for return values and for "out" parameters, it - * doesn't make sense for "in" parameters. - * - * Deprecated: 2.30: API providers should replace all existing uses with - * const and API consumers should adjust their code accordingly - */ -#ifdef G_DISABLE_CONST_RETURNS -#define G_CONST_RETURN GLIB_DEPRECATED_MACRO_IN_2_30_FOR(const) -#else -#define G_CONST_RETURN const GLIB_DEPRECATED_MACRO_IN_2_30_FOR(const) -#endif - -/** - * G_NORETURN: - * - * Expands to the GNU C or MSVC `noreturn` function attribute depending on - * the compiler. It is used for declaring functions which never return. - * Enables optimization of the function, and avoids possible compiler warnings. - * - * Note that %G_NORETURN supersedes the previous %G_GNUC_NORETURN macro, which - * will eventually be deprecated. %G_NORETURN supports more platforms. - * - * Place the attribute before the function declaration as follows: - * - * |[ - * G_NORETURN void g_abort (void); - * ]| - * - * Since: 2.68 - */ -/* Note: We can’t annotate this with GLIB_AVAILABLE_MACRO_IN_2_68 because it’s - * used within the GLib headers in function declarations which are always - * evaluated when a header is included. This results in warnings in third party - * code which includes glib.h, even if the third party code doesn’t use the new - * macro itself. */ -#if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__)) || (0x5110 <= __SUNPRO_C) - /* For compatibility with G_NORETURN_FUNCPTR on clang, use - __attribute__((__noreturn__)), not _Noreturn. */ -# define G_NORETURN __attribute__ ((__noreturn__)) -#elif 1200 <= _MSC_VER - /* Use MSVC specific syntax. */ -# define G_NORETURN __declspec (noreturn) - /* Use ISO C++11 syntax when the compiler supports it. */ -#elif (__cplusplus >= 201103 && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) || (_MSC_VER >= 1900) -# define G_NORETURN [[noreturn]] - /* Use ISO C11 syntax when the compiler supports it. */ -#elif __STDC_VERSION__ >= 201112 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7) -# define G_NORETURN _Noreturn -#else -# define G_NORETURN /* empty */ -#endif - -/** - * G_NORETURN_FUNCPTR: - * - * Expands to the GNU C or MSVC `noreturn` function attribute depending on - * the compiler. It is used for declaring function pointers which never return. - * Enables optimization of the function, and avoids possible compiler warnings. - * - * Place the attribute before the function declaration as follows: - * - * |[ - * G_NORETURN_FUNCPTR void (*funcptr) (void); - * ]| - * - * Note that if the function is not a function pointer, you can simply use - * the %G_NORETURN macro as follows: - * - * |[ - * G_NORETURN void g_abort (void); - * ]| - * - * Since: 2.68 - */ -#if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__)) || (0x5110 <= __SUNPRO_C) -# define G_NORETURN_FUNCPTR __attribute__ ((__noreturn__)) \ - GLIB_AVAILABLE_MACRO_IN_2_68 -#else -# define G_NORETURN_FUNCPTR /* empty */ \ - GLIB_AVAILABLE_MACRO_IN_2_68 -#endif - -/* - * The G_LIKELY and G_UNLIKELY macros let the programmer give hints to - * the compiler about the expected result of an expression. Some compilers - * can use this information for optimizations. - * - * The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when - * putting assignments in g_return_if_fail (). - */ -#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) -#define _G_BOOLEAN_EXPR(expr) \ - G_GNUC_EXTENSION ({ \ - int _g_boolean_var_; \ - if (expr) \ - _g_boolean_var_ = 1; \ - else \ - _g_boolean_var_ = 0; \ - _g_boolean_var_; \ -}) -#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1)) -#define G_UNLIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 0)) -#else -#define G_LIKELY(expr) (expr) -#define G_UNLIKELY(expr) (expr) -#endif - -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (__clang__) -#define G_DEPRECATED __attribute__((__deprecated__)) -#elif defined(_MSC_VER) && (_MSC_VER >= 1300) -#define G_DEPRECATED __declspec(deprecated) -#else -#define G_DEPRECATED -#endif - -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) -#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead"))) -#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) -#define G_DEPRECATED_FOR(f) __declspec(deprecated("is deprecated. Use '" #f "' instead")) -#else -#define G_DEPRECATED_FOR(f) G_DEPRECATED -#endif - -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) || defined (__clang__) -#define G_UNAVAILABLE(maj,min) __attribute__((deprecated("Not available before " #maj "." #min))) -#elif defined(_MSC_FULL_VER) && (_MSC_FULL_VER > 140050320) -#define G_UNAVAILABLE(maj,min) __declspec(deprecated("is not available before " #maj "." #min)) -#else -#define G_UNAVAILABLE(maj,min) G_DEPRECATED -#endif - -#ifndef _GLIB_EXTERN -#define _GLIB_EXTERN extern -#endif - -/* These macros are used to mark deprecated symbols in GLib headers, - * and thus have to be exposed in installed headers. But please - * do *not* use them in other projects. Instead, use G_DEPRECATED - * or define your own wrappers around it. - */ - -#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS -#define GLIB_DEPRECATED _GLIB_EXTERN -#define GLIB_DEPRECATED_FOR(f) _GLIB_EXTERN -#define GLIB_UNAVAILABLE(maj,min) _GLIB_EXTERN -#define GLIB_UNAVAILABLE_STATIC_INLINE(maj,min) -#else -#define GLIB_DEPRECATED G_DEPRECATED _GLIB_EXTERN -#define GLIB_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) _GLIB_EXTERN -#define GLIB_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min) _GLIB_EXTERN -#define GLIB_UNAVAILABLE_STATIC_INLINE(maj,min) G_UNAVAILABLE(maj,min) -#endif - -#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || \ - __clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4)) -#define _GLIB_GNUC_DO_PRAGMA(x) _Pragma(G_STRINGIFY (x)) -#define GLIB_DEPRECATED_MACRO _GLIB_GNUC_DO_PRAGMA(GCC warning "Deprecated pre-processor symbol") -#define GLIB_DEPRECATED_MACRO_FOR(f) _GLIB_GNUC_DO_PRAGMA(GCC warning "Deprecated pre-processor symbol, replace with " #f) -#define GLIB_UNAVAILABLE_MACRO(maj,min) _GLIB_GNUC_DO_PRAGMA(GCC warning "Not available before " #maj "." #min) -#else -#define GLIB_DEPRECATED_MACRO -#define GLIB_DEPRECATED_MACRO_FOR(f) -#define GLIB_UNAVAILABLE_MACRO(maj,min) -#endif - -#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ - ((defined (__GNUC__) && (__GNUC__ > 6 || (__GNUC__ == 6 && __GNUC_MINOR__ >= 1))) || \ - (defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0)))) -#define GLIB_DEPRECATED_ENUMERATOR G_DEPRECATED -#define GLIB_DEPRECATED_ENUMERATOR_FOR(f) G_DEPRECATED_FOR(f) -#define GLIB_UNAVAILABLE_ENUMERATOR(maj,min) G_UNAVAILABLE(maj,min) -#else -#define GLIB_DEPRECATED_ENUMERATOR -#define GLIB_DEPRECATED_ENUMERATOR_FOR(f) -#define GLIB_UNAVAILABLE_ENUMERATOR(maj,min) -#endif - -#if !defined(GLIB_DISABLE_DEPRECATION_WARNINGS) && \ - ((defined (__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))) || \ - (defined (__clang_major__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 0)))) -#define GLIB_DEPRECATED_TYPE G_DEPRECATED -#define GLIB_DEPRECATED_TYPE_FOR(f) G_DEPRECATED_FOR(f) -#define GLIB_UNAVAILABLE_TYPE(maj,min) G_UNAVAILABLE(maj,min) -#else -#define GLIB_DEPRECATED_TYPE -#define GLIB_DEPRECATED_TYPE_FOR(f) -#define GLIB_UNAVAILABLE_TYPE(maj,min) -#endif - -#ifndef __GI_SCANNER__ - -#if defined (__GNUC__) || defined (__clang__) - -/* these macros are private */ -#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName -#define _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) glib_autoptr_clear_##TypeName -#define _GLIB_AUTOPTR_TYPENAME(TypeName) TypeName##_autoptr -#define _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) glib_listautoptr_cleanup_##TypeName -#define _GLIB_AUTOPTR_LIST_TYPENAME(TypeName) TypeName##_listautoptr -#define _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) glib_slistautoptr_cleanup_##TypeName -#define _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName) TypeName##_slistautoptr -#define _GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName) glib_queueautoptr_cleanup_##TypeName -#define _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName) TypeName##_queueautoptr -#define _GLIB_AUTO_FUNC_NAME(TypeName) glib_auto_cleanup_##TypeName -#define _GLIB_CLEANUP(func) __attribute__((cleanup(func))) -#define _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, ParentName, cleanup) \ - typedef TypeName *_GLIB_AUTOPTR_TYPENAME(TypeName); \ - typedef GList *_GLIB_AUTOPTR_LIST_TYPENAME(TypeName); \ - typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName); \ - typedef GQueue *_GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName); \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) (TypeName *_ptr) \ - { if (_ptr) (cleanup) ((ParentName *) _ptr); } \ - static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) \ - { _GLIB_AUTOPTR_CLEAR_FUNC_NAME(TypeName) (*_ptr); } \ - static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) \ - { g_list_free_full (*_l, (GDestroyNotify) (void(*)(void)) cleanup); } \ - static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) \ - { g_slist_free_full (*_l, (GDestroyNotify) (void(*)(void)) cleanup); } \ - static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName) (GQueue **_q) \ - { if (*_q) g_queue_free_full (*_q, (GDestroyNotify) (void(*)(void)) cleanup); } \ - G_GNUC_END_IGNORE_DEPRECATIONS -#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) \ - _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(ModuleObjName, ParentName, _GLIB_AUTOPTR_CLEAR_FUNC_NAME(ParentName)) - - -/* these macros are API */ -#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) \ - _GLIB_DEFINE_AUTOPTR_CLEANUP_FUNCS(TypeName, TypeName, func) -#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { (func) (_ptr); } \ - G_GNUC_END_IGNORE_DEPRECATIONS -#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - static G_GNUC_UNUSED inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { if (*_ptr != none) (func) (*_ptr); } \ - G_GNUC_END_IGNORE_DEPRECATIONS -#define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName) -#define g_autolist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_LIST_TYPENAME(TypeName) -#define g_autoslist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName) -#define g_autoqueue(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName) -#define g_auto(TypeName) _GLIB_CLEANUP(_GLIB_AUTO_FUNC_NAME(TypeName)) TypeName -#define g_autofree _GLIB_CLEANUP(g_autoptr_cleanup_generic_gfree) - -#else /* not GNU C */ -/* this (dummy) macro is private */ -#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) - -/* these (dummy) macros are API */ -#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) -#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) -#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) - -/* no declaration of g_auto() or g_autoptr() here */ -#endif /* __GNUC__ */ - -#else - -#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) - -#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) -#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) -#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) - -#endif /* __GI_SCANNER__ */ - -/** - * G_SIZEOF_MEMBER: - * @struct_type: a structure type, e.g. #GOutputVector - * @member: a field in the structure, e.g. `size` - * - * Returns the size of @member in the struct definition without having a - * declared instance of @struct_type. - * - * Returns: the size of @member in bytes. - * - * Since: 2.64 - */ -#define G_SIZEOF_MEMBER(struct_type, member) \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - sizeof (((struct_type *) 0)->member) - -#endif /* __G_MACROS_H__ */ - -#include -#include -#define GLIB_HAVE_ALLOCA_H - -/* Specifies that GLib's g_print*() functions wrap the - * system printf functions. This is useful to know, for example, - * when using glibc's register_printf_function(). - */ -#undef GLIB_USING_SYSTEM_PRINTF - -#define GLIB_STATIC_COMPILATION 1 -#define GOBJECT_STATIC_COMPILATION 1 -#define GIO_STATIC_COMPILATION 1 - -G_BEGIN_DECLS - -#define G_MINFLOAT FLT_MIN -#define G_MAXFLOAT FLT_MAX -#define G_MINDOUBLE DBL_MIN -#define G_MAXDOUBLE DBL_MAX -#define G_MINSHORT SHRT_MIN -#define G_MAXSHORT SHRT_MAX -#define G_MAXUSHORT USHRT_MAX -#define G_MININT INT_MIN -#define G_MAXINT INT_MAX -#define G_MAXUINT UINT_MAX -#define G_MINLONG LONG_MIN -#define G_MAXLONG LONG_MAX -#define G_MAXULONG ULONG_MAX - -typedef signed char gint8; -typedef unsigned char guint8; - -typedef signed short gint16; -typedef unsigned short guint16; - -#define G_GINT16_MODIFIER "h" -#define G_GINT16_FORMAT "hi" -#define G_GUINT16_FORMAT "hu" - - -typedef signed int gint32; -typedef unsigned int guint32; - -#define G_GINT32_MODIFIER "" -#define G_GINT32_FORMAT "i" -#define G_GUINT32_FORMAT "u" - - -#define G_HAVE_GINT64 1 /* deprecated, always true */ - -typedef signed long gint64; -typedef unsigned long guint64; - -#define G_GINT64_CONSTANT(val) (val##L) -#define G_GUINT64_CONSTANT(val) (val##UL) - -#define G_GINT64_MODIFIER "l" -#define G_GINT64_FORMAT "li" -#define G_GUINT64_FORMAT "lu" - - -#define GLIB_SIZEOF_VOID_P 8 -#define GLIB_SIZEOF_LONG 8 -#define GLIB_SIZEOF_SIZE_T 8 -#define GLIB_SIZEOF_SSIZE_T 8 - -typedef signed long gssize; -typedef unsigned long gsize; -#define G_GSIZE_MODIFIER "l" -#define G_GSSIZE_MODIFIER "l" -#define G_GSIZE_FORMAT "lu" -#define G_GSSIZE_FORMAT "li" - -#define G_MAXSIZE G_MAXULONG -#define G_MINSSIZE G_MINLONG -#define G_MAXSSIZE G_MAXLONG - -typedef gint64 goffset; -#define G_MINOFFSET G_MININT64 -#define G_MAXOFFSET G_MAXINT64 - -#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER -#define G_GOFFSET_FORMAT G_GINT64_FORMAT -#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val) - -#define G_POLLFD_FORMAT "%d" - -#define GPOINTER_TO_INT(p) ((gint) (glong) (p)) -#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p)) - -#define GINT_TO_POINTER(i) ((gpointer) (glong) (i)) -#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u)) - -typedef signed long gintptr; -typedef unsigned long guintptr; - -#define G_GINTPTR_MODIFIER "l" -#define G_GINTPTR_FORMAT "li" -#define G_GUINTPTR_FORMAT "lu" - -#define GLIB_MAJOR_VERSION 2 -#define GLIB_MINOR_VERSION 67 -#define GLIB_MICRO_VERSION 1 - -#define G_OS_UNIX - -#define G_VA_COPY va_copy - - -#ifndef __cplusplus -# define G_HAVE_ISO_VARARGS 1 -#endif - -#ifdef __cplusplus -# define G_HAVE_ISO_VARARGS 1 -#endif - -/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi - * is passed ISO vararg support is turned off, and there is no work - * around to turn it on, so we unconditionally turn it off. - */ -#if __GNUC__ == 2 && __GNUC_MINOR__ == 95 -# undef G_HAVE_ISO_VARARGS -#endif - -#define G_HAVE_GROWING_STACK 0 -#define G_HAVE_GNUC_VISIBILITY 1 - -#ifndef _MSC_VER -# define G_HAVE_GNUC_VARARGS 1 -#endif - -#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) -#define G_GNUC_INTERNAL __attribute__((visibility("hidden"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) -#define G_GNUC_INTERNAL __hidden -#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY) -#define G_GNUC_INTERNAL __attribute__((visibility("hidden"))) -#else -#define G_GNUC_INTERNAL -#endif - -#define G_THREADS_ENABLED -#define G_THREADS_IMPL_POSIX - -#define G_ATOMIC_LOCK_FREE - -#define GINT16_TO_LE(val) ((gint16) (val)) -#define GUINT16_TO_LE(val) ((guint16) (val)) -#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val)) -#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val)) - -#define GINT32_TO_LE(val) ((gint32) (val)) -#define GUINT32_TO_LE(val) ((guint32) (val)) -#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val)) -#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val)) - -#define GINT64_TO_LE(val) ((gint64) (val)) -#define GUINT64_TO_LE(val) ((guint64) (val)) -#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val)) -#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val)) - -#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val)) -#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val)) -#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val)) -#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val)) -#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val)) -#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val)) -#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val)) -#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val)) -#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val)) -#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val)) -#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val)) -#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val)) -#define G_BYTE_ORDER G_LITTLE_ENDIAN - -#define GLIB_SYSDEF_POLLIN =1 -#define GLIB_SYSDEF_POLLOUT =4 -#define GLIB_SYSDEF_POLLPRI =2 -#define GLIB_SYSDEF_POLLHUP =16 -#define GLIB_SYSDEF_POLLERR =8 -#define GLIB_SYSDEF_POLLNVAL =32 - -#define G_MODULE_SUFFIX "so" - -typedef int GPid; -#define G_PID_FORMAT "i" - -#define GLIB_SYSDEF_AF_UNIX 1 -#define GLIB_SYSDEF_AF_INET 2 -#define GLIB_SYSDEF_AF_INET6 10 - -#define GLIB_SYSDEF_MSG_OOB 1 -#define GLIB_SYSDEF_MSG_PEEK 2 -#define GLIB_SYSDEF_MSG_DONTROUTE 4 - -#define G_DIR_SEPARATOR '/' -#define G_DIR_SEPARATOR_S "/" -#define G_SEARCHPATH_SEPARATOR ':' -#define G_SEARCHPATH_SEPARATOR_S ":" - -G_END_DECLS - -#endif /* __GLIBCONFIG_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_VERSION_MACROS_H__ -#define __G_VERSION_MACROS_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* Version boundaries checks */ - -#define G_ENCODE_VERSION(major,minor) ((major) << 16 | (minor) << 8) - -/* XXX: Every new stable minor release bump should add a macro here */ - -/** - * GLIB_VERSION_2_26: - * - * A macro that evaluates to the 2.26 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.32 - */ -#define GLIB_VERSION_2_26 (G_ENCODE_VERSION (2, 26)) - -/** - * GLIB_VERSION_2_28: - * - * A macro that evaluates to the 2.28 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.32 - */ -#define GLIB_VERSION_2_28 (G_ENCODE_VERSION (2, 28)) - -/** - * GLIB_VERSION_2_30: - * - * A macro that evaluates to the 2.30 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.32 - */ -#define GLIB_VERSION_2_30 (G_ENCODE_VERSION (2, 30)) - -/** - * GLIB_VERSION_2_32: - * - * A macro that evaluates to the 2.32 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.32 - */ -#define GLIB_VERSION_2_32 (G_ENCODE_VERSION (2, 32)) - -/** - * GLIB_VERSION_2_34: - * - * A macro that evaluates to the 2.34 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.34 - */ -#define GLIB_VERSION_2_34 (G_ENCODE_VERSION (2, 34)) - -/** - * GLIB_VERSION_2_36: - * - * A macro that evaluates to the 2.36 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.36 - */ -#define GLIB_VERSION_2_36 (G_ENCODE_VERSION (2, 36)) - -/** - * GLIB_VERSION_2_38: - * - * A macro that evaluates to the 2.38 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.38 - */ -#define GLIB_VERSION_2_38 (G_ENCODE_VERSION (2, 38)) - -/** - * GLIB_VERSION_2_40: - * - * A macro that evaluates to the 2.40 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.40 - */ -#define GLIB_VERSION_2_40 (G_ENCODE_VERSION (2, 40)) - -/** - * GLIB_VERSION_2_42: - * - * A macro that evaluates to the 2.42 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.42 - */ -#define GLIB_VERSION_2_42 (G_ENCODE_VERSION (2, 42)) - -/** - * GLIB_VERSION_2_44: - * - * A macro that evaluates to the 2.44 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.44 - */ -#define GLIB_VERSION_2_44 (G_ENCODE_VERSION (2, 44)) - -/** - * GLIB_VERSION_2_46: - * - * A macro that evaluates to the 2.46 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.46 - */ -#define GLIB_VERSION_2_46 (G_ENCODE_VERSION (2, 46)) - -/** - * GLIB_VERSION_2_48: - * - * A macro that evaluates to the 2.48 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.48 - */ -#define GLIB_VERSION_2_48 (G_ENCODE_VERSION (2, 48)) - -/** - * GLIB_VERSION_2_50: - * - * A macro that evaluates to the 2.50 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.50 - */ -#define GLIB_VERSION_2_50 (G_ENCODE_VERSION (2, 50)) - -/** - * GLIB_VERSION_2_52: - * - * A macro that evaluates to the 2.52 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.52 - */ -#define GLIB_VERSION_2_52 (G_ENCODE_VERSION (2, 52)) - -/** - * GLIB_VERSION_2_54: - * - * A macro that evaluates to the 2.54 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.54 - */ -#define GLIB_VERSION_2_54 (G_ENCODE_VERSION (2, 54)) - -/** - * GLIB_VERSION_2_56: - * - * A macro that evaluates to the 2.56 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.56 - */ -#define GLIB_VERSION_2_56 (G_ENCODE_VERSION (2, 56)) - -/** - * GLIB_VERSION_2_58: - * - * A macro that evaluates to the 2.58 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.58 - */ -#define GLIB_VERSION_2_58 (G_ENCODE_VERSION (2, 58)) - -/** - * GLIB_VERSION_2_60: - * - * A macro that evaluates to the 2.60 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.60 - */ -#define GLIB_VERSION_2_60 (G_ENCODE_VERSION (2, 60)) - -/** - * GLIB_VERSION_2_62: - * - * A macro that evaluates to the 2.62 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.62 - */ -#define GLIB_VERSION_2_62 (G_ENCODE_VERSION (2, 62)) - -/** - * GLIB_VERSION_2_64: - * - * A macro that evaluates to the 2.64 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.64 - */ -#define GLIB_VERSION_2_64 (G_ENCODE_VERSION (2, 64)) - -/** - * GLIB_VERSION_2_66: - * - * A macro that evaluates to the 2.66 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.66 - */ -#define GLIB_VERSION_2_66 (G_ENCODE_VERSION (2, 66)) - -/** - * GLIB_VERSION_2_68: - * - * A macro that evaluates to the 2.68 version of GLib, in a format - * that can be used by the C pre-processor. - * - * Since: 2.68 - */ -#define GLIB_VERSION_2_68 (G_ENCODE_VERSION (2, 68)) - -/* evaluates to the current stable version; for development cycles, - * this means the next stable target - */ -#if (GLIB_MINOR_VERSION % 2) -#define GLIB_VERSION_CUR_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION + 1)) -#else -#define GLIB_VERSION_CUR_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION)) -#endif - -/* evaluates to the previous stable version */ -#if (GLIB_MINOR_VERSION % 2) -#define GLIB_VERSION_PREV_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 1)) -#else -#define GLIB_VERSION_PREV_STABLE (G_ENCODE_VERSION (GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION - 2)) -#endif - -/** - * GLIB_VERSION_MIN_REQUIRED: - * - * A macro that should be defined by the user prior to including - * the glib.h header. - * The definition should be one of the predefined GLib version - * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,... - * - * This macro defines the earliest version of GLib that the package is - * required to be able to compile against. - * - * If the compiler is configured to warn about the use of deprecated - * functions, then using functions that were deprecated in version - * %GLIB_VERSION_MIN_REQUIRED or earlier will cause warnings (but - * using functions deprecated in later releases will not). - * - * Since: 2.32 - */ -/* If the package sets GLIB_VERSION_MIN_REQUIRED to some future - * GLIB_VERSION_X_Y value that we don't know about, it will compare as - * 0 in preprocessor tests. - */ -#ifndef GLIB_VERSION_MIN_REQUIRED -# define GLIB_VERSION_MIN_REQUIRED (GLIB_VERSION_CUR_STABLE) -#elif GLIB_VERSION_MIN_REQUIRED == 0 -# undef GLIB_VERSION_MIN_REQUIRED -# define GLIB_VERSION_MIN_REQUIRED (GLIB_VERSION_CUR_STABLE + 2) -#endif - -/** - * GLIB_VERSION_MAX_ALLOWED: - * - * A macro that should be defined by the user prior to including - * the glib.h header. - * The definition should be one of the predefined GLib version - * macros: %GLIB_VERSION_2_26, %GLIB_VERSION_2_28,... - * - * This macro defines the latest version of the GLib API that the - * package is allowed to make use of. - * - * If the compiler is configured to warn about the use of deprecated - * functions, then using functions added after version - * %GLIB_VERSION_MAX_ALLOWED will cause warnings. - * - * Unless you are using GLIB_CHECK_VERSION() or the like to compile - * different code depending on the GLib version, then this should be - * set to the same value as %GLIB_VERSION_MIN_REQUIRED. - * - * Since: 2.32 - */ -#if !defined (GLIB_VERSION_MAX_ALLOWED) || (GLIB_VERSION_MAX_ALLOWED == 0) -# undef GLIB_VERSION_MAX_ALLOWED -# define GLIB_VERSION_MAX_ALLOWED (GLIB_VERSION_CUR_STABLE) -#endif - -/* sanity checks */ -#if GLIB_VERSION_MIN_REQUIRED > GLIB_VERSION_CUR_STABLE -#error "GLIB_VERSION_MIN_REQUIRED must be <= GLIB_VERSION_CUR_STABLE" -#endif -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_MIN_REQUIRED -#error "GLIB_VERSION_MAX_ALLOWED must be >= GLIB_VERSION_MIN_REQUIRED" -#endif -#if GLIB_VERSION_MIN_REQUIRED < GLIB_VERSION_2_26 -#error "GLIB_VERSION_MIN_REQUIRED must be >= GLIB_VERSION_2_26" -#endif - -/* These macros are used to mark deprecated functions in GLib headers, - * and thus have to be exposed in installed headers. But please - * do *not* use them in other projects. Instead, use G_DEPRECATED - * or define your own wrappers around it. - */ -#define GLIB_AVAILABLE_IN_ALL _GLIB_EXTERN - -/* XXX: Every new stable minor release should add a set of macros here */ - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_26 -# define GLIB_DEPRECATED_IN_2_26 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_26_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_26 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_26_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_26 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_26 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_26_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_26 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_26_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_26 -# define GLIB_DEPRECATED_MACRO_IN_2_26_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_26 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_26_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_26 -# define GLIB_DEPRECATED_TYPE_IN_2_26_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26 -# define GLIB_AVAILABLE_IN_2_26 GLIB_UNAVAILABLE(2, 26) -# define GLIB_AVAILABLE_MACRO_IN_2_26 GLIB_UNAVAILABLE_MACRO(2, 26) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_26 GLIB_UNAVAILABLE_ENUMERATOR(2, 26) -# define GLIB_AVAILABLE_TYPE_IN_2_26 GLIB_UNAVAILABLE_TYPE(2, 26) -#else -# define GLIB_AVAILABLE_IN_2_26 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_26 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_26 -# define GLIB_AVAILABLE_TYPE_IN_2_26 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28 -# define GLIB_DEPRECATED_IN_2_28 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_28_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_28 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_28_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_28 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_28 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_28_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_28 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_28_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_28 -# define GLIB_DEPRECATED_MACRO_IN_2_28_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_28 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_28_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_28 -# define GLIB_DEPRECATED_TYPE_IN_2_28_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28 -# define GLIB_AVAILABLE_IN_2_28 GLIB_UNAVAILABLE(2, 28) -# define GLIB_AVAILABLE_MACRO_IN_2_28 GLIB_UNAVAILABLE_MACRO(2, 28) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_28 GLIB_UNAVAILABLE_ENUMERATOR(2, 28) -# define GLIB_AVAILABLE_TYPE_IN_2_28 GLIB_UNAVAILABLE_TYPE(2, 28) -#else -# define GLIB_AVAILABLE_IN_2_28 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_28 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_28 -# define GLIB_AVAILABLE_TYPE_IN_2_28 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30 -# define GLIB_DEPRECATED_IN_2_30 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_30_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_30 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_30_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_30 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_30 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_30_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_30 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_30_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_30 -# define GLIB_DEPRECATED_MACRO_IN_2_30_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_30 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_30_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_30 -# define GLIB_DEPRECATED_TYPE_IN_2_30_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30 -# define GLIB_AVAILABLE_IN_2_30 GLIB_UNAVAILABLE(2, 30) -# define GLIB_AVAILABLE_MACRO_IN_2_30 GLIB_UNAVAILABLE_MACRO(2, 30) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_30 GLIB_UNAVAILABLE_ENUMERATOR(2, 30) -# define GLIB_AVAILABLE_TYPE_IN_2_30 GLIB_UNAVAILABLE_TYPE(2, 30) -#else -# define GLIB_AVAILABLE_IN_2_30 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_30 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_30 -# define GLIB_AVAILABLE_TYPE_IN_2_30 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32 -# define GLIB_DEPRECATED_IN_2_32 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_32_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_32 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_32_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_32 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_32_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_32 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_32_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_32 -# define GLIB_DEPRECATED_MACRO_IN_2_32_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_32 -# define GLIB_DEPRECATED_TYPE_IN_2_32_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_32 -# define GLIB_DEPRECATED_TYPE_IN_2_32_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32 -# define GLIB_AVAILABLE_IN_2_32 GLIB_UNAVAILABLE(2, 32) -# define GLIB_AVAILABLE_MACRO_IN_2_32 GLIB_UNAVAILABLE_MACRO(2, 32) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_32 GLIB_UNAVAILABLE_ENUMERATOR(2, 32) -# define GLIB_AVAILABLE_TYPE_IN_2_32 GLIB_UNAVAILABLE_TYPE(2, 32) -#else -# define GLIB_AVAILABLE_IN_2_32 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_32 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_32 -# define GLIB_AVAILABLE_TYPE_IN_2_32 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34 -# define GLIB_DEPRECATED_IN_2_34 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_34_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_34 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_34_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_34 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_34 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_34_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_34 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_34_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_34 -# define GLIB_DEPRECATED_MACRO_IN_2_34_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_34 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_34_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_34 -# define GLIB_DEPRECATED_TYPE_IN_2_34_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34 -# define GLIB_AVAILABLE_IN_2_34 GLIB_UNAVAILABLE(2, 34) -# define GLIB_AVAILABLE_MACRO_IN_2_34 GLIB_UNAVAILABLE_MACRO(2, 34) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_34 GLIB_UNAVAILABLE_ENUMERATOR(2, 34) -# define GLIB_AVAILABLE_TYPE_IN_2_34 GLIB_UNAVAILABLE_TYPE(2, 34) -#else -# define GLIB_AVAILABLE_IN_2_34 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_34 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_34 -# define GLIB_AVAILABLE_TYPE_IN_2_34 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36 -# define GLIB_DEPRECATED_IN_2_36 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_36_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_36 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_36_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_36 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_36 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_36_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_36 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_36_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_36 -# define GLIB_DEPRECATED_MACRO_IN_2_36_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_36 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_36_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_36 -# define GLIB_DEPRECATED_TYPE_IN_2_36_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36 -# define GLIB_AVAILABLE_IN_2_36 GLIB_UNAVAILABLE(2, 36) -# define GLIB_AVAILABLE_MACRO_IN_2_36 GLIB_UNAVAILABLE_MACRO(2, 36) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_36 GLIB_UNAVAILABLE_ENUMERATOR(2, 36) -# define GLIB_AVAILABLE_TYPE_IN_2_36 GLIB_UNAVAILABLE_TYPE(2, 36) -#else -# define GLIB_AVAILABLE_IN_2_36 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_36 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_36 -# define GLIB_AVAILABLE_TYPE_IN_2_36 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_38 -# define GLIB_DEPRECATED_IN_2_38 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_38_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_38 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_38_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_38 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_38 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_38_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_38 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_38_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_38 -# define GLIB_DEPRECATED_MACRO_IN_2_38_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_38 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_38_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_38 -# define GLIB_DEPRECATED_TYPE_IN_2_38_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_38 -# define GLIB_AVAILABLE_IN_2_38 GLIB_UNAVAILABLE(2, 38) -# define GLIB_AVAILABLE_MACRO_IN_2_38 GLIB_UNAVAILABLE_MACRO(2, 38) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_38 GLIB_UNAVAILABLE_ENUMERATOR(2, 38) -# define GLIB_AVAILABLE_TYPE_IN_2_38 GLIB_UNAVAILABLE_TYPE(2, 38) -#else -# define GLIB_AVAILABLE_IN_2_38 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_38 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_38 -# define GLIB_AVAILABLE_TYPE_IN_2_38 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_40 -# define GLIB_DEPRECATED_IN_2_40 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_40_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_40 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_40_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_40 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_40 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_40_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_40 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_40_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_40 -# define GLIB_DEPRECATED_MACRO_IN_2_40_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_40 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_40_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_40 -# define GLIB_DEPRECATED_TYPE_IN_2_40_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_40 -# define GLIB_AVAILABLE_IN_2_40 GLIB_UNAVAILABLE(2, 40) -# define GLIB_AVAILABLE_MACRO_IN_2_40 GLIB_UNAVAILABLE_MACRO(2, 40) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_40 GLIB_UNAVAILABLE_ENUMERATOR(2, 40) -# define GLIB_AVAILABLE_TYPE_IN_2_40 GLIB_UNAVAILABLE_TYPE(2, 40) -#else -# define GLIB_AVAILABLE_IN_2_40 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_40 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_40 -# define GLIB_AVAILABLE_TYPE_IN_2_40 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_42 -# define GLIB_DEPRECATED_IN_2_42 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_42_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_42 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_42_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_42 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_42_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_42 -# define GLIB_DEPRECATED_MACRO_IN_2_42_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_42 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_42_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_42 -# define GLIB_DEPRECATED_TYPE_IN_2_42_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_42 -# define GLIB_AVAILABLE_IN_2_42 GLIB_UNAVAILABLE(2, 42) -# define GLIB_AVAILABLE_MACRO_IN_2_42 GLIB_UNAVAILABLE_MACRO(2, 42) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_42 GLIB_UNAVAILABLE_ENUMERATOR(2, 42) -# define GLIB_AVAILABLE_TYPE_IN_2_42 GLIB_UNAVAILABLE_TYPE(2, 42) -#else -# define GLIB_AVAILABLE_IN_2_42 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_42 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_42 -# define GLIB_AVAILABLE_TYPE_IN_2_42 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_44 -# define GLIB_DEPRECATED_IN_2_44 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_44_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_44 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_44_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_44 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_44 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_44_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_44 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_44_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_44 -# define GLIB_DEPRECATED_MACRO_IN_2_44_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_44 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_44_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_44 -# define GLIB_DEPRECATED_TYPE_IN_2_44_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_44 -# define GLIB_AVAILABLE_IN_2_44 GLIB_UNAVAILABLE(2, 44) -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 GLIB_UNAVAILABLE_STATIC_INLINE(2, 44) -# define GLIB_AVAILABLE_MACRO_IN_2_44 GLIB_UNAVAILABLE_MACRO(2, 44) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_44 GLIB_UNAVAILABLE_ENUMERATOR(2, 44) -# define GLIB_AVAILABLE_TYPE_IN_2_44 GLIB_UNAVAILABLE_TYPE(2, 44) -#else -# define GLIB_AVAILABLE_IN_2_44 _GLIB_EXTERN -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 -# define GLIB_AVAILABLE_MACRO_IN_2_44 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_44 -# define GLIB_AVAILABLE_TYPE_IN_2_44 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_46 -# define GLIB_DEPRECATED_IN_2_46 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_46_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_46 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_46_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_46 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_46_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_46 -# define GLIB_DEPRECATED_MACRO_IN_2_46_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_46 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_46_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_46 -# define GLIB_DEPRECATED_TYPE_IN_2_46_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_46 -# define GLIB_AVAILABLE_IN_2_46 GLIB_UNAVAILABLE(2, 46) -# define GLIB_AVAILABLE_MACRO_IN_2_46 GLIB_UNAVAILABLE_MACRO(2, 46) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_46 GLIB_UNAVAILABLE_ENUMERATOR(2, 46) -# define GLIB_AVAILABLE_TYPE_IN_2_46 GLIB_UNAVAILABLE_TYPE(2, 46) -#else -# define GLIB_AVAILABLE_IN_2_46 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_46 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_46 -# define GLIB_AVAILABLE_TYPE_IN_2_46 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_48 -# define GLIB_DEPRECATED_IN_2_48 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_48_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_48 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_48_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_48 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_48 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_48_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_48 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_48_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_48 -# define GLIB_DEPRECATED_MACRO_IN_2_48_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_48 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_48_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_48 -# define GLIB_DEPRECATED_TYPE_IN_2_48_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_48 -# define GLIB_AVAILABLE_IN_2_48 GLIB_UNAVAILABLE(2, 48) -# define GLIB_AVAILABLE_MACRO_IN_2_48 GLIB_UNAVAILABLE_MACRO(2, 48) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_48 GLIB_UNAVAILABLE_ENUMERATOR(2, 48) -# define GLIB_AVAILABLE_TYPE_IN_2_48 GLIB_UNAVAILABLE_TYPE(2, 48) -#else -# define GLIB_AVAILABLE_IN_2_48 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_48 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_48 -# define GLIB_AVAILABLE_TYPE_IN_2_48 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_50 -# define GLIB_DEPRECATED_IN_2_50 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_50_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_50 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_50_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_50 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_50 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_50_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_50 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_50_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_50 -# define GLIB_DEPRECATED_MACRO_IN_2_50_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_50 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_50_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_50 -# define GLIB_DEPRECATED_TYPE_IN_2_50_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_50 -# define GLIB_AVAILABLE_IN_2_50 GLIB_UNAVAILABLE(2, 50) -# define GLIB_AVAILABLE_MACRO_IN_2_50 GLIB_UNAVAILABLE_MACRO(2, 50) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_50 GLIB_UNAVAILABLE_ENUMERATOR(2, 50) -# define GLIB_AVAILABLE_TYPE_IN_2_50 GLIB_UNAVAILABLE_TYPE(2, 50) -#else -# define GLIB_AVAILABLE_IN_2_50 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_50 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_50 -# define GLIB_AVAILABLE_TYPE_IN_2_50 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_52 -# define GLIB_DEPRECATED_IN_2_52 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_52_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_52 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_52_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_52 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_52 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_52_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_52 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_52_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_52 -# define GLIB_DEPRECATED_MACRO_IN_2_52_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_52 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_52_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_52 -# define GLIB_DEPRECATED_TYPE_IN_2_52_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_52 -# define GLIB_AVAILABLE_IN_2_52 GLIB_UNAVAILABLE(2, 52) -# define GLIB_AVAILABLE_MACRO_IN_2_52 GLIB_UNAVAILABLE_MACRO(2, 52) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_52 GLIB_UNAVAILABLE_ENUMERATOR(2, 52) -# define GLIB_AVAILABLE_TYPE_IN_2_52 GLIB_UNAVAILABLE_TYPE(2, 52) -#else -# define GLIB_AVAILABLE_IN_2_52 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_52 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_52 -# define GLIB_AVAILABLE_TYPE_IN_2_52 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_54 -# define GLIB_DEPRECATED_IN_2_54 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_54_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_54 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_54_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_54 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_54 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_54_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_54 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_54_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_54 -# define GLIB_DEPRECATED_MACRO_IN_2_54_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_54 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_54_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_54 -# define GLIB_DEPRECATED_TYPE_IN_2_54_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_54 -# define GLIB_AVAILABLE_IN_2_54 GLIB_UNAVAILABLE(2, 54) -# define GLIB_AVAILABLE_MACRO_IN_2_54 GLIB_UNAVAILABLE_MACRO(2, 54) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_54 GLIB_UNAVAILABLE_ENUMERATOR(2, 54) -# define GLIB_AVAILABLE_TYPE_IN_2_54 GLIB_UNAVAILABLE_TYPE(2, 54) -#else -# define GLIB_AVAILABLE_IN_2_54 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_54 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_54 -# define GLIB_AVAILABLE_TYPE_IN_2_54 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_56 -# define GLIB_DEPRECATED_IN_2_56 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_56_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_56 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_56_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_56 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_56 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_56_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_56 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_56_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_56 -# define GLIB_DEPRECATED_MACRO_IN_2_56_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_56 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_56_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_56 -# define GLIB_DEPRECATED_TYPE_IN_2_56_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_56 -# define GLIB_AVAILABLE_IN_2_56 GLIB_UNAVAILABLE(2, 56) -# define GLIB_AVAILABLE_MACRO_IN_2_56 GLIB_UNAVAILABLE_MACRO(2, 56) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_56 GLIB_UNAVAILABLE_ENUMERATOR(2, 56) -# define GLIB_AVAILABLE_TYPE_IN_2_56 GLIB_UNAVAILABLE_TYPE(2, 56) -#else -# define GLIB_AVAILABLE_IN_2_56 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_56 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_56 -# define GLIB_AVAILABLE_TYPE_IN_2_56 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_58 -# define GLIB_DEPRECATED_IN_2_58 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_58_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_58 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_58_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_58 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_58 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_58_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_58 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_58_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_58 -# define GLIB_DEPRECATED_MACRO_IN_2_58_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_58 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_58_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_58 -# define GLIB_DEPRECATED_TYPE_IN_2_58_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_58 -# define GLIB_AVAILABLE_IN_2_58 GLIB_UNAVAILABLE(2, 58) -# define GLIB_AVAILABLE_MACRO_IN_2_58 GLIB_UNAVAILABLE_MACRO(2, 58) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_58 GLIB_UNAVAILABLE_ENUMERATOR(2, 58) -# define GLIB_AVAILABLE_TYPE_IN_2_58 GLIB_UNAVAILABLE_TYPE(2, 58) -#else -# define GLIB_AVAILABLE_IN_2_58 _GLIB_EXTERN -# define GLIB_AVAILABLE_MACRO_IN_2_58 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_58 -# define GLIB_AVAILABLE_TYPE_IN_2_58 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_60 -# define GLIB_DEPRECATED_IN_2_60 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_60_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_60 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_60_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_60 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_60 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_60_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_60 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_60_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_60 -# define GLIB_DEPRECATED_MACRO_IN_2_60_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_60 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_60_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_60 -# define GLIB_DEPRECATED_TYPE_IN_2_60_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_60 -# define GLIB_AVAILABLE_IN_2_60 GLIB_UNAVAILABLE(2, 60) -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 GLIB_UNAVAILABLE_STATIC_INLINE(2, 60) -# define GLIB_AVAILABLE_MACRO_IN_2_60 GLIB_UNAVAILABLE_MACRO(2, 60) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_60 GLIB_UNAVAILABLE_ENUMERATOR(2, 60) -# define GLIB_AVAILABLE_TYPE_IN_2_60 GLIB_UNAVAILABLE_TYPE(2, 60) -#else -# define GLIB_AVAILABLE_IN_2_60 _GLIB_EXTERN -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 -# define GLIB_AVAILABLE_MACRO_IN_2_60 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_60 -# define GLIB_AVAILABLE_TYPE_IN_2_60 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_62 -# define GLIB_DEPRECATED_IN_2_62 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_62_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_62 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_62_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_62 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_62 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_62_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_62 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_62_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_62 -# define GLIB_DEPRECATED_MACRO_IN_2_62_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_62 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_62_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_62 -# define GLIB_DEPRECATED_TYPE_IN_2_62_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_62 -# define GLIB_AVAILABLE_IN_2_62 GLIB_UNAVAILABLE(2, 62) -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 GLIB_UNAVAILABLE_STATIC_INLINE(2, 62) -# define GLIB_AVAILABLE_MACRO_IN_2_62 GLIB_UNAVAILABLE_MACRO(2, 62) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_62 GLIB_UNAVAILABLE_ENUMERATOR(2, 62) -# define GLIB_AVAILABLE_TYPE_IN_2_62 GLIB_UNAVAILABLE_TYPE(2, 62) -#else -# define GLIB_AVAILABLE_IN_2_62 _GLIB_EXTERN -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 -# define GLIB_AVAILABLE_MACRO_IN_2_62 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_62 -# define GLIB_AVAILABLE_TYPE_IN_2_62 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_64 -# define GLIB_DEPRECATED_IN_2_64 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_64_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_64 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_64_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_64 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_64 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_64_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_64 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_64_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_64 -# define GLIB_DEPRECATED_MACRO_IN_2_64_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_64 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_64_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_64 -# define GLIB_DEPRECATED_TYPE_IN_2_64_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_64 -# define GLIB_AVAILABLE_IN_2_64 GLIB_UNAVAILABLE(2, 64) -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 GLIB_UNAVAILABLE_STATIC_INLINE(2, 64) -# define GLIB_AVAILABLE_MACRO_IN_2_64 GLIB_UNAVAILABLE_MACRO(2, 64) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_64 GLIB_UNAVAILABLE_ENUMERATOR(2, 64) -# define GLIB_AVAILABLE_TYPE_IN_2_64 GLIB_UNAVAILABLE_TYPE(2, 64) -#else -# define GLIB_AVAILABLE_IN_2_64 _GLIB_EXTERN -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 -# define GLIB_AVAILABLE_MACRO_IN_2_64 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_64 -# define GLIB_AVAILABLE_TYPE_IN_2_64 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_66 -# define GLIB_DEPRECATED_IN_2_66 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_66_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_66 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_66_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_66 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_66 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_66_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_66 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_66_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_66 -# define GLIB_DEPRECATED_MACRO_IN_2_66_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_66 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_66_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_66 -# define GLIB_DEPRECATED_TYPE_IN_2_66_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_66 -# define GLIB_AVAILABLE_IN_2_66 GLIB_UNAVAILABLE(2, 66) -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_66 GLIB_UNAVAILABLE_STATIC_INLINE(2, 66) -# define GLIB_AVAILABLE_MACRO_IN_2_66 GLIB_UNAVAILABLE_MACRO(2, 66) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_66 GLIB_UNAVAILABLE_ENUMERATOR(2, 66) -# define GLIB_AVAILABLE_TYPE_IN_2_66 GLIB_UNAVAILABLE_TYPE(2, 66) -#else -# define GLIB_AVAILABLE_IN_2_66 _GLIB_EXTERN -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_66 -# define GLIB_AVAILABLE_MACRO_IN_2_66 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_66 -# define GLIB_AVAILABLE_TYPE_IN_2_66 -#endif - -#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_68 -# define GLIB_DEPRECATED_IN_2_68 GLIB_DEPRECATED -# define GLIB_DEPRECATED_IN_2_68_FOR(f) GLIB_DEPRECATED_FOR(f) -# define GLIB_DEPRECATED_MACRO_IN_2_68 GLIB_DEPRECATED_MACRO -# define GLIB_DEPRECATED_MACRO_IN_2_68_FOR(f) GLIB_DEPRECATED_MACRO_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_68 GLIB_DEPRECATED_ENUMERATOR -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) GLIB_DEPRECATED_ENUMERATOR_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_68 GLIB_DEPRECATED_TYPE -# define GLIB_DEPRECATED_TYPE_IN_2_68_FOR(f) GLIB_DEPRECATED_TYPE_FOR(f) -#else -# define GLIB_DEPRECATED_IN_2_68 _GLIB_EXTERN -# define GLIB_DEPRECATED_IN_2_68_FOR(f) _GLIB_EXTERN -# define GLIB_DEPRECATED_MACRO_IN_2_68 -# define GLIB_DEPRECATED_MACRO_IN_2_68_FOR(f) -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_68 -# define GLIB_DEPRECATED_ENUMERATOR_IN_2_68_FOR(f) -# define GLIB_DEPRECATED_TYPE_IN_2_68 -# define GLIB_DEPRECATED_TYPE_IN_2_68_FOR(f) -#endif - -#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_68 -# define GLIB_AVAILABLE_IN_2_68 GLIB_UNAVAILABLE(2, 68) -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_68 GLIB_UNAVAILABLE_STATIC_INLINE(2, 68) -# define GLIB_AVAILABLE_MACRO_IN_2_68 GLIB_UNAVAILABLE_MACRO(2, 68) -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_68 GLIB_UNAVAILABLE_ENUMERATOR(2, 68) -# define GLIB_AVAILABLE_TYPE_IN_2_68 GLIB_UNAVAILABLE_TYPE(2, 68) -#else -# define GLIB_AVAILABLE_IN_2_68 _GLIB_EXTERN -# define GLIB_AVAILABLE_STATIC_INLINE_IN_2_68 -# define GLIB_AVAILABLE_MACRO_IN_2_68 -# define GLIB_AVAILABLE_ENUMERATOR_IN_2_68 -# define GLIB_AVAILABLE_TYPE_IN_2_68 -#endif - -#endif /* __G_VERSION_MACROS_H__ */ -#include - -G_BEGIN_DECLS - -/* Provide type definitions for commonly used types. - * These are useful because a "gint8" can be adjusted - * to be 1 byte (8 bits) on all platforms. Similarly and - * more importantly, "gint32" can be adjusted to be - * 4 bytes (32 bits) on all platforms. - */ - -typedef char gchar; -typedef short gshort; -typedef long glong; -typedef int gint; -typedef gint gboolean; - -typedef unsigned char guchar; -typedef unsigned short gushort; -typedef unsigned long gulong; -typedef unsigned int guint; - -typedef float gfloat; -typedef double gdouble; - -/* Define min and max constants for the fixed size numerical types */ -/** - * G_MININT8: (value -128) - * - * The minimum value which can be held in a #gint8. - * - * Since: 2.4 - */ -#define G_MININT8 ((gint8) (-G_MAXINT8 - 1)) -#define G_MAXINT8 ((gint8) 0x7f) -#define G_MAXUINT8 ((guint8) 0xff) - -/** - * G_MININT16: (value -32768) - * - * The minimum value which can be held in a #gint16. - * - * Since: 2.4 - */ -#define G_MININT16 ((gint16) (-G_MAXINT16 - 1)) -#define G_MAXINT16 ((gint16) 0x7fff) -#define G_MAXUINT16 ((guint16) 0xffff) - -/** - * G_MININT32: (value -2147483648) - * - * The minimum value which can be held in a #gint32. - * - * Since: 2.4 - */ -#define G_MININT32 ((gint32) (-G_MAXINT32 - 1)) -#define G_MAXINT32 ((gint32) 0x7fffffff) -#define G_MAXUINT32 ((guint32) 0xffffffff) - -/** - * G_MININT64: (value -9223372036854775808) - * - * The minimum value which can be held in a #gint64. - */ -#define G_MININT64 ((gint64) (-G_MAXINT64 - G_GINT64_CONSTANT(1))) -#define G_MAXINT64 G_GINT64_CONSTANT(0x7fffffffffffffff) -#define G_MAXUINT64 G_GUINT64_CONSTANT(0xffffffffffffffff) - -typedef void* gpointer; -typedef const void *gconstpointer; - -typedef gint (*GCompareFunc) (gconstpointer a, - gconstpointer b); -typedef gint (*GCompareDataFunc) (gconstpointer a, - gconstpointer b, - gpointer user_data); -typedef gboolean (*GEqualFunc) (gconstpointer a, - gconstpointer b); -typedef void (*GDestroyNotify) (gpointer data); -typedef void (*GFunc) (gpointer data, - gpointer user_data); -typedef guint (*GHashFunc) (gconstpointer key); -typedef void (*GHFunc) (gpointer key, - gpointer value, - gpointer user_data); - -/** - * GCopyFunc: - * @src: (not nullable): A pointer to the data which should be copied - * @data: Additional data - * - * A function of this signature is used to copy the node data - * when doing a deep-copy of a tree. - * - * Returns: (not nullable): A pointer to the copy - * - * Since: 2.4 - */ -typedef gpointer (*GCopyFunc) (gconstpointer src, - gpointer data); -/** - * GFreeFunc: - * @data: a data pointer - * - * Declares a type of function which takes an arbitrary - * data pointer argument and has no return value. It is - * not currently used in GLib or GTK+. - */ -typedef void (*GFreeFunc) (gpointer data); - -/** - * GTranslateFunc: - * @str: the untranslated string - * @data: user data specified when installing the function, e.g. - * in g_option_group_set_translate_func() - * - * The type of functions which are used to translate user-visible - * strings, for output. - * - * Returns: a translation of the string for the current locale. - * The returned string is owned by GLib and must not be freed. - */ -typedef const gchar * (*GTranslateFunc) (const gchar *str, - gpointer data); - - -/* Define some mathematical constants that aren't available - * symbolically in some strict ISO C implementations. - * - * Note that the large number of digits used in these definitions - * doesn't imply that GLib or current computers in general would be - * able to handle floating point numbers with an accuracy like this. - * It's mostly an exercise in futility and future proofing. For - * extended precision floating point support, look somewhere else - * than GLib. - */ -#define G_E 2.7182818284590452353602874713526624977572470937000 -#define G_LN2 0.69314718055994530941723212145817656807550013436026 -#define G_LN10 2.3025850929940456840179914546843642076011014886288 -#define G_PI 3.1415926535897932384626433832795028841971693993751 -#define G_PI_2 1.5707963267948966192313216916397514420985846996876 -#define G_PI_4 0.78539816339744830961566084581987572104929234984378 -#define G_SQRT2 1.4142135623730950488016887242096980785696718753769 - -/* Portable endian checks and conversions - * - * glibconfig.h defines G_BYTE_ORDER which expands to one of - * the below macros. - */ -#define G_LITTLE_ENDIAN 1234 -#define G_BIG_ENDIAN 4321 -#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */ - - -/* Basic bit swapping functions - */ -#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \ - (guint16) ((guint16) (val) >> 8) | \ - (guint16) ((guint16) (val) << 8))) - -#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \ - (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \ - (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \ - (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \ - (((guint32) (val) & (guint32) 0xff000000U) >> 24))) - -#define GUINT64_SWAP_LE_BE_CONSTANT(val) ((guint64) ( \ - (((guint64) (val) & \ - (guint64) G_GINT64_CONSTANT (0x00000000000000ffU)) << 56) | \ - (((guint64) (val) & \ - (guint64) G_GINT64_CONSTANT (0x000000000000ff00U)) << 40) | \ - (((guint64) (val) & \ - (guint64) G_GINT64_CONSTANT (0x0000000000ff0000U)) << 24) | \ - (((guint64) (val) & \ - (guint64) G_GINT64_CONSTANT (0x00000000ff000000U)) << 8) | \ - (((guint64) (val) & \ - (guint64) G_GINT64_CONSTANT (0x000000ff00000000U)) >> 8) | \ - (((guint64) (val) & \ - (guint64) G_GINT64_CONSTANT (0x0000ff0000000000U)) >> 24) | \ - (((guint64) (val) & \ - (guint64) G_GINT64_CONSTANT (0x00ff000000000000U)) >> 40) | \ - (((guint64) (val) & \ - (guint64) G_GINT64_CONSTANT (0xff00000000000000U)) >> 56))) - -/* Arch specific stuff for speed - */ -#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) - -# if __GNUC__ >= 4 && defined (__GNUC_MINOR__) && __GNUC_MINOR__ >= 3 -# define GUINT32_SWAP_LE_BE(val) ((guint32) __builtin_bswap32 ((guint32) (val))) -# define GUINT64_SWAP_LE_BE(val) ((guint64) __builtin_bswap64 ((guint64) (val))) -# endif - -# if defined (__i386__) -# define GUINT16_SWAP_LE_BE_IA32(val) \ - (G_GNUC_EXTENSION \ - ({ guint16 __v, __x = ((guint16) (val)); \ - if (__builtin_constant_p (__x)) \ - __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \ - else \ - __asm__ ("rorw $8, %w0" \ - : "=r" (__v) \ - : "0" (__x) \ - : "cc"); \ - __v; })) -# if !defined (__i486__) && !defined (__i586__) \ - && !defined (__pentium__) && !defined (__i686__) \ - && !defined (__pentiumpro__) && !defined (__pentium4__) -# define GUINT32_SWAP_LE_BE_IA32(val) \ - (G_GNUC_EXTENSION \ - ({ guint32 __v, __x = ((guint32) (val)); \ - if (__builtin_constant_p (__x)) \ - __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ - else \ - __asm__ ("rorw $8, %w0\n\t" \ - "rorl $16, %0\n\t" \ - "rorw $8, %w0" \ - : "=r" (__v) \ - : "0" (__x) \ - : "cc"); \ - __v; })) -# else /* 486 and higher has bswap */ -# define GUINT32_SWAP_LE_BE_IA32(val) \ - (G_GNUC_EXTENSION \ - ({ guint32 __v, __x = ((guint32) (val)); \ - if (__builtin_constant_p (__x)) \ - __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ - else \ - __asm__ ("bswap %0" \ - : "=r" (__v) \ - : "0" (__x)); \ - __v; })) -# endif /* processor specific 32-bit stuff */ -# define GUINT64_SWAP_LE_BE_IA32(val) \ - (G_GNUC_EXTENSION \ - ({ union { guint64 __ll; \ - guint32 __l[2]; } __w, __r; \ - __w.__ll = ((guint64) (val)); \ - if (__builtin_constant_p (__w.__ll)) \ - __r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (__w.__ll); \ - else \ - { \ - __r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]); \ - __r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]); \ - } \ - __r.__ll; })) - /* Possibly just use the constant version and let gcc figure it out? */ -# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val)) -# ifndef GUINT32_SWAP_LE_BE -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val)) -# endif -# ifndef GUINT64_SWAP_LE_BE -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA32 (val)) -# endif -# elif defined (__ia64__) -# define GUINT16_SWAP_LE_BE_IA64(val) \ - (G_GNUC_EXTENSION \ - ({ guint16 __v, __x = ((guint16) (val)); \ - if (__builtin_constant_p (__x)) \ - __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \ - else \ - __asm__ __volatile__ ("shl %0 = %1, 48 ;;" \ - "mux1 %0 = %0, @rev ;;" \ - : "=r" (__v) \ - : "r" (__x)); \ - __v; })) -# define GUINT32_SWAP_LE_BE_IA64(val) \ - (G_GNUC_EXTENSION \ - ({ guint32 __v, __x = ((guint32) (val)); \ - if (__builtin_constant_p (__x)) \ - __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ - else \ - __asm__ __volatile__ ("shl %0 = %1, 32 ;;" \ - "mux1 %0 = %0, @rev ;;" \ - : "=r" (__v) \ - : "r" (__x)); \ - __v; })) -# define GUINT64_SWAP_LE_BE_IA64(val) \ - (G_GNUC_EXTENSION \ - ({ guint64 __v, __x = ((guint64) (val)); \ - if (__builtin_constant_p (__x)) \ - __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \ - else \ - __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \ - : "=r" (__v) \ - : "r" (__x)); \ - __v; })) -# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA64 (val)) -# ifndef GUINT32_SWAP_LE_BE -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA64 (val)) -# endif -# ifndef GUINT64_SWAP_LE_BE -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA64 (val)) -# endif -# elif defined (__x86_64__) -# define GUINT32_SWAP_LE_BE_X86_64(val) \ - (G_GNUC_EXTENSION \ - ({ guint32 __v, __x = ((guint32) (val)); \ - if (__builtin_constant_p (__x)) \ - __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \ - else \ - __asm__ ("bswapl %0" \ - : "=r" (__v) \ - : "0" (__x)); \ - __v; })) -# define GUINT64_SWAP_LE_BE_X86_64(val) \ - (G_GNUC_EXTENSION \ - ({ guint64 __v, __x = ((guint64) (val)); \ - if (__builtin_constant_p (__x)) \ - __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \ - else \ - __asm__ ("bswapq %0" \ - : "=r" (__v) \ - : "0" (__x)); \ - __v; })) - /* gcc seems to figure out optimal code for this on its own */ -# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) -# ifndef GUINT32_SWAP_LE_BE -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val)) -# endif -# ifndef GUINT64_SWAP_LE_BE -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val)) -# endif -# else /* generic gcc */ -# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) -# ifndef GUINT32_SWAP_LE_BE -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) -# endif -# ifndef GUINT64_SWAP_LE_BE -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val)) -# endif -# endif -#else /* generic */ -# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val)) -# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val)) -# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val)) -#endif /* generic */ - -#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val)) -#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val)) -#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \ - (((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \ - (((guint32) (val) & (guint32) 0xffff0000U) >> 16))) -#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \ - (((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \ - (((guint32) (val) & (guint32) 0xff00ff00U) >> 8))) - -/* The G*_TO_?E() macros are defined in glibconfig.h. - * The transformation is symmetric, so the FROM just maps to the TO. - */ -#define GINT16_FROM_LE(val) (GINT16_TO_LE (val)) -#define GUINT16_FROM_LE(val) (GUINT16_TO_LE (val)) -#define GINT16_FROM_BE(val) (GINT16_TO_BE (val)) -#define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val)) -#define GINT32_FROM_LE(val) (GINT32_TO_LE (val)) -#define GUINT32_FROM_LE(val) (GUINT32_TO_LE (val)) -#define GINT32_FROM_BE(val) (GINT32_TO_BE (val)) -#define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val)) - -#define GINT64_FROM_LE(val) (GINT64_TO_LE (val)) -#define GUINT64_FROM_LE(val) (GUINT64_TO_LE (val)) -#define GINT64_FROM_BE(val) (GINT64_TO_BE (val)) -#define GUINT64_FROM_BE(val) (GUINT64_TO_BE (val)) - -#define GLONG_FROM_LE(val) (GLONG_TO_LE (val)) -#define GULONG_FROM_LE(val) (GULONG_TO_LE (val)) -#define GLONG_FROM_BE(val) (GLONG_TO_BE (val)) -#define GULONG_FROM_BE(val) (GULONG_TO_BE (val)) - -#define GINT_FROM_LE(val) (GINT_TO_LE (val)) -#define GUINT_FROM_LE(val) (GUINT_TO_LE (val)) -#define GINT_FROM_BE(val) (GINT_TO_BE (val)) -#define GUINT_FROM_BE(val) (GUINT_TO_BE (val)) - -#define GSIZE_FROM_LE(val) (GSIZE_TO_LE (val)) -#define GSSIZE_FROM_LE(val) (GSSIZE_TO_LE (val)) -#define GSIZE_FROM_BE(val) (GSIZE_TO_BE (val)) -#define GSSIZE_FROM_BE(val) (GSSIZE_TO_BE (val)) - -/* Portable versions of host-network order stuff - */ -#define g_ntohl(val) (GUINT32_FROM_BE (val)) -#define g_ntohs(val) (GUINT16_FROM_BE (val)) -#define g_htonl(val) (GUINT32_TO_BE (val)) -#define g_htons(val) (GUINT16_TO_BE (val)) - -/* Overflow-checked unsigned integer arithmetic - */ -#ifndef _GLIB_TEST_OVERFLOW_FALLBACK -/* https://bugzilla.gnome.org/show_bug.cgi?id=769104 */ -#if __GNUC__ >= 5 && !defined(__INTEL_COMPILER) -#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS -#elif g_macro__has_builtin(__builtin_uadd_overflow) -#define _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS -#endif -#endif - -#define g_uint_checked_add(dest, a, b) \ - _GLIB_CHECKED_ADD_U32(dest, a, b) -#define g_uint_checked_mul(dest, a, b) \ - _GLIB_CHECKED_MUL_U32(dest, a, b) - -#define g_uint64_checked_add(dest, a, b) \ - _GLIB_CHECKED_ADD_U64(dest, a, b) -#define g_uint64_checked_mul(dest, a, b) \ - _GLIB_CHECKED_MUL_U64(dest, a, b) - -#if GLIB_SIZEOF_SIZE_T == 8 -#define g_size_checked_add(dest, a, b) \ - _GLIB_CHECKED_ADD_U64(dest, a, b) -#define g_size_checked_mul(dest, a, b) \ - _GLIB_CHECKED_MUL_U64(dest, a, b) -#else -#define g_size_checked_add(dest, a, b) \ - _GLIB_CHECKED_ADD_U32(dest, a, b) -#define g_size_checked_mul(dest, a, b) \ - _GLIB_CHECKED_MUL_U32(dest, a, b) -#endif - -/* The names of the following inlines are private. Use the macro - * definitions above. - */ -#ifdef _GLIB_HAVE_BUILTIN_OVERFLOW_CHECKS -static inline gboolean _GLIB_CHECKED_ADD_U32 (guint32 *dest, guint32 a, guint32 b) { - return !__builtin_uadd_overflow(a, b, dest); } -static inline gboolean _GLIB_CHECKED_MUL_U32 (guint32 *dest, guint32 a, guint32 b) { - return !__builtin_umul_overflow(a, b, dest); } -static inline gboolean _GLIB_CHECKED_ADD_U64 (guint64 *dest, guint64 a, guint64 b) { - G_STATIC_ASSERT(sizeof (unsigned long long) == sizeof (guint64)); - return !__builtin_uaddll_overflow(a, b, (unsigned long long *) dest); } -static inline gboolean _GLIB_CHECKED_MUL_U64 (guint64 *dest, guint64 a, guint64 b) { - return !__builtin_umulll_overflow(a, b, (unsigned long long *) dest); } -#else -static inline gboolean _GLIB_CHECKED_ADD_U32 (guint32 *dest, guint32 a, guint32 b) { - *dest = a + b; return *dest >= a; } -static inline gboolean _GLIB_CHECKED_MUL_U32 (guint32 *dest, guint32 a, guint32 b) { - *dest = a * b; return !a || *dest / a == b; } -static inline gboolean _GLIB_CHECKED_ADD_U64 (guint64 *dest, guint64 a, guint64 b) { - *dest = a + b; return *dest >= a; } -static inline gboolean _GLIB_CHECKED_MUL_U64 (guint64 *dest, guint64 a, guint64 b) { - *dest = a * b; return !a || *dest / a == b; } -#endif - -/* IEEE Standard 754 Single Precision Storage Format (gfloat): - * - * 31 30 23 22 0 - * +--------+---------------+---------------+ - * | s 1bit | e[30:23] 8bit | f[22:0] 23bit | - * +--------+---------------+---------------+ - * B0------------------->B1------->B2-->B3--> - * - * IEEE Standard 754 Double Precision Storage Format (gdouble): - * - * 63 62 52 51 32 31 0 - * +--------+----------------+----------------+ +---------------+ - * | s 1bit | e[62:52] 11bit | f[51:32] 20bit | | f[31:0] 32bit | - * +--------+----------------+----------------+ +---------------+ - * B0--------------->B1---------->B2--->B3----> B4->B5->B6->B7-> - */ -/* subtract from biased_exponent to form base2 exponent (normal numbers) */ -typedef union _GDoubleIEEE754 GDoubleIEEE754; -typedef union _GFloatIEEE754 GFloatIEEE754; -#define G_IEEE754_FLOAT_BIAS (127) -#define G_IEEE754_DOUBLE_BIAS (1023) -/* multiply with base2 exponent to get base10 exponent (normal numbers) */ -#define G_LOG_2_BASE_10 (0.30102999566398119521) -#if G_BYTE_ORDER == G_LITTLE_ENDIAN -union _GFloatIEEE754 -{ - gfloat v_float; - struct { - guint mantissa : 23; - guint biased_exponent : 8; - guint sign : 1; - } mpn; -}; -union _GDoubleIEEE754 -{ - gdouble v_double; - struct { - guint mantissa_low : 32; - guint mantissa_high : 20; - guint biased_exponent : 11; - guint sign : 1; - } mpn; -}; -#elif G_BYTE_ORDER == G_BIG_ENDIAN -union _GFloatIEEE754 -{ - gfloat v_float; - struct { - guint sign : 1; - guint biased_exponent : 8; - guint mantissa : 23; - } mpn; -}; -union _GDoubleIEEE754 -{ - gdouble v_double; - struct { - guint sign : 1; - guint biased_exponent : 11; - guint mantissa_high : 20; - guint mantissa_low : 32; - } mpn; -}; -#else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */ -#error unknown ENDIAN type -#endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */ - -typedef struct _GTimeVal GTimeVal GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); - -struct _GTimeVal -{ - glong tv_sec; - glong tv_usec; -} GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); - -typedef gint grefcount; -typedef gint gatomicrefcount; /* should be accessed only using atomics */ - -G_END_DECLS - -/* We prefix variable declarations so they can - * properly get exported in Windows DLLs. - */ -#ifndef GLIB_VAR -# ifdef G_PLATFORM_WIN32 -# ifdef GLIB_STATIC_COMPILATION -# define GLIB_VAR extern -# else /* !GLIB_STATIC_COMPILATION */ -# ifdef GLIB_COMPILATION -# ifdef DLL_EXPORT -# define GLIB_VAR extern __declspec(dllexport) -# else /* !DLL_EXPORT */ -# define GLIB_VAR extern -# endif /* !DLL_EXPORT */ -# else /* !GLIB_COMPILATION */ -# define GLIB_VAR extern __declspec(dllimport) -# endif /* !GLIB_COMPILATION */ -# endif /* !GLIB_STATIC_COMPILATION */ -# else /* !G_PLATFORM_WIN32 */ -# define GLIB_VAR _GLIB_EXTERN -# endif /* !G_PLATFORM_WIN32 */ -#endif /* GLIB_VAR */ - -#endif /* __G_TYPES_H__ */ - -#if defined(__BIONIC__) && defined (GLIB_HAVE_ALLOCA_H) -# include -#elif defined(__GNUC__) -/* GCC does the right thing */ -# undef alloca -# define alloca(size) __builtin_alloca (size) -#elif defined (GLIB_HAVE_ALLOCA_H) -/* a native and working alloca.h is there */ -# include -#else /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */ -# if defined(_MSC_VER) || defined(__DMC__) -# include -# define alloca _alloca -# else /* !_MSC_VER && !__DMC__ */ -# ifdef _AIX -# pragma alloca -# else /* !_AIX */ -# ifndef alloca /* predefined by HP cc +Olibcalls */ -G_BEGIN_DECLS -char *alloca (); -G_END_DECLS -# endif /* !alloca */ -# endif /* !_AIX */ -# endif /* !_MSC_VER && !__DMC__ */ -#endif /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */ - -/** - * g_alloca: - * @size: number of bytes to allocate. - * - * Allocates @size bytes on the stack; these bytes will be freed when the current - * stack frame is cleaned up. This macro essentially just wraps the alloca() - * function present on most UNIX variants. - * Thus it provides the same advantages and pitfalls as alloca(): - * - * - alloca() is very fast, as on most systems it's implemented by just adjusting - * the stack pointer register. - * - * - It doesn't cause any memory fragmentation, within its scope, separate alloca() - * blocks just build up and are released together at function end. - * - * - Allocation sizes have to fit into the current stack frame. For instance in a - * threaded environment on Linux, the per-thread stack size is limited to 2 Megabytes, - * so be sparse with alloca() uses. - * - * - Allocation failure due to insufficient stack space is not indicated with a %NULL - * return like e.g. with malloc(). Instead, most systems probably handle it the same - * way as out of stack space situations from infinite function recursion, i.e. - * with a segmentation fault. - * - * - Special care has to be taken when mixing alloca() with GNU C variable sized arrays. - * Stack space allocated with alloca() in the same scope as a variable sized array - * will be freed together with the variable sized array upon exit of that scope, and - * not upon exit of the enclosing function scope. - * - * Returns: space for @size bytes, allocated on the stack - */ -#define g_alloca(size) alloca (size) -/** - * g_newa: - * @struct_type: Type of memory chunks to be allocated - * @n_structs: Number of chunks to be allocated - * - * Wraps g_alloca() in a more typesafe manner. - * - * Returns: Pointer to stack space for @n_structs chunks of type @struct_type - */ -#define g_newa(struct_type, n_structs) ((struct_type*) g_alloca (sizeof (struct_type) * (gsize) (n_structs))) - -#endif /* __G_ALLOCA_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_ARRAY_H__ -#define __G_ARRAY_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GBytes GBytes; -typedef struct _GArray GArray; -typedef struct _GByteArray GByteArray; -typedef struct _GPtrArray GPtrArray; - -struct _GArray -{ - gchar *data; - guint len; -}; - -struct _GByteArray -{ - guint8 *data; - guint len; -}; - -struct _GPtrArray -{ - gpointer *pdata; - guint len; -}; - -/* Resizable arrays. remove fills any cleared spot and shortens the - * array, while preserving the order. remove_fast will distort the - * order by moving the last element to the position of the removed. - */ - -#define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1) -#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &(v), 1) -#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &(v), 1) -#define g_array_index(a,t,i) (((t*) (void *) (a)->data) [(i)]) - -GLIB_AVAILABLE_IN_ALL -GArray* g_array_new (gboolean zero_terminated, - gboolean clear_, - guint element_size); -GLIB_AVAILABLE_IN_2_64 -gpointer g_array_steal (GArray *array, - gsize *len); -GLIB_AVAILABLE_IN_ALL -GArray* g_array_sized_new (gboolean zero_terminated, - gboolean clear_, - guint element_size, - guint reserved_size); -GLIB_AVAILABLE_IN_2_62 -GArray* g_array_copy (GArray *array); -GLIB_AVAILABLE_IN_ALL -gchar* g_array_free (GArray *array, - gboolean free_segment); -GLIB_AVAILABLE_IN_ALL -GArray *g_array_ref (GArray *array); -GLIB_AVAILABLE_IN_ALL -void g_array_unref (GArray *array); -GLIB_AVAILABLE_IN_ALL -guint g_array_get_element_size (GArray *array); -GLIB_AVAILABLE_IN_ALL -GArray* g_array_append_vals (GArray *array, - gconstpointer data, - guint len); -GLIB_AVAILABLE_IN_ALL -GArray* g_array_prepend_vals (GArray *array, - gconstpointer data, - guint len); -GLIB_AVAILABLE_IN_ALL -GArray* g_array_insert_vals (GArray *array, - guint index_, - gconstpointer data, - guint len); -GLIB_AVAILABLE_IN_ALL -GArray* g_array_set_size (GArray *array, - guint length); -GLIB_AVAILABLE_IN_ALL -GArray* g_array_remove_index (GArray *array, - guint index_); -GLIB_AVAILABLE_IN_ALL -GArray* g_array_remove_index_fast (GArray *array, - guint index_); -GLIB_AVAILABLE_IN_ALL -GArray* g_array_remove_range (GArray *array, - guint index_, - guint length); -GLIB_AVAILABLE_IN_ALL -void g_array_sort (GArray *array, - GCompareFunc compare_func); -GLIB_AVAILABLE_IN_ALL -void g_array_sort_with_data (GArray *array, - GCompareDataFunc compare_func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_62 -gboolean g_array_binary_search (GArray *array, - gconstpointer target, - GCompareFunc compare_func, - guint *out_match_index); -GLIB_AVAILABLE_IN_ALL -void g_array_set_clear_func (GArray *array, - GDestroyNotify clear_func); - -/* Resizable pointer array. This interface is much less complicated - * than the above. Add appends a pointer. Remove fills any cleared - * spot and shortens the array. remove_fast will again distort order. - */ -#define g_ptr_array_index(array,index_) ((array)->pdata)[index_] -GLIB_AVAILABLE_IN_ALL -GPtrArray* g_ptr_array_new (void); -GLIB_AVAILABLE_IN_ALL -GPtrArray* g_ptr_array_new_with_free_func (GDestroyNotify element_free_func); -GLIB_AVAILABLE_IN_2_64 -gpointer* g_ptr_array_steal (GPtrArray *array, - gsize *len); -GLIB_AVAILABLE_IN_2_62 -GPtrArray *g_ptr_array_copy (GPtrArray *array, - GCopyFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -GPtrArray* g_ptr_array_sized_new (guint reserved_size); -GLIB_AVAILABLE_IN_ALL -GPtrArray* g_ptr_array_new_full (guint reserved_size, - GDestroyNotify element_free_func); -GLIB_AVAILABLE_IN_ALL -gpointer* g_ptr_array_free (GPtrArray *array, - gboolean free_seg); -GLIB_AVAILABLE_IN_ALL -GPtrArray* g_ptr_array_ref (GPtrArray *array); -GLIB_AVAILABLE_IN_ALL -void g_ptr_array_unref (GPtrArray *array); -GLIB_AVAILABLE_IN_ALL -void g_ptr_array_set_free_func (GPtrArray *array, - GDestroyNotify element_free_func); -GLIB_AVAILABLE_IN_ALL -void g_ptr_array_set_size (GPtrArray *array, - gint length); -GLIB_AVAILABLE_IN_ALL -gpointer g_ptr_array_remove_index (GPtrArray *array, - guint index_); -GLIB_AVAILABLE_IN_ALL -gpointer g_ptr_array_remove_index_fast (GPtrArray *array, - guint index_); -GLIB_AVAILABLE_IN_2_58 -gpointer g_ptr_array_steal_index (GPtrArray *array, - guint index_); -GLIB_AVAILABLE_IN_2_58 -gpointer g_ptr_array_steal_index_fast (GPtrArray *array, - guint index_); -GLIB_AVAILABLE_IN_ALL -gboolean g_ptr_array_remove (GPtrArray *array, - gpointer data); -GLIB_AVAILABLE_IN_ALL -gboolean g_ptr_array_remove_fast (GPtrArray *array, - gpointer data); -GLIB_AVAILABLE_IN_ALL -GPtrArray *g_ptr_array_remove_range (GPtrArray *array, - guint index_, - guint length); -GLIB_AVAILABLE_IN_ALL -void g_ptr_array_add (GPtrArray *array, - gpointer data); -GLIB_AVAILABLE_IN_2_62 -void g_ptr_array_extend (GPtrArray *array_to_extend, - GPtrArray *array, - GCopyFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_62 -void g_ptr_array_extend_and_steal (GPtrArray *array_to_extend, - GPtrArray *array); -GLIB_AVAILABLE_IN_2_40 -void g_ptr_array_insert (GPtrArray *array, - gint index_, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_ptr_array_sort (GPtrArray *array, - GCompareFunc compare_func); -GLIB_AVAILABLE_IN_ALL -void g_ptr_array_sort_with_data (GPtrArray *array, - GCompareDataFunc compare_func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -void g_ptr_array_foreach (GPtrArray *array, - GFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_54 -gboolean g_ptr_array_find (GPtrArray *haystack, - gconstpointer needle, - guint *index_); -GLIB_AVAILABLE_IN_2_54 -gboolean g_ptr_array_find_with_equal_func (GPtrArray *haystack, - gconstpointer needle, - GEqualFunc equal_func, - guint *index_); - - -/* Byte arrays, an array of guint8. Implemented as a GArray, - * but type-safe. - */ - -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_new (void); -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_new_take (guint8 *data, - gsize len); -GLIB_AVAILABLE_IN_2_64 -guint8* g_byte_array_steal (GByteArray *array, - gsize *len); -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_sized_new (guint reserved_size); -GLIB_AVAILABLE_IN_ALL -guint8* g_byte_array_free (GByteArray *array, - gboolean free_segment); -GLIB_AVAILABLE_IN_ALL -GBytes* g_byte_array_free_to_bytes (GByteArray *array); -GLIB_AVAILABLE_IN_ALL -GByteArray *g_byte_array_ref (GByteArray *array); -GLIB_AVAILABLE_IN_ALL -void g_byte_array_unref (GByteArray *array); -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_append (GByteArray *array, - const guint8 *data, - guint len); -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_prepend (GByteArray *array, - const guint8 *data, - guint len); -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_set_size (GByteArray *array, - guint length); -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_remove_index (GByteArray *array, - guint index_); -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_remove_index_fast (GByteArray *array, - guint index_); -GLIB_AVAILABLE_IN_ALL -GByteArray* g_byte_array_remove_range (GByteArray *array, - guint index_, - guint length); -GLIB_AVAILABLE_IN_ALL -void g_byte_array_sort (GByteArray *array, - GCompareFunc compare_func); -GLIB_AVAILABLE_IN_ALL -void g_byte_array_sort_with_data (GByteArray *array, - GCompareDataFunc compare_func, - gpointer user_data); - -G_END_DECLS - -#endif /* __G_ARRAY_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_ASYNCQUEUE_H__ -#define __G_ASYNCQUEUE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_THREAD_H__ -#define __G_THREAD_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* - * Copyright © 2011 Ryan Lortie - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Author: Ryan Lortie - */ - -#ifndef __G_ATOMIC_H__ -#define __G_ATOMIC_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -gint g_atomic_int_get (const volatile gint *atomic); -GLIB_AVAILABLE_IN_ALL -void g_atomic_int_set (volatile gint *atomic, - gint newval); -GLIB_AVAILABLE_IN_ALL -void g_atomic_int_inc (volatile gint *atomic); -GLIB_AVAILABLE_IN_ALL -gboolean g_atomic_int_dec_and_test (volatile gint *atomic); -GLIB_AVAILABLE_IN_ALL -gboolean g_atomic_int_compare_and_exchange (volatile gint *atomic, - gint oldval, - gint newval); -GLIB_AVAILABLE_IN_ALL -gint g_atomic_int_add (volatile gint *atomic, - gint val); -GLIB_AVAILABLE_IN_2_30 -guint g_atomic_int_and (volatile guint *atomic, - guint val); -GLIB_AVAILABLE_IN_2_30 -guint g_atomic_int_or (volatile guint *atomic, - guint val); -GLIB_AVAILABLE_IN_ALL -guint g_atomic_int_xor (volatile guint *atomic, - guint val); - -GLIB_AVAILABLE_IN_ALL -gpointer g_atomic_pointer_get (const volatile void *atomic); -GLIB_AVAILABLE_IN_ALL -void g_atomic_pointer_set (volatile void *atomic, - gpointer newval); -GLIB_AVAILABLE_IN_ALL -gboolean g_atomic_pointer_compare_and_exchange (volatile void *atomic, - gpointer oldval, - gpointer newval); -GLIB_AVAILABLE_IN_ALL -gssize g_atomic_pointer_add (volatile void *atomic, - gssize val); -GLIB_AVAILABLE_IN_2_30 -gsize g_atomic_pointer_and (volatile void *atomic, - gsize val); -GLIB_AVAILABLE_IN_2_30 -gsize g_atomic_pointer_or (volatile void *atomic, - gsize val); -GLIB_AVAILABLE_IN_ALL -gsize g_atomic_pointer_xor (volatile void *atomic, - gsize val); - -GLIB_DEPRECATED_IN_2_30_FOR(g_atomic_int_add) -gint g_atomic_int_exchange_and_add (volatile gint *atomic, - gint val); - -G_END_DECLS - -#if defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) - -/* We prefer the new C11-style atomic extension of GCC if available */ -#if defined(__ATOMIC_SEQ_CST) - -#undef g_atomic_int_get -#define g_atomic_int_get(atomic) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - gint gaig_temp; \ - (void) (0 ? *(atomic) ^ *(atomic) : 1); \ - __atomic_load ((gint *)(atomic), &gaig_temp, __ATOMIC_SEQ_CST); \ - (gint) gaig_temp; \ - })) -#undef g_atomic_int_set -#define g_atomic_int_set(atomic, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - gint gais_temp = (gint) (newval); \ - (void) (0 ? *(atomic) ^ (newval) : 1); \ - __atomic_store ((gint *)(atomic), &gais_temp, __ATOMIC_SEQ_CST); \ - })) - -#if defined(glib_typeof) -#undef g_atomic_pointer_get -#define g_atomic_pointer_get(atomic) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - glib_typeof (*(atomic)) gapg_temp_newval; \ - glib_typeof ((atomic)) gapg_temp_atomic = (atomic); \ - __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ - gapg_temp_newval; \ - })) -#undef g_atomic_pointer_set -#define g_atomic_pointer_set(atomic, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - glib_typeof ((atomic)) gaps_temp_atomic = (atomic); \ - glib_typeof (*(atomic)) gaps_temp_newval = (newval); \ - (void) (0 ? (gpointer) * (atomic) : NULL); \ - __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ - })) -#else /* if !defined(glib_typeof) */ -#undef g_atomic_pointer_get -#define g_atomic_pointer_get(atomic) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - gpointer gapg_temp_newval; \ - gpointer *gapg_temp_atomic = (gpointer *)(atomic); \ - __atomic_load (gapg_temp_atomic, &gapg_temp_newval, __ATOMIC_SEQ_CST); \ - gapg_temp_newval; \ - })) -#undef g_atomic_pointer_set -#define g_atomic_pointer_set(atomic, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - gpointer *gaps_temp_atomic = (gpointer *)(atomic); \ - gpointer gaps_temp_newval = (gpointer)(newval); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - __atomic_store (gaps_temp_atomic, &gaps_temp_newval, __ATOMIC_SEQ_CST); \ - })) -#endif /* !defined(glib_typeof) */ - -#undef g_atomic_int_inc -#define g_atomic_int_inc(atomic) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ *(atomic) : 1); \ - (void) __atomic_fetch_add ((atomic), 1, __ATOMIC_SEQ_CST); \ - })) -#undef g_atomic_int_dec_and_test -#define g_atomic_int_dec_and_test(atomic) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ *(atomic) : 1); \ - __atomic_fetch_sub ((atomic), 1, __ATOMIC_SEQ_CST) == 1; \ - })) -#undef g_atomic_int_compare_and_exchange -#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ - (G_GNUC_EXTENSION ({ \ - gint gaicae_oldval = (oldval); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \ - __atomic_compare_exchange_n ((atomic), &gaicae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ - })) -#undef g_atomic_int_add -#define g_atomic_int_add(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (val) : 1); \ - (gint) __atomic_fetch_add ((atomic), (val), __ATOMIC_SEQ_CST); \ - })) -#undef g_atomic_int_and -#define g_atomic_int_and(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (val) : 1); \ - (guint) __atomic_fetch_and ((atomic), (val), __ATOMIC_SEQ_CST); \ - })) -#undef g_atomic_int_or -#define g_atomic_int_or(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (val) : 1); \ - (guint) __atomic_fetch_or ((atomic), (val), __ATOMIC_SEQ_CST); \ - })) -#undef g_atomic_int_xor -#define g_atomic_int_xor(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (val) : 1); \ - (guint) __atomic_fetch_xor ((atomic), (val), __ATOMIC_SEQ_CST); \ - })) - -#if defined(glib_typeof) -#undef g_atomic_pointer_compare_and_exchange -#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \ - glib_typeof ((oldval)) gapcae_oldval = (oldval); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ - })) -#else /* if !defined(glib_typeof) */ -#undef g_atomic_pointer_compare_and_exchange -#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof (oldval) == sizeof (gpointer)); \ - gpointer gapcae_oldval = (gpointer)(oldval); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \ - })) -#endif /* defined(glib_typeof) */ -#undef g_atomic_pointer_add -#define g_atomic_pointer_add(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - (void) (0 ? (val) ^ (val) : 1); \ - (gssize) __atomic_fetch_add ((atomic), (val), __ATOMIC_SEQ_CST); \ - })) -#undef g_atomic_pointer_and -#define g_atomic_pointer_and(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - gsize *gapa_atomic = (gsize *) (atomic); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - (void) (0 ? (val) ^ (val) : 1); \ - (gsize) __atomic_fetch_and (gapa_atomic, (val), __ATOMIC_SEQ_CST); \ - })) -#undef g_atomic_pointer_or -#define g_atomic_pointer_or(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - gsize *gapo_atomic = (gsize *) (atomic); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - (void) (0 ? (val) ^ (val) : 1); \ - (gsize) __atomic_fetch_or (gapo_atomic, (val), __ATOMIC_SEQ_CST); \ - })) -#undef g_atomic_pointer_xor -#define g_atomic_pointer_xor(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - gsize *gapx_atomic = (gsize *) (atomic); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gsize)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - (void) (0 ? (val) ^ (val) : 1); \ - (gsize) __atomic_fetch_xor (gapx_atomic, (val), __ATOMIC_SEQ_CST); \ - })) - -#else /* defined(__ATOMIC_SEQ_CST) */ - -/* We want to achieve __ATOMIC_SEQ_CST semantics here. See - * https://en.cppreference.com/w/c/atomic/memory_order#Constants. For load - * operations, that means performing an *acquire*: - * > A load operation with this memory order performs the acquire operation on - * > the affected memory location: no reads or writes in the current thread can - * > be reordered before this load. All writes in other threads that release - * > the same atomic variable are visible in the current thread. - * - * “no reads or writes in the current thread can be reordered before this load” - * is implemented using a compiler barrier (a no-op `__asm__` section) to - * prevent instruction reordering. Writes in other threads are synchronised - * using `__sync_synchronize()`. It’s unclear from the GCC documentation whether - * `__sync_synchronize()` acts as a compiler barrier, hence our explicit use of - * one. - * - * For store operations, `__ATOMIC_SEQ_CST` means performing a *release*: - * > A store operation with this memory order performs the release operation: - * > no reads or writes in the current thread can be reordered after this store. - * > All writes in the current thread are visible in other threads that acquire - * > the same atomic variable (see Release-Acquire ordering below) and writes - * > that carry a dependency into the atomic variable become visible in other - * > threads that consume the same atomic (see Release-Consume ordering below). - * - * “no reads or writes in the current thread can be reordered after this store” - * is implemented using a compiler barrier to prevent instruction reordering. - * “All writes in the current thread are visible in other threads” is implemented - * using `__sync_synchronize()`; similarly for “writes that carry a dependency”. - */ -#undef g_atomic_int_get -#define g_atomic_int_get(atomic) \ - (G_GNUC_EXTENSION ({ \ - gint gaig_result; \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ *(atomic) : 1); \ - gaig_result = (gint) *(atomic); \ - __sync_synchronize (); \ - __asm__ __volatile__ ("" : : : "memory"); \ - gaig_result; \ - })) -#undef g_atomic_int_set -#define g_atomic_int_set(atomic, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (newval) : 1); \ - __sync_synchronize (); \ - __asm__ __volatile__ ("" : : : "memory"); \ - *(atomic) = (newval); \ - })) -#undef g_atomic_pointer_get -#define g_atomic_pointer_get(atomic) \ - (G_GNUC_EXTENSION ({ \ - gpointer gapg_result; \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - gapg_result = (gpointer) *(atomic); \ - __sync_synchronize (); \ - __asm__ __volatile__ ("" : : : "memory"); \ - gapg_result; \ - })) -#if defined(glib_typeof) -#undef g_atomic_pointer_set -#define g_atomic_pointer_set(atomic, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - __sync_synchronize (); \ - __asm__ __volatile__ ("" : : : "memory"); \ - *(atomic) = (glib_typeof (*(atomic))) (gsize) (newval); \ - })) -#else /* if !defined(glib_typeof) */ -#undef g_atomic_pointer_set -#define g_atomic_pointer_set(atomic, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - __sync_synchronize (); \ - __asm__ __volatile__ ("" : : : "memory"); \ - *(atomic) = (gpointer) (gsize) (newval); \ - })) -#endif /* defined(glib_typeof) */ - -#undef g_atomic_int_inc -#define g_atomic_int_inc(atomic) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ *(atomic) : 1); \ - (void) __sync_fetch_and_add ((atomic), 1); \ - })) -#undef g_atomic_int_dec_and_test -#define g_atomic_int_dec_and_test(atomic) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ *(atomic) : 1); \ - __sync_fetch_and_sub ((atomic), 1) == 1; \ - })) -#undef g_atomic_int_compare_and_exchange -#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (newval) ^ (oldval) : 1); \ - __sync_bool_compare_and_swap ((atomic), (oldval), (newval)) ? TRUE : FALSE; \ - })) -#undef g_atomic_int_add -#define g_atomic_int_add(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (val) : 1); \ - (gint) __sync_fetch_and_add ((atomic), (val)); \ - })) -#undef g_atomic_int_and -#define g_atomic_int_and(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (val) : 1); \ - (guint) __sync_fetch_and_and ((atomic), (val)); \ - })) -#undef g_atomic_int_or -#define g_atomic_int_or(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (val) : 1); \ - (guint) __sync_fetch_and_or ((atomic), (val)); \ - })) -#undef g_atomic_int_xor -#define g_atomic_int_xor(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gint)); \ - (void) (0 ? *(atomic) ^ (val) : 1); \ - (guint) __sync_fetch_and_xor ((atomic), (val)); \ - })) - -#undef g_atomic_pointer_compare_and_exchange -#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - __sync_bool_compare_and_swap ((atomic), (oldval), (newval)) ? TRUE : FALSE; \ - })) -#undef g_atomic_pointer_add -#define g_atomic_pointer_add(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - (void) (0 ? (val) ^ (val) : 1); \ - (gssize) __sync_fetch_and_add ((atomic), (val)); \ - })) -#undef g_atomic_pointer_and -#define g_atomic_pointer_and(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - (void) (0 ? (val) ^ (val) : 1); \ - (gsize) __sync_fetch_and_and ((atomic), (val)); \ - })) -#undef g_atomic_pointer_or -#define g_atomic_pointer_or(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - (void) (0 ? (val) ^ (val) : 1); \ - (gsize) __sync_fetch_and_or ((atomic), (val)); \ - })) -#undef g_atomic_pointer_xor -#define g_atomic_pointer_xor(atomic, val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(atomic) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(atomic) : NULL); \ - (void) (0 ? (val) ^ (val) : 1); \ - (gsize) __sync_fetch_and_xor ((atomic), (val)); \ - })) - -#endif /* !defined(__ATOMIC_SEQ_CST) */ - -#else /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */ - -#undef g_atomic_int_get -#define g_atomic_int_get(atomic) \ - (_frida_g_atomic_int_get ((gint *) (atomic))) -#undef g_atomic_int_set -#define g_atomic_int_set(atomic, newval) \ - (_frida_g_atomic_int_set ((gint *) (atomic), (gint) (newval))) -#undef g_atomic_int_compare_and_exchange -#define g_atomic_int_compare_and_exchange(atomic, oldval, newval) \ - (_frida_g_atomic_int_compare_and_exchange ((gint *) (atomic), (oldval), (newval))) -#undef g_atomic_int_add -#define g_atomic_int_add(atomic, val) \ - (_frida_g_atomic_int_add ((gint *) (atomic), (val))) -#undef g_atomic_int_and -#define g_atomic_int_and(atomic, val) \ - (_frida_g_atomic_int_and ((guint *) (atomic), (val))) -#undef g_atomic_int_or -#define g_atomic_int_or(atomic, val) \ - (_frida_g_atomic_int_or ((guint *) (atomic), (val))) -#undef g_atomic_int_xor -#define g_atomic_int_xor(atomic, val) \ - (_frida_g_atomic_int_xor ((guint *) (atomic), (val))) -#undef g_atomic_int_inc -#define g_atomic_int_inc(atomic) \ - (_frida_g_atomic_int_inc ((gint *) (atomic))) -#undef g_atomic_int_dec_and_test -#define g_atomic_int_dec_and_test(atomic) \ - (_frida_g_atomic_int_dec_and_test ((gint *) (atomic))) - -#undef g_atomic_pointer_get -#define g_atomic_pointer_get(atomic) \ - (_frida_g_atomic_pointer_get (atomic)) -#undef g_atomic_pointer_set -#define g_atomic_pointer_set(atomic, newval) \ - (_frida_g_atomic_pointer_set ((atomic), (gpointer) (newval))) -#undef g_atomic_pointer_compare_and_exchange -#define g_atomic_pointer_compare_and_exchange(atomic, oldval, newval) \ - (_frida_g_atomic_pointer_compare_and_exchange ((atomic), (gpointer) (oldval), (gpointer) (newval))) -#undef g_atomic_pointer_add -#define g_atomic_pointer_add(atomic, val) \ - (_frida_g_atomic_pointer_add ((atomic), (gssize) (val))) -#undef g_atomic_pointer_and -#define g_atomic_pointer_and(atomic, val) \ - (_frida_g_atomic_pointer_and ((atomic), (gsize) (val))) -#undef g_atomic_pointer_or -#define g_atomic_pointer_or(atomic, val) \ - (_frida_g_atomic_pointer_or ((atomic), (gsize) (val))) -#undef g_atomic_pointer_xor -#define g_atomic_pointer_xor(atomic, val) \ - (_frida_g_atomic_pointer_xor ((atomic), (gsize) (val))) - -#endif /* defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) */ - -#endif /* __G_ATOMIC_H__ */ -/* gerror.h - Error reporting system - * - * Copyright 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_ERROR_H__ -#define __G_ERROR_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_QUARK_H__ -#define __G_QUARK_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef guint32 GQuark; - -/* Quarks (string<->id association) - */ -GLIB_AVAILABLE_IN_ALL -GQuark g_quark_try_string (const gchar *string); -GLIB_AVAILABLE_IN_ALL -GQuark g_quark_from_static_string (const gchar *string); -GLIB_AVAILABLE_IN_ALL -GQuark g_quark_from_string (const gchar *string); -GLIB_AVAILABLE_IN_ALL -const gchar * g_quark_to_string (GQuark quark) G_GNUC_CONST; - -#define G_DEFINE_QUARK(QN, q_n) \ -GQuark \ -q_n##_quark (void) \ -{ \ - static GQuark q; \ - \ - if G_UNLIKELY (q == 0) \ - q = g_quark_from_static_string (#QN); \ - \ - return q; \ -} - -GLIB_AVAILABLE_IN_ALL -const gchar * g_intern_string (const gchar *string); -GLIB_AVAILABLE_IN_ALL -const gchar * g_intern_static_string (const gchar *string); - -G_END_DECLS - -#endif /* __G_QUARK_H__ */ - -G_BEGIN_DECLS - -/** - * GError: - * @domain: error domain, e.g. #G_FILE_ERROR - * @code: error code, e.g. %G_FILE_ERROR_NOENT - * @message: human-readable informative error message - * - * The `GError` structure contains information about - * an error that has occurred. - */ -typedef struct _GError GError; - -struct _GError -{ - GQuark domain; - gint code; - gchar *message; -}; - -GLIB_AVAILABLE_IN_ALL -GError* g_error_new (GQuark domain, - gint code, - const gchar *format, - ...) G_GNUC_PRINTF (3, 4); - -GLIB_AVAILABLE_IN_ALL -GError* g_error_new_literal (GQuark domain, - gint code, - const gchar *message); -GLIB_AVAILABLE_IN_ALL -GError* g_error_new_valist (GQuark domain, - gint code, - const gchar *format, - va_list args) G_GNUC_PRINTF(3, 0); - -GLIB_AVAILABLE_IN_ALL -void g_error_free (GError *error); -GLIB_AVAILABLE_IN_ALL -GError* g_error_copy (const GError *error); - -GLIB_AVAILABLE_IN_ALL -gboolean g_error_matches (const GError *error, - GQuark domain, - gint code); - -/* if (err) *err = g_error_new(domain, code, format, ...), also has - * some sanity checks. - */ -GLIB_AVAILABLE_IN_ALL -void g_set_error (GError **err, - GQuark domain, - gint code, - const gchar *format, - ...) G_GNUC_PRINTF (4, 5); - -GLIB_AVAILABLE_IN_ALL -void g_set_error_literal (GError **err, - GQuark domain, - gint code, - const gchar *message); - -/* if (dest) *dest = src; also has some sanity checks. - */ -GLIB_AVAILABLE_IN_ALL -void g_propagate_error (GError **dest, - GError *src); - -/* if (err && *err) { g_error_free(*err); *err = NULL; } */ -GLIB_AVAILABLE_IN_ALL -void g_clear_error (GError **err); - -/* if (err) prefix the formatted string to the ->message */ -GLIB_AVAILABLE_IN_ALL -void g_prefix_error (GError **err, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); - -/* g_propagate_error then g_error_prefix on dest */ -GLIB_AVAILABLE_IN_ALL -void g_propagate_prefixed_error (GError **dest, - GError *src, - const gchar *format, - ...) G_GNUC_PRINTF (3, 4); - -G_END_DECLS - -#endif /* __G_ERROR_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_UTILS_H__ -#define __G_UTILS_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -G_BEGIN_DECLS - -/* Define G_VA_COPY() to do the right thing for copying va_list variables. - * glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy. - */ -#if !defined (G_VA_COPY) -# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32)) -# define G_VA_COPY(ap1, ap2) (*(ap1) = *(ap2)) -# elif defined (G_VA_COPY_AS_ARRAY) -# define G_VA_COPY(ap1, ap2) memmove ((ap1), (ap2), sizeof (va_list)) -# else /* va_list is a pointer */ -# define G_VA_COPY(ap1, ap2) ((ap1) = (ap2)) -# endif /* va_list is a pointer */ -#endif /* !G_VA_COPY */ - -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_user_name (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_real_name (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_home_dir (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_tmp_dir (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_host_name (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_prgname (void); -GLIB_AVAILABLE_IN_ALL -void g_set_prgname (const gchar *prgname); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_application_name (void); -GLIB_AVAILABLE_IN_ALL -void g_set_application_name (const gchar *application_name); -GLIB_AVAILABLE_IN_2_64 -gchar * g_get_os_info (const gchar *key_name); - -/** - * G_OS_INFO_KEY_NAME: - * - * A key to get the name of the operating system excluding version information suitable for presentation to the user, e.g. "YoYoOS" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_NAME \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "NAME" - -/** - * G_OS_INFO_KEY_PRETTY_NAME: - * - * A key to get the name of the operating system in a format suitable for presentation to the user, e.g. "YoYoOS Foo" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_PRETTY_NAME \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "PRETTY_NAME" - -/** - * G_OS_INFO_KEY_VERSION: - * - * A key to get the operating system version suitable for presentation to the user, e.g. "42 (Foo)" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_VERSION \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "VERSION" - -/** - * G_OS_INFO_KEY_VERSION_CODENAME: - * - * A key to get a codename identifying the operating system release suitable for processing by scripts or usage in generated filenames, e.g. "foo" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_VERSION_CODENAME \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "VERSION_CODENAME" - -/** - * G_OS_INFO_KEY_VERSION_ID: - * - * A key to get the version of the operating system suitable for processing by scripts or usage in generated filenames, e.g. "42" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_VERSION_ID \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "VERSION_ID" - -/** - * G_OS_INFO_KEY_ID: - * - * A key to get an ID identifying the operating system suitable for processing by scripts or usage in generated filenames, e.g. "yoyoos" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_ID \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "ID" - -/** - * G_OS_INFO_KEY_HOME_URL: - * - * A key to get the homepage for the operating system, e.g. "https://www.yoyo-os.com/" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_HOME_URL \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "HOME_URL" - -/** - * G_OS_INFO_KEY_DOCUMENTATION_URL: - * - * A key to get the documentation page for the operating system, e.g. "https://docs.yoyo-os.com/" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_DOCUMENTATION_URL \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "DOCUMENTATION_URL" - -/** - * G_OS_INFO_KEY_SUPPORT_URL: - * - * A key to get the support page for the operating system, e.g. "https://support.yoyo-os.com/" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_SUPPORT_URL \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "SUPPORT_URL" - -/** - * G_OS_INFO_KEY_BUG_REPORT_URL: - * - * A key to get the bug reporting page for the operating system, e.g. "https://bugs.yoyo-os.com/" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_BUG_REPORT_URL \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "BUG_REPORT_URL" - -/** - * G_OS_INFO_KEY_PRIVACY_POLICY_URL: - * - * A key to get the privacy policy for the operating system, e.g. "https://privacy.yoyo-os.com/" - * - * Since: 2.64 - */ -#define G_OS_INFO_KEY_PRIVACY_POLICY_URL \ - GLIB_AVAILABLE_MACRO_IN_2_64 \ - "PRIVACY_POLICY_URL" - -GLIB_AVAILABLE_IN_ALL -void g_reload_user_special_dirs_cache (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_user_data_dir (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_user_config_dir (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_user_cache_dir (void); -GLIB_AVAILABLE_IN_ALL -const gchar * const * g_get_system_data_dirs (void); - -#ifdef G_OS_WIN32 -/* This function is not part of the public GLib API */ -GLIB_AVAILABLE_IN_ALL -const gchar * const * g_win32_get_system_data_dirs_for_module (void (*address_of_function)(void)); -#endif - -#if defined (G_OS_WIN32) && defined (G_CAN_INLINE) -/* This function is not part of the public GLib API either. Just call - * g_get_system_data_dirs() in your code, never mind that that is - * actually a macro and you will in fact call this inline function. - */ -static inline const gchar * const * -_g_win32_get_system_data_dirs (void) -{ - return g_win32_get_system_data_dirs_for_module ((void (*)(void)) &_g_win32_get_system_data_dirs); -} -#undef g_get_system_data_dirs -#define g_get_system_data_dirs _g_win32_get_system_data_dirs -#endif - -GLIB_AVAILABLE_IN_ALL -const gchar * const * g_get_system_config_dirs (void); - -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_user_runtime_dir (void); - -/** - * GUserDirectory: - * @G_USER_DIRECTORY_DESKTOP: the user's Desktop directory - * @G_USER_DIRECTORY_DOCUMENTS: the user's Documents directory - * @G_USER_DIRECTORY_DOWNLOAD: the user's Downloads directory - * @G_USER_DIRECTORY_MUSIC: the user's Music directory - * @G_USER_DIRECTORY_PICTURES: the user's Pictures directory - * @G_USER_DIRECTORY_PUBLIC_SHARE: the user's shared directory - * @G_USER_DIRECTORY_TEMPLATES: the user's Templates directory - * @G_USER_DIRECTORY_VIDEOS: the user's Movies directory - * @G_USER_N_DIRECTORIES: the number of enum values - * - * These are logical ids for special directories which are defined - * depending on the platform used. You should use g_get_user_special_dir() - * to retrieve the full path associated to the logical id. - * - * The #GUserDirectory enumeration can be extended at later date. Not - * every platform has a directory for every logical id in this - * enumeration. - * - * Since: 2.14 - */ -typedef enum { - G_USER_DIRECTORY_DESKTOP, - G_USER_DIRECTORY_DOCUMENTS, - G_USER_DIRECTORY_DOWNLOAD, - G_USER_DIRECTORY_MUSIC, - G_USER_DIRECTORY_PICTURES, - G_USER_DIRECTORY_PUBLIC_SHARE, - G_USER_DIRECTORY_TEMPLATES, - G_USER_DIRECTORY_VIDEOS, - - G_USER_N_DIRECTORIES -} GUserDirectory; - -GLIB_AVAILABLE_IN_ALL -const gchar * g_get_user_special_dir (GUserDirectory directory); - -/** - * GDebugKey: - * @key: the string - * @value: the flag - * - * Associates a string with a bit flag. - * Used in g_parse_debug_string(). - */ -typedef struct _GDebugKey GDebugKey; -struct _GDebugKey -{ - const gchar *key; - guint value; -}; - -/* Miscellaneous utility functions - */ -GLIB_AVAILABLE_IN_ALL -guint g_parse_debug_string (const gchar *string, - const GDebugKey *keys, - guint nkeys); - -GLIB_AVAILABLE_IN_ALL -gint g_snprintf (gchar *string, - gulong n, - gchar const *format, - ...) G_GNUC_PRINTF (3, 4); -GLIB_AVAILABLE_IN_ALL -gint g_vsnprintf (gchar *string, - gulong n, - gchar const *format, - va_list args) - G_GNUC_PRINTF(3, 0); - -GLIB_AVAILABLE_IN_ALL -void g_nullify_pointer (gpointer *nullify_location); - -typedef enum -{ - G_FORMAT_SIZE_DEFAULT = 0, - G_FORMAT_SIZE_LONG_FORMAT = 1 << 0, - G_FORMAT_SIZE_IEC_UNITS = 1 << 1, - G_FORMAT_SIZE_BITS = 1 << 2 -} GFormatSizeFlags; - -GLIB_AVAILABLE_IN_2_30 -gchar *g_format_size_full (guint64 size, - GFormatSizeFlags flags); -GLIB_AVAILABLE_IN_2_30 -gchar *g_format_size (guint64 size); - -GLIB_DEPRECATED_IN_2_30_FOR(g_format_size) -gchar *g_format_size_for_display (goffset size); - -#define g_ATEXIT(proc) (atexit (proc)) GLIB_DEPRECATED_MACRO_IN_2_32 -#define g_memmove(dest,src,len) \ - G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_40_FOR(memmove) - -/** - * GVoidFunc: - * - * Declares a type of function which takes no arguments - * and has no return value. It is used to specify the type - * function passed to g_atexit(). - */ -typedef void (*GVoidFunc) (void) GLIB_DEPRECATED_TYPE_IN_2_32; -#define ATEXIT(proc) g_ATEXIT(proc) GLIB_DEPRECATED_MACRO_IN_2_32 - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED -void g_atexit (GVoidFunc func); -G_GNUC_END_IGNORE_DEPRECATIONS - -#ifdef G_OS_WIN32 -/* It's a bad idea to wrap atexit() on Windows. If the GLib DLL calls - * atexit(), the function will be called when the GLib DLL is detached - * from the program, which is not what the caller wants. The caller - * wants the function to be called when it *itself* exits (or is - * detached, in case the caller, too, is a DLL). - */ -#if (defined(__MINGW_H) && !defined(_STDLIB_H_)) || (defined(_MSC_VER) && !defined(_INC_STDLIB)) -int atexit (void (*)(void)); -#endif -#undef g_atexit -#define g_atexit(func) atexit(func) GLIB_DEPRECATED_MACRO_IN_2_32 -#endif - - -/* Look for an executable in PATH, following execvp() rules */ -GLIB_AVAILABLE_IN_ALL -gchar* g_find_program_in_path (const gchar *program); - -/* Bit tests - * - * These are defined in a convoluted way because we want the compiler to - * be able to inline the code for performance reasons, but for - * historical reasons, we must continue to provide non-inline versions - * on our ABI. - * - * We define these as functions in gutils.c which are just implemented - * as calls to the _impl() versions in order to preserve the ABI. - */ - -#undef g_bit_nth_lsf -#define g_bit_nth_lsf(mask, nth_bit) g_bit_nth_lsf_impl(mask, nth_bit) -#undef g_bit_nth_msf -#define g_bit_nth_msf(mask, nth_bit) g_bit_nth_msf_impl(mask, nth_bit) -#undef g_bit_storage -#define g_bit_storage(number) g_bit_storage_impl(number) - -GLIB_AVAILABLE_IN_ALL -gint (g_bit_nth_lsf) (gulong mask, - gint nth_bit); -GLIB_AVAILABLE_IN_ALL -gint (g_bit_nth_msf) (gulong mask, - gint nth_bit); -GLIB_AVAILABLE_IN_ALL -guint (g_bit_storage) (gulong number); - -static inline gint -g_bit_nth_lsf_impl (gulong mask, - gint nth_bit) -{ - if (G_UNLIKELY (nth_bit < -1)) - nth_bit = -1; - while (nth_bit < ((GLIB_SIZEOF_LONG * 8) - 1)) - { - nth_bit++; - if (mask & (1UL << nth_bit)) - return nth_bit; - } - return -1; -} - -static inline gint -g_bit_nth_msf_impl (gulong mask, - gint nth_bit) -{ - if (nth_bit < 0 || G_UNLIKELY (nth_bit > GLIB_SIZEOF_LONG * 8)) - nth_bit = GLIB_SIZEOF_LONG * 8; - while (nth_bit > 0) - { - nth_bit--; - if (mask & (1UL << nth_bit)) - return nth_bit; - } - return -1; -} - -static inline guint -g_bit_storage_impl (gulong number) -{ -#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) - return G_LIKELY (number) ? - ((GLIB_SIZEOF_LONG * 8U - 1) ^ (guint) __builtin_clzl(number)) + 1 : 1; -#else - guint n_bits = 0; - - do - { - n_bits++; - number >>= 1; - } - while (number); - return n_bits; -#endif -} - -/* Crashes the program. */ -#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_50 -#ifndef G_OS_WIN32 -# include -# define g_abort() abort () -#else -GLIB_AVAILABLE_IN_2_50 -G_NORETURN void g_abort (void) G_ANALYZER_NORETURN; -#endif -#endif - -/* - * This macro is deprecated. This DllMain() is too complex. It is - * recommended to write an explicit minimal DLlMain() that just saves - * the handle to the DLL and then use that handle instead, for - * instance passing it to - * g_win32_get_package_installation_directory_of_module(). - * - * On Windows, this macro defines a DllMain function that stores the - * actual DLL name that the code being compiled will be included in. - * STATIC should be empty or 'static'. DLL_NAME is the name of the - * (pointer to the) char array where the DLL name will be stored. If - * this is used, you must also include . If you need a more complex - * DLL entry point function, you cannot use this. - * - * On non-Windows platforms, expands to nothing. - */ - -#ifndef G_PLATFORM_WIN32 -# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) GLIB_DEPRECATED_MACRO_IN_2_26 -#else -# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) \ -static char *dll_name; \ - \ -BOOL WINAPI \ -DllMain (HINSTANCE hinstDLL, \ - DWORD fdwReason, \ - LPVOID lpvReserved) \ -{ \ - wchar_t wcbfr[1000]; \ - char *tem; \ - switch (fdwReason) \ - { \ - case DLL_PROCESS_ATTACH: \ - GetModuleFileNameW ((HMODULE) hinstDLL, wcbfr, G_N_ELEMENTS (wcbfr)); \ - tem = g_utf16_to_utf8 (wcbfr, -1, NULL, NULL, NULL); \ - dll_name = g_path_get_basename (tem); \ - g_free (tem); \ - break; \ - } \ - \ - return TRUE; \ -} GLIB_DEPRECATED_MACRO_IN_2_26 -#endif /* G_PLATFORM_WIN32 */ - -G_END_DECLS - -#endif /* __G_UTILS_H__ */ - -G_BEGIN_DECLS - -#define G_THREAD_ERROR g_thread_error_quark () -GLIB_AVAILABLE_IN_ALL -GQuark g_thread_error_quark (void); - -typedef enum -{ - G_THREAD_ERROR_AGAIN /* Resource temporarily unavailable */ -} GThreadError; - -typedef gpointer (*GThreadFunc) (gpointer data); -typedef void (*GThreadGarbageHandler) (gpointer data); - -typedef struct _GThreadCallbacks GThreadCallbacks; -typedef struct _GThread GThread; - -typedef union _GMutex GMutex; -typedef struct _GRecMutex GRecMutex; -typedef struct _GRWLock GRWLock; -typedef struct _GCond GCond; -typedef struct _GPrivate GPrivate; -typedef struct _GOnce GOnce; - -typedef enum -{ - G_PRIVATE_DESTROY_LATE = 1 << 0, - G_PRIVATE_DESTROY_LAST = 1 << 1, -} GPrivateFlags; - -struct _GThreadCallbacks -{ - void (*on_thread_init) (void); - void (*on_thread_realize) (void); - void (*on_thread_dispose) (void); - void (*on_thread_finalize) (void); -}; - -union _GMutex -{ - /*< private >*/ - gpointer p; - guint i[2]; -}; - -struct _GRWLock -{ - /*< private >*/ - gpointer p; - guint i[2]; -}; - -struct _GCond -{ - /*< private >*/ - gpointer p; - guint i[2]; -}; - -struct _GRecMutex -{ - /*< private >*/ - gpointer p; - guint i[2]; -}; - -#define G_PRIVATE_INIT(notify) \ - { NULL, (notify), 0, { NULL } } -#define G_PRIVATE_INIT_WITH_FLAGS(notify, flags) \ - { NULL, (notify), (flags), { NULL } } -struct _GPrivate -{ - /*< private >*/ - gpointer p; - GDestroyNotify notify; - GPrivateFlags flags; - gpointer future[1]; -}; - -typedef enum -{ - G_ONCE_STATUS_NOTCALLED, - G_ONCE_STATUS_PROGRESS, - G_ONCE_STATUS_READY -} GOnceStatus; - -#define G_ONCE_INIT { G_ONCE_STATUS_NOTCALLED, NULL } -struct _GOnce -{ - volatile GOnceStatus status; - volatile gpointer retval; -}; - -#define G_LOCK_NAME(name) g__ ## name ## _lock -#define G_LOCK_DEFINE_STATIC(name) static G_LOCK_DEFINE (name) -#define G_LOCK_DEFINE(name) GMutex G_LOCK_NAME (name) -#define G_LOCK_EXTERN(name) extern GMutex G_LOCK_NAME (name) - -#ifdef G_DEBUG_LOCKS -# define G_LOCK(name) G_STMT_START{ \ - g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ - "file %s: line %d (%s): locking: %s ", \ - __FILE__, __LINE__, G_STRFUNC, \ - #name); \ - g_mutex_lock (&G_LOCK_NAME (name)); \ - }G_STMT_END -# define G_UNLOCK(name) G_STMT_START{ \ - g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ - "file %s: line %d (%s): unlocking: %s ", \ - __FILE__, __LINE__, G_STRFUNC, \ - #name); \ - g_mutex_unlock (&G_LOCK_NAME (name)); \ - }G_STMT_END -# define G_TRYLOCK(name) \ - (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ - "file %s: line %d (%s): try locking: %s ", \ - __FILE__, __LINE__, G_STRFUNC, \ - #name), g_mutex_trylock (&G_LOCK_NAME (name))) -#else /* !G_DEBUG_LOCKS */ -# define G_LOCK(name) g_mutex_lock (&G_LOCK_NAME (name)) -# define G_UNLOCK(name) g_mutex_unlock (&G_LOCK_NAME (name)) -# define G_TRYLOCK(name) g_mutex_trylock (&G_LOCK_NAME (name)) -#endif /* !G_DEBUG_LOCKS */ - -GLIB_VAR GThreadCallbacks *glib_thread_callbacks; -GLIB_AVAILABLE_IN_2_68 -void g_thread_set_callbacks (GThreadCallbacks *callbacks); -GLIB_AVAILABLE_IN_2_68 -void g_thread_set_garbage_handler (GThreadGarbageHandler handler, - gpointer user_data); -GLIB_AVAILABLE_IN_2_68 -gboolean g_thread_garbage_collect (void); - -GLIB_AVAILABLE_IN_2_32 -GThread * g_thread_ref (GThread *thread); -GLIB_AVAILABLE_IN_2_32 -void g_thread_unref (GThread *thread); -GLIB_AVAILABLE_IN_2_32 -GThread * g_thread_new (const gchar *name, - GThreadFunc func, - gpointer data); -GLIB_AVAILABLE_IN_2_32 -GThread * g_thread_try_new (const gchar *name, - GThreadFunc func, - gpointer data, - GError **error); -GLIB_AVAILABLE_IN_ALL -GThread * g_thread_self (void); -GLIB_AVAILABLE_IN_ALL -void g_thread_exit (gpointer retval); -GLIB_AVAILABLE_IN_ALL -gpointer g_thread_join (GThread *thread); -GLIB_AVAILABLE_IN_ALL -void g_thread_yield (void); - - -GLIB_AVAILABLE_IN_2_32 -void g_mutex_init (GMutex *mutex); -GLIB_AVAILABLE_IN_2_32 -void g_mutex_clear (GMutex *mutex); -GLIB_AVAILABLE_IN_ALL -void g_mutex_lock (GMutex *mutex); -GLIB_AVAILABLE_IN_ALL -gboolean g_mutex_trylock (GMutex *mutex); -GLIB_AVAILABLE_IN_ALL -void g_mutex_unlock (GMutex *mutex); - -GLIB_AVAILABLE_IN_2_32 -void g_rw_lock_init (GRWLock *rw_lock); -GLIB_AVAILABLE_IN_2_32 -void g_rw_lock_clear (GRWLock *rw_lock); -GLIB_AVAILABLE_IN_2_32 -void g_rw_lock_writer_lock (GRWLock *rw_lock); -GLIB_AVAILABLE_IN_2_32 -gboolean g_rw_lock_writer_trylock (GRWLock *rw_lock); -GLIB_AVAILABLE_IN_2_32 -void g_rw_lock_writer_unlock (GRWLock *rw_lock); -GLIB_AVAILABLE_IN_2_32 -void g_rw_lock_reader_lock (GRWLock *rw_lock); -GLIB_AVAILABLE_IN_2_32 -gboolean g_rw_lock_reader_trylock (GRWLock *rw_lock); -GLIB_AVAILABLE_IN_2_32 -void g_rw_lock_reader_unlock (GRWLock *rw_lock); - -GLIB_AVAILABLE_IN_2_32 -void g_rec_mutex_init (GRecMutex *rec_mutex); -GLIB_AVAILABLE_IN_2_32 -void g_rec_mutex_clear (GRecMutex *rec_mutex); -GLIB_AVAILABLE_IN_2_32 -void g_rec_mutex_lock (GRecMutex *rec_mutex); -GLIB_AVAILABLE_IN_2_32 -gboolean g_rec_mutex_trylock (GRecMutex *rec_mutex); -GLIB_AVAILABLE_IN_2_32 -void g_rec_mutex_unlock (GRecMutex *rec_mutex); - -GLIB_AVAILABLE_IN_2_32 -void g_cond_init (GCond *cond); -GLIB_AVAILABLE_IN_2_32 -void g_cond_clear (GCond *cond); -GLIB_AVAILABLE_IN_ALL -void g_cond_wait (GCond *cond, - GMutex *mutex); -GLIB_AVAILABLE_IN_ALL -void g_cond_signal (GCond *cond); -GLIB_AVAILABLE_IN_ALL -void g_cond_broadcast (GCond *cond); -GLIB_AVAILABLE_IN_2_32 -gboolean g_cond_wait_until (GCond *cond, - GMutex *mutex, - gint64 end_time); - -GLIB_AVAILABLE_IN_ALL -gpointer g_private_get (GPrivate *key); -GLIB_AVAILABLE_IN_ALL -void g_private_set (GPrivate *key, - gpointer value); -GLIB_AVAILABLE_IN_2_32 -void g_private_replace (GPrivate *key, - gpointer value); - -GLIB_AVAILABLE_IN_ALL -gpointer g_once_impl (GOnce *once, - GThreadFunc func, - gpointer arg); -GLIB_AVAILABLE_IN_ALL -gboolean g_once_init_enter (volatile void *location); -GLIB_AVAILABLE_IN_ALL -void g_once_init_leave (volatile void *location, - gsize result); - -/* Use C11-style atomic extensions to check the fast path for status=ready. If - * they are not available, fall back to using a mutex and condition variable in - * g_once_impl(). - * - * On the C11-style codepath, only the load of once->status needs to be atomic, - * as the writes to it and once->retval in g_once_impl() are related by a - * happens-before relation. Release-acquire semantics are defined such that any - * atomic/non-atomic write which happens-before a store/release is guaranteed to - * be seen by the load/acquire of the same atomic variable. */ -#if defined(G_ATOMIC_LOCK_FREE) && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) && defined(__ATOMIC_SEQ_CST) -# define g_once(once, func, arg) \ - ((__atomic_load_n (&(once)->status, __ATOMIC_ACQUIRE) == G_ONCE_STATUS_READY) ? \ - (once)->retval : \ - g_once_impl ((once), (func), (arg))) -#else -# define g_once(once, func, arg) g_once_impl ((once), (func), (arg)) -#endif - -#ifdef __GNUC__ -#undef g_once_init_enter -# define g_once_init_enter(location) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ - (void) (0 ? (gpointer) *(location) : NULL); \ - (!g_atomic_pointer_get (location) && \ - _frida_g_once_init_enter (location)); \ - })) -#undef g_once_init_leave -# define g_once_init_leave(location, result) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer)); \ - 0 ? (void) (*(location) = (result)) : (void) 0; \ - _frida_g_once_init_leave ((location), (gsize) (result)); \ - })) -#else -#undef g_once_init_enter -# define g_once_init_enter(location) \ - (_frida_g_once_init_enter((location))) -#undef g_once_init_leave -# define g_once_init_leave(location, result) \ - (_frida_g_once_init_leave((location), (gsize) (result))) -#endif - -GLIB_AVAILABLE_IN_2_36 -guint g_get_num_processors (void); - -/** - * GMutexLocker: - * - * Opaque type. See g_mutex_locker_new() for details. - * Since: 2.44 - */ -typedef void GMutexLocker; - -/** - * g_mutex_locker_new: - * @mutex: a mutex to lock - * - * Lock @mutex and return a new #GMutexLocker. Unlock with - * g_mutex_locker_free(). Using g_mutex_unlock() on @mutex - * while a #GMutexLocker exists can lead to undefined behaviour. - * - * No allocation is performed, it is equivalent to a g_mutex_lock() call. - * - * This is intended to be used with g_autoptr(). Note that g_autoptr() - * is only available when using GCC or clang, so the following example - * will only work with those compilers: - * |[ - * typedef struct - * { - * ... - * GMutex mutex; - * ... - * } MyObject; - * - * static void - * my_object_do_stuff (MyObject *self) - * { - * g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&self->mutex); - * - * // Code with mutex locked here - * - * if (cond) - * // No need to unlock - * return; - * - * // Optionally early unlock - * g_clear_pointer (&locker, g_mutex_locker_free); - * - * // Code with mutex unlocked here - * } - * ]| - * - * Returns: a #GMutexLocker - * Since: 2.44 - */ -GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 -static inline GMutexLocker * -g_mutex_locker_new (GMutex *mutex) -{ - g_mutex_lock (mutex); - return (GMutexLocker *) mutex; -} - -/** - * g_mutex_locker_free: - * @locker: a GMutexLocker - * - * Unlock @locker's mutex. See g_mutex_locker_new() for details. - * - * No memory is freed, it is equivalent to a g_mutex_unlock() call. - * - * Since: 2.44 - */ -GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 -static inline void -g_mutex_locker_free (GMutexLocker *locker) -{ - g_mutex_unlock ((GMutex *) locker); -} - -/** - * GRecMutexLocker: - * - * Opaque type. See g_rec_mutex_locker_new() for details. - * Since: 2.60 - */ -typedef void GRecMutexLocker; - -/** - * g_rec_mutex_locker_new: - * @rec_mutex: a recursive mutex to lock - * - * Lock @rec_mutex and return a new #GRecMutexLocker. Unlock with - * g_rec_mutex_locker_free(). Using g_rec_mutex_unlock() on @rec_mutex - * while a #GRecMutexLocker exists can lead to undefined behaviour. - * - * No allocation is performed, it is equivalent to a g_rec_mutex_lock() call. - * - * This is intended to be used with g_autoptr(). Note that g_autoptr() - * is only available when using GCC or clang, so the following example - * will only work with those compilers: - * |[ - * typedef struct - * { - * ... - * GRecMutex rec_mutex; - * ... - * } MyObject; - * - * static void - * my_object_do_stuff (MyObject *self) - * { - * g_autoptr(GRecMutexLocker) locker = g_rec_mutex_locker_new (&self->rec_mutex); - * - * // Code with rec_mutex locked here - * - * if (cond) - * // No need to unlock - * return; - * - * // Optionally early unlock - * g_clear_pointer (&locker, g_rec_mutex_locker_free); - * - * // Code with rec_mutex unlocked here - * } - * ]| - * - * Returns: a #GRecMutexLocker - * Since: 2.60 - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 -static inline GRecMutexLocker * -g_rec_mutex_locker_new (GRecMutex *rec_mutex) -{ - g_rec_mutex_lock (rec_mutex); - return (GRecMutexLocker *) rec_mutex; -} -G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * g_rec_mutex_locker_free: - * @locker: a GRecMutexLocker - * - * Unlock @locker's recursive mutex. See g_rec_mutex_locker_new() for details. - * - * No memory is freed, it is equivalent to a g_rec_mutex_unlock() call. - * - * Since: 2.60 - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_STATIC_INLINE_IN_2_60 -static inline void -g_rec_mutex_locker_free (GRecMutexLocker *locker) -{ - g_rec_mutex_unlock ((GRecMutex *) locker); -} -G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * GRWLockWriterLocker: - * - * Opaque type. See g_rw_lock_writer_locker_new() for details. - * Since: 2.62 - */ -typedef void GRWLockWriterLocker; - -/** - * g_rw_lock_writer_locker_new: - * @rw_lock: a #GRWLock - * - * Obtain a write lock on @rw_lock and return a new #GRWLockWriterLocker. - * Unlock with g_rw_lock_writer_locker_free(). Using g_rw_lock_writer_unlock() - * on @rw_lock while a #GRWLockWriterLocker exists can lead to undefined - * behaviour. - * - * No allocation is performed, it is equivalent to a g_rw_lock_writer_lock() call. - * - * This is intended to be used with g_autoptr(). Note that g_autoptr() - * is only available when using GCC or clang, so the following example - * will only work with those compilers: - * |[ - * typedef struct - * { - * ... - * GRWLock rw_lock; - * GPtrArray *array; - * ... - * } MyObject; - * - * static gchar * - * my_object_get_data (MyObject *self, guint index) - * { - * g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new (&self->rw_lock); - * - * // Code with a read lock obtained on rw_lock here - * - * if (self->array == NULL) - * // No need to unlock - * return NULL; - * - * if (index < self->array->len) - * // No need to unlock - * return g_ptr_array_index (self->array, index); - * - * // Optionally early unlock - * g_clear_pointer (&locker, g_rw_lock_reader_locker_free); - * - * // Code with rw_lock unlocked here - * return NULL; - * } - * - * static void - * my_object_set_data (MyObject *self, guint index, gpointer data) - * { - * g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&self->rw_lock); - * - * // Code with a write lock obtained on rw_lock here - * - * if (self->array == NULL) - * self->array = g_ptr_array_new (); - * - * if (cond) - * // No need to unlock - * return; - * - * if (index >= self->array->len) - * g_ptr_array_set_size (self->array, index+1); - * g_ptr_array_index (self->array, index) = data; - * - * // Optionally early unlock - * g_clear_pointer (&locker, g_rw_lock_writer_locker_free); - * - * // Code with rw_lock unlocked here - * } - * ]| - * - * Returns: a #GRWLockWriterLocker - * Since: 2.62 - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 -static inline GRWLockWriterLocker * -g_rw_lock_writer_locker_new (GRWLock *rw_lock) -{ - g_rw_lock_writer_lock (rw_lock); - return (GRWLockWriterLocker *) rw_lock; -} -G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * g_rw_lock_writer_locker_free: - * @locker: a GRWLockWriterLocker - * - * Release a write lock on @locker's read-write lock. See - * g_rw_lock_writer_locker_new() for details. - * - * No memory is freed, it is equivalent to a g_rw_lock_writer_unlock() call. - * - * Since: 2.62 - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 -static inline void -g_rw_lock_writer_locker_free (GRWLockWriterLocker *locker) -{ - g_rw_lock_writer_unlock ((GRWLock *) locker); -} -G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * GRWLockReaderLocker: - * - * Opaque type. See g_rw_lock_reader_locker_new() for details. - * Since: 2.62 - */ -typedef void GRWLockReaderLocker; - -/** - * g_rw_lock_reader_locker_new: - * @rw_lock: a #GRWLock - * - * Obtain a read lock on @rw_lock and return a new #GRWLockReaderLocker. - * Unlock with g_rw_lock_reader_locker_free(). Using g_rw_lock_reader_unlock() - * on @rw_lock while a #GRWLockReaderLocker exists can lead to undefined - * behaviour. - * - * No allocation is performed, it is equivalent to a g_rw_lock_reader_lock() call. - * - * This is intended to be used with g_autoptr(). For a code sample, see - * g_rw_lock_writer_locker_new(). - * - * Returns: a #GRWLockReaderLocker - * Since: 2.62 - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 -static inline GRWLockReaderLocker * -g_rw_lock_reader_locker_new (GRWLock *rw_lock) -{ - g_rw_lock_reader_lock (rw_lock); - return (GRWLockReaderLocker *) rw_lock; -} -G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * g_rw_lock_reader_locker_free: - * @locker: a GRWLockReaderLocker - * - * Release a read lock on @locker's read-write lock. See - * g_rw_lock_reader_locker_new() for details. - * - * No memory is freed, it is equivalent to a g_rw_lock_reader_unlock() call. - * - * Since: 2.62 - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_STATIC_INLINE_IN_2_62 -static inline void -g_rw_lock_reader_locker_free (GRWLockReaderLocker *locker) -{ - g_rw_lock_reader_unlock ((GRWLock *) locker); -} -G_GNUC_END_IGNORE_DEPRECATIONS - -G_END_DECLS - -#endif /* __G_THREAD_H__ */ - -G_BEGIN_DECLS - -typedef struct _GAsyncQueue GAsyncQueue; - -GLIB_AVAILABLE_IN_ALL -GAsyncQueue *g_async_queue_new (void); -GLIB_AVAILABLE_IN_ALL -GAsyncQueue *g_async_queue_new_full (GDestroyNotify item_free_func); -GLIB_AVAILABLE_IN_ALL -void g_async_queue_lock (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -void g_async_queue_unlock (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -GAsyncQueue *g_async_queue_ref (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -void g_async_queue_unref (GAsyncQueue *queue); - -GLIB_DEPRECATED_FOR(g_async_queue_ref) -void g_async_queue_ref_unlocked (GAsyncQueue *queue); - -GLIB_DEPRECATED_FOR(g_async_queue_unref) -void g_async_queue_unref_and_unlock (GAsyncQueue *queue); - -GLIB_AVAILABLE_IN_ALL -void g_async_queue_push (GAsyncQueue *queue, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_async_queue_push_unlocked (GAsyncQueue *queue, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_async_queue_push_sorted (GAsyncQueue *queue, - gpointer data, - GCompareDataFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -void g_async_queue_push_sorted_unlocked (GAsyncQueue *queue, - gpointer data, - GCompareDataFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -gpointer g_async_queue_pop (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -gpointer g_async_queue_pop_unlocked (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -gpointer g_async_queue_try_pop (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -gpointer g_async_queue_try_pop_unlocked (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -gpointer g_async_queue_timeout_pop (GAsyncQueue *queue, - guint64 timeout); -GLIB_AVAILABLE_IN_ALL -gpointer g_async_queue_timeout_pop_unlocked (GAsyncQueue *queue, - guint64 timeout); -GLIB_AVAILABLE_IN_ALL -gint g_async_queue_length (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -gint g_async_queue_length_unlocked (GAsyncQueue *queue); -GLIB_AVAILABLE_IN_ALL -void g_async_queue_sort (GAsyncQueue *queue, - GCompareDataFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -void g_async_queue_sort_unlocked (GAsyncQueue *queue, - GCompareDataFunc func, - gpointer user_data); - -GLIB_AVAILABLE_IN_2_46 -gboolean g_async_queue_remove (GAsyncQueue *queue, - gpointer item); -GLIB_AVAILABLE_IN_2_46 -gboolean g_async_queue_remove_unlocked (GAsyncQueue *queue, - gpointer item); -GLIB_AVAILABLE_IN_2_46 -void g_async_queue_push_front (GAsyncQueue *queue, - gpointer item); -GLIB_AVAILABLE_IN_2_46 -void g_async_queue_push_front_unlocked (GAsyncQueue *queue, - gpointer item); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED_FOR(g_async_queue_timeout_pop) -gpointer g_async_queue_timed_pop (GAsyncQueue *queue, - GTimeVal *end_time); -GLIB_DEPRECATED_FOR(g_async_queue_timeout_pop_unlocked) -gpointer g_async_queue_timed_pop_unlocked (GAsyncQueue *queue, - GTimeVal *end_time); -G_GNUC_END_IGNORE_DEPRECATIONS - -G_END_DECLS - -#endif /* __G_ASYNCQUEUE_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_BACKTRACE_H__ -#define __G_BACKTRACE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#ifdef __sun__ -#include -#endif -#include - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -void g_on_error_query (const gchar *prg_name); -GLIB_AVAILABLE_IN_ALL -void g_on_error_stack_trace (const gchar *prg_name); - -/** - * G_BREAKPOINT: - * - * Inserts a breakpoint instruction into the code. - * - * On architectures which support it, this is implemented as a soft interrupt - * and on other architectures it raises a `SIGTRAP` signal. - * - * `SIGTRAP` is used rather than abort() to allow breakpoints to be skipped past - * in a debugger if they are not the desired target of debugging. - */ -#if (defined (__i386__) || defined (__x86_64__)) && defined (__GNUC__) && __GNUC__ >= 2 -# define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("int $03"); }G_STMT_END -#elif (defined (_MSC_VER) || defined (__DMC__)) && defined (_M_IX86) -# define G_BREAKPOINT() G_STMT_START{ __asm int 3h }G_STMT_END -#elif defined (_MSC_VER) -# define G_BREAKPOINT() G_STMT_START{ __debugbreak(); }G_STMT_END -#elif defined (__alpha__) && !defined(__osf__) && defined (__GNUC__) && __GNUC__ >= 2 -# define G_BREAKPOINT() G_STMT_START{ __asm__ __volatile__ ("bpt"); }G_STMT_END -#elif defined (__APPLE__) || (defined(_WIN32) && (defined(__clang__) || defined(__GNUC__))) -# define G_BREAKPOINT() G_STMT_START{ __builtin_trap(); }G_STMT_END -#else /* !__i386__ && !__alpha__ */ -# define G_BREAKPOINT() G_STMT_START{ raise (SIGTRAP); }G_STMT_END -#endif /* __i386__ */ - -G_END_DECLS - -#endif /* __G_BACKTRACE_H__ */ -/* gbase64.h - Base64 coding functions - * - * Copyright (C) 2005 Alexander Larsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_BASE64_H__ -#define __G_BASE64_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -gsize g_base64_encode_step (const guchar *in, - gsize len, - gboolean break_lines, - gchar *out, - gint *state, - gint *save); -GLIB_AVAILABLE_IN_ALL -gsize g_base64_encode_close (gboolean break_lines, - gchar *out, - gint *state, - gint *save); -GLIB_AVAILABLE_IN_ALL -gchar* g_base64_encode (const guchar *data, - gsize len) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gsize g_base64_decode_step (const gchar *in, - gsize len, - guchar *out, - gint *state, - guint *save); -GLIB_AVAILABLE_IN_ALL -guchar *g_base64_decode (const gchar *text, - gsize *out_len) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -guchar *g_base64_decode_inplace (gchar *text, - gsize *out_len); - - -G_END_DECLS - -#endif /* __G_BASE64_H__ */ -/* - * Copyright © 2008 Ryan Lortie - * Copyright © 2010 Codethink Limited - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Author: Ryan Lortie - */ - -#ifndef __G_BITLOCK_H__ -#define __G_BITLOCK_H__ - - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -void g_bit_lock (volatile gint *address, - gint lock_bit); -GLIB_AVAILABLE_IN_ALL -gboolean g_bit_trylock (volatile gint *address, - gint lock_bit); -GLIB_AVAILABLE_IN_ALL -void g_bit_unlock (volatile gint *address, - gint lock_bit); - -GLIB_AVAILABLE_IN_ALL -void g_pointer_bit_lock (volatile void *address, - gint lock_bit); -GLIB_AVAILABLE_IN_ALL -gboolean g_pointer_bit_trylock (volatile void *address, - gint lock_bit); -GLIB_AVAILABLE_IN_ALL -void g_pointer_bit_unlock (volatile void *address, - gint lock_bit); - -#ifdef __GNUC__ - -#undef g_pointer_bit_lock -#define g_pointer_bit_lock(address, lock_bit) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ - _frida_g_pointer_bit_lock ((address), (lock_bit)); \ - })) - -#undef g_pointer_bit_trylock -#define g_pointer_bit_trylock(address, lock_bit) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ - _frida_g_pointer_bit_trylock ((address), (lock_bit)); \ - })) - -#undef g_pointer_bit_unlock -#define g_pointer_bit_unlock(address, lock_bit) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \ - _frida_g_pointer_bit_unlock ((address), (lock_bit)); \ - })) - -#endif - -G_END_DECLS - -#endif /* __G_BITLOCK_H_ */ -/* gbookmarkfile.h: parsing and building desktop bookmarks - * - * Copyright (C) 2005-2006 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_BOOKMARK_FILE_H__ -#define __G_BOOKMARK_FILE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* - * Copyright (C) 2009-2010 Christian Hergert - * Copyright © 2010 Codethink Limited - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of the - * licence, or (at your option) any later version. - * - * This is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - * - * Authors: Christian Hergert - * Thiago Santos - * Emmanuele Bassi - * Ryan Lortie - */ - -#ifndef __G_DATE_TIME_H__ -#define __G_DATE_TIME_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* - * Copyright © 2010 Codethink Limited - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Author: Ryan Lortie - */ - -#ifndef __G_TIME_ZONE_H__ -#define __G_TIME_ZONE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GTimeZone GTimeZone; - -/** - * GTimeType: - * @G_TIME_TYPE_STANDARD: the time is in local standard time - * @G_TIME_TYPE_DAYLIGHT: the time is in local daylight time - * @G_TIME_TYPE_UNIVERSAL: the time is in UTC - * - * Disambiguates a given time in two ways. - * - * First, specifies if the given time is in universal or local time. - * - * Second, if the time is in local time, specifies if it is local - * standard time or local daylight time. This is important for the case - * where the same local time occurs twice (during daylight savings time - * transitions, for example). - */ -typedef enum -{ - G_TIME_TYPE_STANDARD, - G_TIME_TYPE_DAYLIGHT, - G_TIME_TYPE_UNIVERSAL -} GTimeType; - -GLIB_DEPRECATED_IN_2_68_FOR (g_time_zone_new_identifier) -GTimeZone * g_time_zone_new (const gchar *identifier); -GLIB_AVAILABLE_IN_2_68 -GTimeZone * g_time_zone_new_identifier (const gchar *identifier); -GLIB_AVAILABLE_IN_ALL -GTimeZone * g_time_zone_new_utc (void); -GLIB_AVAILABLE_IN_ALL -GTimeZone * g_time_zone_new_local (void); -GLIB_AVAILABLE_IN_2_58 -GTimeZone * g_time_zone_new_offset (gint32 seconds); - -GLIB_AVAILABLE_IN_ALL -GTimeZone * g_time_zone_ref (GTimeZone *tz); -GLIB_AVAILABLE_IN_ALL -void g_time_zone_unref (GTimeZone *tz); - -GLIB_AVAILABLE_IN_ALL -gint g_time_zone_find_interval (GTimeZone *tz, - GTimeType type, - gint64 time_); - -GLIB_AVAILABLE_IN_ALL -gint g_time_zone_adjust_time (GTimeZone *tz, - GTimeType type, - gint64 *time_); - -GLIB_AVAILABLE_IN_ALL -const gchar * g_time_zone_get_abbreviation (GTimeZone *tz, - gint interval); -GLIB_AVAILABLE_IN_ALL -gint32 g_time_zone_get_offset (GTimeZone *tz, - gint interval); -GLIB_AVAILABLE_IN_ALL -gboolean g_time_zone_is_dst (GTimeZone *tz, - gint interval); -GLIB_AVAILABLE_IN_2_58 -const gchar * g_time_zone_get_identifier (GTimeZone *tz); - -G_END_DECLS - -#endif /* __G_TIME_ZONE_H__ */ - -G_BEGIN_DECLS - -/** - * G_TIME_SPAN_DAY: - * - * Evaluates to a time span of one day. - * - * Since: 2.26 - */ -#define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000)) - -/** - * G_TIME_SPAN_HOUR: - * - * Evaluates to a time span of one hour. - * - * Since: 2.26 - */ -#define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000)) - -/** - * G_TIME_SPAN_MINUTE: - * - * Evaluates to a time span of one minute. - * - * Since: 2.26 - */ -#define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000)) - -/** - * G_TIME_SPAN_SECOND: - * - * Evaluates to a time span of one second. - * - * Since: 2.26 - */ -#define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000)) - -/** - * G_TIME_SPAN_MILLISECOND: - * - * Evaluates to a time span of one millisecond. - * - * Since: 2.26 - */ -#define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000)) - -/** - * GTimeSpan: - * - * A value representing an interval of time, in microseconds. - * - * Since: 2.26 - */ -typedef gint64 GTimeSpan; - -/** - * GDateTime: - * - * `GDateTime` is an opaque structure whose members - * cannot be accessed directly. - * - * Since: 2.26 - */ -typedef struct _GDateTime GDateTime; - -GLIB_AVAILABLE_IN_ALL -void g_date_time_unref (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_ref (GDateTime *datetime); - -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_new_now (GTimeZone *tz); -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_new_now_local (void); -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_new_now_utc (void); - -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_new_from_unix_local (gint64 t); -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_new_from_unix_utc (gint64 t); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_local) -GDateTime * g_date_time_new_from_timeval_local (const GTimeVal *tv); -GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_unix_utc) -GDateTime * g_date_time_new_from_timeval_utc (const GTimeVal *tv); -G_GNUC_END_IGNORE_DEPRECATIONS - -GLIB_AVAILABLE_IN_2_56 -GDateTime * g_date_time_new_from_iso8601 (const gchar *text, - GTimeZone *default_tz); - -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_new (GTimeZone *tz, - gint year, - gint month, - gint day, - gint hour, - gint minute, - gdouble seconds); -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_new_local (gint year, - gint month, - gint day, - gint hour, - gint minute, - gdouble seconds); -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_new_utc (gint year, - gint month, - gint day, - gint hour, - gint minute, - gdouble seconds); - -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add (GDateTime *datetime, - GTimeSpan timespan); - -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add_years (GDateTime *datetime, - gint years); -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add_months (GDateTime *datetime, - gint months); -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add_weeks (GDateTime *datetime, - gint weeks); -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add_days (GDateTime *datetime, - gint days); - -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add_hours (GDateTime *datetime, - gint hours); -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add_minutes (GDateTime *datetime, - gint minutes); -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add_seconds (GDateTime *datetime, - gdouble seconds); - -GLIB_AVAILABLE_IN_ALL -G_GNUC_WARN_UNUSED_RESULT -GDateTime * g_date_time_add_full (GDateTime *datetime, - gint years, - gint months, - gint days, - gint hours, - gint minutes, - gdouble seconds); - -GLIB_AVAILABLE_IN_ALL -gint g_date_time_compare (gconstpointer dt1, - gconstpointer dt2); -GLIB_AVAILABLE_IN_ALL -GTimeSpan g_date_time_difference (GDateTime *end, - GDateTime *begin); -GLIB_AVAILABLE_IN_ALL -guint g_date_time_hash (gconstpointer datetime); -GLIB_AVAILABLE_IN_ALL -gboolean g_date_time_equal (gconstpointer dt1, - gconstpointer dt2); - -GLIB_AVAILABLE_IN_ALL -void g_date_time_get_ymd (GDateTime *datetime, - gint *year, - gint *month, - gint *day); - -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_year (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_month (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_day_of_month (GDateTime *datetime); - -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_week_numbering_year (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_week_of_year (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_day_of_week (GDateTime *datetime); - -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_day_of_year (GDateTime *datetime); - -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_hour (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_minute (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_second (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gint g_date_time_get_microsecond (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gdouble g_date_time_get_seconds (GDateTime *datetime); - -GLIB_AVAILABLE_IN_ALL -gint64 g_date_time_to_unix (GDateTime *datetime); -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_to_unix) -gboolean g_date_time_to_timeval (GDateTime *datetime, - GTimeVal *tv); -G_GNUC_END_IGNORE_DEPRECATIONS - -GLIB_AVAILABLE_IN_ALL -GTimeSpan g_date_time_get_utc_offset (GDateTime *datetime); -GLIB_AVAILABLE_IN_2_58 -GTimeZone * g_date_time_get_timezone (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -const gchar * g_date_time_get_timezone_abbreviation (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -gboolean g_date_time_is_daylight_savings (GDateTime *datetime); - -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_to_timezone (GDateTime *datetime, - GTimeZone *tz); -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_to_local (GDateTime *datetime); -GLIB_AVAILABLE_IN_ALL -GDateTime * g_date_time_to_utc (GDateTime *datetime); - -GLIB_AVAILABLE_IN_ALL -gchar * g_date_time_format (GDateTime *datetime, - const gchar *format) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_2_62 -gchar * g_date_time_format_iso8601 (GDateTime *datetime) G_GNUC_MALLOC; - -G_END_DECLS - -#endif /* __G_DATE_TIME_H__ */ -#include - -G_BEGIN_DECLS - -/** - * G_BOOKMARK_FILE_ERROR: - * - * Error domain for bookmark file parsing. - * Errors in this domain will be from the #GBookmarkFileError - * enumeration. See #GError for information on error domains. - */ -#define G_BOOKMARK_FILE_ERROR (g_bookmark_file_error_quark ()) - - -/** - * GBookmarkFileError: - * @G_BOOKMARK_FILE_ERROR_INVALID_URI: URI was ill-formed - * @G_BOOKMARK_FILE_ERROR_INVALID_VALUE: a requested field was not found - * @G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED: a requested application did - * not register a bookmark - * @G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND: a requested URI was not found - * @G_BOOKMARK_FILE_ERROR_READ: document was ill formed - * @G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was - * in an unknown encoding - * @G_BOOKMARK_FILE_ERROR_WRITE: an error occurred while writing - * @G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND: requested file was not found - * - * Error codes returned by bookmark file parsing. - */ -typedef enum -{ - G_BOOKMARK_FILE_ERROR_INVALID_URI, - G_BOOKMARK_FILE_ERROR_INVALID_VALUE, - G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED, - G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND, - G_BOOKMARK_FILE_ERROR_READ, - G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING, - G_BOOKMARK_FILE_ERROR_WRITE, - G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND -} GBookmarkFileError; - -GLIB_AVAILABLE_IN_ALL -GQuark g_bookmark_file_error_quark (void); - -/** - * GBookmarkFile: - * - * The `GBookmarkFile` structure contains only - * private data and should not be directly accessed. - */ -typedef struct _GBookmarkFile GBookmarkFile; - -GLIB_AVAILABLE_IN_ALL -GBookmarkFile *g_bookmark_file_new (void); -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_free (GBookmarkFile *bookmark); - -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_load_from_file (GBookmarkFile *bookmark, - const gchar *filename, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_load_from_data (GBookmarkFile *bookmark, - const gchar *data, - gsize length, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_load_from_data_dirs (GBookmarkFile *bookmark, - const gchar *file, - gchar **full_path, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar * g_bookmark_file_to_data (GBookmarkFile *bookmark, - gsize *length, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_to_file (GBookmarkFile *bookmark, - const gchar *filename, - GError **error); - -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_set_title (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *title); -GLIB_AVAILABLE_IN_ALL -gchar * g_bookmark_file_get_title (GBookmarkFile *bookmark, - const gchar *uri, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_set_description (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *description); -GLIB_AVAILABLE_IN_ALL -gchar * g_bookmark_file_get_description (GBookmarkFile *bookmark, - const gchar *uri, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_set_mime_type (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *mime_type); -GLIB_AVAILABLE_IN_ALL -gchar * g_bookmark_file_get_mime_type (GBookmarkFile *bookmark, - const gchar *uri, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_set_groups (GBookmarkFile *bookmark, - const gchar *uri, - const gchar **groups, - gsize length); -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_add_group (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *group); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_has_group (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *group, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark, - const gchar *uri, - gsize *length, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_add_application (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *name, - const gchar *exec); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_has_application (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *name, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark, - const gchar *uri, - gsize *length, - GError **error); -GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_application_info) -gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *name, - const gchar *exec, - gint count, - time_t stamp, - GError **error); -GLIB_AVAILABLE_IN_2_66 -gboolean g_bookmark_file_set_application_info (GBookmarkFile *bookmark, - const char *uri, - const char *name, - const char *exec, - int count, - GDateTime *stamp, - GError **error); -GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_application_info) -gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *name, - gchar **exec, - guint *count, - time_t *stamp, - GError **error); -GLIB_AVAILABLE_IN_2_66 -gboolean g_bookmark_file_get_application_info (GBookmarkFile *bookmark, - const char *uri, - const char *name, - char **exec, - unsigned int *count, - GDateTime **stamp, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_set_is_private (GBookmarkFile *bookmark, - const gchar *uri, - gboolean is_private); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark, - const gchar *uri, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_bookmark_file_set_icon (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *href, - const gchar *mime_type); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark, - const gchar *uri, - gchar **href, - gchar **mime_type, - GError **error); -GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_added_date_time) -void g_bookmark_file_set_added (GBookmarkFile *bookmark, - const gchar *uri, - time_t added); -GLIB_AVAILABLE_IN_2_66 -void g_bookmark_file_set_added_date_time (GBookmarkFile *bookmark, - const char *uri, - GDateTime *added); -GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_added_date_time) -time_t g_bookmark_file_get_added (GBookmarkFile *bookmark, - const gchar *uri, - GError **error); -GLIB_AVAILABLE_IN_2_66 -GDateTime *g_bookmark_file_get_added_date_time (GBookmarkFile *bookmark, - const char *uri, - GError **error); -GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_modified_date_time) -void g_bookmark_file_set_modified (GBookmarkFile *bookmark, - const gchar *uri, - time_t modified); -GLIB_AVAILABLE_IN_2_66 -void g_bookmark_file_set_modified_date_time (GBookmarkFile *bookmark, - const char *uri, - GDateTime *modified); -GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_modified_date_time) -time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark, - const gchar *uri, - GError **error); -GLIB_AVAILABLE_IN_2_66 -GDateTime *g_bookmark_file_get_modified_date_time (GBookmarkFile *bookmark, - const char *uri, - GError **error); -GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_visited_date_time) -void g_bookmark_file_set_visited (GBookmarkFile *bookmark, - const gchar *uri, - time_t visited); -GLIB_AVAILABLE_IN_2_66 -void g_bookmark_file_set_visited_date_time (GBookmarkFile *bookmark, - const char *uri, - GDateTime *visited); -GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_visited_date_time) -time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark, - const gchar *uri, - GError **error); -GLIB_AVAILABLE_IN_2_66 -GDateTime *g_bookmark_file_get_visited_date_time (GBookmarkFile *bookmark, - const char *uri, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark, - const gchar *uri); -GLIB_AVAILABLE_IN_ALL -gint g_bookmark_file_get_size (GBookmarkFile *bookmark); -GLIB_AVAILABLE_IN_ALL -gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark, - gsize *length); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *group, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark, - const gchar *uri, - const gchar *name, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark, - const gchar *uri, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark, - const gchar *old_uri, - const gchar *new_uri, - GError **error); - -G_END_DECLS - -#endif /* __G_BOOKMARK_FILE_H__ */ -/* - * Copyright © 2009, 2010 Codethink Limited - * Copyright © 2011 Collabora Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Author: Ryan Lortie - * Stef Walter - */ - -#ifndef __G_BYTES_H__ -#define __G_BYTES_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -GBytes * g_bytes_new (gconstpointer data, - gsize size); - -GLIB_AVAILABLE_IN_ALL -GBytes * g_bytes_new_take (gpointer data, - gsize size); - -GLIB_AVAILABLE_IN_ALL -GBytes * g_bytes_new_static (gconstpointer data, - gsize size); - -GLIB_AVAILABLE_IN_ALL -GBytes * g_bytes_new_with_free_func (gconstpointer data, - gsize size, - GDestroyNotify free_func, - gpointer user_data); - -GLIB_AVAILABLE_IN_ALL -GBytes * g_bytes_new_from_bytes (GBytes *bytes, - gsize offset, - gsize length); - -GLIB_AVAILABLE_IN_ALL -gconstpointer g_bytes_get_data (GBytes *bytes, - gsize *size); - -GLIB_AVAILABLE_IN_ALL -gsize g_bytes_get_size (GBytes *bytes); - -GLIB_AVAILABLE_IN_ALL -GBytes * g_bytes_ref (GBytes *bytes); - -GLIB_AVAILABLE_IN_ALL -void g_bytes_unref (GBytes *bytes); - -GLIB_AVAILABLE_IN_ALL -gpointer g_bytes_unref_to_data (GBytes *bytes, - gsize *size); - -GLIB_AVAILABLE_IN_ALL -GByteArray * g_bytes_unref_to_array (GBytes *bytes); - -GLIB_AVAILABLE_IN_ALL -guint g_bytes_hash (gconstpointer bytes); - -GLIB_AVAILABLE_IN_ALL -gboolean g_bytes_equal (gconstpointer bytes1, - gconstpointer bytes2); - -GLIB_AVAILABLE_IN_ALL -gint g_bytes_compare (gconstpointer bytes1, - gconstpointer bytes2); - -G_END_DECLS - -#endif /* __G_BYTES_H__ */ -/* gcharset.h - Charset functions - * - * Copyright (C) 2011 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_CHARSET_H__ -#define __G_CHARSET_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -gboolean g_get_charset (const char **charset); -GLIB_AVAILABLE_IN_ALL -gchar * g_get_codeset (void); -GLIB_AVAILABLE_IN_2_62 -gboolean g_get_console_charset (const char **charset); - -GLIB_AVAILABLE_IN_ALL -const gchar * const * g_get_language_names (void); -GLIB_AVAILABLE_IN_2_58 -const gchar * const * g_get_language_names_with_category - (const gchar *category_name); -GLIB_AVAILABLE_IN_ALL -gchar ** g_get_locale_variants (const gchar *locale); - -G_END_DECLS - -#endif /* __G_CHARSET_H__ */ -/* gchecksum.h - data hashing functions - * - * Copyright (C) 2007 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_CHECKSUM_H__ -#define __G_CHECKSUM_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * GChecksumType: - * @G_CHECKSUM_MD5: Use the MD5 hashing algorithm - * @G_CHECKSUM_SHA1: Use the SHA-1 hashing algorithm - * @G_CHECKSUM_SHA256: Use the SHA-256 hashing algorithm - * @G_CHECKSUM_SHA384: Use the SHA-384 hashing algorithm (Since: 2.51) - * @G_CHECKSUM_SHA512: Use the SHA-512 hashing algorithm (Since: 2.36) - * - * The hashing algorithm to be used by #GChecksum when performing the - * digest of some data. - * - * Note that the #GChecksumType enumeration may be extended at a later - * date to include new hashing algorithm types. - * - * Since: 2.16 - */ -typedef enum { - G_CHECKSUM_MD5, - G_CHECKSUM_SHA1, - G_CHECKSUM_SHA256, - G_CHECKSUM_SHA512, - G_CHECKSUM_SHA384 -} GChecksumType; - -/** - * GChecksum: - * - * An opaque structure representing a checksumming operation. - * To create a new GChecksum, use g_checksum_new(). To free - * a GChecksum, use g_checksum_free(). - * - * Since: 2.16 - */ -typedef struct _GChecksum GChecksum; - -GLIB_AVAILABLE_IN_ALL -gssize g_checksum_type_get_length (GChecksumType checksum_type); - -GLIB_AVAILABLE_IN_ALL -GChecksum * g_checksum_new (GChecksumType checksum_type); -GLIB_AVAILABLE_IN_ALL -void g_checksum_reset (GChecksum *checksum); -GLIB_AVAILABLE_IN_ALL -GChecksum * g_checksum_copy (const GChecksum *checksum); -GLIB_AVAILABLE_IN_ALL -void g_checksum_free (GChecksum *checksum); -GLIB_AVAILABLE_IN_ALL -void g_checksum_update (GChecksum *checksum, - const guchar *data, - gssize length); -GLIB_AVAILABLE_IN_ALL -const gchar * g_checksum_get_string (GChecksum *checksum); -GLIB_AVAILABLE_IN_ALL -void g_checksum_get_digest (GChecksum *checksum, - guint8 *buffer, - gsize *digest_len); - -GLIB_AVAILABLE_IN_ALL -gchar *g_compute_checksum_for_data (GChecksumType checksum_type, - const guchar *data, - gsize length); -GLIB_AVAILABLE_IN_ALL -gchar *g_compute_checksum_for_string (GChecksumType checksum_type, - const gchar *str, - gssize length); - -GLIB_AVAILABLE_IN_2_34 -gchar *g_compute_checksum_for_bytes (GChecksumType checksum_type, - GBytes *data); - -G_END_DECLS - -#endif /* __G_CHECKSUM_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_CONVERT_H__ -#define __G_CONVERT_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * GConvertError: - * @G_CONVERT_ERROR_NO_CONVERSION: Conversion between the requested character - * sets is not supported. - * @G_CONVERT_ERROR_ILLEGAL_SEQUENCE: Invalid byte sequence in conversion input; - * or the character sequence could not be represented in the target - * character set. - * @G_CONVERT_ERROR_FAILED: Conversion failed for some reason. - * @G_CONVERT_ERROR_PARTIAL_INPUT: Partial character sequence at end of input. - * @G_CONVERT_ERROR_BAD_URI: URI is invalid. - * @G_CONVERT_ERROR_NOT_ABSOLUTE_PATH: Pathname is not an absolute path. - * @G_CONVERT_ERROR_NO_MEMORY: No memory available. Since: 2.40 - * @G_CONVERT_ERROR_EMBEDDED_NUL: An embedded NUL character is present in - * conversion output where a NUL-terminated string is expected. - * Since: 2.56 - * - * Error codes returned by character set conversion routines. - */ -typedef enum -{ - G_CONVERT_ERROR_NO_CONVERSION, - G_CONVERT_ERROR_ILLEGAL_SEQUENCE, - G_CONVERT_ERROR_FAILED, - G_CONVERT_ERROR_PARTIAL_INPUT, - G_CONVERT_ERROR_BAD_URI, - G_CONVERT_ERROR_NOT_ABSOLUTE_PATH, - G_CONVERT_ERROR_NO_MEMORY, - G_CONVERT_ERROR_EMBEDDED_NUL -} GConvertError; - -/** - * G_CONVERT_ERROR: - * - * Error domain for character set conversions. Errors in this domain will - * be from the #GConvertError enumeration. See #GError for information on - * error domains. - */ -#define G_CONVERT_ERROR g_convert_error_quark() -GLIB_AVAILABLE_IN_ALL -GQuark g_convert_error_quark (void); - -/** - * GIConv: (skip) - * - * The GIConv struct wraps an iconv() conversion descriptor. It contains - * private data and should only be accessed using the following functions. - */ -typedef struct _GIConv *GIConv; - -GLIB_AVAILABLE_IN_ALL -GIConv g_iconv_open (const gchar *to_codeset, - const gchar *from_codeset); -GLIB_AVAILABLE_IN_ALL -gsize g_iconv (GIConv converter, - gchar **inbuf, - gsize *inbytes_left, - gchar **outbuf, - gsize *outbytes_left); -GLIB_AVAILABLE_IN_ALL -gint g_iconv_close (GIConv converter); - - -GLIB_AVAILABLE_IN_ALL -gchar* g_convert (const gchar *str, - gssize len, - const gchar *to_codeset, - const gchar *from_codeset, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_convert_with_iconv (const gchar *str, - gssize len, - GIConv converter, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_convert_with_fallback (const gchar *str, - gssize len, - const gchar *to_codeset, - const gchar *from_codeset, - const gchar *fallback, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; - - -/* Convert between libc's idea of strings and UTF-8. - */ -GLIB_AVAILABLE_IN_ALL -gchar* g_locale_to_utf8 (const gchar *opsysstring, - gssize len, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_locale_from_utf8 (const gchar *utf8string, - gssize len, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; - -/* Convert between the operating system (or C runtime) - * representation of file names and UTF-8. - */ -GLIB_AVAILABLE_IN_ALL -gchar* g_filename_to_utf8 (const gchar *opsysstring, - gssize len, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_filename_from_utf8 (const gchar *utf8string, - gssize len, - gsize *bytes_read, - gsize *bytes_written, - GError **error) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gchar *g_filename_from_uri (const gchar *uri, - gchar **hostname, - GError **error) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gchar *g_filename_to_uri (const gchar *filename, - const gchar *hostname, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar *g_filename_display_name (const gchar *filename) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gboolean g_get_filename_charsets (const gchar ***filename_charsets); - -GLIB_AVAILABLE_IN_ALL -gchar *g_filename_display_basename (const gchar *filename) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gchar **g_uri_list_extract_uris (const gchar *uri_list); - -G_END_DECLS - -#endif /* __G_CONVERT_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_DATASET_H__ -#define __G_DATASET_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GData GData; - -typedef void (*GDataForeachFunc) (GQuark key_id, - gpointer data, - gpointer user_data); - -/* Keyed Data List - */ -GLIB_AVAILABLE_IN_ALL -void g_datalist_init (GData **datalist); -GLIB_AVAILABLE_IN_ALL -void g_datalist_clear (GData **datalist); -GLIB_AVAILABLE_IN_ALL -gpointer g_datalist_id_get_data (GData **datalist, - GQuark key_id); -GLIB_AVAILABLE_IN_ALL -void g_datalist_id_set_data_full (GData **datalist, - GQuark key_id, - gpointer data, - GDestroyNotify destroy_func); - -typedef gpointer (*GDuplicateFunc) (gpointer data, gpointer user_data); - -GLIB_AVAILABLE_IN_2_34 -gpointer g_datalist_id_dup_data (GData **datalist, - GQuark key_id, - GDuplicateFunc dup_func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_34 -gboolean g_datalist_id_replace_data (GData **datalist, - GQuark key_id, - gpointer oldval, - gpointer newval, - GDestroyNotify destroy, - GDestroyNotify *old_destroy); - -GLIB_AVAILABLE_IN_ALL -gpointer g_datalist_id_remove_no_notify (GData **datalist, - GQuark key_id); -GLIB_AVAILABLE_IN_ALL -void g_datalist_foreach (GData **datalist, - GDataForeachFunc func, - gpointer user_data); - -/** - * G_DATALIST_FLAGS_MASK: - * - * A bitmask that restricts the possible flags passed to - * g_datalist_set_flags(). Passing a flags value where - * flags & ~G_DATALIST_FLAGS_MASK != 0 is an error. - */ -#define G_DATALIST_FLAGS_MASK 0x3 - -GLIB_AVAILABLE_IN_ALL -void g_datalist_set_flags (GData **datalist, - guint flags); -GLIB_AVAILABLE_IN_ALL -void g_datalist_unset_flags (GData **datalist, - guint flags); -GLIB_AVAILABLE_IN_ALL -guint g_datalist_get_flags (GData **datalist); - -#define g_datalist_id_set_data(dl, q, d) \ - g_datalist_id_set_data_full ((dl), (q), (d), NULL) -#define g_datalist_id_remove_data(dl, q) \ - g_datalist_id_set_data ((dl), (q), NULL) -#define g_datalist_set_data_full(dl, k, d, f) \ - g_datalist_id_set_data_full ((dl), g_quark_from_string (k), (d), (f)) -#define g_datalist_remove_no_notify(dl, k) \ - g_datalist_id_remove_no_notify ((dl), g_quark_try_string (k)) -#define g_datalist_set_data(dl, k, d) \ - g_datalist_set_data_full ((dl), (k), (d), NULL) -#define g_datalist_remove_data(dl, k) \ - g_datalist_id_set_data ((dl), g_quark_try_string (k), NULL) - -/* Location Associated Keyed Data - */ -GLIB_AVAILABLE_IN_ALL -void g_dataset_destroy (gconstpointer dataset_location); -GLIB_AVAILABLE_IN_ALL -gpointer g_dataset_id_get_data (gconstpointer dataset_location, - GQuark key_id); -GLIB_AVAILABLE_IN_ALL -gpointer g_datalist_get_data (GData **datalist, - const gchar *key); -GLIB_AVAILABLE_IN_ALL -void g_dataset_id_set_data_full (gconstpointer dataset_location, - GQuark key_id, - gpointer data, - GDestroyNotify destroy_func); -GLIB_AVAILABLE_IN_ALL -gpointer g_dataset_id_remove_no_notify (gconstpointer dataset_location, - GQuark key_id); -GLIB_AVAILABLE_IN_ALL -void g_dataset_foreach (gconstpointer dataset_location, - GDataForeachFunc func, - gpointer user_data); -#define g_dataset_id_set_data(l, k, d) \ - g_dataset_id_set_data_full ((l), (k), (d), NULL) -#define g_dataset_id_remove_data(l, k) \ - g_dataset_id_set_data ((l), (k), NULL) -#define g_dataset_get_data(l, k) \ - (g_dataset_id_get_data ((l), g_quark_try_string (k))) -#define g_dataset_set_data_full(l, k, d, f) \ - g_dataset_id_set_data_full ((l), g_quark_from_string (k), (d), (f)) -#define g_dataset_remove_no_notify(l, k) \ - g_dataset_id_remove_no_notify ((l), g_quark_try_string (k)) -#define g_dataset_set_data(l, k, d) \ - g_dataset_set_data_full ((l), (k), (d), NULL) -#define g_dataset_remove_data(l, k) \ - g_dataset_id_set_data ((l), g_quark_try_string (k), NULL) - -G_END_DECLS - -#endif /* __G_DATASET_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_DATE_H__ -#define __G_DATE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#include - - -G_BEGIN_DECLS - -/* GDate - * - * Date calculations (not time for now, to be resolved). These are a - * mutant combination of Steffen Beyer's DateCalc routines - * (http://www.perl.com/CPAN/authors/id/STBEY/) and Jon Trowbridge's - * date routines (written for in-house software). Written by Havoc - * Pennington - */ - -typedef gint32 GTime GLIB_DEPRECATED_TYPE_IN_2_62_FOR(GDateTime); -typedef guint16 GDateYear; -typedef guint8 GDateDay; /* day of the month */ -typedef struct _GDate GDate; - -/* enum used to specify order of appearance in parsed date strings */ -typedef enum -{ - G_DATE_DAY = 0, - G_DATE_MONTH = 1, - G_DATE_YEAR = 2 -} GDateDMY; - -/* actual week and month values */ -typedef enum -{ - G_DATE_BAD_WEEKDAY = 0, - G_DATE_MONDAY = 1, - G_DATE_TUESDAY = 2, - G_DATE_WEDNESDAY = 3, - G_DATE_THURSDAY = 4, - G_DATE_FRIDAY = 5, - G_DATE_SATURDAY = 6, - G_DATE_SUNDAY = 7 -} GDateWeekday; -typedef enum -{ - G_DATE_BAD_MONTH = 0, - G_DATE_JANUARY = 1, - G_DATE_FEBRUARY = 2, - G_DATE_MARCH = 3, - G_DATE_APRIL = 4, - G_DATE_MAY = 5, - G_DATE_JUNE = 6, - G_DATE_JULY = 7, - G_DATE_AUGUST = 8, - G_DATE_SEPTEMBER = 9, - G_DATE_OCTOBER = 10, - G_DATE_NOVEMBER = 11, - G_DATE_DECEMBER = 12 -} GDateMonth; - -#define G_DATE_BAD_JULIAN 0U -#define G_DATE_BAD_DAY 0U -#define G_DATE_BAD_YEAR 0U - -/* Note: directly manipulating structs is generally a bad idea, but - * in this case it's an *incredibly* bad idea, because all or part - * of this struct can be invalid at any given time. Use the functions, - * or you will get hosed, I promise. - */ -struct _GDate -{ - guint julian_days : 32; /* julian days representation - we use a - * bitfield hoping that 64 bit platforms - * will pack this whole struct in one big - * int - */ - - guint julian : 1; /* julian is valid */ - guint dmy : 1; /* dmy is valid */ - - /* DMY representation */ - guint day : 6; - guint month : 4; - guint year : 16; -}; - -/* g_date_new() returns an invalid date, you then have to _set() stuff - * to get a usable object. You can also allocate a GDate statically, - * then call g_date_clear() to initialize. - */ -GLIB_AVAILABLE_IN_ALL -GDate* g_date_new (void); -GLIB_AVAILABLE_IN_ALL -GDate* g_date_new_dmy (GDateDay day, - GDateMonth month, - GDateYear year); -GLIB_AVAILABLE_IN_ALL -GDate* g_date_new_julian (guint32 julian_day); -GLIB_AVAILABLE_IN_ALL -void g_date_free (GDate *date); -GLIB_AVAILABLE_IN_2_56 -GDate* g_date_copy (const GDate *date); - -/* check g_date_valid() after doing an operation that might fail, like - * _parse. Almost all g_date operations are undefined on invalid - * dates (the exceptions are the mutators, since you need those to - * return to validity). - */ -GLIB_AVAILABLE_IN_ALL -gboolean g_date_valid (const GDate *date); -GLIB_AVAILABLE_IN_ALL -gboolean g_date_valid_day (GDateDay day) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_date_valid_month (GDateMonth month) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_date_valid_year (GDateYear year) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_date_valid_weekday (GDateWeekday weekday) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_date_valid_julian (guint32 julian_date) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_date_valid_dmy (GDateDay day, - GDateMonth month, - GDateYear year) G_GNUC_CONST; - -GLIB_AVAILABLE_IN_ALL -GDateWeekday g_date_get_weekday (const GDate *date); -GLIB_AVAILABLE_IN_ALL -GDateMonth g_date_get_month (const GDate *date); -GLIB_AVAILABLE_IN_ALL -GDateYear g_date_get_year (const GDate *date); -GLIB_AVAILABLE_IN_ALL -GDateDay g_date_get_day (const GDate *date); -GLIB_AVAILABLE_IN_ALL -guint32 g_date_get_julian (const GDate *date); -GLIB_AVAILABLE_IN_ALL -guint g_date_get_day_of_year (const GDate *date); -/* First monday/sunday is the start of week 1; if we haven't reached - * that day, return 0. These are not ISO weeks of the year; that - * routine needs to be added. - * these functions return the number of weeks, starting on the - * corrsponding day - */ -GLIB_AVAILABLE_IN_ALL -guint g_date_get_monday_week_of_year (const GDate *date); -GLIB_AVAILABLE_IN_ALL -guint g_date_get_sunday_week_of_year (const GDate *date); -GLIB_AVAILABLE_IN_ALL -guint g_date_get_iso8601_week_of_year (const GDate *date); - -/* If you create a static date struct you need to clear it to get it - * in a safe state before use. You can clear a whole array at - * once with the ndates argument. - */ -GLIB_AVAILABLE_IN_ALL -void g_date_clear (GDate *date, - guint n_dates); - -/* The parse routine is meant for dates typed in by a user, so it - * permits many formats but tries to catch common typos. If your data - * needs to be strictly validated, it is not an appropriate function. - */ -GLIB_AVAILABLE_IN_ALL -void g_date_set_parse (GDate *date, - const gchar *str); -GLIB_AVAILABLE_IN_ALL -void g_date_set_time_t (GDate *date, - time_t timet); -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED_IN_2_62_FOR(g_date_set_time_t) -void g_date_set_time_val (GDate *date, - GTimeVal *timeval); -GLIB_DEPRECATED_FOR(g_date_set_time_t) -void g_date_set_time (GDate *date, - GTime time_); -G_GNUC_END_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_IN_ALL -void g_date_set_month (GDate *date, - GDateMonth month); -GLIB_AVAILABLE_IN_ALL -void g_date_set_day (GDate *date, - GDateDay day); -GLIB_AVAILABLE_IN_ALL -void g_date_set_year (GDate *date, - GDateYear year); -GLIB_AVAILABLE_IN_ALL -void g_date_set_dmy (GDate *date, - GDateDay day, - GDateMonth month, - GDateYear y); -GLIB_AVAILABLE_IN_ALL -void g_date_set_julian (GDate *date, - guint32 julian_date); -GLIB_AVAILABLE_IN_ALL -gboolean g_date_is_first_of_month (const GDate *date); -GLIB_AVAILABLE_IN_ALL -gboolean g_date_is_last_of_month (const GDate *date); - -/* To go forward by some number of weeks just go forward weeks*7 days */ -GLIB_AVAILABLE_IN_ALL -void g_date_add_days (GDate *date, - guint n_days); -GLIB_AVAILABLE_IN_ALL -void g_date_subtract_days (GDate *date, - guint n_days); - -/* If you add/sub months while day > 28, the day might change */ -GLIB_AVAILABLE_IN_ALL -void g_date_add_months (GDate *date, - guint n_months); -GLIB_AVAILABLE_IN_ALL -void g_date_subtract_months (GDate *date, - guint n_months); - -/* If it's feb 29, changing years can move you to the 28th */ -GLIB_AVAILABLE_IN_ALL -void g_date_add_years (GDate *date, - guint n_years); -GLIB_AVAILABLE_IN_ALL -void g_date_subtract_years (GDate *date, - guint n_years); -GLIB_AVAILABLE_IN_ALL -gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -guint8 g_date_get_days_in_month (GDateMonth month, - GDateYear year) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST; - -/* Returns the number of days between the two dates. If date2 comes - before date1, a negative value is return. */ -GLIB_AVAILABLE_IN_ALL -gint g_date_days_between (const GDate *date1, - const GDate *date2); - -/* qsort-friendly (with a cast...) */ -GLIB_AVAILABLE_IN_ALL -gint g_date_compare (const GDate *lhs, - const GDate *rhs); -GLIB_AVAILABLE_IN_ALL -void g_date_to_struct_tm (const GDate *date, - struct tm *tm); - -GLIB_AVAILABLE_IN_ALL -void g_date_clamp (GDate *date, - const GDate *min_date, - const GDate *max_date); - -/* Swap date1 and date2's values if date1 > date2. */ -GLIB_AVAILABLE_IN_ALL -void g_date_order (GDate *date1, GDate *date2); - -/* Just like strftime() except you can only use date-related formats. - * Using a time format is undefined. - */ -GLIB_AVAILABLE_IN_ALL -gsize g_date_strftime (gchar *s, - gsize slen, - const gchar *format, - const GDate *date); - -#define g_date_weekday g_date_get_weekday GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_weekday) -#define g_date_month g_date_get_month GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_month) -#define g_date_year g_date_get_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_year) -#define g_date_day g_date_get_day GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_day) -#define g_date_julian g_date_get_julian GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_julian) -#define g_date_day_of_year g_date_get_day_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_day_of_year) -#define g_date_monday_week_of_year g_date_get_monday_week_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_monday_week_of_year) -#define g_date_sunday_week_of_year g_date_get_sunday_week_of_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_sunday_week_of_year) -#define g_date_days_in_month g_date_get_days_in_month GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_days_in_month) -#define g_date_monday_weeks_in_year g_date_get_monday_weeks_in_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_monday_weeks_in_year) -#define g_date_sunday_weeks_in_year g_date_get_sunday_weeks_in_year GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_date_get_sunday_weeks_in_year) - -G_END_DECLS - -#endif /* __G_DATE_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * gdir.c: Simplified wrapper around the DIRENT functions. - * - * Copyright 2001 Hans Breuer - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_DIR_H__ -#define __G_DIR_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -#ifdef G_OS_UNIX -#include -#endif - -G_BEGIN_DECLS - -typedef struct _GDir GDir; - -GLIB_AVAILABLE_IN_ALL -GDir * g_dir_open (const gchar *path, - guint flags, - GError **error); -GLIB_AVAILABLE_IN_ALL -const gchar * g_dir_read_name (GDir *dir); -GLIB_AVAILABLE_IN_ALL -void g_dir_rewind (GDir *dir); -GLIB_AVAILABLE_IN_ALL -void g_dir_close (GDir *dir); - -G_END_DECLS - -#endif /* __G_DIR_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_ENVIRON_H__ -#define __G_ENVIRON_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -const gchar * g_getenv (const gchar *variable); -GLIB_AVAILABLE_IN_ALL -gboolean g_setenv (const gchar *variable, - const gchar *value, - gboolean overwrite); -GLIB_AVAILABLE_IN_ALL -void g_unsetenv (const gchar *variable); -GLIB_AVAILABLE_IN_ALL -gchar ** g_listenv (void); - -GLIB_AVAILABLE_IN_ALL -gchar ** g_get_environ (void); -GLIB_AVAILABLE_IN_ALL -const gchar * g_environ_getenv (gchar **envp, - const gchar *variable); -GLIB_AVAILABLE_IN_ALL -gchar ** g_environ_setenv (gchar **envp, - const gchar *variable, - const gchar *value, - gboolean overwrite) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -gchar ** g_environ_unsetenv (gchar **envp, - const gchar *variable) G_GNUC_WARN_UNUSED_RESULT; - -G_END_DECLS - -#endif /* __G_ENVIRON_H__ */ -/* gfileutils.h - File utility functions - * - * Copyright 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_FILEUTILS_H__ -#define __G_FILEUTILS_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -#define G_FILE_ERROR g_file_error_quark () - -typedef enum -{ - G_FILE_ERROR_EXIST, - G_FILE_ERROR_ISDIR, - G_FILE_ERROR_ACCES, - G_FILE_ERROR_NAMETOOLONG, - G_FILE_ERROR_NOENT, - G_FILE_ERROR_NOTDIR, - G_FILE_ERROR_NXIO, - G_FILE_ERROR_NODEV, - G_FILE_ERROR_ROFS, - G_FILE_ERROR_TXTBSY, - G_FILE_ERROR_FAULT, - G_FILE_ERROR_LOOP, - G_FILE_ERROR_NOSPC, - G_FILE_ERROR_NOMEM, - G_FILE_ERROR_MFILE, - G_FILE_ERROR_NFILE, - G_FILE_ERROR_BADF, - G_FILE_ERROR_INVAL, - G_FILE_ERROR_PIPE, - G_FILE_ERROR_AGAIN, - G_FILE_ERROR_INTR, - G_FILE_ERROR_IO, - G_FILE_ERROR_PERM, - G_FILE_ERROR_NOSYS, - G_FILE_ERROR_FAILED -} GFileError; - -/* For backward-compat reasons, these are synced to an old - * anonymous enum in libgnome. But don't use that enum - * in new code. - */ -typedef enum -{ - G_FILE_TEST_IS_REGULAR = 1 << 0, - G_FILE_TEST_IS_SYMLINK = 1 << 1, - G_FILE_TEST_IS_DIR = 1 << 2, - G_FILE_TEST_IS_EXECUTABLE = 1 << 3, - G_FILE_TEST_EXISTS = 1 << 4 -} GFileTest; - -/** - * GFileSetContentsFlags: - * @G_FILE_SET_CONTENTS_NONE: No guarantees about file consistency or durability. - * The most dangerous setting, which is slightly faster than other settings. - * @G_FILE_SET_CONTENTS_CONSISTENT: Guarantee file consistency: after a crash, - * either the old version of the file or the new version of the file will be - * available, but not a mixture. On Unix systems this equates to an `fsync()` - * on the file and use of an atomic `rename()` of the new version of the file - * over the old. - * @G_FILE_SET_CONTENTS_DURABLE: Guarantee file durability: after a crash, the - * new version of the file will be available. On Unix systems this equates to - * an `fsync()` on the file (if %G_FILE_SET_CONTENTS_CONSISTENT is unset), or - * the effects of %G_FILE_SET_CONTENTS_CONSISTENT plus an `fsync()` on the - * directory containing the file after calling `rename()`. - * @G_FILE_SET_CONTENTS_ONLY_EXISTING: Only apply consistency and durability - * guarantees if the file already exists. This may speed up file operations - * if the file doesn’t currently exist, but may result in a corrupted version - * of the new file if the system crashes while writing it. - * - * Flags to pass to g_file_set_contents_full() to affect its safety and - * performance. - * - * Since: 2.66 - */ -typedef enum -{ - G_FILE_SET_CONTENTS_NONE = 0, - G_FILE_SET_CONTENTS_CONSISTENT = 1 << 0, - G_FILE_SET_CONTENTS_DURABLE = 1 << 1, - G_FILE_SET_CONTENTS_ONLY_EXISTING = 1 << 2 -} GFileSetContentsFlags -GLIB_AVAILABLE_ENUMERATOR_IN_2_66; - -GLIB_AVAILABLE_IN_ALL -GQuark g_file_error_quark (void); -/* So other code can generate a GFileError */ -GLIB_AVAILABLE_IN_ALL -GFileError g_file_error_from_errno (gint err_no); - -GLIB_AVAILABLE_IN_ALL -gboolean g_file_test (const gchar *filename, - GFileTest test); -GLIB_AVAILABLE_IN_ALL -gboolean g_file_get_contents (const gchar *filename, - gchar **contents, - gsize *length, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_file_set_contents (const gchar *filename, - const gchar *contents, - gssize length, - GError **error); -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_IN_2_66 -gboolean g_file_set_contents_full (const gchar *filename, - const gchar *contents, - gssize length, - GFileSetContentsFlags flags, - int mode, - GError **error); -G_GNUC_END_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_IN_ALL -gchar *g_file_read_link (const gchar *filename, - GError **error); - -/* Wrapper / workalike for mkdtemp() */ -GLIB_AVAILABLE_IN_2_30 -gchar *g_mkdtemp (gchar *tmpl); -GLIB_AVAILABLE_IN_2_30 -gchar *g_mkdtemp_full (gchar *tmpl, - gint mode); - -/* Wrapper / workalike for mkstemp() */ -GLIB_AVAILABLE_IN_ALL -gint g_mkstemp (gchar *tmpl); -GLIB_AVAILABLE_IN_ALL -gint g_mkstemp_full (gchar *tmpl, - gint flags, - gint mode); - -/* Wrappers for g_mkstemp and g_mkdtemp() */ -GLIB_AVAILABLE_IN_ALL -gint g_file_open_tmp (const gchar *tmpl, - gchar **name_used, - GError **error); -GLIB_AVAILABLE_IN_2_30 -gchar *g_dir_make_tmp (const gchar *tmpl, - GError **error); - -GLIB_AVAILABLE_IN_ALL -gchar *g_build_path (const gchar *separator, - const gchar *first_element, - ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; -GLIB_AVAILABLE_IN_ALL -gchar *g_build_pathv (const gchar *separator, - gchar **args) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gchar *g_build_filename (const gchar *first_element, - ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; -GLIB_AVAILABLE_IN_ALL -gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_2_56 -gchar *g_build_filename_valist (const gchar *first_element, - va_list *args) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gint g_mkdir_with_parents (const gchar *pathname, - gint mode); - -#ifdef G_OS_WIN32 - -/* On Win32, the canonical directory separator is the backslash, and - * the search path separator is the semicolon. Note that also the - * (forward) slash works as directory separator. - */ -#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/') - -#else /* !G_OS_WIN32 */ - -#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR) - -#endif /* !G_OS_WIN32 */ - -GLIB_AVAILABLE_IN_ALL -gboolean g_path_is_absolute (const gchar *file_name); -GLIB_AVAILABLE_IN_ALL -const gchar *g_path_skip_root (const gchar *file_name); - -GLIB_DEPRECATED_FOR(g_path_get_basename) -const gchar *g_basename (const gchar *file_name); -#define g_dirname g_path_get_dirname GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_path_get_dirname) - -GLIB_AVAILABLE_IN_ALL -gchar *g_get_current_dir (void); -GLIB_AVAILABLE_IN_ALL -gchar *g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar *g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_2_58 -gchar *g_canonicalize_filename (const gchar *filename, - const gchar *relative_to) G_GNUC_MALLOC; - -G_END_DECLS - -#endif /* __G_FILEUTILS_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_GETTEXT_H__ -#define __G_GETTEXT_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -const gchar *g_strip_context (const gchar *msgid, - const gchar *msgval) G_GNUC_FORMAT(1); - -GLIB_AVAILABLE_IN_ALL -const gchar *g_dgettext (const gchar *domain, - const gchar *msgid) G_GNUC_FORMAT(2); -GLIB_AVAILABLE_IN_ALL -const gchar *g_dcgettext (const gchar *domain, - const gchar *msgid, - gint category) G_GNUC_FORMAT(2); -GLIB_AVAILABLE_IN_ALL -const gchar *g_dngettext (const gchar *domain, - const gchar *msgid, - const gchar *msgid_plural, - gulong n) G_GNUC_FORMAT(3); -GLIB_AVAILABLE_IN_ALL -const gchar *g_dpgettext (const gchar *domain, - const gchar *msgctxtid, - gsize msgidoffset) G_GNUC_FORMAT(2); -GLIB_AVAILABLE_IN_ALL -const gchar *g_dpgettext2 (const gchar *domain, - const gchar *context, - const gchar *msgid) G_GNUC_FORMAT(3); - -G_END_DECLS - -#endif /* __G_GETTEXT_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_HASH_H__ -#define __G_HASH_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_LIST_H__ -#define __G_LIST_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_MEM_H__ -#define __G_MEM_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * GMemVTable: - * @malloc: function to use for allocating memory. - * @realloc: function to use for reallocating memory. - * @free: function to use to free memory. - * @calloc: function to use for allocating zero-filled memory. - * @try_malloc: function to use for allocating memory without a default error handler. - * @try_realloc: function to use for reallocating memory without a default error handler. - * - * A set of functions used to perform memory allocation. The same #GMemVTable must - * be used for all allocations in the same program; a call to g_mem_set_vtable(), - * if it exists, should be prior to any use of GLib. - */ -typedef struct _GMemVTable GMemVTable; - - -#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG -/** - * G_MEM_ALIGN: - * - * Indicates the number of bytes to which memory will be aligned on the - * current platform. - */ -# define G_MEM_ALIGN GLIB_SIZEOF_VOID_P -#else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */ -# define G_MEM_ALIGN GLIB_SIZEOF_LONG -#endif /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */ - - -/* Memory allocation functions - */ - -GLIB_AVAILABLE_IN_ALL -void g_free (gpointer mem); - -GLIB_AVAILABLE_IN_2_34 -void g_clear_pointer (gpointer *pp, - GDestroyNotify destroy); - -GLIB_AVAILABLE_IN_ALL -gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_ALL -gpointer g_malloc0 (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_ALL -gpointer g_realloc (gpointer mem, - gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -gpointer g_try_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_ALL -gpointer g_try_malloc0 (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_ALL -gpointer g_try_realloc (gpointer mem, - gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT; - -GLIB_AVAILABLE_IN_ALL -gpointer g_malloc_n (gsize n_blocks, - gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); -GLIB_AVAILABLE_IN_ALL -gpointer g_malloc0_n (gsize n_blocks, - gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); -GLIB_AVAILABLE_IN_ALL -gpointer g_realloc_n (gpointer mem, - gsize n_blocks, - gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -gpointer g_try_malloc_n (gsize n_blocks, - gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); -GLIB_AVAILABLE_IN_ALL -gpointer g_try_malloc0_n (gsize n_blocks, - gsize n_block_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE2(1,2); -GLIB_AVAILABLE_IN_ALL -gpointer g_try_realloc_n (gpointer mem, - gsize n_blocks, - gsize n_block_bytes) G_GNUC_WARN_UNUSED_RESULT; - -#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 -#undef g_clear_pointer -#define g_clear_pointer(pp, destroy) \ - G_STMT_START \ - { \ - G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ - glib_typeof ((pp)) _pp = (pp); \ - glib_typeof (*(pp)) _ptr = *_pp; \ - *_pp = NULL; \ - if (_ptr) \ - (destroy) (_ptr); \ - } \ - G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_34 -#else /* __GNUC__ */ -#undef g_clear_pointer -#define g_clear_pointer(pp, destroy) \ - G_STMT_START { \ - G_STATIC_ASSERT (sizeof *(pp) == sizeof (gpointer)); \ - /* Only one access, please; work around type aliasing */ \ - union { char *in; gpointer *out; } _pp; \ - gpointer _p; \ - /* This assignment is needed to avoid a gcc warning */ \ - GDestroyNotify _destroy = (GDestroyNotify) (destroy); \ - \ - _pp.in = (char *) (pp); \ - _p = *_pp.out; \ - if (_p) \ - { \ - *_pp.out = NULL; \ - _destroy (_p); \ - } \ - } G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_34 -#endif /* __GNUC__ */ - -/** - * g_steal_pointer: - * @pp: (not nullable): a pointer to a pointer - * - * Sets @pp to %NULL, returning the value that was there before. - * - * Conceptually, this transfers the ownership of the pointer from the - * referenced variable to the "caller" of the macro (ie: "steals" the - * reference). - * - * The return value will be properly typed, according to the type of - * @pp. - * - * This can be very useful when combined with g_autoptr() to prevent the - * return value of a function from being automatically freed. Consider - * the following example (which only works on GCC and clang): - * - * |[ - * GObject * - * create_object (void) - * { - * g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL); - * - * if (early_error_case) - * return NULL; - * - * return g_steal_pointer (&obj); - * } - * ]| - * - * It can also be used in similar ways for 'out' parameters and is - * particularly useful for dealing with optional out parameters: - * - * |[ - * gboolean - * get_object (GObject **obj_out) - * { - * g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL); - * - * if (early_error_case) - * return FALSE; - * - * if (obj_out) - * *obj_out = g_steal_pointer (&obj); - * - * return TRUE; - * } - * ]| - * - * In the above example, the object will be automatically freed in the - * early error case and also in the case that %NULL was given for - * @obj_out. - * - * Since: 2.44 - */ -GLIB_AVAILABLE_STATIC_INLINE_IN_2_44 -static inline gpointer -g_steal_pointer (gpointer pp) -{ - gpointer *ptr = (gpointer *) pp; - gpointer ref; - - ref = *ptr; - *ptr = NULL; - - return ref; -} - -/* type safety */ -#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_58 -#define g_steal_pointer(pp) ((glib_typeof (*pp)) (g_steal_pointer) (pp)) -#else /* __GNUC__ */ -/* This version does not depend on gcc extensions, but gcc does not warn - * about incompatible-pointer-types: */ -#define g_steal_pointer(pp) \ - (0 ? (*(pp)) : (g_steal_pointer) (pp)) -#endif /* __GNUC__ */ - -/* Optimise: avoid the call to the (slower) _n function if we can - * determine at compile-time that no overflow happens. - */ -#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) -# define _G_NEW(struct_type, n_structs, func) \ - (struct_type *) (G_GNUC_EXTENSION ({ \ - gsize __n = (gsize) (n_structs); \ - gsize __s = sizeof (struct_type); \ - gpointer __p; \ - if (__s == 1) \ - __p = g_##func (__n); \ - else if (__builtin_constant_p (__n) && \ - (__s == 0 || __n <= G_MAXSIZE / __s)) \ - __p = g_##func (__n * __s); \ - else \ - __p = g_##func##_n (__n, __s); \ - __p; \ - })) -# define _G_RENEW(struct_type, mem, n_structs, func) \ - (struct_type *) (G_GNUC_EXTENSION ({ \ - gsize __n = (gsize) (n_structs); \ - gsize __s = sizeof (struct_type); \ - gpointer __p = (gpointer) (mem); \ - if (__s == 1) \ - __p = g_##func (__p, __n); \ - else if (__builtin_constant_p (__n) && \ - (__s == 0 || __n <= G_MAXSIZE / __s)) \ - __p = g_##func (__p, __n * __s); \ - else \ - __p = g_##func##_n (__p, __n, __s); \ - __p; \ - })) - -#else - -/* Unoptimised version: always call the _n() function. */ - -#define _G_NEW(struct_type, n_structs, func) \ - ((struct_type *) g_##func##_n ((n_structs), sizeof (struct_type))) -#define _G_RENEW(struct_type, mem, n_structs, func) \ - ((struct_type *) g_##func##_n (mem, (n_structs), sizeof (struct_type))) - -#endif - -/** - * g_new: - * @struct_type: the type of the elements to allocate - * @n_structs: the number of elements to allocate - * - * Allocates @n_structs elements of type @struct_type. - * The returned pointer is cast to a pointer to the given type. - * If @n_structs is 0 it returns %NULL. - * Care is taken to avoid overflow when calculating the size of the allocated block. - * - * Since the returned pointer is already casted to the right type, - * it is normally unnecessary to cast it explicitly, and doing - * so might hide memory allocation errors. - * - * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type - */ -#define g_new(struct_type, n_structs) _G_NEW (struct_type, n_structs, malloc) -/** - * g_new0: - * @struct_type: the type of the elements to allocate. - * @n_structs: the number of elements to allocate. - * - * Allocates @n_structs elements of type @struct_type, initialized to 0's. - * The returned pointer is cast to a pointer to the given type. - * If @n_structs is 0 it returns %NULL. - * Care is taken to avoid overflow when calculating the size of the allocated block. - * - * Since the returned pointer is already casted to the right type, - * it is normally unnecessary to cast it explicitly, and doing - * so might hide memory allocation errors. - * - * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type. - */ -#define g_new0(struct_type, n_structs) _G_NEW (struct_type, n_structs, malloc0) -/** - * g_renew: - * @struct_type: the type of the elements to allocate - * @mem: the currently allocated memory - * @n_structs: the number of elements to allocate - * - * Reallocates the memory pointed to by @mem, so that it now has space for - * @n_structs elements of type @struct_type. It returns the new address of - * the memory, which may have been moved. - * Care is taken to avoid overflow when calculating the size of the allocated block. - * - * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type - */ -#define g_renew(struct_type, mem, n_structs) _G_RENEW (struct_type, mem, n_structs, realloc) -/** - * g_try_new: - * @struct_type: the type of the elements to allocate - * @n_structs: the number of elements to allocate - * - * Attempts to allocate @n_structs elements of type @struct_type, and returns - * %NULL on failure. Contrast with g_new(), which aborts the program on failure. - * The returned pointer is cast to a pointer to the given type. - * The function returns %NULL when @n_structs is 0 of if an overflow occurs. - * - * Since: 2.8 - * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type - */ -#define g_try_new(struct_type, n_structs) _G_NEW (struct_type, n_structs, try_malloc) -/** - * g_try_new0: - * @struct_type: the type of the elements to allocate - * @n_structs: the number of elements to allocate - * - * Attempts to allocate @n_structs elements of type @struct_type, initialized - * to 0's, and returns %NULL on failure. Contrast with g_new0(), which aborts - * the program on failure. - * The returned pointer is cast to a pointer to the given type. - * The function returns %NULL when @n_structs is 0 or if an overflow occurs. - * - * Since: 2.8 - * Returns: a pointer to the allocated memory, cast to a pointer to @struct_type - */ -#define g_try_new0(struct_type, n_structs) _G_NEW (struct_type, n_structs, try_malloc0) -/** - * g_try_renew: - * @struct_type: the type of the elements to allocate - * @mem: the currently allocated memory - * @n_structs: the number of elements to allocate - * - * Attempts to reallocate the memory pointed to by @mem, so that it now has - * space for @n_structs elements of type @struct_type, and returns %NULL on - * failure. Contrast with g_renew(), which aborts the program on failure. - * It returns the new address of the memory, which may have been moved. - * The function returns %NULL if an overflow occurs. - * - * Since: 2.8 - * Returns: a pointer to the new allocated memory, cast to a pointer to @struct_type - */ -#define g_try_renew(struct_type, mem, n_structs) _G_RENEW (struct_type, mem, n_structs, try_realloc) - - -/* Memory allocation virtualization for debugging purposes - * g_mem_set_vtable() has to be the very first GLib function called - * if being used - */ -struct _GMemVTable { - gpointer (*malloc) (gsize n_bytes); - gpointer (*realloc) (gpointer mem, - gsize n_bytes); - /* optional; set to NULL if not supported */ - gpointer (*memalign) (gsize alignment, - gsize size); - void (*free) (gpointer mem); - /* optional; set to NULL if not used ! */ - gpointer (*calloc) (gsize n_blocks, - gsize n_block_bytes); - gpointer (*try_malloc) (gsize n_bytes); - gpointer (*try_realloc) (gpointer mem, - gsize n_bytes); -}; -GLIB_VAR GMemVTable *glib_mem_table; -GLIB_AVAILABLE_IN_ALL -void g_mem_set_vtable (GMemVTable *vtable); -GLIB_AVAILABLE_IN_ALL -gboolean g_mem_is_system_malloc (void); - -GLIB_VAR gboolean g_mem_gc_friendly; - -/* Memory profiler and checker, has to be enabled via g_mem_set_vtable() - */ -GLIB_VAR GMemVTable *glib_mem_profiler_table; -GLIB_DEPRECATED_IN_2_46 -void g_mem_profile (void); - -G_END_DECLS - -#endif /* __G_MEM_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_NODE_H__ -#define __G_NODE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GNode GNode; - -/* Tree traverse flags */ -typedef enum -{ - G_TRAVERSE_LEAVES = 1 << 0, - G_TRAVERSE_NON_LEAVES = 1 << 1, - G_TRAVERSE_ALL = G_TRAVERSE_LEAVES | G_TRAVERSE_NON_LEAVES, - G_TRAVERSE_MASK = 0x03, - G_TRAVERSE_LEAFS = G_TRAVERSE_LEAVES, - G_TRAVERSE_NON_LEAFS = G_TRAVERSE_NON_LEAVES -} GTraverseFlags; - -/* Tree traverse orders */ -typedef enum -{ - G_IN_ORDER, - G_PRE_ORDER, - G_POST_ORDER, - G_LEVEL_ORDER -} GTraverseType; - -typedef gboolean (*GNodeTraverseFunc) (GNode *node, - gpointer data); -typedef void (*GNodeForeachFunc) (GNode *node, - gpointer data); - -/* N-way tree implementation - */ -struct _GNode -{ - gpointer data; - GNode *next; - GNode *prev; - GNode *parent; - GNode *children; -}; - -/** - * G_NODE_IS_ROOT: - * @node: a #GNode - * - * Returns %TRUE if a #GNode is the root of a tree. - * - * Returns: %TRUE if the #GNode is the root of a tree - * (i.e. it has no parent or siblings) - */ -#define G_NODE_IS_ROOT(node) (((GNode*) (node))->parent == NULL && \ - ((GNode*) (node))->prev == NULL && \ - ((GNode*) (node))->next == NULL) - -/** - * G_NODE_IS_LEAF: - * @node: a #GNode - * - * Returns %TRUE if a #GNode is a leaf node. - * - * Returns: %TRUE if the #GNode is a leaf node - * (i.e. it has no children) - */ -#define G_NODE_IS_LEAF(node) (((GNode*) (node))->children == NULL) - -GLIB_AVAILABLE_IN_ALL -GNode* g_node_new (gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_node_destroy (GNode *root); -GLIB_AVAILABLE_IN_ALL -void g_node_unlink (GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_copy_deep (GNode *node, - GCopyFunc copy_func, - gpointer data); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_copy (GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_insert (GNode *parent, - gint position, - GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_insert_before (GNode *parent, - GNode *sibling, - GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_insert_after (GNode *parent, - GNode *sibling, - GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_prepend (GNode *parent, - GNode *node); -GLIB_AVAILABLE_IN_ALL -guint g_node_n_nodes (GNode *root, - GTraverseFlags flags); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_get_root (GNode *node); -GLIB_AVAILABLE_IN_ALL -gboolean g_node_is_ancestor (GNode *node, - GNode *descendant); -GLIB_AVAILABLE_IN_ALL -guint g_node_depth (GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_find (GNode *root, - GTraverseType order, - GTraverseFlags flags, - gpointer data); - -/* convenience macros */ -/** - * g_node_append: - * @parent: the #GNode to place the new #GNode under - * @node: the #GNode to insert - * - * Inserts a #GNode as the last child of the given parent. - * - * Returns: the inserted #GNode - */ -#define g_node_append(parent, node) \ - g_node_insert_before ((parent), NULL, (node)) - -/** - * g_node_insert_data: - * @parent: the #GNode to place the new #GNode under - * @position: the position to place the new #GNode at. If position is -1, - * the new #GNode is inserted as the last child of @parent - * @data: the data for the new #GNode - * - * Inserts a new #GNode at the given position. - * - * Returns: the new #GNode - */ -#define g_node_insert_data(parent, position, data) \ - g_node_insert ((parent), (position), g_node_new (data)) - -/** - * g_node_insert_data_after: - * @parent: the #GNode to place the new #GNode under - * @sibling: the sibling #GNode to place the new #GNode after - * @data: the data for the new #GNode - * - * Inserts a new #GNode after the given sibling. - * - * Returns: the new #GNode - */ - -#define g_node_insert_data_after(parent, sibling, data) \ - g_node_insert_after ((parent), (sibling), g_node_new (data)) -/** - * g_node_insert_data_before: - * @parent: the #GNode to place the new #GNode under - * @sibling: the sibling #GNode to place the new #GNode before - * @data: the data for the new #GNode - * - * Inserts a new #GNode before the given sibling. - * - * Returns: the new #GNode - */ -#define g_node_insert_data_before(parent, sibling, data) \ - g_node_insert_before ((parent), (sibling), g_node_new (data)) - -/** - * g_node_prepend_data: - * @parent: the #GNode to place the new #GNode under - * @data: the data for the new #GNode - * - * Inserts a new #GNode as the first child of the given parent. - * - * Returns: the new #GNode - */ -#define g_node_prepend_data(parent, data) \ - g_node_prepend ((parent), g_node_new (data)) - -/** - * g_node_append_data: - * @parent: the #GNode to place the new #GNode under - * @data: the data for the new #GNode - * - * Inserts a new #GNode as the last child of the given parent. - * - * Returns: the new #GNode - */ -#define g_node_append_data(parent, data) \ - g_node_insert_before ((parent), NULL, g_node_new (data)) - -/* traversal function, assumes that 'node' is root - * (only traverses 'node' and its subtree). - * this function is just a high level interface to - * low level traversal functions, optimized for speed. - */ -GLIB_AVAILABLE_IN_ALL -void g_node_traverse (GNode *root, - GTraverseType order, - GTraverseFlags flags, - gint max_depth, - GNodeTraverseFunc func, - gpointer data); - -/* return the maximum tree height starting with 'node', this is an expensive - * operation, since we need to visit all nodes. this could be shortened by - * adding 'guint height' to struct _GNode, but then again, this is not very - * often needed, and would make g_node_insert() more time consuming. - */ -GLIB_AVAILABLE_IN_ALL -guint g_node_max_height (GNode *root); - -GLIB_AVAILABLE_IN_ALL -void g_node_children_foreach (GNode *node, - GTraverseFlags flags, - GNodeForeachFunc func, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_node_reverse_children (GNode *node); -GLIB_AVAILABLE_IN_ALL -guint g_node_n_children (GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_nth_child (GNode *node, - guint n); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_last_child (GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_find_child (GNode *node, - GTraverseFlags flags, - gpointer data); -GLIB_AVAILABLE_IN_ALL -gint g_node_child_position (GNode *node, - GNode *child); -GLIB_AVAILABLE_IN_ALL -gint g_node_child_index (GNode *node, - gpointer data); - -GLIB_AVAILABLE_IN_ALL -GNode* g_node_first_sibling (GNode *node); -GLIB_AVAILABLE_IN_ALL -GNode* g_node_last_sibling (GNode *node); - -/** - * g_node_prev_sibling: - * @node: a #GNode - * - * Gets the previous sibling of a #GNode. - * - * Returns: the previous sibling of @node, or %NULL if @node is the first - * node or %NULL - */ -#define g_node_prev_sibling(node) ((node) ? \ - ((GNode*) (node))->prev : NULL) - -/** - * g_node_next_sibling: - * @node: a #GNode - * - * Gets the next sibling of a #GNode. - * - * Returns: the next sibling of @node, or %NULL if @node is the last node - * or %NULL - */ -#define g_node_next_sibling(node) ((node) ? \ - ((GNode*) (node))->next : NULL) - -/** - * g_node_first_child: - * @node: a #GNode - * - * Gets the first child of a #GNode. - * - * Returns: the first child of @node, or %NULL if @node is %NULL - * or has no children - */ -#define g_node_first_child(node) ((node) ? \ - ((GNode*) (node))->children : NULL) - -G_END_DECLS - -#endif /* __G_NODE_H__ */ - -G_BEGIN_DECLS - -typedef struct _GList GList; - -struct _GList -{ - gpointer data; - GList *next; - GList *prev; -}; - -/* Doubly linked lists - */ -GLIB_AVAILABLE_IN_ALL -GList* g_list_alloc (void) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -void g_list_free (GList *list); -GLIB_AVAILABLE_IN_ALL -void g_list_free_1 (GList *list); -#define g_list_free1 g_list_free_1 -GLIB_AVAILABLE_IN_ALL -void g_list_free_full (GList *list, - GDestroyNotify free_func); -GLIB_AVAILABLE_IN_ALL -GList* g_list_append (GList *list, - gpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_prepend (GList *list, - gpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_insert (GList *list, - gpointer data, - gint position) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_insert_sorted (GList *list, - gpointer data, - GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_insert_sorted_with_data (GList *list, - gpointer data, - GCompareDataFunc func, - gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_insert_before (GList *list, - GList *sibling, - gpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_2_62 -GList* g_list_insert_before_link (GList *list, - GList *sibling, - GList *link_) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_concat (GList *list1, - GList *list2) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_remove (GList *list, - gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_remove_all (GList *list, - gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_remove_link (GList *list, - GList *llink) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_delete_link (GList *list, - GList *link_) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_reverse (GList *list) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_copy (GList *list) G_GNUC_WARN_UNUSED_RESULT; - -GLIB_AVAILABLE_IN_2_34 -GList* g_list_copy_deep (GList *list, - GCopyFunc func, - gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; - -GLIB_AVAILABLE_IN_ALL -GList* g_list_nth (GList *list, - guint n); -GLIB_AVAILABLE_IN_ALL -GList* g_list_nth_prev (GList *list, - guint n); -GLIB_AVAILABLE_IN_ALL -GList* g_list_find (GList *list, - gconstpointer data); -GLIB_AVAILABLE_IN_ALL -GList* g_list_find_custom (GList *list, - gconstpointer data, - GCompareFunc func); -GLIB_AVAILABLE_IN_ALL -gint g_list_position (GList *list, - GList *llink); -GLIB_AVAILABLE_IN_ALL -gint g_list_index (GList *list, - gconstpointer data); -GLIB_AVAILABLE_IN_ALL -GList* g_list_last (GList *list); -GLIB_AVAILABLE_IN_ALL -GList* g_list_first (GList *list); -GLIB_AVAILABLE_IN_ALL -guint g_list_length (GList *list); -GLIB_AVAILABLE_IN_ALL -void g_list_foreach (GList *list, - GFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -GList* g_list_sort (GList *list, - GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GList* g_list_sort_with_data (GList *list, - GCompareDataFunc compare_func, - gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -gpointer g_list_nth_data (GList *list, - guint n); - -GLIB_AVAILABLE_IN_2_64 -void g_clear_list (GList **list_ptr, - GDestroyNotify destroy); - -#undef g_clear_list -#define g_clear_list(list_ptr, destroy) \ - G_STMT_START { \ - GList *_list; \ - \ - _list = *(list_ptr); \ - if (_list) \ - { \ - *list_ptr = NULL; \ - \ - if ((destroy) != NULL) \ - g_list_free_full (_list, (destroy)); \ - else \ - g_list_free (_list); \ - } \ - } G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_64 - - -#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL) -#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL) - -G_END_DECLS - -#endif /* __G_LIST_H__ */ - -G_BEGIN_DECLS - -typedef struct _GHashTable GHashTable; - -typedef gboolean (*GHRFunc) (gpointer key, - gpointer value, - gpointer user_data); - -typedef struct _GHashTableIter GHashTableIter; - -struct _GHashTableIter -{ - /*< private >*/ - gpointer dummy1; - gpointer dummy2; - gpointer dummy3; - int dummy4; - gboolean dummy5; - gpointer dummy6; -}; - -GLIB_AVAILABLE_IN_ALL -GHashTable* g_hash_table_new (GHashFunc hash_func, - GEqualFunc key_equal_func); -GLIB_AVAILABLE_IN_ALL -GHashTable* g_hash_table_new_full (GHashFunc hash_func, - GEqualFunc key_equal_func, - GDestroyNotify key_destroy_func, - GDestroyNotify value_destroy_func); -GLIB_AVAILABLE_IN_ALL -void g_hash_table_destroy (GHashTable *hash_table); -GLIB_AVAILABLE_IN_ALL -gboolean g_hash_table_insert (GHashTable *hash_table, - gpointer key, - gpointer value); -GLIB_AVAILABLE_IN_ALL -gboolean g_hash_table_replace (GHashTable *hash_table, - gpointer key, - gpointer value); -GLIB_AVAILABLE_IN_ALL -gboolean g_hash_table_add (GHashTable *hash_table, - gpointer key); -GLIB_AVAILABLE_IN_ALL -gboolean g_hash_table_remove (GHashTable *hash_table, - gconstpointer key); -GLIB_AVAILABLE_IN_ALL -void g_hash_table_remove_all (GHashTable *hash_table); -GLIB_AVAILABLE_IN_ALL -gboolean g_hash_table_steal (GHashTable *hash_table, - gconstpointer key); -GLIB_AVAILABLE_IN_2_58 -gboolean g_hash_table_steal_extended (GHashTable *hash_table, - gconstpointer lookup_key, - gpointer *stolen_key, - gpointer *stolen_value); -GLIB_AVAILABLE_IN_ALL -void g_hash_table_steal_all (GHashTable *hash_table); -GLIB_AVAILABLE_IN_ALL -gpointer g_hash_table_lookup (GHashTable *hash_table, - gconstpointer key); -GLIB_AVAILABLE_IN_ALL -gboolean g_hash_table_contains (GHashTable *hash_table, - gconstpointer key); -GLIB_AVAILABLE_IN_ALL -gboolean g_hash_table_lookup_extended (GHashTable *hash_table, - gconstpointer lookup_key, - gpointer *orig_key, - gpointer *value); -GLIB_AVAILABLE_IN_ALL -void g_hash_table_foreach (GHashTable *hash_table, - GHFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -gpointer g_hash_table_find (GHashTable *hash_table, - GHRFunc predicate, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -guint g_hash_table_foreach_remove (GHashTable *hash_table, - GHRFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -guint g_hash_table_foreach_steal (GHashTable *hash_table, - GHRFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -guint g_hash_table_size (GHashTable *hash_table); -GLIB_AVAILABLE_IN_ALL -GList * g_hash_table_get_keys (GHashTable *hash_table); -GLIB_AVAILABLE_IN_ALL -GList * g_hash_table_get_values (GHashTable *hash_table); -GLIB_AVAILABLE_IN_2_40 -gpointer * g_hash_table_get_keys_as_array (GHashTable *hash_table, - guint *length); - -GLIB_AVAILABLE_IN_ALL -void g_hash_table_iter_init (GHashTableIter *iter, - GHashTable *hash_table); -GLIB_AVAILABLE_IN_ALL -gboolean g_hash_table_iter_next (GHashTableIter *iter, - gpointer *key, - gpointer *value); -GLIB_AVAILABLE_IN_ALL -GHashTable* g_hash_table_iter_get_hash_table (GHashTableIter *iter); -GLIB_AVAILABLE_IN_ALL -void g_hash_table_iter_remove (GHashTableIter *iter); -GLIB_AVAILABLE_IN_2_30 -void g_hash_table_iter_replace (GHashTableIter *iter, - gpointer value); -GLIB_AVAILABLE_IN_ALL -void g_hash_table_iter_steal (GHashTableIter *iter); - -GLIB_AVAILABLE_IN_ALL -GHashTable* g_hash_table_ref (GHashTable *hash_table); -GLIB_AVAILABLE_IN_ALL -void g_hash_table_unref (GHashTable *hash_table); - -#define g_hash_table_freeze(hash_table) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 -#define g_hash_table_thaw(hash_table) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 - -/* Hash Functions - */ -GLIB_AVAILABLE_IN_ALL -gboolean g_str_equal (gconstpointer v1, - gconstpointer v2); -GLIB_AVAILABLE_IN_ALL -guint g_str_hash (gconstpointer v); - -GLIB_AVAILABLE_IN_ALL -gboolean g_int_equal (gconstpointer v1, - gconstpointer v2); -GLIB_AVAILABLE_IN_ALL -guint g_int_hash (gconstpointer v); - -GLIB_AVAILABLE_IN_ALL -gboolean g_int64_equal (gconstpointer v1, - gconstpointer v2); -GLIB_AVAILABLE_IN_ALL -guint g_int64_hash (gconstpointer v); - -GLIB_AVAILABLE_IN_ALL -gboolean g_double_equal (gconstpointer v1, - gconstpointer v2); -GLIB_AVAILABLE_IN_ALL -guint g_double_hash (gconstpointer v); - -GLIB_AVAILABLE_IN_ALL -guint g_direct_hash (gconstpointer v) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_direct_equal (gconstpointer v1, - gconstpointer v2) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __G_HASH_H__ */ -/* ghmac.h - secure data hashing - * - * Copyright (C) 2011 Stef Walter - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_HMAC_H__ -#define __G_HMAC_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * GHmac: - * - * An opaque structure representing a HMAC operation. - * To create a new GHmac, use g_hmac_new(). To free - * a GHmac, use g_hmac_unref(). - * - * Since: 2.30 - */ -typedef struct _GHmac GHmac; - -GLIB_AVAILABLE_IN_2_30 -GHmac * g_hmac_new (GChecksumType digest_type, - const guchar *key, - gsize key_len); -GLIB_AVAILABLE_IN_2_30 -GHmac * g_hmac_copy (const GHmac *hmac); -GLIB_AVAILABLE_IN_2_30 -GHmac * g_hmac_ref (GHmac *hmac); -GLIB_AVAILABLE_IN_2_30 -void g_hmac_unref (GHmac *hmac); -GLIB_AVAILABLE_IN_2_30 -void g_hmac_update (GHmac *hmac, - const guchar *data, - gssize length); -GLIB_AVAILABLE_IN_2_30 -const gchar * g_hmac_get_string (GHmac *hmac); -GLIB_AVAILABLE_IN_2_30 -void g_hmac_get_digest (GHmac *hmac, - guint8 *buffer, - gsize *digest_len); - -GLIB_AVAILABLE_IN_2_30 -gchar *g_compute_hmac_for_data (GChecksumType digest_type, - const guchar *key, - gsize key_len, - const guchar *data, - gsize length); -GLIB_AVAILABLE_IN_2_30 -gchar *g_compute_hmac_for_string (GChecksumType digest_type, - const guchar *key, - gsize key_len, - const gchar *str, - gssize length); -GLIB_AVAILABLE_IN_2_50 -gchar *g_compute_hmac_for_bytes (GChecksumType digest_type, - GBytes *key, - GBytes *data); - - -G_END_DECLS - -#endif /* __G_CHECKSUM_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_HOOK_H__ -#define __G_HOOK_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - - -/* --- typedefs --- */ -typedef struct _GHook GHook; -typedef struct _GHookList GHookList; - -typedef gint (*GHookCompareFunc) (GHook *new_hook, - GHook *sibling); -typedef gboolean (*GHookFindFunc) (GHook *hook, - gpointer data); -typedef void (*GHookMarshaller) (GHook *hook, - gpointer marshal_data); -typedef gboolean (*GHookCheckMarshaller) (GHook *hook, - gpointer marshal_data); -typedef void (*GHookFunc) (gpointer data); -typedef gboolean (*GHookCheckFunc) (gpointer data); -typedef void (*GHookFinalizeFunc) (GHookList *hook_list, - GHook *hook); -typedef enum -{ - G_HOOK_FLAG_ACTIVE = 1 << 0, - G_HOOK_FLAG_IN_CALL = 1 << 1, - G_HOOK_FLAG_MASK = 0x0f -} GHookFlagMask; -#define G_HOOK_FLAG_USER_SHIFT (4) - - -/* --- structures --- */ -struct _GHookList -{ - gulong seq_id; - guint hook_size : 16; - guint is_setup : 1; - GHook *hooks; - gpointer dummy3; - GHookFinalizeFunc finalize_hook; - gpointer dummy[2]; -}; -struct _GHook -{ - gpointer data; - GHook *next; - GHook *prev; - guint ref_count; - gulong hook_id; - guint flags; - gpointer func; - GDestroyNotify destroy; -}; - - -/* --- macros --- */ -#define G_HOOK(hook) ((GHook*) (hook)) -#define G_HOOK_FLAGS(hook) (G_HOOK (hook)->flags) -#define G_HOOK_ACTIVE(hook) ((G_HOOK_FLAGS (hook) & \ - G_HOOK_FLAG_ACTIVE) != 0) -#define G_HOOK_IN_CALL(hook) ((G_HOOK_FLAGS (hook) & \ - G_HOOK_FLAG_IN_CALL) != 0) -#define G_HOOK_IS_VALID(hook) (G_HOOK (hook)->hook_id != 0 && \ - (G_HOOK_FLAGS (hook) & \ - G_HOOK_FLAG_ACTIVE)) -#define G_HOOK_IS_UNLINKED(hook) (G_HOOK (hook)->next == NULL && \ - G_HOOK (hook)->prev == NULL && \ - G_HOOK (hook)->hook_id == 0 && \ - G_HOOK (hook)->ref_count == 0) - - -/* --- prototypes --- */ -/* callback maintenance functions */ -GLIB_AVAILABLE_IN_ALL -void g_hook_list_init (GHookList *hook_list, - guint hook_size); -GLIB_AVAILABLE_IN_ALL -void g_hook_list_clear (GHookList *hook_list); -GLIB_AVAILABLE_IN_ALL -GHook* g_hook_alloc (GHookList *hook_list); -GLIB_AVAILABLE_IN_ALL -void g_hook_free (GHookList *hook_list, - GHook *hook); -GLIB_AVAILABLE_IN_ALL -GHook * g_hook_ref (GHookList *hook_list, - GHook *hook); -GLIB_AVAILABLE_IN_ALL -void g_hook_unref (GHookList *hook_list, - GHook *hook); -GLIB_AVAILABLE_IN_ALL -gboolean g_hook_destroy (GHookList *hook_list, - gulong hook_id); -GLIB_AVAILABLE_IN_ALL -void g_hook_destroy_link (GHookList *hook_list, - GHook *hook); -GLIB_AVAILABLE_IN_ALL -void g_hook_prepend (GHookList *hook_list, - GHook *hook); -GLIB_AVAILABLE_IN_ALL -void g_hook_insert_before (GHookList *hook_list, - GHook *sibling, - GHook *hook); -GLIB_AVAILABLE_IN_ALL -void g_hook_insert_sorted (GHookList *hook_list, - GHook *hook, - GHookCompareFunc func); -GLIB_AVAILABLE_IN_ALL -GHook* g_hook_get (GHookList *hook_list, - gulong hook_id); -GLIB_AVAILABLE_IN_ALL -GHook* g_hook_find (GHookList *hook_list, - gboolean need_valids, - GHookFindFunc func, - gpointer data); -GLIB_AVAILABLE_IN_ALL -GHook* g_hook_find_data (GHookList *hook_list, - gboolean need_valids, - gpointer data); -GLIB_AVAILABLE_IN_ALL -GHook* g_hook_find_func (GHookList *hook_list, - gboolean need_valids, - gpointer func); -GLIB_AVAILABLE_IN_ALL -GHook* g_hook_find_func_data (GHookList *hook_list, - gboolean need_valids, - gpointer func, - gpointer data); -/* return the first valid hook, and increment its reference count */ -GLIB_AVAILABLE_IN_ALL -GHook* g_hook_first_valid (GHookList *hook_list, - gboolean may_be_in_call); -/* return the next valid hook with incremented reference count, and - * decrement the reference count of the original hook - */ -GLIB_AVAILABLE_IN_ALL -GHook* g_hook_next_valid (GHookList *hook_list, - GHook *hook, - gboolean may_be_in_call); -/* GHookCompareFunc implementation to insert hooks sorted by their id */ -GLIB_AVAILABLE_IN_ALL -gint g_hook_compare_ids (GHook *new_hook, - GHook *sibling); -/* convenience macros */ -#define g_hook_append( hook_list, hook ) \ - g_hook_insert_before ((hook_list), NULL, (hook)) -/* invoke all valid hooks with the (*GHookFunc) signature. - */ -GLIB_AVAILABLE_IN_ALL -void g_hook_list_invoke (GHookList *hook_list, - gboolean may_recurse); -/* invoke all valid hooks with the (*GHookCheckFunc) signature, - * and destroy the hook if FALSE is returned. - */ -GLIB_AVAILABLE_IN_ALL -void g_hook_list_invoke_check (GHookList *hook_list, - gboolean may_recurse); -/* invoke a marshaller on all valid hooks. - */ -GLIB_AVAILABLE_IN_ALL -void g_hook_list_marshal (GHookList *hook_list, - gboolean may_recurse, - GHookMarshaller marshaller, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_hook_list_marshal_check (GHookList *hook_list, - gboolean may_recurse, - GHookCheckMarshaller marshaller, - gpointer marshal_data); - -G_END_DECLS - -#endif /* __G_HOOK_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 2008 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ - -#ifndef __G_HOST_UTILS_H__ -#define __G_HOST_UTILS_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -gboolean g_hostname_is_non_ascii (const gchar *hostname); -GLIB_AVAILABLE_IN_ALL -gboolean g_hostname_is_ascii_encoded (const gchar *hostname); -GLIB_AVAILABLE_IN_ALL -gboolean g_hostname_is_ip_address (const gchar *hostname); - -GLIB_AVAILABLE_IN_ALL -gchar *g_hostname_to_ascii (const gchar *hostname); -GLIB_AVAILABLE_IN_ALL -gchar *g_hostname_to_unicode (const gchar *hostname); - -G_END_DECLS - -#endif /* __G_HOST_UTILS_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_IOCHANNEL_H__ -#define __G_IOCHANNEL_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* gmain.h - the GLib Main loop - * Copyright (C) 1998-2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_MAIN_H__ -#define __G_MAIN_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* gpoll.h - poll(2) support - * Copyright (C) 2008 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_POLL_H__ -#define __G_POLL_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (__G_MAIN_H__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* Any definitions using GPollFD or GPollFunc are primarily - * for Unix and not guaranteed to be the compatible on all - * operating systems on which GLib runs. Right now, the - * GLib does use these functions on Win32 as well, but interprets - * them in a fairly different way than on Unix. If you use - * these definitions, you are should be prepared to recode - * for different operating systems. - * - * Note that on systems with a working poll(2), that function is used - * in place of g_poll(). Thus g_poll() must have the same signature as - * poll(), meaning GPollFD must have the same layout as struct pollfd. - * - * On Win32, the fd in a GPollFD should be Win32 HANDLE (*not* a file - * descriptor as provided by the C runtime) that can be used by - * MsgWaitForMultipleObjects. This does *not* include file handles - * from CreateFile, SOCKETs, nor pipe handles. (But you can use - * WSAEventSelect to signal events when a SOCKET is readable). - * - * On Win32, fd can also be the special value G_WIN32_MSG_HANDLE to - * indicate polling for messages. - * - * But note that G_WIN32_MSG_HANDLE GPollFDs should not be used by GDK - * (GTK) programs, as GDK itself wants to read messages and convert them - * to GDK events. - * - * So, unless you really know what you are doing, it's best not to try - * to use the main loop polling stuff for your own needs on - * Windows. - */ -typedef struct _GPollFD GPollFD; - -/** - * GPollFunc: - * @ufds: an array of #GPollFD elements - * @nfsd: the number of elements in @ufds - * @timeout_: the maximum time to wait for an event of the file descriptors. - * A negative value indicates an infinite timeout. - * - * Specifies the type of function passed to g_main_context_set_poll_func(). - * The semantics of the function should match those of the poll() system call. - * - * Returns: the number of #GPollFD elements which have events or errors - * reported, or -1 if an error occurred. - */ -typedef gint (*GPollFunc) (GPollFD *ufds, - guint nfsd, - gint timeout_); - -/** - * GPollFD: - * @fd: the file descriptor to poll (or a HANDLE on Win32) - * @events: a bitwise combination from #GIOCondition, specifying which - * events should be polled for. Typically for reading from a file - * descriptor you would use %G_IO_IN | %G_IO_HUP | %G_IO_ERR, and - * for writing you would use %G_IO_OUT | %G_IO_ERR. - * @revents: a bitwise combination of flags from #GIOCondition, returned - * from the poll() function to indicate which events occurred. - * - * Represents a file descriptor, which events to poll for, and which events - * occurred. - */ -struct _GPollFD -{ -#if defined (G_OS_WIN32) && GLIB_SIZEOF_VOID_P == 8 -#ifndef __GTK_DOC_IGNORE__ - gint64 fd; -#endif -#else - gint fd; -#endif - gushort events; - gushort revents; -}; - -/** - * G_POLLFD_FORMAT: - * - * A format specifier that can be used in printf()-style format strings - * when printing the @fd member of a #GPollFD. - */ -/* defined in glibconfig.h */ - -GLIB_AVAILABLE_IN_ALL -gint -g_poll (GPollFD *fds, - guint nfds, - gint timeout); - -G_END_DECLS - -#endif /* __G_POLL_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_SLIST_H__ -#define __G_SLIST_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GSList GSList; - -struct _GSList -{ - gpointer data; - GSList *next; -}; - -/* Singly linked lists - */ -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_alloc (void) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -void g_slist_free (GSList *list); -GLIB_AVAILABLE_IN_ALL -void g_slist_free_1 (GSList *list); -#define g_slist_free1 g_slist_free_1 -GLIB_AVAILABLE_IN_ALL -void g_slist_free_full (GSList *list, - GDestroyNotify free_func); -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_append (GSList *list, - gpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_prepend (GSList *list, - gpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_insert (GSList *list, - gpointer data, - gint position) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_insert_sorted (GSList *list, - gpointer data, - GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_insert_sorted_with_data (GSList *list, - gpointer data, - GCompareDataFunc func, - gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_insert_before (GSList *slist, - GSList *sibling, - gpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_concat (GSList *list1, - GSList *list2) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_remove (GSList *list, - gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_remove_all (GSList *list, - gconstpointer data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_remove_link (GSList *list, - GSList *link_) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_delete_link (GSList *list, - GSList *link_) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_reverse (GSList *list) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_copy (GSList *list) G_GNUC_WARN_UNUSED_RESULT; - -GLIB_AVAILABLE_IN_2_34 -GSList* g_slist_copy_deep (GSList *list, - GCopyFunc func, - gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_nth (GSList *list, - guint n); -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_find (GSList *list, - gconstpointer data); -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_find_custom (GSList *list, - gconstpointer data, - GCompareFunc func); -GLIB_AVAILABLE_IN_ALL -gint g_slist_position (GSList *list, - GSList *llink); -GLIB_AVAILABLE_IN_ALL -gint g_slist_index (GSList *list, - gconstpointer data); -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_last (GSList *list); -GLIB_AVAILABLE_IN_ALL -guint g_slist_length (GSList *list); -GLIB_AVAILABLE_IN_ALL -void g_slist_foreach (GSList *list, - GFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_sort (GSList *list, - GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -GSList* g_slist_sort_with_data (GSList *list, - GCompareDataFunc compare_func, - gpointer user_data) G_GNUC_WARN_UNUSED_RESULT; -GLIB_AVAILABLE_IN_ALL -gpointer g_slist_nth_data (GSList *list, - guint n); - -GLIB_AVAILABLE_IN_2_64 -void g_clear_slist (GSList **slist_ptr, - GDestroyNotify destroy); - -#undef g_clear_slist -#define g_clear_slist(slist_ptr, destroy) \ - G_STMT_START { \ - GSList *_slist; \ - \ - _slist = *(slist_ptr); \ - if (_slist) \ - { \ - *slist_ptr = NULL; \ - \ - if ((destroy) != NULL) \ - g_slist_free_full (_slist, (destroy)); \ - else \ - g_slist_free (_slist); \ - } \ - } G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_64 - -#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL) - -G_END_DECLS - -#endif /* __G_SLIST_H__ */ - -G_BEGIN_DECLS - -typedef enum /*< flags >*/ -{ - G_IO_IN GLIB_SYSDEF_POLLIN, - G_IO_OUT GLIB_SYSDEF_POLLOUT, - G_IO_PRI GLIB_SYSDEF_POLLPRI, - G_IO_ERR GLIB_SYSDEF_POLLERR, - G_IO_HUP GLIB_SYSDEF_POLLHUP, - G_IO_NVAL GLIB_SYSDEF_POLLNVAL -} GIOCondition; - - -/** - * GMainContext: - * - * The `GMainContext` struct is an opaque data - * type representing a set of sources to be handled in a main loop. - */ -typedef struct _GMainContext GMainContext; - -/** - * GMainLoop: - * - * The `GMainLoop` struct is an opaque data type - * representing the main event loop of a GLib or GTK+ application. - */ -typedef struct _GMainLoop GMainLoop; - -/** - * GSource: - * - * The `GSource` struct is an opaque data type - * representing an event source. - */ -typedef struct _GSource GSource; -typedef struct _GSourcePrivate GSourcePrivate; - -/** - * GSourceCallbackFuncs: - * @ref: Called when a reference is added to the callback object - * @unref: Called when a reference to the callback object is dropped - * @get: Called to extract the callback function and data from the - * callback object. - * - * The `GSourceCallbackFuncs` struct contains - * functions for managing callback objects. - */ -typedef struct _GSourceCallbackFuncs GSourceCallbackFuncs; - -/** - * GSourceFuncs: - * @prepare: Called before all the file descriptors are polled. If the - * source can determine that it is ready here (without waiting for the - * results of the poll() call) it should return %TRUE. It can also return - * a @timeout_ value which should be the maximum timeout (in milliseconds) - * which should be passed to the poll() call. The actual timeout used will - * be -1 if all sources returned -1, or it will be the minimum of all - * the @timeout_ values returned which were >= 0. Since 2.36 this may - * be %NULL, in which case the effect is as if the function always returns - * %FALSE with a timeout of -1. If @prepare returns a - * timeout and the source also has a ready time set, then the - * lower of the two will be used. - * @check: Called after all the file descriptors are polled. The source - * should return %TRUE if it is ready to be dispatched. Note that some - * time may have passed since the previous prepare function was called, - * so the source should be checked again here. Since 2.36 this may - * be %NULL, in which case the effect is as if the function always returns - * %FALSE. - * @dispatch: Called to dispatch the event source, after it has returned - * %TRUE in either its @prepare or its @check function, or if a ready time - * has been reached. The @dispatch function receives a callback function and - * user data. The callback function may be %NULL if the source was never - * connected to a callback using g_source_set_callback(). The @dispatch - * function should call the callback function with @user_data and whatever - * additional parameters are needed for this type of event source. The - * return value of the @dispatch function should be #G_SOURCE_REMOVE if the - * source should be removed or #G_SOURCE_CONTINUE to keep it. - * @finalize: Called when the source is finalized. At this point, the source - * will have been destroyed, had its callback cleared, and have been removed - * from its #GMainContext, but it will still have its final reference count, - * so methods can be called on it from within this function. - * - * The `GSourceFuncs` struct contains a table of - * functions used to handle event sources in a generic manner. - * - * For idle sources, the prepare and check functions always return %TRUE - * to indicate that the source is always ready to be processed. The prepare - * function also returns a timeout value of 0 to ensure that the poll() call - * doesn't block (since that would be time wasted which could have been spent - * running the idle function). - * - * For timeout sources, the prepare and check functions both return %TRUE - * if the timeout interval has expired. The prepare function also returns - * a timeout value to ensure that the poll() call doesn't block too long - * and miss the next timeout. - * - * For file descriptor sources, the prepare function typically returns %FALSE, - * since it must wait until poll() has been called before it knows whether - * any events need to be processed. It sets the returned timeout to -1 to - * indicate that it doesn't mind how long the poll() call blocks. In the - * check function, it tests the results of the poll() call to see if the - * required condition has been met, and returns %TRUE if so. - */ -typedef struct _GSourceFuncs GSourceFuncs; - -/** - * GPid: - * - * A type which is used to hold a process identification. - * - * On UNIX, processes are identified by a process id (an integer), - * while Windows uses process handles (which are pointers). - * - * GPid is used in GLib only for descendant processes spawned with - * the g_spawn functions. - */ -/* defined in glibconfig.h */ - -/** - * G_PID_FORMAT: - * - * A format specifier that can be used in printf()-style format strings - * when printing a #GPid. - * - * Since: 2.50 - */ -/* defined in glibconfig.h */ - -/** - * GSourceFunc: - * @user_data: data passed to the function, set when the source was - * created with one of the above functions - * - * Specifies the type of function passed to g_timeout_add(), - * g_timeout_add_full(), g_idle_add(), and g_idle_add_full(). - * - * When calling g_source_set_callback(), you may need to cast a function of a - * different type to this type. Use G_SOURCE_FUNC() to avoid warnings about - * incompatible function types. - * - * Returns: %FALSE if the source should be removed. #G_SOURCE_CONTINUE and - * #G_SOURCE_REMOVE are more memorable names for the return value. - */ -typedef gboolean (*GSourceFunc) (gpointer user_data); - -/** - * G_SOURCE_FUNC: - * @f: a function pointer. - * - * Cast a function pointer to a #GSourceFunc, suppressing warnings from GCC 8 - * onwards with `-Wextra` or `-Wcast-function-type` enabled about the function - * types being incompatible. - * - * For example, the correct type of callback for a source created by - * g_child_watch_source_new() is #GChildWatchFunc, which accepts more arguments - * than #GSourceFunc. Casting the function with `(GSourceFunc)` to call - * g_source_set_callback() will trigger a warning, even though it will be cast - * back to the correct type before it is called by the source. - * - * Since: 2.58 - */ -#define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f)) GLIB_AVAILABLE_MACRO_IN_2_58 - -/** - * GChildWatchFunc: - * @pid: the process id of the child process - * @status: Status information about the child process, encoded - * in a platform-specific manner - * @user_data: user data passed to g_child_watch_add() - * - * Prototype of a #GChildWatchSource callback, called when a child - * process has exited. To interpret @status, see the documentation - * for g_spawn_check_exit_status(). - */ -typedef void (*GChildWatchFunc) (GPid pid, - gint status, - gpointer user_data); - - -/** - * GSourceDisposeFunc: - * @source: #GSource that is currently being disposed - * - * Dispose function for @source. See g_source_set_dispose_function() for - * details. - * - * Since: 2.64 - */ -GLIB_AVAILABLE_TYPE_IN_2_64 -typedef void (*GSourceDisposeFunc) (GSource *source); - -struct _GSource -{ - /*< private >*/ - gpointer callback_data; - GSourceCallbackFuncs *callback_funcs; - - const GSourceFuncs *source_funcs; - guint ref_count; - - GMainContext *context; - - gint priority; - guint flags; - guint source_id; - - GSList *poll_fds; - - GSource *prev; - GSource *next; - - char *name; - - GSourcePrivate *priv; -}; - -struct _GSourceCallbackFuncs -{ - void (*ref) (gpointer cb_data); - void (*unref) (gpointer cb_data); - void (*get) (gpointer cb_data, - GSource *source, - GSourceFunc *func, - gpointer *data); -}; - -/** - * GSourceDummyMarshal: - * - * This is just a placeholder for #GClosureMarshal, - * which cannot be used here for dependency reasons. - */ -typedef void (*GSourceDummyMarshal) (void); - -struct _GSourceFuncs -{ - gboolean (*prepare) (GSource *source, - gint *timeout_); - gboolean (*check) (GSource *source); - gboolean (*dispatch) (GSource *source, - GSourceFunc callback, - gpointer user_data); - void (*finalize) (GSource *source); /* Can be NULL */ - - /*< private >*/ - /* For use by g_source_set_closure */ - GSourceFunc closure_callback; - GSourceDummyMarshal closure_marshal; /* Really is of type GClosureMarshal */ -}; - -/* Standard priorities */ - -/** - * G_PRIORITY_HIGH: - * - * Use this for high priority event sources. - * - * It is not used within GLib or GTK+. - */ -#define G_PRIORITY_HIGH -100 - -/** - * G_PRIORITY_DEFAULT: - * - * Use this for default priority event sources. - * - * In GLib this priority is used when adding timeout functions - * with g_timeout_add(). In GDK this priority is used for events - * from the X server. - */ -#define G_PRIORITY_DEFAULT 0 - -/** - * G_PRIORITY_HIGH_IDLE: - * - * Use this for high priority idle functions. - * - * GTK+ uses #G_PRIORITY_HIGH_IDLE + 10 for resizing operations, - * and #G_PRIORITY_HIGH_IDLE + 20 for redrawing operations. (This is - * done to ensure that any pending resizes are processed before any - * pending redraws, so that widgets are not redrawn twice unnecessarily.) - */ -#define G_PRIORITY_HIGH_IDLE 100 - -/** - * G_PRIORITY_DEFAULT_IDLE: - * - * Use this for default priority idle functions. - * - * In GLib this priority is used when adding idle functions with - * g_idle_add(). - */ -#define G_PRIORITY_DEFAULT_IDLE 200 - -/** - * G_PRIORITY_LOW: - * - * Use this for very low priority background tasks. - * - * It is not used within GLib or GTK+. - */ -#define G_PRIORITY_LOW 300 - -/** - * G_SOURCE_REMOVE: - * - * Use this macro as the return value of a #GSourceFunc to remove - * the #GSource from the main loop. - * - * Since: 2.32 - */ -#define G_SOURCE_REMOVE FALSE - -/** - * G_SOURCE_CONTINUE: - * - * Use this macro as the return value of a #GSourceFunc to leave - * the #GSource in the main loop. - * - * Since: 2.32 - */ -#define G_SOURCE_CONTINUE TRUE - -/* GMainContext: */ - -GLIB_AVAILABLE_IN_ALL -GMainContext *g_main_context_new (void); -GLIB_AVAILABLE_IN_ALL -GMainContext *g_main_context_ref (GMainContext *context); -GLIB_AVAILABLE_IN_ALL -void g_main_context_unref (GMainContext *context); -GLIB_AVAILABLE_IN_ALL -GMainContext *g_main_context_default (void); - -GLIB_AVAILABLE_IN_ALL -gboolean g_main_context_iteration (GMainContext *context, - gboolean may_block); -GLIB_AVAILABLE_IN_ALL -gboolean g_main_context_pending (GMainContext *context); - -/* For implementation of legacy interfaces - */ -GLIB_AVAILABLE_IN_ALL -GSource *g_main_context_find_source_by_id (GMainContext *context, - guint source_id); -GLIB_AVAILABLE_IN_ALL -GSource *g_main_context_find_source_by_user_data (GMainContext *context, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -GSource *g_main_context_find_source_by_funcs_user_data (GMainContext *context, - GSourceFuncs *funcs, - gpointer user_data); - -/* Low level functions for implementing custom main loops. - */ -GLIB_AVAILABLE_IN_ALL -void g_main_context_wakeup (GMainContext *context); -GLIB_AVAILABLE_IN_ALL -gboolean g_main_context_acquire (GMainContext *context); -GLIB_AVAILABLE_IN_ALL -void g_main_context_release (GMainContext *context); -GLIB_AVAILABLE_IN_ALL -gboolean g_main_context_is_owner (GMainContext *context); -GLIB_DEPRECATED_IN_2_58_FOR(g_main_context_is_owner) -gboolean g_main_context_wait (GMainContext *context, - GCond *cond, - GMutex *mutex); - -GLIB_AVAILABLE_IN_ALL -gboolean g_main_context_prepare (GMainContext *context, - gint *priority); -GLIB_AVAILABLE_IN_ALL -gint g_main_context_query (GMainContext *context, - gint max_priority, - gint *timeout_, - GPollFD *fds, - gint n_fds); -GLIB_AVAILABLE_IN_ALL -gboolean g_main_context_check (GMainContext *context, - gint max_priority, - GPollFD *fds, - gint n_fds); -GLIB_AVAILABLE_IN_ALL -void g_main_context_dispatch (GMainContext *context); - -GLIB_AVAILABLE_IN_ALL -void g_main_context_set_poll_func (GMainContext *context, - GPollFunc func); -GLIB_AVAILABLE_IN_ALL -GPollFunc g_main_context_get_poll_func (GMainContext *context); - -/* Low level functions for use by source implementations - */ -GLIB_AVAILABLE_IN_ALL -void g_main_context_add_poll (GMainContext *context, - GPollFD *fd, - gint priority); -GLIB_AVAILABLE_IN_ALL -void g_main_context_remove_poll (GMainContext *context, - GPollFD *fd); - -GLIB_AVAILABLE_IN_ALL -gint g_main_depth (void); -GLIB_AVAILABLE_IN_ALL -GSource *g_main_current_source (void); - -/* GMainContexts for other threads - */ -GLIB_AVAILABLE_IN_ALL -void g_main_context_push_thread_default (GMainContext *context); -GLIB_AVAILABLE_IN_ALL -void g_main_context_pop_thread_default (GMainContext *context); -GLIB_AVAILABLE_IN_ALL -GMainContext *g_main_context_get_thread_default (void); -GLIB_AVAILABLE_IN_ALL -GMainContext *g_main_context_ref_thread_default (void); - -/** - * GMainContextPusher: - * - * Opaque type. See g_main_context_pusher_new() for details. - * - * Since: 2.64 - */ -typedef void GMainContextPusher GLIB_AVAILABLE_TYPE_IN_2_64; - -/** - * g_main_context_pusher_new: - * @main_context: (transfer none): a main context to push - * - * Push @main_context as the new thread-default main context for the current - * thread, using g_main_context_push_thread_default(), and return a new - * #GMainContextPusher. Pop with g_main_context_pusher_free(). Using - * g_main_context_pop_thread_default() on @main_context while a - * #GMainContextPusher exists for it can lead to undefined behaviour. - * - * Using two #GMainContextPushers in the same scope is not allowed, as it leads - * to an undefined pop order. - * - * This is intended to be used with g_autoptr(). Note that g_autoptr() - * is only available when using GCC or clang, so the following example - * will only work with those compilers: - * |[ - * typedef struct - * { - * ... - * GMainContext *context; - * ... - * } MyObject; - * - * static void - * my_object_do_stuff (MyObject *self) - * { - * g_autoptr(GMainContextPusher) pusher = g_main_context_pusher_new (self->context); - * - * // Code with main context as the thread default here - * - * if (cond) - * // No need to pop - * return; - * - * // Optionally early pop - * g_clear_pointer (&pusher, g_main_context_pusher_free); - * - * // Code with main context no longer the thread default here - * } - * ]| - * - * Returns: (transfer full): a #GMainContextPusher - * Since: 2.64 - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 -static inline GMainContextPusher * -g_main_context_pusher_new (GMainContext *main_context) -{ - g_main_context_push_thread_default (main_context); - return (GMainContextPusher *) main_context; -} -G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * g_main_context_pusher_free: - * @pusher: (transfer full): a #GMainContextPusher - * - * Pop @pusher’s main context as the thread default main context. - * See g_main_context_pusher_new() for details. - * - * This will pop the #GMainContext as the current thread-default main context, - * but will not call g_main_context_unref() on it. - * - * Since: 2.64 - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_STATIC_INLINE_IN_2_64 -static inline void -g_main_context_pusher_free (GMainContextPusher *pusher) -{ - g_main_context_pop_thread_default ((GMainContext *) pusher); -} -G_GNUC_END_IGNORE_DEPRECATIONS - -/* GMainLoop: */ - -GLIB_AVAILABLE_IN_ALL -GMainLoop *g_main_loop_new (GMainContext *context, - gboolean is_running); -GLIB_AVAILABLE_IN_ALL -void g_main_loop_run (GMainLoop *loop); -GLIB_AVAILABLE_IN_ALL -void g_main_loop_quit (GMainLoop *loop); -GLIB_AVAILABLE_IN_ALL -GMainLoop *g_main_loop_ref (GMainLoop *loop); -GLIB_AVAILABLE_IN_ALL -void g_main_loop_unref (GMainLoop *loop); -GLIB_AVAILABLE_IN_ALL -gboolean g_main_loop_is_running (GMainLoop *loop); -GLIB_AVAILABLE_IN_ALL -GMainContext *g_main_loop_get_context (GMainLoop *loop); - -/* GSource: */ - -GLIB_AVAILABLE_IN_ALL -GSource *g_source_new (GSourceFuncs *source_funcs, - guint struct_size); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_AVAILABLE_IN_2_64 -void g_source_set_dispose_function (GSource *source, - GSourceDisposeFunc dispose); -G_GNUC_END_IGNORE_DEPRECATIONS - -GLIB_AVAILABLE_IN_ALL -GSource *g_source_ref (GSource *source); -GLIB_AVAILABLE_IN_ALL -void g_source_unref (GSource *source); - -GLIB_AVAILABLE_IN_ALL -guint g_source_attach (GSource *source, - GMainContext *context); -GLIB_AVAILABLE_IN_ALL -void g_source_destroy (GSource *source); - -GLIB_AVAILABLE_IN_ALL -void g_source_set_priority (GSource *source, - gint priority); -GLIB_AVAILABLE_IN_ALL -gint g_source_get_priority (GSource *source); -GLIB_AVAILABLE_IN_ALL -void g_source_set_can_recurse (GSource *source, - gboolean can_recurse); -GLIB_AVAILABLE_IN_ALL -gboolean g_source_get_can_recurse (GSource *source); -GLIB_AVAILABLE_IN_ALL -guint g_source_get_id (GSource *source); - -GLIB_AVAILABLE_IN_ALL -GMainContext *g_source_get_context (GSource *source); - -GLIB_AVAILABLE_IN_ALL -void g_source_set_callback (GSource *source, - GSourceFunc func, - gpointer data, - GDestroyNotify notify); - -GLIB_AVAILABLE_IN_ALL -void g_source_set_funcs (GSource *source, - GSourceFuncs *funcs); -GLIB_AVAILABLE_IN_ALL -gboolean g_source_is_destroyed (GSource *source); - -GLIB_AVAILABLE_IN_ALL -void g_source_set_name (GSource *source, - const char *name); -GLIB_AVAILABLE_IN_ALL -const char * g_source_get_name (GSource *source); -GLIB_AVAILABLE_IN_ALL -void g_source_set_name_by_id (guint tag, - const char *name); - -GLIB_AVAILABLE_IN_2_36 -void g_source_set_ready_time (GSource *source, - gint64 ready_time); -GLIB_AVAILABLE_IN_2_36 -gint64 g_source_get_ready_time (GSource *source); - -#ifdef G_OS_UNIX -GLIB_AVAILABLE_IN_2_36 -gpointer g_source_add_unix_fd (GSource *source, - gint fd, - GIOCondition events); -GLIB_AVAILABLE_IN_2_36 -void g_source_modify_unix_fd (GSource *source, - gpointer tag, - GIOCondition new_events); -GLIB_AVAILABLE_IN_2_36 -void g_source_remove_unix_fd (GSource *source, - gpointer tag); -GLIB_AVAILABLE_IN_2_36 -GIOCondition g_source_query_unix_fd (GSource *source, - gpointer tag); -#endif - -/* Used to implement g_source_connect_closure and internally*/ -GLIB_AVAILABLE_IN_ALL -void g_source_set_callback_indirect (GSource *source, - gpointer callback_data, - GSourceCallbackFuncs *callback_funcs); - -GLIB_AVAILABLE_IN_ALL -void g_source_add_poll (GSource *source, - GPollFD *fd); -GLIB_AVAILABLE_IN_ALL -void g_source_remove_poll (GSource *source, - GPollFD *fd); - -GLIB_AVAILABLE_IN_ALL -void g_source_add_child_source (GSource *source, - GSource *child_source); -GLIB_AVAILABLE_IN_ALL -void g_source_remove_child_source (GSource *source, - GSource *child_source); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED_IN_2_28_FOR(g_source_get_time) -void g_source_get_current_time (GSource *source, - GTimeVal *timeval); -G_GNUC_END_IGNORE_DEPRECATIONS - -GLIB_AVAILABLE_IN_ALL -gint64 g_source_get_time (GSource *source); - - /* void g_source_connect_closure (GSource *source, - GClosure *closure); - */ - -/* Specific source types - */ -GLIB_AVAILABLE_IN_ALL -GSource *g_idle_source_new (void); -GLIB_AVAILABLE_IN_ALL -GSource *g_child_watch_source_new (GPid pid); -GLIB_AVAILABLE_IN_ALL -GSource *g_timeout_source_new (guint interval); -GLIB_AVAILABLE_IN_ALL -GSource *g_timeout_source_new_seconds (guint interval); - -/* Miscellaneous functions - */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED_IN_2_62_FOR(g_get_real_time) -void g_get_current_time (GTimeVal *result); -G_GNUC_END_IGNORE_DEPRECATIONS - -GLIB_AVAILABLE_IN_ALL -gint64 g_get_monotonic_time (void); -GLIB_AVAILABLE_IN_ALL -gint64 g_get_real_time (void); - - -/* Source manipulation by ID */ -GLIB_AVAILABLE_IN_ALL -gboolean g_source_remove (guint tag); -GLIB_AVAILABLE_IN_ALL -gboolean g_source_remove_by_user_data (gpointer user_data); -GLIB_AVAILABLE_IN_ALL -gboolean g_source_remove_by_funcs_user_data (GSourceFuncs *funcs, - gpointer user_data); - -/** - * GClearHandleFunc: - * @handle_id: the handle ID to clear - * - * Specifies the type of function passed to g_clear_handle_id(). - * The implementation is expected to free the resource identified - * by @handle_id; for instance, if @handle_id is a #GSource ID, - * g_source_remove() can be used. - * - * Since: 2.56 - */ -typedef void (* GClearHandleFunc) (guint handle_id); - -GLIB_AVAILABLE_IN_2_56 -void g_clear_handle_id (guint *tag_ptr, - GClearHandleFunc clear_func); - -#undef g_clear_handle_id -#define g_clear_handle_id(tag_ptr, clear_func) \ - G_STMT_START { \ - G_STATIC_ASSERT (sizeof *(tag_ptr) == sizeof (guint)); \ - guint *_tag_ptr = (guint *) (tag_ptr); \ - guint _handle_id; \ - \ - _handle_id = *_tag_ptr; \ - if (_handle_id > 0) \ - { \ - *_tag_ptr = 0; \ - clear_func (_handle_id); \ - } \ - } G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_56 - -/* Idles, child watchers and timeouts */ -GLIB_AVAILABLE_IN_ALL -guint g_timeout_add_full (gint priority, - guint interval, - GSourceFunc function, - gpointer data, - GDestroyNotify notify); -GLIB_AVAILABLE_IN_ALL -guint g_timeout_add (guint interval, - GSourceFunc function, - gpointer data); -GLIB_AVAILABLE_IN_ALL -guint g_timeout_add_seconds_full (gint priority, - guint interval, - GSourceFunc function, - gpointer data, - GDestroyNotify notify); -GLIB_AVAILABLE_IN_ALL -guint g_timeout_add_seconds (guint interval, - GSourceFunc function, - gpointer data); -GLIB_AVAILABLE_IN_ALL -guint g_child_watch_add_full (gint priority, - GPid pid, - GChildWatchFunc function, - gpointer data, - GDestroyNotify notify); -GLIB_AVAILABLE_IN_ALL -guint g_child_watch_add (GPid pid, - GChildWatchFunc function, - gpointer data); -GLIB_AVAILABLE_IN_ALL -guint g_idle_add (GSourceFunc function, - gpointer data); -GLIB_AVAILABLE_IN_ALL -guint g_idle_add_full (gint priority, - GSourceFunc function, - gpointer data, - GDestroyNotify notify); -GLIB_AVAILABLE_IN_ALL -gboolean g_idle_remove_by_data (gpointer data); - -GLIB_AVAILABLE_IN_ALL -void g_main_context_invoke_full (GMainContext *context, - gint priority, - GSourceFunc function, - gpointer data, - GDestroyNotify notify); -GLIB_AVAILABLE_IN_ALL -void g_main_context_invoke (GMainContext *context, - GSourceFunc function, - gpointer data); - -/* Hook for GClosure / GSource integration. Don't touch */ -GLIB_VAR GSourceFuncs g_timeout_funcs; -GLIB_VAR GSourceFuncs g_child_watch_funcs; -GLIB_VAR GSourceFuncs g_idle_funcs; -#ifdef G_OS_UNIX -GLIB_VAR GSourceFuncs g_unix_signal_funcs; -GLIB_VAR GSourceFuncs g_unix_fd_source_funcs; -#endif - -G_END_DECLS - -#endif /* __G_MAIN_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_STRING_H__ -#define __G_STRING_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* gunicode.h - Unicode manipulation functions - * - * Copyright (C) 1999, 2000 Tom Tromey - * Copyright 2000, 2005 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_UNICODE_H__ -#define __G_UNICODE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * gunichar: - * - * A type which can hold any UTF-32 or UCS-4 character code, - * also known as a Unicode code point. - * - * If you want to produce the UTF-8 representation of a #gunichar, - * use g_ucs4_to_utf8(). See also g_utf8_to_ucs4() for the reverse - * process. - * - * To print/scan values of this type as integer, use - * %G_GINT32_MODIFIER and/or %G_GUINT32_FORMAT. - * - * The notation to express a Unicode code point in running text is - * as a hexadecimal number with four to six digits and uppercase - * letters, prefixed by the string "U+". Leading zeros are omitted, - * unless the code point would have fewer than four hexadecimal digits. - * For example, "U+0041 LATIN CAPITAL LETTER A". To print a code point - * in the U+-notation, use the format string "U+\%04"G_GINT32_FORMAT"X". - * To scan, use the format string "U+\%06"G_GINT32_FORMAT"X". - * - * |[ - * gunichar c; - * sscanf ("U+0041", "U+%06"G_GINT32_FORMAT"X", &c) - * g_print ("Read U+%04"G_GINT32_FORMAT"X", c); - * ]| - */ -typedef guint32 gunichar; - -/** - * gunichar2: - * - * A type which can hold any UTF-16 code - * pointUTF-16 also has so called - * surrogate pairs to encode characters beyond - * the BMP as pairs of 16bit numbers. Surrogate pairs cannot be stored - * in a single gunichar2 field, but all GLib functions accepting gunichar2 - * arrays will correctly interpret surrogate pairs.. - * - * To print/scan values of this type to/from text you need to convert - * to/from UTF-8, using g_utf16_to_utf8()/g_utf8_to_utf16(). - * - * To print/scan values of this type as integer, use - * %G_GINT16_MODIFIER and/or %G_GUINT16_FORMAT. - */ -typedef guint16 gunichar2; - -/** - * GUnicodeType: - * @G_UNICODE_CONTROL: General category "Other, Control" (Cc) - * @G_UNICODE_FORMAT: General category "Other, Format" (Cf) - * @G_UNICODE_UNASSIGNED: General category "Other, Not Assigned" (Cn) - * @G_UNICODE_PRIVATE_USE: General category "Other, Private Use" (Co) - * @G_UNICODE_SURROGATE: General category "Other, Surrogate" (Cs) - * @G_UNICODE_LOWERCASE_LETTER: General category "Letter, Lowercase" (Ll) - * @G_UNICODE_MODIFIER_LETTER: General category "Letter, Modifier" (Lm) - * @G_UNICODE_OTHER_LETTER: General category "Letter, Other" (Lo) - * @G_UNICODE_TITLECASE_LETTER: General category "Letter, Titlecase" (Lt) - * @G_UNICODE_UPPERCASE_LETTER: General category "Letter, Uppercase" (Lu) - * @G_UNICODE_SPACING_MARK: General category "Mark, Spacing" (Mc) - * @G_UNICODE_ENCLOSING_MARK: General category "Mark, Enclosing" (Me) - * @G_UNICODE_NON_SPACING_MARK: General category "Mark, Nonspacing" (Mn) - * @G_UNICODE_DECIMAL_NUMBER: General category "Number, Decimal Digit" (Nd) - * @G_UNICODE_LETTER_NUMBER: General category "Number, Letter" (Nl) - * @G_UNICODE_OTHER_NUMBER: General category "Number, Other" (No) - * @G_UNICODE_CONNECT_PUNCTUATION: General category "Punctuation, Connector" (Pc) - * @G_UNICODE_DASH_PUNCTUATION: General category "Punctuation, Dash" (Pd) - * @G_UNICODE_CLOSE_PUNCTUATION: General category "Punctuation, Close" (Pe) - * @G_UNICODE_FINAL_PUNCTUATION: General category "Punctuation, Final quote" (Pf) - * @G_UNICODE_INITIAL_PUNCTUATION: General category "Punctuation, Initial quote" (Pi) - * @G_UNICODE_OTHER_PUNCTUATION: General category "Punctuation, Other" (Po) - * @G_UNICODE_OPEN_PUNCTUATION: General category "Punctuation, Open" (Ps) - * @G_UNICODE_CURRENCY_SYMBOL: General category "Symbol, Currency" (Sc) - * @G_UNICODE_MODIFIER_SYMBOL: General category "Symbol, Modifier" (Sk) - * @G_UNICODE_MATH_SYMBOL: General category "Symbol, Math" (Sm) - * @G_UNICODE_OTHER_SYMBOL: General category "Symbol, Other" (So) - * @G_UNICODE_LINE_SEPARATOR: General category "Separator, Line" (Zl) - * @G_UNICODE_PARAGRAPH_SEPARATOR: General category "Separator, Paragraph" (Zp) - * @G_UNICODE_SPACE_SEPARATOR: General category "Separator, Space" (Zs) - * - * These are the possible character classifications from the - * Unicode specification. - * See [Unicode Character Database](http://www.unicode.org/reports/tr44/#General_Category_Values). - */ -typedef enum -{ - G_UNICODE_CONTROL, - G_UNICODE_FORMAT, - G_UNICODE_UNASSIGNED, - G_UNICODE_PRIVATE_USE, - G_UNICODE_SURROGATE, - G_UNICODE_LOWERCASE_LETTER, - G_UNICODE_MODIFIER_LETTER, - G_UNICODE_OTHER_LETTER, - G_UNICODE_TITLECASE_LETTER, - G_UNICODE_UPPERCASE_LETTER, - G_UNICODE_SPACING_MARK, - G_UNICODE_ENCLOSING_MARK, - G_UNICODE_NON_SPACING_MARK, - G_UNICODE_DECIMAL_NUMBER, - G_UNICODE_LETTER_NUMBER, - G_UNICODE_OTHER_NUMBER, - G_UNICODE_CONNECT_PUNCTUATION, - G_UNICODE_DASH_PUNCTUATION, - G_UNICODE_CLOSE_PUNCTUATION, - G_UNICODE_FINAL_PUNCTUATION, - G_UNICODE_INITIAL_PUNCTUATION, - G_UNICODE_OTHER_PUNCTUATION, - G_UNICODE_OPEN_PUNCTUATION, - G_UNICODE_CURRENCY_SYMBOL, - G_UNICODE_MODIFIER_SYMBOL, - G_UNICODE_MATH_SYMBOL, - G_UNICODE_OTHER_SYMBOL, - G_UNICODE_LINE_SEPARATOR, - G_UNICODE_PARAGRAPH_SEPARATOR, - G_UNICODE_SPACE_SEPARATOR -} GUnicodeType; - -/** - * G_UNICODE_COMBINING_MARK: - * - * Older name for %G_UNICODE_SPACING_MARK. - * - * Deprecated: 2.30: Use %G_UNICODE_SPACING_MARK. - */ -#define G_UNICODE_COMBINING_MARK G_UNICODE_SPACING_MARK GLIB_DEPRECATED_MACRO_IN_2_30_FOR(G_UNICODE_SPACING_MARK) - -/** - * GUnicodeBreakType: - * @G_UNICODE_BREAK_MANDATORY: Mandatory Break (BK) - * @G_UNICODE_BREAK_CARRIAGE_RETURN: Carriage Return (CR) - * @G_UNICODE_BREAK_LINE_FEED: Line Feed (LF) - * @G_UNICODE_BREAK_COMBINING_MARK: Attached Characters and Combining Marks (CM) - * @G_UNICODE_BREAK_SURROGATE: Surrogates (SG) - * @G_UNICODE_BREAK_ZERO_WIDTH_SPACE: Zero Width Space (ZW) - * @G_UNICODE_BREAK_INSEPARABLE: Inseparable (IN) - * @G_UNICODE_BREAK_NON_BREAKING_GLUE: Non-breaking ("Glue") (GL) - * @G_UNICODE_BREAK_CONTINGENT: Contingent Break Opportunity (CB) - * @G_UNICODE_BREAK_SPACE: Space (SP) - * @G_UNICODE_BREAK_AFTER: Break Opportunity After (BA) - * @G_UNICODE_BREAK_BEFORE: Break Opportunity Before (BB) - * @G_UNICODE_BREAK_BEFORE_AND_AFTER: Break Opportunity Before and After (B2) - * @G_UNICODE_BREAK_HYPHEN: Hyphen (HY) - * @G_UNICODE_BREAK_NON_STARTER: Nonstarter (NS) - * @G_UNICODE_BREAK_OPEN_PUNCTUATION: Opening Punctuation (OP) - * @G_UNICODE_BREAK_CLOSE_PUNCTUATION: Closing Punctuation (CL) - * @G_UNICODE_BREAK_QUOTATION: Ambiguous Quotation (QU) - * @G_UNICODE_BREAK_EXCLAMATION: Exclamation/Interrogation (EX) - * @G_UNICODE_BREAK_IDEOGRAPHIC: Ideographic (ID) - * @G_UNICODE_BREAK_NUMERIC: Numeric (NU) - * @G_UNICODE_BREAK_INFIX_SEPARATOR: Infix Separator (Numeric) (IS) - * @G_UNICODE_BREAK_SYMBOL: Symbols Allowing Break After (SY) - * @G_UNICODE_BREAK_ALPHABETIC: Ordinary Alphabetic and Symbol Characters (AL) - * @G_UNICODE_BREAK_PREFIX: Prefix (Numeric) (PR) - * @G_UNICODE_BREAK_POSTFIX: Postfix (Numeric) (PO) - * @G_UNICODE_BREAK_COMPLEX_CONTEXT: Complex Content Dependent (South East Asian) (SA) - * @G_UNICODE_BREAK_AMBIGUOUS: Ambiguous (Alphabetic or Ideographic) (AI) - * @G_UNICODE_BREAK_UNKNOWN: Unknown (XX) - * @G_UNICODE_BREAK_NEXT_LINE: Next Line (NL) - * @G_UNICODE_BREAK_WORD_JOINER: Word Joiner (WJ) - * @G_UNICODE_BREAK_HANGUL_L_JAMO: Hangul L Jamo (JL) - * @G_UNICODE_BREAK_HANGUL_V_JAMO: Hangul V Jamo (JV) - * @G_UNICODE_BREAK_HANGUL_T_JAMO: Hangul T Jamo (JT) - * @G_UNICODE_BREAK_HANGUL_LV_SYLLABLE: Hangul LV Syllable (H2) - * @G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE: Hangul LVT Syllable (H3) - * @G_UNICODE_BREAK_CLOSE_PARANTHESIS: Closing Parenthesis (CP). Since 2.28 - * @G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER: Conditional Japanese Starter (CJ). Since: 2.32 - * @G_UNICODE_BREAK_HEBREW_LETTER: Hebrew Letter (HL). Since: 2.32 - * @G_UNICODE_BREAK_REGIONAL_INDICATOR: Regional Indicator (RI). Since: 2.36 - * @G_UNICODE_BREAK_EMOJI_BASE: Emoji Base (EB). Since: 2.50 - * @G_UNICODE_BREAK_EMOJI_MODIFIER: Emoji Modifier (EM). Since: 2.50 - * @G_UNICODE_BREAK_ZERO_WIDTH_JOINER: Zero Width Joiner (ZWJ). Since: 2.50 - * - * These are the possible line break classifications. - * - * Since new unicode versions may add new types here, applications should be ready - * to handle unknown values. They may be regarded as %G_UNICODE_BREAK_UNKNOWN. - * - * See [Unicode Line Breaking Algorithm](http://www.unicode.org/unicode/reports/tr14/). - */ -typedef enum -{ - G_UNICODE_BREAK_MANDATORY, - G_UNICODE_BREAK_CARRIAGE_RETURN, - G_UNICODE_BREAK_LINE_FEED, - G_UNICODE_BREAK_COMBINING_MARK, - G_UNICODE_BREAK_SURROGATE, - G_UNICODE_BREAK_ZERO_WIDTH_SPACE, - G_UNICODE_BREAK_INSEPARABLE, - G_UNICODE_BREAK_NON_BREAKING_GLUE, - G_UNICODE_BREAK_CONTINGENT, - G_UNICODE_BREAK_SPACE, - G_UNICODE_BREAK_AFTER, - G_UNICODE_BREAK_BEFORE, - G_UNICODE_BREAK_BEFORE_AND_AFTER, - G_UNICODE_BREAK_HYPHEN, - G_UNICODE_BREAK_NON_STARTER, - G_UNICODE_BREAK_OPEN_PUNCTUATION, - G_UNICODE_BREAK_CLOSE_PUNCTUATION, - G_UNICODE_BREAK_QUOTATION, - G_UNICODE_BREAK_EXCLAMATION, - G_UNICODE_BREAK_IDEOGRAPHIC, - G_UNICODE_BREAK_NUMERIC, - G_UNICODE_BREAK_INFIX_SEPARATOR, - G_UNICODE_BREAK_SYMBOL, - G_UNICODE_BREAK_ALPHABETIC, - G_UNICODE_BREAK_PREFIX, - G_UNICODE_BREAK_POSTFIX, - G_UNICODE_BREAK_COMPLEX_CONTEXT, - G_UNICODE_BREAK_AMBIGUOUS, - G_UNICODE_BREAK_UNKNOWN, - G_UNICODE_BREAK_NEXT_LINE, - G_UNICODE_BREAK_WORD_JOINER, - G_UNICODE_BREAK_HANGUL_L_JAMO, - G_UNICODE_BREAK_HANGUL_V_JAMO, - G_UNICODE_BREAK_HANGUL_T_JAMO, - G_UNICODE_BREAK_HANGUL_LV_SYLLABLE, - G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE, - G_UNICODE_BREAK_CLOSE_PARANTHESIS, - G_UNICODE_BREAK_CONDITIONAL_JAPANESE_STARTER, - G_UNICODE_BREAK_HEBREW_LETTER, - G_UNICODE_BREAK_REGIONAL_INDICATOR, - G_UNICODE_BREAK_EMOJI_BASE, - G_UNICODE_BREAK_EMOJI_MODIFIER, - G_UNICODE_BREAK_ZERO_WIDTH_JOINER -} GUnicodeBreakType; - -/** - * GUnicodeScript: - * @G_UNICODE_SCRIPT_INVALID_CODE: - * a value never returned from g_unichar_get_script() - * @G_UNICODE_SCRIPT_COMMON: a character used by multiple different scripts - * @G_UNICODE_SCRIPT_INHERITED: a mark glyph that takes its script from the - * base glyph to which it is attached - * @G_UNICODE_SCRIPT_ARABIC: Arabic - * @G_UNICODE_SCRIPT_ARMENIAN: Armenian - * @G_UNICODE_SCRIPT_BENGALI: Bengali - * @G_UNICODE_SCRIPT_BOPOMOFO: Bopomofo - * @G_UNICODE_SCRIPT_CHEROKEE: Cherokee - * @G_UNICODE_SCRIPT_COPTIC: Coptic - * @G_UNICODE_SCRIPT_CYRILLIC: Cyrillic - * @G_UNICODE_SCRIPT_DESERET: Deseret - * @G_UNICODE_SCRIPT_DEVANAGARI: Devanagari - * @G_UNICODE_SCRIPT_ETHIOPIC: Ethiopic - * @G_UNICODE_SCRIPT_GEORGIAN: Georgian - * @G_UNICODE_SCRIPT_GOTHIC: Gothic - * @G_UNICODE_SCRIPT_GREEK: Greek - * @G_UNICODE_SCRIPT_GUJARATI: Gujarati - * @G_UNICODE_SCRIPT_GURMUKHI: Gurmukhi - * @G_UNICODE_SCRIPT_HAN: Han - * @G_UNICODE_SCRIPT_HANGUL: Hangul - * @G_UNICODE_SCRIPT_HEBREW: Hebrew - * @G_UNICODE_SCRIPT_HIRAGANA: Hiragana - * @G_UNICODE_SCRIPT_KANNADA: Kannada - * @G_UNICODE_SCRIPT_KATAKANA: Katakana - * @G_UNICODE_SCRIPT_KHMER: Khmer - * @G_UNICODE_SCRIPT_LAO: Lao - * @G_UNICODE_SCRIPT_LATIN: Latin - * @G_UNICODE_SCRIPT_MALAYALAM: Malayalam - * @G_UNICODE_SCRIPT_MONGOLIAN: Mongolian - * @G_UNICODE_SCRIPT_MYANMAR: Myanmar - * @G_UNICODE_SCRIPT_OGHAM: Ogham - * @G_UNICODE_SCRIPT_OLD_ITALIC: Old Italic - * @G_UNICODE_SCRIPT_ORIYA: Oriya - * @G_UNICODE_SCRIPT_RUNIC: Runic - * @G_UNICODE_SCRIPT_SINHALA: Sinhala - * @G_UNICODE_SCRIPT_SYRIAC: Syriac - * @G_UNICODE_SCRIPT_TAMIL: Tamil - * @G_UNICODE_SCRIPT_TELUGU: Telugu - * @G_UNICODE_SCRIPT_THAANA: Thaana - * @G_UNICODE_SCRIPT_THAI: Thai - * @G_UNICODE_SCRIPT_TIBETAN: Tibetan - * @G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL: - * Canadian Aboriginal - * @G_UNICODE_SCRIPT_YI: Yi - * @G_UNICODE_SCRIPT_TAGALOG: Tagalog - * @G_UNICODE_SCRIPT_HANUNOO: Hanunoo - * @G_UNICODE_SCRIPT_BUHID: Buhid - * @G_UNICODE_SCRIPT_TAGBANWA: Tagbanwa - * @G_UNICODE_SCRIPT_BRAILLE: Braille - * @G_UNICODE_SCRIPT_CYPRIOT: Cypriot - * @G_UNICODE_SCRIPT_LIMBU: Limbu - * @G_UNICODE_SCRIPT_OSMANYA: Osmanya - * @G_UNICODE_SCRIPT_SHAVIAN: Shavian - * @G_UNICODE_SCRIPT_LINEAR_B: Linear B - * @G_UNICODE_SCRIPT_TAI_LE: Tai Le - * @G_UNICODE_SCRIPT_UGARITIC: Ugaritic - * @G_UNICODE_SCRIPT_NEW_TAI_LUE: - * New Tai Lue - * @G_UNICODE_SCRIPT_BUGINESE: Buginese - * @G_UNICODE_SCRIPT_GLAGOLITIC: Glagolitic - * @G_UNICODE_SCRIPT_TIFINAGH: Tifinagh - * @G_UNICODE_SCRIPT_SYLOTI_NAGRI: - * Syloti Nagri - * @G_UNICODE_SCRIPT_OLD_PERSIAN: - * Old Persian - * @G_UNICODE_SCRIPT_KHAROSHTHI: Kharoshthi - * @G_UNICODE_SCRIPT_UNKNOWN: an unassigned code point - * @G_UNICODE_SCRIPT_BALINESE: Balinese - * @G_UNICODE_SCRIPT_CUNEIFORM: Cuneiform - * @G_UNICODE_SCRIPT_PHOENICIAN: Phoenician - * @G_UNICODE_SCRIPT_PHAGS_PA: Phags-pa - * @G_UNICODE_SCRIPT_NKO: N'Ko - * @G_UNICODE_SCRIPT_KAYAH_LI: Kayah Li. Since 2.16.3 - * @G_UNICODE_SCRIPT_LEPCHA: Lepcha. Since 2.16.3 - * @G_UNICODE_SCRIPT_REJANG: Rejang. Since 2.16.3 - * @G_UNICODE_SCRIPT_SUNDANESE: Sundanese. Since 2.16.3 - * @G_UNICODE_SCRIPT_SAURASHTRA: Saurashtra. Since 2.16.3 - * @G_UNICODE_SCRIPT_CHAM: Cham. Since 2.16.3 - * @G_UNICODE_SCRIPT_OL_CHIKI: Ol Chiki. Since 2.16.3 - * @G_UNICODE_SCRIPT_VAI: Vai. Since 2.16.3 - * @G_UNICODE_SCRIPT_CARIAN: Carian. Since 2.16.3 - * @G_UNICODE_SCRIPT_LYCIAN: Lycian. Since 2.16.3 - * @G_UNICODE_SCRIPT_LYDIAN: Lydian. Since 2.16.3 - * @G_UNICODE_SCRIPT_AVESTAN: Avestan. Since 2.26 - * @G_UNICODE_SCRIPT_BAMUM: Bamum. Since 2.26 - * @G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS: - * Egyptian Hieroglpyhs. Since 2.26 - * @G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC: - * Imperial Aramaic. Since 2.26 - * @G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI: - * Inscriptional Pahlavi. Since 2.26 - * @G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN: - * Inscriptional Parthian. Since 2.26 - * @G_UNICODE_SCRIPT_JAVANESE: Javanese. Since 2.26 - * @G_UNICODE_SCRIPT_KAITHI: Kaithi. Since 2.26 - * @G_UNICODE_SCRIPT_LISU: Lisu. Since 2.26 - * @G_UNICODE_SCRIPT_MEETEI_MAYEK: - * Meetei Mayek. Since 2.26 - * @G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN: - * Old South Arabian. Since 2.26 - * @G_UNICODE_SCRIPT_OLD_TURKIC: Old Turkic. Since 2.28 - * @G_UNICODE_SCRIPT_SAMARITAN: Samaritan. Since 2.26 - * @G_UNICODE_SCRIPT_TAI_THAM: Tai Tham. Since 2.26 - * @G_UNICODE_SCRIPT_TAI_VIET: Tai Viet. Since 2.26 - * @G_UNICODE_SCRIPT_BATAK: Batak. Since 2.28 - * @G_UNICODE_SCRIPT_BRAHMI: Brahmi. Since 2.28 - * @G_UNICODE_SCRIPT_MANDAIC: Mandaic. Since 2.28 - * @G_UNICODE_SCRIPT_CHAKMA: Chakma. Since: 2.32 - * @G_UNICODE_SCRIPT_MEROITIC_CURSIVE: Meroitic Cursive. Since: 2.32 - * @G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS: Meroitic Hieroglyphs. Since: 2.32 - * @G_UNICODE_SCRIPT_MIAO: Miao. Since: 2.32 - * @G_UNICODE_SCRIPT_SHARADA: Sharada. Since: 2.32 - * @G_UNICODE_SCRIPT_SORA_SOMPENG: Sora Sompeng. Since: 2.32 - * @G_UNICODE_SCRIPT_TAKRI: Takri. Since: 2.32 - * @G_UNICODE_SCRIPT_BASSA_VAH: Bassa. Since: 2.42 - * @G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN: Caucasian Albanian. Since: 2.42 - * @G_UNICODE_SCRIPT_DUPLOYAN: Duployan. Since: 2.42 - * @G_UNICODE_SCRIPT_ELBASAN: Elbasan. Since: 2.42 - * @G_UNICODE_SCRIPT_GRANTHA: Grantha. Since: 2.42 - * @G_UNICODE_SCRIPT_KHOJKI: Kjohki. Since: 2.42 - * @G_UNICODE_SCRIPT_KHUDAWADI: Khudawadi, Sindhi. Since: 2.42 - * @G_UNICODE_SCRIPT_LINEAR_A: Linear A. Since: 2.42 - * @G_UNICODE_SCRIPT_MAHAJANI: Mahajani. Since: 2.42 - * @G_UNICODE_SCRIPT_MANICHAEAN: Manichaean. Since: 2.42 - * @G_UNICODE_SCRIPT_MENDE_KIKAKUI: Mende Kikakui. Since: 2.42 - * @G_UNICODE_SCRIPT_MODI: Modi. Since: 2.42 - * @G_UNICODE_SCRIPT_MRO: Mro. Since: 2.42 - * @G_UNICODE_SCRIPT_NABATAEAN: Nabataean. Since: 2.42 - * @G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN: Old North Arabian. Since: 2.42 - * @G_UNICODE_SCRIPT_OLD_PERMIC: Old Permic. Since: 2.42 - * @G_UNICODE_SCRIPT_PAHAWH_HMONG: Pahawh Hmong. Since: 2.42 - * @G_UNICODE_SCRIPT_PALMYRENE: Palmyrene. Since: 2.42 - * @G_UNICODE_SCRIPT_PAU_CIN_HAU: Pau Cin Hau. Since: 2.42 - * @G_UNICODE_SCRIPT_PSALTER_PAHLAVI: Psalter Pahlavi. Since: 2.42 - * @G_UNICODE_SCRIPT_SIDDHAM: Siddham. Since: 2.42 - * @G_UNICODE_SCRIPT_TIRHUTA: Tirhuta. Since: 2.42 - * @G_UNICODE_SCRIPT_WARANG_CITI: Warang Citi. Since: 2.42 - * @G_UNICODE_SCRIPT_AHOM: Ahom. Since: 2.48 - * @G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS: Anatolian Hieroglyphs. Since: 2.48 - * @G_UNICODE_SCRIPT_HATRAN: Hatran. Since: 2.48 - * @G_UNICODE_SCRIPT_MULTANI: Multani. Since: 2.48 - * @G_UNICODE_SCRIPT_OLD_HUNGARIAN: Old Hungarian. Since: 2.48 - * @G_UNICODE_SCRIPT_SIGNWRITING: Signwriting. Since: 2.48 - * @G_UNICODE_SCRIPT_ADLAM: Adlam. Since: 2.50 - * @G_UNICODE_SCRIPT_BHAIKSUKI: Bhaiksuki. Since: 2.50 - * @G_UNICODE_SCRIPT_MARCHEN: Marchen. Since: 2.50 - * @G_UNICODE_SCRIPT_NEWA: Newa. Since: 2.50 - * @G_UNICODE_SCRIPT_OSAGE: Osage. Since: 2.50 - * @G_UNICODE_SCRIPT_TANGUT: Tangut. Since: 2.50 - * @G_UNICODE_SCRIPT_MASARAM_GONDI: Masaram Gondi. Since: 2.54 - * @G_UNICODE_SCRIPT_NUSHU: Nushu. Since: 2.54 - * @G_UNICODE_SCRIPT_SOYOMBO: Soyombo. Since: 2.54 - * @G_UNICODE_SCRIPT_ZANABAZAR_SQUARE: Zanabazar Square. Since: 2.54 - * @G_UNICODE_SCRIPT_DOGRA: Dogra. Since: 2.58 - * @G_UNICODE_SCRIPT_GUNJALA_GONDI: Gunjala Gondi. Since: 2.58 - * @G_UNICODE_SCRIPT_HANIFI_ROHINGYA: Hanifi Rohingya. Since: 2.58 - * @G_UNICODE_SCRIPT_MAKASAR: Makasar. Since: 2.58 - * @G_UNICODE_SCRIPT_MEDEFAIDRIN: Medefaidrin. Since: 2.58 - * @G_UNICODE_SCRIPT_OLD_SOGDIAN: Old Sogdian. Since: 2.58 - * @G_UNICODE_SCRIPT_SOGDIAN: Sogdian. Since: 2.58 - * @G_UNICODE_SCRIPT_ELYMAIC: Elym. Since: 2.62 - * @G_UNICODE_SCRIPT_NANDINAGARI: Nand. Since: 2.62 - * @G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG: Rohg. Since: 2.62 - * @G_UNICODE_SCRIPT_WANCHO: Wcho. Since: 2.62 - * @G_UNICODE_SCRIPT_CHORASMIAN: Chorasmian. Since: 2.66 - * @G_UNICODE_SCRIPT_DIVES_AKURU: Dives Akuru. Since: 2.66 - * @G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT: Khitan small script. Since: 2.66 - * @G_UNICODE_SCRIPT_YEZIDI: Yezidi. Since: 2.66 - * - * The #GUnicodeScript enumeration identifies different writing - * systems. The values correspond to the names as defined in the - * Unicode standard. The enumeration has been added in GLib 2.14, - * and is interchangeable with #PangoScript. - * - * Note that new types may be added in the future. Applications - * should be ready to handle unknown values. - * See [Unicode Standard Annex #24: Script names](http://www.unicode.org/reports/tr24/). - */ -typedef enum -{ /* ISO 15924 code */ - G_UNICODE_SCRIPT_INVALID_CODE = -1, - G_UNICODE_SCRIPT_COMMON = 0, /* Zyyy */ - G_UNICODE_SCRIPT_INHERITED, /* Zinh (Qaai) */ - G_UNICODE_SCRIPT_ARABIC, /* Arab */ - G_UNICODE_SCRIPT_ARMENIAN, /* Armn */ - G_UNICODE_SCRIPT_BENGALI, /* Beng */ - G_UNICODE_SCRIPT_BOPOMOFO, /* Bopo */ - G_UNICODE_SCRIPT_CHEROKEE, /* Cher */ - G_UNICODE_SCRIPT_COPTIC, /* Copt (Qaac) */ - G_UNICODE_SCRIPT_CYRILLIC, /* Cyrl (Cyrs) */ - G_UNICODE_SCRIPT_DESERET, /* Dsrt */ - G_UNICODE_SCRIPT_DEVANAGARI, /* Deva */ - G_UNICODE_SCRIPT_ETHIOPIC, /* Ethi */ - G_UNICODE_SCRIPT_GEORGIAN, /* Geor (Geon, Geoa) */ - G_UNICODE_SCRIPT_GOTHIC, /* Goth */ - G_UNICODE_SCRIPT_GREEK, /* Grek */ - G_UNICODE_SCRIPT_GUJARATI, /* Gujr */ - G_UNICODE_SCRIPT_GURMUKHI, /* Guru */ - G_UNICODE_SCRIPT_HAN, /* Hani */ - G_UNICODE_SCRIPT_HANGUL, /* Hang */ - G_UNICODE_SCRIPT_HEBREW, /* Hebr */ - G_UNICODE_SCRIPT_HIRAGANA, /* Hira */ - G_UNICODE_SCRIPT_KANNADA, /* Knda */ - G_UNICODE_SCRIPT_KATAKANA, /* Kana */ - G_UNICODE_SCRIPT_KHMER, /* Khmr */ - G_UNICODE_SCRIPT_LAO, /* Laoo */ - G_UNICODE_SCRIPT_LATIN, /* Latn (Latf, Latg) */ - G_UNICODE_SCRIPT_MALAYALAM, /* Mlym */ - G_UNICODE_SCRIPT_MONGOLIAN, /* Mong */ - G_UNICODE_SCRIPT_MYANMAR, /* Mymr */ - G_UNICODE_SCRIPT_OGHAM, /* Ogam */ - G_UNICODE_SCRIPT_OLD_ITALIC, /* Ital */ - G_UNICODE_SCRIPT_ORIYA, /* Orya */ - G_UNICODE_SCRIPT_RUNIC, /* Runr */ - G_UNICODE_SCRIPT_SINHALA, /* Sinh */ - G_UNICODE_SCRIPT_SYRIAC, /* Syrc (Syrj, Syrn, Syre) */ - G_UNICODE_SCRIPT_TAMIL, /* Taml */ - G_UNICODE_SCRIPT_TELUGU, /* Telu */ - G_UNICODE_SCRIPT_THAANA, /* Thaa */ - G_UNICODE_SCRIPT_THAI, /* Thai */ - G_UNICODE_SCRIPT_TIBETAN, /* Tibt */ - G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL, /* Cans */ - G_UNICODE_SCRIPT_YI, /* Yiii */ - G_UNICODE_SCRIPT_TAGALOG, /* Tglg */ - G_UNICODE_SCRIPT_HANUNOO, /* Hano */ - G_UNICODE_SCRIPT_BUHID, /* Buhd */ - G_UNICODE_SCRIPT_TAGBANWA, /* Tagb */ - - /* Unicode-4.0 additions */ - G_UNICODE_SCRIPT_BRAILLE, /* Brai */ - G_UNICODE_SCRIPT_CYPRIOT, /* Cprt */ - G_UNICODE_SCRIPT_LIMBU, /* Limb */ - G_UNICODE_SCRIPT_OSMANYA, /* Osma */ - G_UNICODE_SCRIPT_SHAVIAN, /* Shaw */ - G_UNICODE_SCRIPT_LINEAR_B, /* Linb */ - G_UNICODE_SCRIPT_TAI_LE, /* Tale */ - G_UNICODE_SCRIPT_UGARITIC, /* Ugar */ - - /* Unicode-4.1 additions */ - G_UNICODE_SCRIPT_NEW_TAI_LUE, /* Talu */ - G_UNICODE_SCRIPT_BUGINESE, /* Bugi */ - G_UNICODE_SCRIPT_GLAGOLITIC, /* Glag */ - G_UNICODE_SCRIPT_TIFINAGH, /* Tfng */ - G_UNICODE_SCRIPT_SYLOTI_NAGRI, /* Sylo */ - G_UNICODE_SCRIPT_OLD_PERSIAN, /* Xpeo */ - G_UNICODE_SCRIPT_KHAROSHTHI, /* Khar */ - - /* Unicode-5.0 additions */ - G_UNICODE_SCRIPT_UNKNOWN, /* Zzzz */ - G_UNICODE_SCRIPT_BALINESE, /* Bali */ - G_UNICODE_SCRIPT_CUNEIFORM, /* Xsux */ - G_UNICODE_SCRIPT_PHOENICIAN, /* Phnx */ - G_UNICODE_SCRIPT_PHAGS_PA, /* Phag */ - G_UNICODE_SCRIPT_NKO, /* Nkoo */ - - /* Unicode-5.1 additions */ - G_UNICODE_SCRIPT_KAYAH_LI, /* Kali */ - G_UNICODE_SCRIPT_LEPCHA, /* Lepc */ - G_UNICODE_SCRIPT_REJANG, /* Rjng */ - G_UNICODE_SCRIPT_SUNDANESE, /* Sund */ - G_UNICODE_SCRIPT_SAURASHTRA, /* Saur */ - G_UNICODE_SCRIPT_CHAM, /* Cham */ - G_UNICODE_SCRIPT_OL_CHIKI, /* Olck */ - G_UNICODE_SCRIPT_VAI, /* Vaii */ - G_UNICODE_SCRIPT_CARIAN, /* Cari */ - G_UNICODE_SCRIPT_LYCIAN, /* Lyci */ - G_UNICODE_SCRIPT_LYDIAN, /* Lydi */ - - /* Unicode-5.2 additions */ - G_UNICODE_SCRIPT_AVESTAN, /* Avst */ - G_UNICODE_SCRIPT_BAMUM, /* Bamu */ - G_UNICODE_SCRIPT_EGYPTIAN_HIEROGLYPHS, /* Egyp */ - G_UNICODE_SCRIPT_IMPERIAL_ARAMAIC, /* Armi */ - G_UNICODE_SCRIPT_INSCRIPTIONAL_PAHLAVI, /* Phli */ - G_UNICODE_SCRIPT_INSCRIPTIONAL_PARTHIAN, /* Prti */ - G_UNICODE_SCRIPT_JAVANESE, /* Java */ - G_UNICODE_SCRIPT_KAITHI, /* Kthi */ - G_UNICODE_SCRIPT_LISU, /* Lisu */ - G_UNICODE_SCRIPT_MEETEI_MAYEK, /* Mtei */ - G_UNICODE_SCRIPT_OLD_SOUTH_ARABIAN, /* Sarb */ - G_UNICODE_SCRIPT_OLD_TURKIC, /* Orkh */ - G_UNICODE_SCRIPT_SAMARITAN, /* Samr */ - G_UNICODE_SCRIPT_TAI_THAM, /* Lana */ - G_UNICODE_SCRIPT_TAI_VIET, /* Tavt */ - - /* Unicode-6.0 additions */ - G_UNICODE_SCRIPT_BATAK, /* Batk */ - G_UNICODE_SCRIPT_BRAHMI, /* Brah */ - G_UNICODE_SCRIPT_MANDAIC, /* Mand */ - - /* Unicode-6.1 additions */ - G_UNICODE_SCRIPT_CHAKMA, /* Cakm */ - G_UNICODE_SCRIPT_MEROITIC_CURSIVE, /* Merc */ - G_UNICODE_SCRIPT_MEROITIC_HIEROGLYPHS, /* Mero */ - G_UNICODE_SCRIPT_MIAO, /* Plrd */ - G_UNICODE_SCRIPT_SHARADA, /* Shrd */ - G_UNICODE_SCRIPT_SORA_SOMPENG, /* Sora */ - G_UNICODE_SCRIPT_TAKRI, /* Takr */ - - /* Unicode 7.0 additions */ - G_UNICODE_SCRIPT_BASSA_VAH, /* Bass */ - G_UNICODE_SCRIPT_CAUCASIAN_ALBANIAN, /* Aghb */ - G_UNICODE_SCRIPT_DUPLOYAN, /* Dupl */ - G_UNICODE_SCRIPT_ELBASAN, /* Elba */ - G_UNICODE_SCRIPT_GRANTHA, /* Gran */ - G_UNICODE_SCRIPT_KHOJKI, /* Khoj */ - G_UNICODE_SCRIPT_KHUDAWADI, /* Sind */ - G_UNICODE_SCRIPT_LINEAR_A, /* Lina */ - G_UNICODE_SCRIPT_MAHAJANI, /* Mahj */ - G_UNICODE_SCRIPT_MANICHAEAN, /* Mani */ - G_UNICODE_SCRIPT_MENDE_KIKAKUI, /* Mend */ - G_UNICODE_SCRIPT_MODI, /* Modi */ - G_UNICODE_SCRIPT_MRO, /* Mroo */ - G_UNICODE_SCRIPT_NABATAEAN, /* Nbat */ - G_UNICODE_SCRIPT_OLD_NORTH_ARABIAN, /* Narb */ - G_UNICODE_SCRIPT_OLD_PERMIC, /* Perm */ - G_UNICODE_SCRIPT_PAHAWH_HMONG, /* Hmng */ - G_UNICODE_SCRIPT_PALMYRENE, /* Palm */ - G_UNICODE_SCRIPT_PAU_CIN_HAU, /* Pauc */ - G_UNICODE_SCRIPT_PSALTER_PAHLAVI, /* Phlp */ - G_UNICODE_SCRIPT_SIDDHAM, /* Sidd */ - G_UNICODE_SCRIPT_TIRHUTA, /* Tirh */ - G_UNICODE_SCRIPT_WARANG_CITI, /* Wara */ - - /* Unicode 8.0 additions */ - G_UNICODE_SCRIPT_AHOM, /* Ahom */ - G_UNICODE_SCRIPT_ANATOLIAN_HIEROGLYPHS, /* Hluw */ - G_UNICODE_SCRIPT_HATRAN, /* Hatr */ - G_UNICODE_SCRIPT_MULTANI, /* Mult */ - G_UNICODE_SCRIPT_OLD_HUNGARIAN, /* Hung */ - G_UNICODE_SCRIPT_SIGNWRITING, /* Sgnw */ - - /* Unicode 9.0 additions */ - G_UNICODE_SCRIPT_ADLAM, /* Adlm */ - G_UNICODE_SCRIPT_BHAIKSUKI, /* Bhks */ - G_UNICODE_SCRIPT_MARCHEN, /* Marc */ - G_UNICODE_SCRIPT_NEWA, /* Newa */ - G_UNICODE_SCRIPT_OSAGE, /* Osge */ - G_UNICODE_SCRIPT_TANGUT, /* Tang */ - - /* Unicode 10.0 additions */ - G_UNICODE_SCRIPT_MASARAM_GONDI, /* Gonm */ - G_UNICODE_SCRIPT_NUSHU, /* Nshu */ - G_UNICODE_SCRIPT_SOYOMBO, /* Soyo */ - G_UNICODE_SCRIPT_ZANABAZAR_SQUARE, /* Zanb */ - - /* Unicode 11.0 additions */ - G_UNICODE_SCRIPT_DOGRA, /* Dogr */ - G_UNICODE_SCRIPT_GUNJALA_GONDI, /* Gong */ - G_UNICODE_SCRIPT_HANIFI_ROHINGYA, /* Rohg */ - G_UNICODE_SCRIPT_MAKASAR, /* Maka */ - G_UNICODE_SCRIPT_MEDEFAIDRIN, /* Medf */ - G_UNICODE_SCRIPT_OLD_SOGDIAN, /* Sogo */ - G_UNICODE_SCRIPT_SOGDIAN, /* Sogd */ - - /* Unicode 12.0 additions */ - G_UNICODE_SCRIPT_ELYMAIC, /* Elym */ - G_UNICODE_SCRIPT_NANDINAGARI, /* Nand */ - G_UNICODE_SCRIPT_NYIAKENG_PUACHUE_HMONG, /* Rohg */ - G_UNICODE_SCRIPT_WANCHO, /* Wcho */ - - /* Unicode 13.0 additions */ - G_UNICODE_SCRIPT_CHORASMIAN, /* Chrs */ - G_UNICODE_SCRIPT_DIVES_AKURU, /* Diak */ - G_UNICODE_SCRIPT_KHITAN_SMALL_SCRIPT, /* Kits */ - G_UNICODE_SCRIPT_YEZIDI /* Yezi */ -} GUnicodeScript; - -GLIB_AVAILABLE_IN_ALL -guint32 g_unicode_script_to_iso15924 (GUnicodeScript script); -GLIB_AVAILABLE_IN_ALL -GUnicodeScript g_unicode_script_from_iso15924 (guint32 iso15924); - -/* These are all analogs of the functions. - */ -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isalnum (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isalpha (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_iscntrl (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isdigit (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isgraph (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_islower (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isprint (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_ispunct (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isspace (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isupper (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isxdigit (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_istitle (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_isdefined (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_iswide (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_iswide_cjk(gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_iszerowidth(gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_ismark (gunichar c) G_GNUC_CONST; - -/* More functions. These convert between the three cases. - * See the Unicode book to understand title case. */ -GLIB_AVAILABLE_IN_ALL -gunichar g_unichar_toupper (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gunichar g_unichar_tolower (gunichar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gunichar g_unichar_totitle (gunichar c) G_GNUC_CONST; - -/* If C is a digit (according to 'g_unichar_isdigit'), then return its - numeric value. Otherwise return -1. */ -GLIB_AVAILABLE_IN_ALL -gint g_unichar_digit_value (gunichar c) G_GNUC_CONST; - -GLIB_AVAILABLE_IN_ALL -gint g_unichar_xdigit_value (gunichar c) G_GNUC_CONST; - -/* Return the Unicode character type of a given character. */ -GLIB_AVAILABLE_IN_ALL -GUnicodeType g_unichar_type (gunichar c) G_GNUC_CONST; - -/* Return the line break property for a given character */ -GLIB_AVAILABLE_IN_ALL -GUnicodeBreakType g_unichar_break_type (gunichar c) G_GNUC_CONST; - -/* Returns the combining class for a given character */ -GLIB_AVAILABLE_IN_ALL -gint g_unichar_combining_class (gunichar uc) G_GNUC_CONST; - -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_get_mirror_char (gunichar ch, - gunichar *mirrored_ch); - -GLIB_AVAILABLE_IN_ALL -GUnicodeScript g_unichar_get_script (gunichar ch) G_GNUC_CONST; - -/* Validate a Unicode character */ -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_validate (gunichar ch) G_GNUC_CONST; - -/* Pairwise canonical compose/decompose */ -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_compose (gunichar a, - gunichar b, - gunichar *ch); -GLIB_AVAILABLE_IN_ALL -gboolean g_unichar_decompose (gunichar ch, - gunichar *a, - gunichar *b); - -GLIB_AVAILABLE_IN_ALL -gsize g_unichar_fully_decompose (gunichar ch, - gboolean compat, - gunichar *result, - gsize result_len); - -/** - * G_UNICHAR_MAX_DECOMPOSITION_LENGTH: - * - * The maximum length (in codepoints) of a compatibility or canonical - * decomposition of a single Unicode character. - * - * This is as defined by Unicode 6.1. - * - * Since: 2.32 - */ -#define G_UNICHAR_MAX_DECOMPOSITION_LENGTH 18 /* codepoints */ - -/* Compute canonical ordering of a string in-place. This rearranges - decomposed characters in the string according to their combining - classes. See the Unicode manual for more information. */ -GLIB_AVAILABLE_IN_ALL -void g_unicode_canonical_ordering (gunichar *string, - gsize len); - - -GLIB_DEPRECATED_IN_2_30 -gunichar *g_unicode_canonical_decomposition (gunichar ch, - gsize *result_len) G_GNUC_MALLOC; - -/* Array of skip-bytes-per-initial character. - */ -GLIB_VAR const gchar * const g_utf8_skip; - -/** - * g_utf8_next_char: - * @p: Pointer to the start of a valid UTF-8 character - * - * Skips to the next character in a UTF-8 string. The string must be - * valid; this macro is as fast as possible, and has no error-checking. - * You would use this macro to iterate over a string character by - * character. The macro returns the start of the next UTF-8 character. - * Before using this macro, use g_utf8_validate() to validate strings - * that may contain invalid UTF-8. - */ -#define g_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(const guchar *)(p)]) - -GLIB_AVAILABLE_IN_ALL -gunichar g_utf8_get_char (const gchar *p) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -gunichar g_utf8_get_char_validated (const gchar *p, - gssize max_len) G_GNUC_PURE; - -GLIB_AVAILABLE_IN_ALL -gchar* g_utf8_offset_to_pointer (const gchar *str, - glong offset) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -glong g_utf8_pointer_to_offset (const gchar *str, - const gchar *pos) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -gchar* g_utf8_prev_char (const gchar *p) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -gchar* g_utf8_find_next_char (const gchar *p, - const gchar *end) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -gchar* g_utf8_find_prev_char (const gchar *str, - const gchar *p) G_GNUC_PURE; - -GLIB_AVAILABLE_IN_ALL -glong g_utf8_strlen (const gchar *p, - gssize max) G_GNUC_PURE; - -GLIB_AVAILABLE_IN_2_30 -gchar *g_utf8_substring (const gchar *str, - glong start_pos, - glong end_pos) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gchar *g_utf8_strncpy (gchar *dest, - const gchar *src, - gsize n); - -/* Find the UTF-8 character corresponding to ch, in string p. These - functions are equivalants to strchr and strrchr */ -GLIB_AVAILABLE_IN_ALL -gchar* g_utf8_strchr (const gchar *p, - gssize len, - gunichar c); -GLIB_AVAILABLE_IN_ALL -gchar* g_utf8_strrchr (const gchar *p, - gssize len, - gunichar c); -GLIB_AVAILABLE_IN_ALL -gchar* g_utf8_strreverse (const gchar *str, - gssize len); - -GLIB_AVAILABLE_IN_ALL -gunichar2 *g_utf8_to_utf16 (const gchar *str, - glong len, - glong *items_read, - glong *items_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gunichar * g_utf8_to_ucs4 (const gchar *str, - glong len, - glong *items_read, - glong *items_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gunichar * g_utf8_to_ucs4_fast (const gchar *str, - glong len, - glong *items_written) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gunichar * g_utf16_to_ucs4 (const gunichar2 *str, - glong len, - glong *items_read, - glong *items_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_utf16_to_utf8 (const gunichar2 *str, - glong len, - glong *items_read, - glong *items_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gunichar2 *g_ucs4_to_utf16 (const gunichar *str, - glong len, - glong *items_read, - glong *items_written, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_ucs4_to_utf8 (const gunichar *str, - glong len, - glong *items_read, - glong *items_written, - GError **error) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gint g_unichar_to_utf8 (gunichar c, - gchar *outbuf); - -GLIB_AVAILABLE_IN_ALL -gboolean g_utf8_validate (const gchar *str, - gssize max_len, - const gchar **end); -GLIB_AVAILABLE_IN_2_60 -gboolean g_utf8_validate_len (const gchar *str, - gsize max_len, - const gchar **end); - -GLIB_AVAILABLE_IN_ALL -gchar *g_utf8_strup (const gchar *str, - gssize len) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar *g_utf8_strdown (const gchar *str, - gssize len) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar *g_utf8_casefold (const gchar *str, - gssize len) G_GNUC_MALLOC; - -/** - * GNormalizeMode: - * @G_NORMALIZE_DEFAULT: standardize differences that do not affect the - * text content, such as the above-mentioned accent representation - * @G_NORMALIZE_NFD: another name for %G_NORMALIZE_DEFAULT - * @G_NORMALIZE_DEFAULT_COMPOSE: like %G_NORMALIZE_DEFAULT, but with - * composed forms rather than a maximally decomposed form - * @G_NORMALIZE_NFC: another name for %G_NORMALIZE_DEFAULT_COMPOSE - * @G_NORMALIZE_ALL: beyond %G_NORMALIZE_DEFAULT also standardize the - * "compatibility" characters in Unicode, such as SUPERSCRIPT THREE - * to the standard forms (in this case DIGIT THREE). Formatting - * information may be lost but for most text operations such - * characters should be considered the same - * @G_NORMALIZE_NFKD: another name for %G_NORMALIZE_ALL - * @G_NORMALIZE_ALL_COMPOSE: like %G_NORMALIZE_ALL, but with composed - * forms rather than a maximally decomposed form - * @G_NORMALIZE_NFKC: another name for %G_NORMALIZE_ALL_COMPOSE - * - * Defines how a Unicode string is transformed in a canonical - * form, standardizing such issues as whether a character with - * an accent is represented as a base character and combining - * accent or as a single precomposed character. Unicode strings - * should generally be normalized before comparing them. - */ -typedef enum { - G_NORMALIZE_DEFAULT, - G_NORMALIZE_NFD = G_NORMALIZE_DEFAULT, - G_NORMALIZE_DEFAULT_COMPOSE, - G_NORMALIZE_NFC = G_NORMALIZE_DEFAULT_COMPOSE, - G_NORMALIZE_ALL, - G_NORMALIZE_NFKD = G_NORMALIZE_ALL, - G_NORMALIZE_ALL_COMPOSE, - G_NORMALIZE_NFKC = G_NORMALIZE_ALL_COMPOSE -} GNormalizeMode; - -GLIB_AVAILABLE_IN_ALL -gchar *g_utf8_normalize (const gchar *str, - gssize len, - GNormalizeMode mode) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gint g_utf8_collate (const gchar *str1, - const gchar *str2) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -gchar *g_utf8_collate_key (const gchar *str, - gssize len) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar *g_utf8_collate_key_for_filename (const gchar *str, - gssize len) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_2_52 -gchar *g_utf8_make_valid (const gchar *str, - gssize len) G_GNUC_MALLOC; - -G_END_DECLS - -#endif /* __G_UNICODE_H__ */ - -G_BEGIN_DECLS - -typedef struct _GString GString; - -struct _GString -{ - gchar *str; - gsize len; - gsize allocated_len; -}; - -GLIB_AVAILABLE_IN_ALL -GString* g_string_new (const gchar *init); -GLIB_AVAILABLE_IN_ALL -GString* g_string_new_len (const gchar *init, - gssize len); -GLIB_AVAILABLE_IN_ALL -GString* g_string_sized_new (gsize dfl_size); -GLIB_AVAILABLE_IN_ALL -gchar* g_string_free (GString *string, - gboolean free_segment); -GLIB_AVAILABLE_IN_2_34 -GBytes* g_string_free_to_bytes (GString *string); -GLIB_AVAILABLE_IN_ALL -gboolean g_string_equal (const GString *v, - const GString *v2); -GLIB_AVAILABLE_IN_ALL -guint g_string_hash (const GString *str); -GLIB_AVAILABLE_IN_ALL -GString* g_string_assign (GString *string, - const gchar *rval); -GLIB_AVAILABLE_IN_ALL -GString* g_string_truncate (GString *string, - gsize len); -GLIB_AVAILABLE_IN_ALL -GString* g_string_set_size (GString *string, - gsize len); -GLIB_AVAILABLE_IN_ALL -GString* g_string_insert_len (GString *string, - gssize pos, - const gchar *val, - gssize len); -GLIB_AVAILABLE_IN_ALL -GString* g_string_append (GString *string, - const gchar *val); -GLIB_AVAILABLE_IN_ALL -GString* g_string_append_len (GString *string, - const gchar *val, - gssize len); -GLIB_AVAILABLE_IN_ALL -GString* g_string_append_c (GString *string, - gchar c); -GLIB_AVAILABLE_IN_ALL -GString* g_string_append_unichar (GString *string, - gunichar wc); -GLIB_AVAILABLE_IN_ALL -GString* g_string_prepend (GString *string, - const gchar *val); -GLIB_AVAILABLE_IN_ALL -GString* g_string_prepend_c (GString *string, - gchar c); -GLIB_AVAILABLE_IN_ALL -GString* g_string_prepend_unichar (GString *string, - gunichar wc); -GLIB_AVAILABLE_IN_ALL -GString* g_string_prepend_len (GString *string, - const gchar *val, - gssize len); -GLIB_AVAILABLE_IN_ALL -GString* g_string_insert (GString *string, - gssize pos, - const gchar *val); -GLIB_AVAILABLE_IN_ALL -GString* g_string_insert_c (GString *string, - gssize pos, - gchar c); -GLIB_AVAILABLE_IN_ALL -GString* g_string_insert_unichar (GString *string, - gssize pos, - gunichar wc); -GLIB_AVAILABLE_IN_ALL -GString* g_string_overwrite (GString *string, - gsize pos, - const gchar *val); -GLIB_AVAILABLE_IN_ALL -GString* g_string_overwrite_len (GString *string, - gsize pos, - const gchar *val, - gssize len); -GLIB_AVAILABLE_IN_ALL -GString* g_string_erase (GString *string, - gssize pos, - gssize len); -GLIB_AVAILABLE_IN_ALL -GString* g_string_ascii_down (GString *string); -GLIB_AVAILABLE_IN_ALL -GString* g_string_ascii_up (GString *string); -GLIB_AVAILABLE_IN_ALL -void g_string_vprintf (GString *string, - const gchar *format, - va_list args) - G_GNUC_PRINTF(2, 0); -GLIB_AVAILABLE_IN_ALL -void g_string_printf (GString *string, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); -GLIB_AVAILABLE_IN_ALL -void g_string_append_vprintf (GString *string, - const gchar *format, - va_list args) - G_GNUC_PRINTF(2, 0); -GLIB_AVAILABLE_IN_ALL -void g_string_append_printf (GString *string, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); -GLIB_AVAILABLE_IN_ALL -GString* g_string_append_uri_escaped (GString *string, - const gchar *unescaped, - const gchar *reserved_chars_allowed, - gboolean allow_utf8); - -/* -- optimize g_strig_append_c --- */ -#ifdef G_CAN_INLINE -static inline GString* -g_string_append_c_inline (GString *gstring, - gchar c) -{ - if (gstring->len + 1 < gstring->allocated_len) - { - gstring->str[gstring->len++] = c; - gstring->str[gstring->len] = 0; - } - else - g_string_insert_c (gstring, -1, c); - return gstring; -} -#undef g_string_append_c -#define g_string_append_c(gstr,c) g_string_append_c_inline (gstr, c) -#endif /* G_CAN_INLINE */ - - -GLIB_DEPRECATED -GString *g_string_down (GString *string); -GLIB_DEPRECATED -GString *g_string_up (GString *string); - -#define g_string_sprintf g_string_printf GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_string_printf) -#define g_string_sprintfa g_string_append_printf GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_string_append_printf) - -G_END_DECLS - -#endif /* __G_STRING_H__ */ - -G_BEGIN_DECLS - -/* GIOChannel - */ - -typedef struct _GIOChannel GIOChannel; -typedef struct _GIOFuncs GIOFuncs; - -typedef enum -{ - G_IO_ERROR_NONE, - G_IO_ERROR_AGAIN, - G_IO_ERROR_INVAL, - G_IO_ERROR_UNKNOWN -} GIOError; - -#define G_IO_CHANNEL_ERROR g_io_channel_error_quark() - -typedef enum -{ - /* Derived from errno */ - G_IO_CHANNEL_ERROR_FBIG, - G_IO_CHANNEL_ERROR_INVAL, - G_IO_CHANNEL_ERROR_IO, - G_IO_CHANNEL_ERROR_ISDIR, - G_IO_CHANNEL_ERROR_NOSPC, - G_IO_CHANNEL_ERROR_NXIO, - G_IO_CHANNEL_ERROR_OVERFLOW, - G_IO_CHANNEL_ERROR_PIPE, - /* Other */ - G_IO_CHANNEL_ERROR_FAILED -} GIOChannelError; - -typedef enum -{ - G_IO_STATUS_ERROR, - G_IO_STATUS_NORMAL, - G_IO_STATUS_EOF, - G_IO_STATUS_AGAIN -} GIOStatus; - -typedef enum -{ - G_SEEK_CUR, - G_SEEK_SET, - G_SEEK_END -} GSeekType; - -typedef enum -{ - G_IO_FLAG_APPEND = 1 << 0, - G_IO_FLAG_NONBLOCK = 1 << 1, - G_IO_FLAG_IS_READABLE = 1 << 2, /* Read only flag */ - G_IO_FLAG_IS_WRITABLE = 1 << 3, /* Read only flag */ - G_IO_FLAG_IS_WRITEABLE = 1 << 3, /* Misspelling in 2.29.10 and earlier */ - G_IO_FLAG_IS_SEEKABLE = 1 << 4, /* Read only flag */ - G_IO_FLAG_MASK = (1 << 5) - 1, - G_IO_FLAG_GET_MASK = G_IO_FLAG_MASK, - G_IO_FLAG_SET_MASK = G_IO_FLAG_APPEND | G_IO_FLAG_NONBLOCK -} GIOFlags; - -struct _GIOChannel -{ - /*< private >*/ - gint ref_count; - GIOFuncs *funcs; - - gchar *encoding; - GIConv read_cd; - GIConv write_cd; - gchar *line_term; /* String which indicates the end of a line of text */ - guint line_term_len; /* So we can have null in the line term */ - - gsize buf_size; - GString *read_buf; /* Raw data from the channel */ - GString *encoded_read_buf; /* Channel data converted to UTF-8 */ - GString *write_buf; /* Data ready to be written to the file */ - gchar partial_write_buf[6]; /* UTF-8 partial characters, null terminated */ - - /* Group the flags together, immediately after partial_write_buf, to save memory */ - - guint use_buffer : 1; /* The encoding uses the buffers */ - guint do_encode : 1; /* The encoding uses the GIConv coverters */ - guint close_on_unref : 1; /* Close the channel on final unref */ - guint is_readable : 1; /* Cached GIOFlag */ - guint is_writeable : 1; /* ditto */ - guint is_seekable : 1; /* ditto */ - - gpointer reserved1; - gpointer reserved2; -}; - -typedef gboolean (*GIOFunc) (GIOChannel *source, - GIOCondition condition, - gpointer data); -struct _GIOFuncs -{ - GIOStatus (*io_read) (GIOChannel *channel, - gchar *buf, - gsize count, - gsize *bytes_read, - GError **err); - GIOStatus (*io_write) (GIOChannel *channel, - const gchar *buf, - gsize count, - gsize *bytes_written, - GError **err); - GIOStatus (*io_seek) (GIOChannel *channel, - gint64 offset, - GSeekType type, - GError **err); - GIOStatus (*io_close) (GIOChannel *channel, - GError **err); - GSource* (*io_create_watch) (GIOChannel *channel, - GIOCondition condition); - void (*io_free) (GIOChannel *channel); - GIOStatus (*io_set_flags) (GIOChannel *channel, - GIOFlags flags, - GError **err); - GIOFlags (*io_get_flags) (GIOChannel *channel); -}; - -GLIB_AVAILABLE_IN_ALL -void g_io_channel_init (GIOChannel *channel); -GLIB_AVAILABLE_IN_ALL -GIOChannel *g_io_channel_ref (GIOChannel *channel); -GLIB_AVAILABLE_IN_ALL -void g_io_channel_unref (GIOChannel *channel); - -GLIB_DEPRECATED_FOR(g_io_channel_read_chars) -GIOError g_io_channel_read (GIOChannel *channel, - gchar *buf, - gsize count, - gsize *bytes_read); - -GLIB_DEPRECATED_FOR(g_io_channel_write_chars) -GIOError g_io_channel_write (GIOChannel *channel, - const gchar *buf, - gsize count, - gsize *bytes_written); - -GLIB_DEPRECATED_FOR(g_io_channel_seek_position) -GIOError g_io_channel_seek (GIOChannel *channel, - gint64 offset, - GSeekType type); - -GLIB_DEPRECATED_FOR(g_io_channel_shutdown) -void g_io_channel_close (GIOChannel *channel); - -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_shutdown (GIOChannel *channel, - gboolean flush, - GError **err); -GLIB_AVAILABLE_IN_ALL -guint g_io_add_watch_full (GIOChannel *channel, - gint priority, - GIOCondition condition, - GIOFunc func, - gpointer user_data, - GDestroyNotify notify); -GLIB_AVAILABLE_IN_ALL -GSource * g_io_create_watch (GIOChannel *channel, - GIOCondition condition); -GLIB_AVAILABLE_IN_ALL -guint g_io_add_watch (GIOChannel *channel, - GIOCondition condition, - GIOFunc func, - gpointer user_data); - -/* character encoding conversion involved functions. - */ - -GLIB_AVAILABLE_IN_ALL -void g_io_channel_set_buffer_size (GIOChannel *channel, - gsize size); -GLIB_AVAILABLE_IN_ALL -gsize g_io_channel_get_buffer_size (GIOChannel *channel); -GLIB_AVAILABLE_IN_ALL -GIOCondition g_io_channel_get_buffer_condition (GIOChannel *channel); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_set_flags (GIOChannel *channel, - GIOFlags flags, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOFlags g_io_channel_get_flags (GIOChannel *channel); -GLIB_AVAILABLE_IN_ALL -void g_io_channel_set_line_term (GIOChannel *channel, - const gchar *line_term, - gint length); -GLIB_AVAILABLE_IN_ALL -const gchar * g_io_channel_get_line_term (GIOChannel *channel, - gint *length); -GLIB_AVAILABLE_IN_ALL -void g_io_channel_set_buffered (GIOChannel *channel, - gboolean buffered); -GLIB_AVAILABLE_IN_ALL -gboolean g_io_channel_get_buffered (GIOChannel *channel); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_set_encoding (GIOChannel *channel, - const gchar *encoding, - GError **error); -GLIB_AVAILABLE_IN_ALL -const gchar * g_io_channel_get_encoding (GIOChannel *channel); -GLIB_AVAILABLE_IN_ALL -void g_io_channel_set_close_on_unref (GIOChannel *channel, - gboolean do_close); -GLIB_AVAILABLE_IN_ALL -gboolean g_io_channel_get_close_on_unref (GIOChannel *channel); - - -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_flush (GIOChannel *channel, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_read_line (GIOChannel *channel, - gchar **str_return, - gsize *length, - gsize *terminator_pos, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_read_line_string (GIOChannel *channel, - GString *buffer, - gsize *terminator_pos, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_read_to_end (GIOChannel *channel, - gchar **str_return, - gsize *length, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_read_chars (GIOChannel *channel, - gchar *buf, - gsize count, - gsize *bytes_read, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_read_unichar (GIOChannel *channel, - gunichar *thechar, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_write_chars (GIOChannel *channel, - const gchar *buf, - gssize count, - gsize *bytes_written, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_write_unichar (GIOChannel *channel, - gunichar thechar, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOStatus g_io_channel_seek_position (GIOChannel *channel, - gint64 offset, - GSeekType type, - GError **error); -GLIB_AVAILABLE_IN_ALL -GIOChannel* g_io_channel_new_file (const gchar *filename, - const gchar *mode, - GError **error); - -/* Error handling */ - -GLIB_AVAILABLE_IN_ALL -GQuark g_io_channel_error_quark (void); -GLIB_AVAILABLE_IN_ALL -GIOChannelError g_io_channel_error_from_errno (gint en); - -/* On Unix, IO channels created with this function for any file - * descriptor or socket. - * - * On Win32, this can be used either for files opened with the MSVCRT - * (the Microsoft run-time C library) _open() or _pipe, including file - * descriptors 0, 1 and 2 (corresponding to stdin, stdout and stderr), - * or for Winsock SOCKETs. If the parameter is a legal file - * descriptor, it is assumed to be such, otherwise it should be a - * SOCKET. This relies on SOCKETs and file descriptors not - * overlapping. If you want to be certain, call either - * g_io_channel_win32_new_fd() or g_io_channel_win32_new_socket() - * instead as appropriate. - * - * The term file descriptor as used in the context of Win32 refers to - * the emulated Unix-like file descriptors MSVCRT provides. The native - * corresponding concept is file HANDLE. There isn't as of yet a way to - * get GIOChannels for Win32 file HANDLEs. - */ -GLIB_AVAILABLE_IN_ALL -GIOChannel* g_io_channel_unix_new (int fd); -GLIB_AVAILABLE_IN_ALL -gint g_io_channel_unix_get_fd (GIOChannel *channel); - - -/* Hook for GClosure / GSource integration. Don't touch */ -GLIB_VAR GSourceFuncs g_io_watch_funcs; - -#ifdef G_OS_WIN32 - -/* You can use this "pseudo file descriptor" in a GPollFD to add - * polling for Windows messages. GTK applications should not do that. - */ - -#define G_WIN32_MSG_HANDLE 19981206 - -/* Use this to get a GPollFD from a GIOChannel, so that you can call - * g_io_channel_win32_poll(). After calling this you should only use - * g_io_channel_read() to read from the GIOChannel, i.e. never read() - * from the underlying file descriptor. For SOCKETs, it is possible to call - * recv(). - */ -GLIB_AVAILABLE_IN_ALL -void g_io_channel_win32_make_pollfd (GIOChannel *channel, - GIOCondition condition, - GPollFD *fd); - -/* This can be used to wait until at least one of the channels is readable. - * On Unix you would do a select() on the file descriptors of the channels. - */ -GLIB_AVAILABLE_IN_ALL -gint g_io_channel_win32_poll (GPollFD *fds, - gint n_fds, - gint timeout_); - -/* Create an IO channel for Windows messages for window handle hwnd. */ -#if GLIB_SIZEOF_VOID_P == 8 -/* We use gsize here so that it is still an integer type and not a - * pointer, like the guint in the traditional prototype. We can't use - * intptr_t as that is not portable enough. - */ -GLIB_AVAILABLE_IN_ALL -GIOChannel *g_io_channel_win32_new_messages (gsize hwnd); -#else -GLIB_AVAILABLE_IN_ALL -GIOChannel *g_io_channel_win32_new_messages (guint hwnd); -#endif - -/* Create an IO channel for C runtime (emulated Unix-like) file - * descriptors. After calling g_io_add_watch() on a IO channel - * returned by this function, you shouldn't call read() on the file - * descriptor. This is because adding polling for a file descriptor is - * implemented on Win32 by starting a thread that sits blocked in a - * read() from the file descriptor most of the time. All reads from - * the file descriptor should be done by this internal GLib - * thread. Your code should call only g_io_channel_read_chars(). - */ -GLIB_AVAILABLE_IN_ALL -GIOChannel* g_io_channel_win32_new_fd (gint fd); - -/* Get the C runtime file descriptor of a channel. */ -GLIB_AVAILABLE_IN_ALL -gint g_io_channel_win32_get_fd (GIOChannel *channel); - -/* Create an IO channel for a winsock socket. The parameter should be - * a SOCKET. Contrary to IO channels for file descriptors (on *Win32), - * you can use normal recv() or recvfrom() on sockets even if GLib - * is polling them. - */ -GLIB_AVAILABLE_IN_ALL -GIOChannel *g_io_channel_win32_new_socket (gint socket); - -GLIB_DEPRECATED_FOR(g_io_channel_win32_new_socket) -GIOChannel *g_io_channel_win32_new_stream_socket (gint socket); - -GLIB_AVAILABLE_IN_ALL -void g_io_channel_win32_set_debug (GIOChannel *channel, - gboolean flag); - -#endif - -G_END_DECLS - -#endif /* __G_IOCHANNEL_H__ */ -/* gkeyfile.h - desktop entry file parser - * - * Copyright 2004 Red Hat, Inc. - * - * Ray Strode - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_KEY_FILE_H__ -#define __G_KEY_FILE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef enum -{ - G_KEY_FILE_ERROR_UNKNOWN_ENCODING, - G_KEY_FILE_ERROR_PARSE, - G_KEY_FILE_ERROR_NOT_FOUND, - G_KEY_FILE_ERROR_KEY_NOT_FOUND, - G_KEY_FILE_ERROR_GROUP_NOT_FOUND, - G_KEY_FILE_ERROR_INVALID_VALUE -} GKeyFileError; - -#define G_KEY_FILE_ERROR g_key_file_error_quark() - -GLIB_AVAILABLE_IN_ALL -GQuark g_key_file_error_quark (void); - -typedef struct _GKeyFile GKeyFile; - -typedef enum -{ - G_KEY_FILE_NONE = 0, - G_KEY_FILE_KEEP_COMMENTS = 1 << 0, - G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1 -} GKeyFileFlags; - -GLIB_AVAILABLE_IN_ALL -GKeyFile *g_key_file_new (void); -GLIB_AVAILABLE_IN_ALL -GKeyFile *g_key_file_ref (GKeyFile *key_file); -GLIB_AVAILABLE_IN_ALL -void g_key_file_unref (GKeyFile *key_file); -GLIB_AVAILABLE_IN_ALL -void g_key_file_free (GKeyFile *key_file); -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_list_separator (GKeyFile *key_file, - gchar separator); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_load_from_file (GKeyFile *key_file, - const gchar *file, - GKeyFileFlags flags, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_load_from_data (GKeyFile *key_file, - const gchar *data, - gsize length, - GKeyFileFlags flags, - GError **error); -GLIB_AVAILABLE_IN_2_50 -gboolean g_key_file_load_from_bytes (GKeyFile *key_file, - GBytes *bytes, - GKeyFileFlags flags, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_load_from_dirs (GKeyFile *key_file, - const gchar *file, - const gchar **search_dirs, - gchar **full_path, - GKeyFileFlags flags, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_load_from_data_dirs (GKeyFile *key_file, - const gchar *file, - gchar **full_path, - GKeyFileFlags flags, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar *g_key_file_to_data (GKeyFile *key_file, - gsize *length, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_2_40 -gboolean g_key_file_save_to_file (GKeyFile *key_file, - const gchar *filename, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar *g_key_file_get_start_group (GKeyFile *key_file) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar **g_key_file_get_groups (GKeyFile *key_file, - gsize *length); -GLIB_AVAILABLE_IN_ALL -gchar **g_key_file_get_keys (GKeyFile *key_file, - const gchar *group_name, - gsize *length, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_has_group (GKeyFile *key_file, - const gchar *group_name); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_has_key (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar *g_key_file_get_value (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_value (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar *value); -GLIB_AVAILABLE_IN_ALL -gchar *g_key_file_get_string (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_string (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar *string); -GLIB_AVAILABLE_IN_ALL -gchar *g_key_file_get_locale_string (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar *locale, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_2_56 -gchar *g_key_file_get_locale_for_key (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar *locale) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_locale_string (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar *locale, - const gchar *string); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_get_boolean (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_boolean (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gboolean value); -GLIB_AVAILABLE_IN_ALL -gint g_key_file_get_integer (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_integer (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gint value); -GLIB_AVAILABLE_IN_ALL -gint64 g_key_file_get_int64 (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_int64 (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gint64 value); -GLIB_AVAILABLE_IN_ALL -guint64 g_key_file_get_uint64 (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_uint64 (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - guint64 value); -GLIB_AVAILABLE_IN_ALL -gdouble g_key_file_get_double (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_double (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gdouble value); -GLIB_AVAILABLE_IN_ALL -gchar **g_key_file_get_string_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gsize *length, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_string_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar * const list[], - gsize length); -GLIB_AVAILABLE_IN_ALL -gchar **g_key_file_get_locale_string_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar *locale, - gsize *length, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_locale_string_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar *locale, - const gchar * const list[], - gsize length); -GLIB_AVAILABLE_IN_ALL -gboolean *g_key_file_get_boolean_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gsize *length, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_boolean_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gboolean list[], - gsize length); -GLIB_AVAILABLE_IN_ALL -gint *g_key_file_get_integer_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gsize *length, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_double_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gdouble list[], - gsize length); -GLIB_AVAILABLE_IN_ALL -gdouble *g_key_file_get_double_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gsize *length, - GError **error) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_key_file_set_integer_list (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - gint list[], - gsize length); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_set_comment (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - const gchar *comment, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar *g_key_file_get_comment (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_remove_comment (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_remove_key (GKeyFile *key_file, - const gchar *group_name, - const gchar *key, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_key_file_remove_group (GKeyFile *key_file, - const gchar *group_name, - GError **error); - -/* Defines for handling freedesktop.org Desktop files */ -#define G_KEY_FILE_DESKTOP_GROUP "Desktop Entry" - -#define G_KEY_FILE_DESKTOP_KEY_TYPE "Type" -#define G_KEY_FILE_DESKTOP_KEY_VERSION "Version" -#define G_KEY_FILE_DESKTOP_KEY_NAME "Name" -#define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME "GenericName" -#define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY "NoDisplay" -#define G_KEY_FILE_DESKTOP_KEY_COMMENT "Comment" -#define G_KEY_FILE_DESKTOP_KEY_ICON "Icon" -#define G_KEY_FILE_DESKTOP_KEY_HIDDEN "Hidden" -#define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN "OnlyShowIn" -#define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN "NotShowIn" -#define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC "TryExec" -#define G_KEY_FILE_DESKTOP_KEY_EXEC "Exec" -#define G_KEY_FILE_DESKTOP_KEY_PATH "Path" -#define G_KEY_FILE_DESKTOP_KEY_TERMINAL "Terminal" -#define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE "MimeType" -#define G_KEY_FILE_DESKTOP_KEY_CATEGORIES "Categories" -#define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY "StartupNotify" -#define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass" -#define G_KEY_FILE_DESKTOP_KEY_URL "URL" -#define G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE "DBusActivatable" -#define G_KEY_FILE_DESKTOP_KEY_ACTIONS "Actions" - -#define G_KEY_FILE_DESKTOP_TYPE_APPLICATION "Application" -#define G_KEY_FILE_DESKTOP_TYPE_LINK "Link" -#define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY "Directory" - -G_END_DECLS - -#endif /* __G_KEY_FILE_H__ */ -/* GLIB - Library of useful routines for C programming - * gmappedfile.h: Simplified wrapper around the mmap function - * - * Copyright 2005 Matthias Clasen - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_MAPPED_FILE_H__ -#define __G_MAPPED_FILE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GMappedFile GMappedFile; - -GLIB_AVAILABLE_IN_ALL -GMappedFile *g_mapped_file_new (const gchar *filename, - gboolean writable, - GError **error); -GLIB_AVAILABLE_IN_ALL -GMappedFile *g_mapped_file_new_from_fd (gint fd, - gboolean writable, - GError **error); -GLIB_AVAILABLE_IN_ALL -gsize g_mapped_file_get_length (GMappedFile *file); -GLIB_AVAILABLE_IN_ALL -gchar *g_mapped_file_get_contents (GMappedFile *file); -GLIB_AVAILABLE_IN_2_34 -GBytes * g_mapped_file_get_bytes (GMappedFile *file); -GLIB_AVAILABLE_IN_ALL -GMappedFile *g_mapped_file_ref (GMappedFile *file); -GLIB_AVAILABLE_IN_ALL -void g_mapped_file_unref (GMappedFile *file); - -GLIB_DEPRECATED_FOR(g_mapped_file_unref) -void g_mapped_file_free (GMappedFile *file); - -G_END_DECLS - -#endif /* __G_MAPPED_FILE_H__ */ -/* gmarkup.h - Simple XML-like string parser/writer - * - * Copyright 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_MARKUP_H__ -#define __G_MARKUP_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#include - - -G_BEGIN_DECLS - -/** - * GMarkupError: - * @G_MARKUP_ERROR_BAD_UTF8: text being parsed was not valid UTF-8 - * @G_MARKUP_ERROR_EMPTY: document contained nothing, or only whitespace - * @G_MARKUP_ERROR_PARSE: document was ill-formed - * @G_MARKUP_ERROR_UNKNOWN_ELEMENT: error should be set by #GMarkupParser - * functions; element wasn't known - * @G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE: error should be set by #GMarkupParser - * functions; attribute wasn't known - * @G_MARKUP_ERROR_INVALID_CONTENT: error should be set by #GMarkupParser - * functions; content was invalid - * @G_MARKUP_ERROR_MISSING_ATTRIBUTE: error should be set by #GMarkupParser - * functions; a required attribute was missing - * - * Error codes returned by markup parsing. - */ -typedef enum -{ - G_MARKUP_ERROR_BAD_UTF8, - G_MARKUP_ERROR_EMPTY, - G_MARKUP_ERROR_PARSE, - /* The following are primarily intended for specific GMarkupParser - * implementations to set. - */ - G_MARKUP_ERROR_UNKNOWN_ELEMENT, - G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, - G_MARKUP_ERROR_INVALID_CONTENT, - G_MARKUP_ERROR_MISSING_ATTRIBUTE -} GMarkupError; - -/** - * G_MARKUP_ERROR: - * - * Error domain for markup parsing. - * Errors in this domain will be from the #GMarkupError enumeration. - * See #GError for information on error domains. - */ -#define G_MARKUP_ERROR g_markup_error_quark () - -GLIB_AVAILABLE_IN_ALL -GQuark g_markup_error_quark (void); - -/** - * GMarkupParseFlags: - * @G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG: flag you should not use - * @G_MARKUP_TREAT_CDATA_AS_TEXT: When this flag is set, CDATA marked - * sections are not passed literally to the @passthrough function of - * the parser. Instead, the content of the section (without the - * ``) is - * passed to the @text function. This flag was added in GLib 2.12 - * @G_MARKUP_PREFIX_ERROR_POSITION: Normally errors caught by GMarkup - * itself have line/column information prefixed to them to let the - * caller know the location of the error. When this flag is set the - * location information is also prefixed to errors generated by the - * #GMarkupParser implementation functions - * @G_MARKUP_IGNORE_QUALIFIED: Ignore (don't report) qualified - * attributes and tags, along with their contents. A qualified - * attribute or tag is one that contains ':' in its name (ie: is in - * another namespace). Since: 2.40. - * - * Flags that affect the behaviour of the parser. - */ -typedef enum -{ - G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0, - G_MARKUP_TREAT_CDATA_AS_TEXT = 1 << 1, - G_MARKUP_PREFIX_ERROR_POSITION = 1 << 2, - G_MARKUP_IGNORE_QUALIFIED = 1 << 3 -} GMarkupParseFlags; - -/** - * GMarkupParseContext: - * - * A parse context is used to parse a stream of bytes that - * you expect to contain marked-up text. - * - * See g_markup_parse_context_new(), #GMarkupParser, and so - * on for more details. - */ -typedef struct _GMarkupParseContext GMarkupParseContext; -typedef struct _GMarkupParser GMarkupParser; - -/** - * GMarkupParser: - * @start_element: Callback to invoke when the opening tag of an element - * is seen. The callback's @attribute_names and @attribute_values parameters - * are %NULL-terminated. - * @end_element: Callback to invoke when the closing tag of an element - * is seen. Note that this is also called for empty tags like - * ``. - * @text: Callback to invoke when some text is seen (text is always - * inside an element). Note that the text of an element may be spread - * over multiple calls of this function. If the - * %G_MARKUP_TREAT_CDATA_AS_TEXT flag is set, this function is also - * called for the content of CDATA marked sections. - * @passthrough: Callback to invoke for comments, processing instructions - * and doctype declarations; if you're re-writing the parsed document, - * write the passthrough text back out in the same position. If the - * %G_MARKUP_TREAT_CDATA_AS_TEXT flag is not set, this function is also - * called for CDATA marked sections. - * @error: Callback to invoke when an error occurs. - * - * Any of the fields in #GMarkupParser can be %NULL, in which case they - * will be ignored. Except for the @error function, any of these callbacks - * can set an error; in particular the %G_MARKUP_ERROR_UNKNOWN_ELEMENT, - * %G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and %G_MARKUP_ERROR_INVALID_CONTENT - * errors are intended to be set from these callbacks. If you set an error - * from a callback, g_markup_parse_context_parse() will report that error - * back to its caller. - */ -struct _GMarkupParser -{ - /* Called for open tags */ - void (*start_element) (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error); - - /* Called for close tags */ - void (*end_element) (GMarkupParseContext *context, - const gchar *element_name, - gpointer user_data, - GError **error); - - /* Called for character data */ - /* text is not nul-terminated */ - void (*text) (GMarkupParseContext *context, - const gchar *text, - gsize text_len, - gpointer user_data, - GError **error); - - /* Called for strings that should be re-saved verbatim in this same - * position, but are not otherwise interpretable. At the moment - * this includes comments and processing instructions. - */ - /* text is not nul-terminated. */ - void (*passthrough) (GMarkupParseContext *context, - const gchar *passthrough_text, - gsize text_len, - gpointer user_data, - GError **error); - - /* Called on error, including one set by other - * methods in the vtable. The GError should not be freed. - */ - void (*error) (GMarkupParseContext *context, - GError *error, - gpointer user_data); -}; - -GLIB_AVAILABLE_IN_ALL -GMarkupParseContext *g_markup_parse_context_new (const GMarkupParser *parser, - GMarkupParseFlags flags, - gpointer user_data, - GDestroyNotify user_data_dnotify); -GLIB_AVAILABLE_IN_2_36 -GMarkupParseContext *g_markup_parse_context_ref (GMarkupParseContext *context); -GLIB_AVAILABLE_IN_2_36 -void g_markup_parse_context_unref (GMarkupParseContext *context); -GLIB_AVAILABLE_IN_ALL -void g_markup_parse_context_free (GMarkupParseContext *context); -GLIB_AVAILABLE_IN_ALL -gboolean g_markup_parse_context_parse (GMarkupParseContext *context, - const gchar *text, - gssize text_len, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_markup_parse_context_push (GMarkupParseContext *context, - const GMarkupParser *parser, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -gpointer g_markup_parse_context_pop (GMarkupParseContext *context); - -GLIB_AVAILABLE_IN_ALL -gboolean g_markup_parse_context_end_parse (GMarkupParseContext *context, - GError **error); -GLIB_AVAILABLE_IN_ALL -const gchar * g_markup_parse_context_get_element (GMarkupParseContext *context); -GLIB_AVAILABLE_IN_ALL -const GSList * g_markup_parse_context_get_element_stack (GMarkupParseContext *context); - -/* For user-constructed error messages, has no precise semantics */ -GLIB_AVAILABLE_IN_ALL -void g_markup_parse_context_get_position (GMarkupParseContext *context, - gint *line_number, - gint *char_number); -GLIB_AVAILABLE_IN_ALL -gpointer g_markup_parse_context_get_user_data (GMarkupParseContext *context); - -/* useful when saving */ -GLIB_AVAILABLE_IN_ALL -gchar* g_markup_escape_text (const gchar *text, - gssize length); - -GLIB_AVAILABLE_IN_ALL -gchar *g_markup_printf_escaped (const char *format, - ...) G_GNUC_PRINTF (1, 2); -GLIB_AVAILABLE_IN_ALL -gchar *g_markup_vprintf_escaped (const char *format, - va_list args) G_GNUC_PRINTF(1, 0); - -typedef enum -{ - G_MARKUP_COLLECT_INVALID, - G_MARKUP_COLLECT_STRING, - G_MARKUP_COLLECT_STRDUP, - G_MARKUP_COLLECT_BOOLEAN, - G_MARKUP_COLLECT_TRISTATE, - - G_MARKUP_COLLECT_OPTIONAL = (1 << 16) -} GMarkupCollectType; - - -/* useful from start_element */ -GLIB_AVAILABLE_IN_ALL -gboolean g_markup_collect_attributes (const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - GError **error, - GMarkupCollectType first_type, - const gchar *first_attr, - ...); - -G_END_DECLS - -#endif /* __G_MARKUP_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_MESSAGES_H__ -#define __G_MESSAGES_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#include -/* - * Copyright © 2007, 2008 Ryan Lortie - * Copyright © 2009, 2010 Codethink Limited - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Author: Ryan Lortie - */ - -#ifndef __G_VARIANT_H__ -#define __G_VARIANT_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -/* - * Copyright © 2007, 2008 Ryan Lortie - * Copyright © 2009, 2010 Codethink Limited - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Author: Ryan Lortie - */ - -#ifndef __G_VARIANT_TYPE_H__ -#define __G_VARIANT_TYPE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * GVariantType: - * - * A type in the GVariant type system. - * - * Two types may not be compared by value; use g_variant_type_equal() or - * g_variant_type_is_subtype_of(). May be copied using - * g_variant_type_copy() and freed using g_variant_type_free(). - **/ -typedef struct _GVariantType GVariantType; - -/** - * G_VARIANT_TYPE_BOOLEAN: - * - * The type of a value that can be either %TRUE or %FALSE. - **/ -#define G_VARIANT_TYPE_BOOLEAN ((const GVariantType *) "b") - -/** - * G_VARIANT_TYPE_BYTE: - * - * The type of an integer value that can range from 0 to 255. - **/ -#define G_VARIANT_TYPE_BYTE ((const GVariantType *) "y") - -/** - * G_VARIANT_TYPE_INT16: - * - * The type of an integer value that can range from -32768 to 32767. - **/ -#define G_VARIANT_TYPE_INT16 ((const GVariantType *) "n") - -/** - * G_VARIANT_TYPE_UINT16: - * - * The type of an integer value that can range from 0 to 65535. - * There were about this many people living in Toronto in the 1870s. - **/ -#define G_VARIANT_TYPE_UINT16 ((const GVariantType *) "q") - -/** - * G_VARIANT_TYPE_INT32: - * - * The type of an integer value that can range from -2147483648 to - * 2147483647. - **/ -#define G_VARIANT_TYPE_INT32 ((const GVariantType *) "i") - -/** - * G_VARIANT_TYPE_UINT32: - * - * The type of an integer value that can range from 0 to 4294967295. - * That's one number for everyone who was around in the late 1970s. - **/ -#define G_VARIANT_TYPE_UINT32 ((const GVariantType *) "u") - -/** - * G_VARIANT_TYPE_INT64: - * - * The type of an integer value that can range from - * -9223372036854775808 to 9223372036854775807. - **/ -#define G_VARIANT_TYPE_INT64 ((const GVariantType *) "x") - -/** - * G_VARIANT_TYPE_UINT64: - * - * The type of an integer value that can range from 0 - * to 18446744073709551615 (inclusive). That's a really big number, - * but a Rubik's cube can have a bit more than twice as many possible - * positions. - **/ -#define G_VARIANT_TYPE_UINT64 ((const GVariantType *) "t") - -/** - * G_VARIANT_TYPE_DOUBLE: - * - * The type of a double precision IEEE754 floating point number. - * These guys go up to about 1.80e308 (plus and minus) but miss out on - * some numbers in between. In any case, that's far greater than the - * estimated number of fundamental particles in the observable - * universe. - **/ -#define G_VARIANT_TYPE_DOUBLE ((const GVariantType *) "d") - -/** - * G_VARIANT_TYPE_STRING: - * - * The type of a string. "" is a string. %NULL is not a string. - **/ -#define G_VARIANT_TYPE_STRING ((const GVariantType *) "s") - -/** - * G_VARIANT_TYPE_OBJECT_PATH: - * - * The type of a D-Bus object reference. These are strings of a - * specific format used to identify objects at a given destination on - * the bus. - * - * If you are not interacting with D-Bus, then there is no reason to make - * use of this type. If you are, then the D-Bus specification contains a - * precise description of valid object paths. - **/ -#define G_VARIANT_TYPE_OBJECT_PATH ((const GVariantType *) "o") - -/** - * G_VARIANT_TYPE_SIGNATURE: - * - * The type of a D-Bus type signature. These are strings of a specific - * format used as type signatures for D-Bus methods and messages. - * - * If you are not interacting with D-Bus, then there is no reason to make - * use of this type. If you are, then the D-Bus specification contains a - * precise description of valid signature strings. - **/ -#define G_VARIANT_TYPE_SIGNATURE ((const GVariantType *) "g") - -/** - * G_VARIANT_TYPE_VARIANT: - * - * The type of a box that contains any other value (including another - * variant). - **/ -#define G_VARIANT_TYPE_VARIANT ((const GVariantType *) "v") - -/** - * G_VARIANT_TYPE_HANDLE: - * - * The type of a 32bit signed integer value, that by convention, is used - * as an index into an array of file descriptors that are sent alongside - * a D-Bus message. - * - * If you are not interacting with D-Bus, then there is no reason to make - * use of this type. - **/ -#define G_VARIANT_TYPE_HANDLE ((const GVariantType *) "h") - -/** - * G_VARIANT_TYPE_UNIT: - * - * The empty tuple type. Has only one instance. Known also as "triv" - * or "void". - **/ -#define G_VARIANT_TYPE_UNIT ((const GVariantType *) "()") - -/** - * G_VARIANT_TYPE_ANY: - * - * An indefinite type that is a supertype of every type (including - * itself). - **/ -#define G_VARIANT_TYPE_ANY ((const GVariantType *) "*") - -/** - * G_VARIANT_TYPE_BASIC: - * - * An indefinite type that is a supertype of every basic (ie: - * non-container) type. - **/ -#define G_VARIANT_TYPE_BASIC ((const GVariantType *) "?") - -/** - * G_VARIANT_TYPE_MAYBE: - * - * An indefinite type that is a supertype of every maybe type. - **/ -#define G_VARIANT_TYPE_MAYBE ((const GVariantType *) "m*") - -/** - * G_VARIANT_TYPE_ARRAY: - * - * An indefinite type that is a supertype of every array type. - **/ -#define G_VARIANT_TYPE_ARRAY ((const GVariantType *) "a*") - -/** - * G_VARIANT_TYPE_TUPLE: - * - * An indefinite type that is a supertype of every tuple type, - * regardless of the number of items in the tuple. - **/ -#define G_VARIANT_TYPE_TUPLE ((const GVariantType *) "r") - -/** - * G_VARIANT_TYPE_DICT_ENTRY: - * - * An indefinite type that is a supertype of every dictionary entry - * type. - **/ -#define G_VARIANT_TYPE_DICT_ENTRY ((const GVariantType *) "{?*}") - -/** - * G_VARIANT_TYPE_DICTIONARY: - * - * An indefinite type that is a supertype of every dictionary type -- - * that is, any array type that has an element type equal to any - * dictionary entry type. - **/ -#define G_VARIANT_TYPE_DICTIONARY ((const GVariantType *) "a{?*}") - -/** - * G_VARIANT_TYPE_STRING_ARRAY: - * - * The type of an array of strings. - **/ -#define G_VARIANT_TYPE_STRING_ARRAY ((const GVariantType *) "as") - -/** - * G_VARIANT_TYPE_OBJECT_PATH_ARRAY: - * - * The type of an array of object paths. - **/ -#define G_VARIANT_TYPE_OBJECT_PATH_ARRAY ((const GVariantType *) "ao") - -/** - * G_VARIANT_TYPE_BYTESTRING: - * - * The type of an array of bytes. This type is commonly used to pass - * around strings that may not be valid utf8. In that case, the - * convention is that the nul terminator character should be included as - * the last character in the array. - **/ -#define G_VARIANT_TYPE_BYTESTRING ((const GVariantType *) "ay") - -/** - * G_VARIANT_TYPE_BYTESTRING_ARRAY: - * - * The type of an array of byte strings (an array of arrays of bytes). - **/ -#define G_VARIANT_TYPE_BYTESTRING_ARRAY ((const GVariantType *) "aay") - -/** - * G_VARIANT_TYPE_VARDICT: - * - * The type of a dictionary mapping strings to variants (the ubiquitous - * "a{sv}" type). - * - * Since: 2.30 - **/ -#define G_VARIANT_TYPE_VARDICT ((const GVariantType *) "a{sv}") - - -/** - * G_VARIANT_TYPE: - * @type_string: a well-formed #GVariantType type string - * - * Converts a string to a const #GVariantType. Depending on the - * current debugging level, this function may perform a runtime check - * to ensure that @string is a valid GVariant type string. - * - * It is always a programmer error to use this macro with an invalid - * type string. If in doubt, use g_variant_type_string_is_valid() to - * check if the string is valid. - * - * Since 2.24 - **/ -#ifndef G_DISABLE_CHECKS -# define G_VARIANT_TYPE(type_string) (g_variant_type_checked_ ((type_string))) -#else -# define G_VARIANT_TYPE(type_string) ((const GVariantType *) (type_string)) -#endif - -/* type string checking */ -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_string_is_valid (const gchar *type_string); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_string_scan (const gchar *string, - const gchar *limit, - const gchar **endptr); - -/* create/destroy */ -GLIB_AVAILABLE_IN_ALL -void g_variant_type_free (GVariantType *type); -GLIB_AVAILABLE_IN_ALL -GVariantType * g_variant_type_copy (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -GVariantType * g_variant_type_new (const gchar *type_string); - -/* getters */ -GLIB_AVAILABLE_IN_ALL -gsize g_variant_type_get_string_length (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -const gchar * g_variant_type_peek_string (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gchar * g_variant_type_dup_string (const GVariantType *type); - -/* classification */ -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_definite (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_container (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_basic (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_maybe (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_array (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_tuple (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_dict_entry (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_variant (const GVariantType *type); - -/* for hash tables */ -GLIB_AVAILABLE_IN_ALL -guint g_variant_type_hash (gconstpointer type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_equal (gconstpointer type1, - gconstpointer type2); - -/* subtypes */ -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_type_is_subtype_of (const GVariantType *type, - const GVariantType *supertype); - -/* type iterator interface */ -GLIB_AVAILABLE_IN_ALL -const GVariantType * g_variant_type_element (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -const GVariantType * g_variant_type_first (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -const GVariantType * g_variant_type_next (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gsize g_variant_type_n_items (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -const GVariantType * g_variant_type_key (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -const GVariantType * g_variant_type_value (const GVariantType *type); - -/* constructors */ -GLIB_AVAILABLE_IN_ALL -GVariantType * g_variant_type_new_array (const GVariantType *element); -GLIB_AVAILABLE_IN_ALL -GVariantType * g_variant_type_new_maybe (const GVariantType *element); -GLIB_AVAILABLE_IN_ALL -GVariantType * g_variant_type_new_tuple (const GVariantType * const *items, - gint length); -GLIB_AVAILABLE_IN_ALL -GVariantType * g_variant_type_new_dict_entry (const GVariantType *key, - const GVariantType *value); - -/*< private >*/ -GLIB_AVAILABLE_IN_ALL -const GVariantType * g_variant_type_checked_ (const gchar *); -GLIB_AVAILABLE_IN_2_60 -gsize g_variant_type_string_get_depth_ (const gchar *type_string); - -G_END_DECLS - -#endif /* __G_VARIANT_TYPE_H__ */ - -G_BEGIN_DECLS - -typedef struct _GVariant GVariant; - -typedef enum -{ - G_VARIANT_CLASS_BOOLEAN = 'b', - G_VARIANT_CLASS_BYTE = 'y', - G_VARIANT_CLASS_INT16 = 'n', - G_VARIANT_CLASS_UINT16 = 'q', - G_VARIANT_CLASS_INT32 = 'i', - G_VARIANT_CLASS_UINT32 = 'u', - G_VARIANT_CLASS_INT64 = 'x', - G_VARIANT_CLASS_UINT64 = 't', - G_VARIANT_CLASS_HANDLE = 'h', - G_VARIANT_CLASS_DOUBLE = 'd', - G_VARIANT_CLASS_STRING = 's', - G_VARIANT_CLASS_OBJECT_PATH = 'o', - G_VARIANT_CLASS_SIGNATURE = 'g', - G_VARIANT_CLASS_VARIANT = 'v', - G_VARIANT_CLASS_MAYBE = 'm', - G_VARIANT_CLASS_ARRAY = 'a', - G_VARIANT_CLASS_TUPLE = '(', - G_VARIANT_CLASS_DICT_ENTRY = '{' -} GVariantClass; - -GLIB_AVAILABLE_IN_ALL -void g_variant_unref (GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_ref (GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_ref_sink (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_is_floating (GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_take_ref (GVariant *value); - -GLIB_AVAILABLE_IN_ALL -const GVariantType * g_variant_get_type (GVariant *value); -GLIB_AVAILABLE_IN_ALL -const gchar * g_variant_get_type_string (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_is_of_type (GVariant *value, - const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_is_container (GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariantClass g_variant_classify (GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_boolean (gboolean value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_byte (guint8 value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_int16 (gint16 value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_uint16 (guint16 value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_int32 (gint32 value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_uint32 (guint32 value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_int64 (gint64 value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_uint64 (guint64 value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_handle (gint32 value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_double (gdouble value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_string (const gchar *string); -GLIB_AVAILABLE_IN_2_38 -GVariant * g_variant_new_take_string (gchar *string); -GLIB_AVAILABLE_IN_2_38 -GVariant * g_variant_new_printf (const gchar *format_string, - ...) G_GNUC_PRINTF (1, 2); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_object_path (const gchar *object_path); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_is_object_path (const gchar *string); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_signature (const gchar *signature); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_is_signature (const gchar *string); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_variant (GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_strv (const gchar * const *strv, - gssize length); -GLIB_AVAILABLE_IN_2_30 -GVariant * g_variant_new_objv (const gchar * const *strv, - gssize length); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_bytestring (const gchar *string); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_bytestring_array (const gchar * const *strv, - gssize length); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_fixed_array (const GVariantType *element_type, - gconstpointer elements, - gsize n_elements, - gsize element_size); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_get_boolean (GVariant *value); -GLIB_AVAILABLE_IN_ALL -guint8 g_variant_get_byte (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gint16 g_variant_get_int16 (GVariant *value); -GLIB_AVAILABLE_IN_ALL -guint16 g_variant_get_uint16 (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gint32 g_variant_get_int32 (GVariant *value); -GLIB_AVAILABLE_IN_ALL -guint32 g_variant_get_uint32 (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gint64 g_variant_get_int64 (GVariant *value); -GLIB_AVAILABLE_IN_ALL -guint64 g_variant_get_uint64 (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gint32 g_variant_get_handle (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gdouble g_variant_get_double (GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_get_variant (GVariant *value); -GLIB_AVAILABLE_IN_ALL -const gchar * g_variant_get_string (GVariant *value, - gsize *length); -GLIB_AVAILABLE_IN_ALL -gchar * g_variant_dup_string (GVariant *value, - gsize *length); -GLIB_AVAILABLE_IN_ALL -const gchar ** g_variant_get_strv (GVariant *value, - gsize *length); -GLIB_AVAILABLE_IN_ALL -gchar ** g_variant_dup_strv (GVariant *value, - gsize *length); -GLIB_AVAILABLE_IN_2_30 -const gchar ** g_variant_get_objv (GVariant *value, - gsize *length); -GLIB_AVAILABLE_IN_ALL -gchar ** g_variant_dup_objv (GVariant *value, - gsize *length); -GLIB_AVAILABLE_IN_ALL -const gchar * g_variant_get_bytestring (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gchar * g_variant_dup_bytestring (GVariant *value, - gsize *length); -GLIB_AVAILABLE_IN_ALL -const gchar ** g_variant_get_bytestring_array (GVariant *value, - gsize *length); -GLIB_AVAILABLE_IN_ALL -gchar ** g_variant_dup_bytestring_array (GVariant *value, - gsize *length); - -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_maybe (const GVariantType *child_type, - GVariant *child); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_array (const GVariantType *child_type, - GVariant * const *children, - gsize n_children); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_tuple (GVariant * const *children, - gsize n_children); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_dict_entry (GVariant *key, - GVariant *value); - -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_get_maybe (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gsize g_variant_n_children (GVariant *value); -GLIB_AVAILABLE_IN_ALL -void g_variant_get_child (GVariant *value, - gsize index_, - const gchar *format_string, - ...); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_get_child_value (GVariant *value, - gsize index_); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_lookup (GVariant *dictionary, - const gchar *key, - const gchar *format_string, - ...); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_lookup_value (GVariant *dictionary, - const gchar *key, - const GVariantType *expected_type); -GLIB_AVAILABLE_IN_ALL -gconstpointer g_variant_get_fixed_array (GVariant *value, - gsize *n_elements, - gsize element_size); - -GLIB_AVAILABLE_IN_ALL -gsize g_variant_get_size (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gconstpointer g_variant_get_data (GVariant *value); -GLIB_AVAILABLE_IN_2_36 -GBytes * g_variant_get_data_as_bytes (GVariant *value); -GLIB_AVAILABLE_IN_ALL -void g_variant_store (GVariant *value, - gpointer data); - -GLIB_AVAILABLE_IN_ALL -gchar * g_variant_print (GVariant *value, - gboolean type_annotate); -GLIB_AVAILABLE_IN_ALL -GString * g_variant_print_string (GVariant *value, - GString *string, - gboolean type_annotate); - -GLIB_AVAILABLE_IN_ALL -guint g_variant_hash (gconstpointer value); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_equal (gconstpointer one, - gconstpointer two); - -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_get_normal_form (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_is_normal_form (GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_byteswap (GVariant *value); - -GLIB_AVAILABLE_IN_2_36 -GVariant * g_variant_new_from_bytes (const GVariantType *type, - GBytes *bytes, - gboolean trusted); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_from_data (const GVariantType *type, - gconstpointer data, - gsize size, - gboolean trusted, - GDestroyNotify notify, - gpointer user_data); - -typedef struct _GVariantIter GVariantIter; -struct _GVariantIter { - /*< private >*/ - gsize x[16]; -}; - -GLIB_AVAILABLE_IN_ALL -GVariantIter * g_variant_iter_new (GVariant *value); -GLIB_AVAILABLE_IN_ALL -gsize g_variant_iter_init (GVariantIter *iter, - GVariant *value); -GLIB_AVAILABLE_IN_ALL -GVariantIter * g_variant_iter_copy (GVariantIter *iter); -GLIB_AVAILABLE_IN_ALL -gsize g_variant_iter_n_children (GVariantIter *iter); -GLIB_AVAILABLE_IN_ALL -void g_variant_iter_free (GVariantIter *iter); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_iter_next_value (GVariantIter *iter); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_iter_next (GVariantIter *iter, - const gchar *format_string, - ...); -GLIB_AVAILABLE_IN_ALL -gboolean g_variant_iter_loop (GVariantIter *iter, - const gchar *format_string, - ...); - - -typedef struct _GVariantBuilder GVariantBuilder; -struct _GVariantBuilder { - /*< private >*/ - union - { - struct { - gsize partial_magic; - const GVariantType *type; - gsize y[14]; - } s; - gsize x[16]; - } u; -}; - -typedef enum -{ - G_VARIANT_PARSE_ERROR_FAILED, - G_VARIANT_PARSE_ERROR_BASIC_TYPE_EXPECTED, - G_VARIANT_PARSE_ERROR_CANNOT_INFER_TYPE, - G_VARIANT_PARSE_ERROR_DEFINITE_TYPE_EXPECTED, - G_VARIANT_PARSE_ERROR_INPUT_NOT_AT_END, - G_VARIANT_PARSE_ERROR_INVALID_CHARACTER, - G_VARIANT_PARSE_ERROR_INVALID_FORMAT_STRING, - G_VARIANT_PARSE_ERROR_INVALID_OBJECT_PATH, - G_VARIANT_PARSE_ERROR_INVALID_SIGNATURE, - G_VARIANT_PARSE_ERROR_INVALID_TYPE_STRING, - G_VARIANT_PARSE_ERROR_NO_COMMON_TYPE, - G_VARIANT_PARSE_ERROR_NUMBER_OUT_OF_RANGE, - G_VARIANT_PARSE_ERROR_NUMBER_TOO_BIG, - G_VARIANT_PARSE_ERROR_TYPE_ERROR, - G_VARIANT_PARSE_ERROR_UNEXPECTED_TOKEN, - G_VARIANT_PARSE_ERROR_UNKNOWN_KEYWORD, - G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT, - G_VARIANT_PARSE_ERROR_VALUE_EXPECTED, - G_VARIANT_PARSE_ERROR_RECURSION -} GVariantParseError; -#define G_VARIANT_PARSE_ERROR (g_variant_parse_error_quark ()) - -GLIB_DEPRECATED_IN_2_38_FOR(g_variant_parse_error_quark) -GQuark g_variant_parser_get_error_quark (void); - -GLIB_AVAILABLE_IN_ALL -GQuark g_variant_parse_error_quark (void); - -/** - * G_VARIANT_BUILDER_INIT: - * @variant_type: a const GVariantType* - * - * A stack-allocated #GVariantBuilder must be initialized if it is - * used together with g_auto() to avoid warnings or crashes if - * function returns before g_variant_builder_init() is called on the - * builder. This macro can be used as initializer instead of an - * explicit zeroing a variable when declaring it and a following - * g_variant_builder_init(), but it cannot be assigned to a variable. - * - * The passed @variant_type should be a static GVariantType to avoid - * lifetime issues, as copying the @variant_type does not happen in - * the G_VARIANT_BUILDER_INIT() call, but rather in functions that - * make sure that #GVariantBuilder is valid. - * - * |[ - * g_auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_BYTESTRING); - * ]| - * - * Since: 2.50 - */ -#define G_VARIANT_BUILDER_INIT(variant_type) { { { 2942751021u, variant_type, { 0, } } } } - -GLIB_AVAILABLE_IN_ALL -GVariantBuilder * g_variant_builder_new (const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -void g_variant_builder_unref (GVariantBuilder *builder); -GLIB_AVAILABLE_IN_ALL -GVariantBuilder * g_variant_builder_ref (GVariantBuilder *builder); -GLIB_AVAILABLE_IN_ALL -void g_variant_builder_init (GVariantBuilder *builder, - const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_builder_end (GVariantBuilder *builder); -GLIB_AVAILABLE_IN_ALL -void g_variant_builder_clear (GVariantBuilder *builder); -GLIB_AVAILABLE_IN_ALL -void g_variant_builder_open (GVariantBuilder *builder, - const GVariantType *type); -GLIB_AVAILABLE_IN_ALL -void g_variant_builder_close (GVariantBuilder *builder); -GLIB_AVAILABLE_IN_ALL -void g_variant_builder_add_value (GVariantBuilder *builder, - GVariant *value); -GLIB_AVAILABLE_IN_ALL -void g_variant_builder_add (GVariantBuilder *builder, - const gchar *format_string, - ...); -GLIB_AVAILABLE_IN_ALL -void g_variant_builder_add_parsed (GVariantBuilder *builder, - const gchar *format, - ...); - -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new (const gchar *format_string, - ...); -GLIB_AVAILABLE_IN_ALL -void g_variant_get (GVariant *value, - const gchar *format_string, - ...); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_va (const gchar *format_string, - const gchar **endptr, - va_list *app); -GLIB_AVAILABLE_IN_ALL -void g_variant_get_va (GVariant *value, - const gchar *format_string, - const gchar **endptr, - va_list *app); -GLIB_AVAILABLE_IN_2_34 -gboolean g_variant_check_format_string (GVariant *value, - const gchar *format_string, - gboolean copy_only); - -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_parse (const GVariantType *type, - const gchar *text, - const gchar *limit, - const gchar **endptr, - GError **error); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_parsed (const gchar *format, - ...); -GLIB_AVAILABLE_IN_ALL -GVariant * g_variant_new_parsed_va (const gchar *format, - va_list *app); - -GLIB_AVAILABLE_IN_2_40 -gchar * g_variant_parse_error_print_context (GError *error, - const gchar *source_str); - -GLIB_AVAILABLE_IN_ALL -gint g_variant_compare (gconstpointer one, - gconstpointer two); - -typedef struct _GVariantDict GVariantDict; -struct _GVariantDict { - /*< private >*/ - union - { - struct { - GVariant *asv; - gsize partial_magic; - gsize y[14]; - } s; - gsize x[16]; - } u; -}; - -/** - * G_VARIANT_DICT_INIT: - * @asv: (nullable): a GVariant* - * - * A stack-allocated #GVariantDict must be initialized if it is used - * together with g_auto() to avoid warnings or crashes if function - * returns before g_variant_dict_init() is called on the builder. - * This macro can be used as initializer instead of an explicit - * zeroing a variable when declaring it and a following - * g_variant_dict_init(), but it cannot be assigned to a variable. - * - * The passed @asv has to live long enough for #GVariantDict to gather - * the entries from, as the gathering does not happen in the - * G_VARIANT_DICT_INIT() call, but rather in functions that make sure - * that #GVariantDict is valid. In context where the initialization - * value has to be a constant expression, the only possible value of - * @asv is %NULL. It is still possible to call g_variant_dict_init() - * safely with a different @asv right after the variable was - * initialized with G_VARIANT_DICT_INIT(). - * - * |[ - * g_autoptr(GVariant) variant = get_asv_variant (); - * g_auto(GVariantDict) dict = G_VARIANT_DICT_INIT (variant); - * ]| - * - * Since: 2.50 - */ -#define G_VARIANT_DICT_INIT(asv) { { { asv, 3488698669u, { 0, } } } } - -GLIB_AVAILABLE_IN_2_40 -GVariantDict * g_variant_dict_new (GVariant *from_asv); - -GLIB_AVAILABLE_IN_2_40 -void g_variant_dict_init (GVariantDict *dict, - GVariant *from_asv); - -GLIB_AVAILABLE_IN_2_40 -gboolean g_variant_dict_lookup (GVariantDict *dict, - const gchar *key, - const gchar *format_string, - ...); -GLIB_AVAILABLE_IN_2_40 -GVariant * g_variant_dict_lookup_value (GVariantDict *dict, - const gchar *key, - const GVariantType *expected_type); -GLIB_AVAILABLE_IN_2_40 -gboolean g_variant_dict_contains (GVariantDict *dict, - const gchar *key); -GLIB_AVAILABLE_IN_2_40 -void g_variant_dict_insert (GVariantDict *dict, - const gchar *key, - const gchar *format_string, - ...); -GLIB_AVAILABLE_IN_2_40 -void g_variant_dict_insert_value (GVariantDict *dict, - const gchar *key, - GVariant *value); -GLIB_AVAILABLE_IN_2_40 -gboolean g_variant_dict_remove (GVariantDict *dict, - const gchar *key); -GLIB_AVAILABLE_IN_2_40 -void g_variant_dict_clear (GVariantDict *dict); -GLIB_AVAILABLE_IN_2_40 -GVariant * g_variant_dict_end (GVariantDict *dict); -GLIB_AVAILABLE_IN_2_40 -GVariantDict * g_variant_dict_ref (GVariantDict *dict); -GLIB_AVAILABLE_IN_2_40 -void g_variant_dict_unref (GVariantDict *dict); - -G_END_DECLS - -#endif /* __G_VARIANT_H__ */ - -G_BEGIN_DECLS - -/* calculate a string size, guaranteed to fit format + args. - */ -GLIB_AVAILABLE_IN_ALL -gsize g_printf_string_upper_bound (const gchar* format, - va_list args) G_GNUC_PRINTF(1, 0); - -/* Log level shift offset for user defined - * log levels (0-7 are used by GLib). - */ -#define G_LOG_LEVEL_USER_SHIFT (8) - -/* Glib log levels and flags. - */ -typedef enum -{ - /* log flags */ - G_LOG_FLAG_RECURSION = 1 << 0, - G_LOG_FLAG_FATAL = 1 << 1, - - /* GLib log levels */ - G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */ - G_LOG_LEVEL_CRITICAL = 1 << 3, - G_LOG_LEVEL_WARNING = 1 << 4, - G_LOG_LEVEL_MESSAGE = 1 << 5, - G_LOG_LEVEL_INFO = 1 << 6, - G_LOG_LEVEL_DEBUG = 1 << 7, - - G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL) -} GLogLevelFlags; - -/* GLib log levels that are considered fatal by default */ -#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR) - -typedef void (*GLogFunc) (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data); - -/* Logging mechanism - */ -GLIB_AVAILABLE_IN_ALL -guint g_log_set_handler (const gchar *log_domain, - GLogLevelFlags log_levels, - GLogFunc log_func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_46 -guint g_log_set_handler_full (const gchar *log_domain, - GLogLevelFlags log_levels, - GLogFunc log_func, - gpointer user_data, - GDestroyNotify destroy); -GLIB_AVAILABLE_IN_ALL -void g_log_remove_handler (const gchar *log_domain, - guint handler_id); -GLIB_AVAILABLE_IN_ALL -void g_log_default_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer unused_data); -GLIB_AVAILABLE_IN_ALL -GLogFunc g_log_set_default_handler (GLogFunc log_func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -void g_log (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *format, - ...) G_GNUC_PRINTF (3, 4); -GLIB_AVAILABLE_IN_ALL -void g_logv (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *format, - va_list args) G_GNUC_PRINTF(3, 0); -GLIB_AVAILABLE_IN_ALL -GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, - GLogLevelFlags fatal_mask); -GLIB_AVAILABLE_IN_ALL -GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask); - -/* Structured logging mechanism. */ - -/** - * GLogWriterOutput: - * @G_LOG_WRITER_HANDLED: Log writer has handled the log entry. - * @G_LOG_WRITER_UNHANDLED: Log writer could not handle the log entry. - * - * Return values from #GLogWriterFuncs to indicate whether the given log entry - * was successfully handled by the writer, or whether there was an error in - * handling it (and hence a fallback writer should be used). - * - * If a #GLogWriterFunc ignores a log entry, it should return - * %G_LOG_WRITER_HANDLED. - * - * Since: 2.50 - */ -typedef enum -{ - G_LOG_WRITER_HANDLED = 1, - G_LOG_WRITER_UNHANDLED = 0, -} GLogWriterOutput; - -/** - * GLogField: - * @key: field name (UTF-8 string) - * @value: field value (arbitrary bytes) - * @length: length of @value, in bytes, or -1 if it is nul-terminated - * - * Structure representing a single field in a structured log entry. See - * g_log_structured() for details. - * - * Log fields may contain arbitrary values, including binary with embedded nul - * bytes. If the field contains a string, the string must be UTF-8 encoded and - * have a trailing nul byte. Otherwise, @length must be set to a non-negative - * value. - * - * Since: 2.50 - */ -typedef struct _GLogField GLogField; -struct _GLogField -{ - const gchar *key; - gconstpointer value; - gssize length; -}; - -/** - * GLogWriterFunc: - * @log_level: log level of the message - * @fields: (array length=n_fields): fields forming the message - * @n_fields: number of @fields - * @user_data: user data passed to g_log_set_writer_func() - * - * Writer function for log entries. A log entry is a collection of one or more - * #GLogFields, using the standard [field names from journal - * specification](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html). - * See g_log_structured() for more information. - * - * Writer functions must ignore fields which they do not recognise, unless they - * can write arbitrary binary output, as field values may be arbitrary binary. - * - * @log_level is guaranteed to be included in @fields as the `PRIORITY` field, - * but is provided separately for convenience of deciding whether or where to - * output the log entry. - * - * Writer functions should return %G_LOG_WRITER_HANDLED if they handled the log - * message successfully or if they deliberately ignored it. If there was an - * error handling the message (for example, if the writer function is meant to - * send messages to a remote logging server and there is a network error), it - * should return %G_LOG_WRITER_UNHANDLED. This allows writer functions to be - * chained and fall back to simpler handlers in case of failure. - * - * Returns: %G_LOG_WRITER_HANDLED if the log entry was handled successfully; - * %G_LOG_WRITER_UNHANDLED otherwise - * Since: 2.50 - */ -typedef GLogWriterOutput (*GLogWriterFunc) (GLogLevelFlags log_level, - const GLogField *fields, - gsize n_fields, - gpointer user_data); - -GLIB_AVAILABLE_IN_2_50 -void g_log_structured (const gchar *log_domain, - GLogLevelFlags log_level, - ...); -GLIB_AVAILABLE_IN_2_50 -void g_log_structured_array (GLogLevelFlags log_level, - const GLogField *fields, - gsize n_fields); - -GLIB_AVAILABLE_IN_2_50 -void g_log_variant (const gchar *log_domain, - GLogLevelFlags log_level, - GVariant *fields); - -GLIB_AVAILABLE_IN_2_50 -void g_log_set_writer_func (GLogWriterFunc func, - gpointer user_data, - GDestroyNotify user_data_free); - -GLIB_AVAILABLE_IN_2_50 -gboolean g_log_writer_supports_color (gint output_fd); -GLIB_AVAILABLE_IN_2_50 -gboolean g_log_writer_is_journald (gint output_fd); - -GLIB_AVAILABLE_IN_2_50 -gchar *g_log_writer_format_fields (GLogLevelFlags log_level, - const GLogField *fields, - gsize n_fields, - gboolean use_color); - -GLIB_AVAILABLE_IN_2_50 -GLogWriterOutput g_log_writer_journald (GLogLevelFlags log_level, - const GLogField *fields, - gsize n_fields, - gpointer user_data); -GLIB_AVAILABLE_IN_2_50 -GLogWriterOutput g_log_writer_standard_streams (GLogLevelFlags log_level, - const GLogField *fields, - gsize n_fields, - gpointer user_data); -GLIB_AVAILABLE_IN_2_50 -GLogWriterOutput g_log_writer_default (GLogLevelFlags log_level, - const GLogField *fields, - gsize n_fields, - gpointer user_data); - -GLIB_AVAILABLE_IN_2_68 -void g_log_writer_default_set_use_stderr (gboolean use_stderr); -GLIB_AVAILABLE_IN_2_68 -gboolean g_log_writer_default_would_drop (GLogLevelFlags log_level, - const char *log_domain); - -/** - * G_DEBUG_HERE: - * - * A convenience form of g_log_structured(), recommended to be added to - * functions when debugging. It prints the current monotonic time and the code - * location using %G_STRLOC. - * - * Since: 2.50 - */ -#define G_DEBUG_HERE() \ - g_log_structured (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ - "CODE_FILE", __FILE__, \ - "CODE_LINE", G_STRINGIFY (__LINE__), \ - "CODE_FUNC", G_STRFUNC, \ - "MESSAGE", "%" G_GINT64_FORMAT ": %s", \ - g_get_monotonic_time (), G_STRLOC) - -/* internal */ -void _g_log_fallback_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer unused_data); - -/* Internal functions, used to implement the following macros */ -GLIB_AVAILABLE_IN_ALL -void g_return_if_fail_warning (const char *log_domain, - const char *pretty_function, - const char *expression) G_ANALYZER_NORETURN; -GLIB_AVAILABLE_IN_ALL -void g_warn_message (const char *domain, - const char *file, - int line, - const char *func, - const char *warnexpr) G_ANALYZER_NORETURN; -GLIB_DEPRECATED -G_NORETURN -void g_assert_warning (const char *log_domain, - const char *file, - const int line, - const char *pretty_function, - const char *expression); - -GLIB_AVAILABLE_IN_2_56 -void g_log_structured_standard (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *file, - const gchar *line, - const gchar *func, - const gchar *message_format, - ...) G_GNUC_PRINTF (6, 7); - -#ifndef G_LOG_DOMAIN -#define G_LOG_DOMAIN ((gchar*) 0) -#endif /* G_LOG_DOMAIN */ - -#if defined(G_HAVE_ISO_VARARGS) && !G_ANALYZER_ANALYZING -#if defined(G_LOG_USE_STRUCTURED) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 -#define g_error(...) G_STMT_START { \ - g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, __VA_ARGS__); \ - for (;;) ; \ - } G_STMT_END -#define g_message(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, __VA_ARGS__) -#define g_critical(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, __VA_ARGS__) -#define g_warning(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, __VA_ARGS__) -#define g_info(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, __VA_ARGS__) -#define g_debug(...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, __VA_ARGS__) -#else -/* for(;;) ; so that GCC knows that control doesn't go past g_error(). - * Put space before ending semicolon to avoid C++ build warnings. - */ -#define g_error(...) G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_ERROR, \ - __VA_ARGS__); \ - for (;;) ; \ - } G_STMT_END -#define g_message(...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_MESSAGE, \ - __VA_ARGS__) -#define g_critical(...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - __VA_ARGS__) -#define g_warning(...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_WARNING, \ - __VA_ARGS__) -#define g_info(...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_INFO, \ - __VA_ARGS__) -#define g_debug(...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - __VA_ARGS__) -#endif -#elif defined(G_HAVE_GNUC_VARARGS) && !G_ANALYZER_ANALYZING -#if defined(G_LOG_USE_STRUCTURED) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 -#define g_error(format...) G_STMT_START { \ - g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, format); \ - for (;;) ; \ - } G_STMT_END -#define g_message(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, format) -#define g_critical(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, format) -#define g_warning(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, format) -#define g_info(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, format) -#define g_debug(format...) g_log_structured_standard (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \ - __FILE__, G_STRINGIFY (__LINE__), \ - G_STRFUNC, format) -#else -#define g_error(format...) G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_ERROR, \ - format); \ - for (;;) ; \ - } G_STMT_END - -#define g_message(format...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_MESSAGE, \ - format) -#define g_critical(format...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - format) -#define g_warning(format...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_WARNING, \ - format) -#define g_info(format...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_INFO, \ - format) -#define g_debug(format...) g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - format) -#endif -#else /* no varargs macros */ -static G_NORETURN void g_error (const gchar *format, ...) G_ANALYZER_NORETURN; -static void g_critical (const gchar *format, ...) G_ANALYZER_NORETURN; - -static inline void -g_error (const gchar *format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args); - va_end (args); - - for(;;) ; -} -static inline void -g_message (const gchar *format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args); - va_end (args); -} -static inline void -g_critical (const gchar *format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, args); - va_end (args); -} -static inline void -g_warning (const gchar *format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args); - va_end (args); -} -static inline void -g_info (const gchar *format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format, args); - va_end (args); -} -static inline void -g_debug (const gchar *format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args); - va_end (args); -} -#endif /* !__GNUC__ */ - -/** - * g_warning_once: - * @...: format string, followed by parameters to insert - * into the format string (as with printf()) - * - * Logs a warning only once. - * - * g_warning_once() calls g_warning() with the passed message the first time - * the statement is executed; subsequent times it is a no-op. - * - * Note! On platforms where the compiler doesn't support variadic macros, the - * warning is printed each time instead of only once. - * - * Since: 2.64 - */ -#if defined(G_HAVE_ISO_VARARGS) && !G_ANALYZER_ANALYZING -#define g_warning_once(...) \ - G_STMT_START { \ - static int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; /* (atomic) */ \ - if (g_atomic_int_compare_and_exchange (&G_PASTE (_GWarningOnceBoolean, __LINE__), \ - 0, 1)) \ - g_warning (__VA_ARGS__); \ - } G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_64 -#elif defined(G_HAVE_GNUC_VARARGS) && !G_ANALYZER_ANALYZING -#define g_warning_once(format...) \ - G_STMT_START { \ - static int G_PASTE (_GWarningOnceBoolean, __LINE__) = 0; /* (atomic) */ \ - if (g_atomic_int_compare_and_exchange (&G_PASTE (_GWarningOnceBoolean, __LINE__), \ - 0, 1)) \ - g_warning (format); \ - } G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_64 -#else -#define g_warning_once g_warning -#endif - -/** - * GPrintFunc: - * @string: the message to output - * - * Specifies the type of the print handler functions. - * These are called with the complete formatted string to output. - */ -typedef void (*GPrintFunc) (const gchar *string); -GLIB_AVAILABLE_IN_ALL -void g_print (const gchar *format, - ...) G_GNUC_PRINTF (1, 2); -GLIB_AVAILABLE_IN_ALL -GPrintFunc g_set_print_handler (GPrintFunc func); -GLIB_AVAILABLE_IN_ALL -void g_printerr (const gchar *format, - ...) G_GNUC_PRINTF (1, 2); -GLIB_AVAILABLE_IN_ALL -GPrintFunc g_set_printerr_handler (GPrintFunc func); - -/** - * g_warn_if_reached: - * - * Logs a warning. - * - * Since: 2.16 - */ -#define g_warn_if_reached() \ - do { \ - g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); \ - } while (0) - -/** - * g_warn_if_fail: - * @expr: the expression to check - * - * Logs a warning if the expression is not true. - * - * Since: 2.16 - */ -#define g_warn_if_fail(expr) \ - do { \ - if G_LIKELY (expr) ; \ - else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, #expr); \ - } while (0) - -#ifdef G_DISABLE_CHECKS - -/** - * g_return_if_fail: - * @expr: the expression to check - * - * Verifies that the expression @expr, usually representing a precondition, - * evaluates to %TRUE. If the function returns a value, use - * g_return_val_if_fail() instead. - * - * If @expr evaluates to %FALSE, the current function should be considered to - * have undefined behaviour (a programmer error). The only correct solution - * to such an error is to change the module that is calling the current - * function, so that it avoids this incorrect call. - * - * To make this undefined behaviour visible, if @expr evaluates to %FALSE, - * the result is usually that a critical message is logged and the current - * function returns. - * - * If `G_DISABLE_CHECKS` is defined then the check is not performed. You - * should therefore not depend on any side effects of @expr. - * - * To debug failure of a g_return_if_fail() check, run the code under a debugger - * with `G_DEBUG=fatal-criticals` or `G_DEBUG=fatal-warnings` defined in the - * environment (see [Running GLib Applications](glib-running.html)): - * - * |[ - * G_DEBUG=fatal-warnings gdb ./my-program - * ]| - * - * Any unrelated failures can be skipped over in - * [gdb](https://www.gnu.org/software/gdb/) using the `continue` command. - */ -#define g_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END - -/** - * g_return_val_if_fail: - * @expr: the expression to check - * @val: the value to return from the current function - * if the expression is not true - * - * Verifies that the expression @expr, usually representing a precondition, - * evaluates to %TRUE. If the function does not return a value, use - * g_return_if_fail() instead. - * - * If @expr evaluates to %FALSE, the current function should be considered to - * have undefined behaviour (a programmer error). The only correct solution - * to such an error is to change the module that is calling the current - * function, so that it avoids this incorrect call. - * - * To make this undefined behaviour visible, if @expr evaluates to %FALSE, - * the result is usually that a critical message is logged and @val is - * returned from the current function. - * - * If `G_DISABLE_CHECKS` is defined then the check is not performed. You - * should therefore not depend on any side effects of @expr. - * - * See g_return_if_fail() for guidance on how to debug failure of this check. - */ -#define g_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END - -/** - * g_return_if_reached: - * - * Logs a critical message and returns from the current function. - * This can only be used in functions which do not return a value. - * - * See g_return_if_fail() for guidance on how to debug failure of this check. - */ -#define g_return_if_reached() G_STMT_START{ return; }G_STMT_END - -/** - * g_return_val_if_reached: - * @val: the value to return from the current function - * - * Logs a critical message and returns @val. - * - * See g_return_if_fail() for guidance on how to debug failure of this check. - */ -#define g_return_val_if_reached(val) G_STMT_START{ return (val); }G_STMT_END - -#else /* !G_DISABLE_CHECKS */ - -#define g_return_if_fail(expr) \ - G_STMT_START { \ - if (G_LIKELY (expr)) \ - { } \ - else \ - { \ - g_return_if_fail_warning (G_LOG_DOMAIN, \ - G_STRFUNC, \ - #expr); \ - return; \ - } \ - } G_STMT_END - -#define g_return_val_if_fail(expr, val) \ - G_STMT_START { \ - if (G_LIKELY (expr)) \ - { } \ - else \ - { \ - g_return_if_fail_warning (G_LOG_DOMAIN, \ - G_STRFUNC, \ - #expr); \ - return (val); \ - } \ - } G_STMT_END - -#define g_return_if_reached() \ - G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - "file %s: line %d (%s): should not be reached", \ - __FILE__, \ - __LINE__, \ - G_STRFUNC); \ - return; \ - } G_STMT_END - -#define g_return_val_if_reached(val) \ - G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_CRITICAL, \ - "file %s: line %d (%s): should not be reached", \ - __FILE__, \ - __LINE__, \ - G_STRFUNC); \ - return (val); \ - } G_STMT_END - -#endif /* !G_DISABLE_CHECKS */ - -G_END_DECLS - -#endif /* __G_MESSAGES_H__ */ -/* goption.h - Option parser - * - * Copyright (C) 2004 Anders Carlsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_OPTION_H__ -#define __G_OPTION_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * GOptionContext: - * - * A `GOptionContext` struct defines which options - * are accepted by the commandline option parser. The struct has only private - * fields and should not be directly accessed. - */ -typedef struct _GOptionContext GOptionContext; - -/** - * GOptionGroup: - * - * A `GOptionGroup` struct defines the options in a single - * group. The struct has only private fields and should not be directly accessed. - * - * All options in a group share the same translation function. Libraries which - * need to parse commandline options are expected to provide a function for - * getting a `GOptionGroup` holding their options, which - * the application can then add to its #GOptionContext. - */ -typedef struct _GOptionGroup GOptionGroup; -typedef struct _GOptionEntry GOptionEntry; - -/** - * GOptionFlags: - * @G_OPTION_FLAG_NONE: No flags. Since: 2.42. - * @G_OPTION_FLAG_HIDDEN: The option doesn't appear in `--help` output. - * @G_OPTION_FLAG_IN_MAIN: The option appears in the main section of the - * `--help` output, even if it is defined in a group. - * @G_OPTION_FLAG_REVERSE: For options of the %G_OPTION_ARG_NONE kind, this - * flag indicates that the sense of the option is reversed. - * @G_OPTION_FLAG_NO_ARG: For options of the %G_OPTION_ARG_CALLBACK kind, - * this flag indicates that the callback does not take any argument - * (like a %G_OPTION_ARG_NONE option). Since 2.8 - * @G_OPTION_FLAG_FILENAME: For options of the %G_OPTION_ARG_CALLBACK - * kind, this flag indicates that the argument should be passed to the - * callback in the GLib filename encoding rather than UTF-8. Since 2.8 - * @G_OPTION_FLAG_OPTIONAL_ARG: For options of the %G_OPTION_ARG_CALLBACK - * kind, this flag indicates that the argument supply is optional. - * If no argument is given then data of %GOptionParseFunc will be - * set to NULL. Since 2.8 - * @G_OPTION_FLAG_NOALIAS: This flag turns off the automatic conflict - * resolution which prefixes long option names with `groupname-` if - * there is a conflict. This option should only be used in situations - * where aliasing is necessary to model some legacy commandline interface. - * It is not safe to use this option, unless all option groups are under - * your direct control. Since 2.8. - * - * Flags which modify individual options. - */ -typedef enum -{ - G_OPTION_FLAG_NONE = 0, - G_OPTION_FLAG_HIDDEN = 1 << 0, - G_OPTION_FLAG_IN_MAIN = 1 << 1, - G_OPTION_FLAG_REVERSE = 1 << 2, - G_OPTION_FLAG_NO_ARG = 1 << 3, - G_OPTION_FLAG_FILENAME = 1 << 4, - G_OPTION_FLAG_OPTIONAL_ARG = 1 << 5, - G_OPTION_FLAG_NOALIAS = 1 << 6 -} GOptionFlags; - -/** - * GOptionArg: - * @G_OPTION_ARG_NONE: No extra argument. This is useful for simple flags. - * @G_OPTION_ARG_STRING: The option takes a UTF-8 string argument. - * @G_OPTION_ARG_INT: The option takes an integer argument. - * @G_OPTION_ARG_CALLBACK: The option provides a callback (of type - * #GOptionArgFunc) to parse the extra argument. - * @G_OPTION_ARG_FILENAME: The option takes a filename as argument, which will - be in the GLib filename encoding rather than UTF-8. - * @G_OPTION_ARG_STRING_ARRAY: The option takes a string argument, multiple - * uses of the option are collected into an array of strings. - * @G_OPTION_ARG_FILENAME_ARRAY: The option takes a filename as argument, - * multiple uses of the option are collected into an array of strings. - * @G_OPTION_ARG_DOUBLE: The option takes a double argument. The argument - * can be formatted either for the user's locale or for the "C" locale. - * Since 2.12 - * @G_OPTION_ARG_INT64: The option takes a 64-bit integer. Like - * %G_OPTION_ARG_INT but for larger numbers. The number can be in - * decimal base, or in hexadecimal (when prefixed with `0x`, for - * example, `0xffffffff`). Since 2.12 - * - * The #GOptionArg enum values determine which type of extra argument the - * options expect to find. If an option expects an extra argument, it can - * be specified in several ways; with a short option: `-x arg`, with a long - * option: `--name arg` or combined in a single argument: `--name=arg`. - */ -typedef enum -{ - G_OPTION_ARG_NONE, - G_OPTION_ARG_STRING, - G_OPTION_ARG_INT, - G_OPTION_ARG_CALLBACK, - G_OPTION_ARG_FILENAME, - G_OPTION_ARG_STRING_ARRAY, - G_OPTION_ARG_FILENAME_ARRAY, - G_OPTION_ARG_DOUBLE, - G_OPTION_ARG_INT64 -} GOptionArg; - -/** - * GOptionArgFunc: - * @option_name: The name of the option being parsed. This will be either a - * single dash followed by a single letter (for a short name) or two dashes - * followed by a long option name. - * @value: The value to be parsed. - * @data: User data added to the #GOptionGroup containing the option when it - * was created with g_option_group_new() - * @error: A return location for errors. The error code %G_OPTION_ERROR_FAILED - * is intended to be used for errors in #GOptionArgFunc callbacks. - * - * The type of function to be passed as callback for %G_OPTION_ARG_CALLBACK - * options. - * - * Returns: %TRUE if the option was successfully parsed, %FALSE if an error - * occurred, in which case @error should be set with g_set_error() - */ -typedef gboolean (*GOptionArgFunc) (const gchar *option_name, - const gchar *value, - gpointer data, - GError **error); - -/** - * GOptionParseFunc: - * @context: The active #GOptionContext - * @group: The group to which the function belongs - * @data: User data added to the #GOptionGroup containing the option when it - * was created with g_option_group_new() - * @error: A return location for error details - * - * The type of function that can be called before and after parsing. - * - * Returns: %TRUE if the function completed successfully, %FALSE if an error - * occurred, in which case @error should be set with g_set_error() - */ -typedef gboolean (*GOptionParseFunc) (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error); - -/** - * GOptionErrorFunc: - * @context: The active #GOptionContext - * @group: The group to which the function belongs - * @data: User data added to the #GOptionGroup containing the option when it - * was created with g_option_group_new() - * @error: The #GError containing details about the parse error - * - * The type of function to be used as callback when a parse error occurs. - */ -typedef void (*GOptionErrorFunc) (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error); - -/** - * G_OPTION_ERROR: - * - * Error domain for option parsing. Errors in this domain will - * be from the #GOptionError enumeration. See #GError for information on - * error domains. - */ -#define G_OPTION_ERROR (g_option_error_quark ()) - -/** - * GOptionError: - * @G_OPTION_ERROR_UNKNOWN_OPTION: An option was not known to the parser. - * This error will only be reported, if the parser hasn't been instructed - * to ignore unknown options, see g_option_context_set_ignore_unknown_options(). - * @G_OPTION_ERROR_BAD_VALUE: A value couldn't be parsed. - * @G_OPTION_ERROR_FAILED: A #GOptionArgFunc callback failed. - * - * Error codes returned by option parsing. - */ -typedef enum -{ - G_OPTION_ERROR_UNKNOWN_OPTION, - G_OPTION_ERROR_BAD_VALUE, - G_OPTION_ERROR_FAILED -} GOptionError; - -GLIB_AVAILABLE_IN_ALL -GQuark g_option_error_quark (void); - -/** - * GOptionEntry: - * @long_name: The long name of an option can be used to specify it - * in a commandline as `--long_name`. Every option must have a - * long name. To resolve conflicts if multiple option groups contain - * the same long name, it is also possible to specify the option as - * `--groupname-long_name`. - * @short_name: If an option has a short name, it can be specified - * `-short_name` in a commandline. @short_name must be a printable - * ASCII character different from '-', or zero if the option has no - * short name. - * @flags: Flags from #GOptionFlags - * @arg: The type of the option, as a #GOptionArg - * @arg_data: If the @arg type is %G_OPTION_ARG_CALLBACK, then @arg_data - * must point to a #GOptionArgFunc callback function, which will be - * called to handle the extra argument. Otherwise, @arg_data is a - * pointer to a location to store the value, the required type of - * the location depends on the @arg type: - * - %G_OPTION_ARG_NONE: %gboolean - * - %G_OPTION_ARG_STRING: %gchar* - * - %G_OPTION_ARG_INT: %gint - * - %G_OPTION_ARG_FILENAME: %gchar* - * - %G_OPTION_ARG_STRING_ARRAY: %gchar** - * - %G_OPTION_ARG_FILENAME_ARRAY: %gchar** - * - %G_OPTION_ARG_DOUBLE: %gdouble - * If @arg type is %G_OPTION_ARG_STRING or %G_OPTION_ARG_FILENAME, - * the location will contain a newly allocated string if the option - * was given. That string needs to be freed by the callee using g_free(). - * Likewise if @arg type is %G_OPTION_ARG_STRING_ARRAY or - * %G_OPTION_ARG_FILENAME_ARRAY, the data should be freed using g_strfreev(). - * @description: the description for the option in `--help` - * output. The @description is translated using the @translate_func - * of the group, see g_option_group_set_translation_domain(). - * @arg_description: The placeholder to use for the extra argument parsed - * by the option in `--help` output. The @arg_description is translated - * using the @translate_func of the group, see - * g_option_group_set_translation_domain(). - * - * A GOptionEntry struct defines a single option. To have an effect, they - * must be added to a #GOptionGroup with g_option_context_add_main_entries() - * or g_option_group_add_entries(). - */ -struct _GOptionEntry -{ - const gchar *long_name; - gchar short_name; - gint flags; - - GOptionArg arg; - gpointer arg_data; - - const gchar *description; - const gchar *arg_description; -}; - -/** - * G_OPTION_REMAINING: - * - * If a long option in the main group has this name, it is not treated as a - * regular option. Instead it collects all non-option arguments which would - * otherwise be left in `argv`. The option must be of type - * %G_OPTION_ARG_CALLBACK, %G_OPTION_ARG_STRING_ARRAY - * or %G_OPTION_ARG_FILENAME_ARRAY. - * - * - * Using #G_OPTION_REMAINING instead of simply scanning `argv` - * for leftover arguments has the advantage that GOption takes care of - * necessary encoding conversions for strings or filenames. - * - * Since: 2.6 - */ -#define G_OPTION_REMAINING "" - -GLIB_AVAILABLE_IN_ALL -GOptionContext *g_option_context_new (const gchar *parameter_string); -GLIB_AVAILABLE_IN_ALL -void g_option_context_set_summary (GOptionContext *context, - const gchar *summary); -GLIB_AVAILABLE_IN_ALL -const gchar * g_option_context_get_summary (GOptionContext *context); -GLIB_AVAILABLE_IN_ALL -void g_option_context_set_description (GOptionContext *context, - const gchar *description); -GLIB_AVAILABLE_IN_ALL -const gchar * g_option_context_get_description (GOptionContext *context); -GLIB_AVAILABLE_IN_ALL -void g_option_context_free (GOptionContext *context); -GLIB_AVAILABLE_IN_ALL -void g_option_context_set_help_enabled (GOptionContext *context, - gboolean help_enabled); -GLIB_AVAILABLE_IN_ALL -gboolean g_option_context_get_help_enabled (GOptionContext *context); -GLIB_AVAILABLE_IN_ALL -void g_option_context_set_ignore_unknown_options (GOptionContext *context, - gboolean ignore_unknown); -GLIB_AVAILABLE_IN_ALL -gboolean g_option_context_get_ignore_unknown_options (GOptionContext *context); - -GLIB_AVAILABLE_IN_2_44 -void g_option_context_set_strict_posix (GOptionContext *context, - gboolean strict_posix); -GLIB_AVAILABLE_IN_2_44 -gboolean g_option_context_get_strict_posix (GOptionContext *context); - -GLIB_AVAILABLE_IN_ALL -void g_option_context_add_main_entries (GOptionContext *context, - const GOptionEntry *entries, - const gchar *translation_domain); -GLIB_AVAILABLE_IN_ALL -gboolean g_option_context_parse (GOptionContext *context, - gint *argc, - gchar ***argv, - GError **error); -GLIB_AVAILABLE_IN_2_40 -gboolean g_option_context_parse_strv (GOptionContext *context, - gchar ***arguments, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_option_context_set_translate_func (GOptionContext *context, - GTranslateFunc func, - gpointer data, - GDestroyNotify destroy_notify); -GLIB_AVAILABLE_IN_ALL -void g_option_context_set_translation_domain (GOptionContext *context, - const gchar *domain); - -GLIB_AVAILABLE_IN_ALL -void g_option_context_add_group (GOptionContext *context, - GOptionGroup *group); -GLIB_AVAILABLE_IN_ALL -void g_option_context_set_main_group (GOptionContext *context, - GOptionGroup *group); -GLIB_AVAILABLE_IN_ALL -GOptionGroup *g_option_context_get_main_group (GOptionContext *context); -GLIB_AVAILABLE_IN_ALL -gchar *g_option_context_get_help (GOptionContext *context, - gboolean main_help, - GOptionGroup *group); - -GLIB_AVAILABLE_IN_ALL -GOptionGroup *g_option_group_new (const gchar *name, - const gchar *description, - const gchar *help_description, - gpointer user_data, - GDestroyNotify destroy); -GLIB_AVAILABLE_IN_ALL -void g_option_group_set_parse_hooks (GOptionGroup *group, - GOptionParseFunc pre_parse_func, - GOptionParseFunc post_parse_func); -GLIB_AVAILABLE_IN_ALL -void g_option_group_set_error_hook (GOptionGroup *group, - GOptionErrorFunc error_func); -GLIB_DEPRECATED_IN_2_44 -void g_option_group_free (GOptionGroup *group); -GLIB_AVAILABLE_IN_2_44 -GOptionGroup *g_option_group_ref (GOptionGroup *group); -GLIB_AVAILABLE_IN_2_44 -void g_option_group_unref (GOptionGroup *group); -GLIB_AVAILABLE_IN_ALL -void g_option_group_add_entries (GOptionGroup *group, - const GOptionEntry *entries); -GLIB_AVAILABLE_IN_ALL -void g_option_group_set_translate_func (GOptionGroup *group, - GTranslateFunc func, - gpointer data, - GDestroyNotify destroy_notify); -GLIB_AVAILABLE_IN_ALL -void g_option_group_set_translation_domain (GOptionGroup *group, - const gchar *domain); - -G_END_DECLS - -#endif /* __G_OPTION_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997, 1999 Peter Mattis, Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_PATTERN_H__ -#define __G_PATTERN_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - - -typedef struct _GPatternSpec GPatternSpec; - -GLIB_AVAILABLE_IN_ALL -GPatternSpec* g_pattern_spec_new (const gchar *pattern); -GLIB_AVAILABLE_IN_ALL -void g_pattern_spec_free (GPatternSpec *pspec); -GLIB_AVAILABLE_IN_ALL -gboolean g_pattern_spec_equal (GPatternSpec *pspec1, - GPatternSpec *pspec2); -GLIB_AVAILABLE_IN_ALL -gboolean g_pattern_match (GPatternSpec *pspec, - guint string_length, - const gchar *string, - const gchar *string_reversed); -GLIB_AVAILABLE_IN_ALL -gboolean g_pattern_match_string (GPatternSpec *pspec, - const gchar *string); -GLIB_AVAILABLE_IN_ALL -gboolean g_pattern_match_simple (const gchar *pattern, - const gchar *string); - -G_END_DECLS - -#endif /* __G_PATTERN_H__ */ -/* - * Copyright © 2018 Ole André Vadla Ravnås - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_PLATFORM_AUDIT_H__ -#define __G_PLATFORM_AUDIT_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GFDCallbacks GFDCallbacks; - -struct _GFDCallbacks -{ - void (*on_fd_opened) (gint fd, const gchar *description); - void (*on_fd_closed) (gint fd, const gchar *description); -}; - -GLIB_VAR -GFDCallbacks *glib_fd_callbacks; -GLIB_AVAILABLE_IN_2_68 -void g_platform_audit_set_fd_callbacks (GFDCallbacks *callbacks); - -G_END_DECLS - -#endif /* __G_PLATFORM_AUDIT_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_PRIMES_H__ -#define __G_PRIMES_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* Prime numbers. - */ - -/* This function returns prime numbers spaced by approximately 1.5-2.0 - * and is for use in resizing data structures which prefer - * prime-valued sizes. The closest spaced prime function returns the - * next largest prime, or the highest it knows about which is about - * MAXINT/4. - */ -GLIB_AVAILABLE_IN_ALL -guint g_spaced_primes_closest (guint num) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __G_PRIMES_H__ */ - /* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_QSORT_H__ -#define __G_QSORT_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -void g_qsort_with_data (gconstpointer pbase, - gint total_elems, - gsize size, - GCompareDataFunc compare_func, - gpointer user_data); - -G_END_DECLS - -#endif /* __G_QSORT_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_QUEUE_H__ -#define __G_QUEUE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GQueue GQueue; - -/** - * GQueue: - * @head: a pointer to the first element of the queue - * @tail: a pointer to the last element of the queue - * @length: the number of elements in the queue - * - * Contains the public fields of a - * [Queue][glib-Double-ended-Queues]. - */ -struct _GQueue -{ - GList *head; - GList *tail; - guint length; -}; - -/** - * G_QUEUE_INIT: - * - * A statically-allocated #GQueue must be initialized with this - * macro before it can be used. This macro can be used to initialize - * a variable, but it cannot be assigned to a variable. In that case - * you have to use g_queue_init(). - * - * |[ - * GQueue my_queue = G_QUEUE_INIT; - * ]| - * - * Since: 2.14 - */ -#define G_QUEUE_INIT { NULL, NULL, 0 } - -/* Queues - */ -GLIB_AVAILABLE_IN_ALL -GQueue* g_queue_new (void); -GLIB_AVAILABLE_IN_ALL -void g_queue_free (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -void g_queue_free_full (GQueue *queue, - GDestroyNotify free_func); -GLIB_AVAILABLE_IN_ALL -void g_queue_init (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -void g_queue_clear (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -gboolean g_queue_is_empty (GQueue *queue); -GLIB_AVAILABLE_IN_2_60 -void g_queue_clear_full (GQueue *queue, - GDestroyNotify free_func); -GLIB_AVAILABLE_IN_ALL -guint g_queue_get_length (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -void g_queue_reverse (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -GQueue * g_queue_copy (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -void g_queue_foreach (GQueue *queue, - GFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -GList * g_queue_find (GQueue *queue, - gconstpointer data); -GLIB_AVAILABLE_IN_ALL -GList * g_queue_find_custom (GQueue *queue, - gconstpointer data, - GCompareFunc func); -GLIB_AVAILABLE_IN_ALL -void g_queue_sort (GQueue *queue, - GCompareDataFunc compare_func, - gpointer user_data); - -GLIB_AVAILABLE_IN_ALL -void g_queue_push_head (GQueue *queue, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_queue_push_tail (GQueue *queue, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_queue_push_nth (GQueue *queue, - gpointer data, - gint n); -GLIB_AVAILABLE_IN_ALL -gpointer g_queue_pop_head (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -gpointer g_queue_pop_tail (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -gpointer g_queue_pop_nth (GQueue *queue, - guint n); -GLIB_AVAILABLE_IN_ALL -gpointer g_queue_peek_head (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -gpointer g_queue_peek_tail (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -gpointer g_queue_peek_nth (GQueue *queue, - guint n); -GLIB_AVAILABLE_IN_ALL -gint g_queue_index (GQueue *queue, - gconstpointer data); -GLIB_AVAILABLE_IN_ALL -gboolean g_queue_remove (GQueue *queue, - gconstpointer data); -GLIB_AVAILABLE_IN_ALL -guint g_queue_remove_all (GQueue *queue, - gconstpointer data); -GLIB_AVAILABLE_IN_ALL -void g_queue_insert_before (GQueue *queue, - GList *sibling, - gpointer data); -GLIB_AVAILABLE_IN_2_62 -void g_queue_insert_before_link - (GQueue *queue, - GList *sibling, - GList *link_); -GLIB_AVAILABLE_IN_ALL -void g_queue_insert_after (GQueue *queue, - GList *sibling, - gpointer data); -GLIB_AVAILABLE_IN_2_62 -void g_queue_insert_after_link - (GQueue *queue, - GList *sibling, - GList *link_); -GLIB_AVAILABLE_IN_ALL -void g_queue_insert_sorted (GQueue *queue, - gpointer data, - GCompareDataFunc func, - gpointer user_data); - -GLIB_AVAILABLE_IN_ALL -void g_queue_push_head_link (GQueue *queue, - GList *link_); -GLIB_AVAILABLE_IN_ALL -void g_queue_push_tail_link (GQueue *queue, - GList *link_); -GLIB_AVAILABLE_IN_ALL -void g_queue_push_nth_link (GQueue *queue, - gint n, - GList *link_); -GLIB_AVAILABLE_IN_ALL -GList* g_queue_pop_head_link (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -GList* g_queue_pop_tail_link (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -GList* g_queue_pop_nth_link (GQueue *queue, - guint n); -GLIB_AVAILABLE_IN_ALL -GList* g_queue_peek_head_link (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -GList* g_queue_peek_tail_link (GQueue *queue); -GLIB_AVAILABLE_IN_ALL -GList* g_queue_peek_nth_link (GQueue *queue, - guint n); -GLIB_AVAILABLE_IN_ALL -gint g_queue_link_index (GQueue *queue, - GList *link_); -GLIB_AVAILABLE_IN_ALL -void g_queue_unlink (GQueue *queue, - GList *link_); -GLIB_AVAILABLE_IN_ALL -void g_queue_delete_link (GQueue *queue, - GList *link_); - -G_END_DECLS - -#endif /* __G_QUEUE_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_RAND_H__ -#define __G_RAND_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GRand GRand; - -/* GRand - a good and fast random number generator: Mersenne Twister - * see http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html for more info. - * The range functions return a value in the interval [begin, end). - * int -> [0..2^32-1] - * int_range -> [begin..end-1] - * double -> [0..1) - * double_range -> [begin..end) - */ - -GLIB_AVAILABLE_IN_ALL -GRand* g_rand_new_with_seed (guint32 seed); -GLIB_AVAILABLE_IN_ALL -GRand* g_rand_new_with_seed_array (const guint32 *seed, - guint seed_length); -GLIB_AVAILABLE_IN_ALL -GRand* g_rand_new (void); -GLIB_AVAILABLE_IN_ALL -void g_rand_free (GRand *rand_); -GLIB_AVAILABLE_IN_ALL -GRand* g_rand_copy (GRand *rand_); -GLIB_AVAILABLE_IN_ALL -void g_rand_set_seed (GRand *rand_, - guint32 seed); -GLIB_AVAILABLE_IN_ALL -void g_rand_set_seed_array (GRand *rand_, - const guint32 *seed, - guint seed_length); - -#define g_rand_boolean(rand_) ((g_rand_int (rand_) & (1 << 15)) != 0) - -GLIB_AVAILABLE_IN_ALL -guint32 g_rand_int (GRand *rand_); -GLIB_AVAILABLE_IN_ALL -gint32 g_rand_int_range (GRand *rand_, - gint32 begin, - gint32 end); -GLIB_AVAILABLE_IN_ALL -gdouble g_rand_double (GRand *rand_); -GLIB_AVAILABLE_IN_ALL -gdouble g_rand_double_range (GRand *rand_, - gdouble begin, - gdouble end); -GLIB_AVAILABLE_IN_ALL -void g_random_set_seed (guint32 seed); - -#define g_random_boolean() ((g_random_int () & (1 << 15)) != 0) - -GLIB_AVAILABLE_IN_ALL -guint32 g_random_int (void); -GLIB_AVAILABLE_IN_ALL -gint32 g_random_int_range (gint32 begin, - gint32 end); -GLIB_AVAILABLE_IN_ALL -gdouble g_random_double (void); -GLIB_AVAILABLE_IN_ALL -gdouble g_random_double_range (gdouble begin, - gdouble end); - - -G_END_DECLS - -#endif /* __G_RAND_H__ */ -/* grcbox.h: Reference counted data - * - * Copyright 2018 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#pragma once - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_2_58 -gpointer g_rc_box_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_2_58 -gpointer g_rc_box_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_2_58 -gpointer g_rc_box_dup (gsize block_size, - gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_2_58 -gpointer g_rc_box_acquire (gpointer mem_block); -GLIB_AVAILABLE_IN_2_58 -void g_rc_box_release (gpointer mem_block); -GLIB_AVAILABLE_IN_2_58 -void g_rc_box_release_full (gpointer mem_block, - GDestroyNotify clear_func); - -GLIB_AVAILABLE_IN_2_58 -gsize g_rc_box_get_size (gpointer mem_block); - -GLIB_AVAILABLE_IN_2_58 -gpointer g_atomic_rc_box_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_2_58 -gpointer g_atomic_rc_box_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_2_58 -gpointer g_atomic_rc_box_dup (gsize block_size, - gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_2_58 -gpointer g_atomic_rc_box_acquire (gpointer mem_block); -GLIB_AVAILABLE_IN_2_58 -void g_atomic_rc_box_release (gpointer mem_block); -GLIB_AVAILABLE_IN_2_58 -void g_atomic_rc_box_release_full (gpointer mem_block, - GDestroyNotify clear_func); - -GLIB_AVAILABLE_IN_2_58 -gsize g_atomic_rc_box_get_size (gpointer mem_block); - -#define g_rc_box_new(type) \ - ((type *) g_rc_box_alloc (sizeof (type))) -#define g_rc_box_new0(type) \ - ((type *) g_rc_box_alloc0 (sizeof (type))) -#define g_atomic_rc_box_new(type) \ - ((type *) g_atomic_rc_box_alloc (sizeof (type))) -#define g_atomic_rc_box_new0(type) \ - ((type *) g_atomic_rc_box_alloc0 (sizeof (type))) - -#ifdef glib_typeof -/* Type check to avoid assigning references to different types */ -#undef g_rc_box_acquire -#define g_rc_box_acquire(mem_block) \ - ((glib_typeof (mem_block)) (_frida_g_rc_box_acquire) (mem_block)) -#undef g_atomic_rc_box_acquire -#define g_atomic_rc_box_acquire(mem_block) \ - ((glib_typeof (mem_block)) (_frida_g_atomic_rc_box_acquire) (mem_block)) - -/* Type check to avoid duplicating data to different types */ -#undef g_rc_box_dup -#define g_rc_box_dup(block_size, mem_block) \ - ((glib_typeof (mem_block)) (_frida_g_rc_box_dup) (block_size, mem_block)) -#undef g_atomic_rc_box_dup -#define g_atomic_rc_box_dup(block_size, mem_block) \ - ((glib_typeof (mem_block)) (_frida_g_atomic_rc_box_dup) (block_size, mem_block)) -#endif - -G_END_DECLS -/* grefcount.h: Reference counting - * - * Copyright 2018 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __GREFCOUNT_H__ -#define __GREFCOUNT_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#if defined(__GNUC__) && defined(G_DISABLE_CHECKS) -#endif - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_2_58 -void g_ref_count_init (grefcount *rc); -GLIB_AVAILABLE_IN_2_58 -void g_ref_count_inc (grefcount *rc); -GLIB_AVAILABLE_IN_2_58 -gboolean g_ref_count_dec (grefcount *rc); -GLIB_AVAILABLE_IN_2_58 -gboolean g_ref_count_compare (grefcount *rc, - gint val); - -GLIB_AVAILABLE_IN_2_58 -void g_atomic_ref_count_init (gatomicrefcount *arc); -GLIB_AVAILABLE_IN_2_58 -void g_atomic_ref_count_inc (gatomicrefcount *arc); -GLIB_AVAILABLE_IN_2_58 -gboolean g_atomic_ref_count_dec (gatomicrefcount *arc); -GLIB_AVAILABLE_IN_2_58 -gboolean g_atomic_ref_count_compare (gatomicrefcount *arc, - gint val); - -/* On GCC we can use __extension__ to inline the API without using - * ancillary functions; we only do this when disabling checks, as - * it disables warnings when saturating the reference counters - */ -#if defined(__GNUC__) && defined(G_DISABLE_CHECKS) - -#undef g_ref_count_init -# define g_ref_count_init(rc) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ - (void) (0 ? *(rc) ^ *(rc) : 1); \ - *(rc) = -1; \ - })) - -#undef g_ref_count_inc -# define g_ref_count_inc(rc) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ - (void) (0 ? *(rc) ^ *(rc) : 1); \ - if (*(rc) == G_MININT) ; else { \ - *(rc) -= 1; \ - } \ - })) - -#undef g_ref_count_dec -# define g_ref_count_dec(rc) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ - grefcount __rc = *(rc); \ - __rc += 1; \ - if (__rc == 0) ; else { \ - *(rc) = __rc; \ - } \ - (gboolean) (__rc == 0); \ - })) - -#undef g_ref_count_compare -# define g_ref_count_compare(rc,val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(rc) == sizeof (grefcount)); \ - (void) (0 ? *(rc) ^ (val) : 1); \ - (gboolean) (*(rc) == -(val)); \ - })) - -#undef g_atomic_ref_count_init -# define g_atomic_ref_count_init(rc) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ - (void) (0 ? *(rc) ^ *(rc) : 1); \ - *(rc) = 1; \ - })) - -#undef g_atomic_ref_count_inc -# define g_atomic_ref_count_inc(rc) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ - (void) (0 ? *(rc) ^ *(rc) : 1); \ - (void) (g_atomic_int_get (rc) == G_MAXINT ? 0 : g_atomic_int_inc ((rc))); \ - })) - -#undef g_atomic_ref_count_dec -# define g_atomic_ref_count_dec(rc) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ - (void) (0 ? *(rc) ^ *(rc) : 1); \ - g_atomic_int_dec_and_test ((rc)); \ - })) - -#undef g_atomic_ref_count_compare -# define g_atomic_ref_count_compare(rc,val) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(rc) == sizeof (gatomicrefcount)); \ - (void) (0 ? *(rc) ^ (val) : 1); \ - (gboolean) (g_atomic_int_get (rc) == (val)); \ - })) - -#endif /* __GNUC__ && G_DISABLE_CHECKS */ - -G_END_DECLS - -#endif /* __GREFCOUNT_H__ */ -/* grefstring.h: Reference counted strings - * - * Copyright 2018 Emmanuele Bassi - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#pragma once - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_2_58 -char * g_ref_string_new (const char *str); -GLIB_AVAILABLE_IN_2_58 -char * g_ref_string_new_len (const char *str, - gssize len); -GLIB_AVAILABLE_IN_2_58 -char * g_ref_string_new_intern (const char *str); - -GLIB_AVAILABLE_IN_2_58 -char * g_ref_string_acquire (char *str); -GLIB_AVAILABLE_IN_2_58 -void g_ref_string_release (char *str); - -GLIB_AVAILABLE_IN_2_58 -gsize g_ref_string_length (char *str); - -/** - * GRefString: - * - * A typedef for a reference-counted string. A pointer to a #GRefString can be - * treated like a standard `char*` array by all code, but can additionally have - * `g_ref_string_*()` methods called on it. `g_ref_string_*()` methods cannot be - * called on `char*` arrays not allocated using g_ref_string_new(). - * - * If using #GRefString with autocleanups, g_autoptr() must be used rather than - * g_autofree(), so that the reference counting metadata is also freed. - * - * Since: 2.58 - */ -typedef char GRefString; - -G_END_DECLS -/* GRegex -- regular expression API wrapper around PCRE. - * - * Copyright (C) 1999, 2000 Scott Wimer - * Copyright (C) 2004, Matthias Clasen - * Copyright (C) 2005 - 2007, Marco Barisione - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_REGEX_H__ -#define __G_REGEX_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * GRegexError: - * @G_REGEX_ERROR_COMPILE: Compilation of the regular expression failed. - * @G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression failed. - * @G_REGEX_ERROR_REPLACE: Replacement failed due to an ill-formed replacement - * string. - * @G_REGEX_ERROR_MATCH: The match process failed. - * @G_REGEX_ERROR_INTERNAL: Internal error of the regular expression engine. - * Since 2.16 - * @G_REGEX_ERROR_STRAY_BACKSLASH: "\\" at end of pattern. Since 2.16 - * @G_REGEX_ERROR_MISSING_CONTROL_CHAR: "\\c" at end of pattern. Since 2.16 - * @G_REGEX_ERROR_UNRECOGNIZED_ESCAPE: Unrecognized character follows "\\". - * Since 2.16 - * @G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER: Numbers out of order in "{}" - * quantifier. Since 2.16 - * @G_REGEX_ERROR_QUANTIFIER_TOO_BIG: Number too big in "{}" quantifier. - * Since 2.16 - * @G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS: Missing terminating "]" for - * character class. Since 2.16 - * @G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS: Invalid escape sequence - * in character class. Since 2.16 - * @G_REGEX_ERROR_RANGE_OUT_OF_ORDER: Range out of order in character class. - * Since 2.16 - * @G_REGEX_ERROR_NOTHING_TO_REPEAT: Nothing to repeat. Since 2.16 - * @G_REGEX_ERROR_UNRECOGNIZED_CHARACTER: Unrecognized character after "(?", - * "(?<" or "(?P". Since 2.16 - * @G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS: POSIX named classes are - * supported only within a class. Since 2.16 - * @G_REGEX_ERROR_UNMATCHED_PARENTHESIS: Missing terminating ")" or ")" - * without opening "(". Since 2.16 - * @G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE: Reference to non-existent - * subpattern. Since 2.16 - * @G_REGEX_ERROR_UNTERMINATED_COMMENT: Missing terminating ")" after comment. - * Since 2.16 - * @G_REGEX_ERROR_EXPRESSION_TOO_LARGE: Regular expression too large. - * Since 2.16 - * @G_REGEX_ERROR_MEMORY_ERROR: Failed to get memory. Since 2.16 - * @G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND: Lookbehind assertion is not - * fixed length. Since 2.16 - * @G_REGEX_ERROR_MALFORMED_CONDITION: Malformed number or name after "(?(". - * Since 2.16 - * @G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES: Conditional group contains - * more than two branches. Since 2.16 - * @G_REGEX_ERROR_ASSERTION_EXPECTED: Assertion expected after "(?(". - * Since 2.16 - * @G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME: Unknown POSIX class name. - * Since 2.16 - * @G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED: POSIX collating - * elements are not supported. Since 2.16 - * @G_REGEX_ERROR_HEX_CODE_TOO_LARGE: Character value in "\\x{...}" sequence - * is too large. Since 2.16 - * @G_REGEX_ERROR_INVALID_CONDITION: Invalid condition "(?(0)". Since 2.16 - * @G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND: \\C not allowed in - * lookbehind assertion. Since 2.16 - * @G_REGEX_ERROR_INFINITE_LOOP: Recursive call could loop indefinitely. - * Since 2.16 - * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR: Missing terminator - * in subpattern name. Since 2.16 - * @G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME: Two named subpatterns have - * the same name. Since 2.16 - * @G_REGEX_ERROR_MALFORMED_PROPERTY: Malformed "\\P" or "\\p" sequence. - * Since 2.16 - * @G_REGEX_ERROR_UNKNOWN_PROPERTY: Unknown property name after "\\P" or - * "\\p". Since 2.16 - * @G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG: Subpattern name is too long - * (maximum 32 characters). Since 2.16 - * @G_REGEX_ERROR_TOO_MANY_SUBPATTERNS: Too many named subpatterns (maximum - * 10,000). Since 2.16 - * @G_REGEX_ERROR_INVALID_OCTAL_VALUE: Octal value is greater than "\\377". - * Since 2.16 - * @G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE: "DEFINE" group contains more - * than one branch. Since 2.16 - * @G_REGEX_ERROR_DEFINE_REPETION: Repeating a "DEFINE" group is not allowed. - * This error is never raised. Since: 2.16 Deprecated: 2.34 - * @G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS: Inconsistent newline options. - * Since 2.16 - * @G_REGEX_ERROR_MISSING_BACK_REFERENCE: "\\g" is not followed by a braced, - * angle-bracketed, or quoted name or number, or by a plain number. Since: 2.16 - * @G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE: relative reference must not be zero. Since: 2.34 - * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN: the backtracing - * control verb used does not allow an argument. Since: 2.34 - * @G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB: unknown backtracing - * control verb. Since: 2.34 - * @G_REGEX_ERROR_NUMBER_TOO_BIG: number is too big in escape sequence. Since: 2.34 - * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME: Missing subpattern name. Since: 2.34 - * @G_REGEX_ERROR_MISSING_DIGIT: Missing digit. Since 2.34 - * @G_REGEX_ERROR_INVALID_DATA_CHARACTER: In JavaScript compatibility mode, - * "[" is an invalid data character. Since: 2.34 - * @G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME: different names for subpatterns of the - * same number are not allowed. Since: 2.34 - * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED: the backtracing control - * verb requires an argument. Since: 2.34 - * @G_REGEX_ERROR_INVALID_CONTROL_CHAR: "\\c" must be followed by an ASCII - * character. Since: 2.34 - * @G_REGEX_ERROR_MISSING_NAME: "\\k" is not followed by a braced, angle-bracketed, or - * quoted name. Since: 2.34 - * @G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS: "\\N" is not supported in a class. Since: 2.34 - * @G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES: too many forward references. Since: 2.34 - * @G_REGEX_ERROR_NAME_TOO_LONG: the name is too long in "(*MARK)", "(*PRUNE)", - * "(*SKIP)", or "(*THEN)". Since: 2.34 - * @G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE: the character value in the \\u sequence is - * too large. Since: 2.34 - * - * Error codes returned by regular expressions functions. - * - * Since: 2.14 - */ -typedef enum -{ - G_REGEX_ERROR_COMPILE, - G_REGEX_ERROR_OPTIMIZE, - G_REGEX_ERROR_REPLACE, - G_REGEX_ERROR_MATCH, - G_REGEX_ERROR_INTERNAL, - - /* These are the error codes from PCRE + 100 */ - G_REGEX_ERROR_STRAY_BACKSLASH = 101, - G_REGEX_ERROR_MISSING_CONTROL_CHAR = 102, - G_REGEX_ERROR_UNRECOGNIZED_ESCAPE = 103, - G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER = 104, - G_REGEX_ERROR_QUANTIFIER_TOO_BIG = 105, - G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS = 106, - G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS = 107, - G_REGEX_ERROR_RANGE_OUT_OF_ORDER = 108, - G_REGEX_ERROR_NOTHING_TO_REPEAT = 109, - G_REGEX_ERROR_UNRECOGNIZED_CHARACTER = 112, - G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113, - G_REGEX_ERROR_UNMATCHED_PARENTHESIS = 114, - G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE = 115, - G_REGEX_ERROR_UNTERMINATED_COMMENT = 118, - G_REGEX_ERROR_EXPRESSION_TOO_LARGE = 120, - G_REGEX_ERROR_MEMORY_ERROR = 121, - G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND = 125, - G_REGEX_ERROR_MALFORMED_CONDITION = 126, - G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES = 127, - G_REGEX_ERROR_ASSERTION_EXPECTED = 128, - G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME = 130, - G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131, - G_REGEX_ERROR_HEX_CODE_TOO_LARGE = 134, - G_REGEX_ERROR_INVALID_CONDITION = 135, - G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136, - G_REGEX_ERROR_INFINITE_LOOP = 140, - G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR = 142, - G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME = 143, - G_REGEX_ERROR_MALFORMED_PROPERTY = 146, - G_REGEX_ERROR_UNKNOWN_PROPERTY = 147, - G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG = 148, - G_REGEX_ERROR_TOO_MANY_SUBPATTERNS = 149, - G_REGEX_ERROR_INVALID_OCTAL_VALUE = 151, - G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE = 154, - G_REGEX_ERROR_DEFINE_REPETION = 155, - G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS = 156, - G_REGEX_ERROR_MISSING_BACK_REFERENCE = 157, - G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE = 158, - G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN = 159, - G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB = 160, - G_REGEX_ERROR_NUMBER_TOO_BIG = 161, - G_REGEX_ERROR_MISSING_SUBPATTERN_NAME = 162, - G_REGEX_ERROR_MISSING_DIGIT = 163, - G_REGEX_ERROR_INVALID_DATA_CHARACTER = 164, - G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME = 165, - G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED = 166, - G_REGEX_ERROR_INVALID_CONTROL_CHAR = 168, - G_REGEX_ERROR_MISSING_NAME = 169, - G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS = 171, - G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES = 172, - G_REGEX_ERROR_NAME_TOO_LONG = 175, - G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE = 176 -} GRegexError; - -/** - * G_REGEX_ERROR: - * - * Error domain for regular expressions. Errors in this domain will be - * from the #GRegexError enumeration. See #GError for information on - * error domains. - * - * Since: 2.14 - */ -#define G_REGEX_ERROR g_regex_error_quark () - -GLIB_AVAILABLE_IN_ALL -GQuark g_regex_error_quark (void); - -/** - * GRegexCompileFlags: - * @G_REGEX_CASELESS: Letters in the pattern match both upper- and - * lowercase letters. This option can be changed within a pattern - * by a "(?i)" option setting. - * @G_REGEX_MULTILINE: By default, GRegex treats the strings as consisting - * of a single line of characters (even if it actually contains - * newlines). The "start of line" metacharacter ("^") matches only - * at the start of the string, while the "end of line" metacharacter - * ("$") matches only at the end of the string, or before a terminating - * newline (unless #G_REGEX_DOLLAR_ENDONLY is set). When - * #G_REGEX_MULTILINE is set, the "start of line" and "end of line" - * constructs match immediately following or immediately before any - * newline in the string, respectively, as well as at the very start - * and end. This can be changed within a pattern by a "(?m)" option - * setting. - * @G_REGEX_DOTALL: A dot metacharacter (".") in the pattern matches all - * characters, including newlines. Without it, newlines are excluded. - * This option can be changed within a pattern by a ("?s") option setting. - * @G_REGEX_EXTENDED: Whitespace data characters in the pattern are - * totally ignored except when escaped or inside a character class. - * Whitespace does not include the VT character (code 11). In addition, - * characters between an unescaped "#" outside a character class and - * the next newline character, inclusive, are also ignored. This can - * be changed within a pattern by a "(?x)" option setting. - * @G_REGEX_ANCHORED: The pattern is forced to be "anchored", that is, - * it is constrained to match only at the first matching point in the - * string that is being searched. This effect can also be achieved by - * appropriate constructs in the pattern itself such as the "^" - * metacharacter. - * @G_REGEX_DOLLAR_ENDONLY: A dollar metacharacter ("$") in the pattern - * matches only at the end of the string. Without this option, a - * dollar also matches immediately before the final character if - * it is a newline (but not before any other newlines). This option - * is ignored if #G_REGEX_MULTILINE is set. - * @G_REGEX_UNGREEDY: Inverts the "greediness" of the quantifiers so that - * they are not greedy by default, but become greedy if followed by "?". - * It can also be set by a "(?U)" option setting within the pattern. - * @G_REGEX_RAW: Usually strings must be valid UTF-8 strings, using this - * flag they are considered as a raw sequence of bytes. - * @G_REGEX_NO_AUTO_CAPTURE: Disables the use of numbered capturing - * parentheses in the pattern. Any opening parenthesis that is not - * followed by "?" behaves as if it were followed by "?:" but named - * parentheses can still be used for capturing (and they acquire numbers - * in the usual way). - * @G_REGEX_OPTIMIZE: Optimize the regular expression. If the pattern will - * be used many times, then it may be worth the effort to optimize it - * to improve the speed of matches. - * @G_REGEX_FIRSTLINE: Limits an unanchored pattern to match before (or at) the - * first newline. Since: 2.34 - * @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not - * be unique. This can be helpful for certain types of pattern when it - * is known that only one instance of the named subpattern can ever be - * matched. - * @G_REGEX_NEWLINE_CR: Usually any newline character or character sequence is - * recognized. If this option is set, the only recognized newline character - * is '\r'. - * @G_REGEX_NEWLINE_LF: Usually any newline character or character sequence is - * recognized. If this option is set, the only recognized newline character - * is '\n'. - * @G_REGEX_NEWLINE_CRLF: Usually any newline character or character sequence is - * recognized. If this option is set, the only recognized newline character - * sequence is '\r\n'. - * @G_REGEX_NEWLINE_ANYCRLF: Usually any newline character or character sequence - * is recognized. If this option is set, the only recognized newline character - * sequences are '\r', '\n', and '\r\n'. Since: 2.34 - * @G_REGEX_BSR_ANYCRLF: Usually any newline character or character sequence - * is recognised. If this option is set, then "\R" only recognizes the newline - * characters '\r', '\n' and '\r\n'. Since: 2.34 - * @G_REGEX_JAVASCRIPT_COMPAT: Changes behaviour so that it is compatible with - * JavaScript rather than PCRE. Since: 2.34 - * - * Flags specifying compile-time options. - * - * Since: 2.14 - */ -/* Remember to update G_REGEX_COMPILE_MASK in gregex.c after - * adding a new flag. - */ -typedef enum -{ - G_REGEX_CASELESS = 1 << 0, - G_REGEX_MULTILINE = 1 << 1, - G_REGEX_DOTALL = 1 << 2, - G_REGEX_EXTENDED = 1 << 3, - G_REGEX_ANCHORED = 1 << 4, - G_REGEX_DOLLAR_ENDONLY = 1 << 5, - G_REGEX_UNGREEDY = 1 << 9, - G_REGEX_RAW = 1 << 11, - G_REGEX_NO_AUTO_CAPTURE = 1 << 12, - G_REGEX_OPTIMIZE = 1 << 13, - G_REGEX_FIRSTLINE = 1 << 18, - G_REGEX_DUPNAMES = 1 << 19, - G_REGEX_NEWLINE_CR = 1 << 20, - G_REGEX_NEWLINE_LF = 1 << 21, - G_REGEX_NEWLINE_CRLF = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF, - G_REGEX_NEWLINE_ANYCRLF = G_REGEX_NEWLINE_CR | 1 << 22, - G_REGEX_BSR_ANYCRLF = 1 << 23, - G_REGEX_JAVASCRIPT_COMPAT = 1 << 25 -} GRegexCompileFlags; - -/** - * GRegexMatchFlags: - * @G_REGEX_MATCH_ANCHORED: The pattern is forced to be "anchored", that is, - * it is constrained to match only at the first matching point in the - * string that is being searched. This effect can also be achieved by - * appropriate constructs in the pattern itself such as the "^" - * metacharacter. - * @G_REGEX_MATCH_NOTBOL: Specifies that first character of the string is - * not the beginning of a line, so the circumflex metacharacter should - * not match before it. Setting this without #G_REGEX_MULTILINE (at - * compile time) causes circumflex never to match. This option affects - * only the behaviour of the circumflex metacharacter, it does not - * affect "\A". - * @G_REGEX_MATCH_NOTEOL: Specifies that the end of the subject string is - * not the end of a line, so the dollar metacharacter should not match - * it nor (except in multiline mode) a newline immediately before it. - * Setting this without #G_REGEX_MULTILINE (at compile time) causes - * dollar never to match. This option affects only the behaviour of - * the dollar metacharacter, it does not affect "\Z" or "\z". - * @G_REGEX_MATCH_NOTEMPTY: An empty string is not considered to be a valid - * match if this option is set. If there are alternatives in the pattern, - * they are tried. If all the alternatives match the empty string, the - * entire match fails. For example, if the pattern "a?b?" is applied to - * a string not beginning with "a" or "b", it matches the empty string - * at the start of the string. With this flag set, this match is not - * valid, so GRegex searches further into the string for occurrences - * of "a" or "b". - * @G_REGEX_MATCH_PARTIAL: Turns on the partial matching feature, for more - * documentation on partial matching see g_match_info_is_partial_match(). - * @G_REGEX_MATCH_NEWLINE_CR: Overrides the newline definition set when - * creating a new #GRegex, setting the '\r' character as line terminator. - * @G_REGEX_MATCH_NEWLINE_LF: Overrides the newline definition set when - * creating a new #GRegex, setting the '\n' character as line terminator. - * @G_REGEX_MATCH_NEWLINE_CRLF: Overrides the newline definition set when - * creating a new #GRegex, setting the '\r\n' characters sequence as line terminator. - * @G_REGEX_MATCH_NEWLINE_ANY: Overrides the newline definition set when - * creating a new #GRegex, any Unicode newline sequence - * is recognised as a newline. These are '\r', '\n' and '\rn', and the - * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), - * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and - * U+2029 PARAGRAPH SEPARATOR. - * @G_REGEX_MATCH_NEWLINE_ANYCRLF: Overrides the newline definition set when - * creating a new #GRegex; any '\r', '\n', or '\r\n' character sequence - * is recognized as a newline. Since: 2.34 - * @G_REGEX_MATCH_BSR_ANYCRLF: Overrides the newline definition for "\R" set when - * creating a new #GRegex; only '\r', '\n', or '\r\n' character sequences - * are recognized as a newline by "\R". Since: 2.34 - * @G_REGEX_MATCH_BSR_ANY: Overrides the newline definition for "\R" set when - * creating a new #GRegex; any Unicode newline character or character sequence - * are recognized as a newline by "\R". These are '\r', '\n' and '\rn', and the - * single characters U+000B LINE TABULATION, U+000C FORM FEED (FF), - * U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and - * U+2029 PARAGRAPH SEPARATOR. Since: 2.34 - * @G_REGEX_MATCH_PARTIAL_SOFT: An alias for #G_REGEX_MATCH_PARTIAL. Since: 2.34 - * @G_REGEX_MATCH_PARTIAL_HARD: Turns on the partial matching feature. In contrast to - * to #G_REGEX_MATCH_PARTIAL_SOFT, this stops matching as soon as a partial match - * is found, without continuing to search for a possible complete match. See - * g_match_info_is_partial_match() for more information. Since: 2.34 - * @G_REGEX_MATCH_NOTEMPTY_ATSTART: Like #G_REGEX_MATCH_NOTEMPTY, but only applied to - * the start of the matched string. For anchored - * patterns this can only happen for pattern containing "\K". Since: 2.34 - * - * Flags specifying match-time options. - * - * Since: 2.14 - */ -/* Remember to update G_REGEX_MATCH_MASK in gregex.c after - * adding a new flag. */ -typedef enum -{ - G_REGEX_MATCH_ANCHORED = 1 << 4, - G_REGEX_MATCH_NOTBOL = 1 << 7, - G_REGEX_MATCH_NOTEOL = 1 << 8, - G_REGEX_MATCH_NOTEMPTY = 1 << 10, - G_REGEX_MATCH_PARTIAL = 1 << 15, - G_REGEX_MATCH_NEWLINE_CR = 1 << 20, - G_REGEX_MATCH_NEWLINE_LF = 1 << 21, - G_REGEX_MATCH_NEWLINE_CRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_LF, - G_REGEX_MATCH_NEWLINE_ANY = 1 << 22, - G_REGEX_MATCH_NEWLINE_ANYCRLF = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_ANY, - G_REGEX_MATCH_BSR_ANYCRLF = 1 << 23, - G_REGEX_MATCH_BSR_ANY = 1 << 24, - G_REGEX_MATCH_PARTIAL_SOFT = G_REGEX_MATCH_PARTIAL, - G_REGEX_MATCH_PARTIAL_HARD = 1 << 27, - G_REGEX_MATCH_NOTEMPTY_ATSTART = 1 << 28 -} GRegexMatchFlags; - -/** - * GRegex: - * - * A GRegex is the "compiled" form of a regular expression pattern. - * This structure is opaque and its fields cannot be accessed directly. - * - * Since: 2.14 - */ -typedef struct _GRegex GRegex; - - -/** - * GMatchInfo: - * - * A GMatchInfo is an opaque struct used to return information about - * matches. - */ -typedef struct _GMatchInfo GMatchInfo; - -/** - * GRegexEvalCallback: - * @match_info: the #GMatchInfo generated by the match. - * Use g_match_info_get_regex() and g_match_info_get_string() if you - * need the #GRegex or the matched string. - * @result: a #GString containing the new string - * @user_data: user data passed to g_regex_replace_eval() - * - * Specifies the type of the function passed to g_regex_replace_eval(). - * It is called for each occurrence of the pattern in the string passed - * to g_regex_replace_eval(), and it should append the replacement to - * @result. - * - * Returns: %FALSE to continue the replacement process, %TRUE to stop it - * - * Since: 2.14 - */ -typedef gboolean (*GRegexEvalCallback) (const GMatchInfo *match_info, - GString *result, - gpointer user_data); - - -GLIB_AVAILABLE_IN_ALL -GRegex *g_regex_new (const gchar *pattern, - GRegexCompileFlags compile_options, - GRegexMatchFlags match_options, - GError **error); -GLIB_AVAILABLE_IN_ALL -GRegex *g_regex_ref (GRegex *regex); -GLIB_AVAILABLE_IN_ALL -void g_regex_unref (GRegex *regex); -GLIB_AVAILABLE_IN_ALL -const gchar *g_regex_get_pattern (const GRegex *regex); -GLIB_AVAILABLE_IN_ALL -gint g_regex_get_max_backref (const GRegex *regex); -GLIB_AVAILABLE_IN_ALL -gint g_regex_get_capture_count (const GRegex *regex); -GLIB_AVAILABLE_IN_ALL -gboolean g_regex_get_has_cr_or_lf (const GRegex *regex); -GLIB_AVAILABLE_IN_2_38 -gint g_regex_get_max_lookbehind (const GRegex *regex); -GLIB_AVAILABLE_IN_ALL -gint g_regex_get_string_number (const GRegex *regex, - const gchar *name); -GLIB_AVAILABLE_IN_ALL -gchar *g_regex_escape_string (const gchar *string, - gint length); -GLIB_AVAILABLE_IN_ALL -gchar *g_regex_escape_nul (const gchar *string, - gint length); - -GLIB_AVAILABLE_IN_ALL -GRegexCompileFlags g_regex_get_compile_flags (const GRegex *regex); -GLIB_AVAILABLE_IN_ALL -GRegexMatchFlags g_regex_get_match_flags (const GRegex *regex); - -/* Matching. */ -GLIB_AVAILABLE_IN_ALL -gboolean g_regex_match_simple (const gchar *pattern, - const gchar *string, - GRegexCompileFlags compile_options, - GRegexMatchFlags match_options); -GLIB_AVAILABLE_IN_ALL -gboolean g_regex_match (const GRegex *regex, - const gchar *string, - GRegexMatchFlags match_options, - GMatchInfo **match_info); -GLIB_AVAILABLE_IN_ALL -gboolean g_regex_match_full (const GRegex *regex, - const gchar *string, - gssize string_len, - gint start_position, - GRegexMatchFlags match_options, - GMatchInfo **match_info, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_regex_match_all (const GRegex *regex, - const gchar *string, - GRegexMatchFlags match_options, - GMatchInfo **match_info); -GLIB_AVAILABLE_IN_ALL -gboolean g_regex_match_all_full (const GRegex *regex, - const gchar *string, - gssize string_len, - gint start_position, - GRegexMatchFlags match_options, - GMatchInfo **match_info, - GError **error); - -/* String splitting. */ -GLIB_AVAILABLE_IN_ALL -gchar **g_regex_split_simple (const gchar *pattern, - const gchar *string, - GRegexCompileFlags compile_options, - GRegexMatchFlags match_options); -GLIB_AVAILABLE_IN_ALL -gchar **g_regex_split (const GRegex *regex, - const gchar *string, - GRegexMatchFlags match_options); -GLIB_AVAILABLE_IN_ALL -gchar **g_regex_split_full (const GRegex *regex, - const gchar *string, - gssize string_len, - gint start_position, - GRegexMatchFlags match_options, - gint max_tokens, - GError **error); - -/* String replacement. */ -GLIB_AVAILABLE_IN_ALL -gchar *g_regex_replace (const GRegex *regex, - const gchar *string, - gssize string_len, - gint start_position, - const gchar *replacement, - GRegexMatchFlags match_options, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar *g_regex_replace_literal (const GRegex *regex, - const gchar *string, - gssize string_len, - gint start_position, - const gchar *replacement, - GRegexMatchFlags match_options, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar *g_regex_replace_eval (const GRegex *regex, - const gchar *string, - gssize string_len, - gint start_position, - GRegexMatchFlags match_options, - GRegexEvalCallback eval, - gpointer user_data, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_regex_check_replacement (const gchar *replacement, - gboolean *has_references, - GError **error); - -/* Match info */ -GLIB_AVAILABLE_IN_ALL -GRegex *g_match_info_get_regex (const GMatchInfo *match_info); -GLIB_AVAILABLE_IN_ALL -const gchar *g_match_info_get_string (const GMatchInfo *match_info); - -GLIB_AVAILABLE_IN_ALL -GMatchInfo *g_match_info_ref (GMatchInfo *match_info); -GLIB_AVAILABLE_IN_ALL -void g_match_info_unref (GMatchInfo *match_info); -GLIB_AVAILABLE_IN_ALL -void g_match_info_free (GMatchInfo *match_info); -GLIB_AVAILABLE_IN_ALL -gboolean g_match_info_next (GMatchInfo *match_info, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_match_info_matches (const GMatchInfo *match_info); -GLIB_AVAILABLE_IN_ALL -gint g_match_info_get_match_count (const GMatchInfo *match_info); -GLIB_AVAILABLE_IN_ALL -gboolean g_match_info_is_partial_match (const GMatchInfo *match_info); -GLIB_AVAILABLE_IN_ALL -gchar *g_match_info_expand_references(const GMatchInfo *match_info, - const gchar *string_to_expand, - GError **error); -GLIB_AVAILABLE_IN_ALL -gchar *g_match_info_fetch (const GMatchInfo *match_info, - gint match_num); -GLIB_AVAILABLE_IN_ALL -gboolean g_match_info_fetch_pos (const GMatchInfo *match_info, - gint match_num, - gint *start_pos, - gint *end_pos); -GLIB_AVAILABLE_IN_ALL -gchar *g_match_info_fetch_named (const GMatchInfo *match_info, - const gchar *name); -GLIB_AVAILABLE_IN_ALL -gboolean g_match_info_fetch_named_pos (const GMatchInfo *match_info, - const gchar *name, - gint *start_pos, - gint *end_pos); -GLIB_AVAILABLE_IN_ALL -gchar **g_match_info_fetch_all (const GMatchInfo *match_info); - -G_END_DECLS - -#endif /* __G_REGEX_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_SCANNER_H__ -#define __G_SCANNER_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GScanner GScanner; -typedef struct _GScannerConfig GScannerConfig; -typedef union _GTokenValue GTokenValue; - -typedef void (*GScannerMsgFunc) (GScanner *scanner, - gchar *message, - gboolean error); - -/* GScanner: Flexible lexical scanner for general purpose. - */ - -/* Character sets */ -#define G_CSET_A_2_Z "ABCDEFGHIJKLMNOPQRSTUVWXYZ" -#define G_CSET_a_2_z "abcdefghijklmnopqrstuvwxyz" -#define G_CSET_DIGITS "0123456789" -#define G_CSET_LATINC "\300\301\302\303\304\305\306"\ - "\307\310\311\312\313\314\315\316\317\320"\ - "\321\322\323\324\325\326"\ - "\330\331\332\333\334\335\336" -#define G_CSET_LATINS "\337\340\341\342\343\344\345\346"\ - "\347\350\351\352\353\354\355\356\357\360"\ - "\361\362\363\364\365\366"\ - "\370\371\372\373\374\375\376\377" - -/* Error types */ -typedef enum -{ - G_ERR_UNKNOWN, - G_ERR_UNEXP_EOF, - G_ERR_UNEXP_EOF_IN_STRING, - G_ERR_UNEXP_EOF_IN_COMMENT, - G_ERR_NON_DIGIT_IN_CONST, - G_ERR_DIGIT_RADIX, - G_ERR_FLOAT_RADIX, - G_ERR_FLOAT_MALFORMED -} GErrorType; - -/* Token types */ -typedef enum -{ - G_TOKEN_EOF = 0, - - G_TOKEN_LEFT_PAREN = '(', - G_TOKEN_RIGHT_PAREN = ')', - G_TOKEN_LEFT_CURLY = '{', - G_TOKEN_RIGHT_CURLY = '}', - G_TOKEN_LEFT_BRACE = '[', - G_TOKEN_RIGHT_BRACE = ']', - G_TOKEN_EQUAL_SIGN = '=', - G_TOKEN_COMMA = ',', - - G_TOKEN_NONE = 256, - - G_TOKEN_ERROR, - - G_TOKEN_CHAR, - G_TOKEN_BINARY, - G_TOKEN_OCTAL, - G_TOKEN_INT, - G_TOKEN_HEX, - G_TOKEN_FLOAT, - G_TOKEN_STRING, - - G_TOKEN_SYMBOL, - G_TOKEN_IDENTIFIER, - G_TOKEN_IDENTIFIER_NULL, - - G_TOKEN_COMMENT_SINGLE, - G_TOKEN_COMMENT_MULTI, - - /*< private >*/ - G_TOKEN_LAST -} GTokenType; - -union _GTokenValue -{ - gpointer v_symbol; - gchar *v_identifier; - gulong v_binary; - gulong v_octal; - gulong v_int; - guint64 v_int64; - gdouble v_float; - gulong v_hex; - gchar *v_string; - gchar *v_comment; - guchar v_char; - guint v_error; -}; - -struct _GScannerConfig -{ - /* Character sets - */ - gchar *cset_skip_characters; /* default: " \t\n" */ - gchar *cset_identifier_first; - gchar *cset_identifier_nth; - gchar *cpair_comment_single; /* default: "#\n" */ - - /* Should symbol lookup work case sensitive? - */ - guint case_sensitive : 1; - - /* Boolean values to be adjusted "on the fly" - * to configure scanning behaviour. - */ - guint skip_comment_multi : 1; /* C like comment */ - guint skip_comment_single : 1; /* single line comment */ - guint scan_comment_multi : 1; /* scan multi line comments? */ - guint scan_identifier : 1; - guint scan_identifier_1char : 1; - guint scan_identifier_NULL : 1; - guint scan_symbols : 1; - guint scan_binary : 1; - guint scan_octal : 1; - guint scan_float : 1; - guint scan_hex : 1; /* '0x0ff0' */ - guint scan_hex_dollar : 1; /* '$0ff0' */ - guint scan_string_sq : 1; /* string: 'anything' */ - guint scan_string_dq : 1; /* string: "\\-escapes!\n" */ - guint numbers_2_int : 1; /* bin, octal, hex => int */ - guint int_2_float : 1; /* int => G_TOKEN_FLOAT? */ - guint identifier_2_string : 1; - guint char_2_token : 1; /* return G_TOKEN_CHAR? */ - guint symbol_2_token : 1; - guint scope_0_fallback : 1; /* try scope 0 on lookups? */ - guint store_int64 : 1; /* use value.v_int64 rather than v_int */ - - /*< private >*/ - guint padding_dummy; -}; - -struct _GScanner -{ - /* unused fields */ - gpointer user_data; - guint max_parse_errors; - - /* g_scanner_error() increments this field */ - guint parse_errors; - - /* name of input stream, featured by the default message handler */ - const gchar *input_name; - - /* quarked data */ - GData *qdata; - - /* link into the scanner configuration */ - GScannerConfig *config; - - /* fields filled in after g_scanner_get_next_token() */ - GTokenType token; - GTokenValue value; - guint line; - guint position; - - /* fields filled in after g_scanner_peek_next_token() */ - GTokenType next_token; - GTokenValue next_value; - guint next_line; - guint next_position; - - /*< private >*/ - /* to be considered private */ - GHashTable *symbol_table; - gint input_fd; - const gchar *text; - const gchar *text_end; - gchar *buffer; - guint scope_id; - - /*< public >*/ - /* handler function for _warn and _error */ - GScannerMsgFunc msg_handler; -}; - -GLIB_AVAILABLE_IN_ALL -GScanner* g_scanner_new (const GScannerConfig *config_templ); -GLIB_AVAILABLE_IN_ALL -void g_scanner_destroy (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -void g_scanner_input_file (GScanner *scanner, - gint input_fd); -GLIB_AVAILABLE_IN_ALL -void g_scanner_sync_file_offset (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -void g_scanner_input_text (GScanner *scanner, - const gchar *text, - guint text_len); -GLIB_AVAILABLE_IN_ALL -GTokenType g_scanner_get_next_token (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -GTokenType g_scanner_peek_next_token (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -GTokenType g_scanner_cur_token (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -GTokenValue g_scanner_cur_value (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -guint g_scanner_cur_line (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -guint g_scanner_cur_position (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -gboolean g_scanner_eof (GScanner *scanner); -GLIB_AVAILABLE_IN_ALL -guint g_scanner_set_scope (GScanner *scanner, - guint scope_id); -GLIB_AVAILABLE_IN_ALL -void g_scanner_scope_add_symbol (GScanner *scanner, - guint scope_id, - const gchar *symbol, - gpointer value); -GLIB_AVAILABLE_IN_ALL -void g_scanner_scope_remove_symbol (GScanner *scanner, - guint scope_id, - const gchar *symbol); -GLIB_AVAILABLE_IN_ALL -gpointer g_scanner_scope_lookup_symbol (GScanner *scanner, - guint scope_id, - const gchar *symbol); -GLIB_AVAILABLE_IN_ALL -void g_scanner_scope_foreach_symbol (GScanner *scanner, - guint scope_id, - GHFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -gpointer g_scanner_lookup_symbol (GScanner *scanner, - const gchar *symbol); -GLIB_AVAILABLE_IN_ALL -void g_scanner_unexp_token (GScanner *scanner, - GTokenType expected_token, - const gchar *identifier_spec, - const gchar *symbol_spec, - const gchar *symbol_name, - const gchar *message, - gint is_error); -GLIB_AVAILABLE_IN_ALL -void g_scanner_error (GScanner *scanner, - const gchar *format, - ...) G_GNUC_PRINTF (2,3); -GLIB_AVAILABLE_IN_ALL -void g_scanner_warn (GScanner *scanner, - const gchar *format, - ...) G_GNUC_PRINTF (2,3); - -/* keep downward source compatibility */ -#define g_scanner_add_symbol( scanner, symbol, value ) G_STMT_START { \ - g_scanner_scope_add_symbol ((scanner), 0, (symbol), (value)); \ -} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_add_symbol) -#define g_scanner_remove_symbol( scanner, symbol ) G_STMT_START { \ - g_scanner_scope_remove_symbol ((scanner), 0, (symbol)); \ -} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_remove_symbol) -#define g_scanner_foreach_symbol( scanner, func, data ) G_STMT_START { \ - g_scanner_scope_foreach_symbol ((scanner), 0, (func), (data)); \ -} G_STMT_END GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_scanner_scope_foreach_symbol) - -/* The following two functions are deprecated and will be removed in - * the next major release. They do no good. */ -#define g_scanner_freeze_symbol_table(scanner) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 -#define g_scanner_thaw_symbol_table(scanner) ((void)0) GLIB_DEPRECATED_MACRO_IN_2_26 - -G_END_DECLS - -#endif /* __G_SCANNER_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 - * Soeren Sandmann (sandmann@daimi.au.dk) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_SEQUENCE_H__ -#define __G_SEQUENCE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GSequence GSequence; -typedef struct _GSequenceNode GSequenceIter; - -typedef gint (* GSequenceIterCompareFunc) (GSequenceIter *a, - GSequenceIter *b, - gpointer data); - - -/* GSequence */ -GLIB_AVAILABLE_IN_ALL -GSequence * g_sequence_new (GDestroyNotify data_destroy); -GLIB_AVAILABLE_IN_ALL -void g_sequence_free (GSequence *seq); -GLIB_AVAILABLE_IN_ALL -gint g_sequence_get_length (GSequence *seq); -GLIB_AVAILABLE_IN_ALL -void g_sequence_foreach (GSequence *seq, - GFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -void g_sequence_foreach_range (GSequenceIter *begin, - GSequenceIter *end, - GFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -void g_sequence_sort (GSequence *seq, - GCompareDataFunc cmp_func, - gpointer cmp_data); -GLIB_AVAILABLE_IN_ALL -void g_sequence_sort_iter (GSequence *seq, - GSequenceIterCompareFunc cmp_func, - gpointer cmp_data); -GLIB_AVAILABLE_IN_2_48 -gboolean g_sequence_is_empty (GSequence *seq); - - -/* Getting iters */ -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_get_begin_iter (GSequence *seq); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_get_end_iter (GSequence *seq); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_get_iter_at_pos (GSequence *seq, - gint pos); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_append (GSequence *seq, - gpointer data); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_prepend (GSequence *seq, - gpointer data); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_insert_before (GSequenceIter *iter, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_sequence_move (GSequenceIter *src, - GSequenceIter *dest); -GLIB_AVAILABLE_IN_ALL -void g_sequence_swap (GSequenceIter *a, - GSequenceIter *b); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_insert_sorted (GSequence *seq, - gpointer data, - GCompareDataFunc cmp_func, - gpointer cmp_data); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_insert_sorted_iter (GSequence *seq, - gpointer data, - GSequenceIterCompareFunc iter_cmp, - gpointer cmp_data); -GLIB_AVAILABLE_IN_ALL -void g_sequence_sort_changed (GSequenceIter *iter, - GCompareDataFunc cmp_func, - gpointer cmp_data); -GLIB_AVAILABLE_IN_ALL -void g_sequence_sort_changed_iter (GSequenceIter *iter, - GSequenceIterCompareFunc iter_cmp, - gpointer cmp_data); -GLIB_AVAILABLE_IN_ALL -void g_sequence_remove (GSequenceIter *iter); -GLIB_AVAILABLE_IN_ALL -void g_sequence_remove_range (GSequenceIter *begin, - GSequenceIter *end); -GLIB_AVAILABLE_IN_ALL -void g_sequence_move_range (GSequenceIter *dest, - GSequenceIter *begin, - GSequenceIter *end); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_search (GSequence *seq, - gpointer data, - GCompareDataFunc cmp_func, - gpointer cmp_data); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_search_iter (GSequence *seq, - gpointer data, - GSequenceIterCompareFunc iter_cmp, - gpointer cmp_data); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_lookup (GSequence *seq, - gpointer data, - GCompareDataFunc cmp_func, - gpointer cmp_data); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_lookup_iter (GSequence *seq, - gpointer data, - GSequenceIterCompareFunc iter_cmp, - gpointer cmp_data); - - -/* Dereferencing */ -GLIB_AVAILABLE_IN_ALL -gpointer g_sequence_get (GSequenceIter *iter); -GLIB_AVAILABLE_IN_ALL -void g_sequence_set (GSequenceIter *iter, - gpointer data); - -/* Operations on GSequenceIter * */ -GLIB_AVAILABLE_IN_ALL -gboolean g_sequence_iter_is_begin (GSequenceIter *iter); -GLIB_AVAILABLE_IN_ALL -gboolean g_sequence_iter_is_end (GSequenceIter *iter); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_iter_next (GSequenceIter *iter); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_iter_prev (GSequenceIter *iter); -GLIB_AVAILABLE_IN_ALL -gint g_sequence_iter_get_position (GSequenceIter *iter); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_iter_move (GSequenceIter *iter, - gint delta); -GLIB_AVAILABLE_IN_ALL -GSequence * g_sequence_iter_get_sequence (GSequenceIter *iter); - - -/* Search */ -GLIB_AVAILABLE_IN_ALL -gint g_sequence_iter_compare (GSequenceIter *a, - GSequenceIter *b); -GLIB_AVAILABLE_IN_ALL -GSequenceIter *g_sequence_range_get_midpoint (GSequenceIter *begin, - GSequenceIter *end); - -G_END_DECLS - -#endif /* __G_SEQUENCE_H__ */ -/* gshell.h - Shell-related utilities - * - * Copyright 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_SHELL_H__ -#define __G_SHELL_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -#define G_SHELL_ERROR g_shell_error_quark () - -typedef enum -{ - /* mismatched or otherwise mangled quoting */ - G_SHELL_ERROR_BAD_QUOTING, - /* string to be parsed was empty */ - G_SHELL_ERROR_EMPTY_STRING, - G_SHELL_ERROR_FAILED -} GShellError; - -GLIB_AVAILABLE_IN_ALL -GQuark g_shell_error_quark (void); - -GLIB_AVAILABLE_IN_ALL -gchar* g_shell_quote (const gchar *unquoted_string); -GLIB_AVAILABLE_IN_ALL -gchar* g_shell_unquote (const gchar *quoted_string, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_shell_parse_argv (const gchar *command_line, - gint *argcp, - gchar ***argvp, - GError **error); - -G_END_DECLS - -#endif /* __G_SHELL_H__ */ -/* GLIB sliced memory - fast threaded memory chunk allocator - * Copyright (C) 2005 Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_SLICE_H__ -#define __G_SLICE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -G_BEGIN_DECLS - -/* slices - fast allocation/release of small memory blocks - */ -GLIB_AVAILABLE_IN_ALL -gpointer g_slice_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_ALL -gpointer g_slice_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_ALL -gpointer g_slice_copy (gsize block_size, - gconstpointer mem_block) G_GNUC_ALLOC_SIZE(1); -GLIB_AVAILABLE_IN_ALL -void g_slice_free1 (gsize block_size, - gpointer mem_block); -GLIB_AVAILABLE_IN_ALL -void g_slice_free_chain_with_offset (gsize block_size, - gpointer mem_chain, - gsize next_offset); -#define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type))) - -/* Allow the compiler to inline memset(). Since the size is a constant, this - * can significantly improve performance. */ -#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__) -# define g_slice_new0(type) \ - (type *) (G_GNUC_EXTENSION ({ \ - gsize __s = sizeof (type); \ - gpointer __p; \ - __p = g_slice_alloc (__s); \ - memset (__p, 0, __s); \ - __p; \ - })) -#else -# define g_slice_new0(type) ((type*) g_slice_alloc0 (sizeof (type))) -#endif - -/* MemoryBlockType * - * g_slice_dup (MemoryBlockType, - * MemoryBlockType *mem_block); - * g_slice_free (MemoryBlockType, - * MemoryBlockType *mem_block); - * g_slice_free_chain (MemoryBlockType, - * MemoryBlockType *first_chain_block, - * memory_block_next_field); - * pseudo prototypes for the macro - * definitions following below. - */ - -/* we go through extra hoops to ensure type safety */ -#define g_slice_dup(type, mem) \ - (1 ? (type*) g_slice_copy (sizeof (type), (mem)) \ - : ((void) ((type*) 0 == (mem)), (type*) 0)) -#define g_slice_free(type, mem) \ -G_STMT_START { \ - if (1) g_slice_free1 (sizeof (type), (mem)); \ - else (void) ((type*) 0 == (mem)); \ -} G_STMT_END -#define g_slice_free_chain(type, mem_chain, next) \ -G_STMT_START { \ - if (1) g_slice_free_chain_with_offset (sizeof (type), \ - (mem_chain), G_STRUCT_OFFSET (type, next)); \ - else (void) ((type*) 0 == (mem_chain)); \ -} G_STMT_END - -/* --- internal debugging API --- */ -typedef enum { - G_SLICE_CONFIG_ALWAYS_MALLOC = 1, - G_SLICE_CONFIG_BYPASS_MAGAZINES, - G_SLICE_CONFIG_WORKING_SET_MSECS, - G_SLICE_CONFIG_COLOR_INCREMENT, - G_SLICE_CONFIG_CHUNK_SIZES, - G_SLICE_CONFIG_CONTENTION_COUNTER -} GSliceConfig; - -GLIB_DEPRECATED_IN_2_34 -void g_slice_set_config (GSliceConfig ckey, gint64 value); -GLIB_DEPRECATED_IN_2_34 -gint64 g_slice_get_config (GSliceConfig ckey); -GLIB_DEPRECATED_IN_2_34 -gint64* g_slice_get_config_state (GSliceConfig ckey, gint64 address, guint *n_values); - -#ifdef G_ENABLE_DEBUG -GLIB_AVAILABLE_IN_ALL -void g_slice_debug_tree_statistics (void); -#endif - -G_END_DECLS - -#endif /* __G_SLICE_H__ */ -/* gspawn.h - Process launching - * - * Copyright 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library; if not, see . - */ - -#ifndef __G_SPAWN_H__ -#define __G_SPAWN_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - - -/* I'm not sure I remember our proposed naming convention here. */ -/** - * G_SPAWN_ERROR: - * - * Error domain for spawning processes. Errors in this domain will - * be from the #GSpawnError enumeration. See #GError for information on - * error domains. - */ -#define G_SPAWN_ERROR g_spawn_error_quark () - -/** - * GSpawnError: - * @G_SPAWN_ERROR_FORK: Fork failed due to lack of memory. - * @G_SPAWN_ERROR_READ: Read or select on pipes failed. - * @G_SPAWN_ERROR_CHDIR: Changing to working directory failed. - * @G_SPAWN_ERROR_ACCES: execv() returned `EACCES` - * @G_SPAWN_ERROR_PERM: execv() returned `EPERM` - * @G_SPAWN_ERROR_TOO_BIG: execv() returned `E2BIG` - * @G_SPAWN_ERROR_2BIG: deprecated alias for %G_SPAWN_ERROR_TOO_BIG (deprecated since GLib 2.32) - * @G_SPAWN_ERROR_NOEXEC: execv() returned `ENOEXEC` - * @G_SPAWN_ERROR_NAMETOOLONG: execv() returned `ENAMETOOLONG` - * @G_SPAWN_ERROR_NOENT: execv() returned `ENOENT` - * @G_SPAWN_ERROR_NOMEM: execv() returned `ENOMEM` - * @G_SPAWN_ERROR_NOTDIR: execv() returned `ENOTDIR` - * @G_SPAWN_ERROR_LOOP: execv() returned `ELOOP` - * @G_SPAWN_ERROR_TXTBUSY: execv() returned `ETXTBUSY` - * @G_SPAWN_ERROR_IO: execv() returned `EIO` - * @G_SPAWN_ERROR_NFILE: execv() returned `ENFILE` - * @G_SPAWN_ERROR_MFILE: execv() returned `EMFILE` - * @G_SPAWN_ERROR_INVAL: execv() returned `EINVAL` - * @G_SPAWN_ERROR_ISDIR: execv() returned `EISDIR` - * @G_SPAWN_ERROR_LIBBAD: execv() returned `ELIBBAD` - * @G_SPAWN_ERROR_FAILED: Some other fatal failure, - * `error->message` should explain. - * - * Error codes returned by spawning processes. - */ -typedef enum -{ - G_SPAWN_ERROR_FORK, /* fork failed due to lack of memory */ - G_SPAWN_ERROR_READ, /* read or select on pipes failed */ - G_SPAWN_ERROR_CHDIR, /* changing to working dir failed */ - G_SPAWN_ERROR_ACCES, /* execv() returned EACCES */ - G_SPAWN_ERROR_PERM, /* execv() returned EPERM */ - G_SPAWN_ERROR_TOO_BIG,/* execv() returned E2BIG */ - G_SPAWN_ERROR_2BIG GLIB_DEPRECATED_ENUMERATOR_IN_2_32_FOR(G_SPAWN_ERROR_TOO_BIG) = G_SPAWN_ERROR_TOO_BIG, - G_SPAWN_ERROR_NOEXEC, /* execv() returned ENOEXEC */ - G_SPAWN_ERROR_NAMETOOLONG, /* "" "" ENAMETOOLONG */ - G_SPAWN_ERROR_NOENT, /* "" "" ENOENT */ - G_SPAWN_ERROR_NOMEM, /* "" "" ENOMEM */ - G_SPAWN_ERROR_NOTDIR, /* "" "" ENOTDIR */ - G_SPAWN_ERROR_LOOP, /* "" "" ELOOP */ - G_SPAWN_ERROR_TXTBUSY, /* "" "" ETXTBUSY */ - G_SPAWN_ERROR_IO, /* "" "" EIO */ - G_SPAWN_ERROR_NFILE, /* "" "" ENFILE */ - G_SPAWN_ERROR_MFILE, /* "" "" EMFLE */ - G_SPAWN_ERROR_INVAL, /* "" "" EINVAL */ - G_SPAWN_ERROR_ISDIR, /* "" "" EISDIR */ - G_SPAWN_ERROR_LIBBAD, /* "" "" ELIBBAD */ - G_SPAWN_ERROR_FAILED /* other fatal failure, error->message - * should explain - */ -} GSpawnError; - -/** - * G_SPAWN_EXIT_ERROR: - * - * Error domain used by g_spawn_check_exit_status(). The code - * will be the program exit code. - */ -#define G_SPAWN_EXIT_ERROR g_spawn_exit_error_quark () - -/** - * GSpawnChildSetupFunc: - * @user_data: (closure): user data to pass to the function. - * - * Specifies the type of the setup function passed to g_spawn_async(), - * g_spawn_sync() and g_spawn_async_with_pipes(), which can, in very - * limited ways, be used to affect the child's execution. - * - * On POSIX platforms, the function is called in the child after GLib - * has performed all the setup it plans to perform, but before calling - * exec(). Actions taken in this function will only affect the child, - * not the parent. - * - * On Windows, the function is called in the parent. Its usefulness on - * Windows is thus questionable. In many cases executing the child setup - * function in the parent can have ill effects, and you should be very - * careful when porting software to Windows that uses child setup - * functions. - * - * However, even on POSIX, you are extremely limited in what you can - * safely do from a #GSpawnChildSetupFunc, because any mutexes that were - * held by other threads in the parent process at the time of the fork() - * will still be locked in the child process, and they will never be - * unlocked (since the threads that held them don't exist in the child). - * POSIX allows only async-signal-safe functions (see signal(7)) to be - * called in the child between fork() and exec(), which drastically limits - * the usefulness of child setup functions. - * - * In particular, it is not safe to call any function which may - * call malloc(), which includes POSIX functions such as setenv(). - * If you need to set up the child environment differently from - * the parent, you should use g_get_environ(), g_environ_setenv(), - * and g_environ_unsetenv(), and then pass the complete environment - * list to the `g_spawn...` function. - */ -typedef void (* GSpawnChildSetupFunc) (gpointer user_data); - -/** - * GSpawnFlags: - * @G_SPAWN_DEFAULT: no flags, default behaviour - * @G_SPAWN_LEAVE_DESCRIPTORS_OPEN: the parent's open file descriptors will - * be inherited by the child; otherwise all descriptors except stdin, - * stdout and stderr will be closed before calling exec() in the child. - * @G_SPAWN_DO_NOT_REAP_CHILD: the child will not be automatically reaped; - * you must use g_child_watch_add() yourself (or call waitpid() or handle - * `SIGCHLD` yourself), or the child will become a zombie. - * @G_SPAWN_SEARCH_PATH: `argv[0]` need not be an absolute path, it will be - * looked for in the user's `PATH`. - * @G_SPAWN_STDOUT_TO_DEV_NULL: the child's standard output will be discarded, - * instead of going to the same location as the parent's standard output. - * @G_SPAWN_STDERR_TO_DEV_NULL: the child's standard error will be discarded. - * @G_SPAWN_CHILD_INHERITS_STDIN: the child will inherit the parent's standard - * input (by default, the child's standard input is attached to `/dev/null`). - * @G_SPAWN_FILE_AND_ARGV_ZERO: the first element of `argv` is the file to - * execute, while the remaining elements are the actual argument vector - * to pass to the file. Normally g_spawn_async_with_pipes() uses `argv[0]` - * as the file to execute, and passes all of `argv` to the child. - * @G_SPAWN_SEARCH_PATH_FROM_ENVP: if `argv[0]` is not an absolute path, - * it will be looked for in the `PATH` from the passed child environment. - * Since: 2.34 - * @G_SPAWN_CLOEXEC_PIPES: create all pipes with the `O_CLOEXEC` flag set. - * Since: 2.40 - * - * Flags passed to g_spawn_sync(), g_spawn_async() and g_spawn_async_with_pipes(). - */ -typedef enum -{ - G_SPAWN_DEFAULT = 0, - G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1 << 0, - G_SPAWN_DO_NOT_REAP_CHILD = 1 << 1, - /* look for argv[0] in the path i.e. use execvp() */ - G_SPAWN_SEARCH_PATH = 1 << 2, - /* Dump output to /dev/null */ - G_SPAWN_STDOUT_TO_DEV_NULL = 1 << 3, - G_SPAWN_STDERR_TO_DEV_NULL = 1 << 4, - G_SPAWN_CHILD_INHERITS_STDIN = 1 << 5, - G_SPAWN_FILE_AND_ARGV_ZERO = 1 << 6, - G_SPAWN_SEARCH_PATH_FROM_ENVP = 1 << 7, - G_SPAWN_CLOEXEC_PIPES = 1 << 8 -} GSpawnFlags; - -GLIB_AVAILABLE_IN_ALL -GQuark g_spawn_error_quark (void); -GLIB_AVAILABLE_IN_ALL -GQuark g_spawn_exit_error_quark (void); - -GLIB_AVAILABLE_IN_ALL -gboolean g_spawn_async (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - GPid *child_pid, - GError **error); - - -/* Opens pipes for non-NULL standard_output, standard_input, standard_error, - * and returns the parent's end of the pipes. - */ -GLIB_AVAILABLE_IN_ALL -gboolean g_spawn_async_with_pipes (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - GPid *child_pid, - gint *standard_input, - gint *standard_output, - gint *standard_error, - GError **error); - -/* Lets you provide fds for stdin/stdout/stderr */ -GLIB_AVAILABLE_IN_2_58 -gboolean g_spawn_async_with_fds (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - GPid *child_pid, - gint stdin_fd, - gint stdout_fd, - gint stderr_fd, - GError **error); - -/* If standard_output or standard_error are non-NULL, the full - * standard output or error of the command will be placed there. - */ - -GLIB_AVAILABLE_IN_ALL -gboolean g_spawn_sync (const gchar *working_directory, - gchar **argv, - gchar **envp, - GSpawnFlags flags, - GSpawnChildSetupFunc child_setup, - gpointer user_data, - gchar **standard_output, - gchar **standard_error, - gint *exit_status, - GError **error); - -GLIB_AVAILABLE_IN_ALL -gboolean g_spawn_command_line_sync (const gchar *command_line, - gchar **standard_output, - gchar **standard_error, - gint *exit_status, - GError **error); -GLIB_AVAILABLE_IN_ALL -gboolean g_spawn_command_line_async (const gchar *command_line, - GError **error); - -GLIB_AVAILABLE_IN_2_34 -gboolean g_spawn_check_exit_status (gint exit_status, - GError **error); - -GLIB_AVAILABLE_IN_ALL -void g_spawn_close_pid (GPid pid); - -G_END_DECLS - -#endif /* __G_SPAWN_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_STRFUNCS_H__ -#define __G_STRFUNCS_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -G_BEGIN_DECLS - -/* Functions like the ones in that are not affected by locale. */ -typedef enum { - G_ASCII_ALNUM = 1 << 0, - G_ASCII_ALPHA = 1 << 1, - G_ASCII_CNTRL = 1 << 2, - G_ASCII_DIGIT = 1 << 3, - G_ASCII_GRAPH = 1 << 4, - G_ASCII_LOWER = 1 << 5, - G_ASCII_PRINT = 1 << 6, - G_ASCII_PUNCT = 1 << 7, - G_ASCII_SPACE = 1 << 8, - G_ASCII_UPPER = 1 << 9, - G_ASCII_XDIGIT = 1 << 10 -} GAsciiType; - -GLIB_VAR const guint16 * const g_ascii_table; - -#define g_ascii_isalnum(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_ALNUM) != 0) - -#define g_ascii_isalpha(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_ALPHA) != 0) - -#define g_ascii_iscntrl(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_CNTRL) != 0) - -#define g_ascii_isdigit(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_DIGIT) != 0) - -#define g_ascii_isgraph(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_GRAPH) != 0) - -#define g_ascii_islower(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_LOWER) != 0) - -#define g_ascii_isprint(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_PRINT) != 0) - -#define g_ascii_ispunct(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_PUNCT) != 0) - -#define g_ascii_isspace(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_SPACE) != 0) - -#define g_ascii_isupper(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_UPPER) != 0) - -#define g_ascii_isxdigit(c) \ - ((g_ascii_table[(guchar) (c)] & G_ASCII_XDIGIT) != 0) - -GLIB_AVAILABLE_IN_ALL -gchar g_ascii_tolower (gchar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gchar g_ascii_toupper (gchar c) G_GNUC_CONST; - -GLIB_AVAILABLE_IN_ALL -gint g_ascii_digit_value (gchar c) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gint g_ascii_xdigit_value (gchar c) G_GNUC_CONST; - -/* String utility functions that modify a string argument or - * return a constant string that must not be freed. - */ -#define G_STR_DELIMITERS "_-|> <." -GLIB_AVAILABLE_IN_ALL -gchar* g_strdelimit (gchar *string, - const gchar *delimiters, - gchar new_delimiter); -GLIB_AVAILABLE_IN_ALL -gchar* g_strcanon (gchar *string, - const gchar *valid_chars, - gchar substitutor); -GLIB_AVAILABLE_IN_ALL -const gchar * g_strerror (gint errnum) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -const gchar * g_strsignal (gint signum) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gchar * g_strreverse (gchar *string); -GLIB_AVAILABLE_IN_ALL -gsize g_strlcpy (gchar *dest, - const gchar *src, - gsize dest_size); -GLIB_AVAILABLE_IN_ALL -gsize g_strlcat (gchar *dest, - const gchar *src, - gsize dest_size); -GLIB_AVAILABLE_IN_ALL -gchar * g_strstr_len (const gchar *haystack, - gssize haystack_len, - const gchar *needle); -GLIB_AVAILABLE_IN_ALL -gchar * g_strrstr (const gchar *haystack, - const gchar *needle); -GLIB_AVAILABLE_IN_ALL -gchar * g_strrstr_len (const gchar *haystack, - gssize haystack_len, - const gchar *needle); - -GLIB_AVAILABLE_IN_ALL -gboolean g_str_has_suffix (const gchar *str, - const gchar *suffix); -GLIB_AVAILABLE_IN_ALL -gboolean g_str_has_prefix (const gchar *str, - const gchar *prefix); - -/* String to/from double conversion functions */ - -GLIB_AVAILABLE_IN_ALL -gdouble g_strtod (const gchar *nptr, - gchar **endptr); -GLIB_AVAILABLE_IN_ALL -gdouble g_ascii_strtod (const gchar *nptr, - gchar **endptr); -GLIB_AVAILABLE_IN_ALL -guint64 g_ascii_strtoull (const gchar *nptr, - gchar **endptr, - guint base); -GLIB_AVAILABLE_IN_ALL -gint64 g_ascii_strtoll (const gchar *nptr, - gchar **endptr, - guint base); -/* 29 bytes should enough for all possible values that - * g_ascii_dtostr can produce. - * Then add 10 for good measure */ -#define G_ASCII_DTOSTR_BUF_SIZE (29 + 10) -GLIB_AVAILABLE_IN_ALL -gchar * g_ascii_dtostr (gchar *buffer, - gint buf_len, - gdouble d); -GLIB_AVAILABLE_IN_ALL -gchar * g_ascii_formatd (gchar *buffer, - gint buf_len, - const gchar *format, - gdouble d); - -/* removes leading spaces */ -GLIB_AVAILABLE_IN_ALL -gchar* g_strchug (gchar *string); -/* removes trailing spaces */ -GLIB_AVAILABLE_IN_ALL -gchar* g_strchomp (gchar *string); -/* removes leading & trailing spaces */ -#define g_strstrip( string ) g_strchomp (g_strchug (string)) - -GLIB_AVAILABLE_IN_ALL -gint g_ascii_strcasecmp (const gchar *s1, - const gchar *s2); -GLIB_AVAILABLE_IN_ALL -gint g_ascii_strncasecmp (const gchar *s1, - const gchar *s2, - gsize n); -GLIB_AVAILABLE_IN_ALL -gchar* g_ascii_strdown (const gchar *str, - gssize len) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_ascii_strup (const gchar *str, - gssize len) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_2_40 -gboolean g_str_is_ascii (const gchar *str); - -GLIB_DEPRECATED -gint g_strcasecmp (const gchar *s1, - const gchar *s2); -GLIB_DEPRECATED -gint g_strncasecmp (const gchar *s1, - const gchar *s2, - guint n); -GLIB_DEPRECATED -gchar* g_strdown (gchar *string); -GLIB_DEPRECATED -gchar* g_strup (gchar *string); - - -/* String utility functions that return a newly allocated string which - * ought to be freed with g_free from the caller at some point. - */ -GLIB_AVAILABLE_IN_ALL -gchar* g_strdup (const gchar *str) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_strdup_printf (const gchar *format, - ...) G_GNUC_PRINTF (1, 2) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_strdup_vprintf (const gchar *format, - va_list args) G_GNUC_PRINTF(1, 0) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_strndup (const gchar *str, - gsize n) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_strnfill (gsize length, - gchar fill_char) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -gchar* g_strconcat (const gchar *string1, - ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; -GLIB_AVAILABLE_IN_ALL -gchar* g_strjoin (const gchar *separator, - ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; - -/* Make a copy of a string interpreting C string -style escape - * sequences. Inverse of g_strescape. The recognized sequences are \b - * \f \n \r \t \\ \" and the octal format. - */ -GLIB_AVAILABLE_IN_ALL -gchar* g_strcompress (const gchar *source) G_GNUC_MALLOC; - -/* Copy a string escaping nonprintable characters like in C strings. - * Inverse of g_strcompress. The exceptions parameter, if non-NULL, points - * to a string containing characters that are not to be escaped. - * - * Deprecated API: gchar* g_strescape (const gchar *source); - * Luckily this function wasn't used much, using NULL as second parameter - * provides mostly identical semantics. - */ -GLIB_AVAILABLE_IN_ALL -gchar* g_strescape (const gchar *source, - const gchar *exceptions) G_GNUC_MALLOC; - -GLIB_AVAILABLE_IN_ALL -gpointer g_memdup (gconstpointer mem, - guint byte_size) G_GNUC_ALLOC_SIZE(2); - -/* NULL terminated string arrays. - * g_strsplit(), g_strsplit_set() split up string into max_tokens tokens - * at delim and return a newly allocated string array. - * g_strjoinv() concatenates all of str_array's strings, sliding in an - * optional separator, the returned string is newly allocated. - * g_strfreev() frees the array itself and all of its strings. - * g_strdupv() copies a NULL-terminated array of strings - * g_strv_length() returns the length of a NULL-terminated array of strings - */ -typedef gchar** GStrv; -GLIB_AVAILABLE_IN_ALL -gchar** g_strsplit (const gchar *string, - const gchar *delimiter, - gint max_tokens); -GLIB_AVAILABLE_IN_ALL -gchar ** g_strsplit_set (const gchar *string, - const gchar *delimiters, - gint max_tokens); -GLIB_AVAILABLE_IN_ALL -gchar* g_strjoinv (const gchar *separator, - gchar **str_array) G_GNUC_MALLOC; -GLIB_AVAILABLE_IN_ALL -void g_strfreev (gchar **str_array); -GLIB_AVAILABLE_IN_ALL -gchar** g_strdupv (gchar **str_array); -GLIB_AVAILABLE_IN_ALL -guint g_strv_length (gchar **str_array); - -GLIB_AVAILABLE_IN_ALL -gchar* g_stpcpy (gchar *dest, - const char *src); - -GLIB_AVAILABLE_IN_2_40 -gchar * g_str_to_ascii (const gchar *str, - const gchar *from_locale); - -GLIB_AVAILABLE_IN_2_40 -gchar ** g_str_tokenize_and_fold (const gchar *string, - const gchar *translit_locale, - gchar ***ascii_alternates); - -GLIB_AVAILABLE_IN_2_40 -gboolean g_str_match_string (const gchar *search_term, - const gchar *potential_hit, - gboolean accept_alternates); - -GLIB_AVAILABLE_IN_2_44 -gboolean g_strv_contains (const gchar * const *strv, - const gchar *str); - -GLIB_AVAILABLE_IN_2_60 -gboolean g_strv_equal (const gchar * const *strv1, - const gchar * const *strv2); - -/* Convenience ASCII string to number API */ - -/** - * GNumberParserError: - * @G_NUMBER_PARSER_ERROR_INVALID: String was not a valid number. - * @G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS: String was a number, but out of bounds. - * - * Error codes returned by functions converting a string to a number. - * - * Since: 2.54 - */ -typedef enum - { - G_NUMBER_PARSER_ERROR_INVALID, - G_NUMBER_PARSER_ERROR_OUT_OF_BOUNDS, - } GNumberParserError; - -/** - * G_NUMBER_PARSER_ERROR: - * - * Domain for errors returned by functions converting a string to a - * number. - * - * Since: 2.54 - */ -#define G_NUMBER_PARSER_ERROR (g_number_parser_error_quark ()) - -GLIB_AVAILABLE_IN_2_54 -GQuark g_number_parser_error_quark (void); - -GLIB_AVAILABLE_IN_2_54 -gboolean g_ascii_string_to_signed (const gchar *str, - guint base, - gint64 min, - gint64 max, - gint64 *out_num, - GError **error); - -GLIB_AVAILABLE_IN_2_54 -gboolean g_ascii_string_to_unsigned (const gchar *str, - guint base, - guint64 min, - guint64 max, - guint64 *out_num, - GError **error); - -G_END_DECLS - -#endif /* __G_STRFUNCS_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_STRINGCHUNK_H__ -#define __G_STRINGCHUNK_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GStringChunk GStringChunk; - -GLIB_AVAILABLE_IN_ALL -GStringChunk* g_string_chunk_new (gsize size); -GLIB_AVAILABLE_IN_ALL -void g_string_chunk_free (GStringChunk *chunk); -GLIB_AVAILABLE_IN_ALL -void g_string_chunk_clear (GStringChunk *chunk); -GLIB_AVAILABLE_IN_ALL -gchar* g_string_chunk_insert (GStringChunk *chunk, - const gchar *string); -GLIB_AVAILABLE_IN_ALL -gchar* g_string_chunk_insert_len (GStringChunk *chunk, - const gchar *string, - gssize len); -GLIB_AVAILABLE_IN_ALL -gchar* g_string_chunk_insert_const (GStringChunk *chunk, - const gchar *string); - -G_END_DECLS - -#endif /* __G_STRING_H__ */ -/* - * Copyright © 2020 Canonical Ltd. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_STRVBUILDER_H__ -#define __G_STRVBUILDER_H__ - -#if !defined(__GLIB_H_INSIDE__) && !defined(GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * GStrvBuilder: - * - * A helper object to build a %NULL-terminated string array - * by appending. See g_strv_builder_new(). - * - * Since: 2.68 - */ -typedef struct _GStrvBuilder GStrvBuilder; - -GLIB_AVAILABLE_IN_2_68 -GStrvBuilder *g_strv_builder_new (void); - -GLIB_AVAILABLE_IN_2_68 -void g_strv_builder_unref (GStrvBuilder *builder); - -GLIB_AVAILABLE_IN_2_68 -GStrvBuilder *g_strv_builder_ref (GStrvBuilder *builder); - -GLIB_AVAILABLE_IN_2_68 -void g_strv_builder_add (GStrvBuilder *builder, - const char *value); - -GLIB_AVAILABLE_IN_2_68 -GStrv g_strv_builder_end (GStrvBuilder *builder); - -G_END_DECLS - -#endif /* __G_STRVBUILDER_H__ */ -/* GLib testing utilities - * Copyright (C) 2007 Imendio AB - * Authors: Tim Janik - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_TEST_UTILS_H__ -#define __G_TEST_UTILS_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -typedef struct GTestCase GTestCase; -typedef struct GTestSuite GTestSuite; -typedef void (*GTestFunc) (void); -typedef void (*GTestDataFunc) (gconstpointer user_data); -typedef void (*GTestFixtureFunc) (gpointer fixture, - gconstpointer user_data); - -/* assertion API */ -#define g_assert_cmpstr(s1, cmp, s2) G_STMT_START { \ - const char *__s1 = (s1), *__s2 = (s2); \ - if (g_strcmp0 (__s1, __s2) cmp 0) ; else \ - g_assertion_message_cmpstr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #s1 " " #cmp " " #s2, __s1, #cmp, __s2); \ - } G_STMT_END -#define g_assert_cmpint(n1, cmp, n2) G_STMT_START { \ - gint64 __n1 = (n1), __n2 = (n2); \ - if (__n1 cmp __n2) ; else \ - g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'i'); \ - } G_STMT_END -#define g_assert_cmpuint(n1, cmp, n2) G_STMT_START { \ - guint64 __n1 = (n1), __n2 = (n2); \ - if (__n1 cmp __n2) ; else \ - g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'i'); \ - } G_STMT_END -#define g_assert_cmphex(n1, cmp, n2) G_STMT_START {\ - guint64 __n1 = (n1), __n2 = (n2); \ - if (__n1 cmp __n2) ; else \ - g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'x'); \ - } G_STMT_END -#define g_assert_cmpfloat(n1,cmp,n2) G_STMT_START { \ - long double __n1 = (long double) (n1), __n2 = (long double) (n2); \ - if (__n1 cmp __n2) ; else \ - g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #n1 " " #cmp " " #n2, (long double) __n1, #cmp, (long double) __n2, 'f'); \ - } G_STMT_END -#define g_assert_cmpfloat_with_epsilon(n1,n2,epsilon) \ - G_STMT_START { \ - double __n1 = (n1), __n2 = (n2), __epsilon = (epsilon); \ - if (G_APPROX_VALUE (__n1, __n2, __epsilon)) ; else \ - g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #n1 " == " #n2 " (+/- " #epsilon ")", __n1, "==", __n2, 'f'); \ - } G_STMT_END -#define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\ - gconstpointer __m1 = m1, __m2 = m2; \ - int __l1 = l1, __l2 = l2; \ - if (__l1 != 0 && __m1 == NULL) \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "assertion failed (" #l1 " == 0 || " #m1 " != NULL)"); \ - else if (__l2 != 0 && __m2 == NULL) \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "assertion failed (" #l2 " == 0 || " #m2 " != NULL)"); \ - else if (__l1 != __l2) \ - g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", \ - (long double) __l1, "==", (long double) __l2, 'i'); \ - else if (__l1 != 0 && __m2 != NULL && memcmp (__m1, __m2, __l1) != 0) \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "assertion failed (" #m1 " == " #m2 ")"); \ - } G_STMT_END -#define g_assert_cmpvariant(v1, v2) \ - G_STMT_START \ - { \ - GVariant *__v1 = (v1), *__v2 = (v2); \ - if (!g_variant_equal (__v1, __v2)) \ - { \ - gchar *__s1, *__s2, *__msg; \ - __s1 = g_variant_print (__v1, TRUE); \ - __s2 = g_variant_print (__v2, TRUE); \ - __msg = g_strdup_printf ("assertion failed (" #v1 " == " #v2 "): %s does not equal %s", __s1, __s2); \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ - g_free (__s1); \ - g_free (__s2); \ - g_free (__msg); \ - } \ - } \ - G_STMT_END -#define g_assert_cmpstrv(strv1, strv2) \ - G_STMT_START \ - { \ - const char * const *__strv1 = (const char * const *) (strv1); \ - const char * const *__strv2 = (const char * const *) (strv2); \ - if (!__strv1 || !__strv2) \ - { \ - if (__strv1) \ - { \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "assertion failed (" #strv1 " == " #strv2 "): " #strv2 " is NULL, but " #strv1 " is not"); \ - } \ - else if (__strv2) \ - { \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "assertion failed (" #strv1 " == " #strv2 "): " #strv1 " is NULL, but " #strv2 " is not"); \ - } \ - } \ - else \ - { \ - guint __l1 = g_strv_length ((char **) __strv1); \ - guint __l2 = g_strv_length ((char **) __strv2); \ - if (__l1 != __l2) \ - { \ - char *__msg; \ - __msg = g_strdup_printf ("assertion failed (" #strv1 " == " #strv2 "): length %u does not equal length %u", __l1, __l2); \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ - g_free (__msg); \ - } \ - else \ - { \ - guint __i; \ - for (__i = 0; __i < __l1; __i++) \ - { \ - if (g_strcmp0 (__strv1[__i], __strv2[__i]) != 0) \ - { \ - g_assertion_message_cmpstrv (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #strv1 " == " #strv2, \ - __strv1, __strv2, __i); \ - } \ - } \ - } \ - } \ - } \ - G_STMT_END -#define g_assert_no_errno(expr) G_STMT_START { \ - int __ret, __errsv; \ - errno = 0; \ - __ret = expr; \ - __errsv = errno; \ - if (__ret < 0) \ - { \ - gchar *__msg; \ - __msg = g_strdup_printf ("assertion failed (" #expr " >= 0): errno %i: %s", __errsv, g_strerror (__errsv)); \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, __msg); \ - g_free (__msg); \ - } \ - } G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_66 -#define g_assert_no_error(err) G_STMT_START { \ - if (err) \ - g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #err, err, 0, 0); \ - } G_STMT_END -#define g_assert_error(err, dom, c) G_STMT_START { \ - if (!err || (err)->domain != dom || (err)->code != c) \ - g_assertion_message_error (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #err, err, dom, c); \ - } G_STMT_END -#define g_assert_true(expr) G_STMT_START { \ - if G_LIKELY (expr) ; else \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "'" #expr "' should be TRUE"); \ - } G_STMT_END -#define g_assert_false(expr) G_STMT_START { \ - if G_LIKELY (!(expr)) ; else \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "'" #expr "' should be FALSE"); \ - } G_STMT_END - -/* Use nullptr in C++ to catch misuse of these macros. */ -#if defined(__cplusplus) && __cplusplus >= 201100L -#define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == nullptr) ; else \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "'" #expr "' should be nullptr"); \ - } G_STMT_END -#define g_assert_nonnull(expr) G_STMT_START { \ - if G_LIKELY ((expr) != nullptr) ; else \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "'" #expr "' should not be nullptr"); \ - } G_STMT_END -#else /* not C++ */ -#define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == NULL) ; else \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "'" #expr "' should be NULL"); \ - } G_STMT_END -#define g_assert_nonnull(expr) G_STMT_START { \ - if G_LIKELY ((expr) != NULL) ; else \ - g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - "'" #expr "' should not be NULL"); \ - } G_STMT_END -#endif - -#ifdef G_DISABLE_ASSERT -/* https://gcc.gnu.org/onlinedocs/gcc-8.3.0/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005funreachable - * GCC 5 is not a strict lower bound for versions of GCC which provide __builtin_unreachable(). */ -#if __GNUC__ >= 5 || g_macro__has_builtin(__builtin_unreachable) -#define g_assert_not_reached() G_STMT_START { (void) 0; __builtin_unreachable (); } G_STMT_END -#elif defined (_MSC_VER) -#define g_assert_not_reached() G_STMT_START { (void) 0; __assume (0); } G_STMT_END -#else /* if __builtin_unreachable() is not supported: */ -#define g_assert_not_reached() G_STMT_START { (void) 0; } G_STMT_END -#endif - -#define g_assert(expr) G_STMT_START { (void) 0; } G_STMT_END -#else /* !G_DISABLE_ASSERT */ -#define g_assert_not_reached() G_STMT_START { g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } G_STMT_END -#define g_assert(expr) G_STMT_START { \ - if G_LIKELY (expr) ; else \ - g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \ - #expr); \ - } G_STMT_END -#endif /* !G_DISABLE_ASSERT */ - -typedef void (*GAssertionFunc) (const char *domain, - const char *file, - int line, - const char *func, - const char *message, - gpointer user_data); - -GLIB_AVAILABLE_IN_2_68 -void g_assertion_set_handler (GAssertionFunc handler, - gpointer user_data); - -GLIB_AVAILABLE_IN_ALL -int g_strcmp0 (const char *str1, - const char *str2); - -/* report performance results */ -GLIB_AVAILABLE_IN_ALL -void g_test_minimized_result (double minimized_quantity, - const char *format, - ...) G_GNUC_PRINTF (2, 3); -GLIB_AVAILABLE_IN_ALL -void g_test_maximized_result (double maximized_quantity, - const char *format, - ...) G_GNUC_PRINTF (2, 3); - -/* initialize testing framework */ -GLIB_AVAILABLE_IN_ALL -void g_test_init (int *argc, - char ***argv, - ...) G_GNUC_NULL_TERMINATED; - -/** - * G_TEST_OPTION_ISOLATE_DIRS: - * - * Creates a unique temporary directory for each unit test and uses - * g_set_user_dirs() to set XDG directories to point into subdirectories of it - * for the duration of the unit test. The directory tree is cleaned up after the - * test finishes successfully. Note that this doesn’t take effect until - * g_test_run() is called, so calls to (for example) g_get_user_home_dir() will - * return the system-wide value when made in a test program’s main() function. - * - * The following functions will return subdirectories of the temporary directory - * when this option is used. The specific subdirectory paths in use are not - * guaranteed to be stable API — always use a getter function to retrieve them. - * - * - g_get_home_dir() - * - g_get_user_cache_dir() - * - g_get_system_config_dirs() - * - g_get_user_config_dir() - * - g_get_system_data_dirs() - * - g_get_user_data_dir() - * - g_get_user_runtime_dir() - * - * The subdirectories may not be created by the test harness; as with normal - * calls to functions like g_get_user_cache_dir(), the caller must be prepared - * to create the directory if it doesn’t exist. - * - * Since: 2.60 - */ -#define G_TEST_OPTION_ISOLATE_DIRS "isolate_dirs" - -/* While we discourage its use, g_assert() is often used in unit tests - * (especially in legacy code). g_assert_*() should really be used instead. - * g_assert() can be disabled at client program compile time, which can render - * tests useless. Highlight that to the user. */ -#ifdef G_DISABLE_ASSERT -#if defined(G_HAVE_ISO_VARARGS) -#undef g_test_init -#define g_test_init(argc, argv, ...) \ - G_STMT_START { \ - g_printerr ("Tests were compiled with G_DISABLE_ASSERT and are likely no-ops. Aborting.\n"); \ - exit (1); \ - } G_STMT_END -#elif defined(G_HAVE_GNUC_VARARGS) -#undef g_test_init -#define g_test_init(argc, argv...) \ - G_STMT_START { \ - g_printerr ("Tests were compiled with G_DISABLE_ASSERT and are likely no-ops. Aborting.\n"); \ - exit (1); \ - } G_STMT_END -#else /* no varargs */ - /* do nothing */ -#endif /* varargs support */ -#endif /* G_DISABLE_ASSERT */ - -/* query testing framework config */ -#define g_test_initialized() (g_test_config_vars->test_initialized) -#define g_test_quick() (g_test_config_vars->test_quick) -#define g_test_slow() (!g_test_config_vars->test_quick) -#define g_test_thorough() (!g_test_config_vars->test_quick) -#define g_test_perf() (g_test_config_vars->test_perf) -#define g_test_verbose() (g_test_config_vars->test_verbose) -#define g_test_quiet() (g_test_config_vars->test_quiet) -#define g_test_undefined() (g_test_config_vars->test_undefined) -GLIB_AVAILABLE_IN_2_38 -gboolean g_test_subprocess (void); - -/* run all tests under toplevel suite (path: /) */ -GLIB_AVAILABLE_IN_ALL -int g_test_run (void); -/* hook up a test functions under test path */ -GLIB_AVAILABLE_IN_ALL -void g_test_add_func (const char *testpath, - GTestFunc test_func); - -GLIB_AVAILABLE_IN_ALL -void g_test_add_data_func (const char *testpath, - gconstpointer test_data, - GTestDataFunc test_func); - -GLIB_AVAILABLE_IN_2_34 -void g_test_add_data_func_full (const char *testpath, - gpointer test_data, - GTestDataFunc test_func, - GDestroyNotify data_free_func); - -/* tell about failure */ -GLIB_AVAILABLE_IN_2_30 -void g_test_fail (void); -GLIB_AVAILABLE_IN_2_38 -void g_test_incomplete (const gchar *msg); -GLIB_AVAILABLE_IN_2_38 -void g_test_skip (const gchar *msg); -GLIB_AVAILABLE_IN_2_38 -gboolean g_test_failed (void); -GLIB_AVAILABLE_IN_2_38 -void g_test_set_nonfatal_assertions (void); - -/** - * g_test_add: - * @testpath: The test path for a new test case. - * @Fixture: The type of a fixture data structure. - * @tdata: Data argument for the test functions. - * @fsetup: The function to set up the fixture data. - * @ftest: The actual test function. - * @fteardown: The function to tear down the fixture data. - * - * Hook up a new test case at @testpath, similar to g_test_add_func(). - * A fixture data structure with setup and teardown functions may be provided, - * similar to g_test_create_case(). - * - * g_test_add() is implemented as a macro, so that the fsetup(), ftest() and - * fteardown() callbacks can expect a @Fixture pointer as their first argument - * in a type safe manner. They otherwise have type #GTestFixtureFunc. - * - * Since: 2.16 - */ -#define g_test_add(testpath, Fixture, tdata, fsetup, ftest, fteardown) \ - G_STMT_START { \ - void (*add_vtable) (const char*, \ - gsize, \ - gconstpointer, \ - void (*) (Fixture*, gconstpointer), \ - void (*) (Fixture*, gconstpointer), \ - void (*) (Fixture*, gconstpointer)) = (void (*) (const gchar *, gsize, gconstpointer, void (*) (Fixture*, gconstpointer), void (*) (Fixture*, gconstpointer), void (*) (Fixture*, gconstpointer))) g_test_add_vtable; \ - add_vtable \ - (testpath, sizeof (Fixture), tdata, fsetup, ftest, fteardown); \ - } G_STMT_END - -/* add test messages to the test report */ -GLIB_AVAILABLE_IN_ALL -void g_test_message (const char *format, - ...) G_GNUC_PRINTF (1, 2); -GLIB_AVAILABLE_IN_ALL -void g_test_bug_base (const char *uri_pattern); -GLIB_AVAILABLE_IN_ALL -void g_test_bug (const char *bug_uri_snippet); -GLIB_AVAILABLE_IN_2_62 -void g_test_summary (const char *summary); -/* measure test timings */ -GLIB_AVAILABLE_IN_ALL -void g_test_timer_start (void); -GLIB_AVAILABLE_IN_ALL -double g_test_timer_elapsed (void); /* elapsed seconds */ -GLIB_AVAILABLE_IN_ALL -double g_test_timer_last (void); /* repeat last elapsed() result */ - -/* automatically g_free or g_object_unref upon teardown */ -GLIB_AVAILABLE_IN_ALL -void g_test_queue_free (gpointer gfree_pointer); -GLIB_AVAILABLE_IN_ALL -void g_test_queue_destroy (GDestroyNotify destroy_func, - gpointer destroy_data); -#define g_test_queue_unref(gobject) g_test_queue_destroy (g_object_unref, gobject) - -/** - * GTestTrapFlags: - * @G_TEST_TRAP_SILENCE_STDOUT: Redirect stdout of the test child to - * `/dev/null` so it cannot be observed on the console during test - * runs. The actual output is still captured though to allow later - * tests with g_test_trap_assert_stdout(). - * @G_TEST_TRAP_SILENCE_STDERR: Redirect stderr of the test child to - * `/dev/null` so it cannot be observed on the console during test - * runs. The actual output is still captured though to allow later - * tests with g_test_trap_assert_stderr(). - * @G_TEST_TRAP_INHERIT_STDIN: If this flag is given, stdin of the - * child process is shared with stdin of its parent process. - * It is redirected to `/dev/null` otherwise. - * - * Test traps are guards around forked tests. - * These flags determine what traps to set. - * - * Deprecated: 2.38: #GTestTrapFlags is used only with g_test_trap_fork(), - * which is deprecated. g_test_trap_subprocess() uses - * #GTestSubprocessFlags. - */ -typedef enum { - G_TEST_TRAP_SILENCE_STDOUT = 1 << 7, - G_TEST_TRAP_SILENCE_STDERR = 1 << 8, - G_TEST_TRAP_INHERIT_STDIN = 1 << 9 -} GTestTrapFlags GLIB_DEPRECATED_TYPE_IN_2_38_FOR(GTestSubprocessFlags); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -GLIB_DEPRECATED_IN_2_38_FOR (g_test_trap_subprocess) -gboolean g_test_trap_fork (guint64 usec_timeout, - GTestTrapFlags test_trap_flags); - -G_GNUC_END_IGNORE_DEPRECATIONS - -typedef enum { - G_TEST_SUBPROCESS_INHERIT_STDIN = 1 << 0, - G_TEST_SUBPROCESS_INHERIT_STDOUT = 1 << 1, - G_TEST_SUBPROCESS_INHERIT_STDERR = 1 << 2 -} GTestSubprocessFlags; - -GLIB_AVAILABLE_IN_2_38 -void g_test_trap_subprocess (const char *test_path, - guint64 usec_timeout, - GTestSubprocessFlags test_flags); - -GLIB_AVAILABLE_IN_ALL -gboolean g_test_trap_has_passed (void); -GLIB_AVAILABLE_IN_ALL -gboolean g_test_trap_reached_timeout (void); -#define g_test_trap_assert_passed() g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 0, 0) -#define g_test_trap_assert_failed() g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 1, 0) -#define g_test_trap_assert_stdout(soutpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 2, soutpattern) -#define g_test_trap_assert_stdout_unmatched(soutpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 3, soutpattern) -#define g_test_trap_assert_stderr(serrpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 4, serrpattern) -#define g_test_trap_assert_stderr_unmatched(serrpattern) g_test_trap_assertions (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, 5, serrpattern) - -/* provide seed-able random numbers for tests */ -#define g_test_rand_bit() (0 != (g_test_rand_int() & (1 << 15))) -GLIB_AVAILABLE_IN_ALL -gint32 g_test_rand_int (void); -GLIB_AVAILABLE_IN_ALL -gint32 g_test_rand_int_range (gint32 begin, - gint32 end); -GLIB_AVAILABLE_IN_ALL -double g_test_rand_double (void); -GLIB_AVAILABLE_IN_ALL -double g_test_rand_double_range (double range_start, - double range_end); - -/* - * semi-internal API: non-documented symbols with stable ABI. You - * should use the non-internal helper macros instead. However, for - * compatibility reason, you may use this semi-internal API. - */ -GLIB_AVAILABLE_IN_ALL -GTestCase* g_test_create_case (const char *test_name, - gsize data_size, - gconstpointer test_data, - GTestFixtureFunc data_setup, - GTestFixtureFunc data_test, - GTestFixtureFunc data_teardown); -GLIB_AVAILABLE_IN_ALL -GTestSuite* g_test_create_suite (const char *suite_name); -GLIB_AVAILABLE_IN_ALL -GTestSuite* g_test_get_root (void); -GLIB_AVAILABLE_IN_ALL -void g_test_suite_add (GTestSuite *suite, - GTestCase *test_case); -GLIB_AVAILABLE_IN_ALL -void g_test_suite_add_suite (GTestSuite *suite, - GTestSuite *nestedsuite); -GLIB_AVAILABLE_IN_ALL -int g_test_run_suite (GTestSuite *suite); - -GLIB_AVAILABLE_IN_ALL -void g_test_trap_assertions (const char *domain, - const char *file, - int line, - const char *func, - guint64 assertion_flags, /* 0-pass, 1-fail, 2-outpattern, 4-errpattern */ - const char *pattern); -GLIB_AVAILABLE_IN_ALL -void g_assertion_message (const char *domain, - const char *file, - int line, - const char *func, - const char *message) G_ANALYZER_NORETURN; -GLIB_AVAILABLE_IN_ALL -G_NORETURN -void g_assertion_message_expr (const char *domain, - const char *file, - int line, - const char *func, - const char *expr); -GLIB_AVAILABLE_IN_ALL -void g_assertion_message_cmpstr (const char *domain, - const char *file, - int line, - const char *func, - const char *expr, - const char *arg1, - const char *cmp, - const char *arg2) G_ANALYZER_NORETURN; - -GLIB_AVAILABLE_IN_2_68 -void g_assertion_message_cmpstrv (const char *domain, - const char *file, - int line, - const char *func, - const char *expr, - const char * const *arg1, - const char * const *arg2, - gsize first_wrong_idx) G_ANALYZER_NORETURN; -GLIB_AVAILABLE_IN_ALL -void g_assertion_message_cmpnum (const char *domain, - const char *file, - int line, - const char *func, - const char *expr, - long double arg1, - const char *cmp, - long double arg2, - char numtype) G_ANALYZER_NORETURN; -GLIB_AVAILABLE_IN_ALL -void g_assertion_message_error (const char *domain, - const char *file, - int line, - const char *func, - const char *expr, - const GError *error, - GQuark error_domain, - int error_code) G_ANALYZER_NORETURN; -GLIB_AVAILABLE_IN_ALL -void g_test_add_vtable (const char *testpath, - gsize data_size, - gconstpointer test_data, - GTestFixtureFunc data_setup, - GTestFixtureFunc data_test, - GTestFixtureFunc data_teardown); -typedef struct { - gboolean test_initialized; - gboolean test_quick; /* disable thorough tests */ - gboolean test_perf; /* run performance tests */ - gboolean test_verbose; /* extra info */ - gboolean test_quiet; /* reduce output */ - gboolean test_undefined; /* run tests that are meant to assert */ -} GTestConfig; -GLIB_VAR const GTestConfig * const g_test_config_vars; - -/* internal logging API */ -typedef enum { - G_TEST_RUN_SUCCESS, - G_TEST_RUN_SKIPPED, - G_TEST_RUN_FAILURE, - G_TEST_RUN_INCOMPLETE -} GTestResult; - -typedef enum { - G_TEST_LOG_NONE, - G_TEST_LOG_ERROR, /* s:msg */ - G_TEST_LOG_START_BINARY, /* s:binaryname s:seed */ - G_TEST_LOG_LIST_CASE, /* s:testpath */ - G_TEST_LOG_SKIP_CASE, /* s:testpath */ - G_TEST_LOG_START_CASE, /* s:testpath */ - G_TEST_LOG_STOP_CASE, /* d:status d:nforks d:elapsed */ - G_TEST_LOG_MIN_RESULT, /* s:blurb d:result */ - G_TEST_LOG_MAX_RESULT, /* s:blurb d:result */ - G_TEST_LOG_MESSAGE, /* s:blurb */ - G_TEST_LOG_START_SUITE, - G_TEST_LOG_STOP_SUITE -} GTestLogType; - -typedef struct { - GTestLogType log_type; - guint n_strings; - gchar **strings; /* NULL terminated */ - guint n_nums; - long double *nums; -} GTestLogMsg; -typedef struct { - /*< private >*/ - GString *data; - GSList *msgs; -} GTestLogBuffer; - -GLIB_AVAILABLE_IN_ALL -const char* g_test_log_type_name (GTestLogType log_type); -GLIB_AVAILABLE_IN_ALL -GTestLogBuffer* g_test_log_buffer_new (void); -GLIB_AVAILABLE_IN_ALL -void g_test_log_buffer_free (GTestLogBuffer *tbuffer); -GLIB_AVAILABLE_IN_ALL -void g_test_log_buffer_push (GTestLogBuffer *tbuffer, - guint n_bytes, - const guint8 *bytes); -GLIB_AVAILABLE_IN_ALL -GTestLogMsg* g_test_log_buffer_pop (GTestLogBuffer *tbuffer); -GLIB_AVAILABLE_IN_ALL -void g_test_log_msg_free (GTestLogMsg *tmsg); - -/** - * GTestLogFatalFunc: - * @log_domain: the log domain of the message - * @log_level: the log level of the message (including the fatal and recursion flags) - * @message: the message to process - * @user_data: user data, set in g_test_log_set_fatal_handler() - * - * Specifies the prototype of fatal log handler functions. - * - * Returns: %TRUE if the program should abort, %FALSE otherwise - * - * Since: 2.22 - */ -typedef gboolean (*GTestLogFatalFunc) (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data); -GLIB_AVAILABLE_IN_ALL -void -g_test_log_set_fatal_handler (GTestLogFatalFunc log_func, - gpointer user_data); - -GLIB_AVAILABLE_IN_2_34 -void g_test_expect_message (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *pattern); -GLIB_AVAILABLE_IN_2_34 -void g_test_assert_expected_messages_internal (const char *domain, - const char *file, - int line, - const char *func); - -typedef enum -{ - G_TEST_DIST, - G_TEST_BUILT -} GTestFileType; - -GLIB_AVAILABLE_IN_2_38 -gchar * g_test_build_filename (GTestFileType file_type, - const gchar *first_path, - ...) G_GNUC_NULL_TERMINATED; -GLIB_AVAILABLE_IN_2_38 -const gchar *g_test_get_dir (GTestFileType file_type); -GLIB_AVAILABLE_IN_2_38 -const gchar *g_test_get_filename (GTestFileType file_type, - const gchar *first_path, - ...) G_GNUC_NULL_TERMINATED; - -#define g_test_assert_expected_messages() g_test_assert_expected_messages_internal (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC) - -G_END_DECLS - -#endif /* __G_TEST_UTILS_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_THREADPOOL_H__ -#define __G_THREADPOOL_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GThreadPool GThreadPool; - -/* Thread Pools - */ - -struct _GThreadPool -{ - GFunc func; - gpointer user_data; - gboolean exclusive; -}; - -GLIB_AVAILABLE_IN_ALL -GThreadPool * g_thread_pool_new (GFunc func, - gpointer user_data, - gint max_threads, - gboolean exclusive, - GError **error); -GLIB_AVAILABLE_IN_ALL -void g_thread_pool_free (GThreadPool *pool, - gboolean immediate, - gboolean wait_); -GLIB_AVAILABLE_IN_ALL -gboolean g_thread_pool_push (GThreadPool *pool, - gpointer data, - GError **error); -GLIB_AVAILABLE_IN_ALL -guint g_thread_pool_unprocessed (GThreadPool *pool); -GLIB_AVAILABLE_IN_ALL -void g_thread_pool_set_sort_function (GThreadPool *pool, - GCompareDataFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_46 -gboolean g_thread_pool_move_to_front (GThreadPool *pool, - gpointer data); - -GLIB_AVAILABLE_IN_ALL -gboolean g_thread_pool_set_max_threads (GThreadPool *pool, - gint max_threads, - GError **error); -GLIB_AVAILABLE_IN_ALL -gint g_thread_pool_get_max_threads (GThreadPool *pool); -GLIB_AVAILABLE_IN_ALL -guint g_thread_pool_get_num_threads (GThreadPool *pool); - -GLIB_AVAILABLE_IN_ALL -void g_thread_pool_set_max_unused_threads (gint max_threads); -GLIB_AVAILABLE_IN_ALL -gint g_thread_pool_get_max_unused_threads (void); -GLIB_AVAILABLE_IN_ALL -guint g_thread_pool_get_num_unused_threads (void); -GLIB_AVAILABLE_IN_ALL -void g_thread_pool_stop_unused_threads (void); -GLIB_AVAILABLE_IN_ALL -void g_thread_pool_set_max_idle_time (guint interval); -GLIB_AVAILABLE_IN_ALL -guint g_thread_pool_get_max_idle_time (void); - -G_END_DECLS - -#endif /* __G_THREADPOOL_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_TIMER_H__ -#define __G_TIMER_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* Timer - */ - -/* microseconds per second */ -typedef struct _GTimer GTimer; - -#define G_USEC_PER_SEC 1000000 - -GLIB_AVAILABLE_IN_ALL -GTimer* g_timer_new (void); -GLIB_AVAILABLE_IN_ALL -void g_timer_destroy (GTimer *timer); -GLIB_AVAILABLE_IN_ALL -void g_timer_start (GTimer *timer); -GLIB_AVAILABLE_IN_ALL -void g_timer_stop (GTimer *timer); -GLIB_AVAILABLE_IN_ALL -void g_timer_reset (GTimer *timer); -GLIB_AVAILABLE_IN_ALL -void g_timer_continue (GTimer *timer); -GLIB_AVAILABLE_IN_ALL -gdouble g_timer_elapsed (GTimer *timer, - gulong *microseconds); -GLIB_AVAILABLE_IN_2_62 -gboolean g_timer_is_active (GTimer *timer); - -GLIB_AVAILABLE_IN_ALL -void g_usleep (gulong microseconds); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED_IN_2_62 -void g_time_val_add (GTimeVal *time_, - glong microseconds); -GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_new_from_iso8601) -gboolean g_time_val_from_iso8601 (const gchar *iso_date, - GTimeVal *time_); -GLIB_DEPRECATED_IN_2_62_FOR(g_date_time_format) -gchar* g_time_val_to_iso8601 (GTimeVal *time_) G_GNUC_MALLOC; -G_GNUC_END_IGNORE_DEPRECATIONS - -G_END_DECLS - -#endif /* __G_TIMER_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_TRASH_STACK_H__ -#define __G_TRASH_STACK_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -typedef struct _GTrashStack GTrashStack GLIB_DEPRECATED_TYPE_IN_2_48; -struct _GTrashStack -{ - GTrashStack *next; -} GLIB_DEPRECATED_TYPE_IN_2_48; - -GLIB_DEPRECATED_IN_2_48 -void g_trash_stack_push (GTrashStack **stack_p, - gpointer data_p); -GLIB_DEPRECATED_IN_2_48 -gpointer g_trash_stack_pop (GTrashStack **stack_p); -GLIB_DEPRECATED_IN_2_48 -gpointer g_trash_stack_peek (GTrashStack **stack_p); -GLIB_DEPRECATED_IN_2_48 -guint g_trash_stack_height (GTrashStack **stack_p); - -G_GNUC_END_IGNORE_DEPRECATIONS - -G_END_DECLS - -#endif /* __G_TRASH_STACK_H_ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_TREE_H__ -#define __G_TREE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -#undef G_TREE_DEBUG - -typedef struct _GTree GTree; - -/** - * GTreeNode: - * - * An opaque type which identifies a specific node in a #GTree. - * - * Since: 2.68 - */ -typedef struct _GTreeNode GTreeNode; - -typedef gboolean (*GTraverseFunc) (gpointer key, - gpointer value, - gpointer data); - -/** - * GTraverseNodeFunc: - * @node: a #GTreeNode - * @data: user data passed to g_tree_foreach_node() - * - * Specifies the type of function passed to g_tree_foreach_node(). It is - * passed each node, together with the @user_data parameter passed to - * g_tree_foreach_node(). If the function returns %TRUE, the traversal is - * stopped. - * - * Returns: %TRUE to stop the traversal - * Since: 2.68 - */ -typedef gboolean (*GTraverseNodeFunc) (GTreeNode *node, - gpointer data); - -/* Balanced binary trees - */ -GLIB_AVAILABLE_IN_ALL -GTree* g_tree_new (GCompareFunc key_compare_func); -GLIB_AVAILABLE_IN_ALL -GTree* g_tree_new_with_data (GCompareDataFunc key_compare_func, - gpointer key_compare_data); -GLIB_AVAILABLE_IN_ALL -GTree* g_tree_new_full (GCompareDataFunc key_compare_func, - gpointer key_compare_data, - GDestroyNotify key_destroy_func, - GDestroyNotify value_destroy_func); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_node_first (GTree *tree); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_node_last (GTree *tree); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_node_previous (GTreeNode *node); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_node_next (GTreeNode *node); -GLIB_AVAILABLE_IN_ALL -GTree* g_tree_ref (GTree *tree); -GLIB_AVAILABLE_IN_ALL -void g_tree_unref (GTree *tree); -GLIB_AVAILABLE_IN_ALL -void g_tree_destroy (GTree *tree); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_insert_node (GTree *tree, - gpointer key, - gpointer value); -GLIB_AVAILABLE_IN_ALL -void g_tree_insert (GTree *tree, - gpointer key, - gpointer value); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_replace_node (GTree *tree, - gpointer key, - gpointer value); -GLIB_AVAILABLE_IN_ALL -void g_tree_replace (GTree *tree, - gpointer key, - gpointer value); -GLIB_AVAILABLE_IN_ALL -gboolean g_tree_remove (GTree *tree, - gconstpointer key); -GLIB_AVAILABLE_IN_ALL -gboolean g_tree_steal (GTree *tree, - gconstpointer key); -GLIB_AVAILABLE_IN_2_68 -gpointer g_tree_node_key (GTreeNode *node); -GLIB_AVAILABLE_IN_2_68 -gpointer g_tree_node_value (GTreeNode *node); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_lookup_node (GTree *tree, - gconstpointer key); -GLIB_AVAILABLE_IN_ALL -gpointer g_tree_lookup (GTree *tree, - gconstpointer key); -GLIB_AVAILABLE_IN_ALL -gboolean g_tree_lookup_extended (GTree *tree, - gconstpointer lookup_key, - gpointer *orig_key, - gpointer *value); -GLIB_AVAILABLE_IN_ALL -void g_tree_foreach (GTree *tree, - GTraverseFunc func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_68 -void g_tree_foreach_node (GTree *tree, - GTraverseNodeFunc func, - gpointer user_data); - -GLIB_DEPRECATED -void g_tree_traverse (GTree *tree, - GTraverseFunc traverse_func, - GTraverseType traverse_type, - gpointer user_data); - -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_search_node (GTree *tree, - GCompareFunc search_func, - gconstpointer user_data); -GLIB_AVAILABLE_IN_ALL -gpointer g_tree_search (GTree *tree, - GCompareFunc search_func, - gconstpointer user_data); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_lower_bound (GTree *tree, - gconstpointer key); -GLIB_AVAILABLE_IN_2_68 -GTreeNode *g_tree_upper_bound (GTree *tree, - gconstpointer key); -GLIB_AVAILABLE_IN_ALL -gint g_tree_height (GTree *tree); -GLIB_AVAILABLE_IN_ALL -gint g_tree_nnodes (GTree *tree); - -#ifdef G_TREE_DEBUG -/*< private >*/ -#ifndef __GTK_DOC_IGNORE__ -void g_tree_dump (GTree *tree); -#endif /* !__GTK_DOC_IGNORE__ */ -#endif /* G_TREE_DEBUG */ - -G_END_DECLS - -#endif /* __G_TREE_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright © 2020 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see - * . - */ - -#pragma once - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -typedef struct _GUri GUri; - -GLIB_AVAILABLE_IN_2_66 -GUri * g_uri_ref (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -void g_uri_unref (GUri *uri); - -/** - * GUriFlags: - * @G_URI_FLAGS_NONE: No flags set. - * @G_URI_FLAGS_PARSE_RELAXED: Parse the URI more relaxedly than the - * [RFC 3986](https://tools.ietf.org/html/rfc3986) grammar specifies, - * fixing up or ignoring common mistakes in URIs coming from external - * sources. This is also needed for some obscure URI schemes where `;` - * separates the host from the path. Don’t use this flag unless you need to. - * @G_URI_FLAGS_HAS_PASSWORD: The userinfo field may contain a password, - * which will be separated from the username by `:`. - * @G_URI_FLAGS_HAS_AUTH_PARAMS: The userinfo may contain additional - * authentication-related parameters, which will be separated from - * the username and/or password by `;`. - * @G_URI_FLAGS_NON_DNS: The host component should not be assumed to be a - * DNS hostname or IP address (for example, for `smb` URIs with NetBIOS - * hostnames). - * @G_URI_FLAGS_ENCODED: When parsing a URI, this indicates that `%`-encoded - * characters in the userinfo, path, query, and fragment fields - * should not be decoded. (And likewise the host field if - * %G_URI_FLAGS_NON_DNS is also set.) When building a URI, it indicates - * that you have already `%`-encoded the components, and so #GUri - * should not do any encoding itself. - * @G_URI_FLAGS_ENCODED_QUERY: Same as %G_URI_FLAGS_ENCODED, for the query - * field only. - * @G_URI_FLAGS_ENCODED_PATH: Same as %G_URI_FLAGS_ENCODED, for the path only. - * @G_URI_FLAGS_ENCODED_FRAGMENT: Same as %G_URI_FLAGS_ENCODED, for the - * fragment only. - * @G_URI_FLAGS_SCHEME_NORMALIZE: A scheme-based normalization will be applied. - * For example, when parsing an HTTP URI changing omitted path to `/` and - * omitted port to `80`; and when building a URI, changing empty path to `/` - * and default port `80`). This only supports a subset of known schemes. (Since: 2.68) - * - * Flags that describe a URI. - * - * When parsing a URI, if you need to choose different flags based on - * the type of URI, you can use g_uri_peek_scheme() on the URI string - * to check the scheme first, and use that to decide what flags to - * parse it with. - * - * Since: 2.66 - */ -GLIB_AVAILABLE_TYPE_IN_2_66 -typedef enum { - G_URI_FLAGS_NONE = 0, - G_URI_FLAGS_PARSE_RELAXED = 1 << 0, - G_URI_FLAGS_HAS_PASSWORD = 1 << 1, - G_URI_FLAGS_HAS_AUTH_PARAMS = 1 << 2, - G_URI_FLAGS_ENCODED = 1 << 3, - G_URI_FLAGS_NON_DNS = 1 << 4, - G_URI_FLAGS_ENCODED_QUERY = 1 << 5, - G_URI_FLAGS_ENCODED_PATH = 1 << 6, - G_URI_FLAGS_ENCODED_FRAGMENT = 1 << 7, - G_URI_FLAGS_SCHEME_NORMALIZE = 1 << 8, -} GUriFlags; - -GLIB_AVAILABLE_IN_2_66 -gboolean g_uri_split (const gchar *uri_ref, - GUriFlags flags, - gchar **scheme, - gchar **userinfo, - gchar **host, - gint *port, - gchar **path, - gchar **query, - gchar **fragment, - GError **error); -GLIB_AVAILABLE_IN_2_66 -gboolean g_uri_split_with_user (const gchar *uri_ref, - GUriFlags flags, - gchar **scheme, - gchar **user, - gchar **password, - gchar **auth_params, - gchar **host, - gint *port, - gchar **path, - gchar **query, - gchar **fragment, - GError **error); -GLIB_AVAILABLE_IN_2_66 -gboolean g_uri_split_network (const gchar *uri_string, - GUriFlags flags, - gchar **scheme, - gchar **host, - gint *port, - GError **error); - -GLIB_AVAILABLE_IN_2_66 -gboolean g_uri_is_valid (const gchar *uri_string, - GUriFlags flags, - GError **error); - -GLIB_AVAILABLE_IN_2_66 -gchar * g_uri_join (GUriFlags flags, - const gchar *scheme, - const gchar *userinfo, - const gchar *host, - gint port, - const gchar *path, - const gchar *query, - const gchar *fragment); -GLIB_AVAILABLE_IN_2_66 -gchar * g_uri_join_with_user (GUriFlags flags, - const gchar *scheme, - const gchar *user, - const gchar *password, - const gchar *auth_params, - const gchar *host, - gint port, - const gchar *path, - const gchar *query, - const gchar *fragment); - -GLIB_AVAILABLE_IN_2_66 -GUri * g_uri_parse (const gchar *uri_string, - GUriFlags flags, - GError **error); -GLIB_AVAILABLE_IN_2_66 -GUri * g_uri_parse_relative (GUri *base_uri, - const gchar *uri_ref, - GUriFlags flags, - GError **error); - -GLIB_AVAILABLE_IN_2_66 -gchar * g_uri_resolve_relative (const gchar *base_uri_string, - const gchar *uri_ref, - GUriFlags flags, - GError **error); - -GLIB_AVAILABLE_IN_2_66 -GUri * g_uri_build (GUriFlags flags, - const gchar *scheme, - const gchar *userinfo, - const gchar *host, - gint port, - const gchar *path, - const gchar *query, - const gchar *fragment); -GLIB_AVAILABLE_IN_2_66 -GUri * g_uri_build_with_user (GUriFlags flags, - const gchar *scheme, - const gchar *user, - const gchar *password, - const gchar *auth_params, - const gchar *host, - gint port, - const gchar *path, - const gchar *query, - const gchar *fragment); - -/** - * GUriHideFlags: - * @G_URI_HIDE_NONE: No flags set. - * @G_URI_HIDE_USERINFO: Hide the userinfo. - * @G_URI_HIDE_PASSWORD: Hide the password. - * @G_URI_HIDE_AUTH_PARAMS: Hide the auth_params. - * @G_URI_HIDE_QUERY: Hide the query. - * @G_URI_HIDE_FRAGMENT: Hide the fragment. - * - * Flags describing what parts of the URI to hide in - * g_uri_to_string_partial(). Note that %G_URI_HIDE_PASSWORD and - * %G_URI_HIDE_AUTH_PARAMS will only work if the #GUri was parsed with - * the corresponding flags. - * - * Since: 2.66 - */ -GLIB_AVAILABLE_TYPE_IN_2_66 -typedef enum { - G_URI_HIDE_NONE = 0, - G_URI_HIDE_USERINFO = 1 << 0, - G_URI_HIDE_PASSWORD = 1 << 1, - G_URI_HIDE_AUTH_PARAMS = 1 << 2, - G_URI_HIDE_QUERY = 1 << 3, - G_URI_HIDE_FRAGMENT = 1 << 4, -} GUriHideFlags; - -GLIB_AVAILABLE_IN_2_66 -char * g_uri_to_string (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -char * g_uri_to_string_partial (GUri *uri, - GUriHideFlags flags); - -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_scheme (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_userinfo (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_user (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_password (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_auth_params (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_host (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -gint g_uri_get_port (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_path (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_query (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -const gchar *g_uri_get_fragment (GUri *uri); -GLIB_AVAILABLE_IN_2_66 -GUriFlags g_uri_get_flags (GUri *uri); - -/** - * GUriParamsFlags: - * @G_URI_PARAMS_NONE: No flags set. - * @G_URI_PARAMS_CASE_INSENSITIVE: Parameter names are case insensitive. - * @G_URI_PARAMS_WWW_FORM: Replace `+` with space character. Only useful for - * URLs on the web, using the `https` or `http` schemas. - * @G_URI_PARAMS_PARSE_RELAXED: See %G_URI_FLAGS_PARSE_RELAXED. - * - * Flags modifying the way parameters are handled by g_uri_parse_params() and - * #GUriParamsIter. - * - * Since: 2.66 - */ -GLIB_AVAILABLE_TYPE_IN_2_66 -typedef enum { - G_URI_PARAMS_NONE = 0, - G_URI_PARAMS_CASE_INSENSITIVE = 1 << 0, - G_URI_PARAMS_WWW_FORM = 1 << 1, - G_URI_PARAMS_PARSE_RELAXED = 1 << 2, -} GUriParamsFlags; - -GLIB_AVAILABLE_IN_2_66 -GHashTable *g_uri_parse_params (const gchar *params, - gssize length, - const gchar *separators, - GUriParamsFlags flags, - GError **error); - -typedef struct _GUriParamsIter GUriParamsIter; - -struct _GUriParamsIter -{ - /*< private >*/ - gint dummy0; - gpointer dummy1; - gpointer dummy2; - guint8 dummy3[256]; -}; - -GLIB_AVAILABLE_IN_2_66 -void g_uri_params_iter_init (GUriParamsIter *iter, - const gchar *params, - gssize length, - const gchar *separators, - GUriParamsFlags flags); - -GLIB_AVAILABLE_IN_2_66 -gboolean g_uri_params_iter_next (GUriParamsIter *iter, - gchar **attribute, - gchar **value, - GError **error); - -/** - * G_URI_ERROR: - * - * Error domain for URI methods. Errors in this domain will be from - * the #GUriError enumeration. See #GError for information on error - * domains. - * - * Since: 2.66 - */ -#define G_URI_ERROR (g_uri_error_quark ()) GLIB_AVAILABLE_MACRO_IN_2_66 -GLIB_AVAILABLE_IN_2_66 -GQuark g_uri_error_quark (void); - -/** - * GUriError: - * @G_URI_ERROR_FAILED: Generic error if no more specific error is available. - * See the error message for details. - * @G_URI_ERROR_BAD_SCHEME: The scheme of a URI could not be parsed. - * @G_URI_ERROR_BAD_USER: The user/userinfo of a URI could not be parsed. - * @G_URI_ERROR_BAD_PASSWORD: The password of a URI could not be parsed. - * @G_URI_ERROR_BAD_AUTH_PARAMS: The authentication parameters of a URI could not be parsed. - * @G_URI_ERROR_BAD_HOST: The host of a URI could not be parsed. - * @G_URI_ERROR_BAD_PORT: The port of a URI could not be parsed. - * @G_URI_ERROR_BAD_PATH: The path of a URI could not be parsed. - * @G_URI_ERROR_BAD_QUERY: The query of a URI could not be parsed. - * @G_URI_ERROR_BAD_FRAGMENT: The fragment of a URI could not be parsed. - * - * Error codes returned by #GUri methods. - * - * Since: 2.66 - */ -typedef enum { - G_URI_ERROR_FAILED, - G_URI_ERROR_BAD_SCHEME, - G_URI_ERROR_BAD_USER, - G_URI_ERROR_BAD_PASSWORD, - G_URI_ERROR_BAD_AUTH_PARAMS, - G_URI_ERROR_BAD_HOST, - G_URI_ERROR_BAD_PORT, - G_URI_ERROR_BAD_PATH, - G_URI_ERROR_BAD_QUERY, - G_URI_ERROR_BAD_FRAGMENT, -} GUriError; - -/** - * G_URI_RESERVED_CHARS_GENERIC_DELIMITERS: - * - * Generic delimiters characters as defined in - * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `:/?#[]@`. - * - * Since: 2.16 - **/ -#define G_URI_RESERVED_CHARS_GENERIC_DELIMITERS ":/?#[]@" - -/** - * G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS: - * - * Subcomponent delimiter characters as defined in - * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `!$&'()*+,;=`. - * - * Since: 2.16 - **/ -#define G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS "!$&'()*+,;=" - -/** - * G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT: - * - * Allowed characters in path elements. Includes `!$&'()*+,;=:@`. - * - * Since: 2.16 - **/ -#define G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":@" - -/** - * G_URI_RESERVED_CHARS_ALLOWED_IN_PATH: - * - * Allowed characters in a path. Includes `!$&'()*+,;=:@/`. - * - * Since: 2.16 - **/ -#define G_URI_RESERVED_CHARS_ALLOWED_IN_PATH G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT "/" - -/** - * G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO: - * - * Allowed characters in userinfo as defined in - * [RFC 3986](https://tools.ietf.org/html/rfc3986). Includes `!$&'()*+,;=:`. - * - * Since: 2.16 - **/ -#define G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS ":" - -GLIB_AVAILABLE_IN_ALL -char * g_uri_unescape_string (const char *escaped_string, - const char *illegal_characters); -GLIB_AVAILABLE_IN_ALL -char * g_uri_unescape_segment (const char *escaped_string, - const char *escaped_string_end, - const char *illegal_characters); - -GLIB_AVAILABLE_IN_ALL -char * g_uri_parse_scheme (const char *uri); -GLIB_AVAILABLE_IN_2_66 -const char *g_uri_peek_scheme (const char *uri); - -GLIB_AVAILABLE_IN_ALL -char * g_uri_escape_string (const char *unescaped, - const char *reserved_chars_allowed, - gboolean allow_utf8); - -GLIB_AVAILABLE_IN_2_66 -GBytes * g_uri_unescape_bytes (const char *escaped_string, - gssize length, - const char *illegal_characters, - GError **error); - -GLIB_AVAILABLE_IN_2_66 -char * g_uri_escape_bytes (const guint8 *unescaped, - gsize length, - const char *reserved_chars_allowed); - -G_GNUC_END_IGNORE_DEPRECATIONS - -G_END_DECLS -/* guuid.h - UUID functions - * - * Copyright (C) 2013-2015, 2017 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 of the - * licence, or (at your option) any later version. - * - * This is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA. - * - * Authors: Marc-André Lureau - */ - -#ifndef __G_UUID_H__ -#define __G_UUID_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_2_52 -gboolean g_uuid_string_is_valid (const gchar *str); - -GLIB_AVAILABLE_IN_2_52 -gchar * g_uuid_string_random (void); - -G_END_DECLS - -#endif /* __G_UUID_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_VERSION_H__ -#define __G_VERSION_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_VAR const guint glib_major_version; -GLIB_VAR const guint glib_minor_version; -GLIB_VAR const guint glib_micro_version; -GLIB_VAR const guint glib_interface_age; -GLIB_VAR const guint glib_binary_age; - -GLIB_AVAILABLE_IN_ALL -const gchar * glib_check_version (guint required_major, - guint required_minor, - guint required_micro); - -#define GLIB_CHECK_VERSION(major,minor,micro) \ - (GLIB_MAJOR_VERSION > (major) || \ - (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \ - (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \ - GLIB_MICRO_VERSION >= (micro))) - -G_END_DECLS - -#endif /* __G_VERSION_H__ */ - -#ifdef G_PLATFORM_WIN32 -#include -#endif - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -#ifndef __G_ALLOCATOR_H__ -#define __G_ALLOCATOR_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GAllocator GAllocator; -typedef struct _GMemChunk GMemChunk; - -#define G_ALLOC_ONLY 1 -#define G_ALLOC_AND_FREE 2 -#define G_ALLOCATOR_LIST 1 -#define G_ALLOCATOR_SLIST 2 -#define G_ALLOCATOR_NODE 3 - -#define g_chunk_new(type, chunk) ((type *) g_mem_chunk_alloc (chunk)) -#define g_chunk_new0(type, chunk) ((type *) g_mem_chunk_alloc0 (chunk)) -#define g_chunk_free(mem, mem_chunk) (g_mem_chunk_free (mem_chunk, mem)) -#define g_mem_chunk_create(type, x, y) (g_mem_chunk_new (NULL, sizeof (type), 0, 0)) - - -GLIB_DEPRECATED -GMemChunk * g_mem_chunk_new (const gchar *name, - gint atom_size, - gsize area_size, - gint type); -GLIB_DEPRECATED -void g_mem_chunk_destroy (GMemChunk *mem_chunk); -GLIB_DEPRECATED -gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk); -GLIB_DEPRECATED -gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk); -GLIB_DEPRECATED -void g_mem_chunk_free (GMemChunk *mem_chunk, - gpointer mem); -GLIB_DEPRECATED -void g_mem_chunk_clean (GMemChunk *mem_chunk); -GLIB_DEPRECATED -void g_mem_chunk_reset (GMemChunk *mem_chunk); -GLIB_DEPRECATED -void g_mem_chunk_print (GMemChunk *mem_chunk); -GLIB_DEPRECATED -void g_mem_chunk_info (void); -GLIB_DEPRECATED -void g_blow_chunks (void); - - -GLIB_DEPRECATED -GAllocator * g_allocator_new (const gchar *name, - guint n_preallocs); -GLIB_DEPRECATED -void g_allocator_free (GAllocator *allocator); -GLIB_DEPRECATED -void g_list_push_allocator (GAllocator *allocator); -GLIB_DEPRECATED -void g_list_pop_allocator (void); -GLIB_DEPRECATED -void g_slist_push_allocator (GAllocator *allocator); -GLIB_DEPRECATED -void g_slist_pop_allocator (void); -GLIB_DEPRECATED -void g_node_push_allocator (GAllocator *allocator); -GLIB_DEPRECATED -void g_node_pop_allocator (void); - -G_END_DECLS - -#endif /* __G_ALLOCATOR_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_CACHE_H__ -#define __G_CACHE_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GCache GCache GLIB_DEPRECATED_TYPE_IN_2_26_FOR(GHashTable); - -typedef gpointer (*GCacheNewFunc) (gpointer key) GLIB_DEPRECATED_TYPE_IN_2_26; -typedef gpointer (*GCacheDupFunc) (gpointer value) GLIB_DEPRECATED_TYPE_IN_2_26; -typedef void (*GCacheDestroyFunc) (gpointer value) GLIB_DEPRECATED_TYPE_IN_2_26; - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -/* Caches - */ -GLIB_DEPRECATED -GCache* g_cache_new (GCacheNewFunc value_new_func, - GCacheDestroyFunc value_destroy_func, - GCacheDupFunc key_dup_func, - GCacheDestroyFunc key_destroy_func, - GHashFunc hash_key_func, - GHashFunc hash_value_func, - GEqualFunc key_equal_func); -GLIB_DEPRECATED -void g_cache_destroy (GCache *cache); -GLIB_DEPRECATED -gpointer g_cache_insert (GCache *cache, - gpointer key); -GLIB_DEPRECATED -void g_cache_remove (GCache *cache, - gconstpointer value); -GLIB_DEPRECATED -void g_cache_key_foreach (GCache *cache, - GHFunc func, - gpointer user_data); -GLIB_DEPRECATED -void g_cache_value_foreach (GCache *cache, - GHFunc func, - gpointer user_data); - -G_GNUC_END_IGNORE_DEPRECATIONS - -G_END_DECLS - -#endif /* __G_CACHE_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_COMPLETION_H__ -#define __G_COMPLETION_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GCompletion GCompletion; - -typedef gchar* (*GCompletionFunc) (gpointer); - -/* GCompletion - */ - -typedef gint (*GCompletionStrncmpFunc) (const gchar *s1, - const gchar *s2, - gsize n); - -struct _GCompletion -{ - GList* items; - GCompletionFunc func; - - gchar* prefix; - GList* cache; - GCompletionStrncmpFunc strncmp_func; -}; - -GLIB_DEPRECATED_IN_2_26 -GCompletion* g_completion_new (GCompletionFunc func); -GLIB_DEPRECATED_IN_2_26 -void g_completion_add_items (GCompletion* cmp, - GList* items); -GLIB_DEPRECATED_IN_2_26 -void g_completion_remove_items (GCompletion* cmp, - GList* items); -GLIB_DEPRECATED_IN_2_26 -void g_completion_clear_items (GCompletion* cmp); -GLIB_DEPRECATED_IN_2_26 -GList* g_completion_complete (GCompletion* cmp, - const gchar* prefix, - gchar** new_prefix); -GLIB_DEPRECATED_IN_2_26 -GList* g_completion_complete_utf8 (GCompletion *cmp, - const gchar* prefix, - gchar** new_prefix); -GLIB_DEPRECATED_IN_2_26 -void g_completion_set_compare (GCompletion *cmp, - GCompletionStrncmpFunc strncmp_func); -GLIB_DEPRECATED_IN_2_26 -void g_completion_free (GCompletion* cmp); - -G_END_DECLS - -#endif /* __G_COMPLETION_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_DEPRECATED_MAIN_H__ -#define __G_DEPRECATED_MAIN_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* ============== Compat main loop stuff ================== */ - -/** - * g_main_new: - * @is_running: set to %TRUE to indicate that the loop is running. This - * is not very important since calling g_main_run() will set this - * to %TRUE anyway. - * - * Creates a new #GMainLoop for th default main context. - * - * Returns: a new #GMainLoop - * - * Deprecated: 2.2: Use g_main_loop_new() instead - */ -#define g_main_new(is_running) g_main_loop_new (NULL, is_running) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_new) - -/** - * g_main_run: - * @loop: a #GMainLoop - * - * Runs a main loop until it stops running. - * - * Deprecated: 2.2: Use g_main_loop_run() instead - */ -#define g_main_run(loop) g_main_loop_run(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_run) - -/** - * g_main_quit: - * @loop: a #GMainLoop - * - * Stops the #GMainLoop. - * If g_main_run() was called to run the #GMainLoop, it will now return. - * - * Deprecated: 2.2: Use g_main_loop_quit() instead - */ -#define g_main_quit(loop) g_main_loop_quit(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_quit) - -/** - * g_main_destroy: - * @loop: a #GMainLoop - * - * Frees the memory allocated for the #GMainLoop. - * - * Deprecated: 2.2: Use g_main_loop_unref() instead - */ -#define g_main_destroy(loop) g_main_loop_unref(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_unref) - -/** - * g_main_is_running: - * @loop: a #GMainLoop - * - * Checks if the main loop is running. - * - * Returns: %TRUE if the main loop is running - * - * Deprecated: 2.2: Use g_main_loop_is_running() instead - */ -#define g_main_is_running(loop) g_main_loop_is_running(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_is_running) - -/** - * g_main_iteration: - * @may_block: set to %TRUE if it should block (i.e. wait) until an event - * source becomes ready. It will return after an event source has been - * processed. If set to %FALSE it will return immediately if no event - * source is ready to be processed. - * - * Runs a single iteration for the default #GMainContext. - * - * Returns: %TRUE if more events are pending. - * - * Deprecated: 2.2: Use g_main_context_iteration() instead. - */ -#define g_main_iteration(may_block) g_main_context_iteration (NULL, may_block) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_iteration) - -/** - * g_main_pending: - * - * Checks if any events are pending for the default #GMainContext - * (i.e. ready to be processed). - * - * Returns: %TRUE if any events are pending. - * - * Deprecated: 2.2: Use g_main_context_pending() instead. - */ -#define g_main_pending() g_main_context_pending (NULL) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_pending) - -/** - * g_main_set_poll_func: - * @func: the function to call to poll all file descriptors - * - * Sets the function to use for the handle polling of file descriptors - * for the default main context. - * - * Deprecated: 2.2: Use g_main_context_set_poll_func() again - */ -#define g_main_set_poll_func(func) g_main_context_set_poll_func (NULL, func) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_context_set_poll_func) - -G_END_DECLS - -#endif /* __G_DEPRECATED_MAIN_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_REL_H__ -#define __G_REL_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GRelation GRelation; -typedef struct _GTuples GTuples; - -struct _GTuples -{ - guint len; -}; - -/* GRelation - * - * Indexed Relations. Imagine a really simple table in a - * database. Relations are not ordered. This data type is meant for - * maintaining a N-way mapping. - * - * g_relation_new() creates a relation with FIELDS fields - * - * g_relation_destroy() frees all resources - * g_tuples_destroy() frees the result of g_relation_select() - * - * g_relation_index() indexes relation FIELD with the provided - * equality and hash functions. this must be done before any - * calls to insert are made. - * - * g_relation_insert() inserts a new tuple. you are expected to - * provide the right number of fields. - * - * g_relation_delete() deletes all relations with KEY in FIELD - * g_relation_select() returns ... - * g_relation_count() counts ... - */ - -GLIB_DEPRECATED_IN_2_26 -GRelation* g_relation_new (gint fields); -GLIB_DEPRECATED_IN_2_26 -void g_relation_destroy (GRelation *relation); -GLIB_DEPRECATED_IN_2_26 -void g_relation_index (GRelation *relation, - gint field, - GHashFunc hash_func, - GEqualFunc key_equal_func); -GLIB_DEPRECATED_IN_2_26 -void g_relation_insert (GRelation *relation, - ...); -GLIB_DEPRECATED_IN_2_26 -gint g_relation_delete (GRelation *relation, - gconstpointer key, - gint field); -GLIB_DEPRECATED_IN_2_26 -GTuples* g_relation_select (GRelation *relation, - gconstpointer key, - gint field); -GLIB_DEPRECATED_IN_2_26 -gint g_relation_count (GRelation *relation, - gconstpointer key, - gint field); -GLIB_DEPRECATED_IN_2_26 -gboolean g_relation_exists (GRelation *relation, - ...); -GLIB_DEPRECATED_IN_2_26 -void g_relation_print (GRelation *relation); -GLIB_DEPRECATED_IN_2_26 -void g_tuples_destroy (GTuples *tuples); -GLIB_DEPRECATED_IN_2_26 -gpointer g_tuples_index (GTuples *tuples, - gint index_, - gint field); - -G_END_DECLS - -#endif /* __G_REL_H__ */ -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __G_DEPRECATED_THREAD_H__ -#define __G_DEPRECATED_THREAD_H__ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -typedef enum -{ - G_THREAD_PRIORITY_LOW, - G_THREAD_PRIORITY_NORMAL, - G_THREAD_PRIORITY_HIGH, - G_THREAD_PRIORITY_URGENT -} GThreadPriority GLIB_DEPRECATED_TYPE_IN_2_32; - -struct _GThread -{ - /*< private >*/ - GThreadFunc func; - gpointer data; - gboolean joinable; - GThreadPriority priority; -}; - -typedef struct _GThreadFunctions GThreadFunctions GLIB_DEPRECATED_TYPE_IN_2_32; -struct _GThreadFunctions -{ - GMutex* (*mutex_new) (void); - void (*mutex_lock) (GMutex *mutex); - gboolean (*mutex_trylock) (GMutex *mutex); - void (*mutex_unlock) (GMutex *mutex); - void (*mutex_free) (GMutex *mutex); - GCond* (*cond_new) (void); - void (*cond_signal) (GCond *cond); - void (*cond_broadcast) (GCond *cond); - void (*cond_wait) (GCond *cond, - GMutex *mutex); - gboolean (*cond_timed_wait) (GCond *cond, - GMutex *mutex, - GTimeVal *end_time); - void (*cond_free) (GCond *cond); - GPrivate* (*private_new) (GDestroyNotify destructor); - gpointer (*private_get) (GPrivate *private_key); - void (*private_set) (GPrivate *private_key, - gpointer data); - void (*thread_create) (GThreadFunc func, - gpointer data, - gulong stack_size, - gboolean joinable, - gboolean bound, - GThreadPriority priority, - gpointer thread, - GError **error); - void (*thread_yield) (void); - void (*thread_join) (gpointer thread); - void (*thread_exit) (void); - void (*thread_set_priority)(gpointer thread, - GThreadPriority priority); - void (*thread_self) (gpointer thread); - gboolean (*thread_equal) (gpointer thread1, - gpointer thread2); -} GLIB_DEPRECATED_TYPE_IN_2_32; - -GLIB_VAR GThreadFunctions g_thread_functions_for_glib_use; -GLIB_VAR gboolean g_thread_use_default_impl; - -GLIB_VAR guint64 (*g_thread_gettime) (void); - -GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new) -GThread *g_thread_create (GThreadFunc func, - gpointer data, - gboolean joinable, - GError **error); - -GLIB_DEPRECATED_IN_2_32_FOR(g_thread_new) -GThread *g_thread_create_full (GThreadFunc func, - gpointer data, - gulong stack_size, - gboolean joinable, - gboolean bound, - GThreadPriority priority, - GError **error); - -GLIB_DEPRECATED_IN_2_32 -void g_thread_set_priority (GThread *thread, - GThreadPriority priority); - -GLIB_DEPRECATED_IN_2_32 -void g_thread_foreach (GFunc thread_func, - gpointer user_data); - -#ifndef G_OS_WIN32 -#include -#include -#endif - -#define g_static_mutex_get_mutex g_static_mutex_get_mutex_impl GLIB_DEPRECATED_MACRO_IN_2_32 -#define G_STATIC_MUTEX_INIT { NULL } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_init) -typedef struct -{ - GMutex *mutex; -#ifndef G_OS_WIN32 - /* only for ABI compatibility reasons */ - pthread_mutex_t unused; -#endif -} GStaticMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GMutex); - -#define g_static_mutex_lock(mutex) \ - g_mutex_lock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_lock) -#define g_static_mutex_trylock(mutex) \ - g_mutex_trylock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_trylock) -#define g_static_mutex_unlock(mutex) \ - g_mutex_unlock (g_static_mutex_get_mutex (mutex)) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_mutex_unlock) - -GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_init) -void g_static_mutex_init (GStaticMutex *mutex); -GLIB_DEPRECATED_IN_2_32_FOR(g_mutex_clear) -void g_static_mutex_free (GStaticMutex *mutex); -GLIB_DEPRECATED_IN_2_32_FOR(GMutex) -GMutex *g_static_mutex_get_mutex_impl (GStaticMutex *mutex); - -typedef struct _GStaticRecMutex GStaticRecMutex GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); -struct _GStaticRecMutex -{ - /*< private >*/ - GStaticMutex mutex; - guint depth; - - /* ABI compat only */ - union { -#ifdef G_OS_WIN32 - void *owner; -#else - pthread_t owner; -#endif - gdouble dummy; - } unused; -} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRecMutex); - -#define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT, 0, { 0 } } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rec_mutex_init) -GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_init) -void g_static_rec_mutex_init (GStaticRecMutex *mutex); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_lock) -void g_static_rec_mutex_lock (GStaticRecMutex *mutex); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_try_lock) -gboolean g_static_rec_mutex_trylock (GStaticRecMutex *mutex); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_unlock) -void g_static_rec_mutex_unlock (GStaticRecMutex *mutex); - -GLIB_DEPRECATED_IN_2_32 -void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex, - guint depth); - -GLIB_DEPRECATED_IN_2_32 -guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rec_mutex_free) -void g_static_rec_mutex_free (GStaticRecMutex *mutex); - -typedef struct _GStaticRWLock GStaticRWLock GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); -struct _GStaticRWLock -{ - /*< private >*/ - GStaticMutex mutex; - GCond *read_cond; - GCond *write_cond; - guint read_counter; - gboolean have_writer; - guint want_to_read; - guint want_to_write; -} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GRWLock); - -#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, 0, 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(g_rw_lock_init) - -GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_init) -void g_static_rw_lock_init (GStaticRWLock *lock); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_lock) -void g_static_rw_lock_reader_lock (GStaticRWLock *lock); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_trylock) -gboolean g_static_rw_lock_reader_trylock (GStaticRWLock *lock); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_reader_unlock) -void g_static_rw_lock_reader_unlock (GStaticRWLock *lock); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_lock) -void g_static_rw_lock_writer_lock (GStaticRWLock *lock); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_trylock) -gboolean g_static_rw_lock_writer_trylock (GStaticRWLock *lock); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_writer_unlock) -void g_static_rw_lock_writer_unlock (GStaticRWLock *lock); - -GLIB_DEPRECATED_IN_2_32_FOR(g_rw_lock_free) -void g_static_rw_lock_free (GStaticRWLock *lock); - -GLIB_DEPRECATED_IN_2_32 -GPrivate * g_private_new (GDestroyNotify notify); - -typedef struct _GStaticPrivate GStaticPrivate GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); -struct _GStaticPrivate -{ - /*< private >*/ - guint index; -} GLIB_DEPRECATED_TYPE_IN_2_32_FOR(GPrivate); - -#define G_STATIC_PRIVATE_INIT { 0 } GLIB_DEPRECATED_MACRO_IN_2_32_FOR(G_PRIVATE_INIT) -GLIB_DEPRECATED_IN_2_32 -void g_static_private_init (GStaticPrivate *private_key); - -GLIB_DEPRECATED_IN_2_32_FOR(g_private_get) -gpointer g_static_private_get (GStaticPrivate *private_key); - -GLIB_DEPRECATED_IN_2_32_FOR(g_private_set) -void g_static_private_set (GStaticPrivate *private_key, - gpointer data, - GDestroyNotify notify); - -GLIB_DEPRECATED_IN_2_32 -void g_static_private_free (GStaticPrivate *private_key); - -GLIB_DEPRECATED_IN_2_32 -gboolean g_once_init_enter_impl (volatile gsize *location); - -GLIB_DEPRECATED_IN_2_32 -void g_thread_init (gpointer vtable); -GLIB_DEPRECATED_IN_2_32 -void g_thread_init_with_errorcheck_mutexes (gpointer vtable); - -GLIB_DEPRECATED_IN_2_32 -gboolean g_thread_get_initialized (void); - -GLIB_VAR gboolean g_threads_got_initialized; - -#define g_thread_supported() (1) GLIB_DEPRECATED_MACRO_IN_2_32 - -GLIB_DEPRECATED_IN_2_32 -GMutex * g_mutex_new (void); -GLIB_DEPRECATED_IN_2_32 -void g_mutex_free (GMutex *mutex); -GLIB_DEPRECATED_IN_2_32 -GCond * g_cond_new (void); -GLIB_DEPRECATED_IN_2_32 -void g_cond_free (GCond *cond); -GLIB_DEPRECATED_IN_2_32 -gboolean g_cond_timed_wait (GCond *cond, - GMutex *mutex, - GTimeVal *timeval); - -G_GNUC_END_IGNORE_DEPRECATIONS - -G_END_DECLS - -#endif /* __G_DEPRECATED_THREAD_H__ */ - -/* - * Copyright © 2015 Canonical Limited - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Author: Ryan Lortie - */ - -#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) -#error "Only can be included directly." -#endif - -static inline void -g_autoptr_cleanup_generic_gfree (void *p) -{ - void **pp = (void**)p; - g_free (*pp); -} - -static inline void -g_autoptr_cleanup_gstring_free (GString *string) -{ - if (string) - g_string_free (string, TRUE); -} - -/* Ignore deprecations in case we refer to a type which was added in a more - * recent GLib version than the user’s #GLIB_VERSION_MAX_ALLOWED definition. */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -/* If adding a cleanup here, please also add a test case to - * glib/tests/autoptr.c - */ -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAsyncQueue, g_async_queue_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBookmarkFile, g_bookmark_file_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBytes, g_bytes_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GChecksum, g_checksum_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDateTime, g_date_time_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDate, g_date_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDir, g_dir_close) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GError, g_error_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHashTable, g_hash_table_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHmac, g_hmac_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GIOChannel, g_io_channel_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GKeyFile, g_key_file_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GList, g_list_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GArray, g_array_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPtrArray, g_ptr_array_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GByteArray, g_byte_array_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainContext, g_main_context_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainContextPusher, g_main_context_pusher_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainLoop, g_main_loop_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSource, g_source_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMappedFile, g_mapped_file_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMarkupParseContext, g_markup_parse_context_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNode, g_node_destroy) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionContext, g_option_context_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionGroup, g_option_group_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPatternSpec, g_pattern_spec_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GQueue, g_queue_free) -G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRand, g_rand_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRegex, g_regex_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMatchInfo, g_match_info_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GScanner, g_scanner_destroy) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSequence, g_sequence_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSList, g_slist_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GString, g_autoptr_cleanup_gstring_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GStringChunk, g_string_chunk_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GStrvBuilder, g_strv_builder_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GThread, g_thread_unref) -G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GMutex, g_mutex_clear) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMutexLocker, g_mutex_locker_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRecMutexLocker, g_rec_mutex_locker_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRWLockWriterLocker, g_rw_lock_writer_locker_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRWLockReaderLocker, g_rw_lock_reader_locker_free) -G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GCond, g_cond_clear) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTimer, g_timer_destroy) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTimeZone, g_time_zone_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTree, g_tree_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariant, g_variant_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantBuilder, g_variant_builder_unref) -G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantBuilder, g_variant_builder_clear) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantIter, g_variant_iter_free) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantDict, g_variant_dict_unref) -G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantDict, g_variant_dict_clear) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantType, g_variant_type_free) -G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRefString, g_ref_string_release) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GUri, g_uri_unref) - -G_GNUC_END_IGNORE_DEPRECATIONS - -#undef __GLIB_H_INSIDE__ - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_2_68 -void glib_init (void); - -GLIB_AVAILABLE_IN_2_68 -void glib_shutdown (void); - -GLIB_AVAILABLE_IN_2_68 -void glib_deinit (void); - -GLIB_AVAILABLE_IN_2_68 -void glib_prepare_to_fork (void); - -GLIB_AVAILABLE_IN_2_68 -void glib_recover_from_fork_in_parent (void); - -GLIB_AVAILABLE_IN_2_68 -void glib_recover_from_fork_in_child (void); - -G_END_DECLS - -#endif /* __G_LIB_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __G_OBJECT_H__ -#define __G_OBJECT_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __G_TYPE_H__ -#define __G_TYPE_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* Basic Type Macros - */ -/** - * G_TYPE_FUNDAMENTAL: - * @type: A #GType value. - * - * The fundamental type which is the ancestor of @type. - * Fundamental types are types that serve as ultimate bases for the derived types, - * thus they are the roots of distinct inheritance hierarchies. - */ -#define G_TYPE_FUNDAMENTAL(type) (g_type_fundamental (type)) -/** - * G_TYPE_FUNDAMENTAL_MAX: - * - * An integer constant that represents the number of identifiers reserved - * for types that are assigned at compile-time. - */ -#define G_TYPE_FUNDAMENTAL_MAX (255 << G_TYPE_FUNDAMENTAL_SHIFT) - -/* Constant fundamental types, - */ -/** - * G_TYPE_INVALID: - * - * An invalid #GType used as error return value in some functions which return - * a #GType. - */ -#define G_TYPE_INVALID G_TYPE_MAKE_FUNDAMENTAL (0) -/** - * G_TYPE_NONE: - * - * A fundamental type which is used as a replacement for the C - * void return type. - */ -#define G_TYPE_NONE G_TYPE_MAKE_FUNDAMENTAL (1) -/** - * G_TYPE_INTERFACE: - * - * The fundamental type from which all interfaces are derived. - */ -#define G_TYPE_INTERFACE G_TYPE_MAKE_FUNDAMENTAL (2) -/** - * G_TYPE_CHAR: - * - * The fundamental type corresponding to #gchar. - * The type designated by G_TYPE_CHAR is unconditionally an 8-bit signed integer. - * This may or may not be the same type a the C type "gchar". - */ -#define G_TYPE_CHAR G_TYPE_MAKE_FUNDAMENTAL (3) -/** - * G_TYPE_UCHAR: - * - * The fundamental type corresponding to #guchar. - */ -#define G_TYPE_UCHAR G_TYPE_MAKE_FUNDAMENTAL (4) -/** - * G_TYPE_BOOLEAN: - * - * The fundamental type corresponding to #gboolean. - */ -#define G_TYPE_BOOLEAN G_TYPE_MAKE_FUNDAMENTAL (5) -/** - * G_TYPE_INT: - * - * The fundamental type corresponding to #gint. - */ -#define G_TYPE_INT G_TYPE_MAKE_FUNDAMENTAL (6) -/** - * G_TYPE_UINT: - * - * The fundamental type corresponding to #guint. - */ -#define G_TYPE_UINT G_TYPE_MAKE_FUNDAMENTAL (7) -/** - * G_TYPE_LONG: - * - * The fundamental type corresponding to #glong. - */ -#define G_TYPE_LONG G_TYPE_MAKE_FUNDAMENTAL (8) -/** - * G_TYPE_ULONG: - * - * The fundamental type corresponding to #gulong. - */ -#define G_TYPE_ULONG G_TYPE_MAKE_FUNDAMENTAL (9) -/** - * G_TYPE_INT64: - * - * The fundamental type corresponding to #gint64. - */ -#define G_TYPE_INT64 G_TYPE_MAKE_FUNDAMENTAL (10) -/** - * G_TYPE_UINT64: - * - * The fundamental type corresponding to #guint64. - */ -#define G_TYPE_UINT64 G_TYPE_MAKE_FUNDAMENTAL (11) -/** - * G_TYPE_ENUM: - * - * The fundamental type from which all enumeration types are derived. - */ -#define G_TYPE_ENUM G_TYPE_MAKE_FUNDAMENTAL (12) -/** - * G_TYPE_FLAGS: - * - * The fundamental type from which all flags types are derived. - */ -#define G_TYPE_FLAGS G_TYPE_MAKE_FUNDAMENTAL (13) -/** - * G_TYPE_FLOAT: - * - * The fundamental type corresponding to #gfloat. - */ -#define G_TYPE_FLOAT G_TYPE_MAKE_FUNDAMENTAL (14) -/** - * G_TYPE_DOUBLE: - * - * The fundamental type corresponding to #gdouble. - */ -#define G_TYPE_DOUBLE G_TYPE_MAKE_FUNDAMENTAL (15) -/** - * G_TYPE_STRING: - * - * The fundamental type corresponding to nul-terminated C strings. - */ -#define G_TYPE_STRING G_TYPE_MAKE_FUNDAMENTAL (16) -/** - * G_TYPE_POINTER: - * - * The fundamental type corresponding to #gpointer. - */ -#define G_TYPE_POINTER G_TYPE_MAKE_FUNDAMENTAL (17) -/** - * G_TYPE_BOXED: - * - * The fundamental type from which all boxed types are derived. - */ -#define G_TYPE_BOXED G_TYPE_MAKE_FUNDAMENTAL (18) -/** - * G_TYPE_PARAM: - * - * The fundamental type from which all #GParamSpec types are derived. - */ -#define G_TYPE_PARAM G_TYPE_MAKE_FUNDAMENTAL (19) -/** - * G_TYPE_OBJECT: - * - * The fundamental type for #GObject. - */ -#define G_TYPE_OBJECT G_TYPE_MAKE_FUNDAMENTAL (20) -/** - * G_TYPE_VARIANT: - * - * The fundamental type corresponding to #GVariant. - * - * All floating #GVariant instances passed through the #GType system are - * consumed. - * - * Note that callbacks in closures, and signal handlers - * for signals of return type %G_TYPE_VARIANT, must never return floating - * variants. - * - * Note: GLib 2.24 did include a boxed type with this name. It was replaced - * with this fundamental type in 2.26. - * - * Since: 2.26 - */ -#define G_TYPE_VARIANT G_TYPE_MAKE_FUNDAMENTAL (21) - - -/* Reserved fundamental type numbers to create new fundamental - * type IDs with G_TYPE_MAKE_FUNDAMENTAL(). - * - * Open an issue on https://gitlab.gnome.org/GNOME/glib/issues/new for - * reservations. - */ -/** - * G_TYPE_FUNDAMENTAL_SHIFT: - * - * Shift value used in converting numbers to type IDs. - */ -#define G_TYPE_FUNDAMENTAL_SHIFT (2) -/** - * G_TYPE_MAKE_FUNDAMENTAL: - * @x: the fundamental type number. - * - * Get the type ID for the fundamental type number @x. - * Use g_type_fundamental_next() instead of this macro to create new fundamental - * types. - * - * Returns: the GType - */ -#define G_TYPE_MAKE_FUNDAMENTAL(x) ((GType) ((x) << G_TYPE_FUNDAMENTAL_SHIFT)) -/** - * G_TYPE_RESERVED_GLIB_FIRST: - * - * First fundamental type number to create a new fundamental type id with - * G_TYPE_MAKE_FUNDAMENTAL() reserved for GLib. - */ -#define G_TYPE_RESERVED_GLIB_FIRST (22) -/** - * G_TYPE_RESERVED_GLIB_LAST: - * - * Last fundamental type number reserved for GLib. - */ -#define G_TYPE_RESERVED_GLIB_LAST (31) -/** - * G_TYPE_RESERVED_BSE_FIRST: - * - * First fundamental type number to create a new fundamental type id with - * G_TYPE_MAKE_FUNDAMENTAL() reserved for BSE. - */ -#define G_TYPE_RESERVED_BSE_FIRST (32) -/** - * G_TYPE_RESERVED_BSE_LAST: - * - * Last fundamental type number reserved for BSE. - */ -#define G_TYPE_RESERVED_BSE_LAST (48) -/** - * G_TYPE_RESERVED_USER_FIRST: - * - * First available fundamental type number to create new fundamental - * type id with G_TYPE_MAKE_FUNDAMENTAL(). - */ -#define G_TYPE_RESERVED_USER_FIRST (49) - - -/* Type Checking Macros - */ -/** - * G_TYPE_IS_FUNDAMENTAL: - * @type: A #GType value - * - * Checks if @type is a fundamental type. - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_FUNDAMENTAL(type) ((type) <= G_TYPE_FUNDAMENTAL_MAX) -/** - * G_TYPE_IS_DERIVED: - * @type: A #GType value - * - * Checks if @type is derived (or in object-oriented terminology: - * inherited) from another type (this holds true for all non-fundamental - * types). - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_DERIVED(type) ((type) > G_TYPE_FUNDAMENTAL_MAX) -/** - * G_TYPE_IS_INTERFACE: - * @type: A #GType value - * - * Checks if @type is an interface type. - * An interface type provides a pure API, the implementation - * of which is provided by another type (which is then said to conform - * to the interface). GLib interfaces are somewhat analogous to Java - * interfaces and C++ classes containing only pure virtual functions, - * with the difference that GType interfaces are not derivable (but see - * g_type_interface_add_prerequisite() for an alternative). - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_INTERFACE(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_INTERFACE) -/** - * G_TYPE_IS_CLASSED: - * @type: A #GType value - * - * Checks if @type is a classed type. - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_CLASSED(type) (g_type_test_flags ((type), G_TYPE_FLAG_CLASSED)) -/** - * G_TYPE_IS_INSTANTIATABLE: - * @type: A #GType value - * - * Checks if @type can be instantiated. Instantiation is the - * process of creating an instance (object) of this type. - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_INSTANTIATABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE)) -/** - * G_TYPE_IS_DERIVABLE: - * @type: A #GType value - * - * Checks if @type is a derivable type. A derivable type can - * be used as the base class of a flat (single-level) class hierarchy. - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DERIVABLE)) -/** - * G_TYPE_IS_DEEP_DERIVABLE: - * @type: A #GType value - * - * Checks if @type is a deep derivable type. A deep derivable type - * can be used as the base class of a deep (multi-level) class hierarchy. - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_DEEP_DERIVABLE(type) (g_type_test_flags ((type), G_TYPE_FLAG_DEEP_DERIVABLE)) -/** - * G_TYPE_IS_ABSTRACT: - * @type: A #GType value - * - * Checks if @type is an abstract type. An abstract type cannot be - * instantiated and is normally used as an abstract base class for - * derived classes. - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)) -/** - * G_TYPE_IS_VALUE_ABSTRACT: - * @type: A #GType value - * - * Checks if @type is an abstract value type. An abstract value type introduces - * a value table, but can't be used for g_value_init() and is normally used as - * an abstract base type for derived value types. - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_VALUE_ABSTRACT(type) (g_type_test_flags ((type), G_TYPE_FLAG_VALUE_ABSTRACT)) -/** - * G_TYPE_IS_VALUE_TYPE: - * @type: A #GType value - * - * Checks if @type is a value type and can be used with g_value_init(). - * - * Returns: %TRUE on success - */ -#define G_TYPE_IS_VALUE_TYPE(type) (g_type_check_is_value_type (type)) -/** - * G_TYPE_HAS_VALUE_TABLE: - * @type: A #GType value - * - * Checks if @type has a #GTypeValueTable. - * - * Returns: %TRUE on success - */ -#define G_TYPE_HAS_VALUE_TABLE(type) (g_type_value_table_peek (type) != NULL) - - -/* Typedefs - */ -/** - * GType: - * - * A numerical value which represents the unique identifier of a registered - * type. - */ -#if GLIB_SIZEOF_SIZE_T != GLIB_SIZEOF_LONG || !defined __cplusplus -typedef gsize GType; -#else /* for historic reasons, C++ links against gulong GTypes */ -typedef gulong GType; -#endif -typedef struct _GValue GValue; -typedef union _GTypeCValue GTypeCValue; -typedef struct _GTypePlugin GTypePlugin; -typedef struct _GTypeClass GTypeClass; -typedef struct _GTypeInterface GTypeInterface; -typedef struct _GTypeInstance GTypeInstance; -typedef struct _GTypeInfo GTypeInfo; -typedef struct _GTypeFundamentalInfo GTypeFundamentalInfo; -typedef struct _GInterfaceInfo GInterfaceInfo; -typedef struct _GTypeValueTable GTypeValueTable; -typedef struct _GTypeQuery GTypeQuery; - - -/* Basic Type Structures - */ -/** - * GTypeClass: - * - * An opaque structure used as the base of all classes. - */ -struct _GTypeClass -{ - /*< private >*/ - GType g_type; -}; -/** - * GTypeInstance: - * - * An opaque structure used as the base of all type instances. - */ -struct _GTypeInstance -{ - /*< private >*/ - GTypeClass *g_class; -}; -/** - * GTypeInterface: - * - * An opaque structure used as the base of all interface types. - */ -struct _GTypeInterface -{ - /*< private >*/ - GType g_type; /* iface type */ - GType g_instance_type; -}; -/** - * GTypeQuery: - * @type: the #GType value of the type - * @type_name: the name of the type - * @class_size: the size of the class structure - * @instance_size: the size of the instance structure - * - * A structure holding information for a specific type. - * It is filled in by the g_type_query() function. - */ -struct _GTypeQuery -{ - GType type; - const gchar *type_name; - guint class_size; - guint instance_size; -}; - - -/* Casts, checks and accessors for structured types - * usage of these macros is reserved to type implementations only - */ -/*< protected >*/ -/** - * G_TYPE_CHECK_INSTANCE: - * @instance: Location of a #GTypeInstance structure - * - * Checks if @instance is a valid #GTypeInstance structure, - * otherwise issues a warning and returns %FALSE. %NULL is not a valid - * #GTypeInstance. - * - * This macro should only be used in type implementations. - * - * Returns: %TRUE on success - */ -#define G_TYPE_CHECK_INSTANCE(instance) (_G_TYPE_CHI ((GTypeInstance*) (instance))) -/** - * G_TYPE_CHECK_INSTANCE_CAST: - * @instance: (nullable): Location of a #GTypeInstance structure - * @g_type: The type to be returned - * @c_type: The corresponding C type of @g_type - * - * Checks that @instance is an instance of the type identified by @g_type - * and issues a warning if this is not the case. Returns @instance casted - * to a pointer to @c_type. - * - * No warning will be issued if @instance is %NULL, and %NULL will be returned. - * - * This macro should only be used in type implementations. - */ -#define G_TYPE_CHECK_INSTANCE_CAST(instance, g_type, c_type) (_G_TYPE_CIC ((instance), (g_type), c_type)) -/** - * G_TYPE_CHECK_INSTANCE_TYPE: - * @instance: (nullable): Location of a #GTypeInstance structure. - * @g_type: The type to be checked - * - * Checks if @instance is an instance of the type identified by @g_type. If - * @instance is %NULL, %FALSE will be returned. - * - * This macro should only be used in type implementations. - * - * Returns: %TRUE on success - */ -#define G_TYPE_CHECK_INSTANCE_TYPE(instance, g_type) (_G_TYPE_CIT ((instance), (g_type))) -/** - * G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE: - * @instance: (nullable): Location of a #GTypeInstance structure. - * @g_type: The fundamental type to be checked - * - * Checks if @instance is an instance of the fundamental type identified by @g_type. - * If @instance is %NULL, %FALSE will be returned. - * - * This macro should only be used in type implementations. - * - * Returns: %TRUE on success - */ -#define G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE(instance, g_type) (_G_TYPE_CIFT ((instance), (g_type))) -/** - * G_TYPE_INSTANCE_GET_CLASS: - * @instance: Location of the #GTypeInstance structure - * @g_type: The #GType of the class to be returned - * @c_type: The C type of the class structure - * - * Get the class structure of a given @instance, casted - * to a specified ancestor type @g_type of the instance. - * - * Note that while calling a GInstanceInitFunc(), the class pointer - * gets modified, so it might not always return the expected pointer. - * - * This macro should only be used in type implementations. - * - * Returns: a pointer to the class structure - */ -#define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type) (_G_TYPE_IGC ((instance), (g_type), c_type)) -/** - * G_TYPE_INSTANCE_GET_INTERFACE: - * @instance: Location of the #GTypeInstance structure - * @g_type: The #GType of the interface to be returned - * @c_type: The C type of the interface structure - * - * Get the interface structure for interface @g_type of a given @instance. - * - * This macro should only be used in type implementations. - * - * Returns: a pointer to the interface structure - */ -#define G_TYPE_INSTANCE_GET_INTERFACE(instance, g_type, c_type) (_G_TYPE_IGI ((instance), (g_type), c_type)) -/** - * G_TYPE_CHECK_CLASS_CAST: - * @g_class: Location of a #GTypeClass structure - * @g_type: The type to be returned - * @c_type: The corresponding C type of class structure of @g_type - * - * Checks that @g_class is a class structure of the type identified by @g_type - * and issues a warning if this is not the case. Returns @g_class casted - * to a pointer to @c_type. %NULL is not a valid class structure. - * - * This macro should only be used in type implementations. - */ -#define G_TYPE_CHECK_CLASS_CAST(g_class, g_type, c_type) (_G_TYPE_CCC ((g_class), (g_type), c_type)) -/** - * G_TYPE_CHECK_CLASS_TYPE: - * @g_class: (nullable): Location of a #GTypeClass structure - * @g_type: The type to be checked - * - * Checks if @g_class is a class structure of the type identified by - * @g_type. If @g_class is %NULL, %FALSE will be returned. - * - * This macro should only be used in type implementations. - * - * Returns: %TRUE on success - */ -#define G_TYPE_CHECK_CLASS_TYPE(g_class, g_type) (_G_TYPE_CCT ((g_class), (g_type))) -/** - * G_TYPE_CHECK_VALUE: - * @value: a #GValue - * - * Checks if @value has been initialized to hold values - * of a value type. - * - * This macro should only be used in type implementations. - * - * Returns: %TRUE on success - */ -#define G_TYPE_CHECK_VALUE(value) (_G_TYPE_CHV ((value))) -/** - * G_TYPE_CHECK_VALUE_TYPE: - * @value: a #GValue - * @g_type: The type to be checked - * - * Checks if @value has been initialized to hold values - * of type @g_type. - * - * This macro should only be used in type implementations. - * - * Returns: %TRUE on success - */ -#define G_TYPE_CHECK_VALUE_TYPE(value, g_type) (_G_TYPE_CVH ((value), (g_type))) -/** - * G_TYPE_FROM_INSTANCE: - * @instance: Location of a valid #GTypeInstance structure - * - * Get the type identifier from a given @instance structure. - * - * This macro should only be used in type implementations. - * - * Returns: the #GType - */ -#define G_TYPE_FROM_INSTANCE(instance) (G_TYPE_FROM_CLASS (((GTypeInstance*) (instance))->g_class)) -/** - * G_TYPE_FROM_CLASS: - * @g_class: Location of a valid #GTypeClass structure - * - * Get the type identifier from a given @class structure. - * - * This macro should only be used in type implementations. - * - * Returns: the #GType - */ -#define G_TYPE_FROM_CLASS(g_class) (((GTypeClass*) (g_class))->g_type) -/** - * G_TYPE_FROM_INTERFACE: - * @g_iface: Location of a valid #GTypeInterface structure - * - * Get the type identifier from a given @interface structure. - * - * This macro should only be used in type implementations. - * - * Returns: the #GType - */ -#define G_TYPE_FROM_INTERFACE(g_iface) (((GTypeInterface*) (g_iface))->g_type) - -/** - * G_TYPE_INSTANCE_GET_PRIVATE: - * @instance: the instance of a type deriving from @private_type - * @g_type: the type identifying which private data to retrieve - * @c_type: The C type for the private structure - * - * Gets the private structure for a particular type. - * The private structure must have been registered in the - * class_init function with g_type_class_add_private(). - * - * This macro should only be used in type implementations. - * - * Since: 2.4 - * Deprecated: 2.58: Use %G_ADD_PRIVATE and the generated - * `your_type_get_instance_private()` function instead - * Returns: (not nullable): a pointer to the private data structure - */ -#define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type) ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type))) GLIB_DEPRECATED_MACRO_IN_2_58_FOR(G_ADD_PRIVATE) - -/** - * G_TYPE_CLASS_GET_PRIVATE: - * @klass: the class of a type deriving from @private_type - * @g_type: the type identifying which private data to retrieve - * @c_type: The C type for the private structure - * - * Gets the private class structure for a particular type. - * The private structure must have been registered in the - * get_type() function with g_type_add_class_private(). - * - * This macro should only be used in type implementations. - * - * Since: 2.24 - * Returns: (not nullable): a pointer to the private data structure - */ -#define G_TYPE_CLASS_GET_PRIVATE(klass, g_type, c_type) ((c_type*) g_type_class_get_private ((GTypeClass*) (klass), (g_type))) - -/** - * GTypeDebugFlags: - * @G_TYPE_DEBUG_NONE: Print no messages - * @G_TYPE_DEBUG_OBJECTS: Print messages about object bookkeeping - * @G_TYPE_DEBUG_SIGNALS: Print messages about signal emissions - * @G_TYPE_DEBUG_MASK: Mask covering all debug flags - * @G_TYPE_DEBUG_INSTANCE_COUNT: Keep a count of instances of each type - * - * These flags used to be passed to g_type_init_with_debug_flags() which - * is now deprecated. - * - * If you need to enable debugging features, use the GOBJECT_DEBUG - * environment variable. - * - * Deprecated: 2.36: g_type_init() is now done automatically - */ -typedef enum /*< skip >*/ -{ - G_TYPE_DEBUG_NONE = 0, - G_TYPE_DEBUG_OBJECTS = 1 << 0, - G_TYPE_DEBUG_SIGNALS = 1 << 1, - G_TYPE_DEBUG_INSTANCE_COUNT = 1 << 2, - G_TYPE_DEBUG_MASK = 0x07 -} GTypeDebugFlags GLIB_DEPRECATED_TYPE_IN_2_36; - - -/* --- prototypes --- */ -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -GLIB_DEPRECATED_IN_2_36 -void g_type_init (void); -GLIB_DEPRECATED_IN_2_36 -void g_type_init_with_debug_flags (GTypeDebugFlags debug_flags); -G_GNUC_END_IGNORE_DEPRECATIONS - -GLIB_AVAILABLE_IN_ALL -const gchar * g_type_name (GType type); -GLIB_AVAILABLE_IN_ALL -GQuark g_type_qname (GType type); -GLIB_AVAILABLE_IN_ALL -GType g_type_from_name (const gchar *name); -GLIB_AVAILABLE_IN_ALL -GType g_type_parent (GType type); -GLIB_AVAILABLE_IN_ALL -guint g_type_depth (GType type); -GLIB_AVAILABLE_IN_ALL -GType g_type_next_base (GType leaf_type, - GType root_type); -GLIB_AVAILABLE_IN_ALL -gboolean g_type_is_a (GType type, - GType is_a_type); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_class_ref (GType type); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_class_peek (GType type); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_class_peek_static (GType type); -GLIB_AVAILABLE_IN_ALL -void g_type_class_unref (gpointer g_class); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_class_peek_parent (gpointer g_class); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_interface_peek (gpointer instance_class, - GType iface_type); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_interface_peek_parent (gpointer g_iface); - -GLIB_AVAILABLE_IN_ALL -gpointer g_type_default_interface_ref (GType g_type); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_default_interface_peek (GType g_type); -GLIB_AVAILABLE_IN_ALL -void g_type_default_interface_unref (gpointer g_iface); - -/* g_free() the returned arrays */ -GLIB_AVAILABLE_IN_ALL -GType* g_type_children (GType type, - guint *n_children); -GLIB_AVAILABLE_IN_ALL -GType* g_type_interfaces (GType type, - guint *n_interfaces); - -/* per-type _static_ data */ -GLIB_AVAILABLE_IN_ALL -void g_type_set_qdata (GType type, - GQuark quark, - gpointer data); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_get_qdata (GType type, - GQuark quark); -GLIB_AVAILABLE_IN_ALL -void g_type_query (GType type, - GTypeQuery *query); - -GLIB_AVAILABLE_IN_2_44 -int g_type_get_instance_count (GType type); - -/* --- type registration --- */ -/** - * GBaseInitFunc: - * @g_class: (type GObject.TypeClass): The #GTypeClass structure to initialize - * - * A callback function used by the type system to do base initialization - * of the class structures of derived types. It is called as part of the - * initialization process of all derived classes and should reallocate - * or reset all dynamic class members copied over from the parent class. - * For example, class members (such as strings) that are not sufficiently - * handled by a plain memory copy of the parent class into the derived class - * have to be altered. See GClassInitFunc() for a discussion of the class - * initialization process. - */ -typedef void (*GBaseInitFunc) (gpointer g_class); -/** - * GBaseFinalizeFunc: - * @g_class: (type GObject.TypeClass): The #GTypeClass structure to finalize - * - * A callback function used by the type system to finalize those portions - * of a derived types class structure that were setup from the corresponding - * GBaseInitFunc() function. Class finalization basically works the inverse - * way in which class initialization is performed. - * See GClassInitFunc() for a discussion of the class initialization process. - */ -typedef void (*GBaseFinalizeFunc) (gpointer g_class); -/** - * GClassInitFunc: - * @g_class: (type GObject.TypeClass): The #GTypeClass structure to initialize. - * @class_data: The @class_data member supplied via the #GTypeInfo structure. - * - * A callback function used by the type system to initialize the class - * of a specific type. This function should initialize all static class - * members. - * - * The initialization process of a class involves: - * - * - Copying common members from the parent class over to the - * derived class structure. - * - Zero initialization of the remaining members not copied - * over from the parent class. - * - Invocation of the GBaseInitFunc() initializers of all parent - * types and the class' type. - * - Invocation of the class' GClassInitFunc() initializer. - * - * Since derived classes are partially initialized through a memory copy - * of the parent class, the general rule is that GBaseInitFunc() and - * GBaseFinalizeFunc() should take care of necessary reinitialization - * and release of those class members that were introduced by the type - * that specified these GBaseInitFunc()/GBaseFinalizeFunc(). - * GClassInitFunc() should only care about initializing static - * class members, while dynamic class members (such as allocated strings - * or reference counted resources) are better handled by a GBaseInitFunc() - * for this type, so proper initialization of the dynamic class members - * is performed for class initialization of derived types as well. - * - * An example may help to correspond the intend of the different class - * initializers: - * - * |[ - * typedef struct { - * GObjectClass parent_class; - * gint static_integer; - * gchar *dynamic_string; - * } TypeAClass; - * static void - * type_a_base_class_init (TypeAClass *class) - * { - * class->dynamic_string = g_strdup ("some string"); - * } - * static void - * type_a_base_class_finalize (TypeAClass *class) - * { - * g_free (class->dynamic_string); - * } - * static void - * type_a_class_init (TypeAClass *class) - * { - * class->static_integer = 42; - * } - * - * typedef struct { - * TypeAClass parent_class; - * gfloat static_float; - * GString *dynamic_gstring; - * } TypeBClass; - * static void - * type_b_base_class_init (TypeBClass *class) - * { - * class->dynamic_gstring = g_string_new ("some other string"); - * } - * static void - * type_b_base_class_finalize (TypeBClass *class) - * { - * g_string_free (class->dynamic_gstring); - * } - * static void - * type_b_class_init (TypeBClass *class) - * { - * class->static_float = 3.14159265358979323846; - * } - * ]| - * Initialization of TypeBClass will first cause initialization of - * TypeAClass (derived classes reference their parent classes, see - * g_type_class_ref() on this). - * - * Initialization of TypeAClass roughly involves zero-initializing its fields, - * then calling its GBaseInitFunc() type_a_base_class_init() to allocate - * its dynamic members (dynamic_string), and finally calling its GClassInitFunc() - * type_a_class_init() to initialize its static members (static_integer). - * The first step in the initialization process of TypeBClass is then - * a plain memory copy of the contents of TypeAClass into TypeBClass and - * zero-initialization of the remaining fields in TypeBClass. - * The dynamic members of TypeAClass within TypeBClass now need - * reinitialization which is performed by calling type_a_base_class_init() - * with an argument of TypeBClass. - * - * After that, the GBaseInitFunc() of TypeBClass, type_b_base_class_init() - * is called to allocate the dynamic members of TypeBClass (dynamic_gstring), - * and finally the GClassInitFunc() of TypeBClass, type_b_class_init(), - * is called to complete the initialization process with the static members - * (static_float). - * - * Corresponding finalization counter parts to the GBaseInitFunc() functions - * have to be provided to release allocated resources at class finalization - * time. - */ -typedef void (*GClassInitFunc) (gpointer g_class, - gpointer class_data); -/** - * GClassFinalizeFunc: - * @g_class: (type GObject.TypeClass): The #GTypeClass structure to finalize - * @class_data: The @class_data member supplied via the #GTypeInfo structure - * - * A callback function used by the type system to finalize a class. - * This function is rarely needed, as dynamically allocated class resources - * should be handled by GBaseInitFunc() and GBaseFinalizeFunc(). - * Also, specification of a GClassFinalizeFunc() in the #GTypeInfo - * structure of a static type is invalid, because classes of static types - * will never be finalized (they are artificially kept alive when their - * reference count drops to zero). - */ -typedef void (*GClassFinalizeFunc) (gpointer g_class, - gpointer class_data); -/** - * GInstanceInitFunc: - * @instance: The instance to initialize - * @g_class: (type GObject.TypeClass): The class of the type the instance is - * created for - * - * A callback function used by the type system to initialize a new - * instance of a type. This function initializes all instance members and - * allocates any resources required by it. - * - * Initialization of a derived instance involves calling all its parent - * types instance initializers, so the class member of the instance - * is altered during its initialization to always point to the class that - * belongs to the type the current initializer was introduced for. - * - * The extended members of @instance are guaranteed to have been filled with - * zeros before this function is called. - */ -typedef void (*GInstanceInitFunc) (GTypeInstance *instance, - gpointer g_class); -/** - * GInterfaceInitFunc: - * @g_iface: (type GObject.TypeInterface): The interface structure to initialize - * @iface_data: The @interface_data supplied via the #GInterfaceInfo structure - * - * A callback function used by the type system to initialize a new - * interface. This function should initialize all internal data and - * allocate any resources required by the interface. - * - * The members of @iface_data are guaranteed to have been filled with - * zeros before this function is called. - */ -typedef void (*GInterfaceInitFunc) (gpointer g_iface, - gpointer iface_data); -/** - * GInterfaceFinalizeFunc: - * @g_iface: (type GObject.TypeInterface): The interface structure to finalize - * @iface_data: The @interface_data supplied via the #GInterfaceInfo structure - * - * A callback function used by the type system to finalize an interface. - * This function should destroy any internal data and release any resources - * allocated by the corresponding GInterfaceInitFunc() function. - */ -typedef void (*GInterfaceFinalizeFunc) (gpointer g_iface, - gpointer iface_data); -/** - * GTypeClassCacheFunc: - * @cache_data: data that was given to the g_type_add_class_cache_func() call - * @g_class: (type GObject.TypeClass): The #GTypeClass structure which is - * unreferenced - * - * A callback function which is called when the reference count of a class - * drops to zero. It may use g_type_class_ref() to prevent the class from - * being freed. You should not call g_type_class_unref() from a - * #GTypeClassCacheFunc function to prevent infinite recursion, use - * g_type_class_unref_uncached() instead. - * - * The functions have to check the class id passed in to figure - * whether they actually want to cache the class of this type, since all - * classes are routed through the same #GTypeClassCacheFunc chain. - * - * Returns: %TRUE to stop further #GTypeClassCacheFuncs from being - * called, %FALSE to continue - */ -typedef gboolean (*GTypeClassCacheFunc) (gpointer cache_data, - GTypeClass *g_class); -/** - * GTypeInterfaceCheckFunc: - * @check_data: data passed to g_type_add_interface_check() - * @g_iface: (type GObject.TypeInterface): the interface that has been - * initialized - * - * A callback called after an interface vtable is initialized. - * See g_type_add_interface_check(). - * - * Since: 2.4 - */ -typedef void (*GTypeInterfaceCheckFunc) (gpointer check_data, - gpointer g_iface); -/** - * GTypeFundamentalFlags: - * @G_TYPE_FLAG_CLASSED: Indicates a classed type - * @G_TYPE_FLAG_INSTANTIATABLE: Indicates an instantiatable type (implies classed) - * @G_TYPE_FLAG_DERIVABLE: Indicates a flat derivable type - * @G_TYPE_FLAG_DEEP_DERIVABLE: Indicates a deep derivable type (implies derivable) - * - * Bit masks used to check or determine specific characteristics of a - * fundamental type. - */ -typedef enum /*< skip >*/ -{ - G_TYPE_FLAG_CLASSED = (1 << 0), - G_TYPE_FLAG_INSTANTIATABLE = (1 << 1), - G_TYPE_FLAG_DERIVABLE = (1 << 2), - G_TYPE_FLAG_DEEP_DERIVABLE = (1 << 3) -} GTypeFundamentalFlags; -/** - * GTypeFlags: - * @G_TYPE_FLAG_ABSTRACT: Indicates an abstract type. No instances can be - * created for an abstract type - * @G_TYPE_FLAG_VALUE_ABSTRACT: Indicates an abstract value type, i.e. a type - * that introduces a value table, but can't be used for - * g_value_init() - * - * Bit masks used to check or determine characteristics of a type. - */ -typedef enum /*< skip >*/ -{ - G_TYPE_FLAG_ABSTRACT = (1 << 4), - G_TYPE_FLAG_VALUE_ABSTRACT = (1 << 5) -} GTypeFlags; -/** - * GTypeInfo: - * @class_size: Size of the class structure (required for interface, classed and instantiatable types) - * @base_init: Location of the base initialization function (optional) - * @base_finalize: Location of the base finalization function (optional) - * @class_init: Location of the class initialization function for - * classed and instantiatable types. Location of the default vtable - * inititalization function for interface types. (optional) This function - * is used both to fill in virtual functions in the class or default vtable, - * and to do type-specific setup such as registering signals and object - * properties. - * @class_finalize: Location of the class finalization function for - * classed and instantiatable types. Location of the default vtable - * finalization function for interface types. (optional) - * @class_data: User-supplied data passed to the class init/finalize functions - * @instance_size: Size of the instance (object) structure (required for instantiatable types only) - * @n_preallocs: Prior to GLib 2.10, it specified the number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching). Since GLib 2.10, it is ignored, since instances are allocated with the [slice allocator][glib-Memory-Slices] now. - * @instance_init: Location of the instance initialization function (optional, for instantiatable types only) - * @value_table: A #GTypeValueTable function table for generic handling of GValues - * of this type (usually only useful for fundamental types) - * - * This structure is used to provide the type system with the information - * required to initialize and destruct (finalize) a type's class and - * its instances. - * - * The initialized structure is passed to the g_type_register_static() function - * (or is copied into the provided #GTypeInfo structure in the - * g_type_plugin_complete_type_info()). The type system will perform a deep - * copy of this structure, so its memory does not need to be persistent - * across invocation of g_type_register_static(). - */ -struct _GTypeInfo -{ - /* interface types, classed types, instantiated types */ - guint16 class_size; - - GBaseInitFunc base_init; - GBaseFinalizeFunc base_finalize; - - /* interface types, classed types, instantiated types */ - GClassInitFunc class_init; - GClassFinalizeFunc class_finalize; - gconstpointer class_data; - - /* instantiated types */ - guint16 instance_size; - guint16 n_preallocs; - GInstanceInitFunc instance_init; - - /* value handling */ - const GTypeValueTable *value_table; -}; -/** - * GTypeFundamentalInfo: - * @type_flags: #GTypeFundamentalFlags describing the characteristics of the fundamental type - * - * A structure that provides information to the type system which is - * used specifically for managing fundamental types. - */ -struct _GTypeFundamentalInfo -{ - GTypeFundamentalFlags type_flags; -}; -/** - * GInterfaceInfo: - * @interface_init: location of the interface initialization function - * @interface_finalize: location of the interface finalization function - * @interface_data: user-supplied data passed to the interface init/finalize functions - * - * A structure that provides information to the type system which is - * used specifically for managing interface types. - */ -struct _GInterfaceInfo -{ - GInterfaceInitFunc interface_init; - GInterfaceFinalizeFunc interface_finalize; - gpointer interface_data; -}; -/** - * GTypeValueTable: - * @value_init: Default initialize @values contents by poking values - * directly into the value->data array. The data array of - * the #GValue passed into this function was zero-filled - * with `memset()`, so no care has to be taken to free any - * old contents. E.g. for the implementation of a string - * value that may never be %NULL, the implementation might - * look like: - * |[ - * value->data[0].v_pointer = g_strdup (""); - * ]| - * @value_free: Free any old contents that might be left in the - * data array of the passed in @value. No resources may - * remain allocated through the #GValue contents after - * this function returns. E.g. for our above string type: - * |[ - * // only free strings without a specific flag for static storage - * if (!(value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS)) - * g_free (value->data[0].v_pointer); - * ]| - * @value_copy: @dest_value is a #GValue with zero-filled data section - * and @src_value is a properly setup #GValue of same or - * derived type. - * The purpose of this function is to copy the contents of - * @src_value into @dest_value in a way, that even after - * @src_value has been freed, the contents of @dest_value - * remain valid. String type example: - * |[ - * dest_value->data[0].v_pointer = g_strdup (src_value->data[0].v_pointer); - * ]| - * @value_peek_pointer: If the value contents fit into a pointer, such as objects - * or strings, return this pointer, so the caller can peek at - * the current contents. To extend on our above string example: - * |[ - * return value->data[0].v_pointer; - * ]| - * @collect_format: A string format describing how to collect the contents of - * this value bit-by-bit. Each character in the format represents - * an argument to be collected, and the characters themselves indicate - * the type of the argument. Currently supported arguments are: - * - 'i' - Integers. passed as collect_values[].v_int. - * - 'l' - Longs. passed as collect_values[].v_long. - * - 'd' - Doubles. passed as collect_values[].v_double. - * - 'p' - Pointers. passed as collect_values[].v_pointer. - * It should be noted that for variable argument list construction, - * ANSI C promotes every type smaller than an integer to an int, and - * floats to doubles. So for collection of short int or char, 'i' - * needs to be used, and for collection of floats 'd'. - * @collect_value: The collect_value() function is responsible for converting the - * values collected from a variable argument list into contents - * suitable for storage in a GValue. This function should setup - * @value similar to value_init(); e.g. for a string value that - * does not allow %NULL pointers, it needs to either spew an error, - * or do an implicit conversion by storing an empty string. - * The @value passed in to this function has a zero-filled data - * array, so just like for value_init() it is guaranteed to not - * contain any old contents that might need freeing. - * @n_collect_values is exactly the string length of @collect_format, - * and @collect_values is an array of unions #GTypeCValue with - * length @n_collect_values, containing the collected values - * according to @collect_format. - * @collect_flags is an argument provided as a hint by the caller. - * It may contain the flag %G_VALUE_NOCOPY_CONTENTS indicating, - * that the collected value contents may be considered "static" - * for the duration of the @value lifetime. - * Thus an extra copy of the contents stored in @collect_values is - * not required for assignment to @value. - * For our above string example, we continue with: - * |[ - * if (!collect_values[0].v_pointer) - * value->data[0].v_pointer = g_strdup (""); - * else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) - * { - * value->data[0].v_pointer = collect_values[0].v_pointer; - * // keep a flag for the value_free() implementation to not free this string - * value->data[1].v_uint = G_VALUE_NOCOPY_CONTENTS; - * } - * else - * value->data[0].v_pointer = g_strdup (collect_values[0].v_pointer); - * return NULL; - * ]| - * It should be noted, that it is generally a bad idea to follow the - * #G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to - * reentrancy requirements and reference count assertions performed - * by the signal emission code, reference counts should always be - * incremented for reference counted contents stored in the value->data - * array. To deviate from our string example for a moment, and taking - * a look at an exemplary implementation for collect_value() of - * #GObject: - * |[ - * GObject *object = G_OBJECT (collect_values[0].v_pointer); - * g_return_val_if_fail (object != NULL, - * g_strdup_printf ("Object passed as invalid NULL pointer")); - * // never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types - * value->data[0].v_pointer = g_object_ref (object); - * return NULL; - * ]| - * The reference count for valid objects is always incremented, - * regardless of @collect_flags. For invalid objects, the example - * returns a newly allocated string without altering @value. - * Upon success, collect_value() needs to return %NULL. If, however, - * an error condition occurred, collect_value() may spew an - * error by returning a newly allocated non-%NULL string, giving - * a suitable description of the error condition. - * The calling code makes no assumptions about the @value - * contents being valid upon error returns, @value - * is simply thrown away without further freeing. As such, it is - * a good idea to not allocate #GValue contents, prior to returning - * an error, however, collect_values() is not obliged to return - * a correctly setup @value for error returns, simply because - * any non-%NULL return is considered a fatal condition so further - * program behaviour is undefined. - * @lcopy_format: Format description of the arguments to collect for @lcopy_value, - * analogous to @collect_format. Usually, @lcopy_format string consists - * only of 'p's to provide lcopy_value() with pointers to storage locations. - * @lcopy_value: This function is responsible for storing the @value contents into - * arguments passed through a variable argument list which got - * collected into @collect_values according to @lcopy_format. - * @n_collect_values equals the string length of @lcopy_format, - * and @collect_flags may contain %G_VALUE_NOCOPY_CONTENTS. - * In contrast to collect_value(), lcopy_value() is obliged to - * always properly support %G_VALUE_NOCOPY_CONTENTS. - * Similar to collect_value() the function may prematurely abort - * by returning a newly allocated string describing an error condition. - * To complete the string example: - * |[ - * gchar **string_p = collect_values[0].v_pointer; - * g_return_val_if_fail (string_p != NULL, - * g_strdup_printf ("string location passed as NULL")); - * if (collect_flags & G_VALUE_NOCOPY_CONTENTS) - * *string_p = value->data[0].v_pointer; - * else - * *string_p = g_strdup (value->data[0].v_pointer); - * ]| - * And an illustrative version of lcopy_value() for - * reference-counted types: - * |[ - * GObject **object_p = collect_values[0].v_pointer; - * g_return_val_if_fail (object_p != NULL, - * g_strdup_printf ("object location passed as NULL")); - * if (!value->data[0].v_pointer) - * *object_p = NULL; - * else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) // always honour - * *object_p = value->data[0].v_pointer; - * else - * *object_p = g_object_ref (value->data[0].v_pointer); - * return NULL; - * ]| - * - * The #GTypeValueTable provides the functions required by the #GValue - * implementation, to serve as a container for values of a type. - */ - -struct _GTypeValueTable -{ - void (*value_init) (GValue *value); - void (*value_free) (GValue *value); - void (*value_copy) (const GValue *src_value, - GValue *dest_value); - /* varargs functionality (optional) */ - gpointer (*value_peek_pointer) (const GValue *value); - const gchar *collect_format; - gchar* (*collect_value) (GValue *value, - guint n_collect_values, - GTypeCValue *collect_values, - guint collect_flags); - const gchar *lcopy_format; - gchar* (*lcopy_value) (const GValue *value, - guint n_collect_values, - GTypeCValue *collect_values, - guint collect_flags); -}; -GLIB_AVAILABLE_IN_ALL -GType g_type_register_static (GType parent_type, - const gchar *type_name, - const GTypeInfo *info, - GTypeFlags flags); -GLIB_AVAILABLE_IN_ALL -GType g_type_register_static_simple (GType parent_type, - const gchar *type_name, - guint class_size, - GClassInitFunc class_init, - guint instance_size, - GInstanceInitFunc instance_init, - GTypeFlags flags); - -GLIB_AVAILABLE_IN_ALL -GType g_type_register_dynamic (GType parent_type, - const gchar *type_name, - GTypePlugin *plugin, - GTypeFlags flags); -GLIB_AVAILABLE_IN_ALL -GType g_type_register_fundamental (GType type_id, - const gchar *type_name, - const GTypeInfo *info, - const GTypeFundamentalInfo *finfo, - GTypeFlags flags); -GLIB_AVAILABLE_IN_ALL -void g_type_add_interface_static (GType instance_type, - GType interface_type, - const GInterfaceInfo *info); -GLIB_AVAILABLE_IN_ALL -void g_type_add_interface_dynamic (GType instance_type, - GType interface_type, - GTypePlugin *plugin); -GLIB_AVAILABLE_IN_ALL -void g_type_interface_add_prerequisite (GType interface_type, - GType prerequisite_type); -GLIB_AVAILABLE_IN_ALL -GType*g_type_interface_prerequisites (GType interface_type, - guint *n_prerequisites); -GLIB_AVAILABLE_IN_2_68 -GType g_type_interface_instantiatable_prerequisite - (GType interface_type); -GLIB_DEPRECATED_IN_2_58 -void g_type_class_add_private (gpointer g_class, - gsize private_size); -GLIB_AVAILABLE_IN_2_38 -gint g_type_add_instance_private (GType class_type, - gsize private_size); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_instance_get_private (GTypeInstance *instance, - GType private_type); -GLIB_AVAILABLE_IN_2_38 -void g_type_class_adjust_private_offset (gpointer g_class, - gint *private_size_or_offset); - -GLIB_AVAILABLE_IN_ALL -void g_type_add_class_private (GType class_type, - gsize private_size); -GLIB_AVAILABLE_IN_ALL -gpointer g_type_class_get_private (GTypeClass *klass, - GType private_type); -GLIB_AVAILABLE_IN_2_38 -gint g_type_class_get_instance_private_offset (gpointer g_class); - -GLIB_AVAILABLE_IN_2_34 -void g_type_ensure (GType type); -GLIB_AVAILABLE_IN_2_36 -guint g_type_get_type_registration_serial (void); - - -/* --- GType boilerplate --- */ -/** - * G_DECLARE_FINAL_TYPE: - * @ModuleObjName: The name of the new type, in camel case (like GtkWidget) - * @module_obj_name: The name of the new type in lowercase, with words - * separated by '_' (like 'gtk_widget') - * @MODULE: The name of the module, in all caps (like 'GTK') - * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET') - * @ParentName: the name of the parent type, in camel case (like GtkWidget) - * - * A convenience macro for emitting the usual declarations in the header file for a type which is not (at the - * present time) intended to be subclassed. - * - * You might use it in a header as follows: - * - * |[ - * #ifndef _myapp_window_h_ - * #define _myapp_window_h_ - * - * #include - * - * #define MY_APP_TYPE_WINDOW my_app_window_get_type () - * G_DECLARE_FINAL_TYPE (MyAppWindow, my_app_window, MY_APP, WINDOW, GtkWindow) - * - * MyAppWindow * my_app_window_new (void); - * - * ... - * - * #endif - * ]| - * - * This results in the following things happening: - * - * - the usual my_app_window_get_type() function is declared with a return type of #GType - * - * - the MyAppWindow types is defined as a typedef of struct _MyAppWindow. The struct itself is not - * defined and should be defined from the .c file before G_DEFINE_TYPE() is used. - * - * - the MY_APP_WINDOW() cast is emitted as static inline function along with the MY_APP_IS_WINDOW() type - * checking function - * - * - the MyAppWindowClass type is defined as a struct containing GtkWindowClass. This is done for the - * convenience of the person defining the type and should not be considered to be part of the ABI. In - * particular, without a firm declaration of the instance structure, it is not possible to subclass the type - * and therefore the fact that the size of the class structure is exposed is not a concern and it can be - * freely changed at any point in the future. - * - * - g_autoptr() support being added for your type, based on the type of your parent class - * - * You can only use this function if your parent type also supports g_autoptr(). - * - * Because the type macro (MY_APP_TYPE_WINDOW in the above example) is not a callable, you must continue to - * manually define this as a macro for yourself. - * - * The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro - * to be used in the usual way with export control and API versioning macros. - * - * If you want to declare your own class structure, use G_DECLARE_DERIVABLE_TYPE(). - * - * If you are writing a library, it is important to note that it is possible to convert a type from using - * G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you - * should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be - * subclassed. Once a class structure has been exposed it is not possible to change its size or remove or - * reorder items without breaking the API and/or ABI. - * - * Since: 2.44 - **/ -#define G_DECLARE_FINAL_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \ - GType module_obj_name##_get_type (void); \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - typedef struct _##ModuleObjName ModuleObjName; \ - typedef struct { ParentName##Class parent_class; } ModuleObjName##Class; \ - \ - _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \ - G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref) \ - \ - G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ - return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ - G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ - return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ - G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * G_DECLARE_DERIVABLE_TYPE: - * @ModuleObjName: The name of the new type, in camel case (like GtkWidget) - * @module_obj_name: The name of the new type in lowercase, with words - * separated by '_' (like 'gtk_widget') - * @MODULE: The name of the module, in all caps (like 'GTK') - * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET') - * @ParentName: the name of the parent type, in camel case (like GtkWidget) - * - * A convenience macro for emitting the usual declarations in the - * header file for a type which is intended to be subclassed. - * - * You might use it in a header as follows: - * - * |[ - * #ifndef _gtk_frobber_h_ - * #define _gtk_frobber_h_ - * - * #define GTK_TYPE_FROBBER gtk_frobber_get_type () - * GDK_AVAILABLE_IN_3_12 - * G_DECLARE_DERIVABLE_TYPE (GtkFrobber, gtk_frobber, GTK, FROBBER, GtkWidget) - * - * struct _GtkFrobberClass - * { - * GtkWidgetClass parent_class; - * - * void (* handle_frob) (GtkFrobber *frobber, - * guint n_frobs); - * - * gpointer padding[12]; - * }; - * - * GtkWidget * gtk_frobber_new (void); - * - * ... - * - * #endif - * ]| - * - * This results in the following things happening: - * - * - the usual gtk_frobber_get_type() function is declared with a return type of #GType - * - * - the GtkFrobber struct is created with GtkWidget as the first and only item. You are expected to use - * a private structure from your .c file to store your instance variables. - * - * - the GtkFrobberClass type is defined as a typedef to struct _GtkFrobberClass, which is left undefined. - * You should do this from the header file directly after you use the macro. - * - * - the GTK_FROBBER() and GTK_FROBBER_CLASS() casts are emitted as static inline functions along with - * the GTK_IS_FROBBER() and GTK_IS_FROBBER_CLASS() type checking functions and GTK_FROBBER_GET_CLASS() - * function. - * - * - g_autoptr() support being added for your type, based on the type of your parent class - * - * You can only use this function if your parent type also supports g_autoptr(). - * - * Because the type macro (GTK_TYPE_FROBBER in the above example) is not a callable, you must continue to - * manually define this as a macro for yourself. - * - * The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro - * to be used in the usual way with export control and API versioning macros. - * - * If you are writing a library, it is important to note that it is possible to convert a type from using - * G_DECLARE_FINAL_TYPE() to G_DECLARE_DERIVABLE_TYPE() without breaking API or ABI. As a precaution, you - * should therefore use G_DECLARE_FINAL_TYPE() until you are sure that it makes sense for your class to be - * subclassed. Once a class structure has been exposed it is not possible to change its size or remove or - * reorder items without breaking the API and/or ABI. If you want to declare your own class structure, use - * G_DECLARE_DERIVABLE_TYPE(). If you want to declare a class without exposing the class or instance - * structures, use G_DECLARE_FINAL_TYPE(). - * - * If you must use G_DECLARE_DERIVABLE_TYPE() you should be sure to include some padding at the bottom of your - * class structure to leave space for the addition of future virtual functions. - * - * Since: 2.44 - **/ -#define G_DECLARE_DERIVABLE_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \ - GType module_obj_name##_get_type (void); \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - typedef struct _##ModuleObjName ModuleObjName; \ - typedef struct _##ModuleObjName##Class ModuleObjName##Class; \ - struct _##ModuleObjName { ParentName parent_instance; }; \ - \ - _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, ParentName) \ - G_DEFINE_AUTOPTR_CLEANUP_FUNC (ModuleObjName##Class, g_type_class_unref) \ - \ - G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ - return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ - G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_CLASS (gpointer ptr) { \ - return G_TYPE_CHECK_CLASS_CAST (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \ - G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ - return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ - G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME##_CLASS (gpointer ptr) { \ - return G_TYPE_CHECK_CLASS_TYPE (ptr, module_obj_name##_get_type ()); } \ - G_GNUC_UNUSED static inline ModuleObjName##Class * MODULE##_##OBJ_NAME##_GET_CLASS (gpointer ptr) { \ - return G_TYPE_INSTANCE_GET_CLASS (ptr, module_obj_name##_get_type (), ModuleObjName##Class); } \ - G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * G_DECLARE_INTERFACE: - * @ModuleObjName: The name of the new type, in camel case (like GtkWidget) - * @module_obj_name: The name of the new type in lowercase, with words - * separated by '_' (like 'gtk_widget') - * @MODULE: The name of the module, in all caps (like 'GTK') - * @OBJ_NAME: The bare name of the type, in all caps (like 'WIDGET') - * @PrerequisiteName: the name of the prerequisite type, in camel case (like GtkWidget) - * - * A convenience macro for emitting the usual declarations in the header file for a GInterface type. - * - * You might use it in a header as follows: - * - * |[ - * #ifndef _my_model_h_ - * #define _my_model_h_ - * - * #define MY_TYPE_MODEL my_model_get_type () - * GDK_AVAILABLE_IN_3_12 - * G_DECLARE_INTERFACE (MyModel, my_model, MY, MODEL, GObject) - * - * struct _MyModelInterface - * { - * GTypeInterface g_iface; - * - * gpointer (* get_item) (MyModel *model); - * }; - * - * gpointer my_model_get_item (MyModel *model); - * - * ... - * - * #endif - * ]| - * - * This results in the following things happening: - * - * - the usual my_model_get_type() function is declared with a return type of #GType - * - * - the MyModelInterface type is defined as a typedef to struct _MyModelInterface, - * which is left undefined. You should do this from the header file directly after - * you use the macro. - * - * - the MY_MODEL() cast is emitted as static inline functions along with - * the MY_IS_MODEL() type checking function and MY_MODEL_GET_IFACE() function. - * - * - g_autoptr() support being added for your type, based on your prerequisite type. - * - * You can only use this function if your prerequisite type also supports g_autoptr(). - * - * Because the type macro (MY_TYPE_MODEL in the above example) is not a callable, you must continue to - * manually define this as a macro for yourself. - * - * The declaration of the _get_type() function is the first thing emitted by the macro. This allows this macro - * to be used in the usual way with export control and API versioning macros. - * - * Since: 2.44 - **/ -#define G_DECLARE_INTERFACE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, PrerequisiteName) \ - GType module_obj_name##_get_type (void); \ - G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ - typedef struct _##ModuleObjName ModuleObjName; \ - typedef struct _##ModuleObjName##Interface ModuleObjName##Interface; \ - \ - _GLIB_DEFINE_AUTOPTR_CHAINUP (ModuleObjName, PrerequisiteName) \ - \ - G_GNUC_UNUSED static inline ModuleObjName * MODULE##_##OBJ_NAME (gpointer ptr) { \ - return G_TYPE_CHECK_INSTANCE_CAST (ptr, module_obj_name##_get_type (), ModuleObjName); } \ - G_GNUC_UNUSED static inline gboolean MODULE##_IS_##OBJ_NAME (gpointer ptr) { \ - return G_TYPE_CHECK_INSTANCE_TYPE (ptr, module_obj_name##_get_type ()); } \ - G_GNUC_UNUSED static inline ModuleObjName##Interface * MODULE##_##OBJ_NAME##_GET_IFACE (gpointer ptr) { \ - return G_TYPE_INSTANCE_GET_INTERFACE (ptr, module_obj_name##_get_type (), ModuleObjName##Interface); } \ - G_GNUC_END_IGNORE_DEPRECATIONS - -/** - * G_DEFINE_TYPE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words - * separated by '_'. - * @T_P: The #GType of the parent type. - * - * A convenience macro for type implementations, which declares a class - * initialization function, an instance initialization function (see #GTypeInfo - * for information about these) and a static variable named `t_n_parent_class` - * pointing to the parent class. Furthermore, it defines a *_get_type() function. - * See G_DEFINE_TYPE_EXTENDED() for an example. - * - * Since: 2.4 - */ -#define G_DEFINE_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, {}) -/** - * G_DEFINE_TYPE_WITH_CODE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type in lowercase, with words separated by '_'. - * @T_P: The #GType of the parent type. - * @_C_: Custom code that gets inserted in the *_get_type() function. - * - * A convenience macro for type implementations. - * Similar to G_DEFINE_TYPE(), but allows you to insert custom code into the - * *_get_type() function, e.g. interface implementations via G_IMPLEMENT_INTERFACE(). - * See G_DEFINE_TYPE_EXTENDED() for an example. - * - * Since: 2.4 - */ -#define G_DEFINE_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, 0) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() -/** - * G_DEFINE_TYPE_WITH_PRIVATE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words - * separated by '_'. - * @T_P: The #GType of the parent type. - * - * A convenience macro for type implementations, which declares a class - * initialization function, an instance initialization function (see #GTypeInfo - * for information about these), a static variable named `t_n_parent_class` - * pointing to the parent class, and adds private instance data to the type. - * Furthermore, it defines a *_get_type() function. See G_DEFINE_TYPE_EXTENDED() - * for an example. - * - * Note that private structs added with this macros must have a struct - * name of the form @TN Private. - * - * The private instance data can be retrieved using the automatically generated - * getter function `t_n_get_instance_private()`. - * - * See also: G_ADD_PRIVATE() - * - * Since: 2.38 - */ -#define G_DEFINE_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, 0, G_ADD_PRIVATE (TN)) -/** - * G_DEFINE_ABSTRACT_TYPE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words - * separated by '_'. - * @T_P: The #GType of the parent type. - * - * A convenience macro for type implementations. - * Similar to G_DEFINE_TYPE(), but defines an abstract type. - * See G_DEFINE_TYPE_EXTENDED() for an example. - * - * Since: 2.4 - */ -#define G_DEFINE_ABSTRACT_TYPE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, {}) -/** - * G_DEFINE_ABSTRACT_TYPE_WITH_CODE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words - * separated by '_'. - * @T_P: The #GType of the parent type. - * @_C_: Custom code that gets inserted in the @type_name_get_type() function. - * - * A convenience macro for type implementations. - * Similar to G_DEFINE_TYPE_WITH_CODE(), but defines an abstract type and - * allows you to insert custom code into the *_get_type() function, e.g. - * interface implementations via G_IMPLEMENT_INTERFACE(). - * See G_DEFINE_TYPE_EXTENDED() for an example. - * - * Since: 2.4 - */ -#define G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() -/** - * G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words - * separated by '_'. - * @T_P: The #GType of the parent type. - * - * Similar to G_DEFINE_TYPE_WITH_PRIVATE(), but defines an abstract type. - * See G_DEFINE_TYPE_EXTENDED() for an example. - * - * Since: 2.38 - */ -#define G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(TN, t_n, T_P) G_DEFINE_TYPE_EXTENDED (TN, t_n, T_P, G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (TN)) -/** - * G_DEFINE_TYPE_EXTENDED: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words - * separated by '_'. - * @T_P: The #GType of the parent type. - * @_f_: #GTypeFlags to pass to g_type_register_static() - * @_C_: Custom code that gets inserted in the *_get_type() function. - * - * The most general convenience macro for type implementations, on which - * G_DEFINE_TYPE(), etc are based. - * - * |[ - * G_DEFINE_TYPE_EXTENDED (GtkGadget, - * gtk_gadget, - * GTK_TYPE_WIDGET, - * 0, - * G_ADD_PRIVATE (GtkGadget) - * G_IMPLEMENT_INTERFACE (TYPE_GIZMO, - * gtk_gadget_gizmo_init)); - * ]| - * expands to - * |[ - * static void gtk_gadget_init (GtkGadget *self); - * static void gtk_gadget_class_init (GtkGadgetClass *klass); - * static gpointer gtk_gadget_parent_class = NULL; - * static gint GtkGadget_private_offset; - * static void gtk_gadget_class_intern_init (gpointer klass) - * { - * gtk_gadget_parent_class = g_type_class_peek_parent (klass); - * if (GtkGadget_private_offset != 0) - * g_type_class_adjust_private_offset (klass, &GtkGadget_private_offset); - * gtk_gadget_class_init ((GtkGadgetClass*) klass); - * } - * static inline gpointer gtk_gadget_get_instance_private (GtkGadget *self) - * { - * return (G_STRUCT_MEMBER_P (self, GtkGadget_private_offset)); - * } - * - * GType - * gtk_gadget_get_type (void) - * { - * static gsize static_g_define_type_id = 0; - * if (g_once_init_enter (&static_g_define_type_id)) - * { - * GType g_define_type_id = - * g_type_register_static_simple (GTK_TYPE_WIDGET, - * g_intern_static_string ("GtkGadget"), - * sizeof (GtkGadgetClass), - * (GClassInitFunc) gtk_gadget_class_intern_init, - * sizeof (GtkGadget), - * (GInstanceInitFunc) gtk_gadget_init, - * 0); - * { - * GtkGadget_private_offset = - * g_type_add_instance_private (g_define_type_id, sizeof (GtkGadgetPrivate)); - * } - * { - * const GInterfaceInfo g_implement_interface_info = { - * (GInterfaceInitFunc) gtk_gadget_gizmo_init - * }; - * g_type_add_interface_static (g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); - * } - * g_once_init_leave (&static_g_define_type_id, g_define_type_id); - * } - * return static_g_define_type_id; - * } - * ]| - * The only pieces which have to be manually provided are the definitions of - * the instance and class structure and the definitions of the instance and - * class init functions. - * - * Since: 2.4 - */ -#define G_DEFINE_TYPE_EXTENDED(TN, t_n, T_P, _f_, _C_) _G_DEFINE_TYPE_EXTENDED_BEGIN (TN, t_n, T_P, _f_) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() - -/** - * G_DEFINE_INTERFACE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words separated by '_'. - * @T_P: The #GType of the prerequisite type for the interface, or 0 - * (%G_TYPE_INVALID) for no prerequisite type. - * - * A convenience macro for #GTypeInterface definitions, which declares - * a default vtable initialization function and defines a *_get_type() - * function. - * - * The macro expects the interface initialization function to have the - * name `t_n ## _default_init`, and the interface structure to have the - * name `TN ## Interface`. - * - * The initialization function has signature - * `static void t_n ## _default_init (TypeName##Interface *klass);`, rather than - * the full #GInterfaceInitFunc signature, for brevity and convenience. If you - * need to use an initialization function with an `iface_data` argument, you - * must write the #GTypeInterface definitions manually. - * - * Since: 2.24 - */ -#define G_DEFINE_INTERFACE(TN, t_n, T_P) G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, ;) - -/** - * G_DEFINE_INTERFACE_WITH_CODE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words separated by '_'. - * @T_P: The #GType of the prerequisite type for the interface, or 0 - * (%G_TYPE_INVALID) for no prerequisite type. - * @_C_: Custom code that gets inserted in the *_get_type() function. - * - * A convenience macro for #GTypeInterface definitions. Similar to - * G_DEFINE_INTERFACE(), but allows you to insert custom code into the - * *_get_type() function, e.g. additional interface implementations - * via G_IMPLEMENT_INTERFACE(), or additional prerequisite types. See - * G_DEFINE_TYPE_EXTENDED() for a similar example using - * G_DEFINE_TYPE_WITH_CODE(). - * - * Since: 2.24 - */ -#define G_DEFINE_INTERFACE_WITH_CODE(TN, t_n, T_P, _C_) _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TN, t_n, T_P) {_C_;} _G_DEFINE_INTERFACE_EXTENDED_END() - -/** - * G_IMPLEMENT_INTERFACE: - * @TYPE_IFACE: The #GType of the interface to add - * @iface_init: (type GInterfaceInitFunc): The interface init function, of type #GInterfaceInitFunc - * - * A convenience macro to ease interface addition in the `_C_` section - * of G_DEFINE_TYPE_WITH_CODE() or G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). - * See G_DEFINE_TYPE_EXTENDED() for an example. - * - * Note that this macro can only be used together with the G_DEFINE_TYPE_* - * macros, since it depends on variable names from those macros. - * - * Since: 2.4 - */ -#define G_IMPLEMENT_INTERFACE(TYPE_IFACE, iface_init) { \ - const GInterfaceInfo g_implement_interface_info = { \ - (GInterfaceInitFunc)(void (*)(void)) iface_init, NULL, NULL \ - }; \ - g_type_add_interface_static (g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \ -} - -/** - * G_ADD_PRIVATE: - * @TypeName: the name of the type in CamelCase - * - * A convenience macro to ease adding private data to instances of a new type - * in the @_C_ section of G_DEFINE_TYPE_WITH_CODE() or - * G_DEFINE_ABSTRACT_TYPE_WITH_CODE(). - * - * For instance: - * - * |[ - * typedef struct _MyObject MyObject; - * typedef struct _MyObjectClass MyObjectClass; - * - * typedef struct { - * gint foo; - * gint bar; - * } MyObjectPrivate; - * - * G_DEFINE_TYPE_WITH_CODE (MyObject, my_object, G_TYPE_OBJECT, - * G_ADD_PRIVATE (MyObject)) - * ]| - * - * Will add MyObjectPrivate as the private data to any instance of the MyObject - * type. - * - * G_DEFINE_TYPE_* macros will automatically create a private function - * based on the arguments to this macro, which can be used to safely - * retrieve the private data from an instance of the type; for instance: - * - * |[ - * gint - * my_object_get_foo (MyObject *obj) - * { - * MyObjectPrivate *priv = my_object_get_instance_private (obj); - * - * g_return_val_if_fail (MY_IS_OBJECT (obj), 0); - * - * return priv->foo; - * } - * - * void - * my_object_set_bar (MyObject *obj, - * gint bar) - * { - * MyObjectPrivate *priv = my_object_get_instance_private (obj); - * - * g_return_if_fail (MY_IS_OBJECT (obj)); - * - * if (priv->bar != bar) - * priv->bar = bar; - * } - * ]| - * - * Note that this macro can only be used together with the G_DEFINE_TYPE_* - * macros, since it depends on variable names from those macros. - * - * Also note that private structs added with these macros must have a struct - * name of the form `TypeNamePrivate`. - * - * It is safe to call the `_get_instance_private` function on %NULL or invalid - * objects since it's only adding an offset to the instance pointer. In that - * case the returned pointer must not be dereferenced. - * - * Since: 2.38 - */ -#define G_ADD_PRIVATE(TypeName) { \ - TypeName##_private_offset = \ - g_type_add_instance_private (g_define_type_id, sizeof (TypeName##Private)); \ -} - -/** - * G_PRIVATE_OFFSET: - * @TypeName: the name of the type in CamelCase - * @field: the name of the field in the private data structure - * - * Evaluates to the offset of the @field inside the instance private data - * structure for @TypeName. - * - * Note that this macro can only be used together with the G_DEFINE_TYPE_* - * and G_ADD_PRIVATE() macros, since it depends on variable names from - * those macros. - * - * Since: 2.38 - */ -#define G_PRIVATE_OFFSET(TypeName, field) \ - (TypeName##_private_offset + (G_STRUCT_OFFSET (TypeName##Private, field))) - -/** - * G_PRIVATE_FIELD_P: - * @TypeName: the name of the type in CamelCase - * @inst: the instance of @TypeName you wish to access - * @field_name: the name of the field in the private data structure - * - * Evaluates to a pointer to the @field_name inside the @inst private data - * structure for @TypeName. - * - * Note that this macro can only be used together with the G_DEFINE_TYPE_* - * and G_ADD_PRIVATE() macros, since it depends on variable names from - * those macros. - * - * Since: 2.38 - */ -#define G_PRIVATE_FIELD_P(TypeName, inst, field_name) \ - G_STRUCT_MEMBER_P (inst, G_PRIVATE_OFFSET (TypeName, field_name)) - -/** - * G_PRIVATE_FIELD: - * @TypeName: the name of the type in CamelCase - * @inst: the instance of @TypeName you wish to access - * @field_type: the type of the field in the private data structure - * @field_name: the name of the field in the private data structure - * - * Evaluates to the @field_name inside the @inst private data - * structure for @TypeName. - * - * Note that this macro can only be used together with the G_DEFINE_TYPE_* - * and G_ADD_PRIVATE() macros, since it depends on variable names from - * those macros. - * - * Since: 2.38 - */ -#define G_PRIVATE_FIELD(TypeName, inst, field_type, field_name) \ - G_STRUCT_MEMBER (field_type, inst, G_PRIVATE_OFFSET (TypeName, field_name)) - -/* we need to have this macro under conditional expansion, as it references - * a function that has been added in 2.38. see bug: - * https://bugzilla.gnome.org/show_bug.cgi?id=703191 - */ -#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 -#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ -static void type_name##_class_intern_init (gpointer klass) \ -{ \ - type_name##_parent_class = g_type_class_peek_parent (klass); \ - if (TypeName##_private_offset != 0) \ - g_type_class_adjust_private_offset (klass, &TypeName##_private_offset); \ - type_name##_class_init ((TypeName##Class*) klass); \ -} - -#else -#define _G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ -static void type_name##_class_intern_init (gpointer klass) \ -{ \ - type_name##_parent_class = g_type_class_peek_parent (klass); \ - type_name##_class_init ((TypeName##Class*) klass); \ -} -#endif /* GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38 */ - -/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */ -#define _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \ -\ -static void type_name##_init (TypeName *self); \ -static void type_name##_class_init (TypeName##Class *klass); \ -static GType type_name##_get_type_once (void); \ -static gpointer type_name##_parent_class = NULL; \ -static gint TypeName##_private_offset; \ -\ -_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ -\ -G_GNUC_UNUSED \ -static inline gpointer \ -type_name##_get_instance_private (TypeName *self) \ -{ \ - return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \ -} \ -\ -GType \ -type_name##_get_type (void) \ -{ \ - static gsize static_g_define_type_id = 0; - /* Prelude goes here */ - -/* Added for _G_DEFINE_TYPE_EXTENDED_WITH_PRELUDE */ -#define _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \ - if (g_once_init_enter (&static_g_define_type_id)) \ - { \ - GType g_define_type_id = type_name##_get_type_once (); \ - g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ - } \ - return static_g_define_type_id; \ -} /* closes type_name##_get_type() */ \ -\ -G_GNUC_NO_INLINE \ -static GType \ -type_name##_get_type_once (void) \ -{ \ - GType g_define_type_id = \ - g_type_register_static_simple (TYPE_PARENT, \ - g_intern_static_string (#TypeName), \ - sizeof (TypeName##Class), \ - (GClassInitFunc)(void (*)(void)) type_name##_class_intern_init, \ - sizeof (TypeName), \ - (GInstanceInitFunc)(void (*)(void)) type_name##_init, \ - (GTypeFlags) flags); \ - { /* custom code follows */ -#define _G_DEFINE_TYPE_EXTENDED_END() \ - /* following custom code */ \ - } \ - return g_define_type_id; \ -} /* closes type_name##_get_type_once() */ - -/* This was defined before we had G_DEFINE_TYPE_WITH_CODE_AND_PRELUDE, it's simplest - * to keep it. - */ -#define _G_DEFINE_TYPE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PARENT, flags) \ - _G_DEFINE_TYPE_EXTENDED_BEGIN_PRE(TypeName, type_name, TYPE_PARENT) \ - _G_DEFINE_TYPE_EXTENDED_BEGIN_REGISTER(TypeName, type_name, TYPE_PARENT, flags) \ - -#define _G_DEFINE_INTERFACE_EXTENDED_BEGIN(TypeName, type_name, TYPE_PREREQ) \ -\ -static void type_name##_default_init (TypeName##Interface *klass); \ -\ -GType \ -type_name##_get_type (void) \ -{ \ - static gsize static_g_define_type_id = 0; \ - if (g_once_init_enter (&static_g_define_type_id)) \ - { \ - GType g_define_type_id = \ - g_type_register_static_simple (G_TYPE_INTERFACE, \ - g_intern_static_string (#TypeName), \ - sizeof (TypeName##Interface), \ - (GClassInitFunc)(void (*)(void)) type_name##_default_init, \ - 0, \ - (GInstanceInitFunc)NULL, \ - (GTypeFlags) 0); \ - if (TYPE_PREREQ != G_TYPE_INVALID) \ - g_type_interface_add_prerequisite (g_define_type_id, TYPE_PREREQ); \ - { /* custom code follows */ -#define _G_DEFINE_INTERFACE_EXTENDED_END() \ - /* following custom code */ \ - } \ - g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ - } \ - return static_g_define_type_id; \ -} /* closes type_name##_get_type() */ - -/** - * G_DEFINE_BOXED_TYPE: - * @TypeName: The name of the new type, in Camel case - * @type_name: The name of the new type, in lowercase, with words - * separated by '_' - * @copy_func: the #GBoxedCopyFunc for the new type - * @free_func: the #GBoxedFreeFunc for the new type - * - * A convenience macro for boxed type implementations, which defines a - * type_name_get_type() function registering the boxed type. - * - * Since: 2.26 - */ -#define G_DEFINE_BOXED_TYPE(TypeName, type_name, copy_func, free_func) G_DEFINE_BOXED_TYPE_WITH_CODE (TypeName, type_name, copy_func, free_func, {}) -/** - * G_DEFINE_BOXED_TYPE_WITH_CODE: - * @TypeName: The name of the new type, in Camel case - * @type_name: The name of the new type, in lowercase, with words - * separated by '_' - * @copy_func: the #GBoxedCopyFunc for the new type - * @free_func: the #GBoxedFreeFunc for the new type - * @_C_: Custom code that gets inserted in the *_get_type() function - * - * A convenience macro for boxed type implementations. - * Similar to G_DEFINE_BOXED_TYPE(), but allows to insert custom code into the - * type_name_get_type() function, e.g. to register value transformations with - * g_value_register_transform_func(), for instance: - * - * |[ - * G_DEFINE_BOXED_TYPE_WITH_CODE (GdkRectangle, gdk_rectangle, - * gdk_rectangle_copy, - * gdk_rectangle_free, - * register_rectangle_transform_funcs (g_define_type_id)) - * ]| - * - * Similarly to the %G_DEFINE_TYPE family of macros, the #GType of the newly - * defined boxed type is exposed in the `g_define_type_id` variable. - * - * Since: 2.26 - */ -#define G_DEFINE_BOXED_TYPE_WITH_CODE(TypeName, type_name, copy_func, free_func, _C_) _G_DEFINE_BOXED_TYPE_BEGIN (TypeName, type_name, copy_func, free_func) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() - -/* Only use this in non-C++ on GCC >= 2.7, except for Darwin/ppc64. - * See https://bugzilla.gnome.org/show_bug.cgi?id=647145 - */ -#if !defined (__cplusplus) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) && !(defined (__APPLE__) && defined (__ppc64__)) -#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \ -static GType type_name##_get_type_once (void); \ -\ -GType \ -type_name##_get_type (void) \ -{ \ - static gsize static_g_define_type_id = 0; \ - if (g_once_init_enter (&static_g_define_type_id)) \ - { \ - GType g_define_type_id = type_name##_get_type_once (); \ - g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ - } \ - return static_g_define_type_id; \ -} \ -\ -G_GNUC_NO_INLINE \ -static GType \ -type_name##_get_type_once (void) \ -{ \ - GType (* _g_register_boxed) \ - (const gchar *, \ - union \ - { \ - TypeName * (*do_copy_type) (TypeName *); \ - TypeName * (*do_const_copy_type) (const TypeName *); \ - GBoxedCopyFunc do_copy_boxed; \ - } __attribute__((__transparent_union__)), \ - union \ - { \ - void (* do_free_type) (TypeName *); \ - GBoxedFreeFunc do_free_boxed; \ - } __attribute__((__transparent_union__)) \ - ) = g_boxed_type_register_static; \ - GType g_define_type_id = \ - _g_register_boxed (g_intern_static_string (#TypeName), copy_func, free_func); \ - { /* custom code follows */ -#else -#define _G_DEFINE_BOXED_TYPE_BEGIN(TypeName, type_name, copy_func, free_func) \ -static GType type_name##_get_type_once (void); \ -\ -GType \ -type_name##_get_type (void) \ -{ \ - static gsize static_g_define_type_id = 0; \ - if (g_once_init_enter (&static_g_define_type_id)) \ - { \ - GType g_define_type_id = type_name##_get_type_once (); \ - g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ - } \ - return static_g_define_type_id; \ -} \ -\ -G_GNUC_NO_INLINE \ -static GType \ -type_name##_get_type_once (void) \ -{ \ - GType g_define_type_id = \ - g_boxed_type_register_static (g_intern_static_string (#TypeName), \ - (GBoxedCopyFunc) copy_func, \ - (GBoxedFreeFunc) free_func); \ - { /* custom code follows */ -#endif /* __GNUC__ */ - -/** - * G_DEFINE_POINTER_TYPE: - * @TypeName: The name of the new type, in Camel case - * @type_name: The name of the new type, in lowercase, with words - * separated by '_' - * - * A convenience macro for pointer type implementations, which defines a - * type_name_get_type() function registering the pointer type. - * - * Since: 2.26 - */ -#define G_DEFINE_POINTER_TYPE(TypeName, type_name) G_DEFINE_POINTER_TYPE_WITH_CODE (TypeName, type_name, {}) -/** - * G_DEFINE_POINTER_TYPE_WITH_CODE: - * @TypeName: The name of the new type, in Camel case - * @type_name: The name of the new type, in lowercase, with words - * separated by '_' - * @_C_: Custom code that gets inserted in the *_get_type() function - * - * A convenience macro for pointer type implementations. - * Similar to G_DEFINE_POINTER_TYPE(), but allows to insert - * custom code into the type_name_get_type() function. - * - * Since: 2.26 - */ -#define G_DEFINE_POINTER_TYPE_WITH_CODE(TypeName, type_name, _C_) _G_DEFINE_POINTER_TYPE_BEGIN (TypeName, type_name) {_C_;} _G_DEFINE_TYPE_EXTENDED_END() - -#define _G_DEFINE_POINTER_TYPE_BEGIN(TypeName, type_name) \ -static GType type_name##_get_type_once (void); \ -\ -GType \ -type_name##_get_type (void) \ -{ \ - static gsize static_g_define_type_id = 0; \ - if (g_once_init_enter (&static_g_define_type_id)) \ - { \ - GType g_define_type_id = type_name##_get_type_once (); \ - g_once_init_leave (&static_g_define_type_id, g_define_type_id); \ - } \ - return static_g_define_type_id; \ -} \ -\ -G_GNUC_NO_INLINE \ -static GType \ -type_name##_get_type_once (void) \ -{ \ - GType g_define_type_id = \ - g_pointer_type_register_static (g_intern_static_string (#TypeName)); \ - { /* custom code follows */ - -/* --- protected (for fundamental type implementations) --- */ -GLIB_AVAILABLE_IN_ALL -GTypePlugin* g_type_get_plugin (GType type); -GLIB_AVAILABLE_IN_ALL -GTypePlugin* g_type_interface_get_plugin (GType instance_type, - GType interface_type); -GLIB_AVAILABLE_IN_ALL -GType g_type_fundamental_next (void); -GLIB_AVAILABLE_IN_ALL -GType g_type_fundamental (GType type_id); -GLIB_AVAILABLE_IN_ALL -GTypeInstance* g_type_create_instance (GType type); -GLIB_AVAILABLE_IN_ALL -void g_type_free_instance (GTypeInstance *instance); - -GLIB_AVAILABLE_IN_ALL -void g_type_add_class_cache_func (gpointer cache_data, - GTypeClassCacheFunc cache_func); -GLIB_AVAILABLE_IN_ALL -void g_type_remove_class_cache_func (gpointer cache_data, - GTypeClassCacheFunc cache_func); -GLIB_AVAILABLE_IN_ALL -void g_type_class_unref_uncached (gpointer g_class); - -GLIB_AVAILABLE_IN_ALL -void g_type_add_interface_check (gpointer check_data, - GTypeInterfaceCheckFunc check_func); -GLIB_AVAILABLE_IN_ALL -void g_type_remove_interface_check (gpointer check_data, - GTypeInterfaceCheckFunc check_func); - -GLIB_AVAILABLE_IN_ALL -GTypeValueTable* g_type_value_table_peek (GType type); - - -/*< private >*/ -GLIB_AVAILABLE_IN_ALL -gboolean g_type_check_instance (GTypeInstance *instance) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -GTypeInstance* g_type_check_instance_cast (GTypeInstance *instance, - GType iface_type); -GLIB_AVAILABLE_IN_ALL -gboolean g_type_check_instance_is_a (GTypeInstance *instance, - GType iface_type) G_GNUC_PURE; -GLIB_AVAILABLE_IN_2_42 -gboolean g_type_check_instance_is_fundamentally_a (GTypeInstance *instance, - GType fundamental_type) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -GTypeClass* g_type_check_class_cast (GTypeClass *g_class, - GType is_a_type); -GLIB_AVAILABLE_IN_ALL -gboolean g_type_check_class_is_a (GTypeClass *g_class, - GType is_a_type) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -gboolean g_type_check_is_value_type (GType type) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_type_check_value (const GValue *value) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -gboolean g_type_check_value_holds (const GValue *value, - GType type) G_GNUC_PURE; -GLIB_AVAILABLE_IN_ALL -gboolean g_type_test_flags (GType type, - guint flags) G_GNUC_CONST; - - -/* --- debugging functions --- */ -GLIB_AVAILABLE_IN_ALL -const gchar * g_type_name_from_instance (GTypeInstance *instance); -GLIB_AVAILABLE_IN_ALL -const gchar * g_type_name_from_class (GTypeClass *g_class); - - -/* --- implementation bits --- */ -#ifndef G_DISABLE_CAST_CHECKS -# define _G_TYPE_CIC(ip, gt, ct) \ - ((ct*) g_type_check_instance_cast ((GTypeInstance*) ip, gt)) -# define _G_TYPE_CCC(cp, gt, ct) \ - ((ct*) g_type_check_class_cast ((GTypeClass*) cp, gt)) -#else /* G_DISABLE_CAST_CHECKS */ -# define _G_TYPE_CIC(ip, gt, ct) ((ct*) ip) -# define _G_TYPE_CCC(cp, gt, ct) ((ct*) cp) -#endif /* G_DISABLE_CAST_CHECKS */ -#define _G_TYPE_CHI(ip) (g_type_check_instance ((GTypeInstance*) ip)) -#define _G_TYPE_CHV(vl) (g_type_check_value ((GValue*) vl)) -#define _G_TYPE_IGC(ip, gt, ct) ((ct*) (((GTypeInstance*) ip)->g_class)) -#define _G_TYPE_IGI(ip, gt, ct) ((ct*) g_type_interface_peek (((GTypeInstance*) ip)->g_class, gt)) -#define _G_TYPE_CIFT(ip, ft) (g_type_check_instance_is_fundamentally_a ((GTypeInstance*) ip, ft)) -#ifdef __GNUC__ -# define _G_TYPE_CIT(ip, gt) (G_GNUC_EXTENSION ({ \ - GTypeInstance *__inst = (GTypeInstance*) ip; GType __t = gt; gboolean __r; \ - if (!__inst) \ - __r = FALSE; \ - else if (__inst->g_class && __inst->g_class->g_type == __t) \ - __r = TRUE; \ - else \ - __r = g_type_check_instance_is_a (__inst, __t); \ - __r; \ -})) -# define _G_TYPE_CCT(cp, gt) (G_GNUC_EXTENSION ({ \ - GTypeClass *__class = (GTypeClass*) cp; GType __t = gt; gboolean __r; \ - if (!__class) \ - __r = FALSE; \ - else if (__class->g_type == __t) \ - __r = TRUE; \ - else \ - __r = g_type_check_class_is_a (__class, __t); \ - __r; \ -})) -# define _G_TYPE_CVH(vl, gt) (G_GNUC_EXTENSION ({ \ - const GValue *__val = (const GValue*) vl; GType __t = gt; gboolean __r; \ - if (!__val) \ - __r = FALSE; \ - else if (__val->g_type == __t) \ - __r = TRUE; \ - else \ - __r = g_type_check_value_holds (__val, __t); \ - __r; \ -})) -#else /* !__GNUC__ */ -# define _G_TYPE_CIT(ip, gt) (g_type_check_instance_is_a ((GTypeInstance*) ip, gt)) -# define _G_TYPE_CCT(cp, gt) (g_type_check_class_is_a ((GTypeClass*) cp, gt)) -# define _G_TYPE_CVH(vl, gt) (g_type_check_value_holds ((const GValue*) vl, gt)) -#endif /* !__GNUC__ */ -/** - * G_TYPE_FLAG_RESERVED_ID_BIT: - * - * A bit in the type number that's supposed to be left untouched. - */ -#define G_TYPE_FLAG_RESERVED_ID_BIT ((GType) (1 << 0)) - -G_END_DECLS - -#endif /* __G_TYPE_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - * - * gvalue.h: generic GValue functions - */ -#ifndef __G_VALUE_H__ -#define __G_VALUE_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* --- type macros --- */ -/** - * G_TYPE_IS_VALUE: - * @type: A #GType value. - * - * Checks whether the passed in type ID can be used for g_value_init(). - * That is, this macro checks whether this type provides an implementation - * of the #GTypeValueTable functions required for a type to create a #GValue of. - * - * Returns: Whether @type is suitable as a #GValue type. - */ -#define G_TYPE_IS_VALUE(type) (g_type_check_is_value_type (type)) -/** - * G_IS_VALUE: - * @value: A #GValue structure. - * - * Checks if @value is a valid and initialized #GValue structure. - * - * Returns: %TRUE on success. - */ -#define G_IS_VALUE(value) (G_TYPE_CHECK_VALUE (value)) -/** - * G_VALUE_TYPE: - * @value: A #GValue structure. - * - * Get the type identifier of @value. - * - * Returns: the #GType. - */ -#define G_VALUE_TYPE(value) (((GValue*) (value))->g_type) -/** - * G_VALUE_TYPE_NAME: - * @value: A #GValue structure. - * - * Gets the type name of @value. - * - * Returns: the type name. - */ -#define G_VALUE_TYPE_NAME(value) (g_type_name (G_VALUE_TYPE (value))) -/** - * G_VALUE_HOLDS: - * @value: A #GValue structure. - * @type: A #GType value. - * - * Checks if @value holds (or contains) a value of @type. - * This macro will also check for @value != %NULL and issue a - * warning if the check fails. - * - * Returns: %TRUE if @value holds the @type. - */ -#define G_VALUE_HOLDS(value,type) (G_TYPE_CHECK_VALUE_TYPE ((value), (type))) - - -/* --- typedefs & structures --- */ -/** - * GValueTransform: - * @src_value: Source value. - * @dest_value: Target value. - * - * The type of value transformation functions which can be registered with - * g_value_register_transform_func(). - * - * @dest_value will be initialized to the correct destination type. - */ -typedef void (*GValueTransform) (const GValue *src_value, - GValue *dest_value); -/** - * GValue: - * - * An opaque structure used to hold different types of values. - * The data within the structure has protected scope: it is accessible only - * to functions within a #GTypeValueTable structure, or implementations of - * the g_value_*() API. That is, code portions which implement new fundamental - * types. - * #GValue users cannot make any assumptions about how data is stored - * within the 2 element @data union, and the @g_type member should - * only be accessed through the G_VALUE_TYPE() macro. - */ -struct _GValue -{ - /*< private >*/ - GType g_type; - - /* public for GTypeValueTable methods */ - union { - gint v_int; - guint v_uint; - glong v_long; - gulong v_ulong; - gint64 v_int64; - guint64 v_uint64; - gfloat v_float; - gdouble v_double; - gpointer v_pointer; - } data[2]; -}; - - -/* --- prototypes --- */ -GLIB_AVAILABLE_IN_ALL -GValue* g_value_init (GValue *value, - GType g_type); -GLIB_AVAILABLE_IN_ALL -void g_value_copy (const GValue *src_value, - GValue *dest_value); -GLIB_AVAILABLE_IN_ALL -GValue* g_value_reset (GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_unset (GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_instance (GValue *value, - gpointer instance); -GLIB_AVAILABLE_IN_2_42 -void g_value_init_from_instance (GValue *value, - gpointer instance); - - -/* --- private --- */ -GLIB_AVAILABLE_IN_ALL -gboolean g_value_fits_pointer (const GValue *value); -GLIB_AVAILABLE_IN_ALL -gpointer g_value_peek_pointer (const GValue *value); - - -/* --- implementation details --- */ -GLIB_AVAILABLE_IN_ALL -gboolean g_value_type_compatible (GType src_type, - GType dest_type); -GLIB_AVAILABLE_IN_ALL -gboolean g_value_type_transformable (GType src_type, - GType dest_type); -GLIB_AVAILABLE_IN_ALL -gboolean g_value_transform (const GValue *src_value, - GValue *dest_value); -GLIB_AVAILABLE_IN_ALL -void g_value_register_transform_func (GType src_type, - GType dest_type, - GValueTransform transform_func); - -/** - * G_VALUE_NOCOPY_CONTENTS: - * - * If passed to G_VALUE_COLLECT(), allocated data won't be copied - * but used verbatim. This does not affect ref-counted types like - * objects. This does not affect usage of g_value_copy(), the data will - * be copied if it is not ref-counted. - */ -#define G_VALUE_NOCOPY_CONTENTS (1 << 27) - -/** - * G_VALUE_INTERNED_STRING: - * - * For string values, indicates that the string contained is canonical and will - * exist for the duration of the process. See g_value_set_interned_string(). - * - * Since: 2.66 - */ -#define G_VALUE_INTERNED_STRING (1 << 28) GLIB_AVAILABLE_MACRO_IN_2_66 - -/** - * G_VALUE_INIT: - * - * A #GValue must be initialized before it can be used. This macro can - * be used as initializer instead of an explicit `{ 0 }` when declaring - * a variable, but it cannot be assigned to a variable. - * - * |[ - * GValue value = G_VALUE_INIT; - * ]| - * - * Since: 2.30 - */ -#define G_VALUE_INIT { 0, { { 0 } } } - - -G_END_DECLS - -#endif /* __G_VALUE_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - * - * gparam.h: GParamSpec base class implementation - */ -#ifndef __G_PARAM_H__ -#define __G_PARAM_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* --- standard type macros --- */ -/** - * G_TYPE_IS_PARAM: - * @type: a #GType ID - * - * Checks whether @type "is a" %G_TYPE_PARAM. - */ -#define G_TYPE_IS_PARAM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_PARAM) -/** - * G_PARAM_SPEC: - * @pspec: a valid #GParamSpec - * - * Casts a derived #GParamSpec object (e.g. of type #GParamSpecInt) into - * a #GParamSpec object. - */ -#define G_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM, GParamSpec)) -/** - * G_IS_PARAM_SPEC: - * @pspec: a #GParamSpec - * - * Checks whether @pspec "is a" valid #GParamSpec structure of type %G_TYPE_PARAM - * or derived. - */ -#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_42 -#define G_IS_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE ((pspec), G_TYPE_PARAM)) -#else -#define G_IS_PARAM_SPEC(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM)) -#endif -/** - * G_PARAM_SPEC_CLASS: - * @pclass: a valid #GParamSpecClass - * - * Casts a derived #GParamSpecClass structure into a #GParamSpecClass structure. - */ -#define G_PARAM_SPEC_CLASS(pclass) (G_TYPE_CHECK_CLASS_CAST ((pclass), G_TYPE_PARAM, GParamSpecClass)) -/** - * G_IS_PARAM_SPEC_CLASS: - * @pclass: a #GParamSpecClass - * - * Checks whether @pclass "is a" valid #GParamSpecClass structure of type - * %G_TYPE_PARAM or derived. - */ -#define G_IS_PARAM_SPEC_CLASS(pclass) (G_TYPE_CHECK_CLASS_TYPE ((pclass), G_TYPE_PARAM)) -/** - * G_PARAM_SPEC_GET_CLASS: - * @pspec: a valid #GParamSpec - * - * Retrieves the #GParamSpecClass of a #GParamSpec. - */ -#define G_PARAM_SPEC_GET_CLASS(pspec) (G_TYPE_INSTANCE_GET_CLASS ((pspec), G_TYPE_PARAM, GParamSpecClass)) - - -/* --- convenience macros --- */ -/** - * G_PARAM_SPEC_TYPE: - * @pspec: a valid #GParamSpec - * - * Retrieves the #GType of this @pspec. - */ -#define G_PARAM_SPEC_TYPE(pspec) (G_TYPE_FROM_INSTANCE (pspec)) -/** - * G_PARAM_SPEC_TYPE_NAME: - * @pspec: a valid #GParamSpec - * - * Retrieves the #GType name of this @pspec. - */ -#define G_PARAM_SPEC_TYPE_NAME(pspec) (g_type_name (G_PARAM_SPEC_TYPE (pspec))) -/** - * G_PARAM_SPEC_VALUE_TYPE: - * @pspec: a valid #GParamSpec - * - * Retrieves the #GType to initialize a #GValue for this parameter. - */ -#define G_PARAM_SPEC_VALUE_TYPE(pspec) (G_PARAM_SPEC (pspec)->value_type) -/** - * G_VALUE_HOLDS_PARAM: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values derived from type %G_TYPE_PARAM. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_PARAM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_PARAM)) - - -/* --- flags --- */ -/** - * GParamFlags: - * @G_PARAM_READABLE: the parameter is readable - * @G_PARAM_WRITABLE: the parameter is writable - * @G_PARAM_READWRITE: alias for %G_PARAM_READABLE | %G_PARAM_WRITABLE - * @G_PARAM_CONSTRUCT: the parameter will be set upon object construction - * @G_PARAM_CONSTRUCT_ONLY: the parameter can only be set upon object construction - * @G_PARAM_LAX_VALIDATION: upon parameter conversion (see g_param_value_convert()) - * strict validation is not required - * @G_PARAM_STATIC_NAME: the string used as name when constructing the - * parameter is guaranteed to remain valid and - * unmodified for the lifetime of the parameter. - * Since 2.8 - * @G_PARAM_STATIC_NICK: the string used as nick when constructing the - * parameter is guaranteed to remain valid and - * unmmodified for the lifetime of the parameter. - * Since 2.8 - * @G_PARAM_STATIC_BLURB: the string used as blurb when constructing the - * parameter is guaranteed to remain valid and - * unmodified for the lifetime of the parameter. - * Since 2.8 - * @G_PARAM_EXPLICIT_NOTIFY: calls to g_object_set_property() for this - * property will not automatically result in a "notify" signal being - * emitted: the implementation must call g_object_notify() themselves - * in case the property actually changes. Since: 2.42. - * @G_PARAM_PRIVATE: internal - * @G_PARAM_DEPRECATED: the parameter is deprecated and will be removed - * in a future version. A warning will be generated if it is used - * while running with G_ENABLE_DIAGNOSTIC=1. - * Since 2.26 - * - * Through the #GParamFlags flag values, certain aspects of parameters - * can be configured. See also #G_PARAM_STATIC_STRINGS. - */ -typedef enum -{ - G_PARAM_READABLE = 1 << 0, - G_PARAM_WRITABLE = 1 << 1, - G_PARAM_READWRITE = (G_PARAM_READABLE | G_PARAM_WRITABLE), - G_PARAM_CONSTRUCT = 1 << 2, - G_PARAM_CONSTRUCT_ONLY = 1 << 3, - G_PARAM_LAX_VALIDATION = 1 << 4, - G_PARAM_STATIC_NAME = 1 << 5, - G_PARAM_PRIVATE GLIB_DEPRECATED_ENUMERATOR_IN_2_26 = G_PARAM_STATIC_NAME, - G_PARAM_STATIC_NICK = 1 << 6, - G_PARAM_STATIC_BLURB = 1 << 7, - /* User defined flags go here */ - G_PARAM_EXPLICIT_NOTIFY = 1 << 30, - /* Avoid warning with -Wpedantic for gcc6 */ - G_PARAM_DEPRECATED = (gint)(1u << 31) -} GParamFlags; - -/** - * G_PARAM_STATIC_STRINGS: - * - * #GParamFlags value alias for %G_PARAM_STATIC_NAME | %G_PARAM_STATIC_NICK | %G_PARAM_STATIC_BLURB. - * - * Since 2.13.0 - */ -#define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) -/* bits in the range 0xffffff00 are reserved for 3rd party usage */ -/** - * G_PARAM_MASK: - * - * Mask containing the bits of #GParamSpec.flags which are reserved for GLib. - */ -#define G_PARAM_MASK (0x000000ff) -/** - * G_PARAM_USER_SHIFT: - * - * Minimum shift count to be used for user defined flags, to be stored in - * #GParamSpec.flags. The maximum allowed is 10. - */ -#define G_PARAM_USER_SHIFT (8) - -/* --- typedefs & structures --- */ -typedef struct _GParamSpec GParamSpec; -typedef struct _GParamSpecClass GParamSpecClass; -typedef struct _GParameter GParameter GLIB_DEPRECATED_TYPE_IN_2_54; -typedef struct _GParamSpecPool GParamSpecPool; -/** - * GParamSpec: (ref-func g_param_spec_ref_sink) (unref-func g_param_spec_uref) (set-value-func g_value_set_param) (get-value-func g_value_get_param) - * @g_type_instance: private #GTypeInstance portion - * @name: name of this parameter: always an interned string - * @flags: #GParamFlags flags for this parameter - * @value_type: the #GValue type for this parameter - * @owner_type: #GType type that uses (introduces) this parameter - * - * All other fields of the GParamSpec struct are private and - * should not be used directly. - */ -struct _GParamSpec -{ - GTypeInstance g_type_instance; - - const gchar *name; /* interned string */ - GParamFlags flags; - GType value_type; - GType owner_type; /* class or interface using this property */ - - /*< private >*/ - gchar *_nick; - gchar *_blurb; - GData *qdata; - guint ref_count; - guint param_id; /* sort-criteria */ -}; -/** - * GParamSpecClass: - * @g_type_class: the parent class - * @value_type: the #GValue type for this parameter - * @finalize: The instance finalization function (optional), should chain - * up to the finalize method of the parent class. - * @value_set_default: Resets a @value to the default value for this type - * (recommended, the default is g_value_reset()), see - * g_param_value_set_default(). - * @value_validate: Ensures that the contents of @value comply with the - * specifications set out by this type (optional), see - * g_param_value_validate(). - * @values_cmp: Compares @value1 with @value2 according to this type - * (recommended, the default is memcmp()), see g_param_values_cmp(). - * - * The class structure for the GParamSpec type. - * Normally, GParamSpec classes are filled by - * g_param_type_register_static(). - */ -struct _GParamSpecClass -{ - GTypeClass g_type_class; - - GType value_type; - - void (*finalize) (GParamSpec *pspec); - - /* GParam methods */ - void (*value_set_default) (GParamSpec *pspec, - GValue *value); - gboolean (*value_validate) (GParamSpec *pspec, - GValue *value); - gint (*values_cmp) (GParamSpec *pspec, - const GValue *value1, - const GValue *value2); - /*< private >*/ - gpointer dummy[4]; -}; -/** - * GParameter: - * @name: the parameter name - * @value: the parameter value - * - * The GParameter struct is an auxiliary structure used - * to hand parameter name/value pairs to g_object_newv(). - * - * Deprecated: 2.54: This type is not introspectable. - */ -struct _GParameter /* auxiliary structure for _setv() variants */ -{ - const gchar *name; - GValue value; -} GLIB_DEPRECATED_TYPE_IN_2_54; - - -/* --- prototypes --- */ -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_ref (GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -void g_param_spec_unref (GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -void g_param_spec_sink (GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_ref_sink (GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -gpointer g_param_spec_get_qdata (GParamSpec *pspec, - GQuark quark); -GLIB_AVAILABLE_IN_ALL -void g_param_spec_set_qdata (GParamSpec *pspec, - GQuark quark, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_param_spec_set_qdata_full (GParamSpec *pspec, - GQuark quark, - gpointer data, - GDestroyNotify destroy); -GLIB_AVAILABLE_IN_ALL -gpointer g_param_spec_steal_qdata (GParamSpec *pspec, - GQuark quark); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_get_redirect_target (GParamSpec *pspec); - -GLIB_AVAILABLE_IN_ALL -void g_param_value_set_default (GParamSpec *pspec, - GValue *value); -GLIB_AVAILABLE_IN_ALL -gboolean g_param_value_defaults (GParamSpec *pspec, - const GValue *value); -GLIB_AVAILABLE_IN_ALL -gboolean g_param_value_validate (GParamSpec *pspec, - GValue *value); -GLIB_AVAILABLE_IN_ALL -gboolean g_param_value_convert (GParamSpec *pspec, - const GValue *src_value, - GValue *dest_value, - gboolean strict_validation); -GLIB_AVAILABLE_IN_ALL -gint g_param_values_cmp (GParamSpec *pspec, - const GValue *value1, - const GValue *value2); -GLIB_AVAILABLE_IN_ALL -const gchar * g_param_spec_get_name (GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -const gchar * g_param_spec_get_nick (GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -const gchar * g_param_spec_get_blurb (GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -void g_value_set_param (GValue *value, - GParamSpec *param); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_value_get_param (const GValue *value); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_value_dup_param (const GValue *value); - - -GLIB_AVAILABLE_IN_ALL -void g_value_take_param (GValue *value, - GParamSpec *param); -GLIB_DEPRECATED_FOR(g_value_take_param) -void g_value_set_param_take_ownership (GValue *value, - GParamSpec *param); -GLIB_AVAILABLE_IN_2_36 -const GValue * g_param_spec_get_default_value (GParamSpec *pspec); - -GLIB_AVAILABLE_IN_2_46 -GQuark g_param_spec_get_name_quark (GParamSpec *pspec); - -/* --- convenience functions --- */ -typedef struct _GParamSpecTypeInfo GParamSpecTypeInfo; -/** - * GParamSpecTypeInfo: - * @instance_size: Size of the instance (object) structure. - * @n_preallocs: Prior to GLib 2.10, it specified the number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching). Since GLib 2.10, it is ignored, since instances are allocated with the [slice allocator][glib-Memory-Slices] now. - * @instance_init: Location of the instance initialization function (optional). - * @value_type: The #GType of values conforming to this #GParamSpec - * @finalize: The instance finalization function (optional). - * @value_set_default: Resets a @value to the default value for @pspec - * (recommended, the default is g_value_reset()), see - * g_param_value_set_default(). - * @value_validate: Ensures that the contents of @value comply with the - * specifications set out by @pspec (optional), see - * g_param_value_validate(). - * @values_cmp: Compares @value1 with @value2 according to @pspec - * (recommended, the default is memcmp()), see g_param_values_cmp(). - * - * This structure is used to provide the type system with the information - * required to initialize and destruct (finalize) a parameter's class and - * instances thereof. - * The initialized structure is passed to the g_param_type_register_static() - * The type system will perform a deep copy of this structure, so its memory - * does not need to be persistent across invocation of - * g_param_type_register_static(). - */ -struct _GParamSpecTypeInfo -{ - /* type system portion */ - guint16 instance_size; /* obligatory */ - guint16 n_preallocs; /* optional */ - void (*instance_init) (GParamSpec *pspec); /* optional */ - - /* class portion */ - GType value_type; /* obligatory */ - void (*finalize) (GParamSpec *pspec); /* optional */ - void (*value_set_default) (GParamSpec *pspec, /* recommended */ - GValue *value); - gboolean (*value_validate) (GParamSpec *pspec, /* optional */ - GValue *value); - gint (*values_cmp) (GParamSpec *pspec, /* recommended */ - const GValue *value1, - const GValue *value2); -}; -GLIB_AVAILABLE_IN_ALL -GType g_param_type_register_static (const gchar *name, - const GParamSpecTypeInfo *pspec_info); - -GLIB_AVAILABLE_IN_2_66 -gboolean g_param_spec_is_valid_name (const gchar *name); - -/* For registering builting types */ -GType _g_param_type_register_static_constant (const gchar *name, - const GParamSpecTypeInfo *pspec_info, - GType opt_type); - - -/* --- protected --- */ -GLIB_AVAILABLE_IN_ALL -gpointer g_param_spec_internal (GType param_type, - const gchar *name, - const gchar *nick, - const gchar *blurb, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpecPool* g_param_spec_pool_new (gboolean type_prefixing); -GLIB_AVAILABLE_IN_ALL -void g_param_spec_pool_insert (GParamSpecPool *pool, - GParamSpec *pspec, - GType owner_type); -GLIB_AVAILABLE_IN_ALL -void g_param_spec_pool_remove (GParamSpecPool *pool, - GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_pool_lookup (GParamSpecPool *pool, - const gchar *param_name, - GType owner_type, - gboolean walk_ancestors); -GLIB_AVAILABLE_IN_ALL -GList* g_param_spec_pool_list_owned (GParamSpecPool *pool, - GType owner_type); -GLIB_AVAILABLE_IN_ALL -GParamSpec** g_param_spec_pool_list (GParamSpecPool *pool, - GType owner_type, - guint *n_pspecs_p); - - -/* contracts: - * - * gboolean value_validate (GParamSpec *pspec, - * GValue *value): - * modify value contents in the least destructive way, so - * that it complies with pspec's requirements (i.e. - * according to minimum/maximum ranges etc...). return - * whether modification was necessary. - * - * gint values_cmp (GParamSpec *pspec, - * const GValue *value1, - * const GValue *value2): - * return value1 - value2, i.e. (-1) if value1 < value2, - * (+1) if value1 > value2, and (0) otherwise (equality) - */ - -G_END_DECLS - -#endif /* __G_PARAM_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 2000-2001 Red Hat, Inc. - * Copyright (C) 2005 Imendio AB - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __G_CLOSURE_H__ -#define __G_CLOSURE_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* --- defines --- */ -/** - * G_CLOSURE_NEEDS_MARSHAL: - * @closure: a #GClosure - * - * Check if the closure still needs a marshaller. See g_closure_set_marshal(). - * - * Returns: %TRUE if a #GClosureMarshal marshaller has not yet been set on - * @closure. - */ -#define G_CLOSURE_NEEDS_MARSHAL(closure) (((GClosure*) (closure))->marshal == NULL) -/** - * G_CLOSURE_N_NOTIFIERS: - * @cl: a #GClosure - * - * Get the total number of notifiers connected with the closure @cl. - * The count includes the meta marshaller, the finalize and invalidate notifiers - * and the marshal guards. Note that each guard counts as two notifiers. - * See g_closure_set_meta_marshal(), g_closure_add_finalize_notifier(), - * g_closure_add_invalidate_notifier() and g_closure_add_marshal_guards(). - * - * Returns: number of notifiers - */ -#define G_CLOSURE_N_NOTIFIERS(cl) (((cl)->n_guards << 1L) + \ - (cl)->n_fnotifiers + (cl)->n_inotifiers) -/** - * G_CCLOSURE_SWAP_DATA: - * @cclosure: a #GCClosure - * - * Checks whether the user data of the #GCClosure should be passed as the - * first parameter to the callback. See g_cclosure_new_swap(). - * - * Returns: %TRUE if data has to be swapped. - */ -#define G_CCLOSURE_SWAP_DATA(cclosure) (((GClosure*) (cclosure))->derivative_flag) -/** - * G_CALLBACK: - * @f: a function pointer. - * - * Cast a function pointer to a #GCallback. - */ -#define G_CALLBACK(f) ((GCallback) (f)) - - -/* -- typedefs --- */ -typedef struct _GClosure GClosure; -typedef struct _GClosureNotifyData GClosureNotifyData; - -/** - * GCallback: - * - * The type used for callback functions in structure definitions and function - * signatures. This doesn't mean that all callback functions must take no - * parameters and return void. The required signature of a callback function - * is determined by the context in which is used (e.g. the signal to which it - * is connected). Use G_CALLBACK() to cast the callback function to a #GCallback. - */ -typedef void (*GCallback) (void); -/** - * GClosureNotify: - * @data: data specified when registering the notification callback - * @closure: the #GClosure on which the notification is emitted - * - * The type used for the various notification callbacks which can be registered - * on closures. - */ -typedef void (*GClosureNotify) (gpointer data, - GClosure *closure); -/** - * GClosureMarshal: - * @closure: the #GClosure to which the marshaller belongs - * @return_value: (nullable): a #GValue to store the return - * value. May be %NULL if the callback of @closure doesn't return a - * value. - * @n_param_values: the length of the @param_values array - * @param_values: (array length=n_param_values): an array of - * #GValues holding the arguments on which to invoke the - * callback of @closure - * @invocation_hint: (nullable): the invocation hint given as the - * last argument to g_closure_invoke() - * @marshal_data: (nullable): additional data specified when - * registering the marshaller, see g_closure_set_marshal() and - * g_closure_set_meta_marshal() - * - * The type used for marshaller functions. - */ -typedef void (*GClosureMarshal) (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -/** - * GVaClosureMarshal: - * @closure: the #GClosure to which the marshaller belongs - * @return_value: (nullable): a #GValue to store the return - * value. May be %NULL if the callback of @closure doesn't return a - * value. - * @instance: (type GObject.TypeInstance): the instance on which the closure is - * invoked. - * @args: va_list of arguments to be passed to the closure. - * @marshal_data: (nullable): additional data specified when - * registering the marshaller, see g_closure_set_marshal() and - * g_closure_set_meta_marshal() - * @n_params: the length of the @param_types array - * @param_types: (array length=n_params): the #GType of each argument from - * @args. - * - * This is the signature of va_list marshaller functions, an optional - * marshaller that can be used in some situations to avoid - * marshalling the signal argument into GValues. - */ -typedef void (* GVaClosureMarshal) (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/** - * GCClosure: - * @closure: the #GClosure - * @callback: the callback function - * - * A #GCClosure is a specialization of #GClosure for C function callbacks. - */ -typedef struct _GCClosure GCClosure; - - -/* --- structures --- */ -struct _GClosureNotifyData -{ - gpointer data; - GClosureNotify notify; -}; -/** - * GClosure: - * @in_marshal: Indicates whether the closure is currently being invoked with - * g_closure_invoke() - * @is_invalid: Indicates whether the closure has been invalidated by - * g_closure_invalidate() - * - * A #GClosure represents a callback supplied by the programmer. - */ -struct _GClosure -{ - /*< private >*/ - guint ref_count : 15; /* (atomic) */ - /* meta_marshal is not used anymore but must be zero for historical reasons - as it was exposed in the G_CLOSURE_N_NOTIFIERS macro */ - guint meta_marshal_nouse : 1; /* (atomic) */ - guint n_guards : 1; /* (atomic) */ - guint n_fnotifiers : 2; /* finalization notifiers (atomic) */ - guint n_inotifiers : 8; /* invalidation notifiers (atomic) */ - guint in_inotify : 1; /* (atomic) */ - guint floating : 1; /* (atomic) */ - /*< protected >*/ - guint derivative_flag : 1; /* (atomic) */ - /*< public >*/ - guint in_marshal : 1; /* (atomic) */ - guint is_invalid : 1; /* (atomic) */ - - /*< private >*/ void (*marshal) (GClosure *closure, - GValue /*out*/ *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - /*< protected >*/ gpointer data; - - /*< private >*/ GClosureNotifyData *notifiers; - - /* invariants/constraints: - * - ->marshal and ->data are _invalid_ as soon as ->is_invalid==TRUE - * - invocation of all inotifiers occurs prior to fnotifiers - * - order of inotifiers is random - * inotifiers may _not_ free/invalidate parameter values (e.g. ->data) - * - order of fnotifiers is random - * - each notifier may only be removed before or during its invocation - * - reference counting may only happen prior to fnotify invocation - * (in that sense, fnotifiers are really finalization handlers) - */ -}; -/* closure for C function calls, callback() is the user function - */ -struct _GCClosure -{ - GClosure closure; - gpointer callback; -}; - - -/* --- prototypes --- */ -GLIB_AVAILABLE_IN_ALL -GClosure* g_cclosure_new (GCallback callback_func, - gpointer user_data, - GClosureNotify destroy_data); -GLIB_AVAILABLE_IN_ALL -GClosure* g_cclosure_new_swap (GCallback callback_func, - gpointer user_data, - GClosureNotify destroy_data); -GLIB_AVAILABLE_IN_ALL -GClosure* g_signal_type_cclosure_new (GType itype, - guint struct_offset); - - -/* --- prototypes --- */ -GLIB_AVAILABLE_IN_ALL -GClosure* g_closure_ref (GClosure *closure); -GLIB_AVAILABLE_IN_ALL -void g_closure_sink (GClosure *closure); -GLIB_AVAILABLE_IN_ALL -void g_closure_unref (GClosure *closure); -/* intimidating */ -GLIB_AVAILABLE_IN_ALL -GClosure* g_closure_new_simple (guint sizeof_closure, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_closure_add_finalize_notifier (GClosure *closure, - gpointer notify_data, - GClosureNotify notify_func); -GLIB_AVAILABLE_IN_ALL -void g_closure_remove_finalize_notifier (GClosure *closure, - gpointer notify_data, - GClosureNotify notify_func); -GLIB_AVAILABLE_IN_ALL -void g_closure_add_invalidate_notifier (GClosure *closure, - gpointer notify_data, - GClosureNotify notify_func); -GLIB_AVAILABLE_IN_ALL -void g_closure_remove_invalidate_notifier (GClosure *closure, - gpointer notify_data, - GClosureNotify notify_func); -GLIB_AVAILABLE_IN_ALL -void g_closure_add_marshal_guards (GClosure *closure, - gpointer pre_marshal_data, - GClosureNotify pre_marshal_notify, - gpointer post_marshal_data, - GClosureNotify post_marshal_notify); -GLIB_AVAILABLE_IN_ALL -void g_closure_set_marshal (GClosure *closure, - GClosureMarshal marshal); -GLIB_AVAILABLE_IN_ALL -void g_closure_set_meta_marshal (GClosure *closure, - gpointer marshal_data, - GClosureMarshal meta_marshal); -GLIB_AVAILABLE_IN_ALL -void g_closure_invalidate (GClosure *closure); -GLIB_AVAILABLE_IN_ALL -void g_closure_invoke (GClosure *closure, - GValue /*out*/ *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint); - -/* FIXME: - OK: data_object::destroy -> closure_invalidate(); - MIS: closure_invalidate() -> disconnect(closure); - MIS: disconnect(closure) -> (unlink) closure_unref(); - OK: closure_finalize() -> g_free (data_string); - - random remarks: - - need marshaller repo with decent aliasing to base types - - provide marshaller collection, virtually covering anything out there -*/ - -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_generic (GClosure *closure, - GValue *return_gvalue, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_generic_va (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args_list, - gpointer marshal_data, - int n_params, - GType *param_types); - - -G_END_DECLS - -#endif /* __G_CLOSURE_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 2000-2001 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __G_SIGNAL_H__ -#define __G_SIGNAL_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - -/* GObject - GLib Type, Object, Parameter and Signal Library - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ - -#ifndef __G_MARSHAL_H__ -#define __G_MARSHAL_H__ - -G_BEGIN_DECLS - -/* VOID:VOID */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__VOID (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__VOIDv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:BOOLEAN */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__BOOLEAN (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__BOOLEANv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:CHAR */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__CHAR (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__CHARv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:UCHAR */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__UCHAR (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__UCHARv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:INT */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__INT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__INTv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:UINT */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__UINT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__UINTv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:LONG */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__LONG (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__LONGv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:ULONG */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__ULONG (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__ULONGv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:ENUM */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__ENUM (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__ENUMv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:FLAGS */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__FLAGS (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__FLAGSv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:FLOAT */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__FLOAT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__FLOATv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:DOUBLE */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__DOUBLE (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__DOUBLEv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:STRING */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__STRING (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__STRINGv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:PARAM */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__PARAM (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__PARAMv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:BOXED */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__BOXED (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__BOXEDv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:POINTER */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__POINTERv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:OBJECT */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__OBJECT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__OBJECTv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:VARIANT */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__VARIANT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__VARIANTv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* VOID:UINT,POINTER */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__UINT_POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_VOID__UINT_POINTERv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* BOOL:FLAGS */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_BOOLEAN__FLAGS (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_BOOLEAN__FLAGSv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/** - * g_cclosure_marshal_BOOL__FLAGS: - * @closure: A #GClosure. - * @return_value: A #GValue to store the return value. May be %NULL - * if the callback of closure doesn't return a value. - * @n_param_values: The length of the @param_values array. - * @param_values: An array of #GValues holding the arguments - * on which to invoke the callback of closure. - * @invocation_hint: The invocation hint given as the last argument to - * g_closure_invoke(). - * @marshal_data: Additional data specified when registering the - * marshaller, see g_closure_set_marshal() and - * g_closure_set_meta_marshal() - * - * An old alias for g_cclosure_marshal_BOOLEAN__FLAGS(). - */ -#define g_cclosure_marshal_BOOL__FLAGS g_cclosure_marshal_BOOLEAN__FLAGS - -/* STRING:OBJECT,POINTER */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_STRING__OBJECT_POINTER (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_STRING__OBJECT_POINTERv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/* BOOL:BOXED,BOXED */ -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_BOOLEAN__BOXED_BOXED (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -GLIB_AVAILABLE_IN_ALL -void g_cclosure_marshal_BOOLEAN__BOXED_BOXEDv (GClosure *closure, - GValue *return_value, - gpointer instance, - va_list args, - gpointer marshal_data, - int n_params, - GType *param_types); - -/** - * g_cclosure_marshal_BOOL__BOXED_BOXED: - * @closure: A #GClosure. - * @return_value: A #GValue to store the return value. May be %NULL - * if the callback of closure doesn't return a value. - * @n_param_values: The length of the @param_values array. - * @param_values: An array of #GValues holding the arguments - * on which to invoke the callback of closure. - * @invocation_hint: The invocation hint given as the last argument to - * g_closure_invoke(). - * @marshal_data: Additional data specified when registering the - * marshaller, see g_closure_set_marshal() and - * g_closure_set_meta_marshal() - * - * An old alias for g_cclosure_marshal_BOOLEAN__BOXED_BOXED(). - */ -#define g_cclosure_marshal_BOOL__BOXED_BOXED g_cclosure_marshal_BOOLEAN__BOXED_BOXED - -G_END_DECLS - -#endif /* __G_MARSHAL_H__ */ - -G_BEGIN_DECLS - -/* --- typedefs --- */ -typedef struct _GSignalQuery GSignalQuery; -typedef struct _GSignalInvocationHint GSignalInvocationHint; -/** - * GSignalCMarshaller: - * - * This is the signature of marshaller functions, required to marshall - * arrays of parameter values to signal emissions into C language callback - * invocations. It is merely an alias to #GClosureMarshal since the #GClosure - * mechanism takes over responsibility of actual function invocation for the - * signal system. - */ -typedef GClosureMarshal GSignalCMarshaller; -/** - * GSignalCVaMarshaller: - * - * This is the signature of va_list marshaller functions, an optional - * marshaller that can be used in some situations to avoid - * marshalling the signal argument into GValues. - */ -typedef GVaClosureMarshal GSignalCVaMarshaller; -/** - * GSignalEmissionHook: - * @ihint: Signal invocation hint, see #GSignalInvocationHint. - * @n_param_values: the number of parameters to the function, including - * the instance on which the signal was emitted. - * @param_values: (array length=n_param_values): the instance on which - * the signal was emitted, followed by the parameters of the emission. - * @data: user data associated with the hook. - * - * A simple function pointer to get invoked when the signal is emitted. This - * allows you to tie a hook to the signal type, so that it will trap all - * emissions of that signal, from any object. - * - * You may not attach these to signals created with the #G_SIGNAL_NO_HOOKS flag. - * - * Returns: whether it wants to stay connected. If it returns %FALSE, the signal - * hook is disconnected (and destroyed). - */ -typedef gboolean (*GSignalEmissionHook) (GSignalInvocationHint *ihint, - guint n_param_values, - const GValue *param_values, - gpointer data); -/** - * GSignalAccumulator: - * @ihint: Signal invocation hint, see #GSignalInvocationHint. - * @return_accu: Accumulator to collect callback return values in, this - * is the return value of the current signal emission. - * @handler_return: A #GValue holding the return value of the signal handler. - * @data: Callback data that was specified when creating the signal. - * - * The signal accumulator is a special callback function that can be used - * to collect return values of the various callbacks that are called - * during a signal emission. The signal accumulator is specified at signal - * creation time, if it is left %NULL, no accumulation of callback return - * values is performed. The return value of signal emissions is then the - * value returned by the last callback. - * - * Returns: The accumulator function returns whether the signal emission - * should be aborted. Returning %FALSE means to abort the - * current emission and %TRUE is returned for continuation. - */ -typedef gboolean (*GSignalAccumulator) (GSignalInvocationHint *ihint, - GValue *return_accu, - const GValue *handler_return, - gpointer data); - - -/* --- run, match and connect types --- */ -/** - * GSignalFlags: - * @G_SIGNAL_RUN_FIRST: Invoke the object method handler in the first emission stage. - * @G_SIGNAL_RUN_LAST: Invoke the object method handler in the third emission stage. - * @G_SIGNAL_RUN_CLEANUP: Invoke the object method handler in the last emission stage. - * @G_SIGNAL_NO_RECURSE: Signals being emitted for an object while currently being in - * emission for this very object will not be emitted recursively, - * but instead cause the first emission to be restarted. - * @G_SIGNAL_DETAILED: This signal supports "::detail" appendices to the signal name - * upon handler connections and emissions. - * @G_SIGNAL_ACTION: Action signals are signals that may freely be emitted on alive - * objects from user code via g_signal_emit() and friends, without - * the need of being embedded into extra code that performs pre or - * post emission adjustments on the object. They can also be thought - * of as object methods which can be called generically by - * third-party code. - * @G_SIGNAL_NO_HOOKS: No emissions hooks are supported for this signal. - * @G_SIGNAL_MUST_COLLECT: Varargs signal emission will always collect the - * arguments, even if there are no signal handlers connected. Since 2.30. - * @G_SIGNAL_DEPRECATED: The signal is deprecated and will be removed - * in a future version. A warning will be generated if it is connected while - * running with G_ENABLE_DIAGNOSTIC=1. Since 2.32. - * @G_SIGNAL_ACCUMULATOR_FIRST_RUN: Only used in #GSignalAccumulator accumulator - * functions for the #GSignalInvocationHint::run_type field to mark the first - * call to the accumulator function for a signal emission. Since 2.68. - * - * The signal flags are used to specify a signal's behaviour, the overall - * signal description outlines how especially the RUN flags control the - * stages of a signal emission. - */ -typedef enum -{ - G_SIGNAL_RUN_FIRST = 1 << 0, - G_SIGNAL_RUN_LAST = 1 << 1, - G_SIGNAL_RUN_CLEANUP = 1 << 2, - G_SIGNAL_NO_RECURSE = 1 << 3, - G_SIGNAL_DETAILED = 1 << 4, - G_SIGNAL_ACTION = 1 << 5, - G_SIGNAL_NO_HOOKS = 1 << 6, - G_SIGNAL_MUST_COLLECT = 1 << 7, - G_SIGNAL_DEPRECATED = 1 << 8, - /* normal signal flags until 1 << 16 */ - G_SIGNAL_ACCUMULATOR_FIRST_RUN = 1 << 17, -} GSignalFlags; -/** - * G_SIGNAL_FLAGS_MASK: - * - * A mask for all #GSignalFlags bits. - */ -#define G_SIGNAL_FLAGS_MASK 0x1ff -/** - * GConnectFlags: - * @G_CONNECT_AFTER: whether the handler should be called before or after the - * default handler of the signal. - * @G_CONNECT_SWAPPED: whether the instance and data should be swapped when - * calling the handler; see g_signal_connect_swapped() for an example. - * - * The connection flags are used to specify the behaviour of a signal's - * connection. - */ -typedef enum -{ - G_CONNECT_AFTER = 1 << 0, - G_CONNECT_SWAPPED = 1 << 1 -} GConnectFlags; -/** - * GSignalMatchType: - * @G_SIGNAL_MATCH_ID: The signal id must be equal. - * @G_SIGNAL_MATCH_DETAIL: The signal detail must be equal. - * @G_SIGNAL_MATCH_CLOSURE: The closure must be the same. - * @G_SIGNAL_MATCH_FUNC: The C closure callback must be the same. - * @G_SIGNAL_MATCH_DATA: The closure data must be the same. - * @G_SIGNAL_MATCH_UNBLOCKED: Only unblocked signals may be matched. - * - * The match types specify what g_signal_handlers_block_matched(), - * g_signal_handlers_unblock_matched() and g_signal_handlers_disconnect_matched() - * match signals by. - */ -typedef enum -{ - G_SIGNAL_MATCH_ID = 1 << 0, - G_SIGNAL_MATCH_DETAIL = 1 << 1, - G_SIGNAL_MATCH_CLOSURE = 1 << 2, - G_SIGNAL_MATCH_FUNC = 1 << 3, - G_SIGNAL_MATCH_DATA = 1 << 4, - G_SIGNAL_MATCH_UNBLOCKED = 1 << 5 -} GSignalMatchType; -/** - * G_SIGNAL_MATCH_MASK: - * - * A mask for all #GSignalMatchType bits. - */ -#define G_SIGNAL_MATCH_MASK 0x3f -/** - * G_SIGNAL_TYPE_STATIC_SCOPE: - * - * This macro flags signal argument types for which the signal system may - * assume that instances thereof remain persistent across all signal emissions - * they are used in. This is only useful for non ref-counted, value-copy types. - * - * To flag a signal argument in this way, add `| G_SIGNAL_TYPE_STATIC_SCOPE` - * to the corresponding argument of g_signal_new(). - * |[ - * g_signal_new ("size_request", - * G_TYPE_FROM_CLASS (gobject_class), - * G_SIGNAL_RUN_FIRST, - * G_STRUCT_OFFSET (GtkWidgetClass, size_request), - * NULL, NULL, - * _gtk_marshal_VOID__BOXED, - * G_TYPE_NONE, 1, - * GTK_TYPE_REQUISITION | G_SIGNAL_TYPE_STATIC_SCOPE); - * ]| - */ -#define G_SIGNAL_TYPE_STATIC_SCOPE (G_TYPE_FLAG_RESERVED_ID_BIT) - - -/* --- signal information --- */ -/** - * GSignalInvocationHint: - * @signal_id: The signal id of the signal invoking the callback - * @detail: The detail passed on for this emission - * @run_type: The stage the signal emission is currently in, this - * field will contain one of %G_SIGNAL_RUN_FIRST, - * %G_SIGNAL_RUN_LAST or %G_SIGNAL_RUN_CLEANUP and %G_SIGNAL_ACCUMULATOR_FIRST_RUN. - * %G_SIGNAL_ACCUMULATOR_FIRST_RUN is only set for the first run of the accumulator - * function for a signal emission. - * - * The #GSignalInvocationHint structure is used to pass on additional information - * to callbacks during a signal emission. - */ -struct _GSignalInvocationHint -{ - guint signal_id; - GQuark detail; - GSignalFlags run_type; -}; -/** - * GSignalQuery: - * @signal_id: The signal id of the signal being queried, or 0 if the - * signal to be queried was unknown. - * @signal_name: The signal name. - * @itype: The interface/instance type that this signal can be emitted for. - * @signal_flags: The signal flags as passed in to g_signal_new(). - * @return_type: The return type for user callbacks. - * @n_params: The number of parameters that user callbacks take. - * @param_types: (array length=n_params): The individual parameter types for - * user callbacks, note that the effective callback signature is: - * |[ - * @return_type callback (#gpointer data1, - * [param_types param_names,] - * gpointer data2); - * ]| - * - * A structure holding in-depth information for a specific signal. It is - * filled in by the g_signal_query() function. - */ -struct _GSignalQuery -{ - guint signal_id; - const gchar *signal_name; - GType itype; - GSignalFlags signal_flags; - GType return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ - guint n_params; - const GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ -}; - - -/* --- signals --- */ -GLIB_AVAILABLE_IN_ALL -guint g_signal_newv (const gchar *signal_name, - GType itype, - GSignalFlags signal_flags, - GClosure *class_closure, - GSignalAccumulator accumulator, - gpointer accu_data, - GSignalCMarshaller c_marshaller, - GType return_type, - guint n_params, - GType *param_types); -GLIB_AVAILABLE_IN_ALL -guint g_signal_new_valist (const gchar *signal_name, - GType itype, - GSignalFlags signal_flags, - GClosure *class_closure, - GSignalAccumulator accumulator, - gpointer accu_data, - GSignalCMarshaller c_marshaller, - GType return_type, - guint n_params, - va_list args); -GLIB_AVAILABLE_IN_ALL -guint g_signal_new (const gchar *signal_name, - GType itype, - GSignalFlags signal_flags, - guint class_offset, - GSignalAccumulator accumulator, - gpointer accu_data, - GSignalCMarshaller c_marshaller, - GType return_type, - guint n_params, - ...); -GLIB_AVAILABLE_IN_ALL -guint g_signal_new_class_handler (const gchar *signal_name, - GType itype, - GSignalFlags signal_flags, - GCallback class_handler, - GSignalAccumulator accumulator, - gpointer accu_data, - GSignalCMarshaller c_marshaller, - GType return_type, - guint n_params, - ...); -GLIB_AVAILABLE_IN_ALL -void g_signal_set_va_marshaller (guint signal_id, - GType instance_type, - GSignalCVaMarshaller va_marshaller); - -GLIB_AVAILABLE_IN_ALL -void g_signal_emitv (const GValue *instance_and_params, - guint signal_id, - GQuark detail, - GValue *return_value); -GLIB_AVAILABLE_IN_ALL -void g_signal_emit_valist (gpointer instance, - guint signal_id, - GQuark detail, - va_list var_args); -GLIB_AVAILABLE_IN_ALL -void g_signal_emit (gpointer instance, - guint signal_id, - GQuark detail, - ...); -GLIB_AVAILABLE_IN_ALL -void g_signal_emit_by_name (gpointer instance, - const gchar *detailed_signal, - ...); -GLIB_AVAILABLE_IN_ALL -guint g_signal_lookup (const gchar *name, - GType itype); -GLIB_AVAILABLE_IN_ALL -const gchar * g_signal_name (guint signal_id); -GLIB_AVAILABLE_IN_ALL -void g_signal_query (guint signal_id, - GSignalQuery *query); -GLIB_AVAILABLE_IN_ALL -guint* g_signal_list_ids (GType itype, - guint *n_ids); -GLIB_AVAILABLE_IN_2_66 -gboolean g_signal_is_valid_name (const gchar *name); -GLIB_AVAILABLE_IN_ALL -gboolean g_signal_parse_name (const gchar *detailed_signal, - GType itype, - guint *signal_id_p, - GQuark *detail_p, - gboolean force_detail_quark); -GLIB_AVAILABLE_IN_ALL -GSignalInvocationHint* g_signal_get_invocation_hint (gpointer instance); - - -/* --- signal emissions --- */ -GLIB_AVAILABLE_IN_ALL -void g_signal_stop_emission (gpointer instance, - guint signal_id, - GQuark detail); -GLIB_AVAILABLE_IN_ALL -void g_signal_stop_emission_by_name (gpointer instance, - const gchar *detailed_signal); -GLIB_AVAILABLE_IN_ALL -gulong g_signal_add_emission_hook (guint signal_id, - GQuark detail, - GSignalEmissionHook hook_func, - gpointer hook_data, - GDestroyNotify data_destroy); -GLIB_AVAILABLE_IN_ALL -void g_signal_remove_emission_hook (guint signal_id, - gulong hook_id); - - -/* --- signal handlers --- */ -GLIB_AVAILABLE_IN_ALL -gboolean g_signal_has_handler_pending (gpointer instance, - guint signal_id, - GQuark detail, - gboolean may_be_blocked); -GLIB_AVAILABLE_IN_ALL -gulong g_signal_connect_closure_by_id (gpointer instance, - guint signal_id, - GQuark detail, - GClosure *closure, - gboolean after); -GLIB_AVAILABLE_IN_ALL -gulong g_signal_connect_closure (gpointer instance, - const gchar *detailed_signal, - GClosure *closure, - gboolean after); -GLIB_AVAILABLE_IN_ALL -gulong g_signal_connect_data (gpointer instance, - const gchar *detailed_signal, - GCallback c_handler, - gpointer data, - GClosureNotify destroy_data, - GConnectFlags connect_flags); -GLIB_AVAILABLE_IN_ALL -void g_signal_handler_block (gpointer instance, - gulong handler_id); -GLIB_AVAILABLE_IN_ALL -void g_signal_handler_unblock (gpointer instance, - gulong handler_id); -GLIB_AVAILABLE_IN_ALL -void g_signal_handler_disconnect (gpointer instance, - gulong handler_id); -GLIB_AVAILABLE_IN_ALL -gboolean g_signal_handler_is_connected (gpointer instance, - gulong handler_id); -GLIB_AVAILABLE_IN_ALL -gulong g_signal_handler_find (gpointer instance, - GSignalMatchType mask, - guint signal_id, - GQuark detail, - GClosure *closure, - gpointer func, - gpointer data); -GLIB_AVAILABLE_IN_ALL -guint g_signal_handlers_block_matched (gpointer instance, - GSignalMatchType mask, - guint signal_id, - GQuark detail, - GClosure *closure, - gpointer func, - gpointer data); -GLIB_AVAILABLE_IN_ALL -guint g_signal_handlers_unblock_matched (gpointer instance, - GSignalMatchType mask, - guint signal_id, - GQuark detail, - GClosure *closure, - gpointer func, - gpointer data); -GLIB_AVAILABLE_IN_ALL -guint g_signal_handlers_disconnect_matched (gpointer instance, - GSignalMatchType mask, - guint signal_id, - GQuark detail, - GClosure *closure, - gpointer func, - gpointer data); - -GLIB_AVAILABLE_IN_2_62 -void g_clear_signal_handler (gulong *handler_id_ptr, - gpointer instance); - -#undef g_clear_signal_handler -#define g_clear_signal_handler(handler_id_ptr, instance) \ - G_STMT_START { \ - G_STATIC_ASSERT (sizeof *(handler_id_ptr) == sizeof (gulong)); \ - gulong _handler_id = *(handler_id_ptr); \ - \ - if (_handler_id > 0) \ - { \ - g_signal_handler_disconnect ((instance), _handler_id); \ - *(handler_id_ptr) = 0; \ - } \ - } G_STMT_END \ - GLIB_AVAILABLE_MACRO_IN_2_62 - -/* --- overriding and chaining --- */ -GLIB_AVAILABLE_IN_ALL -void g_signal_override_class_closure (guint signal_id, - GType instance_type, - GClosure *class_closure); -GLIB_AVAILABLE_IN_ALL -void g_signal_override_class_handler (const gchar *signal_name, - GType instance_type, - GCallback class_handler); -GLIB_AVAILABLE_IN_ALL -void g_signal_chain_from_overridden (const GValue *instance_and_params, - GValue *return_value); -GLIB_AVAILABLE_IN_ALL -void g_signal_chain_from_overridden_handler (gpointer instance, - ...); - - -/* --- convenience --- */ -/** - * g_signal_connect: - * @instance: the instance to connect to. - * @detailed_signal: a string of the form "signal-name::detail". - * @c_handler: the #GCallback to connect. - * @data: data to pass to @c_handler calls. - * - * Connects a #GCallback function to a signal for a particular object. - * - * The handler will be called before the default handler of the signal. - * - * See [memory management of signal handlers][signal-memory-management] for - * details on how to handle the return value and memory management of @data. - * - * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) - */ -#define g_signal_connect(instance, detailed_signal, c_handler, data) \ - g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (GConnectFlags) 0) -/** - * g_signal_connect_after: - * @instance: the instance to connect to. - * @detailed_signal: a string of the form "signal-name::detail". - * @c_handler: the #GCallback to connect. - * @data: data to pass to @c_handler calls. - * - * Connects a #GCallback function to a signal for a particular object. - * - * The handler will be called after the default handler of the signal. - * - * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) - */ -#define g_signal_connect_after(instance, detailed_signal, c_handler, data) \ - g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_AFTER) -/** - * g_signal_connect_swapped: - * @instance: the instance to connect to. - * @detailed_signal: a string of the form "signal-name::detail". - * @c_handler: the #GCallback to connect. - * @data: data to pass to @c_handler calls. - * - * Connects a #GCallback function to a signal for a particular object. - * - * The instance on which the signal is emitted and @data will be swapped when - * calling the handler. This is useful when calling pre-existing functions to - * operate purely on the @data, rather than the @instance: swapping the - * parameters avoids the need to write a wrapper function. - * - * For example, this allows the shorter code: - * |[ - * g_signal_connect_swapped (button, "clicked", - * (GCallback) gtk_widget_hide, other_widget); - * ]| - * - * Rather than the cumbersome: - * |[ - * static void - * button_clicked_cb (GtkButton *button, GtkWidget *other_widget) - * { - * gtk_widget_hide (other_widget); - * } - * - * ... - * - * g_signal_connect (button, "clicked", - * (GCallback) button_clicked_cb, other_widget); - * ]| - * - * Returns: the handler ID, of type #gulong (always greater than 0 for successful connections) - */ -#define g_signal_connect_swapped(instance, detailed_signal, c_handler, data) \ - g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, G_CONNECT_SWAPPED) -/** - * g_signal_handlers_disconnect_by_func: - * @instance: The instance to remove handlers from. - * @func: The C closure callback of the handlers (useless for non-C closures). - * @data: The closure data of the handlers' closures. - * - * Disconnects all handlers on an instance that match @func and @data. - * - * Returns: The number of handlers that matched. - */ -#define g_signal_handlers_disconnect_by_func(instance, func, data) \ - g_signal_handlers_disconnect_matched ((instance), \ - (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ - 0, 0, NULL, (func), (data)) - -/** - * g_signal_handlers_disconnect_by_data: - * @instance: The instance to remove handlers from - * @data: the closure data of the handlers' closures - * - * Disconnects all handlers on an instance that match @data. - * - * Returns: The number of handlers that matched. - * - * Since: 2.32 - */ -#define g_signal_handlers_disconnect_by_data(instance, data) \ - g_signal_handlers_disconnect_matched ((instance), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, (data)) - -/** - * g_signal_handlers_block_by_func: - * @instance: The instance to block handlers from. - * @func: The C closure callback of the handlers (useless for non-C closures). - * @data: The closure data of the handlers' closures. - * - * Blocks all handlers on an instance that match @func and @data. - * - * Returns: The number of handlers that matched. - */ -#define g_signal_handlers_block_by_func(instance, func, data) \ - g_signal_handlers_block_matched ((instance), \ - (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ - 0, 0, NULL, (func), (data)) -/** - * g_signal_handlers_unblock_by_func: - * @instance: The instance to unblock handlers from. - * @func: The C closure callback of the handlers (useless for non-C closures). - * @data: The closure data of the handlers' closures. - * - * Unblocks all handlers on an instance that match @func and @data. - * - * Returns: The number of handlers that matched. - */ -#define g_signal_handlers_unblock_by_func(instance, func, data) \ - g_signal_handlers_unblock_matched ((instance), \ - (GSignalMatchType) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), \ - 0, 0, NULL, (func), (data)) - - -GLIB_AVAILABLE_IN_ALL -gboolean g_signal_accumulator_true_handled (GSignalInvocationHint *ihint, - GValue *return_accu, - const GValue *handler_return, - gpointer dummy); - -GLIB_AVAILABLE_IN_ALL -gboolean g_signal_accumulator_first_wins (GSignalInvocationHint *ihint, - GValue *return_accu, - const GValue *handler_return, - gpointer dummy); - -/*< private >*/ -GLIB_AVAILABLE_IN_ALL -void g_signal_handlers_destroy (gpointer instance); -void _g_signals_destroy (GType itype); - -G_END_DECLS - -#endif /* __G_SIGNAL_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 2000-2001 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __G_BOXED_H__ -#define __G_BOXED_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -#ifndef __GI_SCANNER__ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 2000-2001 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __GLIB_TYPES_H__ -#define __GLIB_TYPES_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) && !defined(GLIB_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* A hack necesssary to preprocess this file with g-ir-scanner */ -#ifdef __GI_SCANNER__ -typedef gsize GType; -#endif - -/* --- GLib boxed types --- */ -/** - * G_TYPE_DATE: - * - * The #GType for #GDate. - */ -#define G_TYPE_DATE (g_date_get_type ()) - -/** - * G_TYPE_STRV: - * - * The #GType for a boxed type holding a %NULL-terminated array of strings. - * - * The code fragments in the following example show the use of a property of - * type #G_TYPE_STRV with g_object_class_install_property(), g_object_set() - * and g_object_get(). - * - * |[ - * g_object_class_install_property (object_class, - * PROP_AUTHORS, - * g_param_spec_boxed ("authors", - * _("Authors"), - * _("List of authors"), - * G_TYPE_STRV, - * G_PARAM_READWRITE)); - * - * gchar *authors[] = { "Owen", "Tim", NULL }; - * g_object_set (obj, "authors", authors, NULL); - * - * gchar *writers[]; - * g_object_get (obj, "authors", &writers, NULL); - * /* do something with writers */ - * g_strfreev (writers); - * ]| - * - * Since: 2.4 - */ -#define G_TYPE_STRV (g_strv_get_type ()) - -/** - * G_TYPE_GSTRING: - * - * The #GType for #GString. - */ -#define G_TYPE_GSTRING (g_gstring_get_type ()) - -/** - * G_TYPE_HASH_TABLE: - * - * The #GType for a boxed type holding a #GHashTable reference. - * - * Since: 2.10 - */ -#define G_TYPE_HASH_TABLE (g_hash_table_get_type ()) - -/** - * G_TYPE_REGEX: - * - * The #GType for a boxed type holding a #GRegex reference. - * - * Since: 2.14 - */ -#define G_TYPE_REGEX (g_regex_get_type ()) - -/** - * G_TYPE_MATCH_INFO: - * - * The #GType for a boxed type holding a #GMatchInfo reference. - * - * Since: 2.30 - */ -#define G_TYPE_MATCH_INFO (g_match_info_get_type ()) - -/** - * G_TYPE_ARRAY: - * - * The #GType for a boxed type holding a #GArray reference. - * - * Since: 2.22 - */ -#define G_TYPE_ARRAY (g_array_get_type ()) - -/** - * G_TYPE_BYTE_ARRAY: - * - * The #GType for a boxed type holding a #GByteArray reference. - * - * Since: 2.22 - */ -#define G_TYPE_BYTE_ARRAY (g_byte_array_get_type ()) - -/** - * G_TYPE_PTR_ARRAY: - * - * The #GType for a boxed type holding a #GPtrArray reference. - * - * Since: 2.22 - */ -#define G_TYPE_PTR_ARRAY (g_ptr_array_get_type ()) - -/** - * G_TYPE_BYTES: - * - * The #GType for #GBytes. - * - * Since: 2.32 - */ -#define G_TYPE_BYTES (g_bytes_get_type ()) - -/** - * G_TYPE_VARIANT_TYPE: - * - * The #GType for a boxed type holding a #GVariantType. - * - * Since: 2.24 - */ -#define G_TYPE_VARIANT_TYPE (g_variant_type_get_gtype ()) - -/** - * G_TYPE_ERROR: - * - * The #GType for a boxed type holding a #GError. - * - * Since: 2.26 - */ -#define G_TYPE_ERROR (g_error_get_type ()) - -/** - * G_TYPE_DATE_TIME: - * - * The #GType for a boxed type holding a #GDateTime. - * - * Since: 2.26 - */ -#define G_TYPE_DATE_TIME (g_date_time_get_type ()) - -/** - * G_TYPE_TIME_ZONE: - * - * The #GType for a boxed type holding a #GTimeZone. - * - * Since: 2.34 - */ -#define G_TYPE_TIME_ZONE (g_time_zone_get_type ()) - -/** - * G_TYPE_IO_CHANNEL: - * - * The #GType for #GIOChannel. - */ -#define G_TYPE_IO_CHANNEL (g_io_channel_get_type ()) - -/** - * G_TYPE_IO_CONDITION: - * - * The #GType for #GIOCondition. - */ -#define G_TYPE_IO_CONDITION (g_io_condition_get_type ()) - -/** - * G_TYPE_VARIANT_BUILDER: - * - * The #GType for a boxed type holding a #GVariantBuilder. - * - * Since: 2.30 - */ -#define G_TYPE_VARIANT_BUILDER (g_variant_builder_get_type ()) - -/** - * G_TYPE_VARIANT_DICT: - * - * The #GType for a boxed type holding a #GVariantDict. - * - * Since: 2.40 - */ -#define G_TYPE_VARIANT_DICT (g_variant_dict_get_type ()) - -/** - * G_TYPE_MAIN_LOOP: - * - * The #GType for a boxed type holding a #GMainLoop. - * - * Since: 2.30 - */ -#define G_TYPE_MAIN_LOOP (g_main_loop_get_type ()) - -/** - * G_TYPE_MAIN_CONTEXT: - * - * The #GType for a boxed type holding a #GMainContext. - * - * Since: 2.30 - */ -#define G_TYPE_MAIN_CONTEXT (g_main_context_get_type ()) - -/** - * G_TYPE_SOURCE: - * - * The #GType for a boxed type holding a #GSource. - * - * Since: 2.30 - */ -#define G_TYPE_SOURCE (g_source_get_type ()) - -/** - * G_TYPE_POLLFD: - * - * The #GType for a boxed type holding a #GPollFD. - * - * Since: 2.36 - */ -#define G_TYPE_POLLFD (g_pollfd_get_type ()) - -/** - * G_TYPE_MARKUP_PARSE_CONTEXT: - * - * The #GType for a boxed type holding a #GMarkupParseContext. - * - * Since: 2.36 - */ -#define G_TYPE_MARKUP_PARSE_CONTEXT (g_markup_parse_context_get_type ()) - -/** - * G_TYPE_KEY_FILE: - * - * The #GType for a boxed type holding a #GKeyFile. - * - * Since: 2.32 - */ -#define G_TYPE_KEY_FILE (g_key_file_get_type ()) - -/** - * G_TYPE_MAPPED_FILE: - * - * The #GType for a boxed type holding a #GMappedFile. - * - * Since: 2.40 - */ -#define G_TYPE_MAPPED_FILE (g_mapped_file_get_type ()) - -/** - * G_TYPE_THREAD: - * - * The #GType for a boxed type holding a #GThread. - * - * Since: 2.36 - */ -#define G_TYPE_THREAD (g_thread_get_type ()) - -/** - * G_TYPE_CHECKSUM: - * - * The #GType for a boxed type holding a #GChecksum. - * - * Since: 2.36 - */ -#define G_TYPE_CHECKSUM (g_checksum_get_type ()) - -/** - * G_TYPE_OPTION_GROUP: - * - * The #GType for a boxed type holding a #GOptionGroup. - * - * Since: 2.44 - */ -#define G_TYPE_OPTION_GROUP (g_option_group_get_type ()) - -/** - * G_TYPE_URI: - * - * The #GType for a boxed type holding a #GUri. - * - * Since: 2.66 - */ -#define G_TYPE_URI (g_uri_get_type ()) - -/** - * G_TYPE_TREE: - * - * The #GType for #GTree. - * - * Since: 2.68 - */ -#define G_TYPE_TREE (g_tree_get_type ()) - -GLIB_AVAILABLE_IN_ALL -GType g_date_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_strv_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_gstring_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_hash_table_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_array_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_byte_array_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_ptr_array_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_bytes_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_variant_type_get_gtype (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_regex_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_30 -GType g_match_info_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_error_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_date_time_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_time_zone_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_io_channel_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_io_condition_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_variant_builder_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_40 -GType g_variant_dict_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_key_file_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_30 -GType g_main_loop_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_30 -GType g_main_context_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_30 -GType g_source_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_36 -GType g_pollfd_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_36 -GType g_thread_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_36 -GType g_checksum_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_36 -GType g_markup_parse_context_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_40 -GType g_mapped_file_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_44 -GType g_option_group_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_66 -GType g_uri_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_2_68 -GType g_tree_get_type (void) G_GNUC_CONST; - -GLIB_DEPRECATED_FOR('G_TYPE_VARIANT') -GType g_variant_get_gtype (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __GLIB_TYPES_H__ */ -#endif - -G_BEGIN_DECLS - -/* --- type macros --- */ -#define G_TYPE_IS_BOXED(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_BOXED) -/** - * G_VALUE_HOLDS_BOXED: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values derived - * from type %G_TYPE_BOXED. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_BOXED(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOXED)) - - -/* --- typedefs --- */ -/** - * GBoxedCopyFunc: - * @boxed: (not nullable): The boxed structure to be copied. - * - * This function is provided by the user and should produce a copy - * of the passed in boxed structure. - * - * Returns: (not nullable): The newly created copy of the boxed structure. - */ -typedef gpointer (*GBoxedCopyFunc) (gpointer boxed); - -/** - * GBoxedFreeFunc: - * @boxed: (not nullable): The boxed structure to be freed. - * - * This function is provided by the user and should free the boxed - * structure passed. - */ -typedef void (*GBoxedFreeFunc) (gpointer boxed); - - -/* --- prototypes --- */ -GLIB_AVAILABLE_IN_ALL -gpointer g_boxed_copy (GType boxed_type, - gconstpointer src_boxed); -GLIB_AVAILABLE_IN_ALL -void g_boxed_free (GType boxed_type, - gpointer boxed); -GLIB_AVAILABLE_IN_ALL -void g_value_set_boxed (GValue *value, - gconstpointer v_boxed); -GLIB_AVAILABLE_IN_ALL -void g_value_set_static_boxed (GValue *value, - gconstpointer v_boxed); -GLIB_AVAILABLE_IN_ALL -void g_value_take_boxed (GValue *value, - gconstpointer v_boxed); -GLIB_DEPRECATED_FOR(g_value_take_boxed) -void g_value_set_boxed_take_ownership (GValue *value, - gconstpointer v_boxed); -GLIB_AVAILABLE_IN_ALL -gpointer g_value_get_boxed (const GValue *value); -GLIB_AVAILABLE_IN_ALL -gpointer g_value_dup_boxed (const GValue *value); - - -/* --- convenience --- */ -GLIB_AVAILABLE_IN_ALL -GType g_boxed_type_register_static (const gchar *name, - GBoxedCopyFunc boxed_copy, - GBoxedFreeFunc boxed_free); - -/* --- GObject boxed types --- */ -/** - * G_TYPE_CLOSURE: - * - * The #GType for #GClosure. - */ -#define G_TYPE_CLOSURE (g_closure_get_type ()) - -/** - * G_TYPE_VALUE: - * - * The type ID of the "GValue" type which is a boxed type, - * used to pass around pointers to GValues. - */ -#define G_TYPE_VALUE (g_value_get_type ()) - -GLIB_AVAILABLE_IN_ALL -GType g_closure_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_value_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __G_BOXED_H__ */ - -G_BEGIN_DECLS - -/* --- type macros --- */ -/** - * G_TYPE_IS_OBJECT: - * @type: Type id to check - * - * Check if the passed in type id is a %G_TYPE_OBJECT or derived from it. - * - * Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT. - */ -#define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT) -/** - * G_OBJECT: - * @object: Object which is subject to casting. - * - * Casts a #GObject or derived pointer into a (GObject*) pointer. - * Depending on the current debugging level, this function may invoke - * certain runtime checks to identify invalid casts. - */ -#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject)) -/** - * G_OBJECT_CLASS: - * @class: a valid #GObjectClass - * - * Casts a derived #GObjectClass structure into a #GObjectClass structure. - */ -#define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass)) -/** - * G_IS_OBJECT: - * @object: Instance to check for being a %G_TYPE_OBJECT. - * - * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT. - */ -#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_42 -#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE ((object), G_TYPE_OBJECT)) -#else -#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT)) -#endif -/** - * G_IS_OBJECT_CLASS: - * @class: a #GObjectClass - * - * Checks whether @class "is a" valid #GObjectClass structure of type - * %G_TYPE_OBJECT or derived. - */ -#define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT)) -/** - * G_OBJECT_GET_CLASS: - * @object: a #GObject instance. - * - * Get the class structure associated to a #GObject instance. - * - * Returns: pointer to object class structure. - */ -#define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass)) -/** - * G_OBJECT_TYPE: - * @object: Object to return the type id for. - * - * Get the type id of an object. - * - * Returns: Type id of @object. - */ -#define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object)) -/** - * G_OBJECT_TYPE_NAME: - * @object: Object to return the type name for. - * - * Get the name of an object's type. - * - * Returns: Type name of @object. The string is owned by the type system and - * should not be freed. - */ -#define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object))) -/** - * G_OBJECT_CLASS_TYPE: - * @class: a valid #GObjectClass - * - * Get the type id of a class structure. - * - * Returns: Type id of @class. - */ -#define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) -/** - * G_OBJECT_CLASS_NAME: - * @class: a valid #GObjectClass - * - * Return the name of a class structure's type. - * - * Returns: Type name of @class. The string is owned by the type system and - * should not be freed. - */ -#define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class))) -/** - * G_VALUE_HOLDS_OBJECT: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values derived from type %G_TYPE_OBJECT. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT)) - -/* --- type macros --- */ -/** - * G_TYPE_INITIALLY_UNOWNED: - * - * The type for #GInitiallyUnowned. - */ -#define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type()) -/** - * G_INITIALLY_UNOWNED: - * @object: Object which is subject to casting. - * - * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*) - * pointer. Depending on the current debugging level, this function may invoke - * certain runtime checks to identify invalid casts. - */ -#define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned)) -/** - * G_INITIALLY_UNOWNED_CLASS: - * @class: a valid #GInitiallyUnownedClass - * - * Casts a derived #GInitiallyUnownedClass structure into a - * #GInitiallyUnownedClass structure. - */ -#define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass)) -/** - * G_IS_INITIALLY_UNOWNED: - * @object: Instance to check for being a %G_TYPE_INITIALLY_UNOWNED. - * - * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_INITIALLY_UNOWNED. - */ -#define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED)) -/** - * G_IS_INITIALLY_UNOWNED_CLASS: - * @class: a #GInitiallyUnownedClass - * - * Checks whether @class "is a" valid #GInitiallyUnownedClass structure of type - * %G_TYPE_INITIALLY_UNOWNED or derived. - */ -#define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED)) -/** - * G_INITIALLY_UNOWNED_GET_CLASS: - * @object: a #GInitiallyUnowned instance. - * - * Get the class structure associated to a #GInitiallyUnowned instance. - * - * Returns: pointer to object class structure. - */ -#define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass)) -/* GInitiallyUnowned ia a GObject with initially floating reference count */ - - -/* --- typedefs & structures --- */ -typedef struct _GObject GObject; -typedef struct _GObjectClass GObjectClass; -typedef struct _GObject GInitiallyUnowned; -typedef struct _GObjectClass GInitiallyUnownedClass; -typedef struct _GObjectConstructParam GObjectConstructParam; -/** - * GObjectGetPropertyFunc: - * @object: a #GObject - * @property_id: the numeric id under which the property was registered with - * g_object_class_install_property(). - * @value: a #GValue to return the property value in - * @pspec: the #GParamSpec describing the property - * - * The type of the @get_property function of #GObjectClass. - */ -typedef void (*GObjectGetPropertyFunc) (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -/** - * GObjectSetPropertyFunc: - * @object: a #GObject - * @property_id: the numeric id under which the property was registered with - * g_object_class_install_property(). - * @value: the new value for the property - * @pspec: the #GParamSpec describing the property - * - * The type of the @set_property function of #GObjectClass. - */ -typedef void (*GObjectSetPropertyFunc) (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -/** - * GObjectFinalizeFunc: - * @object: the #GObject being finalized - * - * The type of the @finalize function of #GObjectClass. - */ -typedef void (*GObjectFinalizeFunc) (GObject *object); -/** - * GWeakNotify: - * @data: data that was provided when the weak reference was established - * @where_the_object_was: the object being disposed - * - * A #GWeakNotify function can be added to an object as a callback that gets - * triggered when the object is finalized. Since the object is already being - * disposed when the #GWeakNotify is called, there's not much you could do - * with the object, apart from e.g. using its address as hash-index or the like. - */ -typedef void (*GWeakNotify) (gpointer data, - GObject *where_the_object_was); -/** - * GObject: - * - * All the fields in the GObject structure are private - * to the #GObject implementation and should never be accessed directly. - */ -struct _GObject -{ - GTypeInstance g_type_instance; - - /*< private >*/ - guint ref_count; /* (atomic) */ - GData *qdata; -}; -/** - * GObjectClass: - * @g_type_class: the parent class - * @constructor: the @constructor function is called by g_object_new () to - * complete the object initialization after all the construction properties are - * set. The first thing a @constructor implementation must do is chain up to the - * @constructor of the parent class. Overriding @constructor should be rarely - * needed, e.g. to handle construct properties, or to implement singletons. - * @set_property: the generic setter for all properties of this type. Should be - * overridden for every type with properties. If implementations of - * @set_property don't emit property change notification explicitly, this will - * be done implicitly by the type system. However, if the notify signal is - * emitted explicitly, the type system will not emit it a second time. - * @get_property: the generic getter for all properties of this type. Should be - * overridden for every type with properties. - * @dispose: the @dispose function is supposed to drop all references to other - * objects, but keep the instance otherwise intact, so that client method - * invocations still work. It may be run multiple times (due to reference - * loops). Before returning, @dispose should chain up to the @dispose method - * of the parent class. - * @finalize: instance finalization function, should finish the finalization of - * the instance begun in @dispose and chain up to the @finalize method of the - * parent class. - * @dispatch_properties_changed: emits property change notification for a bunch - * of properties. Overriding @dispatch_properties_changed should be rarely - * needed. - * @notify: the class closure for the notify signal - * @constructed: the @constructed function is called by g_object_new() as the - * final step of the object creation process. At the point of the call, all - * construction properties have been set on the object. The purpose of this - * call is to allow for object initialisation steps that can only be performed - * after construction properties have been set. @constructed implementors - * should chain up to the @constructed call of their parent class to allow it - * to complete its initialisation. - * - * The class structure for the GObject type. - * - * |[ - * // Example of implementing a singleton using a constructor. - * static MySingleton *the_singleton = NULL; - * - * static GObject* - * my_singleton_constructor (GType type, - * guint n_construct_params, - * GObjectConstructParam *construct_params) - * { - * GObject *object; - * - * if (!the_singleton) - * { - * object = G_OBJECT_CLASS (parent_class)->constructor (type, - * n_construct_params, - * construct_params); - * the_singleton = MY_SINGLETON (object); - * } - * else - * object = g_object_ref (G_OBJECT (the_singleton)); - * - * return object; - * } - * ]| - */ -struct _GObjectClass -{ - GTypeClass g_type_class; - - /*< private >*/ - GSList *construct_properties; - - /*< public >*/ - /* seldom overridden */ - GObject* (*constructor) (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties); - /* overridable methods */ - void (*set_property) (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); - void (*get_property) (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); - void (*dispose) (GObject *object); - void (*finalize) (GObject *object); - /* seldom overridden */ - void (*dispatch_properties_changed) (GObject *object, - guint n_pspecs, - GParamSpec **pspecs); - /* signals */ - void (*notify) (GObject *object, - GParamSpec *pspec); - - /* called when done constructing */ - void (*constructed) (GObject *object); - - /*< private >*/ - gsize flags; - - /* padding */ - gpointer pdummy[6]; -}; -/** - * GObjectConstructParam: - * @pspec: the #GParamSpec of the construct parameter - * @value: the value to set the parameter to - * - * The GObjectConstructParam struct is an auxiliary - * structure used to hand #GParamSpec/#GValue pairs to the @constructor of - * a #GObjectClass. - */ -struct _GObjectConstructParam -{ - GParamSpec *pspec; - GValue *value; -}; - -/** - * GInitiallyUnowned: - * - * All the fields in the GInitiallyUnowned structure - * are private to the #GInitiallyUnowned implementation and should never be - * accessed directly. - */ -/** - * GInitiallyUnownedClass: - * - * The class structure for the GInitiallyUnowned type. - */ - - -/* --- prototypes --- */ -GLIB_AVAILABLE_IN_ALL -GType g_initially_unowned_get_type (void); -GLIB_AVAILABLE_IN_ALL -void g_object_class_install_property (GObjectClass *oclass, - guint property_id, - GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_object_class_find_property (GObjectClass *oclass, - const gchar *property_name); -GLIB_AVAILABLE_IN_ALL -GParamSpec**g_object_class_list_properties (GObjectClass *oclass, - guint *n_properties); -GLIB_AVAILABLE_IN_ALL -void g_object_class_override_property (GObjectClass *oclass, - guint property_id, - const gchar *name); -GLIB_AVAILABLE_IN_ALL -void g_object_class_install_properties (GObjectClass *oclass, - guint n_pspecs, - GParamSpec **pspecs); - -GLIB_AVAILABLE_IN_ALL -void g_object_interface_install_property (gpointer g_iface, - GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_object_interface_find_property (gpointer g_iface, - const gchar *property_name); -GLIB_AVAILABLE_IN_ALL -GParamSpec**g_object_interface_list_properties (gpointer g_iface, - guint *n_properties_p); - -GLIB_AVAILABLE_IN_ALL -GType g_object_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gpointer g_object_new (GType object_type, - const gchar *first_property_name, - ...); -GLIB_AVAILABLE_IN_2_54 -GObject* g_object_new_with_properties (GType object_type, - guint n_properties, - const char *names[], - const GValue values[]); - -G_GNUC_BEGIN_IGNORE_DEPRECATIONS - -GLIB_DEPRECATED_IN_2_54_FOR(g_object_new_with_properties) -gpointer g_object_newv (GType object_type, - guint n_parameters, - GParameter *parameters); - -G_GNUC_END_IGNORE_DEPRECATIONS - -GLIB_AVAILABLE_IN_ALL -GObject* g_object_new_valist (GType object_type, - const gchar *first_property_name, - va_list var_args); -GLIB_AVAILABLE_IN_ALL -void g_object_set (gpointer object, - const gchar *first_property_name, - ...) G_GNUC_NULL_TERMINATED; -GLIB_AVAILABLE_IN_ALL -void g_object_get (gpointer object, - const gchar *first_property_name, - ...) G_GNUC_NULL_TERMINATED; -GLIB_AVAILABLE_IN_ALL -gpointer g_object_connect (gpointer object, - const gchar *signal_spec, - ...) G_GNUC_NULL_TERMINATED; -GLIB_AVAILABLE_IN_ALL -void g_object_disconnect (gpointer object, - const gchar *signal_spec, - ...) G_GNUC_NULL_TERMINATED; -GLIB_AVAILABLE_IN_2_54 -void g_object_setv (GObject *object, - guint n_properties, - const gchar *names[], - const GValue values[]); -GLIB_AVAILABLE_IN_ALL -void g_object_set_valist (GObject *object, - const gchar *first_property_name, - va_list var_args); -GLIB_AVAILABLE_IN_2_54 -void g_object_getv (GObject *object, - guint n_properties, - const gchar *names[], - GValue values[]); -GLIB_AVAILABLE_IN_ALL -void g_object_get_valist (GObject *object, - const gchar *first_property_name, - va_list var_args); -GLIB_AVAILABLE_IN_ALL -void g_object_set_property (GObject *object, - const gchar *property_name, - const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_object_get_property (GObject *object, - const gchar *property_name, - GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_object_freeze_notify (GObject *object); -GLIB_AVAILABLE_IN_ALL -void g_object_notify (GObject *object, - const gchar *property_name); -GLIB_AVAILABLE_IN_ALL -void g_object_notify_by_pspec (GObject *object, - GParamSpec *pspec); -GLIB_AVAILABLE_IN_ALL -void g_object_thaw_notify (GObject *object); -GLIB_AVAILABLE_IN_ALL -gboolean g_object_is_floating (gpointer object); -GLIB_AVAILABLE_IN_ALL -gpointer g_object_ref_sink (gpointer object); -GLIB_AVAILABLE_IN_ALL -gpointer g_object_ref (gpointer object); -GLIB_AVAILABLE_IN_ALL -void g_object_unref (gpointer object); -GLIB_AVAILABLE_IN_ALL -void g_object_weak_ref (GObject *object, - GWeakNotify notify, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_object_weak_unref (GObject *object, - GWeakNotify notify, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_object_add_weak_pointer (GObject *object, - gpointer *weak_pointer_location); -GLIB_AVAILABLE_IN_ALL -void g_object_remove_weak_pointer (GObject *object, - gpointer *weak_pointer_location); - -#if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56 -/* Make reference APIs type safe with macros */ -#undef g_object_ref -#define g_object_ref(Obj) ((glib_typeof (Obj)) (_frida_g_object_ref) (Obj)) -#undef g_object_ref_sink -#define g_object_ref_sink(Obj) ((glib_typeof (Obj)) (_frida_g_object_ref_sink) (Obj)) -#endif - -/** - * GToggleNotify: - * @data: Callback data passed to g_object_add_toggle_ref() - * @object: The object on which g_object_add_toggle_ref() was called. - * @is_last_ref: %TRUE if the toggle reference is now the - * last reference to the object. %FALSE if the toggle - * reference was the last reference and there are now other - * references. - * - * A callback function used for notification when the state - * of a toggle reference changes. See g_object_add_toggle_ref(). - */ -typedef void (*GToggleNotify) (gpointer data, - GObject *object, - gboolean is_last_ref); - -GLIB_AVAILABLE_IN_ALL -void g_object_add_toggle_ref (GObject *object, - GToggleNotify notify, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_object_remove_toggle_ref (GObject *object, - GToggleNotify notify, - gpointer data); - -GLIB_AVAILABLE_IN_ALL -gpointer g_object_get_qdata (GObject *object, - GQuark quark); -GLIB_AVAILABLE_IN_ALL -void g_object_set_qdata (GObject *object, - GQuark quark, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_object_set_qdata_full (GObject *object, - GQuark quark, - gpointer data, - GDestroyNotify destroy); -GLIB_AVAILABLE_IN_ALL -gpointer g_object_steal_qdata (GObject *object, - GQuark quark); - -GLIB_AVAILABLE_IN_2_34 -gpointer g_object_dup_qdata (GObject *object, - GQuark quark, - GDuplicateFunc dup_func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_34 -gboolean g_object_replace_qdata (GObject *object, - GQuark quark, - gpointer oldval, - gpointer newval, - GDestroyNotify destroy, - GDestroyNotify *old_destroy); - -GLIB_AVAILABLE_IN_ALL -gpointer g_object_get_data (GObject *object, - const gchar *key); -GLIB_AVAILABLE_IN_ALL -void g_object_set_data (GObject *object, - const gchar *key, - gpointer data); -GLIB_AVAILABLE_IN_ALL -void g_object_set_data_full (GObject *object, - const gchar *key, - gpointer data, - GDestroyNotify destroy); -GLIB_AVAILABLE_IN_ALL -gpointer g_object_steal_data (GObject *object, - const gchar *key); - -GLIB_AVAILABLE_IN_2_34 -gpointer g_object_dup_data (GObject *object, - const gchar *key, - GDuplicateFunc dup_func, - gpointer user_data); -GLIB_AVAILABLE_IN_2_34 -gboolean g_object_replace_data (GObject *object, - const gchar *key, - gpointer oldval, - gpointer newval, - GDestroyNotify destroy, - GDestroyNotify *old_destroy); - - -GLIB_AVAILABLE_IN_ALL -void g_object_watch_closure (GObject *object, - GClosure *closure); -GLIB_AVAILABLE_IN_ALL -GClosure* g_cclosure_new_object (GCallback callback_func, - GObject *object); -GLIB_AVAILABLE_IN_ALL -GClosure* g_cclosure_new_object_swap (GCallback callback_func, - GObject *object); -GLIB_AVAILABLE_IN_ALL -GClosure* g_closure_new_object (guint sizeof_closure, - GObject *object); -GLIB_AVAILABLE_IN_ALL -void g_value_set_object (GValue *value, - gpointer v_object); -GLIB_AVAILABLE_IN_ALL -gpointer g_value_get_object (const GValue *value); -GLIB_AVAILABLE_IN_ALL -gpointer g_value_dup_object (const GValue *value); -GLIB_AVAILABLE_IN_ALL -gulong g_signal_connect_object (gpointer instance, - const gchar *detailed_signal, - GCallback c_handler, - gpointer gobject, - GConnectFlags connect_flags); - -/*< protected >*/ -GLIB_AVAILABLE_IN_ALL -void g_object_force_floating (GObject *object); -GLIB_AVAILABLE_IN_ALL -void g_object_run_dispose (GObject *object); - - -GLIB_AVAILABLE_IN_ALL -void g_value_take_object (GValue *value, - gpointer v_object); -GLIB_DEPRECATED_FOR(g_value_take_object) -void g_value_set_object_take_ownership (GValue *value, - gpointer v_object); - -GLIB_DEPRECATED -gsize g_object_compat_control (gsize what, - gpointer data); - -/* --- implementation macros --- */ -#define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \ -G_STMT_START { \ - GObject *_glib__object = (GObject*) (object); \ - GParamSpec *_glib__pspec = (GParamSpec*) (pspec); \ - guint _glib__property_id = (property_id); \ - g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'", \ - __FILE__, __LINE__, \ - (pname), \ - _glib__property_id, \ - _glib__pspec->name, \ - g_type_name (G_PARAM_SPEC_TYPE (_glib__pspec)), \ - G_OBJECT_TYPE_NAME (_glib__object)); \ -} G_STMT_END -/** - * G_OBJECT_WARN_INVALID_PROPERTY_ID: - * @object: the #GObject on which set_property() or get_property() was called - * @property_id: the numeric id of the property - * @pspec: the #GParamSpec of the property - * - * This macro should be used to emit a standard warning about unexpected - * properties in set_property() and get_property() implementations. - */ -#define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \ - G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec)) - -GLIB_AVAILABLE_IN_ALL -void g_clear_object (GObject **object_ptr); -#undef g_clear_object -#define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref) - -/** - * g_set_object: (skip) - * @object_ptr: (inout) (not optional) (nullable): a pointer to a #GObject reference - * @new_object: (nullable) (transfer none): a pointer to the new #GObject to - * assign to @object_ptr, or %NULL to clear the pointer - * - * Updates a #GObject pointer to refer to @new_object. It increments the - * reference count of @new_object (if non-%NULL), decrements the reference - * count of the current value of @object_ptr (if non-%NULL), and assigns - * @new_object to @object_ptr. The assignment is not atomic. - * - * @object_ptr must not be %NULL, but can point to a %NULL value. - * - * A macro is also included that allows this function to be used without - * pointer casts. The function itself is static inline, so its address may vary - * between compilation units. - * - * One convenient usage of this function is in implementing property setters: - * |[ - * void - * foo_set_bar (Foo *foo, - * Bar *new_bar) - * { - * g_return_if_fail (IS_FOO (foo)); - * g_return_if_fail (new_bar == NULL || IS_BAR (new_bar)); - * - * if (g_set_object (&foo->bar, new_bar)) - * g_object_notify (foo, "bar"); - * } - * ]| - * - * Returns: %TRUE if the value of @object_ptr changed, %FALSE otherwise - * - * Since: 2.44 - */ -static inline gboolean -(g_set_object) (GObject **object_ptr, - GObject *new_object) -{ - GObject *old_object = *object_ptr; - - /* rely on g_object_[un]ref() to check the pointers are actually GObjects; - * elide a (object_ptr != NULL) check because most of the time we will be - * operating on struct members with a constant offset, so a NULL check would - * not catch bugs - */ - - if (old_object == new_object) - return FALSE; - - if (new_object != NULL) - g_object_ref (new_object); - - *object_ptr = new_object; - - if (old_object != NULL) - g_object_unref (old_object); - - return TRUE; -} - -/* We need GCC for __extension__, which we need to sort out strict aliasing of @object_ptr */ -#if defined(__GNUC__) - -#define g_set_object(object_ptr, new_object) \ - (G_GNUC_EXTENSION ({ \ - G_STATIC_ASSERT (sizeof *(object_ptr) == sizeof (new_object)); \ - /* Only one access, please; work around type aliasing */ \ - union { char *in; GObject **out; } _object_ptr; \ - _object_ptr.in = (char *) (object_ptr); \ - /* Check types match */ \ - (void) (0 ? *(object_ptr) = (new_object), FALSE : FALSE); \ - (g_set_object) (_object_ptr.out, (GObject *) new_object); \ - })) \ - GLIB_AVAILABLE_MACRO_IN_2_44 - -#else /* if !defined(__GNUC__) */ - -#define g_set_object(object_ptr, new_object) \ - (/* Check types match. */ \ - 0 ? *(object_ptr) = (new_object), FALSE : \ - (g_set_object) ((GObject **) (object_ptr), (GObject *) (new_object)) \ - ) - -#endif /* !defined(__GNUC__) */ - -/** - * g_assert_finalize_object: (skip) - * @object: (transfer full) (type GObject.Object): an object - * - * Assert that @object is non-%NULL, then release one reference to it with - * g_object_unref() and assert that it has been finalized (i.e. that there - * are no more references). - * - * If assertions are disabled via `G_DISABLE_ASSERT`, - * this macro just calls g_object_unref() without any further checks. - * - * This macro should only be used in regression tests. - * - * Since: 2.62 - */ -static inline void -(g_assert_finalize_object) (GObject *object) -{ - gpointer weak_pointer = object; - - g_assert_true (G_IS_OBJECT (weak_pointer)); - g_object_add_weak_pointer (object, &weak_pointer); - g_object_unref (weak_pointer); - g_assert_null (weak_pointer); -} - -#ifdef G_DISABLE_ASSERT -#define g_assert_finalize_object(object) g_object_unref (object) -#else -#define g_assert_finalize_object(object) (g_assert_finalize_object ((GObject *) object)) -#endif - -/** - * g_clear_weak_pointer: (skip) - * @weak_pointer_location: The memory address of a pointer - * - * Clears a weak reference to a #GObject. - * - * @weak_pointer_location must not be %NULL. - * - * If the weak reference is %NULL then this function does nothing. - * Otherwise, the weak reference to the object is removed for that location - * and the pointer is set to %NULL. - * - * A macro is also included that allows this function to be used without - * pointer casts. The function itself is static inline, so its address may vary - * between compilation units. - * - * Since: 2.56 - */ -static inline void -(g_clear_weak_pointer) (gpointer *weak_pointer_location) -{ - GObject *object = (GObject *) *weak_pointer_location; - - if (object != NULL) - { - g_object_remove_weak_pointer (object, weak_pointer_location); - *weak_pointer_location = NULL; - } -} - -#define g_clear_weak_pointer(weak_pointer_location) \ - (/* Check types match. */ \ - (g_clear_weak_pointer) ((gpointer *) (weak_pointer_location)) \ - ) - -/** - * g_set_weak_pointer: (skip) - * @weak_pointer_location: the memory address of a pointer - * @new_object: (nullable) (transfer none): a pointer to the new #GObject to - * assign to it, or %NULL to clear the pointer - * - * Updates a pointer to weakly refer to @new_object. It assigns @new_object - * to @weak_pointer_location and ensures that @weak_pointer_location will - * automatically be set to %NULL if @new_object gets destroyed. The assignment - * is not atomic. The weak reference is not thread-safe, see - * g_object_add_weak_pointer() for details. - * - * @weak_pointer_location must not be %NULL. - * - * A macro is also included that allows this function to be used without - * pointer casts. The function itself is static inline, so its address may vary - * between compilation units. - * - * One convenient usage of this function is in implementing property setters: - * |[ - * void - * foo_set_bar (Foo *foo, - * Bar *new_bar) - * { - * g_return_if_fail (IS_FOO (foo)); - * g_return_if_fail (new_bar == NULL || IS_BAR (new_bar)); - * - * if (g_set_weak_pointer (&foo->bar, new_bar)) - * g_object_notify (foo, "bar"); - * } - * ]| - * - * Returns: %TRUE if the value of @weak_pointer_location changed, %FALSE otherwise - * - * Since: 2.56 - */ -static inline gboolean -(g_set_weak_pointer) (gpointer *weak_pointer_location, - GObject *new_object) -{ - GObject *old_object = (GObject *) *weak_pointer_location; - - /* elide a (weak_pointer_location != NULL) check because most of the time we - * will be operating on struct members with a constant offset, so a NULL - * check would not catch bugs - */ - - if (old_object == new_object) - return FALSE; - - if (old_object != NULL) - g_object_remove_weak_pointer (old_object, weak_pointer_location); - - *weak_pointer_location = new_object; - - if (new_object != NULL) - g_object_add_weak_pointer (new_object, weak_pointer_location); - - return TRUE; -} - -#define g_set_weak_pointer(weak_pointer_location, new_object) \ - (/* Check types match. */ \ - 0 ? *(weak_pointer_location) = (new_object), FALSE : \ - (g_set_weak_pointer) ((gpointer *) (weak_pointer_location), (GObject *) (new_object)) \ - ) - -typedef struct { - /**/ - union { gpointer p; } priv; -} GWeakRef; - -GLIB_AVAILABLE_IN_ALL -void g_weak_ref_init (GWeakRef *weak_ref, - gpointer object); -GLIB_AVAILABLE_IN_ALL -void g_weak_ref_clear (GWeakRef *weak_ref); -GLIB_AVAILABLE_IN_ALL -gpointer g_weak_ref_get (GWeakRef *weak_ref); -GLIB_AVAILABLE_IN_ALL -void g_weak_ref_set (GWeakRef *weak_ref, - gpointer object); - -G_END_DECLS - -#endif /* __G_OBJECT_H__ */ - -G_BEGIN_DECLS - -#define G_TYPE_BINDING_FLAGS (g_binding_flags_get_type ()) - -#define G_TYPE_BINDING (g_binding_get_type ()) -#define G_BINDING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_BINDING, GBinding)) -#define G_IS_BINDING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_BINDING)) - -/** - * GBinding: - * - * GBinding is an opaque structure whose members - * cannot be accessed directly. - * - * Since: 2.26 - */ -typedef struct _GBinding GBinding; - -/** - * GBindingTransformFunc: - * @binding: a #GBinding - * @from_value: the #GValue containing the value to transform - * @to_value: the #GValue in which to store the transformed value - * @user_data: data passed to the transform function - * - * A function to be called to transform @from_value to @to_value. If - * this is the @transform_to function of a binding, then @from_value - * is the @source_property on the @source object, and @to_value is the - * @target_property on the @target object. If this is the - * @transform_from function of a %G_BINDING_BIDIRECTIONAL binding, - * then those roles are reversed. - * - * Returns: %TRUE if the transformation was successful, and %FALSE - * otherwise - * - * Since: 2.26 - */ -typedef gboolean (* GBindingTransformFunc) (GBinding *binding, - const GValue *from_value, - GValue *to_value, - gpointer user_data); - -/** - * GBindingFlags: - * @G_BINDING_DEFAULT: The default binding; if the source property - * changes, the target property is updated with its value. - * @G_BINDING_BIDIRECTIONAL: Bidirectional binding; if either the - * property of the source or the property of the target changes, - * the other is updated. - * @G_BINDING_SYNC_CREATE: Synchronize the values of the source and - * target properties when creating the binding; the direction of - * the synchronization is always from the source to the target. - * @G_BINDING_INVERT_BOOLEAN: If the two properties being bound are - * booleans, setting one to %TRUE will result in the other being - * set to %FALSE and vice versa. This flag will only work for - * boolean properties, and cannot be used when passing custom - * transformation functions to g_object_bind_property_full(). - * - * Flags to be passed to g_object_bind_property() or - * g_object_bind_property_full(). - * - * This enumeration can be extended at later date. - * - * Since: 2.26 - */ -typedef enum { /*< prefix=G_BINDING >*/ - G_BINDING_DEFAULT = 0, - - G_BINDING_BIDIRECTIONAL = 1 << 0, - G_BINDING_SYNC_CREATE = 1 << 1, - G_BINDING_INVERT_BOOLEAN = 1 << 2 -} GBindingFlags; - -GLIB_AVAILABLE_IN_ALL -GType g_binding_flags_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -GType g_binding_get_type (void) G_GNUC_CONST; - -GLIB_AVAILABLE_IN_ALL -GBindingFlags g_binding_get_flags (GBinding *binding); -GLIB_DEPRECATED_IN_2_68_FOR(g_binding_dup_source) -GObject * g_binding_get_source (GBinding *binding); -GLIB_AVAILABLE_IN_2_68 -GObject * g_binding_dup_source (GBinding *binding); -GLIB_DEPRECATED_IN_2_68_FOR(g_binding_dup_target) -GObject * g_binding_get_target (GBinding *binding); -GLIB_AVAILABLE_IN_2_68 -GObject * g_binding_dup_target (GBinding *binding); -GLIB_AVAILABLE_IN_ALL -const gchar * g_binding_get_source_property (GBinding *binding); -GLIB_AVAILABLE_IN_ALL -const gchar * g_binding_get_target_property (GBinding *binding); -GLIB_AVAILABLE_IN_2_38 -void g_binding_unbind (GBinding *binding); - -GLIB_AVAILABLE_IN_ALL -GBinding *g_object_bind_property (gpointer source, - const gchar *source_property, - gpointer target, - const gchar *target_property, - GBindingFlags flags); -GLIB_AVAILABLE_IN_ALL -GBinding *g_object_bind_property_full (gpointer source, - const gchar *source_property, - gpointer target, - const gchar *target_property, - GBindingFlags flags, - GBindingTransformFunc transform_to, - GBindingTransformFunc transform_from, - gpointer user_data, - GDestroyNotify notify); -GLIB_AVAILABLE_IN_ALL -GBinding *g_object_bind_property_with_closures (gpointer source, - const gchar *source_property, - gpointer target, - const gchar *target_property, - GBindingFlags flags, - GClosure *transform_to, - GClosure *transform_from); - -G_END_DECLS - -#endif /* __G_BINDING_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __G_ENUMS_H__ -#define __G_ENUMS_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* --- type macros --- */ -/** - * G_TYPE_IS_ENUM: - * @type: a #GType ID. - * - * Checks whether @type "is a" %G_TYPE_ENUM. - * - * Returns: %TRUE if @type "is a" %G_TYPE_ENUM. - */ -#define G_TYPE_IS_ENUM(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_ENUM) -/** - * G_ENUM_CLASS: - * @class: a valid #GEnumClass - * - * Casts a derived #GEnumClass structure into a #GEnumClass structure. - */ -#define G_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_ENUM, GEnumClass)) -/** - * G_IS_ENUM_CLASS: - * @class: a #GEnumClass - * - * Checks whether @class "is a" valid #GEnumClass structure of type %G_TYPE_ENUM - * or derived. - */ -#define G_IS_ENUM_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_ENUM)) -/** - * G_ENUM_CLASS_TYPE: - * @class: a #GEnumClass - * - * Get the type identifier from a given #GEnumClass structure. - * - * Returns: the #GType - */ -#define G_ENUM_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) -/** - * G_ENUM_CLASS_TYPE_NAME: - * @class: a #GEnumClass - * - * Get the static type name from a given #GEnumClass structure. - * - * Returns: the type name. - */ -#define G_ENUM_CLASS_TYPE_NAME(class) (g_type_name (G_ENUM_CLASS_TYPE (class))) - - -/** - * G_TYPE_IS_FLAGS: - * @type: a #GType ID. - * - * Checks whether @type "is a" %G_TYPE_FLAGS. - * - * Returns: %TRUE if @type "is a" %G_TYPE_FLAGS. - */ -#define G_TYPE_IS_FLAGS(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_FLAGS) -/** - * G_FLAGS_CLASS: - * @class: a valid #GFlagsClass - * - * Casts a derived #GFlagsClass structure into a #GFlagsClass structure. - */ -#define G_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_FLAGS, GFlagsClass)) -/** - * G_IS_FLAGS_CLASS: - * @class: a #GFlagsClass - * - * Checks whether @class "is a" valid #GFlagsClass structure of type %G_TYPE_FLAGS - * or derived. - */ -#define G_IS_FLAGS_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_FLAGS)) -/** - * G_FLAGS_CLASS_TYPE: - * @class: a #GFlagsClass - * - * Get the type identifier from a given #GFlagsClass structure. - * - * Returns: the #GType - */ -#define G_FLAGS_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) -/** - * G_FLAGS_CLASS_TYPE_NAME: - * @class: a #GFlagsClass - * - * Get the static type name from a given #GFlagsClass structure. - * - * Returns: the type name. - */ -#define G_FLAGS_CLASS_TYPE_NAME(class) (g_type_name (G_FLAGS_CLASS_TYPE (class))) - - -/** - * G_VALUE_HOLDS_ENUM: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values derived from type %G_TYPE_ENUM. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_ENUM(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ENUM)) -/** - * G_VALUE_HOLDS_FLAGS: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values derived from type %G_TYPE_FLAGS. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_FLAGS(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLAGS)) - - -/* --- enum/flag values & classes --- */ -typedef struct _GEnumClass GEnumClass; -typedef struct _GFlagsClass GFlagsClass; -typedef struct _GEnumValue GEnumValue; -typedef struct _GFlagsValue GFlagsValue; - -/** - * GEnumClass: - * @g_type_class: the parent class - * @minimum: the smallest possible value. - * @maximum: the largest possible value. - * @n_values: the number of possible values. - * @values: an array of #GEnumValue structs describing the - * individual values. - * - * The class of an enumeration type holds information about its - * possible values. - */ -struct _GEnumClass -{ - GTypeClass g_type_class; - - /*< public >*/ - gint minimum; - gint maximum; - guint n_values; - GEnumValue *values; -}; -/** - * GFlagsClass: - * @g_type_class: the parent class - * @mask: a mask covering all possible values. - * @n_values: the number of possible values. - * @values: an array of #GFlagsValue structs describing the - * individual values. - * - * The class of a flags type holds information about its - * possible values. - */ -struct _GFlagsClass -{ - GTypeClass g_type_class; - - /*< public >*/ - guint mask; - guint n_values; - GFlagsValue *values; -}; -/** - * GEnumValue: - * @value: the enum value - * @value_name: the name of the value - * @value_nick: the nickname of the value - * - * A structure which contains a single enum value, its name, and its - * nickname. - */ -struct _GEnumValue -{ - gint value; - const gchar *value_name; - const gchar *value_nick; -}; -/** - * GFlagsValue: - * @value: the flags value - * @value_name: the name of the value - * @value_nick: the nickname of the value - * - * A structure which contains a single flags value, its name, and its - * nickname. - */ -struct _GFlagsValue -{ - guint value; - const gchar *value_name; - const gchar *value_nick; -}; - - -/* --- prototypes --- */ -GLIB_AVAILABLE_IN_ALL -GEnumValue* g_enum_get_value (GEnumClass *enum_class, - gint value); -GLIB_AVAILABLE_IN_ALL -GEnumValue* g_enum_get_value_by_name (GEnumClass *enum_class, - const gchar *name); -GLIB_AVAILABLE_IN_ALL -GEnumValue* g_enum_get_value_by_nick (GEnumClass *enum_class, - const gchar *nick); -GLIB_AVAILABLE_IN_ALL -GFlagsValue* g_flags_get_first_value (GFlagsClass *flags_class, - guint value); -GLIB_AVAILABLE_IN_ALL -GFlagsValue* g_flags_get_value_by_name (GFlagsClass *flags_class, - const gchar *name); -GLIB_AVAILABLE_IN_ALL -GFlagsValue* g_flags_get_value_by_nick (GFlagsClass *flags_class, - const gchar *nick); -GLIB_AVAILABLE_IN_2_54 -gchar *g_enum_to_string (GType g_enum_type, - gint value); -GLIB_AVAILABLE_IN_2_54 -gchar *g_flags_to_string (GType flags_type, - guint value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_enum (GValue *value, - gint v_enum); -GLIB_AVAILABLE_IN_ALL -gint g_value_get_enum (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_flags (GValue *value, - guint v_flags); -GLIB_AVAILABLE_IN_ALL -guint g_value_get_flags (const GValue *value); - - - -/* --- registration functions --- */ -/* const_static_values is a NULL terminated array of enum/flags - * values that is taken over! - */ -GLIB_AVAILABLE_IN_ALL -GType g_enum_register_static (const gchar *name, - const GEnumValue *const_static_values); -GLIB_AVAILABLE_IN_ALL -GType g_flags_register_static (const gchar *name, - const GFlagsValue *const_static_values); -/* functions to complete the type information - * for enums/flags implemented by plugins - */ -GLIB_AVAILABLE_IN_ALL -void g_enum_complete_type_info (GType g_enum_type, - GTypeInfo *info, - const GEnumValue *const_values); -GLIB_AVAILABLE_IN_ALL -void g_flags_complete_type_info (GType g_flags_type, - GTypeInfo *info, - const GFlagsValue *const_values); - -G_END_DECLS - -#endif /* __G_ENUMS_H__ */ - -/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ - -#ifndef __GOBJECT_ENUM_TYPES_H__ -#define __GOBJECT_ENUM_TYPES_H__ - - -G_BEGIN_DECLS - -/* enumerations from "../../../deps/glib/gobject/../glib/gunicode.h" */ -GLIB_AVAILABLE_IN_2_60 GType g_unicode_type_get_type (void) G_GNUC_CONST; -#define G_TYPE_UNICODE_TYPE (g_unicode_type_get_type ()) -GLIB_AVAILABLE_IN_2_60 GType g_unicode_break_type_get_type (void) G_GNUC_CONST; -#define G_TYPE_UNICODE_BREAK_TYPE (g_unicode_break_type_get_type ()) -GLIB_AVAILABLE_IN_2_60 GType g_unicode_script_get_type (void) G_GNUC_CONST; -#define G_TYPE_UNICODE_SCRIPT (g_unicode_script_get_type ()) -GLIB_AVAILABLE_IN_2_60 GType g_normalize_mode_get_type (void) G_GNUC_CONST; -#define G_TYPE_NORMALIZE_MODE (g_normalize_mode_get_type ()) -G_END_DECLS - -#endif /* __GOBJECT_ENUM_TYPES_H__ */ - -/* Generated data ends here */ - -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - * - * gparamspecs.h: GLib default param specs - */ -#ifndef __G_PARAMSPECS_H__ -#define __G_PARAMSPECS_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* --- type macros --- */ -/** - * G_TYPE_PARAM_CHAR: - * - * The #GType of #GParamSpecChar. - */ -#define G_TYPE_PARAM_CHAR (g_param_spec_types[0]) -/** - * G_IS_PARAM_SPEC_CHAR: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_CHAR. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_CHAR)) -/** - * G_PARAM_SPEC_CHAR: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecChar. - */ -#define G_PARAM_SPEC_CHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_CHAR, GParamSpecChar)) - -/** - * G_TYPE_PARAM_UCHAR: - * - * The #GType of #GParamSpecUChar. - */ -#define G_TYPE_PARAM_UCHAR (g_param_spec_types[1]) -/** - * G_IS_PARAM_SPEC_UCHAR: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UCHAR. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UCHAR)) -/** - * G_PARAM_SPEC_UCHAR: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecUChar. - */ -#define G_PARAM_SPEC_UCHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UCHAR, GParamSpecUChar)) - -/** - * G_TYPE_PARAM_BOOLEAN: - * - * The #GType of #GParamSpecBoolean. - */ -#define G_TYPE_PARAM_BOOLEAN (g_param_spec_types[2]) -/** - * G_IS_PARAM_SPEC_BOOLEAN: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_BOOLEAN. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOOLEAN)) -/** - * G_PARAM_SPEC_BOOLEAN: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecBoolean. - */ -#define G_PARAM_SPEC_BOOLEAN(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOOLEAN, GParamSpecBoolean)) - -/** - * G_TYPE_PARAM_INT: - * - * The #GType of #GParamSpecInt. - */ -#define G_TYPE_PARAM_INT (g_param_spec_types[3]) -/** - * G_IS_PARAM_SPEC_INT: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_INT. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT)) -/** - * G_PARAM_SPEC_INT: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecInt. - */ -#define G_PARAM_SPEC_INT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT, GParamSpecInt)) - -/** - * G_TYPE_PARAM_UINT: - * - * The #GType of #GParamSpecUInt. - */ -#define G_TYPE_PARAM_UINT (g_param_spec_types[4]) -/** - * G_IS_PARAM_SPEC_UINT: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UINT. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT)) -/** - * G_PARAM_SPEC_UINT: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecUInt. - */ -#define G_PARAM_SPEC_UINT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT, GParamSpecUInt)) - -/** - * G_TYPE_PARAM_LONG: - * - * The #GType of #GParamSpecLong. - */ -#define G_TYPE_PARAM_LONG (g_param_spec_types[5]) -/** - * G_IS_PARAM_SPEC_LONG: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_LONG. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_LONG)) -/** - * G_PARAM_SPEC_LONG: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecLong. - */ -#define G_PARAM_SPEC_LONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_LONG, GParamSpecLong)) - -/** - * G_TYPE_PARAM_ULONG: - * - * The #GType of #GParamSpecULong. - */ -#define G_TYPE_PARAM_ULONG (g_param_spec_types[6]) -/** - * G_IS_PARAM_SPEC_ULONG: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_ULONG. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ULONG)) -/** - * G_PARAM_SPEC_ULONG: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecULong. - */ -#define G_PARAM_SPEC_ULONG(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ULONG, GParamSpecULong)) - -/** - * G_TYPE_PARAM_INT64: - * - * The #GType of #GParamSpecInt64. - */ -#define G_TYPE_PARAM_INT64 (g_param_spec_types[7]) -/** - * G_IS_PARAM_SPEC_INT64: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_INT64. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_INT64(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_INT64)) -/** - * G_PARAM_SPEC_INT64: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecInt64. - */ -#define G_PARAM_SPEC_INT64(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_INT64, GParamSpecInt64)) - -/** - * G_TYPE_PARAM_UINT64: - * - * The #GType of #GParamSpecUInt64. - */ -#define G_TYPE_PARAM_UINT64 (g_param_spec_types[8]) -/** - * G_IS_PARAM_SPEC_UINT64: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UINT64. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_UINT64(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UINT64)) -/** - * G_PARAM_SPEC_UINT64: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecUInt64. - */ -#define G_PARAM_SPEC_UINT64(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UINT64, GParamSpecUInt64)) - -/** - * G_TYPE_PARAM_UNICHAR: - * - * The #GType of #GParamSpecUnichar. - */ -#define G_TYPE_PARAM_UNICHAR (g_param_spec_types[9]) -/** - * G_PARAM_SPEC_UNICHAR: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecUnichar. - */ -#define G_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_UNICHAR, GParamSpecUnichar)) -/** - * G_IS_PARAM_SPEC_UNICHAR: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_UNICHAR. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_UNICHAR(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_UNICHAR)) - -/** - * G_TYPE_PARAM_ENUM: - * - * The #GType of #GParamSpecEnum. - */ -#define G_TYPE_PARAM_ENUM (g_param_spec_types[10]) -/** - * G_IS_PARAM_SPEC_ENUM: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_ENUM. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_ENUM)) -/** - * G_PARAM_SPEC_ENUM: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecEnum. - */ -#define G_PARAM_SPEC_ENUM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_ENUM, GParamSpecEnum)) - -/** - * G_TYPE_PARAM_FLAGS: - * - * The #GType of #GParamSpecFlags. - */ -#define G_TYPE_PARAM_FLAGS (g_param_spec_types[11]) -/** - * G_IS_PARAM_SPEC_FLAGS: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_FLAGS. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLAGS)) -/** - * G_PARAM_SPEC_FLAGS: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecFlags. - */ -#define G_PARAM_SPEC_FLAGS(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLAGS, GParamSpecFlags)) - -/** - * G_TYPE_PARAM_FLOAT: - * - * The #GType of #GParamSpecFloat. - */ -#define G_TYPE_PARAM_FLOAT (g_param_spec_types[12]) -/** - * G_IS_PARAM_SPEC_FLOAT: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_FLOAT. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_FLOAT)) -/** - * G_PARAM_SPEC_FLOAT: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecFloat. - */ -#define G_PARAM_SPEC_FLOAT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_FLOAT, GParamSpecFloat)) - -/** - * G_TYPE_PARAM_DOUBLE: - * - * The #GType of #GParamSpecDouble. - */ -#define G_TYPE_PARAM_DOUBLE (g_param_spec_types[13]) -/** - * G_IS_PARAM_SPEC_DOUBLE: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_DOUBLE. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_DOUBLE)) -/** - * G_PARAM_SPEC_DOUBLE: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecDouble. - */ -#define G_PARAM_SPEC_DOUBLE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_DOUBLE, GParamSpecDouble)) - -/** - * G_TYPE_PARAM_STRING: - * - * The #GType of #GParamSpecString. - */ -#define G_TYPE_PARAM_STRING (g_param_spec_types[14]) -/** - * G_IS_PARAM_SPEC_STRING: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_STRING. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_STRING)) -/** - * G_PARAM_SPEC_STRING: - * @pspec: a valid #GParamSpec instance - * - * Casts a #GParamSpec instance into a #GParamSpecString. - */ -#define G_PARAM_SPEC_STRING(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_STRING, GParamSpecString)) - -/** - * G_TYPE_PARAM_PARAM: - * - * The #GType of #GParamSpecParam. - */ -#define G_TYPE_PARAM_PARAM (g_param_spec_types[15]) -/** - * G_IS_PARAM_SPEC_PARAM: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_PARAM. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_PARAM)) -/** - * G_PARAM_SPEC_PARAM: - * @pspec: a valid #GParamSpec instance - * - * Casts a #GParamSpec instance into a #GParamSpecParam. - */ -#define G_PARAM_SPEC_PARAM(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_PARAM, GParamSpecParam)) - -/** - * G_TYPE_PARAM_BOXED: - * - * The #GType of #GParamSpecBoxed. - */ -#define G_TYPE_PARAM_BOXED (g_param_spec_types[16]) -/** - * G_IS_PARAM_SPEC_BOXED: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_BOXED. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_BOXED)) -/** - * G_PARAM_SPEC_BOXED: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecBoxed. - */ -#define G_PARAM_SPEC_BOXED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_BOXED, GParamSpecBoxed)) - -/** - * G_TYPE_PARAM_POINTER: - * - * The #GType of #GParamSpecPointer. - */ -#define G_TYPE_PARAM_POINTER (g_param_spec_types[17]) -/** - * G_IS_PARAM_SPEC_POINTER: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_POINTER. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_POINTER)) -/** - * G_PARAM_SPEC_POINTER: - * @pspec: a valid #GParamSpec instance - * - * Casts a #GParamSpec instance into a #GParamSpecPointer. - */ -#define G_PARAM_SPEC_POINTER(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_POINTER, GParamSpecPointer)) - -/** - * G_TYPE_PARAM_VALUE_ARRAY: - * - * The #GType of #GParamSpecValueArray. - * - * Deprecated: 2.32: Use #GArray instead of #GValueArray - */ -#define G_TYPE_PARAM_VALUE_ARRAY (g_param_spec_types[18]) GLIB_DEPRECATED_MACRO_IN_2_32 -/** - * G_IS_PARAM_SPEC_VALUE_ARRAY: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VALUE_ARRAY. - * - * Returns: %TRUE on success. - * - * Deprecated: 2.32: Use #GArray instead of #GValueArray - */ -#define G_IS_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VALUE_ARRAY)) GLIB_DEPRECATED_MACRO_IN_2_32 -/** - * G_PARAM_SPEC_VALUE_ARRAY: - * @pspec: a valid #GParamSpec instance - * - * Cast a #GParamSpec instance into a #GParamSpecValueArray. - * - * Deprecated: 2.32: Use #GArray instead of #GValueArray - */ -#define G_PARAM_SPEC_VALUE_ARRAY(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VALUE_ARRAY, GParamSpecValueArray)) GLIB_DEPRECATED_MACRO_IN_2_32 - -/** - * G_TYPE_PARAM_OBJECT: - * - * The #GType of #GParamSpecObject. - */ -#define G_TYPE_PARAM_OBJECT (g_param_spec_types[19]) -/** - * G_IS_PARAM_SPEC_OBJECT: - * @pspec: a valid #GParamSpec instance - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_OBJECT. - * - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OBJECT)) -/** - * G_PARAM_SPEC_OBJECT: - * @pspec: a valid #GParamSpec instance - * - * Casts a #GParamSpec instance into a #GParamSpecObject. - */ -#define G_PARAM_SPEC_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OBJECT, GParamSpecObject)) - -/** - * G_TYPE_PARAM_OVERRIDE: - * - * The #GType of #GParamSpecOverride. - * - * Since: 2.4 - */ -#define G_TYPE_PARAM_OVERRIDE (g_param_spec_types[20]) -/** - * G_IS_PARAM_SPEC_OVERRIDE: - * @pspec: a #GParamSpec - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_OVERRIDE. - * - * Since: 2.4 - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_OVERRIDE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_OVERRIDE)) -/** - * G_PARAM_SPEC_OVERRIDE: - * @pspec: a #GParamSpec - * - * Casts a #GParamSpec into a #GParamSpecOverride. - * - * Since: 2.4 - */ -#define G_PARAM_SPEC_OVERRIDE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_OVERRIDE, GParamSpecOverride)) - -/** - * G_TYPE_PARAM_GTYPE: - * - * The #GType of #GParamSpecGType. - * - * Since: 2.10 - */ -#define G_TYPE_PARAM_GTYPE (g_param_spec_types[21]) -/** - * G_IS_PARAM_SPEC_GTYPE: - * @pspec: a #GParamSpec - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_GTYPE. - * - * Since: 2.10 - * Returns: %TRUE on success. - */ -#define G_IS_PARAM_SPEC_GTYPE(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_GTYPE)) -/** - * G_PARAM_SPEC_GTYPE: - * @pspec: a #GParamSpec - * - * Casts a #GParamSpec into a #GParamSpecGType. - * - * Since: 2.10 - */ -#define G_PARAM_SPEC_GTYPE(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_GTYPE, GParamSpecGType)) - -/** - * G_TYPE_PARAM_VARIANT: - * - * The #GType of #GParamSpecVariant. - * - * Since: 2.26 - */ -#define G_TYPE_PARAM_VARIANT (g_param_spec_types[22]) -/** - * G_IS_PARAM_SPEC_VARIANT: - * @pspec: a #GParamSpec - * - * Checks whether the given #GParamSpec is of type %G_TYPE_PARAM_VARIANT. - * - * Returns: %TRUE on success - * - * Since: 2.26 - */ -#define G_IS_PARAM_SPEC_VARIANT(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), G_TYPE_PARAM_VARIANT)) -/** - * G_PARAM_SPEC_VARIANT: - * @pspec: a #GParamSpec - * - * Casts a #GParamSpec into a #GParamSpecVariant. - * - * Since: 2.26 - */ -#define G_PARAM_SPEC_VARIANT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), G_TYPE_PARAM_VARIANT, GParamSpecVariant)) - -/* --- typedefs & structures --- */ -typedef struct _GParamSpecChar GParamSpecChar; -typedef struct _GParamSpecUChar GParamSpecUChar; -typedef struct _GParamSpecBoolean GParamSpecBoolean; -typedef struct _GParamSpecInt GParamSpecInt; -typedef struct _GParamSpecUInt GParamSpecUInt; -typedef struct _GParamSpecLong GParamSpecLong; -typedef struct _GParamSpecULong GParamSpecULong; -typedef struct _GParamSpecInt64 GParamSpecInt64; -typedef struct _GParamSpecUInt64 GParamSpecUInt64; -typedef struct _GParamSpecUnichar GParamSpecUnichar; -typedef struct _GParamSpecEnum GParamSpecEnum; -typedef struct _GParamSpecFlags GParamSpecFlags; -typedef struct _GParamSpecFloat GParamSpecFloat; -typedef struct _GParamSpecDouble GParamSpecDouble; -typedef struct _GParamSpecString GParamSpecString; -typedef struct _GParamSpecParam GParamSpecParam; -typedef struct _GParamSpecBoxed GParamSpecBoxed; -typedef struct _GParamSpecPointer GParamSpecPointer; -typedef struct _GParamSpecValueArray GParamSpecValueArray; -typedef struct _GParamSpecObject GParamSpecObject; -typedef struct _GParamSpecOverride GParamSpecOverride; -typedef struct _GParamSpecGType GParamSpecGType; -typedef struct _GParamSpecVariant GParamSpecVariant; - -/** - * GParamSpecChar: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for character properties. - */ -struct _GParamSpecChar -{ - GParamSpec parent_instance; - - gint8 minimum; - gint8 maximum; - gint8 default_value; -}; -/** - * GParamSpecUChar: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for unsigned character properties. - */ -struct _GParamSpecUChar -{ - GParamSpec parent_instance; - - guint8 minimum; - guint8 maximum; - guint8 default_value; -}; -/** - * GParamSpecBoolean: - * @parent_instance: private #GParamSpec portion - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for boolean properties. - */ -struct _GParamSpecBoolean -{ - GParamSpec parent_instance; - - gboolean default_value; -}; -/** - * GParamSpecInt: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for integer properties. - */ -struct _GParamSpecInt -{ - GParamSpec parent_instance; - - gint minimum; - gint maximum; - gint default_value; -}; -/** - * GParamSpecUInt: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for unsigned integer properties. - */ -struct _GParamSpecUInt -{ - GParamSpec parent_instance; - - guint minimum; - guint maximum; - guint default_value; -}; -/** - * GParamSpecLong: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for long integer properties. - */ -struct _GParamSpecLong -{ - GParamSpec parent_instance; - - glong minimum; - glong maximum; - glong default_value; -}; -/** - * GParamSpecULong: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for unsigned long integer properties. - */ -struct _GParamSpecULong -{ - GParamSpec parent_instance; - - gulong minimum; - gulong maximum; - gulong default_value; -}; -/** - * GParamSpecInt64: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for 64bit integer properties. - */ -struct _GParamSpecInt64 -{ - GParamSpec parent_instance; - - gint64 minimum; - gint64 maximum; - gint64 default_value; -}; -/** - * GParamSpecUInt64: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for unsigned 64bit integer properties. - */ -struct _GParamSpecUInt64 -{ - GParamSpec parent_instance; - - guint64 minimum; - guint64 maximum; - guint64 default_value; -}; -/** - * GParamSpecUnichar: - * @parent_instance: private #GParamSpec portion - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for unichar (unsigned integer) properties. - */ -struct _GParamSpecUnichar -{ - GParamSpec parent_instance; - - gunichar default_value; -}; -/** - * GParamSpecEnum: - * @parent_instance: private #GParamSpec portion - * @enum_class: the #GEnumClass for the enum - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for enum - * properties. - */ -struct _GParamSpecEnum -{ - GParamSpec parent_instance; - - GEnumClass *enum_class; - gint default_value; -}; -/** - * GParamSpecFlags: - * @parent_instance: private #GParamSpec portion - * @flags_class: the #GFlagsClass for the flags - * @default_value: default value for the property specified - * - * A #GParamSpec derived structure that contains the meta data for flags - * properties. - */ -struct _GParamSpecFlags -{ - GParamSpec parent_instance; - - GFlagsClass *flags_class; - guint default_value; -}; -/** - * GParamSpecFloat: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * @epsilon: values closer than @epsilon will be considered identical - * by g_param_values_cmp(); the default value is 1e-30. - * - * A #GParamSpec derived structure that contains the meta data for float properties. - */ -struct _GParamSpecFloat -{ - GParamSpec parent_instance; - - gfloat minimum; - gfloat maximum; - gfloat default_value; - gfloat epsilon; -}; -/** - * GParamSpecDouble: - * @parent_instance: private #GParamSpec portion - * @minimum: minimum value for the property specified - * @maximum: maximum value for the property specified - * @default_value: default value for the property specified - * @epsilon: values closer than @epsilon will be considered identical - * by g_param_values_cmp(); the default value is 1e-90. - * - * A #GParamSpec derived structure that contains the meta data for double properties. - */ -struct _GParamSpecDouble -{ - GParamSpec parent_instance; - - gdouble minimum; - gdouble maximum; - gdouble default_value; - gdouble epsilon; -}; -/** - * GParamSpecString: - * @parent_instance: private #GParamSpec portion - * @default_value: default value for the property specified - * @cset_first: a string containing the allowed values for the first byte - * @cset_nth: a string containing the allowed values for the subsequent bytes - * @substitutor: the replacement byte for bytes which don't match @cset_first or @cset_nth. - * @null_fold_if_empty: replace empty string by %NULL - * @ensure_non_null: replace %NULL strings by an empty string - * - * A #GParamSpec derived structure that contains the meta data for string - * properties. - */ -struct _GParamSpecString -{ - GParamSpec parent_instance; - - gchar *default_value; - gchar *cset_first; - gchar *cset_nth; - gchar substitutor; - guint null_fold_if_empty : 1; - guint ensure_non_null : 1; -}; -/** - * GParamSpecParam: - * @parent_instance: private #GParamSpec portion - * - * A #GParamSpec derived structure that contains the meta data for %G_TYPE_PARAM - * properties. - */ -struct _GParamSpecParam -{ - GParamSpec parent_instance; -}; -/** - * GParamSpecBoxed: - * @parent_instance: private #GParamSpec portion - * - * A #GParamSpec derived structure that contains the meta data for boxed properties. - */ -struct _GParamSpecBoxed -{ - GParamSpec parent_instance; -}; -/** - * GParamSpecPointer: - * @parent_instance: private #GParamSpec portion - * - * A #GParamSpec derived structure that contains the meta data for pointer properties. - */ -struct _GParamSpecPointer -{ - GParamSpec parent_instance; -}; -/** - * GParamSpecValueArray: - * @parent_instance: private #GParamSpec portion - * @element_spec: a #GParamSpec describing the elements contained in arrays of this property, may be %NULL - * @fixed_n_elements: if greater than 0, arrays of this property will always have this many elements - * - * A #GParamSpec derived structure that contains the meta data for #GValueArray properties. - */ -struct _GParamSpecValueArray -{ - GParamSpec parent_instance; - GParamSpec *element_spec; - guint fixed_n_elements; -}; -/** - * GParamSpecObject: - * @parent_instance: private #GParamSpec portion - * - * A #GParamSpec derived structure that contains the meta data for object properties. - */ -struct _GParamSpecObject -{ - GParamSpec parent_instance; -}; -/** - * GParamSpecOverride: - * - * This is a type of #GParamSpec type that simply redirects operations to - * another paramspec. All operations other than getting or - * setting the value are redirected, including accessing the nick and - * blurb, validating a value, and so forth. See - * g_param_spec_get_redirect_target() for retrieving the overridden - * property. #GParamSpecOverride is used in implementing - * g_object_class_override_property(), and will not be directly useful - * unless you are implementing a new base type similar to GObject. - * - * Since: 2.4 - */ -struct _GParamSpecOverride -{ - /*< private >*/ - GParamSpec parent_instance; - GParamSpec *overridden; -}; -/** - * GParamSpecGType: - * @parent_instance: private #GParamSpec portion - * @is_a_type: a #GType whose subtypes can occur as values - * - * A #GParamSpec derived structure that contains the meta data for #GType properties. - * - * Since: 2.10 - */ -struct _GParamSpecGType -{ - GParamSpec parent_instance; - GType is_a_type; -}; -/** - * GParamSpecVariant: - * @parent_instance: private #GParamSpec portion - * @type: a #GVariantType, or %NULL - * @default_value: a #GVariant, or %NULL - * - * A #GParamSpec derived structure that contains the meta data for #GVariant properties. - * - * When comparing values with g_param_values_cmp(), scalar values with the same - * type will be compared with g_variant_compare(). Other non-%NULL variants will - * be checked for equality with g_variant_equal(), and their sort order is - * otherwise undefined. %NULL is ordered before non-%NULL variants. Two %NULL - * values compare equal. - * - * Since: 2.26 - */ -struct _GParamSpecVariant -{ - GParamSpec parent_instance; - GVariantType *type; - GVariant *default_value; - - /*< private >*/ - gpointer padding[4]; -}; - -/* --- GParamSpec prototypes --- */ -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_char (const gchar *name, - const gchar *nick, - const gchar *blurb, - gint8 minimum, - gint8 maximum, - gint8 default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_uchar (const gchar *name, - const gchar *nick, - const gchar *blurb, - guint8 minimum, - guint8 maximum, - guint8 default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_boolean (const gchar *name, - const gchar *nick, - const gchar *blurb, - gboolean default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_int (const gchar *name, - const gchar *nick, - const gchar *blurb, - gint minimum, - gint maximum, - gint default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_uint (const gchar *name, - const gchar *nick, - const gchar *blurb, - guint minimum, - guint maximum, - guint default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_long (const gchar *name, - const gchar *nick, - const gchar *blurb, - glong minimum, - glong maximum, - glong default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_ulong (const gchar *name, - const gchar *nick, - const gchar *blurb, - gulong minimum, - gulong maximum, - gulong default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_int64 (const gchar *name, - const gchar *nick, - const gchar *blurb, - gint64 minimum, - gint64 maximum, - gint64 default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_uint64 (const gchar *name, - const gchar *nick, - const gchar *blurb, - guint64 minimum, - guint64 maximum, - guint64 default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_unichar (const gchar *name, - const gchar *nick, - const gchar *blurb, - gunichar default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_enum (const gchar *name, - const gchar *nick, - const gchar *blurb, - GType enum_type, - gint default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_flags (const gchar *name, - const gchar *nick, - const gchar *blurb, - GType flags_type, - guint default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_float (const gchar *name, - const gchar *nick, - const gchar *blurb, - gfloat minimum, - gfloat maximum, - gfloat default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_double (const gchar *name, - const gchar *nick, - const gchar *blurb, - gdouble minimum, - gdouble maximum, - gdouble default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_string (const gchar *name, - const gchar *nick, - const gchar *blurb, - const gchar *default_value, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_param (const gchar *name, - const gchar *nick, - const gchar *blurb, - GType param_type, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_boxed (const gchar *name, - const gchar *nick, - const gchar *blurb, - GType boxed_type, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_pointer (const gchar *name, - const gchar *nick, - const gchar *blurb, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_value_array (const gchar *name, - const gchar *nick, - const gchar *blurb, - GParamSpec *element_spec, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_object (const gchar *name, - const gchar *nick, - const gchar *blurb, - GType object_type, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_override (const gchar *name, - GParamSpec *overridden); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_gtype (const gchar *name, - const gchar *nick, - const gchar *blurb, - GType is_a_type, - GParamFlags flags); -GLIB_AVAILABLE_IN_ALL -GParamSpec* g_param_spec_variant (const gchar *name, - const gchar *nick, - const gchar *blurb, - const GVariantType *type, - GVariant *default_value, - GParamFlags flags); - -/* --- internal --- */ -/* We prefix variable declarations so they can - * properly get exported in windows dlls. - */ -#ifndef GOBJECT_VAR -# ifdef G_PLATFORM_WIN32 -# ifdef GOBJECT_STATIC_COMPILATION -# define GOBJECT_VAR extern -# else /* !GOBJECT_STATIC_COMPILATION */ -# ifdef GOBJECT_COMPILATION -# ifdef DLL_EXPORT -# define GOBJECT_VAR extern __declspec(dllexport) -# else /* !DLL_EXPORT */ -# define GOBJECT_VAR extern -# endif /* !DLL_EXPORT */ -# else /* !GOBJECT_COMPILATION */ -# define GOBJECT_VAR extern __declspec(dllimport) -# endif /* !GOBJECT_COMPILATION */ -# endif /* !GOBJECT_STATIC_COMPILATION */ -# else /* !G_PLATFORM_WIN32 */ -# define GOBJECT_VAR _GLIB_EXTERN -# endif /* !G_PLATFORM_WIN32 */ -#endif /* GOBJECT_VAR */ - -GOBJECT_VAR GType *g_param_spec_types; - -G_END_DECLS - -#endif /* __G_PARAMSPECS_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 2001 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __G_SOURCECLOSURE_H__ -#define __G_SOURCECLOSURE_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -GLIB_AVAILABLE_IN_ALL -void g_source_set_closure (GSource *source, - GClosure *closure); - -GLIB_AVAILABLE_IN_ALL -void g_source_set_dummy_callback (GSource *source); - -G_END_DECLS - -#endif /* __G_SOURCECLOSURE_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ -#ifndef __G_TYPE_MODULE_H__ -#define __G_TYPE_MODULE_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -typedef struct _GTypeModule GTypeModule; -typedef struct _GTypeModuleClass GTypeModuleClass; - -#define G_TYPE_TYPE_MODULE (g_type_module_get_type ()) -#define G_TYPE_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), G_TYPE_TYPE_MODULE, GTypeModule)) -#define G_TYPE_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_TYPE_MODULE, GTypeModuleClass)) -#define G_IS_TYPE_MODULE(module) (G_TYPE_CHECK_INSTANCE_TYPE ((module), G_TYPE_TYPE_MODULE)) -#define G_IS_TYPE_MODULE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_TYPE_MODULE)) -#define G_TYPE_MODULE_GET_CLASS(module) (G_TYPE_INSTANCE_GET_CLASS ((module), G_TYPE_TYPE_MODULE, GTypeModuleClass)) - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTypeModule, g_object_unref) - -/** - * GTypeModule: - * @name: the name of the module - * - * The members of the GTypeModule structure should not - * be accessed directly, except for the @name field. - */ -struct _GTypeModule -{ - GObject parent_instance; - - guint use_count; - GSList *type_infos; - GSList *interface_infos; - - /*< public >*/ - gchar *name; -}; - -/** - * GTypeModuleClass: - * @parent_class: the parent class - * @load: loads the module and registers one or more types using - * g_type_module_register_type(). - * @unload: unloads the module - * - * In order to implement dynamic loading of types based on #GTypeModule, - * the @load and @unload functions in #GTypeModuleClass must be implemented. - */ -struct _GTypeModuleClass -{ - GObjectClass parent_class; - - /*< public >*/ - gboolean (* load) (GTypeModule *module); - void (* unload) (GTypeModule *module); - - /*< private >*/ - /* Padding for future expansion */ - void (*reserved1) (void); - void (*reserved2) (void); - void (*reserved3) (void); - void (*reserved4) (void); -}; - -/** - * G_DEFINE_DYNAMIC_TYPE: - * @TN: The name of the new type, in Camel case. - * @t_n: The name of the new type, in lowercase, with words - * separated by '_'. - * @T_P: The #GType of the parent type. - * - * A convenience macro for dynamic type implementations, which declares a - * class initialization function, an instance initialization function (see - * #GTypeInfo for information about these) and a static variable named - * `t_n`_parent_class pointing to the parent class. Furthermore, - * it defines a `*_get_type()` and a static `*_register_type()` functions - * for use in your `module_init()`. - * - * See G_DEFINE_DYNAMIC_TYPE_EXTENDED() for an example. - * - * Since: 2.14 - */ -#define G_DEFINE_DYNAMIC_TYPE(TN, t_n, T_P) G_DEFINE_DYNAMIC_TYPE_EXTENDED (TN, t_n, T_P, 0, {}) -/** - * G_DEFINE_DYNAMIC_TYPE_EXTENDED: - * @TypeName: The name of the new type, in Camel case. - * @type_name: The name of the new type, in lowercase, with words - * separated by '_'. - * @TYPE_PARENT: The #GType of the parent type. - * @flags: #GTypeFlags to pass to g_type_module_register_type() - * @CODE: Custom code that gets inserted in the *_get_type() function. - * - * A more general version of G_DEFINE_DYNAMIC_TYPE() which - * allows to specify #GTypeFlags and custom code. - * - * |[ - * G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtkGadget, - * gtk_gadget, - * GTK_TYPE_THING, - * 0, - * G_IMPLEMENT_INTERFACE_DYNAMIC (TYPE_GIZMO, - * gtk_gadget_gizmo_init)); - * ]| - * expands to - * |[ - * static void gtk_gadget_init (GtkGadget *self); - * static void gtk_gadget_class_init (GtkGadgetClass *klass); - * static void gtk_gadget_class_finalize (GtkGadgetClass *klass); - * - * static gpointer gtk_gadget_parent_class = NULL; - * static GType gtk_gadget_type_id = 0; - * - * static void gtk_gadget_class_intern_init (gpointer klass) - * { - * gtk_gadget_parent_class = g_type_class_peek_parent (klass); - * gtk_gadget_class_init ((GtkGadgetClass*) klass); - * } - * - * GType - * gtk_gadget_get_type (void) - * { - * return gtk_gadget_type_id; - * } - * - * static void - * gtk_gadget_register_type (GTypeModule *type_module) - * { - * const GTypeInfo g_define_type_info = { - * sizeof (GtkGadgetClass), - * (GBaseInitFunc) NULL, - * (GBaseFinalizeFunc) NULL, - * (GClassInitFunc) gtk_gadget_class_intern_init, - * (GClassFinalizeFunc) gtk_gadget_class_finalize, - * NULL, // class_data - * sizeof (GtkGadget), - * 0, // n_preallocs - * (GInstanceInitFunc) gtk_gadget_init, - * NULL // value_table - * }; - * gtk_gadget_type_id = g_type_module_register_type (type_module, - * GTK_TYPE_THING, - * "GtkGadget", - * &g_define_type_info, - * (GTypeFlags) flags); - * { - * const GInterfaceInfo g_implement_interface_info = { - * (GInterfaceInitFunc) gtk_gadget_gizmo_init - * }; - * g_type_module_add_interface (type_module, g_define_type_id, TYPE_GIZMO, &g_implement_interface_info); - * } - * } - * ]| - * - * Since: 2.14 - */ -#define G_DEFINE_DYNAMIC_TYPE_EXTENDED(TypeName, type_name, TYPE_PARENT, flags, CODE) \ -static void type_name##_init (TypeName *self); \ -static void type_name##_class_init (TypeName##Class *klass); \ -static void type_name##_class_finalize (TypeName##Class *klass); \ -static gpointer type_name##_parent_class = NULL; \ -static GType type_name##_type_id = 0; \ -static gint TypeName##_private_offset; \ -\ -_G_DEFINE_TYPE_EXTENDED_CLASS_INIT(TypeName, type_name) \ -\ -G_GNUC_UNUSED \ -static inline gpointer \ -type_name##_get_instance_private (TypeName *self) \ -{ \ - return (G_STRUCT_MEMBER_P (self, TypeName##_private_offset)); \ -} \ -\ -GType \ -type_name##_get_type (void) \ -{ \ - return type_name##_type_id; \ -} \ -static void \ -type_name##_register_type (GTypeModule *type_module) \ -{ \ - GType g_define_type_id G_GNUC_UNUSED; \ - const GTypeInfo g_define_type_info = { \ - sizeof (TypeName##Class), \ - (GBaseInitFunc) NULL, \ - (GBaseFinalizeFunc) NULL, \ - (GClassInitFunc)(void (*)(void)) type_name##_class_intern_init, \ - (GClassFinalizeFunc)(void (*)(void)) type_name##_class_finalize, \ - NULL, /* class_data */ \ - sizeof (TypeName), \ - 0, /* n_preallocs */ \ - (GInstanceInitFunc)(void (*)(void)) type_name##_init, \ - NULL /* value_table */ \ - }; \ - type_name##_type_id = g_type_module_register_type (type_module, \ - TYPE_PARENT, \ - #TypeName, \ - &g_define_type_info, \ - (GTypeFlags) flags); \ - g_define_type_id = type_name##_type_id; \ - { CODE ; } \ -} - -/** - * G_IMPLEMENT_INTERFACE_DYNAMIC: - * @TYPE_IFACE: The #GType of the interface to add - * @iface_init: The interface init function - * - * A convenience macro to ease interface addition in the @_C_ section - * of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). See G_DEFINE_DYNAMIC_TYPE_EXTENDED() - * for an example. - * - * Note that this macro can only be used together with the - * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable - * names from that macro. - * - * Since: 2.24 - */ -#define G_IMPLEMENT_INTERFACE_DYNAMIC(TYPE_IFACE, iface_init) { \ - const GInterfaceInfo g_implement_interface_info = { \ - (GInterfaceInitFunc)(void (*)(void)) iface_init, NULL, NULL \ - }; \ - g_type_module_add_interface (type_module, g_define_type_id, TYPE_IFACE, &g_implement_interface_info); \ -} - -/** - * G_ADD_PRIVATE_DYNAMIC: - * @TypeName: the name of the type in CamelCase - * - * A convenience macro to ease adding private data to instances of a new dynamic - * type in the @_C_ section of G_DEFINE_DYNAMIC_TYPE_EXTENDED(). See - * G_ADD_PRIVATE() for details, it is similar but for static types. - * - * Note that this macro can only be used together with the - * G_DEFINE_DYNAMIC_TYPE_EXTENDED macros, since it depends on variable - * names from that macro. - * - * Since: 2.38 - */ -#define G_ADD_PRIVATE_DYNAMIC(TypeName) { \ - TypeName##_private_offset = sizeof (TypeName##Private); \ -} - -GLIB_AVAILABLE_IN_ALL -GType g_type_module_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -gboolean g_type_module_use (GTypeModule *module); -GLIB_AVAILABLE_IN_ALL -void g_type_module_unuse (GTypeModule *module); -GLIB_AVAILABLE_IN_ALL -void g_type_module_set_name (GTypeModule *module, - const gchar *name); -GLIB_AVAILABLE_IN_ALL -GType g_type_module_register_type (GTypeModule *module, - GType parent_type, - const gchar *type_name, - const GTypeInfo *type_info, - GTypeFlags flags); -GLIB_AVAILABLE_IN_ALL -void g_type_module_add_interface (GTypeModule *module, - GType instance_type, - GType interface_type, - const GInterfaceInfo *interface_info); -GLIB_AVAILABLE_IN_ALL -GType g_type_module_register_enum (GTypeModule *module, - const gchar *name, - const GEnumValue *const_static_values); -GLIB_AVAILABLE_IN_ALL -GType g_type_module_register_flags (GTypeModule *module, - const gchar *name, - const GFlagsValue *const_static_values); - -G_END_DECLS - -#endif /* __G_TYPE_MODULE_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - */ -#ifndef __G_TYPE_PLUGIN_H__ -#define __G_TYPE_PLUGIN_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* --- type macros --- */ -#define G_TYPE_TYPE_PLUGIN (g_type_plugin_get_type ()) -#define G_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TYPE_PLUGIN, GTypePlugin)) -#define G_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), G_TYPE_TYPE_PLUGIN, GTypePluginClass)) -#define G_IS_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TYPE_PLUGIN)) -#define G_IS_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), G_TYPE_TYPE_PLUGIN)) -#define G_TYPE_PLUGIN_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_TYPE_PLUGIN, GTypePluginClass)) - - -/* --- typedefs & structures --- */ -typedef struct _GTypePluginClass GTypePluginClass; -/** - * GTypePluginUse: - * @plugin: the #GTypePlugin whose use count should be increased - * - * The type of the @use_plugin function of #GTypePluginClass, which gets called - * to increase the use count of @plugin. - */ -typedef void (*GTypePluginUse) (GTypePlugin *plugin); -/** - * GTypePluginUnuse: - * @plugin: the #GTypePlugin whose use count should be decreased - * - * The type of the @unuse_plugin function of #GTypePluginClass. - */ -typedef void (*GTypePluginUnuse) (GTypePlugin *plugin); -/** - * GTypePluginCompleteTypeInfo: - * @plugin: the #GTypePlugin - * @g_type: the #GType whose info is completed - * @info: the #GTypeInfo struct to fill in - * @value_table: the #GTypeValueTable to fill in - * - * The type of the @complete_type_info function of #GTypePluginClass. - */ -typedef void (*GTypePluginCompleteTypeInfo) (GTypePlugin *plugin, - GType g_type, - GTypeInfo *info, - GTypeValueTable *value_table); -/** - * GTypePluginCompleteInterfaceInfo: - * @plugin: the #GTypePlugin - * @instance_type: the #GType of an instantiatable type to which the interface - * is added - * @interface_type: the #GType of the interface whose info is completed - * @info: the #GInterfaceInfo to fill in - * - * The type of the @complete_interface_info function of #GTypePluginClass. - */ -typedef void (*GTypePluginCompleteInterfaceInfo) (GTypePlugin *plugin, - GType instance_type, - GType interface_type, - GInterfaceInfo *info); -/** - * GTypePlugin: - * - * The GTypePlugin typedef is used as a placeholder - * for objects that implement the GTypePlugin interface. - */ -/** - * GTypePluginClass: - * @use_plugin: Increases the use count of the plugin. - * @unuse_plugin: Decreases the use count of the plugin. - * @complete_type_info: Fills in the #GTypeInfo and - * #GTypeValueTable structs for the type. The structs are initialized - * with `memset(s, 0, sizeof (s))` before calling this function. - * @complete_interface_info: Fills in missing parts of the #GInterfaceInfo - * for the interface. The structs is initialized with - * `memset(s, 0, sizeof (s))` before calling this function. - * - * The #GTypePlugin interface is used by the type system in order to handle - * the lifecycle of dynamically loaded types. - */ -struct _GTypePluginClass -{ - /*< private >*/ - GTypeInterface base_iface; - - /*< public >*/ - GTypePluginUse use_plugin; - GTypePluginUnuse unuse_plugin; - GTypePluginCompleteTypeInfo complete_type_info; - GTypePluginCompleteInterfaceInfo complete_interface_info; -}; - - -/* --- prototypes --- */ -GLIB_AVAILABLE_IN_ALL -GType g_type_plugin_get_type (void) G_GNUC_CONST; -GLIB_AVAILABLE_IN_ALL -void g_type_plugin_use (GTypePlugin *plugin); -GLIB_AVAILABLE_IN_ALL -void g_type_plugin_unuse (GTypePlugin *plugin); -GLIB_AVAILABLE_IN_ALL -void g_type_plugin_complete_type_info (GTypePlugin *plugin, - GType g_type, - GTypeInfo *info, - GTypeValueTable *value_table); -GLIB_AVAILABLE_IN_ALL -void g_type_plugin_complete_interface_info (GTypePlugin *plugin, - GType instance_type, - GType interface_type, - GInterfaceInfo *info); - -G_END_DECLS - -#endif /* __G_TYPE_PLUGIN_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 2001 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - * - * gvaluearray.h: GLib array type holding GValues - */ -#ifndef __G_VALUE_ARRAY_H__ -#define __G_VALUE_ARRAY_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/** - * G_TYPE_VALUE_ARRAY: - * - * The type ID of the "GValueArray" type which is a boxed type, - * used to pass around pointers to GValueArrays. - * - * Deprecated: 2.32: Use #GArray instead of #GValueArray - */ -#define G_TYPE_VALUE_ARRAY (g_value_array_get_type ()) GLIB_DEPRECATED_MACRO_IN_2_32_FOR(G_TYPE_ARRAY) - -/* --- typedefs & structs --- */ -typedef struct _GValueArray GValueArray; -/** - * GValueArray: - * @n_values: number of values contained in the array - * @values: array of values - * - * A #GValueArray contains an array of #GValue elements. - */ -struct _GValueArray -{ - guint n_values; - GValue *values; - - /*< private >*/ - guint n_prealloced; -}; - -/* --- prototypes --- */ -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GType g_value_array_get_type (void) G_GNUC_CONST; - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValue* g_value_array_get_nth (GValueArray *value_array, - guint index_); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValueArray* g_value_array_new (guint n_prealloced); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -void g_value_array_free (GValueArray *value_array); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValueArray* g_value_array_copy (const GValueArray *value_array); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValueArray* g_value_array_prepend (GValueArray *value_array, - const GValue *value); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValueArray* g_value_array_append (GValueArray *value_array, - const GValue *value); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValueArray* g_value_array_insert (GValueArray *value_array, - guint index_, - const GValue *value); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValueArray* g_value_array_remove (GValueArray *value_array, - guint index_); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValueArray* g_value_array_sort (GValueArray *value_array, - GCompareFunc compare_func); - -GLIB_DEPRECATED_IN_2_32_FOR(GArray) -GValueArray* g_value_array_sort_with_data (GValueArray *value_array, - GCompareDataFunc compare_func, - gpointer user_data); - - -G_END_DECLS - -#endif /* __G_VALUE_ARRAY_H__ */ -/* GObject - GLib Type, Object, Parameter and Signal Library - * Copyright (C) 1997-1999, 2000-2001 Tim Janik and Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General - * Public License along with this library; if not, see . - * - * gvaluetypes.h: GLib default values - */ -#ifndef __G_VALUETYPES_H__ -#define __G_VALUETYPES_H__ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - - -G_BEGIN_DECLS - -/* --- type macros --- */ -/** - * G_VALUE_HOLDS_CHAR: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_CHAR. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_CHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_CHAR)) -/** - * G_VALUE_HOLDS_UCHAR: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_UCHAR. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_UCHAR(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UCHAR)) -/** - * G_VALUE_HOLDS_BOOLEAN: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_BOOLEAN. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_BOOLEAN(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_BOOLEAN)) -/** - * G_VALUE_HOLDS_INT: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_INT. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_INT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT)) -/** - * G_VALUE_HOLDS_UINT: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_UINT. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_UINT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT)) -/** - * G_VALUE_HOLDS_LONG: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_LONG. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_LONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_LONG)) -/** - * G_VALUE_HOLDS_ULONG: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_ULONG. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_ULONG(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_ULONG)) -/** - * G_VALUE_HOLDS_INT64: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_INT64. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_INT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_INT64)) -/** - * G_VALUE_HOLDS_UINT64: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_UINT64. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_UINT64(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_UINT64)) -/** - * G_VALUE_HOLDS_FLOAT: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_FLOAT. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_FLOAT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_FLOAT)) -/** - * G_VALUE_HOLDS_DOUBLE: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_DOUBLE. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_DOUBLE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_DOUBLE)) -/** - * G_VALUE_HOLDS_STRING: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_STRING. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_STRING(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_STRING)) -/** - * G_VALUE_IS_INTERNED_STRING: - * @value: a valid #GValue structure - * - * Checks whether @value contains a string which is canonical. - * - * Returns: %TRUE if the value contains a string in its canonical - * representation, as returned by g_intern_string(). See also - * g_value_set_interned_string(). - * - * Since: 2.66 - */ -#define G_VALUE_IS_INTERNED_STRING(value) (G_VALUE_HOLDS_STRING (value) && ((value)->data[1].v_uint & G_VALUE_INTERNED_STRING)) GLIB_AVAILABLE_MACRO_IN_2_66 -/** - * G_VALUE_HOLDS_POINTER: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_POINTER. - * - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_POINTER(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_POINTER)) -/** - * G_TYPE_GTYPE: - * - * The type for #GType. - */ -#define G_TYPE_GTYPE (g_gtype_get_type()) -/** - * G_VALUE_HOLDS_GTYPE: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_GTYPE. - * - * Since: 2.12 - * Returns: %TRUE on success. - */ -#define G_VALUE_HOLDS_GTYPE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_GTYPE)) -/** - * G_VALUE_HOLDS_VARIANT: - * @value: a valid #GValue structure - * - * Checks whether the given #GValue can hold values of type %G_TYPE_VARIANT. - * - * Returns: %TRUE on success. - * - * Since: 2.26 - */ -#define G_VALUE_HOLDS_VARIANT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_VARIANT)) - - -/* --- prototypes --- */ -GLIB_DEPRECATED_IN_2_32_FOR(g_value_set_schar) -void g_value_set_char (GValue *value, - gchar v_char); -GLIB_DEPRECATED_IN_2_32_FOR(g_value_get_schar) -gchar g_value_get_char (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_schar (GValue *value, - gint8 v_char); -GLIB_AVAILABLE_IN_ALL -gint8 g_value_get_schar (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_uchar (GValue *value, - guchar v_uchar); -GLIB_AVAILABLE_IN_ALL -guchar g_value_get_uchar (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_boolean (GValue *value, - gboolean v_boolean); -GLIB_AVAILABLE_IN_ALL -gboolean g_value_get_boolean (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_int (GValue *value, - gint v_int); -GLIB_AVAILABLE_IN_ALL -gint g_value_get_int (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_uint (GValue *value, - guint v_uint); -GLIB_AVAILABLE_IN_ALL -guint g_value_get_uint (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_long (GValue *value, - glong v_long); -GLIB_AVAILABLE_IN_ALL -glong g_value_get_long (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_ulong (GValue *value, - gulong v_ulong); -GLIB_AVAILABLE_IN_ALL -gulong g_value_get_ulong (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_int64 (GValue *value, - gint64 v_int64); -GLIB_AVAILABLE_IN_ALL -gint64 g_value_get_int64 (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_uint64 (GValue *value, - guint64 v_uint64); -GLIB_AVAILABLE_IN_ALL -guint64 g_value_get_uint64 (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_float (GValue *value, - gfloat v_float); -GLIB_AVAILABLE_IN_ALL -gfloat g_value_get_float (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_double (GValue *value, - gdouble v_double); -GLIB_AVAILABLE_IN_ALL -gdouble g_value_get_double (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_string (GValue *value, - const gchar *v_string); -GLIB_AVAILABLE_IN_ALL -void g_value_set_static_string (GValue *value, - const gchar *v_string); -GLIB_AVAILABLE_IN_2_66 -void g_value_set_interned_string (GValue *value, - const gchar *v_string); -GLIB_AVAILABLE_IN_ALL -const gchar * g_value_get_string (const GValue *value); -GLIB_AVAILABLE_IN_ALL -gchar* g_value_dup_string (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_pointer (GValue *value, - gpointer v_pointer); -GLIB_AVAILABLE_IN_ALL -gpointer g_value_get_pointer (const GValue *value); -GLIB_AVAILABLE_IN_ALL -GType g_gtype_get_type (void); -GLIB_AVAILABLE_IN_ALL -void g_value_set_gtype (GValue *value, - GType v_gtype); -GLIB_AVAILABLE_IN_ALL -GType g_value_get_gtype (const GValue *value); -GLIB_AVAILABLE_IN_ALL -void g_value_set_variant (GValue *value, - GVariant *variant); -GLIB_AVAILABLE_IN_ALL -void g_value_take_variant (GValue *value, - GVariant *variant); -GLIB_AVAILABLE_IN_ALL -GVariant* g_value_get_variant (const GValue *value); -GLIB_AVAILABLE_IN_ALL -GVariant* g_value_dup_variant (const GValue *value); - - -/* Convenience for registering new pointer types */ -GLIB_AVAILABLE_IN_ALL -GType g_pointer_type_register_static (const gchar *name); - -/* debugging aid, describe value contents as string */ -GLIB_AVAILABLE_IN_ALL -gchar* g_strdup_value_contents (const GValue *value); - - -GLIB_AVAILABLE_IN_ALL -void g_value_take_string (GValue *value, - gchar *v_string); -GLIB_DEPRECATED_FOR(g_value_take_string) -void g_value_set_string_take_ownership (GValue *value, - gchar *v_string); - - -/* humpf, need a C representable type name for G_TYPE_STRING */ -/** - * gchararray: - * - * A C representable type name for #G_TYPE_STRING. - */ -typedef gchar* gchararray; - - -G_END_DECLS - -#endif /* __G_VALUETYPES_H__ */ - -/* - * Copyright © 2015 Canonical Limited - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - * - * Author: Ryan Lortie - */ - -#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) -#error "Only can be included directly." -#endif - -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GClosure, g_closure_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GEnumClass, g_type_class_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFlagsClass, g_type_class_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GObject, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInitiallyUnowned, g_object_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GParamSpec, g_param_spec_unref) -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTypeClass, g_type_class_unref) -G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GValue, g_value_unset) - -#undef __GLIB_GOBJECT_H_INSIDE__ - -GLIB_AVAILABLE_IN_2_68 -void gobject_init (void); - -#endif /* __GLIB_GOBJECT_H__ */ - -G_BEGIN_DECLS - -/* Enumerations from "gumdarwinmodule.h" */ -GType gum_darwin_module_flags_get_type (void) G_GNUC_CONST; -#define GUM_TYPE_DARWIN_MODULE_FLAGS (gum_darwin_module_flags_get_type ()) - -/* Enumerations from "gumdefs.h" */ -GType gum_cpu_type_get_type (void) G_GNUC_CONST; -#define GUM_TYPE_CPU_TYPE (gum_cpu_type_get_type ()) - -/* Enumerations from "guminterceptor.h" */ -GType gum_attach_return_get_type (void) G_GNUC_CONST; -#define GUM_TYPE_ATTACH_RETURN (gum_attach_return_get_type ()) -GType gum_replace_return_get_type (void) G_GNUC_CONST; -#define GUM_TYPE_REPLACE_RETURN (gum_replace_return_get_type ()) - -/* Enumerations from "gumprocess.h" */ -GType gum_code_signing_policy_get_type (void) G_GNUC_CONST; -#define GUM_TYPE_CODE_SIGNING_POLICY (gum_code_signing_policy_get_type ()) -G_END_DECLS - -#endif /* __GUM_ENUM_TYPES_H__ */ - -/* Generated data ends here */ - - -#if !defined (GUM_STATIC) && defined (G_OS_WIN32) -# ifdef GUM_EXPORTS -# define GUM_API __declspec(dllexport) -# else -# define GUM_API __declspec(dllimport) -# endif -#else -# define GUM_API -#endif - -#if !defined (__arm__) && !defined (__aarch64__) -# if GLIB_SIZEOF_VOID_P == 4 -# define GUM_NATIVE_CPU GUM_CPU_IA32 -# else -# define GUM_NATIVE_CPU GUM_CPU_AMD64 -# endif -#elif defined (__arm__) || defined (__aarch64__) -# if GLIB_SIZEOF_VOID_P == 4 -# define GUM_NATIVE_CPU GUM_CPU_ARM -# else -# define GUM_NATIVE_CPU GUM_CPU_ARM64 -# endif -#elif defined (__mips__) -# define GUM_NATIVE_CPU GUM_CPU_MIPS -#endif -#ifdef G_OS_WIN32 -# define GUM_NATIVE_ABI GUM_ABI_WINDOWS -# define GUM_NATIVE_ABI_IS_WINDOWS 1 -# define GUM_NATIVE_ABI_IS_UNIX 0 -#else -# define GUM_NATIVE_ABI GUM_ABI_UNIX -# define GUM_NATIVE_ABI_IS_WINDOWS 0 -# define GUM_NATIVE_ABI_IS_UNIX 1 -#endif - -G_BEGIN_DECLS - -typedef guint64 GumAddress; -#define GUM_ADDRESS(a) ((GumAddress) (guintptr) (a)) -#define GUM_TYPE_ADDRESS (gum_address_get_type ()) -typedef guint GumOS; -typedef guint GumCallingConvention; -typedef guint GumAbiType; -typedef guint GumCpuFeatures; -typedef guint GumInstructionEncoding; -typedef guint GumArgType; -typedef struct _GumArgument GumArgument; -typedef guint GumBranchHint; -typedef struct _GumIA32CpuContext GumIA32CpuContext; -typedef struct _GumX64CpuContext GumX64CpuContext; -typedef struct _GumArmCpuContext GumArmCpuContext; -typedef struct _GumArm64CpuContext GumArm64CpuContext; -typedef struct _GumMipsCpuContext GumMipsCpuContext; -/* - * The only non-legacy big-endian configuration on 32-bit ARM systems is BE8. - * In this configuration, whilst the data is in big-endian, the code stream is - * still in little-endian. Since Capstone is disassembling the code stream, it - * should work in little-endian even on BE8 systems. - */ -#if G_BYTE_ORDER == G_LITTLE_ENDIAN || defined (__arm__) -# define GUM_DEFAULT_CS_ENDIAN CS_MODE_LITTLE_ENDIAN -#else -# define GUM_DEFAULT_CS_ENDIAN CS_MODE_BIG_ENDIAN -#endif -#if !defined (__arm__) && !defined (__aarch64__) && !defined (__mips__) -# define GUM_DEFAULT_CS_ARCH CS_ARCH_X86 -# if GLIB_SIZEOF_VOID_P == 4 -/** - * GUM_DEFAULT_CS_MODE: (skip) - */ -# define GUM_DEFAULT_CS_MODE CS_MODE_32 -typedef GumIA32CpuContext GumCpuContext; -# else -/** - * GUM_DEFAULT_CS_MODE: (skip) - */ -# define GUM_DEFAULT_CS_MODE CS_MODE_64 -typedef GumX64CpuContext GumCpuContext; -# endif -#elif defined (__arm__) && !defined (__aarch64__) -# define GUM_DEFAULT_CS_ARCH CS_ARCH_ARM -/** - * GUM_DEFAULT_CS_MODE: (skip) - */ -# define GUM_DEFAULT_CS_MODE \ - ((cs_mode) (CS_MODE_ARM | CS_MODE_V8 | GUM_DEFAULT_CS_ENDIAN)) -# define GUM_PSR_T_BIT 0x20 -typedef GumArmCpuContext GumCpuContext; -#elif defined (__aarch64__) -# define GUM_DEFAULT_CS_ARCH CS_ARCH_ARM64 -/** - * GUM_DEFAULT_CS_MODE: (skip) - */ -# define GUM_DEFAULT_CS_MODE GUM_DEFAULT_CS_ENDIAN -typedef GumArm64CpuContext GumCpuContext; -#elif defined (__mips__) -# define GUM_DEFAULT_CS_ARCH CS_ARCH_MIPS -# if GLIB_SIZEOF_VOID_P == 4 -/** - * GUM_DEFAULT_CS_MODE: (skip) - */ -# define GUM_DEFAULT_CS_MODE ((cs_mode) \ - (CS_MODE_MIPS32 | GUM_DEFAULT_CS_ENDIAN)) -# else -/** - * GUM_DEFAULT_CS_MODE: (skip) - */ -# define GUM_DEFAULT_CS_MODE ((cs_mode) \ - (CS_MODE_MIPS64 | GUM_DEFAULT_CS_ENDIAN)) -# endif -typedef GumMipsCpuContext GumCpuContext; -#endif -typedef guint GumRelocationScenario; - -enum _GumOS -{ - GUM_OS_WINDOWS, - GUM_OS_MACOS, - GUM_OS_LINUX, - GUM_OS_IOS, - GUM_OS_ANDROID, - GUM_OS_QNX -}; - -enum _GumCallingConvention -{ - GUM_CALL_CAPI, - GUM_CALL_SYSAPI -}; - -enum _GumAbiType -{ - GUM_ABI_UNIX, - GUM_ABI_WINDOWS -}; - -typedef enum { - GUM_CPU_INVALID, - GUM_CPU_IA32, - GUM_CPU_AMD64, - GUM_CPU_ARM, - GUM_CPU_ARM64, - GUM_CPU_MIPS -} GumCpuType; - -enum _GumCpuFeatures -{ - GUM_CPU_AVX2 = 1 << 0, - GUM_CPU_VFP2 = 1 << 1, - GUM_CPU_VFP3 = 1 << 2, - GUM_CPU_PTRAUTH = 1 << 3, -}; - -enum _GumInstructionEncoding -{ - GUM_INSTRUCTION_DEFAULT, - GUM_INSTRUCTION_SPECIAL -}; - -enum _GumArgType -{ - GUM_ARG_ADDRESS, - GUM_ARG_REGISTER -}; - -struct _GumArgument -{ - GumArgType type; - - union - { - GumAddress address; - gint reg; - } value; -}; - -enum _GumBranchHint -{ - GUM_NO_HINT, - GUM_LIKELY, - GUM_UNLIKELY -}; - -struct _GumIA32CpuContext -{ - guint32 eip; - - guint32 edi; - guint32 esi; - guint32 ebp; - guint32 esp; - guint32 ebx; - guint32 edx; - guint32 ecx; - guint32 eax; -}; - -struct _GumX64CpuContext -{ - guint64 rip; - - guint64 r15; - guint64 r14; - guint64 r13; - guint64 r12; - guint64 r11; - guint64 r10; - guint64 r9; - guint64 r8; - - guint64 rdi; - guint64 rsi; - guint64 rbp; - guint64 rsp; - guint64 rbx; - guint64 rdx; - guint64 rcx; - guint64 rax; -}; - -struct _GumArmCpuContext -{ - guint32 cpsr; - guint32 pc; - guint32 sp; - - guint32 r8; - guint32 r9; - guint32 r10; - guint32 r11; - guint32 r12; - - guint32 r[8]; - guint32 lr; -}; - -struct _GumArm64CpuContext -{ - guint64 pc; - guint64 sp; - - guint64 x[29]; - guint64 fp; - guint64 lr; - guint8 q[128]; -}; - -struct _GumMipsCpuContext -{ - /* - * This structure represents the register state pushed onto the stack by the - * trampoline which allows us to vector from the original minimal assembly - * hook to architecture agnostic C code inside frida-gum. These registers are - * natively sized. Even if some have not been expanded to 64-bits from the - * MIPS32 architecture MIPS can only perform aligned data access and as such - * pushing zero extended values is simpler than attempting to push minimally - * sized data types. - */ - gsize pc; - - gsize gp; - gsize sp; - gsize fp; - gsize ra; - - gsize hi; - gsize lo; - - gsize at; - - gsize v0; - gsize v1; - - gsize a0; - gsize a1; - gsize a2; - gsize a3; - - gsize t0; - gsize t1; - gsize t2; - gsize t3; - gsize t4; - gsize t5; - gsize t6; - gsize t7; - gsize t8; - gsize t9; - - gsize s0; - gsize s1; - gsize s2; - gsize s3; - gsize s4; - gsize s5; - gsize s6; - gsize s7; - - gsize k0; - gsize k1; -}; - -enum _GumRelocationScenario -{ - GUM_SCENARIO_OFFLINE, - GUM_SCENARIO_ONLINE -}; - -#ifndef __arm__ -# if GLIB_SIZEOF_VOID_P == 8 -# define GUM_CPU_CONTEXT_XAX(c) ((c)->rax) -# define GUM_CPU_CONTEXT_XCX(c) ((c)->rcx) -# define GUM_CPU_CONTEXT_XDX(c) ((c)->rdx) -# define GUM_CPU_CONTEXT_XBX(c) ((c)->rbx) -# define GUM_CPU_CONTEXT_XSP(c) ((c)->rsp) -# define GUM_CPU_CONTEXT_XBP(c) ((c)->rbp) -# define GUM_CPU_CONTEXT_XSI(c) ((c)->rsi) -# define GUM_CPU_CONTEXT_XDI(c) ((c)->rdi) -# define GUM_CPU_CONTEXT_XIP(c) ((c)->rip) -# define GUM_CPU_CONTEXT_OFFSET_XAX (G_STRUCT_OFFSET (GumCpuContext, rax)) -# define GUM_CPU_CONTEXT_OFFSET_XCX (G_STRUCT_OFFSET (GumCpuContext, rcx)) -# define GUM_CPU_CONTEXT_OFFSET_XDX (G_STRUCT_OFFSET (GumCpuContext, rdx)) -# define GUM_CPU_CONTEXT_OFFSET_XBX (G_STRUCT_OFFSET (GumCpuContext, rbx)) -# define GUM_CPU_CONTEXT_OFFSET_XSP (G_STRUCT_OFFSET (GumCpuContext, rsp)) -# define GUM_CPU_CONTEXT_OFFSET_XBP (G_STRUCT_OFFSET (GumCpuContext, rbp)) -# define GUM_CPU_CONTEXT_OFFSET_XSI (G_STRUCT_OFFSET (GumCpuContext, rsi)) -# define GUM_CPU_CONTEXT_OFFSET_XDI (G_STRUCT_OFFSET (GumCpuContext, rdi)) -# define GUM_CPU_CONTEXT_OFFSET_XIP (G_STRUCT_OFFSET (GumCpuContext, rip)) -# else -# define GUM_CPU_CONTEXT_XAX(c) ((c)->eax) -# define GUM_CPU_CONTEXT_XCX(c) ((c)->ecx) -# define GUM_CPU_CONTEXT_XDX(c) ((c)->edx) -# define GUM_CPU_CONTEXT_XBX(c) ((c)->ebx) -# define GUM_CPU_CONTEXT_XSP(c) ((c)->esp) -# define GUM_CPU_CONTEXT_XBP(c) ((c)->ebp) -# define GUM_CPU_CONTEXT_XSI(c) ((c)->esi) -# define GUM_CPU_CONTEXT_XDI(c) ((c)->edi) -# define GUM_CPU_CONTEXT_XIP(c) ((c)->eip) -# define GUM_CPU_CONTEXT_OFFSET_XAX (G_STRUCT_OFFSET (GumCpuContext, eax)) -# define GUM_CPU_CONTEXT_OFFSET_XCX (G_STRUCT_OFFSET (GumCpuContext, ecx)) -# define GUM_CPU_CONTEXT_OFFSET_XDX (G_STRUCT_OFFSET (GumCpuContext, edx)) -# define GUM_CPU_CONTEXT_OFFSET_XBX (G_STRUCT_OFFSET (GumCpuContext, ebx)) -# define GUM_CPU_CONTEXT_OFFSET_XSP (G_STRUCT_OFFSET (GumCpuContext, esp)) -# define GUM_CPU_CONTEXT_OFFSET_XBP (G_STRUCT_OFFSET (GumCpuContext, ebp)) -# define GUM_CPU_CONTEXT_OFFSET_XSI (G_STRUCT_OFFSET (GumCpuContext, esi)) -# define GUM_CPU_CONTEXT_OFFSET_XDI (G_STRUCT_OFFSET (GumCpuContext, edi)) -# define GUM_CPU_CONTEXT_OFFSET_XIP (G_STRUCT_OFFSET (GumCpuContext, eip)) -# endif -#endif - -#define GUM_MAX_PATH 260 -#define GUM_MAX_TYPE_NAME 16 -#define GUM_MAX_SYMBOL_NAME 2048 - -#define GUM_MAX_THREADS 768 -#define GUM_MAX_CALL_DEPTH 32 -#define GUM_MAX_BACKTRACE_DEPTH 16 -#define GUM_MAX_WORST_CASE_INFO_SIZE 128 - -#define GUM_MAX_LISTENERS_PER_FUNCTION 2 -#define GUM_MAX_LISTENER_DATA 512 - -#define GUM_MAX_THREAD_RANGES 2 - -#if GLIB_SIZEOF_VOID_P == 8 -#define GUM_CPU_MODE CS_MODE_64 -#define GUM_THUNK -#else -#define GUM_CPU_MODE CS_MODE_32 -#define GUM_THUNK GUM_FASTCALL -#endif -#if !defined (G_OS_WIN32) && GLIB_SIZEOF_VOID_P == 8 -# define GUM_THUNK_REG_ARG0 GUM_REG_XDI -# define GUM_THUNK_REG_ARG1 GUM_REG_XSI -#else -# define GUM_THUNK_REG_ARG0 GUM_REG_XCX -# define GUM_THUNK_REG_ARG1 GUM_REG_XDX -#endif -#define GUM_RED_ZONE_SIZE 128 - -#ifdef _MSC_VER -# define GUM_CDECL __cdecl -# define GUM_STDCALL __stdcall -# define GUM_FASTCALL __fastcall -# define GUM_NOINLINE __declspec (noinline) -#else -# ifndef __arm__ -# if GLIB_SIZEOF_VOID_P == 4 -# define GUM_CDECL __attribute__((cdecl)) -# define GUM_STDCALL __attribute__((stdcall)) -# else -# define GUM_CDECL -# define GUM_STDCALL -# endif -# define GUM_FASTCALL __attribute__((fastcall)) -# else -# define GUM_CDECL -# define GUM_STDCALL -# define GUM_FASTCALL -# endif -# define GUM_NOINLINE __attribute__((noinline)) -#endif - -#define GUM_ALIGN_POINTER(t, p, b) \ - ((t) GSIZE_TO_POINTER (((GPOINTER_TO_SIZE (p) + ((gsize) (b - 1))) & \ - ~((gsize) (b - 1))))) -#define GUM_ALIGN_SIZE(s, b) \ - ((((gsize) s) + ((gsize) (b - 1))) & ~((gsize) (b - 1))) - -#define GUM_FUNCPTR_TO_POINTER(f) (GSIZE_TO_POINTER (f)) -#define GUM_POINTER_TO_FUNCPTR(t, p) ((t) GPOINTER_TO_SIZE (p)) - -#define GUM_INT2_MASK 0x00000003U -#define GUM_INT4_MASK 0x0000000fU -#define GUM_INT5_MASK 0x0000001fU -#define GUM_INT6_MASK 0x0000003fU -#define GUM_INT8_MASK 0x000000ffU -#define GUM_INT10_MASK 0x000003ffU -#define GUM_INT11_MASK 0x000007ffU -#define GUM_INT12_MASK 0x00000fffU -#define GUM_INT14_MASK 0x00003fffU -#define GUM_INT16_MASK 0x0000ffffU -#define GUM_INT18_MASK 0x0003ffffU -#define GUM_INT19_MASK 0x0007ffffU -#define GUM_INT24_MASK 0x00ffffffU -#define GUM_INT26_MASK 0x03ffffffU -#define GUM_INT28_MASK 0x0fffffffU -#define GUM_INT32_MASK 0xffffffffU - -#define GUM_IS_WITHIN_UINT7_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (0) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (127)) -#define GUM_IS_WITHIN_UINT8_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (0) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (255)) -#define GUM_IS_WITHIN_INT8_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-128) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (127)) -#define GUM_IS_WITHIN_INT11_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-1024) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (1023)) -#define GUM_IS_WITHIN_INT14_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-8192) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (8191)) -#define GUM_IS_WITHIN_INT16_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-32768) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (32767)) -#define GUM_IS_WITHIN_INT18_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-131072) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (131071)) -#define GUM_IS_WITHIN_INT19_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-262144) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (262143)) -#define GUM_IS_WITHIN_INT20_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-524288) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (524287)) -#define GUM_IS_WITHIN_INT21_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-1048576) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (1048575)) -#define GUM_IS_WITHIN_INT24_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-8388608) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (8388607)) -#define GUM_IS_WITHIN_INT26_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-33554432) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (33554431)) -#define GUM_IS_WITHIN_INT28_RANGE(i) \ - (((gint64) (i)) >= G_GINT64_CONSTANT (-134217728) && \ - ((gint64) (i)) <= G_GINT64_CONSTANT (134217727)) -#define GUM_IS_WITHIN_INT32_RANGE(i) \ - (((gint64) (i)) >= (gint64) G_MININT32 && \ - ((gint64) (i)) <= (gint64) G_MAXINT32) - -GUM_API GumCpuFeatures gum_query_cpu_features (void); - -GUM_API gpointer gum_cpu_context_get_nth_argument (GumCpuContext * self, - guint n); -GUM_API void gum_cpu_context_replace_nth_argument (GumCpuContext * self, - guint n, gpointer value); -GUM_API gpointer gum_cpu_context_get_return_value (GumCpuContext * self); -GUM_API void gum_cpu_context_replace_return_value (GumCpuContext * self, - gpointer value); - -GUM_API GType gum_address_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif - -/* - * Copyright (C) 2016-2018 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_API_RESOLVER_H__ -#define __GUM_API_RESOLVER_H__ - - -G_BEGIN_DECLS - -#define GUM_TYPE_API_RESOLVER (gum_api_resolver_get_type ()) -G_DECLARE_INTERFACE (GumApiResolver, gum_api_resolver, GUM, API_RESOLVER, - GObject) - -typedef struct _GumApiDetails GumApiDetails; - -typedef gboolean (* GumFoundApiFunc) (const GumApiDetails * details, - gpointer user_data); - -struct _GumApiResolverInterface -{ - GTypeInterface parent; - - void (* enumerate_matches) (GumApiResolver * self, const gchar * query, - GumFoundApiFunc func, gpointer user_data, GError ** error); -}; - -struct _GumApiDetails -{ - const gchar * name; - GumAddress address; -}; - -GUM_API GumApiResolver * gum_api_resolver_make (const gchar * type); - -GUM_API void gum_api_resolver_enumerate_matches (GumApiResolver * self, - const gchar * query, GumFoundApiFunc func, gpointer user_data, - GError ** error); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2008-2018 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_BACKTRACER_H__ -#define __GUM_BACKTRACER_H__ - -/* - * Copyright (C) 2008-2010 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_RETURN_ADDRESS_H__ -#define __GUM_RETURN_ADDRESS_H__ - - -typedef struct _GumReturnAddressDetails GumReturnAddressDetails; -typedef gpointer GumReturnAddress; -typedef struct _GumReturnAddressArray GumReturnAddressArray; - -struct _GumReturnAddressDetails -{ - GumReturnAddress address; - gchar module_name[GUM_MAX_PATH + 1]; - gchar function_name[GUM_MAX_SYMBOL_NAME + 1]; - gchar file_name[GUM_MAX_PATH + 1]; - guint line_number; -}; - -struct _GumReturnAddressArray -{ - guint len; - GumReturnAddress items[GUM_MAX_BACKTRACE_DEPTH]; -}; - -G_BEGIN_DECLS - -GUM_API gboolean gum_return_address_details_from_address ( - GumReturnAddress address, GumReturnAddressDetails * details); - -GUM_API gboolean gum_return_address_array_is_equal ( - const GumReturnAddressArray * array1, - const GumReturnAddressArray * array2); - -G_END_DECLS - -#endif - -G_BEGIN_DECLS - -#define GUM_TYPE_BACKTRACER (gum_backtracer_get_type ()) -G_DECLARE_INTERFACE (GumBacktracer, gum_backtracer, GUM, BACKTRACER, GObject) - -struct _GumBacktracerInterface -{ - GTypeInterface parent; - - void (* generate) (GumBacktracer * self, const GumCpuContext * cpu_context, - GumReturnAddressArray * return_addresses); -}; - -GUM_API GumBacktracer * gum_backtracer_make_accurate (void); -GUM_API GumBacktracer * gum_backtracer_make_fuzzy (void); - -GUM_API void gum_backtracer_generate (GumBacktracer * self, - const GumCpuContext * cpu_context, - GumReturnAddressArray * return_addresses); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2017-2018 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_CLOAK_H__ -#define __GUM_CLOAK_H__ - -/* - * Copyright (C) 2008-2020 Ole André Vadla Ravnås - * Copyright (C) 2008 Christian Berentsen - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_MEMORY_H__ -#define __GUM_MEMORY_H__ - - -#define GUM_TYPE_MEMORY_RANGE (gum_memory_range_get_type ()) -#define GUM_MEMORY_RANGE_INCLUDES(r, a) ((a) >= (r)->base_address && \ - (a) < ((r)->base_address + (r)->size)) - -#define GUM_PAGE_RW ((GumPageProtection) (GUM_PAGE_READ | GUM_PAGE_WRITE)) -#define GUM_PAGE_RX ((GumPageProtection) (GUM_PAGE_READ | GUM_PAGE_EXECUTE)) -#define GUM_PAGE_RWX ((GumPageProtection) (GUM_PAGE_READ | GUM_PAGE_WRITE | \ - GUM_PAGE_EXECUTE)) - -G_BEGIN_DECLS - -typedef guint GumPtrauthSupport; -typedef guint GumRwxSupport; -typedef guint GumMemoryOperation; -typedef guint GumPageProtection; -typedef struct _GumAddressSpec GumAddressSpec; -typedef struct _GumMemoryRange GumMemoryRange; -typedef struct _GumMatchPattern GumMatchPattern; - -typedef gboolean (* GumMemoryIsNearFunc) (gpointer memory, gpointer address); - -enum _GumPtrauthSupport -{ - GUM_PTRAUTH_INVALID, - GUM_PTRAUTH_UNSUPPORTED, - GUM_PTRAUTH_SUPPORTED -}; - -enum _GumRwxSupport -{ - GUM_RWX_NONE, - GUM_RWX_ALLOCATIONS_ONLY, - GUM_RWX_FULL -}; - -enum _GumMemoryOperation -{ - GUM_MEMOP_INVALID, - GUM_MEMOP_READ, - GUM_MEMOP_WRITE, - GUM_MEMOP_EXECUTE -}; - -enum _GumPageProtection -{ - GUM_PAGE_NO_ACCESS = 0, - GUM_PAGE_READ = (1 << 0), - GUM_PAGE_WRITE = (1 << 1), - GUM_PAGE_EXECUTE = (1 << 2), -}; - -struct _GumAddressSpec -{ - gpointer near_address; - gsize max_distance; -}; - -struct _GumMemoryRange -{ - GumAddress base_address; - gsize size; -}; - -typedef void (* GumMemoryPatchApplyFunc) (gpointer mem, gpointer user_data); -typedef gboolean (* GumMemoryScanMatchFunc) (GumAddress address, gsize size, - gpointer user_data); - -GUM_API void gum_internal_heap_ref (void); -GUM_API void gum_internal_heap_unref (void); - -GUM_API gpointer gum_sign_code_pointer (gpointer value); -GUM_API gpointer gum_strip_code_pointer (gpointer value); -GUM_API GumAddress gum_sign_code_address (GumAddress value); -GUM_API GumAddress gum_strip_code_address (GumAddress value); -GUM_API GumPtrauthSupport gum_query_ptrauth_support (void); -GUM_API guint gum_query_page_size (void); -GUM_API gboolean gum_query_is_rwx_supported (void); -GUM_API GumRwxSupport gum_query_rwx_support (void); -GUM_API gboolean gum_memory_is_readable (gconstpointer address, gsize len); -GUM_API guint8 * gum_memory_read (gconstpointer address, gsize len, - gsize * n_bytes_read); -GUM_API gboolean gum_memory_write (gpointer address, const guint8 * bytes, - gsize len); -GUM_API gboolean gum_memory_patch_code (gpointer address, gsize size, - GumMemoryPatchApplyFunc apply, gpointer apply_data); -GUM_API gboolean gum_memory_mark_code (gpointer address, gsize size); - -GUM_API void gum_memory_scan (const GumMemoryRange * range, - const GumMatchPattern * pattern, GumMemoryScanMatchFunc func, - gpointer user_data); - -GUM_API GumMatchPattern * gum_match_pattern_new_from_string ( - const gchar * match_combined_str); -GUM_API void gum_match_pattern_free (GumMatchPattern * pattern); - -GUM_API void gum_ensure_code_readable (gconstpointer address, gsize size); - -GUM_API void gum_mprotect (gpointer address, gsize size, - GumPageProtection page_prot); -GUM_API gboolean gum_try_mprotect (gpointer address, gsize size, - GumPageProtection page_prot); - -GUM_API void gum_clear_cache (gpointer address, gsize size); - -#define gum_new(struct_type, n_structs) \ - ((struct_type *) gum_malloc (n_structs * sizeof (struct_type))) -#define gum_new0(struct_type, n_structs) \ - ((struct_type *) gum_malloc0 (n_structs * sizeof (struct_type))) - -GUM_API guint gum_peek_private_memory_usage (void); - -GUM_API gpointer gum_malloc (gsize size); -GUM_API gpointer gum_malloc0 (gsize size); -GUM_API gsize gum_malloc_usable_size (gconstpointer mem); -GUM_API gpointer gum_calloc (gsize count, gsize size); -GUM_API gpointer gum_realloc (gpointer mem, gsize size); -GUM_API gpointer gum_memalign (gsize alignment, gsize size); -GUM_API gpointer gum_memdup (gconstpointer mem, gsize byte_size); -GUM_API void gum_free (gpointer mem); - -GUM_API gpointer gum_alloc_n_pages (guint n_pages, GumPageProtection page_prot); -GUM_API gpointer gum_try_alloc_n_pages (guint n_pages, - GumPageProtection page_prot); -GUM_API gpointer gum_alloc_n_pages_near (guint n_pages, - GumPageProtection page_prot, const GumAddressSpec * address_spec); -GUM_API gpointer gum_try_alloc_n_pages_near (guint n_pages, - GumPageProtection page_prot, const GumAddressSpec * address_spec); -GUM_API void gum_query_page_allocation_range (gconstpointer mem, guint size, - GumMemoryRange * range); -GUM_API void gum_free_pages (gpointer mem); - -GUM_API gpointer gum_memory_allocate (gpointer address, gsize size, - gsize alignment, GumPageProtection page_prot); -GUM_API gboolean gum_memory_free (gpointer address, gsize size); -GUM_API gboolean gum_memory_release (gpointer address, gsize size); -GUM_API gboolean gum_memory_commit (gpointer address, gsize size, - GumPageProtection page_prot); -GUM_API gboolean gum_memory_decommit (gpointer address, gsize size); - -GUM_API GType gum_memory_range_get_type (void) G_GNUC_CONST; -GUM_API GumMemoryRange * gum_memory_range_copy (const GumMemoryRange * range); -GUM_API void gum_memory_range_free (GumMemoryRange * range); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2008-2020 Ole André Vadla Ravnås - * Copyright (C) 2020 Francesco Tamagni - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_PROCESS_H__ -#define __GUM_PROCESS_H__ - - -#define GUM_THREAD_ID_INVALID ((GumThreadId) -1) - -#define GUM_TYPE_MODULE_DETAILS (gum_module_details_get_type ()) - -G_BEGIN_DECLS - -typedef guint GumProcessId; -typedef gsize GumThreadId; -typedef guint GumThreadState; -typedef struct _GumThreadDetails GumThreadDetails; -typedef struct _GumModuleDetails GumModuleDetails; -typedef guint GumImportType; -typedef guint GumExportType; -typedef guint GumSymbolType; -typedef struct _GumImportDetails GumImportDetails; -typedef struct _GumExportDetails GumExportDetails; -typedef struct _GumSymbolDetails GumSymbolDetails; -typedef struct _GumSymbolSection GumSymbolSection; -typedef struct _GumRangeDetails GumRangeDetails; -typedef struct _GumFileMapping GumFileMapping; -typedef struct _GumMallocRangeDetails GumMallocRangeDetails; - -typedef enum { - GUM_CODE_SIGNING_OPTIONAL, - GUM_CODE_SIGNING_REQUIRED -} GumCodeSigningPolicy; - -enum _GumThreadState -{ - GUM_THREAD_RUNNING = 1, - GUM_THREAD_STOPPED, - GUM_THREAD_WAITING, - GUM_THREAD_UNINTERRUPTIBLE, - GUM_THREAD_HALTED -}; - -struct _GumThreadDetails -{ - GumThreadId id; - GumThreadState state; - GumCpuContext cpu_context; -}; - -struct _GumModuleDetails -{ - const gchar * name; - const GumMemoryRange * range; - const gchar * path; -}; - -enum _GumImportType -{ - GUM_IMPORT_UNKNOWN, - GUM_IMPORT_FUNCTION, - GUM_IMPORT_VARIABLE -}; - -enum _GumExportType -{ - GUM_EXPORT_FUNCTION = 1, - GUM_EXPORT_VARIABLE -}; - -enum _GumSymbolType -{ - /* Common */ - GUM_SYMBOL_UNKNOWN, - GUM_SYMBOL_SECTION, - - /* Mach-O */ - GUM_SYMBOL_UNDEFINED, - GUM_SYMBOL_ABSOLUTE, - GUM_SYMBOL_PREBOUND_UNDEFINED, - GUM_SYMBOL_INDIRECT, - - /* ELF */ - GUM_SYMBOL_OBJECT, - GUM_SYMBOL_FUNCTION, - GUM_SYMBOL_FILE, - GUM_SYMBOL_COMMON, - GUM_SYMBOL_TLS, -}; - -struct _GumImportDetails -{ - GumImportType type; - const gchar * name; - const gchar * module; - GumAddress address; - GumAddress slot; -}; - -struct _GumExportDetails -{ - GumExportType type; - const gchar * name; - GumAddress address; -}; - -struct _GumSymbolDetails -{ - gboolean is_global; - GumSymbolType type; - const GumSymbolSection * section; - const gchar * name; - GumAddress address; - gssize size; -}; - -struct _GumSymbolSection -{ - const gchar * id; - GumPageProtection protection; -}; - -struct _GumRangeDetails -{ - const GumMemoryRange * range; - GumPageProtection protection; - const GumFileMapping * file; -}; - -struct _GumFileMapping -{ - const gchar * path; - guint64 offset; - gsize size; -}; - -struct _GumMallocRangeDetails -{ - const GumMemoryRange * range; -}; - -typedef void (* GumModifyThreadFunc) (GumThreadId thread_id, - GumCpuContext * cpu_context, gpointer user_data); -typedef gboolean (* GumFoundThreadFunc) (const GumThreadDetails * details, - gpointer user_data); -typedef gboolean (* GumFoundModuleFunc) (const GumModuleDetails * details, - gpointer user_data); -typedef gboolean (* GumFoundImportFunc) (const GumImportDetails * details, - gpointer user_data); -typedef gboolean (* GumFoundExportFunc) (const GumExportDetails * details, - gpointer user_data); -typedef gboolean (* GumFoundSymbolFunc) (const GumSymbolDetails * details, - gpointer user_data); -typedef gboolean (* GumFoundRangeFunc) (const GumRangeDetails * details, - gpointer user_data); -typedef gboolean (* GumFoundMallocRangeFunc) ( - const GumMallocRangeDetails * details, gpointer user_data); - -GUM_API GumOS gum_process_get_native_os (void); -GUM_API GumCodeSigningPolicy gum_process_get_code_signing_policy (void); -GUM_API void gum_process_set_code_signing_policy (GumCodeSigningPolicy policy); -GUM_API const gchar * gum_process_query_libc_name (void); -GUM_API gboolean gum_process_is_debugger_attached (void); -GUM_API GumProcessId gum_process_get_id (void); -GUM_API GumThreadId gum_process_get_current_thread_id (void); -GUM_API gboolean gum_process_has_thread (GumThreadId thread_id); -GUM_API gboolean gum_process_modify_thread (GumThreadId thread_id, - GumModifyThreadFunc func, gpointer user_data); -GUM_API void gum_process_enumerate_threads (GumFoundThreadFunc func, - gpointer user_data); -GUM_API void gum_process_enumerate_modules (GumFoundModuleFunc func, - gpointer user_data); -GUM_API void gum_process_enumerate_ranges (GumPageProtection prot, - GumFoundRangeFunc func, gpointer user_data); -GUM_API void gum_process_enumerate_malloc_ranges ( - GumFoundMallocRangeFunc func, gpointer user_data); -GUM_API guint gum_thread_try_get_ranges (GumMemoryRange * ranges, - guint max_length); -GUM_API gint gum_thread_get_system_error (void); -GUM_API void gum_thread_set_system_error (gint value); -GUM_API gboolean gum_module_load (const gchar * module_name, GError ** error); -GUM_API gboolean gum_module_ensure_initialized (const gchar * module_name); -GUM_API void gum_module_enumerate_imports (const gchar * module_name, - GumFoundImportFunc func, gpointer user_data); -GUM_API void gum_module_enumerate_exports (const gchar * module_name, - GumFoundExportFunc func, gpointer user_data); -GUM_API void gum_module_enumerate_symbols (const gchar * module_name, - GumFoundSymbolFunc func, gpointer user_data); -GUM_API void gum_module_enumerate_ranges (const gchar * module_name, - GumPageProtection prot, GumFoundRangeFunc func, gpointer user_data); -GUM_API GumAddress gum_module_find_base_address (const gchar * module_name); -GUM_API GumAddress gum_module_find_export_by_name (const gchar * module_name, - const gchar * symbol_name); -GUM_API GumAddress gum_module_find_symbol_by_name (const gchar * module_name, - const gchar * symbol_name); - -GUM_API const gchar * gum_code_signing_policy_to_string ( - GumCodeSigningPolicy policy); - -GUM_API GType gum_module_details_get_type (void) G_GNUC_CONST; -GUM_API GumModuleDetails * gum_module_details_copy ( - const GumModuleDetails * module); -GUM_API void gum_module_details_free (GumModuleDetails * module); - -GUM_API const gchar * gum_symbol_type_to_string (GumSymbolType type); - -G_END_DECLS - -#endif - -G_BEGIN_DECLS - -typedef gboolean (* GumCloakFoundThreadFunc) (GumThreadId id, - gpointer user_data); -typedef gboolean (* GumCloakFoundRangeFunc) (const GumMemoryRange * range, - gpointer user_data); -typedef gboolean (* GumCloakFoundFDFunc) (gint fd, gpointer user_data); - -GUM_API void gum_cloak_add_thread (GumThreadId id); -GUM_API void gum_cloak_remove_thread (GumThreadId id); -GUM_API gboolean gum_cloak_has_thread (GumThreadId id); -GUM_API void gum_cloak_enumerate_threads (GumCloakFoundThreadFunc func, - gpointer user_data); - -GUM_API void gum_cloak_add_range (const GumMemoryRange * range); -GUM_API void gum_cloak_remove_range (const GumMemoryRange * range); -GUM_API GArray * gum_cloak_clip_range (const GumMemoryRange * range); -GUM_API void gum_cloak_enumerate_ranges (GumCloakFoundRangeFunc func, - gpointer user_data); - -GUM_API void gum_cloak_add_file_descriptor (gint fd); -GUM_API void gum_cloak_remove_file_descriptor (gint fd); -GUM_API gboolean gum_cloak_has_file_descriptor (gint fd); -GUM_API void gum_cloak_enumerate_file_descriptors (GumCloakFoundFDFunc func, - gpointer user_data); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2010 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_CODE_ALLOCATOR_H__ -#define __GUM_CODE_ALLOCATOR_H__ - - -typedef struct _GumCodeAllocator GumCodeAllocator; -typedef struct _GumCodeSlice GumCodeSlice; -typedef struct _GumCodeDeflector GumCodeDeflector; - -struct _GumCodeAllocator -{ - gsize slice_size; - gsize pages_per_batch; - gsize slices_per_batch; - gsize pages_metadata_size; - - GSList * uncommitted_pages; - GHashTable * dirty_pages; - GList * free_slices; - - GSList * dispatchers; -}; - -struct _GumCodeSlice -{ - gpointer data; - gsize size; -}; - -struct _GumCodeDeflector -{ - gpointer return_address; - gpointer target; - gpointer trampoline; -}; - -void gum_code_allocator_init (GumCodeAllocator * allocator, gsize slice_size); -void gum_code_allocator_free (GumCodeAllocator * allocator); - -GumCodeSlice * gum_code_allocator_alloc_slice (GumCodeAllocator * self); -GumCodeSlice * gum_code_allocator_try_alloc_slice_near (GumCodeAllocator * self, - const GumAddressSpec * spec, gsize alignment); -void gum_code_allocator_commit (GumCodeAllocator * self); -void gum_code_slice_free (GumCodeSlice * slice); - -GumCodeDeflector * gum_code_allocator_alloc_deflector (GumCodeAllocator * self, - const GumAddressSpec * caller, gpointer return_address, gpointer target, - gboolean dedicated); -void gum_code_deflector_free (GumCodeDeflector * deflector); - -#endif -/* - * Copyright (C) 2016-2019 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_CODE_SEGMENT_H__ -#define __GUM_CODE_SEGMENT_H__ - - -G_BEGIN_DECLS - -typedef struct _GumCodeSegment GumCodeSegment; - -GUM_API gboolean gum_code_segment_is_supported (void); - -GUM_API GumCodeSegment * gum_code_segment_new (gsize size, - const GumAddressSpec * spec); -GUM_API void gum_code_segment_free (GumCodeSegment * segment); - -GUM_API gpointer gum_code_segment_get_address (GumCodeSegment * self); -GUM_API gsize gum_code_segment_get_size (GumCodeSegment * self); -GUM_API gsize gum_code_segment_get_virtual_size (GumCodeSegment * self); - -GUM_API void gum_code_segment_realize (GumCodeSegment * self); -GUM_API void gum_code_segment_map (GumCodeSegment * self, gsize source_offset, - gsize source_size, gpointer target_address); - -GUM_API gboolean gum_code_segment_mark (gpointer code, gsize size, - GError ** error); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2015-2020 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_DARWIN_MODULE_H__ -#define __GUM_DARWIN_MODULE_H__ - - -#define GUM_DARWIN_EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE 2 - -G_BEGIN_DECLS - -#define GUM_TYPE_DARWIN_MODULE (gum_darwin_module_get_type ()) -G_DECLARE_FINAL_TYPE (GumDarwinModule, gum_darwin_module, GUM_DARWIN, MODULE, - GObject) - -#define GUM_DARWIN_PORT_NULL 0 -#define GUM_DARWIN_EXPORT_KIND_MASK 3 - -typedef guint GumDarwinModuleFiletype; -typedef gint GumDarwinCpuType; -typedef gint GumDarwinCpuSubtype; - -typedef struct _GumDarwinModuleImage GumDarwinModuleImage; - -typedef struct _GumDarwinModuleImageSegment GumDarwinModuleImageSegment; -typedef struct _GumDarwinSectionDetails GumDarwinSectionDetails; -typedef struct _GumDarwinChainedFixupsDetails GumDarwinChainedFixupsDetails; -typedef struct _GumDarwinRebaseDetails GumDarwinRebaseDetails; -typedef struct _GumDarwinBindDetails GumDarwinBindDetails; -typedef struct _GumDarwinThreadedItem GumDarwinThreadedItem; -typedef struct _GumDarwinInitPointersDetails GumDarwinInitPointersDetails; -typedef struct _GumDarwinInitOffsetsDetails GumDarwinInitOffsetsDetails; -typedef struct _GumDarwinTermPointersDetails GumDarwinTermPointersDetails; -typedef struct _GumDarwinSegment GumDarwinSegment; -typedef struct _GumDarwinExportDetails GumDarwinExportDetails; -typedef struct _GumDarwinSymbolDetails GumDarwinSymbolDetails; - -typedef guint8 GumDarwinRebaseType; -typedef guint8 GumDarwinBindType; -typedef guint8 GumDarwinThreadedItemType; -typedef gint GumDarwinBindOrdinal; -typedef guint8 GumDarwinBindSymbolFlags; -typedef guint8 GumDarwinExportSymbolKind; -typedef guint8 GumDarwinExportSymbolFlags; - -typedef guint GumDarwinPort; -typedef gint GumDarwinPageProtection; - -typedef gboolean (* GumFoundDarwinExportFunc) ( - const GumDarwinExportDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinSymbolFunc) ( - const GumDarwinSymbolDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinSectionFunc) ( - const GumDarwinSectionDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinChainedFixupsFunc) ( - const GumDarwinChainedFixupsDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinRebaseFunc) ( - const GumDarwinRebaseDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinBindFunc) ( - const GumDarwinBindDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinInitPointersFunc) ( - const GumDarwinInitPointersDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinInitOffsetsFunc) ( - const GumDarwinInitOffsetsDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinTermPointersFunc) ( - const GumDarwinTermPointersDetails * details, gpointer user_data); -typedef gboolean (* GumFoundDarwinDependencyFunc) (const gchar * path, - gpointer user_data); - -typedef struct _GumDyldInfoCommand GumDyldInfoCommand; -typedef struct _GumSymtabCommand GumSymtabCommand; -typedef struct _GumDysymtabCommand GumDysymtabCommand; - -typedef enum { - GUM_DARWIN_MODULE_FLAGS_NONE = 0, - GUM_DARWIN_MODULE_FLAGS_HEADER_ONLY = (1 << 0), -} GumDarwinModuleFlags; - -struct _GumDarwinModule -{ - GObject parent; - - GumDarwinModuleFiletype filetype; - gchar * name; - gchar * uuid; - - GumDarwinPort task; - gboolean is_local; - gboolean is_kernel; - GumCpuType cpu_type; - GumPtrauthSupport ptrauth_support; - gsize pointer_size; - GumAddress base_address; - gchar * source_path; - GBytes * source_blob; - GumDarwinModuleFlags flags; - - GumDarwinModuleImage * image; - - const GumDyldInfoCommand * info; - const GumSymtabCommand * symtab; - const GumDysymtabCommand * dysymtab; - - GumAddress preferred_address; - - GArray * segments; - GArray * text_ranges; - - const guint8 * rebases; - const guint8 * rebases_end; - gpointer rebases_malloc_data; - - const guint8 * binds; - const guint8 * binds_end; - gpointer binds_malloc_data; - - const guint8 * lazy_binds; - const guint8 * lazy_binds_end; - gpointer lazy_binds_malloc_data; - - const guint8 * exports; - const guint8 * exports_end; - gpointer exports_malloc_data; - - GPtrArray * dependencies; - GPtrArray * reexports; -}; - -enum _GumDarwinModuleFiletype -{ - GUM_DARWIN_MODULE_FILETYPE_OBJECT = 1, - GUM_DARWIN_MODULE_FILETYPE_EXECUTE, - GUM_DARWIN_MODULE_FILETYPE_FVMLIB, - GUM_DARWIN_MODULE_FILETYPE_CORE, - GUM_DARWIN_MODULE_FILETYPE_PRELOAD, - GUM_DARWIN_MODULE_FILETYPE_DYLIB, - GUM_DARWIN_MODULE_FILETYPE_DYLINKER, - GUM_DARWIN_MODULE_FILETYPE_BUNDLE, - GUM_DARWIN_MODULE_FILETYPE_DYLIB_STUB, - GUM_DARWIN_MODULE_FILETYPE_DSYM, - GUM_DARWIN_MODULE_FILETYPE_KEXT_BUNDLE, - GUM_DARWIN_MODULE_FILETYPE_FILESET, -}; - -enum _GumDarwinCpuArchType -{ - GUM_DARWIN_CPU_ARCH_ABI64 = 0x01000000, - GUM_DARWIN_CPU_ARCH_ABI64_32 = 0x02000000, -}; - -enum _GumDarwinCpuType -{ - GUM_DARWIN_CPU_X86 = 7, - GUM_DARWIN_CPU_X86_64 = 7 | GUM_DARWIN_CPU_ARCH_ABI64, - GUM_DARWIN_CPU_ARM = 12, - GUM_DARWIN_CPU_ARM64 = 12 | GUM_DARWIN_CPU_ARCH_ABI64, - GUM_DARWIN_CPU_ARM64_32 = 12 | GUM_DARWIN_CPU_ARCH_ABI64_32, -}; - -enum _GumDarwinCpuSubtype -{ - GUM_DARWIN_CPU_SUBTYPE_ARM64E = 2, - - GUM_DARWIN_CPU_SUBTYPE_MASK = 0x00ffffff, -}; - -struct _GumDarwinModuleImage -{ - gpointer data; - guint64 size; - gconstpointer linkedit; - - guint64 source_offset; - guint64 source_size; - guint64 shared_offset; - guint64 shared_size; - GArray * shared_segments; - - GBytes * bytes; - gpointer malloc_data; -}; - -struct _GumDarwinModuleImageSegment -{ - guint64 offset; - guint64 size; - GumDarwinPageProtection protection; -}; - -struct _GumDarwinSectionDetails -{ - gchar segment_name[17]; - gchar section_name[17]; - GumAddress vm_address; - guint64 size; - GumDarwinPageProtection protection; - guint32 file_offset; - guint32 flags; -}; - -struct _GumDarwinChainedFixupsDetails -{ - GumAddress vm_address; - guint64 file_offset; - guint32 size; -}; - -struct _GumDarwinRebaseDetails -{ - const GumDarwinSegment * segment; - guint64 offset; - GumDarwinRebaseType type; - GumAddress slide; -}; - -struct _GumDarwinBindDetails -{ - const GumDarwinSegment * segment; - guint64 offset; - GumDarwinBindType type; - GumDarwinBindOrdinal library_ordinal; - const gchar * symbol_name; - GumDarwinBindSymbolFlags symbol_flags; - gint64 addend; - guint16 threaded_table_size; -}; - -struct _GumDarwinThreadedItem -{ - gboolean is_authenticated; - GumDarwinThreadedItemType type; - guint16 delta; - guint8 key; - gboolean has_address_diversity; - guint16 diversity; - - guint16 bind_ordinal; - - GumAddress rebase_address; -}; - -struct _GumDarwinInitPointersDetails -{ - GumAddress address; - guint64 count; -}; - -struct _GumDarwinInitOffsetsDetails -{ - GumAddress address; - guint64 count; -}; - -struct _GumDarwinTermPointersDetails -{ - GumAddress address; - guint64 count; -}; - -struct _GumDarwinSegment -{ - gchar name[17]; - GumAddress vm_address; - guint64 vm_size; - guint64 file_offset; - guint64 file_size; - GumDarwinPageProtection protection; -}; - -struct _GumDarwinExportDetails -{ - const gchar * name; - guint64 flags; - - union - { - struct - { - guint64 offset; - }; - - struct - { - guint64 stub; - guint64 resolver; - }; - - struct - { - gint reexport_library_ordinal; - const gchar * reexport_symbol; - }; - }; -}; - -struct _GumDarwinSymbolDetails -{ - const gchar * name; - GumAddress address; - - /* These map 1:1 to their struct nlist / nlist_64 equivalents. */ - guint8 type; - guint8 section; - guint16 description; -}; - -enum _GumDarwinRebaseType -{ - GUM_DARWIN_REBASE_POINTER = 1, - GUM_DARWIN_REBASE_TEXT_ABSOLUTE32, - GUM_DARWIN_REBASE_TEXT_PCREL32, -}; - -enum _GumDarwinBindType -{ - GUM_DARWIN_BIND_POINTER = 1, - GUM_DARWIN_BIND_TEXT_ABSOLUTE32, - GUM_DARWIN_BIND_TEXT_PCREL32, - GUM_DARWIN_BIND_THREADED_TABLE, - GUM_DARWIN_BIND_THREADED_ITEMS, -}; - -enum _GumDarwinThreadedItemType -{ - GUM_DARWIN_THREADED_REBASE, - GUM_DARWIN_THREADED_BIND -}; - -enum _GumDarwinBindOrdinal -{ - GUM_DARWIN_BIND_SELF = 0, - GUM_DARWIN_BIND_MAIN_EXECUTABLE = -1, - GUM_DARWIN_BIND_FLAT_LOOKUP = -2, - GUM_DARWIN_BIND_WEAK_LOOKUP = -3, -}; - -enum _GumDarwinBindSymbolFlags -{ - GUM_DARWIN_BIND_WEAK_IMPORT = 0x1, - GUM_DARWIN_BIND_NON_WEAK_DEFINITION = 0x8, -}; - -enum _GumDarwinExportSymbolKind -{ - GUM_DARWIN_EXPORT_REGULAR, - GUM_DARWIN_EXPORT_THREAD_LOCAL, - GUM_DARWIN_EXPORT_ABSOLUTE -}; - -enum _GumDarwinExportSymbolFlags -{ - GUM_DARWIN_EXPORT_WEAK_DEFINITION = 0x04, - GUM_DARWIN_EXPORT_REEXPORT = 0x08, - GUM_DARWIN_EXPORT_STUB_AND_RESOLVER = 0x10, -}; - -GUM_API GumDarwinModule * gum_darwin_module_new_from_file (const gchar * path, - GumCpuType cpu_type, GumPtrauthSupport ptrauth_support, - GumDarwinModuleFlags flags, GError ** error); -GUM_API GumDarwinModule * gum_darwin_module_new_from_blob (GBytes * blob, - GumCpuType cpu_type, GumPtrauthSupport ptrauth_support, - GumDarwinModuleFlags flags, GError ** error); -GUM_API GumDarwinModule * gum_darwin_module_new_from_memory (const gchar * name, - GumDarwinPort task, GumAddress base_address, GumDarwinModuleFlags flags, - GError ** error); - -GUM_API gboolean gum_darwin_module_resolve_export (GumDarwinModule * self, - const gchar * symbol, GumDarwinExportDetails * details); -GUM_API GumAddress gum_darwin_module_resolve_symbol_address ( - GumDarwinModule * self, const gchar * symbol); -GUM_API gboolean gum_darwin_module_get_lacks_exports_for_reexports ( - GumDarwinModule * self); -GUM_API void gum_darwin_module_enumerate_imports (GumDarwinModule * self, - GumFoundImportFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_exports (GumDarwinModule * self, - GumFoundDarwinExportFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_symbols (GumDarwinModule * self, - GumFoundDarwinSymbolFunc func, gpointer user_data); -GUM_API GumAddress gum_darwin_module_get_slide (GumDarwinModule * self); -GUM_API const GumDarwinSegment * gum_darwin_module_get_nth_segment ( - GumDarwinModule * self, gsize index); -GUM_API void gum_darwin_module_enumerate_sections (GumDarwinModule * self, - GumFoundDarwinSectionFunc func, gpointer user_data); -GUM_API gboolean gum_darwin_module_is_address_in_text_section ( - GumDarwinModule * self, GumAddress address); -GUM_API void gum_darwin_module_enumerate_chained_fixups (GumDarwinModule * self, - GumFoundDarwinChainedFixupsFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_rebases (GumDarwinModule * self, - GumFoundDarwinRebaseFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_binds (GumDarwinModule * self, - GumFoundDarwinBindFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_lazy_binds (GumDarwinModule * self, - GumFoundDarwinBindFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_init_pointers (GumDarwinModule * self, - GumFoundDarwinInitPointersFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_init_offsets (GumDarwinModule * self, - GumFoundDarwinInitOffsetsFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_term_pointers (GumDarwinModule * self, - GumFoundDarwinTermPointersFunc func, gpointer user_data); -GUM_API void gum_darwin_module_enumerate_dependencies (GumDarwinModule * self, - GumFoundDarwinDependencyFunc func, gpointer user_data); -GUM_API const gchar * gum_darwin_module_get_dependency_by_ordinal ( - GumDarwinModule * self, gint ordinal); - -GUM_API void gum_darwin_threaded_item_parse (guint64 value, - GumDarwinThreadedItem * result); - -GUM_API GumDarwinModuleImage * gum_darwin_module_image_new (void); -GUM_API GumDarwinModuleImage * gum_darwin_module_image_dup ( - const GumDarwinModuleImage * other); -GUM_API void gum_darwin_module_image_free (GumDarwinModuleImage * image); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2009 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_EVENT_H__ -#define __GUM_EVENT_H__ - - -G_BEGIN_DECLS - -typedef guint GumEventType; - -typedef union _GumEvent GumEvent; - -typedef struct _GumAnyEvent GumAnyEvent; -typedef struct _GumCallEvent GumCallEvent; -typedef struct _GumRetEvent GumRetEvent; -typedef struct _GumExecEvent GumExecEvent; -typedef struct _GumBlockEvent GumBlockEvent; -typedef struct _GumCompileEvent GumCompileEvent; - -enum _GumEventType -{ - GUM_NOTHING = 0, - GUM_CALL = 1 << 0, - GUM_RET = 1 << 1, - GUM_EXEC = 1 << 2, - GUM_BLOCK = 1 << 3, - GUM_COMPILE = 1 << 4, -}; - -struct _GumAnyEvent -{ - GumEventType type; -}; - -struct _GumCallEvent -{ - GumEventType type; - - gpointer location; - gpointer target; - gint depth; -}; - -struct _GumRetEvent -{ - GumEventType type; - - gpointer location; - gpointer target; - gint depth; -}; - -struct _GumExecEvent -{ - GumEventType type; - - gpointer location; -}; - -struct _GumBlockEvent -{ - GumEventType type; - - gpointer begin; - gpointer end; -}; - -struct _GumCompileEvent -{ - GumEventType type; - - gpointer begin; - gpointer end; -}; - -union _GumEvent -{ - GumEventType type; - - GumAnyEvent any; - GumCallEvent call; - GumRetEvent ret; - GumExecEvent exec; - GumBlockEvent block; - GumCompileEvent compile; -}; - -G_END_DECLS - -#endif -/* - * Copyright (C) 2009-2020 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_EVENT_SINK_H__ -#define __GUM_EVENT_SINK_H__ - - -G_BEGIN_DECLS - -#define GUM_TYPE_EVENT_SINK (gum_event_sink_get_type ()) -G_DECLARE_INTERFACE (GumEventSink, gum_event_sink, GUM, EVENT_SINK, GObject) - -#define GUM_TYPE_DEFAULT_EVENT_SINK (gum_default_event_sink_get_type ()) -G_DECLARE_FINAL_TYPE (GumDefaultEventSink, gum_default_event_sink, GUM, - DEFAULT_EVENT_SINK, GObject) - -struct _GumEventSinkInterface -{ - GTypeInterface parent; - - GumEventType (* query_mask) (GumEventSink * self); - void (* start) (GumEventSink * self); - void (* process) (GumEventSink * self, const GumEvent * event, - GumCpuContext * cpu_context); - void (* flush) (GumEventSink * self); - void (* stop) (GumEventSink * self); -}; - -GUM_API GumEventType gum_event_sink_query_mask (GumEventSink * self); -GUM_API void gum_event_sink_start (GumEventSink * self); -GUM_API void gum_event_sink_process (GumEventSink * self, - const GumEvent * event, GumCpuContext * cpu_context); -GUM_API void gum_event_sink_flush (GumEventSink * self); -GUM_API void gum_event_sink_stop (GumEventSink * self); - -GUM_API GumEventSink * gum_event_sink_make_default (void); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2015-2018 Ole André Vadla Ravnås - * Copyright (C) 2020 Francesco Tamagni - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_EXCEPTOR_H__ -#define __GUM_EXCEPTOR_H__ - -#include - -G_BEGIN_DECLS - -#define GUM_TYPE_EXCEPTOR (gum_exceptor_get_type ()) -G_DECLARE_FINAL_TYPE (GumExceptor, gum_exceptor, GUM, EXCEPTOR, GObject) - -#if defined (G_OS_WIN32) || defined (__APPLE__) -# define GUM_NATIVE_SETJMP(env) setjmp (env) -# define GUM_NATIVE_LONGJMP longjmp - typedef jmp_buf GumExceptorNativeJmpBuf; -#else -# define GUM_NATIVE_SETJMP(env) sigsetjmp (env, TRUE) -# define GUM_NATIVE_LONGJMP siglongjmp -# if !defined (GUM_GIR_COMPILATION) - typedef sigjmp_buf GumExceptorNativeJmpBuf; -# endif -#endif - -typedef struct _GumExceptionDetails GumExceptionDetails; -typedef guint GumExceptionType; -typedef struct _GumExceptionMemoryDetails GumExceptionMemoryDetails; -typedef gboolean (* GumExceptionHandler) (GumExceptionDetails * details, - gpointer user_data); - -typedef struct _GumExceptorScope GumExceptorScope; - -enum _GumExceptionType -{ - GUM_EXCEPTION_ABORT = 1, - GUM_EXCEPTION_ACCESS_VIOLATION, - GUM_EXCEPTION_GUARD_PAGE, - GUM_EXCEPTION_ILLEGAL_INSTRUCTION, - GUM_EXCEPTION_STACK_OVERFLOW, - GUM_EXCEPTION_ARITHMETIC, - GUM_EXCEPTION_BREAKPOINT, - GUM_EXCEPTION_SINGLE_STEP, - GUM_EXCEPTION_SYSTEM -}; - -struct _GumExceptionMemoryDetails -{ - GumMemoryOperation operation; - gpointer address; -}; - -struct _GumExceptionDetails -{ - GumThreadId thread_id; - GumExceptionType type; - gpointer address; - GumExceptionMemoryDetails memory; - GumCpuContext context; - gpointer native_context; -}; - -struct _GumExceptorScope -{ - GumExceptionDetails exception; - - /*< private */ - gboolean exception_occurred; - gpointer padding[2]; - jmp_buf env; -#ifdef __ANDROID__ - sigset_t mask; -#endif - - GumExceptorScope * next; -}; - -GUM_API GumExceptor * gum_exceptor_obtain (void); - -GUM_API void gum_exceptor_add (GumExceptor * self, GumExceptionHandler func, - gpointer user_data); -GUM_API void gum_exceptor_remove (GumExceptor * self, GumExceptionHandler func, - gpointer user_data); - -#if defined (_MSC_VER) && GLIB_SIZEOF_VOID_P == 8 -/* - * On MSVC/64-bit setjmp() is actually an intrinsic that calls _setjmp() with a - * a hidden second argument specifying the frame pointer. This makes sense when - * the longjmp() is guaranteed to happen from code we control, but is not - * reliable otherwise. - */ -# define gum_exceptor_try(self, scope) ( \ - _gum_exceptor_prepare_try (self, scope), \ - ((int (*) (jmp_buf env, void * frame_pointer)) _setjmp) ( \ - (scope)->env, NULL) == 0) -#else -# define gum_exceptor_try(self, scope) ( \ - _gum_exceptor_prepare_try (self, scope), \ - GUM_NATIVE_SETJMP ((scope)->env) == 0) -#endif -GUM_API gboolean gum_exceptor_catch (GumExceptor * self, - GumExceptorScope * scope); -GUM_API gboolean gum_exceptor_has_scope (GumExceptor * self, - GumThreadId thread_id); - -GUM_API gchar * gum_exception_details_to_string ( - const GumExceptionDetails * details); - -GUM_API void _gum_exceptor_prepare_try (GumExceptor * self, - GumExceptorScope * scope); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2009 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_FUNCTION_H__ -#define __GUM_FUNCTION_H__ - -G_BEGIN_DECLS - -typedef struct _GumFunctionDetails GumFunctionDetails; - -struct _GumFunctionDetails -{ - const gchar * name; - gpointer address; - gint num_arguments; -}; - -G_END_DECLS - -#endif -/* - * Copyright (C) 2008-2019 Ole André Vadla Ravnås - * Copyright (C) 2008 Christian Berentsen - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_INTERCEPTOR_H__ -#define __GUM_INTERCEPTOR_H__ - -/* - * Copyright (C) 2008-2018 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_INVOCATION_LISTENER_H__ -#define __GUM_INVOCATION_LISTENER_H__ - -/* - * Copyright (C) 2008-2019 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_INVOCATION_CONTEXT_H__ -#define __GUM_INVOCATION_CONTEXT_H__ - - - -#define GUM_IC_GET_THREAD_DATA(context, data_type) \ - ((data_type *) gum_invocation_context_get_listener_thread_data (context, \ - sizeof (data_type))) -#define GUM_IC_GET_FUNC_DATA(context, data_type) \ - ((data_type) gum_invocation_context_get_listener_function_data (context)) -#define GUM_IC_GET_INVOCATION_DATA(context, data_type) \ - ((data_type *) \ - gum_invocation_context_get_listener_invocation_data (context,\ - sizeof (data_type))) - -#define GUM_IC_GET_REPLACEMENT_DATA(ctx, data_type) \ - ((data_type) gum_invocation_context_get_replacement_data (ctx)) - -typedef struct _GumInvocationBackend GumInvocationBackend; -typedef struct _GumInvocationContext GumInvocationContext; -typedef guint GumPointCut; - -struct _GumInvocationBackend -{ - GumPointCut (* get_point_cut) (GumInvocationContext * context); - - GumThreadId (* get_thread_id) (GumInvocationContext * context); - guint (* get_depth) (GumInvocationContext * context); - - gpointer (* get_listener_thread_data) (GumInvocationContext * context, - gsize required_size); - gpointer (* get_listener_function_data) (GumInvocationContext * context); - gpointer (* get_listener_invocation_data) ( - GumInvocationContext * context, gsize required_size); - - gpointer (* get_replacement_data) (GumInvocationContext * context); - - gpointer state; - gpointer data; -}; - -struct _GumInvocationContext -{ - GCallback function; - GumCpuContext * cpu_context; - gint system_error; - - /*< private */ - GumInvocationBackend * backend; -}; - -enum _GumPointCut -{ - GUM_POINT_ENTER, - GUM_POINT_LEAVE -}; - -G_BEGIN_DECLS - -GUM_API GumPointCut gum_invocation_context_get_point_cut ( - GumInvocationContext * context); - -GUM_API gpointer gum_invocation_context_get_nth_argument ( - GumInvocationContext * context, guint n); -GUM_API void gum_invocation_context_replace_nth_argument ( - GumInvocationContext * context, guint n, gpointer value); -GUM_API gpointer gum_invocation_context_get_return_value ( - GumInvocationContext * context); -GUM_API void gum_invocation_context_replace_return_value ( - GumInvocationContext * context, gpointer value); - -GUM_API gpointer gum_invocation_context_get_return_address ( - GumInvocationContext * context); - -GUM_API guint gum_invocation_context_get_thread_id ( - GumInvocationContext * context); -GUM_API guint gum_invocation_context_get_depth ( - GumInvocationContext * context); - -GUM_API gpointer gum_invocation_context_get_listener_thread_data ( - GumInvocationContext * context, gsize required_size); -GUM_API gpointer gum_invocation_context_get_listener_function_data ( - GumInvocationContext * context); -GUM_API gpointer gum_invocation_context_get_listener_invocation_data ( - GumInvocationContext * context, gsize required_size); - -GUM_API gpointer gum_invocation_context_get_replacement_data ( - GumInvocationContext * context); - -G_END_DECLS - -#endif - -G_BEGIN_DECLS - -#define GUM_TYPE_INVOCATION_LISTENER (gum_invocation_listener_get_type ()) -G_DECLARE_INTERFACE (GumInvocationListener, gum_invocation_listener, GUM, - INVOCATION_LISTENER, GObject) - -struct _GumInvocationListenerInterface -{ - GTypeInterface parent; - - void (* on_enter) (GumInvocationListener * self, - GumInvocationContext * context); - void (* on_leave) (GumInvocationListener * self, - GumInvocationContext * context); -}; - -GUM_API void gum_invocation_listener_on_enter (GumInvocationListener * self, - GumInvocationContext * context); -GUM_API void gum_invocation_listener_on_leave (GumInvocationListener * self, - GumInvocationContext * context); - -G_END_DECLS - -#endif - -G_BEGIN_DECLS - -#define GUM_TYPE_INTERCEPTOR (gum_interceptor_get_type ()) -G_DECLARE_FINAL_TYPE (GumInterceptor, gum_interceptor, GUM, INTERCEPTOR, - GObject) - -typedef GArray GumInvocationStack; -typedef guint GumInvocationState; - -typedef enum -{ - GUM_ATTACH_OK = 0, - GUM_ATTACH_WRONG_SIGNATURE = -1, - GUM_ATTACH_ALREADY_ATTACHED = -2, - GUM_ATTACH_POLICY_VIOLATION = -3 -} GumAttachReturn; - -typedef enum -{ - GUM_REPLACE_OK = 0, - GUM_REPLACE_WRONG_SIGNATURE = -1, - GUM_REPLACE_ALREADY_REPLACED = -2, - GUM_REPLACE_POLICY_VIOLATION = -3 -} GumReplaceReturn; - -GUM_API GumInterceptor * gum_interceptor_obtain (void); - -GUM_API GumAttachReturn gum_interceptor_attach (GumInterceptor * self, - gpointer function_address, GumInvocationListener * listener, - gpointer listener_function_data); -GUM_API void gum_interceptor_detach (GumInterceptor * self, - GumInvocationListener * listener); - -GUM_API GumReplaceReturn gum_interceptor_replace (GumInterceptor * self, - gpointer function_address, gpointer replacement_function, - gpointer replacement_data); -GUM_API void gum_interceptor_revert (GumInterceptor * self, - gpointer function_address); - -GUM_API void gum_interceptor_begin_transaction (GumInterceptor * self); -GUM_API void gum_interceptor_end_transaction (GumInterceptor * self); -GUM_API gboolean gum_interceptor_flush (GumInterceptor * self); - -GUM_API GumInvocationContext * gum_interceptor_get_current_invocation (void); -GUM_API GumInvocationStack * gum_interceptor_get_current_stack (void); - -GUM_API void gum_interceptor_ignore_current_thread (GumInterceptor * self); -GUM_API void gum_interceptor_unignore_current_thread (GumInterceptor * self); - -GUM_API void gum_interceptor_ignore_other_threads (GumInterceptor * self); -GUM_API void gum_interceptor_unignore_other_threads (GumInterceptor * self); - -GUM_API gpointer gum_invocation_stack_translate (GumInvocationStack * self, - gpointer return_address); - -GUM_API void gum_interceptor_save (GumInvocationState * state); -GUM_API void gum_interceptor_restore (GumInvocationState * state); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2015 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_KERNEL_H__ -#define __GUM_KERNEL_H__ - - -G_BEGIN_DECLS - -typedef struct _GumKernelModuleRangeDetails GumKernelModuleRangeDetails; - -struct _GumKernelModuleRangeDetails -{ - gchar name[48]; - GumAddress address; - guint64 size; - GumPageProtection protection; -}; - -typedef gboolean (* GumFoundKernelModuleRangeFunc) ( - const GumKernelModuleRangeDetails * details, gpointer user_data); - -GUM_API gboolean gum_kernel_api_is_available (void); -GUM_API guint gum_kernel_query_page_size (void); -GUM_API GumAddress gum_kernel_alloc_n_pages (guint n_pages); -GUM_API void gum_kernel_free_pages (GumAddress mem); -GUM_API gboolean gum_kernel_try_mprotect (GumAddress address, gsize size, - GumPageProtection page_prot); -GUM_API guint8 * gum_kernel_read (GumAddress address, gsize len, - gsize * n_bytes_read); -GUM_API gboolean gum_kernel_write (GumAddress address, const guint8 * bytes, - gsize len); -GUM_API void gum_kernel_scan (const GumMemoryRange * range, - const GumMatchPattern * pattern, GumMemoryScanMatchFunc func, - gpointer user_data); -GUM_API void gum_kernel_enumerate_ranges (GumPageProtection prot, - GumFoundRangeFunc func, gpointer user_data); -GUM_API void gum_kernel_enumerate_module_ranges (const gchar * module_name, - GumPageProtection prot, GumFoundKernelModuleRangeFunc func, - gpointer user_data); -GUM_API void gum_kernel_enumerate_modules (GumFoundModuleFunc func, - gpointer user_data); -GUM_API GumAddress gum_kernel_find_base_address (void); -GUM_API void gum_kernel_set_base_address (GumAddress base); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2015 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_LIBC_H__ -#define __GUM_LIBC_H__ - - -G_BEGIN_DECLS - -G_GNUC_INTERNAL gpointer gum_memset (gpointer dst, gint c, gsize n); -G_GNUC_INTERNAL gpointer gum_memcpy (gpointer dst, gconstpointer src, gsize n); -G_GNUC_INTERNAL gpointer gum_memmove (gpointer dst, gconstpointer src, gsize n); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2010-2018 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_MEMORY_ACCESS_MONITOR_H__ -#define __GUM_MEMORY_ACCESS_MONITOR_H__ - - -G_BEGIN_DECLS - -#define GUM_TYPE_MEMORY_ACCESS_MONITOR (gum_memory_access_monitor_get_type ()) -G_DECLARE_FINAL_TYPE (GumMemoryAccessMonitor, gum_memory_access_monitor, GUM, - MEMORY_ACCESS_MONITOR, GObject) - -typedef struct _GumMemoryAccessDetails GumMemoryAccessDetails; - -typedef void (* GumMemoryAccessNotify) (GumMemoryAccessMonitor * monitor, - const GumMemoryAccessDetails * details, gpointer user_data); - -struct _GumMemoryAccessDetails -{ - GumMemoryOperation operation; - gpointer from; - gpointer address; - - guint range_index; - guint page_index; - guint pages_completed; - guint pages_total; -}; - -GUM_API GumMemoryAccessMonitor * gum_memory_access_monitor_new ( - const GumMemoryRange * ranges, guint num_ranges, - GumPageProtection access_mask, gboolean auto_reset, - GumMemoryAccessNotify func, gpointer data, - GDestroyNotify data_destroy); - -GUM_API gboolean gum_memory_access_monitor_enable ( - GumMemoryAccessMonitor * self, GError ** error); -GUM_API void gum_memory_access_monitor_disable (GumMemoryAccessMonitor * self); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2013-2018 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_MEMORY_MAP_H__ -#define __GUM_MEMORY_MAP_H__ - - -G_BEGIN_DECLS - -#define GUM_TYPE_MEMORY_MAP (gum_memory_map_get_type ()) -G_DECLARE_FINAL_TYPE (GumMemoryMap, gum_memory_map, GUM, MEMORY_MAP, GObject) - -GUM_API GumMemoryMap * gum_memory_map_new (GumPageProtection prot); - -GUM_API gboolean gum_memory_map_contains (GumMemoryMap * self, - const GumMemoryRange * range); - -GUM_API void gum_memory_map_update (GumMemoryMap * self); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2017-2019 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_METAL_ARRAY_H__ -#define __GUM_METAL_ARRAY_H__ - - -typedef struct _GumMetalArray GumMetalArray; - -struct _GumMetalArray -{ - gpointer data; - guint length; - guint capacity; - - guint element_size; -}; - -G_BEGIN_DECLS - -GUM_API void gum_metal_array_init (GumMetalArray * array, guint element_size); -GUM_API void gum_metal_array_free (GumMetalArray * array); - -GUM_API gpointer gum_metal_array_element_at (GumMetalArray * self, - guint index_); -GUM_API gpointer gum_metal_array_insert_at (GumMetalArray * self, guint index_); -GUM_API void gum_metal_array_remove_at (GumMetalArray * self, guint index_); -GUM_API void gum_metal_array_remove_all (GumMetalArray * self); -GUM_API gpointer gum_metal_array_append (GumMetalArray * self); - -GUM_API void gum_metal_array_get_extents (GumMetalArray * self, - gpointer * start, gpointer * end); -GUM_API void gum_metal_array_ensure_capacity (GumMetalArray * self, - guint capacity); - -G_END_DECLS - -#endif -/* GLIB - Library of useful routines for C programming - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, see . - */ - -/* - * Modified by the GLib Team and others 1997-2000. See the AUTHORS - * file for a list of people on the GLib Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GLib at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef __GUM_METAL_HASH_H__ -#define __GUM_METAL_HASH_H__ - - -G_BEGIN_DECLS - -typedef struct _GumMetalHashTable GumMetalHashTable; -typedef struct _GumMetalHashTableIter GumMetalHashTableIter; - -struct _GumMetalHashTableIter -{ - gpointer dummy1; - gpointer dummy2; - gpointer dummy3; - int dummy4; - gboolean dummy5; - gpointer dummy6; -}; - -GUM_API GumMetalHashTable * gum_metal_hash_table_new (GHashFunc hash_func, - GEqualFunc key_equal_func); -GUM_API GumMetalHashTable * gum_metal_hash_table_new_full (GHashFunc hash_func, - GEqualFunc key_equal_func, GDestroyNotify key_destroy_func, - GDestroyNotify value_destroy_func); -GUM_API void gum_metal_hash_table_destroy (GumMetalHashTable * hash_table); -GUM_API gboolean gum_metal_hash_table_insert (GumMetalHashTable * hash_table, - gpointer key, gpointer value); -GUM_API gboolean gum_metal_hash_table_replace (GumMetalHashTable * hash_table, - gpointer key, gpointer value); -GUM_API gboolean gum_metal_hash_table_add (GumMetalHashTable * hash_table, - gpointer key); -GUM_API gboolean gum_metal_hash_table_remove (GumMetalHashTable * hash_table, - gconstpointer key); -GUM_API void gum_metal_hash_table_remove_all (GumMetalHashTable * hash_table); -GUM_API gboolean gum_metal_hash_table_steal (GumMetalHashTable * hash_table, - gconstpointer key); -GUM_API void gum_metal_hash_table_steal_all (GumMetalHashTable * hash_table); -GUM_API gpointer gum_metal_hash_table_lookup (GumMetalHashTable * hash_table, - gconstpointer key); -GUM_API gboolean gum_metal_hash_table_contains (GumMetalHashTable * hash_table, - gconstpointer key); -GUM_API gboolean gum_metal_hash_table_lookup_extended ( - GumMetalHashTable * hash_table, gconstpointer lookup_key, - gpointer * orig_key, gpointer * value); -GUM_API void gum_metal_hash_table_foreach (GumMetalHashTable * hash_table, - GHFunc func, gpointer user_data); -GUM_API gpointer gum_metal_hash_table_find (GumMetalHashTable * hash_table, - GHRFunc predicate, gpointer user_data); -GUM_API guint gum_metal_hash_table_foreach_remove ( - GumMetalHashTable * hash_table, GHRFunc func, gpointer user_data); -GUM_API guint gum_metal_hash_table_foreach_steal (GumMetalHashTable * hash_table, - GHRFunc func, gpointer user_data); -GUM_API guint gum_metal_hash_table_size (GumMetalHashTable * hash_table); - -GUM_API void gum_metal_hash_table_iter_init (GumMetalHashTableIter * iter, - GumMetalHashTable * hash_table); -GUM_API gboolean gum_metal_hash_table_iter_next (GumMetalHashTableIter * iter, - gpointer * key, gpointer * value); -GUM_API GumMetalHashTable* gum_metal_hash_table_iter_get_hash_table ( - GumMetalHashTableIter * iter); -GUM_API void gum_metal_hash_table_iter_remove (GumMetalHashTableIter * iter); -GUM_API void gum_metal_hash_table_iter_replace (GumMetalHashTableIter * iter, - gpointer value); -GUM_API void gum_metal_hash_table_iter_steal (GumMetalHashTableIter * iter); - -GUM_API GumMetalHashTable * gum_metal_hash_table_ref ( - GumMetalHashTable * hash_table); -GUM_API void gum_metal_hash_table_unref (GumMetalHashTable * hash_table); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2016 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_MODULE_API_RESOLVER_H__ -#define __GUM_MODULE_API_RESOLVER_H__ - - -G_BEGIN_DECLS - -#define GUM_TYPE_MODULE_API_RESOLVER (gum_module_api_resolver_get_type ()) -G_DECLARE_FINAL_TYPE (GumModuleApiResolver, gum_module_api_resolver, GUM, - MODULE_API_RESOLVER, GObject) - -GUM_API GumApiResolver * gum_module_api_resolver_new (void); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2015-2017 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_MODULE_MAP_H__ -#define __GUM_MODULE_MAP_H__ - - -G_BEGIN_DECLS - -#define GUM_TYPE_MODULE_MAP (gum_module_map_get_type ()) -G_DECLARE_FINAL_TYPE (GumModuleMap, gum_module_map, GUM, MODULE_MAP, GObject) - -typedef gboolean (* GumModuleMapFilterFunc) (const GumModuleDetails * details, - gpointer user_data); - -GUM_API GumModuleMap * gum_module_map_new (void); -GUM_API GumModuleMap * gum_module_map_new_filtered (GumModuleMapFilterFunc func, - gpointer data, GDestroyNotify data_destroy); - -GUM_API const GumModuleDetails * gum_module_map_find (GumModuleMap * self, - GumAddress address); - -GUM_API void gum_module_map_update (GumModuleMap * self); - -GUM_API GArray * gum_module_map_get_values (GumModuleMap * self); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2014 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_PRINTF_H__ -#define __GUM_PRINTF_H__ - - -G_BEGIN_DECLS - -gint gum_vsnprintf (gchar * str, gsize size, const gchar * format, - va_list args); -gint gum_snprintf (gchar * str, gsize size, const gchar * format, ...); -gint gum_vasprintf (gchar ** ret, const gchar * format, va_list ap); -gint gum_asprintf (gchar ** ret, const gchar * format, ...); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2010-2019 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_SPINLOCK_H__ -#define __GUM_SPINLOCK_H__ - - -#define GUM_SPINLOCK_INIT { NULL } - -G_BEGIN_DECLS - -typedef struct _GumSpinlock GumSpinlock; - -struct _GumSpinlock -{ - gpointer data; -}; - -void gum_spinlock_init (GumSpinlock * spinlock); - -void gum_spinlock_acquire (GumSpinlock * spinlock); -void gum_spinlock_release (GumSpinlock * spinlock); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2009-2018 Ole André Vadla Ravnås - * Copyright (C) 2010 Karl Trygve Kalleberg - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_STALKER_H__ -#define __GUM_STALKER_H__ - -#ifndef CAPSTONE_ENGINE_H -#define CAPSTONE_ENGINE_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2013-2016 */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#if defined(CAPSTONE_HAS_OSXKERNEL) -#include -#else -#include -#include -#endif - -/* Capstone Disassembly Engine */ -/* By Axel Souchet & Nguyen Anh Quynh, 2014 */ - -#ifndef CAPSTONE_PLATFORM_H -#define CAPSTONE_PLATFORM_H - - -// handle C99 issue (for pre-2013 VisualStudio) -#if !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) -// MSVC - -// stdbool.h -#if (_MSC_VER < 1800) || defined(_KERNEL_MODE) -// this system does not have stdbool.h -#ifndef __cplusplus -typedef unsigned char bool; -#define false 0 -#define true 1 -#endif // __cplusplus - -#else -// VisualStudio 2013+ -> C99 is supported -#include -#endif // (_MSC_VER < 1800) || defined(_KERNEL_MODE) - -#else -// not MSVC -> C99 is supported -#include -#endif // !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__MINGW64__) && (defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)) - - -// handle inttypes.h / stdint.h compatibility -#if defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) -#include "windowsce/stdint.h" -#endif // defined(_WIN32_WCE) && (_WIN32_WCE < 0x800) - -#if defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) -// this system does not have inttypes.h - -#if defined(_MSC_VER) && (_MSC_VER <= 1600 || defined(_KERNEL_MODE)) -// this system does not have stdint.h -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed int int32_t; -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -#endif // defined(_MSC_VER) && (_MSC_VER <= 1600 || defined(_KERNEL_MODE)) - -#if defined(_MSC_VER) && (_MSC_VER < 1600 || defined(_KERNEL_MODE)) -#define INT8_MIN (-127i8 - 1) -#define INT16_MIN (-32767i16 - 1) -#define INT32_MIN (-2147483647i32 - 1) -#define INT64_MIN (-9223372036854775807i64 - 1) -#define INT8_MAX 127i8 -#define INT16_MAX 32767i16 -#define INT32_MAX 2147483647i32 -#define INT64_MAX 9223372036854775807i64 -#define UINT8_MAX 0xffui8 -#define UINT16_MAX 0xffffui16 -#define UINT32_MAX 0xffffffffui32 -#define UINT64_MAX 0xffffffffffffffffui64 -#endif // defined(_MSC_VER) && (_MSC_VER < 1600 || defined(_KERNEL_MODE)) - -#ifdef CAPSTONE_HAS_OSXKERNEL -// this system has stdint.h -#include -#endif - -#define __PRI_8_LENGTH_MODIFIER__ "hh" -#define __PRI_64_LENGTH_MODIFIER__ "ll" - -#define PRId8 __PRI_8_LENGTH_MODIFIER__ "d" -#define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i" -#define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o" -#define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u" -#define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x" -#define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X" - -#define PRId16 "hd" -#define PRIi16 "hi" -#define PRIo16 "ho" -#define PRIu16 "hu" -#define PRIx16 "hx" -#define PRIX16 "hX" - -#if defined(_MSC_VER) && _MSC_VER <= 1700 -#define PRId32 "ld" -#define PRIi32 "li" -#define PRIo32 "lo" -#define PRIu32 "lu" -#define PRIx32 "lx" -#define PRIX32 "lX" -#else // OSX -#define PRId32 "d" -#define PRIi32 "i" -#define PRIo32 "o" -#define PRIu32 "u" -#define PRIx32 "x" -#define PRIX32 "X" -#endif // defined(_MSC_VER) && _MSC_VER <= 1700 - -#if defined(_MSC_VER) && _MSC_VER <= 1700 -// redefine functions from inttypes.h used in cstool -#define strtoull _strtoui64 -#endif - -#define PRId64 __PRI_64_LENGTH_MODIFIER__ "d" -#define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i" -#define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o" -#define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u" -#define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x" -#define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X" - -#else -// this system has inttypes.h by default -#include -#endif // defined(CAPSTONE_HAS_OSXKERNEL) || (defined(_MSC_VER) && (_MSC_VER <= 1700 || defined(_KERNEL_MODE))) - -#endif - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#pragma warning(disable:4100) -#define CAPSTONE_API __cdecl -#ifdef CAPSTONE_SHARED -#define CAPSTONE_EXPORT __declspec(dllexport) -#else // defined(CAPSTONE_STATIC) -#define CAPSTONE_EXPORT -#endif -#else -#define CAPSTONE_API -#if (defined(__GNUC__) || defined(__IBMC__)) && !defined(CAPSTONE_STATIC) -#define CAPSTONE_EXPORT __attribute__((visibility("default"))) -#else // defined(CAPSTONE_STATIC) -#define CAPSTONE_EXPORT -#endif -#endif - -#if (defined(__GNUC__) || defined(__IBMC__)) -#define CAPSTONE_DEPRECATED __attribute__((deprecated)) -#elif defined(_MSC_VER) -#define CAPSTONE_DEPRECATED __declspec(deprecated) -#else -#pragma message("WARNING: You need to implement CAPSTONE_DEPRECATED for this compiler") -#define CAPSTONE_DEPRECATED -#endif - -// Capstone API version -#define CS_API_MAJOR 5 -#define CS_API_MINOR 0 - -// Version for bleeding edge code of the Github's "next" branch. -// Use this if you want the absolutely latest development code. -// This version number will be bumped up whenever we have a new major change. -#define CS_NEXT_VERSION 5 - -// Capstone package version -#define CS_VERSION_MAJOR CS_API_MAJOR -#define CS_VERSION_MINOR CS_API_MINOR -#define CS_VERSION_EXTRA 0 - -/// Macro to create combined version which can be compared to -/// result of cs_version() API. -#define CS_MAKE_VERSION(major, minor) ((major << 8) + minor) - -/// Maximum size of an instruction mnemonic string. -#define CS_MNEMONIC_SIZE 32 - -// Handle using with all API -typedef size_t csh; - -/// Architecture type -typedef enum cs_arch { - CS_ARCH_ARM = 0, ///< ARM architecture (including Thumb, Thumb-2) - CS_ARCH_ARM64, ///< ARM-64, also called AArch64 - CS_ARCH_MIPS, ///< Mips architecture - CS_ARCH_X86, ///< X86 architecture (including x86 & x86-64) - CS_ARCH_PPC, ///< PowerPC architecture - CS_ARCH_SPARC, ///< Sparc architecture - CS_ARCH_SYSZ, ///< SystemZ architecture - CS_ARCH_XCORE, ///< XCore architecture - CS_ARCH_M68K, ///< 68K architecture - CS_ARCH_TMS320C64X, ///< TMS320C64x architecture - CS_ARCH_M680X, ///< 680X architecture - CS_ARCH_EVM, ///< Ethereum architecture - CS_ARCH_MOS65XX, ///< MOS65XX architecture (including MOS6502) - CS_ARCH_WASM, ///< WebAssembly architecture - CS_ARCH_BPF, ///< Berkeley Packet Filter architecture (including eBPF) - CS_ARCH_RISCV, ///< RISCV architecture - CS_ARCH_MAX, - CS_ARCH_ALL = 0xFFFF, // All architectures - for cs_support() -} cs_arch; - -// Support value to verify diet mode of the engine. -// If cs_support(CS_SUPPORT_DIET) return True, the engine was compiled -// in diet mode. -#define CS_SUPPORT_DIET (CS_ARCH_ALL + 1) - -// Support value to verify X86 reduce mode of the engine. -// If cs_support(CS_SUPPORT_X86_REDUCE) return True, the engine was compiled -// in X86 reduce mode. -#define CS_SUPPORT_X86_REDUCE (CS_ARCH_ALL + 2) - -/// Mode type -typedef enum cs_mode { - CS_MODE_LITTLE_ENDIAN = 0, ///< little-endian mode (default mode) - CS_MODE_ARM = 0, ///< 32-bit ARM - CS_MODE_16 = 1 << 1, ///< 16-bit mode (X86) - CS_MODE_32 = 1 << 2, ///< 32-bit mode (X86) - CS_MODE_64 = 1 << 3, ///< 64-bit mode (X86, PPC) - CS_MODE_THUMB = 1 << 4, ///< ARM's Thumb mode, including Thumb-2 - CS_MODE_MCLASS = 1 << 5, ///< ARM's Cortex-M series - CS_MODE_V8 = 1 << 6, ///< ARMv8 A32 encodings for ARM - CS_MODE_MICRO = 1 << 4, ///< MicroMips mode (MIPS) - CS_MODE_MIPS3 = 1 << 5, ///< Mips III ISA - CS_MODE_MIPS32R6 = 1 << 6, ///< Mips32r6 ISA - CS_MODE_MIPS2 = 1 << 7, ///< Mips II ISA - CS_MODE_V9 = 1 << 4, ///< SparcV9 mode (Sparc) - CS_MODE_QPX = 1 << 4, ///< Quad Processing eXtensions mode (PPC) - CS_MODE_SPE = 1 << 5, ///< Signal Processing Engine mode (PPC) - CS_MODE_BOOKE = 1 << 6, ///< Book-E mode (PPC) - CS_MODE_M68K_000 = 1 << 1, ///< M68K 68000 mode - CS_MODE_M68K_010 = 1 << 2, ///< M68K 68010 mode - CS_MODE_M68K_020 = 1 << 3, ///< M68K 68020 mode - CS_MODE_M68K_030 = 1 << 4, ///< M68K 68030 mode - CS_MODE_M68K_040 = 1 << 5, ///< M68K 68040 mode - CS_MODE_M68K_060 = 1 << 6, ///< M68K 68060 mode - CS_MODE_BIG_ENDIAN = 1U << 31, ///< big-endian mode - CS_MODE_MIPS32 = CS_MODE_32, ///< Mips32 ISA (Mips) - CS_MODE_MIPS64 = CS_MODE_64, ///< Mips64 ISA (Mips) - CS_MODE_M680X_6301 = 1 << 1, ///< M680X Hitachi 6301,6303 mode - CS_MODE_M680X_6309 = 1 << 2, ///< M680X Hitachi 6309 mode - CS_MODE_M680X_6800 = 1 << 3, ///< M680X Motorola 6800,6802 mode - CS_MODE_M680X_6801 = 1 << 4, ///< M680X Motorola 6801,6803 mode - CS_MODE_M680X_6805 = 1 << 5, ///< M680X Motorola/Freescale 6805 mode - CS_MODE_M680X_6808 = 1 << 6, ///< M680X Motorola/Freescale/NXP 68HC08 mode - CS_MODE_M680X_6809 = 1 << 7, ///< M680X Motorola 6809 mode - CS_MODE_M680X_6811 = 1 << 8, ///< M680X Motorola/Freescale/NXP 68HC11 mode - CS_MODE_M680X_CPU12 = 1 << 9, ///< M680X Motorola/Freescale/NXP CPU12 - ///< used on M68HC12/HCS12 - CS_MODE_M680X_HCS08 = 1 << 10, ///< M680X Freescale/NXP HCS08 mode - CS_MODE_BPF_CLASSIC = 0, ///< Classic BPF mode (default) - CS_MODE_BPF_EXTENDED = 1 << 0, ///< Extended BPF mode - CS_MODE_RISCV32 = 1 << 0, ///< RISCV RV32G - CS_MODE_RISCV64 = 1 << 1, ///< RISCV RV64G - CS_MODE_RISCVC = 1 << 2, ///< RISCV compressed instructure mode - CS_MODE_MOS65XX_6502 = 1 << 1, ///< MOS65XXX MOS 6502 - CS_MODE_MOS65XX_65C02 = 1 << 2, ///< MOS65XXX WDC 65c02 - CS_MODE_MOS65XX_W65C02 = 1 << 3, ///< MOS65XXX WDC W65c02 - CS_MODE_MOS65XX_65816 = 1 << 4, ///< MOS65XXX WDC 65816, 8-bit m/x - CS_MODE_MOS65XX_65816_LONG_M = (1 << 5), ///< MOS65XXX WDC 65816, 16-bit m, 8-bit x - CS_MODE_MOS65XX_65816_LONG_X = (1 << 6), ///< MOS65XXX WDC 65816, 8-bit m, 16-bit x - CS_MODE_MOS65XX_65816_LONG_MX = CS_MODE_MOS65XX_65816_LONG_M | CS_MODE_MOS65XX_65816_LONG_X, -} cs_mode; - -typedef void* (CAPSTONE_API *cs_malloc_t)(size_t size); -typedef void* (CAPSTONE_API *cs_calloc_t)(size_t nmemb, size_t size); -typedef void* (CAPSTONE_API *cs_realloc_t)(void *ptr, size_t size); -typedef void (CAPSTONE_API *cs_free_t)(void *ptr); -typedef int (CAPSTONE_API *cs_vsnprintf_t)(char *str, size_t size, const char *format, va_list ap); - - -/// User-defined dynamic memory related functions: malloc/calloc/realloc/free/vsnprintf() -/// By default, Capstone uses system's malloc(), calloc(), realloc(), free() & vsnprintf(). -typedef struct cs_opt_mem { - cs_malloc_t malloc; - cs_calloc_t calloc; - cs_realloc_t realloc; - cs_free_t free; - cs_vsnprintf_t vsnprintf; -} cs_opt_mem; - -/// Customize mnemonic for instructions with alternative name. -/// To reset existing customized instruction to its default mnemonic, -/// call cs_option(CS_OPT_MNEMONIC) again with the same @id and NULL value -/// for @mnemonic. -typedef struct cs_opt_mnem { - /// ID of instruction to be customized. - unsigned int id; - /// Customized instruction mnemonic. - const char *mnemonic; -} cs_opt_mnem; - -/// Runtime option for the disassembled engine -typedef enum cs_opt_type { - CS_OPT_INVALID = 0, ///< No option specified - CS_OPT_SYNTAX, ///< Assembly output syntax - CS_OPT_DETAIL, ///< Break down instruction structure into details - CS_OPT_MODE, ///< Change engine's mode at run-time - CS_OPT_MEM, ///< User-defined dynamic memory related functions - CS_OPT_SKIPDATA, ///< Skip data when disassembling. Then engine is in SKIPDATA mode. - CS_OPT_SKIPDATA_SETUP, ///< Setup user-defined function for SKIPDATA option - CS_OPT_MNEMONIC, ///< Customize instruction mnemonic - CS_OPT_UNSIGNED, ///< print immediate operands in unsigned form -} cs_opt_type; - -/// Runtime option value (associated with option type above) -typedef enum cs_opt_value { - CS_OPT_OFF = 0, ///< Turn OFF an option - default for CS_OPT_DETAIL, CS_OPT_SKIPDATA, CS_OPT_UNSIGNED. - CS_OPT_ON = 3, ///< Turn ON an option (CS_OPT_DETAIL, CS_OPT_SKIPDATA). - CS_OPT_SYNTAX_DEFAULT = 0, ///< Default asm syntax (CS_OPT_SYNTAX). - CS_OPT_SYNTAX_INTEL, ///< X86 Intel asm syntax - default on X86 (CS_OPT_SYNTAX). - CS_OPT_SYNTAX_ATT, ///< X86 ATT asm syntax (CS_OPT_SYNTAX). - CS_OPT_SYNTAX_NOREGNAME, ///< Prints register name with only number (CS_OPT_SYNTAX) - CS_OPT_SYNTAX_MASM, ///< X86 Intel Masm syntax (CS_OPT_SYNTAX). - CS_OPT_SYNTAX_MOTOROLA, ///< MOS65XX use $ as hex prefix -} cs_opt_value; - -/// Common instruction operand types - to be consistent across all architectures. -typedef enum cs_op_type { - CS_OP_INVALID = 0, ///< uninitialized/invalid operand. - CS_OP_REG, ///< Register operand. - CS_OP_IMM, ///< Immediate operand. - CS_OP_MEM, ///< Memory operand. - CS_OP_FP, ///< Floating-Point operand. -} cs_op_type; - -/// Common instruction operand access types - to be consistent across all architectures. -/// It is possible to combine access types, for example: CS_AC_READ | CS_AC_WRITE -typedef enum cs_ac_type { - CS_AC_INVALID = 0, ///< Uninitialized/invalid access type. - CS_AC_READ = 1 << 0, ///< Operand read from memory or register. - CS_AC_WRITE = 1 << 1, ///< Operand write to memory or register. -} cs_ac_type; - -/// Common instruction groups - to be consistent across all architectures. -typedef enum cs_group_type { - CS_GRP_INVALID = 0, ///< uninitialized/invalid group. - CS_GRP_JUMP, ///< all jump instructions (conditional+direct+indirect jumps) - CS_GRP_CALL, ///< all call instructions - CS_GRP_RET, ///< all return instructions - CS_GRP_INT, ///< all interrupt instructions (int+syscall) - CS_GRP_IRET, ///< all interrupt return instructions - CS_GRP_PRIVILEGE, ///< all privileged instructions - CS_GRP_BRANCH_RELATIVE, ///< all relative branching instructions -} cs_group_type; - -/** - User-defined callback function for SKIPDATA option. - See tests/test_skipdata.c for sample code demonstrating this API. - - @code: the input buffer containing code to be disassembled. - This is the same buffer passed to cs_disasm(). - @code_size: size (in bytes) of the above @code buffer. - @offset: the position of the currently-examining byte in the input - buffer @code mentioned above. - @user_data: user-data passed to cs_option() via @user_data field in - cs_opt_skipdata struct below. - - @return: return number of bytes to skip, or 0 to immediately stop disassembling. -*/ -typedef size_t (CAPSTONE_API *cs_skipdata_cb_t)(const uint8_t *code, size_t code_size, size_t offset, void *user_data); - -/// User-customized setup for SKIPDATA option -typedef struct cs_opt_skipdata { - /// Capstone considers data to skip as special "instructions". - /// User can specify the string for this instruction's "mnemonic" here. - /// By default (if @mnemonic is NULL), Capstone use ".byte". - const char *mnemonic; - - /// User-defined callback function to be called when Capstone hits data. - /// If the returned value from this callback is positive (>0), Capstone - /// will skip exactly that number of bytes & continue. Otherwise, if - /// the callback returns 0, Capstone stops disassembling and returns - /// immediately from cs_disasm() - /// NOTE: if this callback pointer is NULL, Capstone would skip a number - /// of bytes depending on architectures, as following: - /// Arm: 2 bytes (Thumb mode) or 4 bytes. - /// Arm64: 4 bytes. - /// Mips: 4 bytes. - /// M680x: 1 byte. - /// PowerPC: 4 bytes. - /// Sparc: 4 bytes. - /// SystemZ: 2 bytes. - /// X86: 1 bytes. - /// XCore: 2 bytes. - /// EVM: 1 bytes. - /// RISCV: 4 bytes. - /// WASM: 1 bytes. - /// MOS65XX: 1 bytes. - /// BPF: 8 bytes. - cs_skipdata_cb_t callback; // default value is NULL - - /// User-defined data to be passed to @callback function pointer. - void *user_data; -} cs_opt_skipdata; - - -#ifndef CAPSTONE_ARM_H -#define CAPSTONE_ARM_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2013-2015 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// ARM shift type -typedef enum arm_shifter { - ARM_SFT_INVALID = 0, - ARM_SFT_ASR, ///< shift with immediate const - ARM_SFT_LSL, ///< shift with immediate const - ARM_SFT_LSR, ///< shift with immediate const - ARM_SFT_ROR, ///< shift with immediate const - ARM_SFT_RRX, ///< shift with immediate const - ARM_SFT_ASR_REG, ///< shift with register - ARM_SFT_LSL_REG, ///< shift with register - ARM_SFT_LSR_REG, ///< shift with register - ARM_SFT_ROR_REG, ///< shift with register - ARM_SFT_RRX_REG, ///< shift with register -} arm_shifter; - -/// ARM condition code -typedef enum arm_cc { - ARM_CC_INVALID = 0, - ARM_CC_EQ, ///< Equal Equal - ARM_CC_NE, ///< Not equal Not equal, or unordered - ARM_CC_HS, ///< Carry set >, ==, or unordered - ARM_CC_LO, ///< Carry clear Less than - ARM_CC_MI, ///< Minus, negative Less than - ARM_CC_PL, ///< Plus, positive or zero >, ==, or unordered - ARM_CC_VS, ///< Overflow Unordered - ARM_CC_VC, ///< No overflow Not unordered - ARM_CC_HI, ///< Unsigned higher Greater than, or unordered - ARM_CC_LS, ///< Unsigned lower or same Less than or equal - ARM_CC_GE, ///< Greater than or equal Greater than or equal - ARM_CC_LT, ///< Less than Less than, or unordered - ARM_CC_GT, ///< Greater than Greater than - ARM_CC_LE, ///< Less than or equal <, ==, or unordered - ARM_CC_AL ///< Always (unconditional) Always (unconditional) -} arm_cc; - -typedef enum arm_sysreg { - /// Special registers for MSR - ARM_SYSREG_INVALID = 0, - - // SPSR* registers can be OR combined - ARM_SYSREG_SPSR_C = 1, - ARM_SYSREG_SPSR_X = 2, - ARM_SYSREG_SPSR_S = 4, - ARM_SYSREG_SPSR_F = 8, - - // CPSR* registers can be OR combined - ARM_SYSREG_CPSR_C = 16, - ARM_SYSREG_CPSR_X = 32, - ARM_SYSREG_CPSR_S = 64, - ARM_SYSREG_CPSR_F = 128, - - // independent registers - ARM_SYSREG_APSR = 256, - ARM_SYSREG_APSR_G, - ARM_SYSREG_APSR_NZCVQ, - ARM_SYSREG_APSR_NZCVQG, - - ARM_SYSREG_IAPSR, - ARM_SYSREG_IAPSR_G, - ARM_SYSREG_IAPSR_NZCVQG, - ARM_SYSREG_IAPSR_NZCVQ, - - ARM_SYSREG_EAPSR, - ARM_SYSREG_EAPSR_G, - ARM_SYSREG_EAPSR_NZCVQG, - ARM_SYSREG_EAPSR_NZCVQ, - - ARM_SYSREG_XPSR, - ARM_SYSREG_XPSR_G, - ARM_SYSREG_XPSR_NZCVQG, - ARM_SYSREG_XPSR_NZCVQ, - - ARM_SYSREG_IPSR, - ARM_SYSREG_EPSR, - ARM_SYSREG_IEPSR, - - ARM_SYSREG_MSP, - ARM_SYSREG_PSP, - ARM_SYSREG_PRIMASK, - ARM_SYSREG_BASEPRI, - ARM_SYSREG_BASEPRI_MAX, - ARM_SYSREG_FAULTMASK, - ARM_SYSREG_CONTROL, - ARM_SYSREG_MSPLIM, - ARM_SYSREG_PSPLIM, - ARM_SYSREG_MSP_NS, - ARM_SYSREG_PSP_NS, - ARM_SYSREG_MSPLIM_NS, - ARM_SYSREG_PSPLIM_NS, - ARM_SYSREG_PRIMASK_NS, - ARM_SYSREG_BASEPRI_NS, - ARM_SYSREG_FAULTMASK_NS, - ARM_SYSREG_CONTROL_NS, - ARM_SYSREG_SP_NS, - - // Banked Registers - ARM_SYSREG_R8_USR, - ARM_SYSREG_R9_USR, - ARM_SYSREG_R10_USR, - ARM_SYSREG_R11_USR, - ARM_SYSREG_R12_USR, - ARM_SYSREG_SP_USR, - ARM_SYSREG_LR_USR, - ARM_SYSREG_R8_FIQ, - ARM_SYSREG_R9_FIQ, - ARM_SYSREG_R10_FIQ, - ARM_SYSREG_R11_FIQ, - ARM_SYSREG_R12_FIQ, - ARM_SYSREG_SP_FIQ, - ARM_SYSREG_LR_FIQ, - ARM_SYSREG_LR_IRQ, - ARM_SYSREG_SP_IRQ, - ARM_SYSREG_LR_SVC, - ARM_SYSREG_SP_SVC, - ARM_SYSREG_LR_ABT, - ARM_SYSREG_SP_ABT, - ARM_SYSREG_LR_UND, - ARM_SYSREG_SP_UND, - ARM_SYSREG_LR_MON, - ARM_SYSREG_SP_MON, - ARM_SYSREG_ELR_HYP, - ARM_SYSREG_SP_HYP, - - ARM_SYSREG_SPSR_FIQ, - ARM_SYSREG_SPSR_IRQ, - ARM_SYSREG_SPSR_SVC, - ARM_SYSREG_SPSR_ABT, - ARM_SYSREG_SPSR_UND, - ARM_SYSREG_SPSR_MON, - ARM_SYSREG_SPSR_HYP, -} arm_sysreg; - -/// The memory barrier constants map directly to the 4-bit encoding of -/// the option field for Memory Barrier operations. -typedef enum arm_mem_barrier { - ARM_MB_INVALID = 0, - ARM_MB_RESERVED_0, - ARM_MB_OSHLD, - ARM_MB_OSHST, - ARM_MB_OSH, - ARM_MB_RESERVED_4, - ARM_MB_NSHLD, - ARM_MB_NSHST, - ARM_MB_NSH, - ARM_MB_RESERVED_8, - ARM_MB_ISHLD, - ARM_MB_ISHST, - ARM_MB_ISH, - ARM_MB_RESERVED_12, - ARM_MB_LD, - ARM_MB_ST, - ARM_MB_SY, -} arm_mem_barrier; - -/// Operand type for instruction's operands -typedef enum arm_op_type { - ARM_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - ARM_OP_REG, ///< = CS_OP_REG (Register operand). - ARM_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - ARM_OP_MEM, ///< = CS_OP_MEM (Memory operand). - ARM_OP_FP, ///< = CS_OP_FP (Floating-Point operand). - ARM_OP_CIMM = 64, ///< C-Immediate (coprocessor registers) - ARM_OP_PIMM, ///< P-Immediate (coprocessor registers) - ARM_OP_SETEND, ///< operand for SETEND instruction - ARM_OP_SYSREG, ///< MSR/MRS special register operand -} arm_op_type; - -/// Operand type for SETEND instruction -typedef enum arm_setend_type { - ARM_SETEND_INVALID = 0, ///< Uninitialized. - ARM_SETEND_BE, ///< BE operand. - ARM_SETEND_LE, ///< LE operand -} arm_setend_type; - -typedef enum arm_cpsmode_type { - ARM_CPSMODE_INVALID = 0, - ARM_CPSMODE_IE = 2, - ARM_CPSMODE_ID = 3 -} arm_cpsmode_type; - -/// Operand type for SETEND instruction -typedef enum arm_cpsflag_type { - ARM_CPSFLAG_INVALID = 0, - ARM_CPSFLAG_F = 1, - ARM_CPSFLAG_I = 2, - ARM_CPSFLAG_A = 4, - ARM_CPSFLAG_NONE = 16, ///< no flag -} arm_cpsflag_type; - -/// Data type for elements of vector instructions. -typedef enum arm_vectordata_type { - ARM_VECTORDATA_INVALID = 0, - - // Integer type - ARM_VECTORDATA_I8, - ARM_VECTORDATA_I16, - ARM_VECTORDATA_I32, - ARM_VECTORDATA_I64, - - // Signed integer type - ARM_VECTORDATA_S8, - ARM_VECTORDATA_S16, - ARM_VECTORDATA_S32, - ARM_VECTORDATA_S64, - - // Unsigned integer type - ARM_VECTORDATA_U8, - ARM_VECTORDATA_U16, - ARM_VECTORDATA_U32, - ARM_VECTORDATA_U64, - - // Data type for VMUL/VMULL - ARM_VECTORDATA_P8, - - // Floating type - ARM_VECTORDATA_F16, - ARM_VECTORDATA_F32, - ARM_VECTORDATA_F64, - - // Convert float <-> float - ARM_VECTORDATA_F16F64, // f16.f64 - ARM_VECTORDATA_F64F16, // f64.f16 - ARM_VECTORDATA_F32F16, // f32.f16 - ARM_VECTORDATA_F16F32, // f32.f16 - ARM_VECTORDATA_F64F32, // f64.f32 - ARM_VECTORDATA_F32F64, // f32.f64 - - // Convert integer <-> float - ARM_VECTORDATA_S32F32, // s32.f32 - ARM_VECTORDATA_U32F32, // u32.f32 - ARM_VECTORDATA_F32S32, // f32.s32 - ARM_VECTORDATA_F32U32, // f32.u32 - ARM_VECTORDATA_F64S16, // f64.s16 - ARM_VECTORDATA_F32S16, // f32.s16 - ARM_VECTORDATA_F64S32, // f64.s32 - ARM_VECTORDATA_S16F64, // s16.f64 - ARM_VECTORDATA_S16F32, // s16.f64 - ARM_VECTORDATA_S32F64, // s32.f64 - ARM_VECTORDATA_U16F64, // u16.f64 - ARM_VECTORDATA_U16F32, // u16.f32 - ARM_VECTORDATA_U32F64, // u32.f64 - ARM_VECTORDATA_F64U16, // f64.u16 - ARM_VECTORDATA_F32U16, // f32.u16 - ARM_VECTORDATA_F64U32, // f64.u32 - ARM_VECTORDATA_F16U16, // f16.u16 - ARM_VECTORDATA_U16F16, // u16.f16 - ARM_VECTORDATA_F16U32, // f16.u32 - ARM_VECTORDATA_U32F16, // u32.f16 -} arm_vectordata_type; - -/// ARM registers -typedef enum arm_reg { - ARM_REG_INVALID = 0, - ARM_REG_APSR, - ARM_REG_APSR_NZCV, - ARM_REG_CPSR, - ARM_REG_FPEXC, - ARM_REG_FPINST, - ARM_REG_FPSCR, - ARM_REG_FPSCR_NZCV, - ARM_REG_FPSID, - ARM_REG_ITSTATE, - ARM_REG_LR, - ARM_REG_PC, - ARM_REG_SP, - ARM_REG_SPSR, - ARM_REG_D0, - ARM_REG_D1, - ARM_REG_D2, - ARM_REG_D3, - ARM_REG_D4, - ARM_REG_D5, - ARM_REG_D6, - ARM_REG_D7, - ARM_REG_D8, - ARM_REG_D9, - ARM_REG_D10, - ARM_REG_D11, - ARM_REG_D12, - ARM_REG_D13, - ARM_REG_D14, - ARM_REG_D15, - ARM_REG_D16, - ARM_REG_D17, - ARM_REG_D18, - ARM_REG_D19, - ARM_REG_D20, - ARM_REG_D21, - ARM_REG_D22, - ARM_REG_D23, - ARM_REG_D24, - ARM_REG_D25, - ARM_REG_D26, - ARM_REG_D27, - ARM_REG_D28, - ARM_REG_D29, - ARM_REG_D30, - ARM_REG_D31, - ARM_REG_FPINST2, - ARM_REG_MVFR0, - ARM_REG_MVFR1, - ARM_REG_MVFR2, - ARM_REG_Q0, - ARM_REG_Q1, - ARM_REG_Q2, - ARM_REG_Q3, - ARM_REG_Q4, - ARM_REG_Q5, - ARM_REG_Q6, - ARM_REG_Q7, - ARM_REG_Q8, - ARM_REG_Q9, - ARM_REG_Q10, - ARM_REG_Q11, - ARM_REG_Q12, - ARM_REG_Q13, - ARM_REG_Q14, - ARM_REG_Q15, - ARM_REG_R0, - ARM_REG_R1, - ARM_REG_R2, - ARM_REG_R3, - ARM_REG_R4, - ARM_REG_R5, - ARM_REG_R6, - ARM_REG_R7, - ARM_REG_R8, - ARM_REG_R9, - ARM_REG_R10, - ARM_REG_R11, - ARM_REG_R12, - ARM_REG_S0, - ARM_REG_S1, - ARM_REG_S2, - ARM_REG_S3, - ARM_REG_S4, - ARM_REG_S5, - ARM_REG_S6, - ARM_REG_S7, - ARM_REG_S8, - ARM_REG_S9, - ARM_REG_S10, - ARM_REG_S11, - ARM_REG_S12, - ARM_REG_S13, - ARM_REG_S14, - ARM_REG_S15, - ARM_REG_S16, - ARM_REG_S17, - ARM_REG_S18, - ARM_REG_S19, - ARM_REG_S20, - ARM_REG_S21, - ARM_REG_S22, - ARM_REG_S23, - ARM_REG_S24, - ARM_REG_S25, - ARM_REG_S26, - ARM_REG_S27, - ARM_REG_S28, - ARM_REG_S29, - ARM_REG_S30, - ARM_REG_S31, - - ARM_REG_ENDING, // <-- mark the end of the list or registers - - // alias registers - ARM_REG_R13 = ARM_REG_SP, - ARM_REG_R14 = ARM_REG_LR, - ARM_REG_R15 = ARM_REG_PC, - - ARM_REG_SB = ARM_REG_R9, - ARM_REG_SL = ARM_REG_R10, - ARM_REG_FP = ARM_REG_R11, - ARM_REG_IP = ARM_REG_R12, -} arm_reg; - -/// Instruction's operand referring to memory -/// This is associated with ARM_OP_MEM operand type above -typedef struct arm_op_mem { - arm_reg base; ///< base register - arm_reg index; ///< index register - int scale; ///< scale for index register (can be 1, or -1) - int disp; ///< displacement/offset value - /// left-shift on index register, or 0 if irrelevant - /// NOTE: this value can also be fetched via operand.shift.value - int lshift; -} arm_op_mem; - -/// Instruction operand -typedef struct cs_arm_op { - int vector_index; ///< Vector Index for some vector operands (or -1 if irrelevant) - - struct { - arm_shifter type; - unsigned int value; - } shift; - - arm_op_type type; ///< operand type - - union { - int reg; ///< register value for REG/SYSREG operand - int32_t imm; ///< immediate value for C-IMM, P-IMM or IMM operand - double fp; ///< floating point value for FP operand - arm_op_mem mem; ///< base/index/scale/disp value for MEM operand - arm_setend_type setend; ///< SETEND instruction's operand type - }; - - /// in some instructions, an operand can be subtracted or added to - /// the base register, - /// if TRUE, this operand is subtracted. otherwise, it is added. - bool subtracted; - - /// How is this operand accessed? (READ, WRITE or READ|WRITE) - /// This field is combined of cs_ac_type. - /// NOTE: this field is irrelevant if engine is compiled in DIET mode. - uint8_t access; - - /// Neon lane index for NEON instructions (or -1 if irrelevant) - int8_t neon_lane; -} cs_arm_op; - -/// Instruction structure -typedef struct cs_arm { - bool usermode; ///< User-mode registers to be loaded (for LDM/STM instructions) - int vector_size; ///< Scalar size for vector instructions - arm_vectordata_type vector_data; ///< Data type for elements of vector instructions - arm_cpsmode_type cps_mode; ///< CPS mode for CPS instruction - arm_cpsflag_type cps_flag; ///< CPS mode for CPS instruction - arm_cc cc; ///< conditional code for this insn - bool update_flags; ///< does this insn update flags? - bool writeback; ///< does this insn write-back? - arm_mem_barrier mem_barrier; ///< Option for some memory barrier instructions - - /// Number of operands of this instruction, - /// or 0 when instruction has no operand. - uint8_t op_count; - - cs_arm_op operands[36]; ///< operands for this instruction. -} cs_arm; - -/// ARM instruction -typedef enum arm_insn { - ARM_INS_INVALID = 0, - - ARM_INS_ADC, - ARM_INS_ADD, - ARM_INS_ADDW, - ARM_INS_ADR, - ARM_INS_AESD, - ARM_INS_AESE, - ARM_INS_AESIMC, - ARM_INS_AESMC, - ARM_INS_AND, - ARM_INS_ASR, - ARM_INS_B, - ARM_INS_BFC, - ARM_INS_BFI, - ARM_INS_BIC, - ARM_INS_BKPT, - ARM_INS_BL, - ARM_INS_BLX, - ARM_INS_BLXNS, - ARM_INS_BX, - ARM_INS_BXJ, - ARM_INS_BXNS, - ARM_INS_CBNZ, - ARM_INS_CBZ, - ARM_INS_CDP, - ARM_INS_CDP2, - ARM_INS_CLREX, - ARM_INS_CLZ, - ARM_INS_CMN, - ARM_INS_CMP, - ARM_INS_CPS, - ARM_INS_CRC32B, - ARM_INS_CRC32CB, - ARM_INS_CRC32CH, - ARM_INS_CRC32CW, - ARM_INS_CRC32H, - ARM_INS_CRC32W, - ARM_INS_CSDB, - ARM_INS_DBG, - ARM_INS_DCPS1, - ARM_INS_DCPS2, - ARM_INS_DCPS3, - ARM_INS_DFB, - ARM_INS_DMB, - ARM_INS_DSB, - ARM_INS_EOR, - ARM_INS_ERET, - ARM_INS_ESB, - ARM_INS_FADDD, - ARM_INS_FADDS, - ARM_INS_FCMPZD, - ARM_INS_FCMPZS, - ARM_INS_FCONSTD, - ARM_INS_FCONSTS, - ARM_INS_FLDMDBX, - ARM_INS_FLDMIAX, - ARM_INS_FMDHR, - ARM_INS_FMDLR, - ARM_INS_FMSTAT, - ARM_INS_FSTMDBX, - ARM_INS_FSTMIAX, - ARM_INS_FSUBD, - ARM_INS_FSUBS, - ARM_INS_HINT, - ARM_INS_HLT, - ARM_INS_HVC, - ARM_INS_ISB, - ARM_INS_IT, - ARM_INS_LDA, - ARM_INS_LDAB, - ARM_INS_LDAEX, - ARM_INS_LDAEXB, - ARM_INS_LDAEXD, - ARM_INS_LDAEXH, - ARM_INS_LDAH, - ARM_INS_LDC, - ARM_INS_LDC2, - ARM_INS_LDC2L, - ARM_INS_LDCL, - ARM_INS_LDM, - ARM_INS_LDMDA, - ARM_INS_LDMDB, - ARM_INS_LDMIB, - ARM_INS_LDR, - ARM_INS_LDRB, - ARM_INS_LDRBT, - ARM_INS_LDRD, - ARM_INS_LDREX, - ARM_INS_LDREXB, - ARM_INS_LDREXD, - ARM_INS_LDREXH, - ARM_INS_LDRH, - ARM_INS_LDRHT, - ARM_INS_LDRSB, - ARM_INS_LDRSBT, - ARM_INS_LDRSH, - ARM_INS_LDRSHT, - ARM_INS_LDRT, - ARM_INS_LSL, - ARM_INS_LSR, - ARM_INS_MCR, - ARM_INS_MCR2, - ARM_INS_MCRR, - ARM_INS_MCRR2, - ARM_INS_MLA, - ARM_INS_MLS, - ARM_INS_MOV, - ARM_INS_MOVS, - ARM_INS_MOVT, - ARM_INS_MOVW, - ARM_INS_MRC, - ARM_INS_MRC2, - ARM_INS_MRRC, - ARM_INS_MRRC2, - ARM_INS_MRS, - ARM_INS_MSR, - ARM_INS_MUL, - ARM_INS_MVN, - ARM_INS_NEG, - ARM_INS_NOP, - ARM_INS_ORN, - ARM_INS_ORR, - ARM_INS_PKHBT, - ARM_INS_PKHTB, - ARM_INS_PLD, - ARM_INS_PLDW, - ARM_INS_PLI, - ARM_INS_POP, - ARM_INS_PUSH, - ARM_INS_QADD, - ARM_INS_QADD16, - ARM_INS_QADD8, - ARM_INS_QASX, - ARM_INS_QDADD, - ARM_INS_QDSUB, - ARM_INS_QSAX, - ARM_INS_QSUB, - ARM_INS_QSUB16, - ARM_INS_QSUB8, - ARM_INS_RBIT, - ARM_INS_REV, - ARM_INS_REV16, - ARM_INS_REVSH, - ARM_INS_RFEDA, - ARM_INS_RFEDB, - ARM_INS_RFEIA, - ARM_INS_RFEIB, - ARM_INS_ROR, - ARM_INS_RRX, - ARM_INS_RSB, - ARM_INS_RSC, - ARM_INS_SADD16, - ARM_INS_SADD8, - ARM_INS_SASX, - ARM_INS_SBC, - ARM_INS_SBFX, - ARM_INS_SDIV, - ARM_INS_SEL, - ARM_INS_SETEND, - ARM_INS_SETPAN, - ARM_INS_SEV, - ARM_INS_SEVL, - ARM_INS_SG, - ARM_INS_SHA1C, - ARM_INS_SHA1H, - ARM_INS_SHA1M, - ARM_INS_SHA1P, - ARM_INS_SHA1SU0, - ARM_INS_SHA1SU1, - ARM_INS_SHA256H, - ARM_INS_SHA256H2, - ARM_INS_SHA256SU0, - ARM_INS_SHA256SU1, - ARM_INS_SHADD16, - ARM_INS_SHADD8, - ARM_INS_SHASX, - ARM_INS_SHSAX, - ARM_INS_SHSUB16, - ARM_INS_SHSUB8, - ARM_INS_SMC, - ARM_INS_SMLABB, - ARM_INS_SMLABT, - ARM_INS_SMLAD, - ARM_INS_SMLADX, - ARM_INS_SMLAL, - ARM_INS_SMLALBB, - ARM_INS_SMLALBT, - ARM_INS_SMLALD, - ARM_INS_SMLALDX, - ARM_INS_SMLALTB, - ARM_INS_SMLALTT, - ARM_INS_SMLATB, - ARM_INS_SMLATT, - ARM_INS_SMLAWB, - ARM_INS_SMLAWT, - ARM_INS_SMLSD, - ARM_INS_SMLSDX, - ARM_INS_SMLSLD, - ARM_INS_SMLSLDX, - ARM_INS_SMMLA, - ARM_INS_SMMLAR, - ARM_INS_SMMLS, - ARM_INS_SMMLSR, - ARM_INS_SMMUL, - ARM_INS_SMMULR, - ARM_INS_SMUAD, - ARM_INS_SMUADX, - ARM_INS_SMULBB, - ARM_INS_SMULBT, - ARM_INS_SMULL, - ARM_INS_SMULTB, - ARM_INS_SMULTT, - ARM_INS_SMULWB, - ARM_INS_SMULWT, - ARM_INS_SMUSD, - ARM_INS_SMUSDX, - ARM_INS_SRSDA, - ARM_INS_SRSDB, - ARM_INS_SRSIA, - ARM_INS_SRSIB, - ARM_INS_SSAT, - ARM_INS_SSAT16, - ARM_INS_SSAX, - ARM_INS_SSUB16, - ARM_INS_SSUB8, - ARM_INS_STC, - ARM_INS_STC2, - ARM_INS_STC2L, - ARM_INS_STCL, - ARM_INS_STL, - ARM_INS_STLB, - ARM_INS_STLEX, - ARM_INS_STLEXB, - ARM_INS_STLEXD, - ARM_INS_STLEXH, - ARM_INS_STLH, - ARM_INS_STM, - ARM_INS_STMDA, - ARM_INS_STMDB, - ARM_INS_STMIB, - ARM_INS_STR, - ARM_INS_STRB, - ARM_INS_STRBT, - ARM_INS_STRD, - ARM_INS_STREX, - ARM_INS_STREXB, - ARM_INS_STREXD, - ARM_INS_STREXH, - ARM_INS_STRH, - ARM_INS_STRHT, - ARM_INS_STRT, - ARM_INS_SUB, - ARM_INS_SUBS, - ARM_INS_SUBW, - ARM_INS_SVC, - ARM_INS_SWP, - ARM_INS_SWPB, - ARM_INS_SXTAB, - ARM_INS_SXTAB16, - ARM_INS_SXTAH, - ARM_INS_SXTB, - ARM_INS_SXTB16, - ARM_INS_SXTH, - ARM_INS_TBB, - ARM_INS_TBH, - ARM_INS_TEQ, - ARM_INS_TRAP, - ARM_INS_TSB, - ARM_INS_TST, - ARM_INS_TT, - ARM_INS_TTA, - ARM_INS_TTAT, - ARM_INS_TTT, - ARM_INS_UADD16, - ARM_INS_UADD8, - ARM_INS_UASX, - ARM_INS_UBFX, - ARM_INS_UDF, - ARM_INS_UDIV, - ARM_INS_UHADD16, - ARM_INS_UHADD8, - ARM_INS_UHASX, - ARM_INS_UHSAX, - ARM_INS_UHSUB16, - ARM_INS_UHSUB8, - ARM_INS_UMAAL, - ARM_INS_UMLAL, - ARM_INS_UMULL, - ARM_INS_UQADD16, - ARM_INS_UQADD8, - ARM_INS_UQASX, - ARM_INS_UQSAX, - ARM_INS_UQSUB16, - ARM_INS_UQSUB8, - ARM_INS_USAD8, - ARM_INS_USADA8, - ARM_INS_USAT, - ARM_INS_USAT16, - ARM_INS_USAX, - ARM_INS_USUB16, - ARM_INS_USUB8, - ARM_INS_UXTAB, - ARM_INS_UXTAB16, - ARM_INS_UXTAH, - ARM_INS_UXTB, - ARM_INS_UXTB16, - ARM_INS_UXTH, - ARM_INS_VABA, - ARM_INS_VABAL, - ARM_INS_VABD, - ARM_INS_VABDL, - ARM_INS_VABS, - ARM_INS_VACGE, - ARM_INS_VACGT, - ARM_INS_VACLE, - ARM_INS_VACLT, - ARM_INS_VADD, - ARM_INS_VADDHN, - ARM_INS_VADDL, - ARM_INS_VADDW, - ARM_INS_VAND, - ARM_INS_VBIC, - ARM_INS_VBIF, - ARM_INS_VBIT, - ARM_INS_VBSL, - ARM_INS_VCADD, - ARM_INS_VCEQ, - ARM_INS_VCGE, - ARM_INS_VCGT, - ARM_INS_VCLE, - ARM_INS_VCLS, - ARM_INS_VCLT, - ARM_INS_VCLZ, - ARM_INS_VCMLA, - ARM_INS_VCMP, - ARM_INS_VCMPE, - ARM_INS_VCNT, - ARM_INS_VCVT, - ARM_INS_VCVTA, - ARM_INS_VCVTB, - ARM_INS_VCVTM, - ARM_INS_VCVTN, - ARM_INS_VCVTP, - ARM_INS_VCVTR, - ARM_INS_VCVTT, - ARM_INS_VDIV, - ARM_INS_VDUP, - ARM_INS_VEOR, - ARM_INS_VEXT, - ARM_INS_VFMA, - ARM_INS_VFMS, - ARM_INS_VFNMA, - ARM_INS_VFNMS, - ARM_INS_VHADD, - ARM_INS_VHSUB, - ARM_INS_VINS, - ARM_INS_VJCVT, - ARM_INS_VLD1, - ARM_INS_VLD2, - ARM_INS_VLD3, - ARM_INS_VLD4, - ARM_INS_VLDMDB, - ARM_INS_VLDMIA, - ARM_INS_VLDR, - ARM_INS_VLLDM, - ARM_INS_VLSTM, - ARM_INS_VMAX, - ARM_INS_VMAXNM, - ARM_INS_VMIN, - ARM_INS_VMINNM, - ARM_INS_VMLA, - ARM_INS_VMLAL, - ARM_INS_VMLS, - ARM_INS_VMLSL, - ARM_INS_VMOV, - ARM_INS_VMOVL, - ARM_INS_VMOVN, - ARM_INS_VMOVX, - ARM_INS_VMRS, - ARM_INS_VMSR, - ARM_INS_VMUL, - ARM_INS_VMULL, - ARM_INS_VMVN, - ARM_INS_VNEG, - ARM_INS_VNMLA, - ARM_INS_VNMLS, - ARM_INS_VNMUL, - ARM_INS_VORN, - ARM_INS_VORR, - ARM_INS_VPADAL, - ARM_INS_VPADD, - ARM_INS_VPADDL, - ARM_INS_VPMAX, - ARM_INS_VPMIN, - ARM_INS_VPOP, - ARM_INS_VPUSH, - ARM_INS_VQABS, - ARM_INS_VQADD, - ARM_INS_VQDMLAL, - ARM_INS_VQDMLSL, - ARM_INS_VQDMULH, - ARM_INS_VQDMULL, - ARM_INS_VQMOVN, - ARM_INS_VQMOVUN, - ARM_INS_VQNEG, - ARM_INS_VQRDMLAH, - ARM_INS_VQRDMLSH, - ARM_INS_VQRDMULH, - ARM_INS_VQRSHL, - ARM_INS_VQRSHRN, - ARM_INS_VQRSHRUN, - ARM_INS_VQSHL, - ARM_INS_VQSHLU, - ARM_INS_VQSHRN, - ARM_INS_VQSHRUN, - ARM_INS_VQSUB, - ARM_INS_VRADDHN, - ARM_INS_VRECPE, - ARM_INS_VRECPS, - ARM_INS_VREV16, - ARM_INS_VREV32, - ARM_INS_VREV64, - ARM_INS_VRHADD, - ARM_INS_VRINTA, - ARM_INS_VRINTM, - ARM_INS_VRINTN, - ARM_INS_VRINTP, - ARM_INS_VRINTR, - ARM_INS_VRINTX, - ARM_INS_VRINTZ, - ARM_INS_VRSHL, - ARM_INS_VRSHR, - ARM_INS_VRSHRN, - ARM_INS_VRSQRTE, - ARM_INS_VRSQRTS, - ARM_INS_VRSRA, - ARM_INS_VRSUBHN, - ARM_INS_VSDOT, - ARM_INS_VSELEQ, - ARM_INS_VSELGE, - ARM_INS_VSELGT, - ARM_INS_VSELVS, - ARM_INS_VSHL, - ARM_INS_VSHLL, - ARM_INS_VSHR, - ARM_INS_VSHRN, - ARM_INS_VSLI, - ARM_INS_VSQRT, - ARM_INS_VSRA, - ARM_INS_VSRI, - ARM_INS_VST1, - ARM_INS_VST2, - ARM_INS_VST3, - ARM_INS_VST4, - ARM_INS_VSTMDB, - ARM_INS_VSTMIA, - ARM_INS_VSTR, - ARM_INS_VSUB, - ARM_INS_VSUBHN, - ARM_INS_VSUBL, - ARM_INS_VSUBW, - ARM_INS_VSWP, - ARM_INS_VTBL, - ARM_INS_VTBX, - ARM_INS_VTRN, - ARM_INS_VTST, - ARM_INS_VUDOT, - ARM_INS_VUZP, - ARM_INS_VZIP, - ARM_INS_WFE, - ARM_INS_WFI, - ARM_INS_YIELD, - - ARM_INS_ENDING, // <-- mark the end of the list of instructions -} arm_insn; - -/// Group of ARM instructions -typedef enum arm_insn_group { - ARM_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - // Generic groups - // all jump instructions (conditional+direct+indirect jumps) - ARM_GRP_JUMP, ///< = CS_GRP_JUMP - ARM_GRP_CALL, ///< = CS_GRP_CALL - ARM_GRP_INT = 4, ///< = CS_GRP_INT - ARM_GRP_PRIVILEGE = 6, ///< = CS_GRP_PRIVILEGE - ARM_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE - - // Architecture-specific groups - ARM_GRP_CRYPTO = 128, - ARM_GRP_DATABARRIER, - ARM_GRP_DIVIDE, - ARM_GRP_FPARMV8, - ARM_GRP_MULTPRO, - ARM_GRP_NEON, - ARM_GRP_T2EXTRACTPACK, - ARM_GRP_THUMB2DSP, - ARM_GRP_TRUSTZONE, - ARM_GRP_V4T, - ARM_GRP_V5T, - ARM_GRP_V5TE, - ARM_GRP_V6, - ARM_GRP_V6T2, - ARM_GRP_V7, - ARM_GRP_V8, - ARM_GRP_VFP2, - ARM_GRP_VFP3, - ARM_GRP_VFP4, - ARM_GRP_ARM, - ARM_GRP_MCLASS, - ARM_GRP_NOTMCLASS, - ARM_GRP_THUMB, - ARM_GRP_THUMB1ONLY, - ARM_GRP_THUMB2, - ARM_GRP_PREV8, - ARM_GRP_FPVMLX, - ARM_GRP_MULOPS, - ARM_GRP_CRC, - ARM_GRP_DPVFP, - ARM_GRP_V6M, - ARM_GRP_VIRTUALIZATION, - - ARM_GRP_ENDING, -} arm_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_ARM64_H -#define CAPSTONE_ARM64_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2013-2015 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// ARM64 shift type -typedef enum arm64_shifter { - ARM64_SFT_INVALID = 0, - ARM64_SFT_LSL = 1, - ARM64_SFT_MSL = 2, - ARM64_SFT_LSR = 3, - ARM64_SFT_ASR = 4, - ARM64_SFT_ROR = 5, -} arm64_shifter; - -/// ARM64 extender type -typedef enum arm64_extender { - ARM64_EXT_INVALID = 0, - ARM64_EXT_UXTB = 1, - ARM64_EXT_UXTH = 2, - ARM64_EXT_UXTW = 3, - ARM64_EXT_UXTX = 4, - ARM64_EXT_SXTB = 5, - ARM64_EXT_SXTH = 6, - ARM64_EXT_SXTW = 7, - ARM64_EXT_SXTX = 8, -} arm64_extender; - -/// ARM64 condition code -typedef enum arm64_cc { - ARM64_CC_INVALID = 0, - ARM64_CC_EQ = 1, ///< Equal - ARM64_CC_NE = 2, ///< Not equal: Not equal, or unordered - ARM64_CC_HS = 3, ///< Unsigned higher or same: >, ==, or unordered - ARM64_CC_LO = 4, ///< Unsigned lower or same: Less than - ARM64_CC_MI = 5, ///< Minus, negative: Less than - ARM64_CC_PL = 6, ///< Plus, positive or zero: >, ==, or unordered - ARM64_CC_VS = 7, ///< Overflow: Unordered - ARM64_CC_VC = 8, ///< No overflow: Ordered - ARM64_CC_HI = 9, ///< Unsigned higher: Greater than, or unordered - ARM64_CC_LS = 10, ///< Unsigned lower or same: Less than or equal - ARM64_CC_GE = 11, ///< Greater than or equal: Greater than or equal - ARM64_CC_LT = 12, ///< Less than: Less than, or unordered - ARM64_CC_GT = 13, ///< Signed greater than: Greater than - ARM64_CC_LE = 14, ///< Signed less than or equal: <, ==, or unordered - ARM64_CC_AL = 15, ///< Always (unconditional): Always (unconditional) - ARM64_CC_NV = 16, ///< Always (unconditional): Always (unconditional) - //< Note the NV exists purely to disassemble 0b1111. Execution is "always". -} arm64_cc; - -/// System registers -typedef enum arm64_sysreg { - // System registers for MRS - ARM64_SYSREG_INVALID = 0, - - ARM64_SYSREG_MDCCSR_EL0 = 0x9808, - ARM64_SYSREG_DBGDTRRX_EL0 = 0x9828, - ARM64_SYSREG_MDRAR_EL1 = 0x8080, - ARM64_SYSREG_OSLSR_EL1 = 0x808C, - ARM64_SYSREG_DBGAUTHSTATUS_EL1 = 0x83F6, - ARM64_SYSREG_PMCEID0_EL0 = 0xDCE6, - ARM64_SYSREG_PMCEID1_EL0 = 0xDCE7, - ARM64_SYSREG_MIDR_EL1 = 0xC000, - ARM64_SYSREG_CCSIDR_EL1 = 0xC800, - ARM64_SYSREG_CCSIDR2_EL1 = 0xC802, - ARM64_SYSREG_CLIDR_EL1 = 0xC801, - ARM64_SYSREG_CTR_EL0 = 0xD801, - ARM64_SYSREG_MPIDR_EL1 = 0xC005, - ARM64_SYSREG_REVIDR_EL1 = 0xC006, - ARM64_SYSREG_AIDR_EL1 = 0xC807, - ARM64_SYSREG_DCZID_EL0 = 0xD807, - ARM64_SYSREG_ID_PFR0_EL1 = 0xC008, - ARM64_SYSREG_ID_PFR1_EL1 = 0xC009, - ARM64_SYSREG_ID_DFR0_EL1 = 0xC00A, - ARM64_SYSREG_ID_AFR0_EL1 = 0xC00B, - ARM64_SYSREG_ID_MMFR0_EL1 = 0xC00C, - ARM64_SYSREG_ID_MMFR1_EL1 = 0xC00D, - ARM64_SYSREG_ID_MMFR2_EL1 = 0xC00E, - ARM64_SYSREG_ID_MMFR3_EL1 = 0xC00F, - ARM64_SYSREG_ID_ISAR0_EL1 = 0xC010, - ARM64_SYSREG_ID_ISAR1_EL1 = 0xC011, - ARM64_SYSREG_ID_ISAR2_EL1 = 0xC012, - ARM64_SYSREG_ID_ISAR3_EL1 = 0xC013, - ARM64_SYSREG_ID_ISAR4_EL1 = 0xC014, - ARM64_SYSREG_ID_ISAR5_EL1 = 0xC015, - ARM64_SYSREG_ID_ISAR6_EL1 = 0xC017, - ARM64_SYSREG_ID_AA64PFR0_EL1 = 0xC020, - ARM64_SYSREG_ID_AA64PFR1_EL1 = 0xC021, - ARM64_SYSREG_ID_AA64DFR0_EL1 = 0xC028, - ARM64_SYSREG_ID_AA64DFR1_EL1 = 0xC029, - ARM64_SYSREG_ID_AA64AFR0_EL1 = 0xC02C, - ARM64_SYSREG_ID_AA64AFR1_EL1 = 0xC02D, - ARM64_SYSREG_ID_AA64ISAR0_EL1 = 0xC030, - ARM64_SYSREG_ID_AA64ISAR1_EL1 = 0xC031, - ARM64_SYSREG_ID_AA64MMFR0_EL1 = 0xC038, - ARM64_SYSREG_ID_AA64MMFR1_EL1 = 0xC039, - ARM64_SYSREG_ID_AA64MMFR2_EL1 = 0xC03A, - ARM64_SYSREG_MVFR0_EL1 = 0xC018, - ARM64_SYSREG_MVFR1_EL1 = 0xC019, - ARM64_SYSREG_MVFR2_EL1 = 0xC01A, - ARM64_SYSREG_RVBAR_EL1 = 0xC601, - ARM64_SYSREG_RVBAR_EL2 = 0xE601, - ARM64_SYSREG_RVBAR_EL3 = 0xF601, - ARM64_SYSREG_ISR_EL1 = 0xC608, - ARM64_SYSREG_CNTPCT_EL0 = 0xDF01, - ARM64_SYSREG_CNTVCT_EL0 = 0xDF02, - ARM64_SYSREG_ID_MMFR4_EL1 = 0xC016, - ARM64_SYSREG_TRCSTATR = 0x8818, - ARM64_SYSREG_TRCIDR8 = 0x8806, - ARM64_SYSREG_TRCIDR9 = 0x880E, - ARM64_SYSREG_TRCIDR10 = 0x8816, - ARM64_SYSREG_TRCIDR11 = 0x881E, - ARM64_SYSREG_TRCIDR12 = 0x8826, - ARM64_SYSREG_TRCIDR13 = 0x882E, - ARM64_SYSREG_TRCIDR0 = 0x8847, - ARM64_SYSREG_TRCIDR1 = 0x884F, - ARM64_SYSREG_TRCIDR2 = 0x8857, - ARM64_SYSREG_TRCIDR3 = 0x885F, - ARM64_SYSREG_TRCIDR4 = 0x8867, - ARM64_SYSREG_TRCIDR5 = 0x886F, - ARM64_SYSREG_TRCIDR6 = 0x8877, - ARM64_SYSREG_TRCIDR7 = 0x887F, - ARM64_SYSREG_TRCOSLSR = 0x888C, - ARM64_SYSREG_TRCPDSR = 0x88AC, - ARM64_SYSREG_TRCDEVAFF0 = 0x8BD6, - ARM64_SYSREG_TRCDEVAFF1 = 0x8BDE, - ARM64_SYSREG_TRCLSR = 0x8BEE, - ARM64_SYSREG_TRCAUTHSTATUS = 0x8BF6, - ARM64_SYSREG_TRCDEVARCH = 0x8BFE, - ARM64_SYSREG_TRCDEVID = 0x8B97, - ARM64_SYSREG_TRCDEVTYPE = 0x8B9F, - ARM64_SYSREG_TRCPIDR4 = 0x8BA7, - ARM64_SYSREG_TRCPIDR5 = 0x8BAF, - ARM64_SYSREG_TRCPIDR6 = 0x8BB7, - ARM64_SYSREG_TRCPIDR7 = 0x8BBF, - ARM64_SYSREG_TRCPIDR0 = 0x8BC7, - ARM64_SYSREG_TRCPIDR1 = 0x8BCF, - ARM64_SYSREG_TRCPIDR2 = 0x8BD7, - ARM64_SYSREG_TRCPIDR3 = 0x8BDF, - ARM64_SYSREG_TRCCIDR0 = 0x8BE7, - ARM64_SYSREG_TRCCIDR1 = 0x8BEF, - ARM64_SYSREG_TRCCIDR2 = 0x8BF7, - ARM64_SYSREG_TRCCIDR3 = 0x8BFF, - ARM64_SYSREG_ICC_IAR1_EL1 = 0xC660, - ARM64_SYSREG_ICC_IAR0_EL1 = 0xC640, - ARM64_SYSREG_ICC_HPPIR1_EL1 = 0xC662, - ARM64_SYSREG_ICC_HPPIR0_EL1 = 0xC642, - ARM64_SYSREG_ICC_RPR_EL1 = 0xC65B, - ARM64_SYSREG_ICH_VTR_EL2 = 0xE659, - ARM64_SYSREG_ICH_EISR_EL2 = 0xE65B, - ARM64_SYSREG_ICH_ELRSR_EL2 = 0xE65D, - ARM64_SYSREG_ID_AA64ZFR0_EL1 = 0xC024, - ARM64_SYSREG_LORID_EL1 = 0xC527, - ARM64_SYSREG_ERRIDR_EL1 = 0xC298, - ARM64_SYSREG_ERXFR_EL1 = 0xC2A0, - ARM64_SYSREG_DBGDTRTX_EL0 = 0x9828, - ARM64_SYSREG_OSLAR_EL1 = 0x8084, - ARM64_SYSREG_PMSWINC_EL0 = 0xDCE4, - ARM64_SYSREG_TRCOSLAR = 0x8884, - ARM64_SYSREG_TRCLAR = 0x8BE6, - ARM64_SYSREG_ICC_EOIR1_EL1 = 0xC661, - ARM64_SYSREG_ICC_EOIR0_EL1 = 0xC641, - ARM64_SYSREG_ICC_DIR_EL1 = 0xC659, - ARM64_SYSREG_ICC_SGI1R_EL1 = 0xC65D, - ARM64_SYSREG_ICC_ASGI1R_EL1 = 0xC65E, - ARM64_SYSREG_ICC_SGI0R_EL1 = 0xC65F, - ARM64_SYSREG_OSDTRRX_EL1 = 0x8002, - ARM64_SYSREG_OSDTRTX_EL1 = 0x801A, - ARM64_SYSREG_TEECR32_EL1 = 0x9000, - ARM64_SYSREG_MDCCINT_EL1 = 0x8010, - ARM64_SYSREG_MDSCR_EL1 = 0x8012, - ARM64_SYSREG_DBGDTR_EL0 = 0x9820, - ARM64_SYSREG_OSECCR_EL1 = 0x8032, - ARM64_SYSREG_DBGVCR32_EL2 = 0xA038, - ARM64_SYSREG_DBGBVR0_EL1 = 0x8004, - ARM64_SYSREG_DBGBVR1_EL1 = 0x800C, - ARM64_SYSREG_DBGBVR2_EL1 = 0x8014, - ARM64_SYSREG_DBGBVR3_EL1 = 0x801C, - ARM64_SYSREG_DBGBVR4_EL1 = 0x8024, - ARM64_SYSREG_DBGBVR5_EL1 = 0x802C, - ARM64_SYSREG_DBGBVR6_EL1 = 0x8034, - ARM64_SYSREG_DBGBVR7_EL1 = 0x803C, - ARM64_SYSREG_DBGBVR8_EL1 = 0x8044, - ARM64_SYSREG_DBGBVR9_EL1 = 0x804C, - ARM64_SYSREG_DBGBVR10_EL1 = 0x8054, - ARM64_SYSREG_DBGBVR11_EL1 = 0x805C, - ARM64_SYSREG_DBGBVR12_EL1 = 0x8064, - ARM64_SYSREG_DBGBVR13_EL1 = 0x806C, - ARM64_SYSREG_DBGBVR14_EL1 = 0x8074, - ARM64_SYSREG_DBGBVR15_EL1 = 0x807C, - ARM64_SYSREG_DBGBCR0_EL1 = 0x8005, - ARM64_SYSREG_DBGBCR1_EL1 = 0x800D, - ARM64_SYSREG_DBGBCR2_EL1 = 0x8015, - ARM64_SYSREG_DBGBCR3_EL1 = 0x801D, - ARM64_SYSREG_DBGBCR4_EL1 = 0x8025, - ARM64_SYSREG_DBGBCR5_EL1 = 0x802D, - ARM64_SYSREG_DBGBCR6_EL1 = 0x8035, - ARM64_SYSREG_DBGBCR7_EL1 = 0x803D, - ARM64_SYSREG_DBGBCR8_EL1 = 0x8045, - ARM64_SYSREG_DBGBCR9_EL1 = 0x804D, - ARM64_SYSREG_DBGBCR10_EL1 = 0x8055, - ARM64_SYSREG_DBGBCR11_EL1 = 0x805D, - ARM64_SYSREG_DBGBCR12_EL1 = 0x8065, - ARM64_SYSREG_DBGBCR13_EL1 = 0x806D, - ARM64_SYSREG_DBGBCR14_EL1 = 0x8075, - ARM64_SYSREG_DBGBCR15_EL1 = 0x807D, - ARM64_SYSREG_DBGWVR0_EL1 = 0x8006, - ARM64_SYSREG_DBGWVR1_EL1 = 0x800E, - ARM64_SYSREG_DBGWVR2_EL1 = 0x8016, - ARM64_SYSREG_DBGWVR3_EL1 = 0x801E, - ARM64_SYSREG_DBGWVR4_EL1 = 0x8026, - ARM64_SYSREG_DBGWVR5_EL1 = 0x802E, - ARM64_SYSREG_DBGWVR6_EL1 = 0x8036, - ARM64_SYSREG_DBGWVR7_EL1 = 0x803E, - ARM64_SYSREG_DBGWVR8_EL1 = 0x8046, - ARM64_SYSREG_DBGWVR9_EL1 = 0x804E, - ARM64_SYSREG_DBGWVR10_EL1 = 0x8056, - ARM64_SYSREG_DBGWVR11_EL1 = 0x805E, - ARM64_SYSREG_DBGWVR12_EL1 = 0x8066, - ARM64_SYSREG_DBGWVR13_EL1 = 0x806E, - ARM64_SYSREG_DBGWVR14_EL1 = 0x8076, - ARM64_SYSREG_DBGWVR15_EL1 = 0x807E, - ARM64_SYSREG_DBGWCR0_EL1 = 0x8007, - ARM64_SYSREG_DBGWCR1_EL1 = 0x800F, - ARM64_SYSREG_DBGWCR2_EL1 = 0x8017, - ARM64_SYSREG_DBGWCR3_EL1 = 0x801F, - ARM64_SYSREG_DBGWCR4_EL1 = 0x8027, - ARM64_SYSREG_DBGWCR5_EL1 = 0x802F, - ARM64_SYSREG_DBGWCR6_EL1 = 0x8037, - ARM64_SYSREG_DBGWCR7_EL1 = 0x803F, - ARM64_SYSREG_DBGWCR8_EL1 = 0x8047, - ARM64_SYSREG_DBGWCR9_EL1 = 0x804F, - ARM64_SYSREG_DBGWCR10_EL1 = 0x8057, - ARM64_SYSREG_DBGWCR11_EL1 = 0x805F, - ARM64_SYSREG_DBGWCR12_EL1 = 0x8067, - ARM64_SYSREG_DBGWCR13_EL1 = 0x806F, - ARM64_SYSREG_DBGWCR14_EL1 = 0x8077, - ARM64_SYSREG_DBGWCR15_EL1 = 0x807F, - ARM64_SYSREG_TEEHBR32_EL1 = 0x9080, - ARM64_SYSREG_OSDLR_EL1 = 0x809C, - ARM64_SYSREG_DBGPRCR_EL1 = 0x80A4, - ARM64_SYSREG_DBGCLAIMSET_EL1 = 0x83C6, - ARM64_SYSREG_DBGCLAIMCLR_EL1 = 0x83CE, - ARM64_SYSREG_CSSELR_EL1 = 0xD000, - ARM64_SYSREG_VPIDR_EL2 = 0xE000, - ARM64_SYSREG_VMPIDR_EL2 = 0xE005, - ARM64_SYSREG_CPACR_EL1 = 0xC082, - ARM64_SYSREG_SCTLR_EL1 = 0xC080, - ARM64_SYSREG_SCTLR_EL2 = 0xE080, - ARM64_SYSREG_SCTLR_EL3 = 0xF080, - ARM64_SYSREG_ACTLR_EL1 = 0xC081, - ARM64_SYSREG_ACTLR_EL2 = 0xE081, - ARM64_SYSREG_ACTLR_EL3 = 0xF081, - ARM64_SYSREG_HCR_EL2 = 0xE088, - ARM64_SYSREG_SCR_EL3 = 0xF088, - ARM64_SYSREG_MDCR_EL2 = 0xE089, - ARM64_SYSREG_SDER32_EL3 = 0xF089, - ARM64_SYSREG_CPTR_EL2 = 0xE08A, - ARM64_SYSREG_CPTR_EL3 = 0xF08A, - ARM64_SYSREG_HSTR_EL2 = 0xE08B, - ARM64_SYSREG_HACR_EL2 = 0xE08F, - ARM64_SYSREG_MDCR_EL3 = 0xF099, - ARM64_SYSREG_TTBR0_EL1 = 0xC100, - ARM64_SYSREG_TTBR0_EL2 = 0xE100, - ARM64_SYSREG_TTBR0_EL3 = 0xF100, - ARM64_SYSREG_TTBR1_EL1 = 0xC101, - ARM64_SYSREG_TCR_EL1 = 0xC102, - ARM64_SYSREG_TCR_EL2 = 0xE102, - ARM64_SYSREG_TCR_EL3 = 0xF102, - ARM64_SYSREG_VTTBR_EL2 = 0xE108, - ARM64_SYSREG_VTCR_EL2 = 0xE10A, - ARM64_SYSREG_DACR32_EL2 = 0xE180, - ARM64_SYSREG_SPSR_EL1 = 0xC200, - ARM64_SYSREG_SPSR_EL2 = 0xE200, - ARM64_SYSREG_SPSR_EL3 = 0xF200, - ARM64_SYSREG_ELR_EL1 = 0xC201, - ARM64_SYSREG_ELR_EL2 = 0xE201, - ARM64_SYSREG_ELR_EL3 = 0xF201, - ARM64_SYSREG_SP_EL0 = 0xC208, - ARM64_SYSREG_SP_EL1 = 0xE208, - ARM64_SYSREG_SP_EL2 = 0xF208, - ARM64_SYSREG_SPSEL = 0xC210, - ARM64_SYSREG_NZCV = 0xDA10, - ARM64_SYSREG_DAIF = 0xDA11, - ARM64_SYSREG_CURRENTEL = 0xC212, - ARM64_SYSREG_SPSR_IRQ = 0xE218, - ARM64_SYSREG_SPSR_ABT = 0xE219, - ARM64_SYSREG_SPSR_UND = 0xE21A, - ARM64_SYSREG_SPSR_FIQ = 0xE21B, - ARM64_SYSREG_FPCR = 0xDA20, - ARM64_SYSREG_FPSR = 0xDA21, - ARM64_SYSREG_DSPSR_EL0 = 0xDA28, - ARM64_SYSREG_DLR_EL0 = 0xDA29, - ARM64_SYSREG_IFSR32_EL2 = 0xE281, - ARM64_SYSREG_AFSR0_EL1 = 0xC288, - ARM64_SYSREG_AFSR0_EL2 = 0xE288, - ARM64_SYSREG_AFSR0_EL3 = 0xF288, - ARM64_SYSREG_AFSR1_EL1 = 0xC289, - ARM64_SYSREG_AFSR1_EL2 = 0xE289, - ARM64_SYSREG_AFSR1_EL3 = 0xF289, - ARM64_SYSREG_ESR_EL1 = 0xC290, - ARM64_SYSREG_ESR_EL2 = 0xE290, - ARM64_SYSREG_ESR_EL3 = 0xF290, - ARM64_SYSREG_FPEXC32_EL2 = 0xE298, - ARM64_SYSREG_FAR_EL1 = 0xC300, - ARM64_SYSREG_FAR_EL2 = 0xE300, - ARM64_SYSREG_FAR_EL3 = 0xF300, - ARM64_SYSREG_HPFAR_EL2 = 0xE304, - ARM64_SYSREG_PAR_EL1 = 0xC3A0, - ARM64_SYSREG_PMCR_EL0 = 0xDCE0, - ARM64_SYSREG_PMCNTENSET_EL0 = 0xDCE1, - ARM64_SYSREG_PMCNTENCLR_EL0 = 0xDCE2, - ARM64_SYSREG_PMOVSCLR_EL0 = 0xDCE3, - ARM64_SYSREG_PMSELR_EL0 = 0xDCE5, - ARM64_SYSREG_PMCCNTR_EL0 = 0xDCE8, - ARM64_SYSREG_PMXEVTYPER_EL0 = 0xDCE9, - ARM64_SYSREG_PMXEVCNTR_EL0 = 0xDCEA, - ARM64_SYSREG_PMUSERENR_EL0 = 0xDCF0, - ARM64_SYSREG_PMINTENSET_EL1 = 0xC4F1, - ARM64_SYSREG_PMINTENCLR_EL1 = 0xC4F2, - ARM64_SYSREG_PMOVSSET_EL0 = 0xDCF3, - ARM64_SYSREG_MAIR_EL1 = 0xC510, - ARM64_SYSREG_MAIR_EL2 = 0xE510, - ARM64_SYSREG_MAIR_EL3 = 0xF510, - ARM64_SYSREG_AMAIR_EL1 = 0xC518, - ARM64_SYSREG_AMAIR_EL2 = 0xE518, - ARM64_SYSREG_AMAIR_EL3 = 0xF518, - ARM64_SYSREG_VBAR_EL1 = 0xC600, - ARM64_SYSREG_VBAR_EL2 = 0xE600, - ARM64_SYSREG_VBAR_EL3 = 0xF600, - ARM64_SYSREG_RMR_EL1 = 0xC602, - ARM64_SYSREG_RMR_EL2 = 0xE602, - ARM64_SYSREG_RMR_EL3 = 0xF602, - ARM64_SYSREG_CONTEXTIDR_EL1 = 0xC681, - ARM64_SYSREG_TPIDR_EL0 = 0xDE82, - ARM64_SYSREG_TPIDR_EL2 = 0xE682, - ARM64_SYSREG_TPIDR_EL3 = 0xF682, - ARM64_SYSREG_TPIDRRO_EL0 = 0xDE83, - ARM64_SYSREG_TPIDR_EL1 = 0xC684, - ARM64_SYSREG_CNTFRQ_EL0 = 0xDF00, - ARM64_SYSREG_CNTVOFF_EL2 = 0xE703, - ARM64_SYSREG_CNTKCTL_EL1 = 0xC708, - ARM64_SYSREG_CNTHCTL_EL2 = 0xE708, - ARM64_SYSREG_CNTP_TVAL_EL0 = 0xDF10, - ARM64_SYSREG_CNTHP_TVAL_EL2 = 0xE710, - ARM64_SYSREG_CNTPS_TVAL_EL1 = 0xFF10, - ARM64_SYSREG_CNTP_CTL_EL0 = 0xDF11, - ARM64_SYSREG_CNTHP_CTL_EL2 = 0xE711, - ARM64_SYSREG_CNTPS_CTL_EL1 = 0xFF11, - ARM64_SYSREG_CNTP_CVAL_EL0 = 0xDF12, - ARM64_SYSREG_CNTHP_CVAL_EL2 = 0xE712, - ARM64_SYSREG_CNTPS_CVAL_EL1 = 0xFF12, - ARM64_SYSREG_CNTV_TVAL_EL0 = 0xDF18, - ARM64_SYSREG_CNTV_CTL_EL0 = 0xDF19, - ARM64_SYSREG_CNTV_CVAL_EL0 = 0xDF1A, - ARM64_SYSREG_PMEVCNTR0_EL0 = 0xDF40, - ARM64_SYSREG_PMEVCNTR1_EL0 = 0xDF41, - ARM64_SYSREG_PMEVCNTR2_EL0 = 0xDF42, - ARM64_SYSREG_PMEVCNTR3_EL0 = 0xDF43, - ARM64_SYSREG_PMEVCNTR4_EL0 = 0xDF44, - ARM64_SYSREG_PMEVCNTR5_EL0 = 0xDF45, - ARM64_SYSREG_PMEVCNTR6_EL0 = 0xDF46, - ARM64_SYSREG_PMEVCNTR7_EL0 = 0xDF47, - ARM64_SYSREG_PMEVCNTR8_EL0 = 0xDF48, - ARM64_SYSREG_PMEVCNTR9_EL0 = 0xDF49, - ARM64_SYSREG_PMEVCNTR10_EL0 = 0xDF4A, - ARM64_SYSREG_PMEVCNTR11_EL0 = 0xDF4B, - ARM64_SYSREG_PMEVCNTR12_EL0 = 0xDF4C, - ARM64_SYSREG_PMEVCNTR13_EL0 = 0xDF4D, - ARM64_SYSREG_PMEVCNTR14_EL0 = 0xDF4E, - ARM64_SYSREG_PMEVCNTR15_EL0 = 0xDF4F, - ARM64_SYSREG_PMEVCNTR16_EL0 = 0xDF50, - ARM64_SYSREG_PMEVCNTR17_EL0 = 0xDF51, - ARM64_SYSREG_PMEVCNTR18_EL0 = 0xDF52, - ARM64_SYSREG_PMEVCNTR19_EL0 = 0xDF53, - ARM64_SYSREG_PMEVCNTR20_EL0 = 0xDF54, - ARM64_SYSREG_PMEVCNTR21_EL0 = 0xDF55, - ARM64_SYSREG_PMEVCNTR22_EL0 = 0xDF56, - ARM64_SYSREG_PMEVCNTR23_EL0 = 0xDF57, - ARM64_SYSREG_PMEVCNTR24_EL0 = 0xDF58, - ARM64_SYSREG_PMEVCNTR25_EL0 = 0xDF59, - ARM64_SYSREG_PMEVCNTR26_EL0 = 0xDF5A, - ARM64_SYSREG_PMEVCNTR27_EL0 = 0xDF5B, - ARM64_SYSREG_PMEVCNTR28_EL0 = 0xDF5C, - ARM64_SYSREG_PMEVCNTR29_EL0 = 0xDF5D, - ARM64_SYSREG_PMEVCNTR30_EL0 = 0xDF5E, - ARM64_SYSREG_PMCCFILTR_EL0 = 0xDF7F, - ARM64_SYSREG_PMEVTYPER0_EL0 = 0xDF60, - ARM64_SYSREG_PMEVTYPER1_EL0 = 0xDF61, - ARM64_SYSREG_PMEVTYPER2_EL0 = 0xDF62, - ARM64_SYSREG_PMEVTYPER3_EL0 = 0xDF63, - ARM64_SYSREG_PMEVTYPER4_EL0 = 0xDF64, - ARM64_SYSREG_PMEVTYPER5_EL0 = 0xDF65, - ARM64_SYSREG_PMEVTYPER6_EL0 = 0xDF66, - ARM64_SYSREG_PMEVTYPER7_EL0 = 0xDF67, - ARM64_SYSREG_PMEVTYPER8_EL0 = 0xDF68, - ARM64_SYSREG_PMEVTYPER9_EL0 = 0xDF69, - ARM64_SYSREG_PMEVTYPER10_EL0 = 0xDF6A, - ARM64_SYSREG_PMEVTYPER11_EL0 = 0xDF6B, - ARM64_SYSREG_PMEVTYPER12_EL0 = 0xDF6C, - ARM64_SYSREG_PMEVTYPER13_EL0 = 0xDF6D, - ARM64_SYSREG_PMEVTYPER14_EL0 = 0xDF6E, - ARM64_SYSREG_PMEVTYPER15_EL0 = 0xDF6F, - ARM64_SYSREG_PMEVTYPER16_EL0 = 0xDF70, - ARM64_SYSREG_PMEVTYPER17_EL0 = 0xDF71, - ARM64_SYSREG_PMEVTYPER18_EL0 = 0xDF72, - ARM64_SYSREG_PMEVTYPER19_EL0 = 0xDF73, - ARM64_SYSREG_PMEVTYPER20_EL0 = 0xDF74, - ARM64_SYSREG_PMEVTYPER21_EL0 = 0xDF75, - ARM64_SYSREG_PMEVTYPER22_EL0 = 0xDF76, - ARM64_SYSREG_PMEVTYPER23_EL0 = 0xDF77, - ARM64_SYSREG_PMEVTYPER24_EL0 = 0xDF78, - ARM64_SYSREG_PMEVTYPER25_EL0 = 0xDF79, - ARM64_SYSREG_PMEVTYPER26_EL0 = 0xDF7A, - ARM64_SYSREG_PMEVTYPER27_EL0 = 0xDF7B, - ARM64_SYSREG_PMEVTYPER28_EL0 = 0xDF7C, - ARM64_SYSREG_PMEVTYPER29_EL0 = 0xDF7D, - ARM64_SYSREG_PMEVTYPER30_EL0 = 0xDF7E, - ARM64_SYSREG_TRCPRGCTLR = 0x8808, - ARM64_SYSREG_TRCPROCSELR = 0x8810, - ARM64_SYSREG_TRCCONFIGR = 0x8820, - ARM64_SYSREG_TRCAUXCTLR = 0x8830, - ARM64_SYSREG_TRCEVENTCTL0R = 0x8840, - ARM64_SYSREG_TRCEVENTCTL1R = 0x8848, - ARM64_SYSREG_TRCSTALLCTLR = 0x8858, - ARM64_SYSREG_TRCTSCTLR = 0x8860, - ARM64_SYSREG_TRCSYNCPR = 0x8868, - ARM64_SYSREG_TRCCCCTLR = 0x8870, - ARM64_SYSREG_TRCBBCTLR = 0x8878, - ARM64_SYSREG_TRCTRACEIDR = 0x8801, - ARM64_SYSREG_TRCQCTLR = 0x8809, - ARM64_SYSREG_TRCVICTLR = 0x8802, - ARM64_SYSREG_TRCVIIECTLR = 0x880A, - ARM64_SYSREG_TRCVISSCTLR = 0x8812, - ARM64_SYSREG_TRCVIPCSSCTLR = 0x881A, - ARM64_SYSREG_TRCVDCTLR = 0x8842, - ARM64_SYSREG_TRCVDSACCTLR = 0x884A, - ARM64_SYSREG_TRCVDARCCTLR = 0x8852, - ARM64_SYSREG_TRCSEQEVR0 = 0x8804, - ARM64_SYSREG_TRCSEQEVR1 = 0x880C, - ARM64_SYSREG_TRCSEQEVR2 = 0x8814, - ARM64_SYSREG_TRCSEQRSTEVR = 0x8834, - ARM64_SYSREG_TRCSEQSTR = 0x883C, - ARM64_SYSREG_TRCEXTINSELR = 0x8844, - ARM64_SYSREG_TRCCNTRLDVR0 = 0x8805, - ARM64_SYSREG_TRCCNTRLDVR1 = 0x880D, - ARM64_SYSREG_TRCCNTRLDVR2 = 0x8815, - ARM64_SYSREG_TRCCNTRLDVR3 = 0x881D, - ARM64_SYSREG_TRCCNTCTLR0 = 0x8825, - ARM64_SYSREG_TRCCNTCTLR1 = 0x882D, - ARM64_SYSREG_TRCCNTCTLR2 = 0x8835, - ARM64_SYSREG_TRCCNTCTLR3 = 0x883D, - ARM64_SYSREG_TRCCNTVR0 = 0x8845, - ARM64_SYSREG_TRCCNTVR1 = 0x884D, - ARM64_SYSREG_TRCCNTVR2 = 0x8855, - ARM64_SYSREG_TRCCNTVR3 = 0x885D, - ARM64_SYSREG_TRCIMSPEC0 = 0x8807, - ARM64_SYSREG_TRCIMSPEC1 = 0x880F, - ARM64_SYSREG_TRCIMSPEC2 = 0x8817, - ARM64_SYSREG_TRCIMSPEC3 = 0x881F, - ARM64_SYSREG_TRCIMSPEC4 = 0x8827, - ARM64_SYSREG_TRCIMSPEC5 = 0x882F, - ARM64_SYSREG_TRCIMSPEC6 = 0x8837, - ARM64_SYSREG_TRCIMSPEC7 = 0x883F, - ARM64_SYSREG_TRCRSCTLR2 = 0x8890, - ARM64_SYSREG_TRCRSCTLR3 = 0x8898, - ARM64_SYSREG_TRCRSCTLR4 = 0x88A0, - ARM64_SYSREG_TRCRSCTLR5 = 0x88A8, - ARM64_SYSREG_TRCRSCTLR6 = 0x88B0, - ARM64_SYSREG_TRCRSCTLR7 = 0x88B8, - ARM64_SYSREG_TRCRSCTLR8 = 0x88C0, - ARM64_SYSREG_TRCRSCTLR9 = 0x88C8, - ARM64_SYSREG_TRCRSCTLR10 = 0x88D0, - ARM64_SYSREG_TRCRSCTLR11 = 0x88D8, - ARM64_SYSREG_TRCRSCTLR12 = 0x88E0, - ARM64_SYSREG_TRCRSCTLR13 = 0x88E8, - ARM64_SYSREG_TRCRSCTLR14 = 0x88F0, - ARM64_SYSREG_TRCRSCTLR15 = 0x88F8, - ARM64_SYSREG_TRCRSCTLR16 = 0x8881, - ARM64_SYSREG_TRCRSCTLR17 = 0x8889, - ARM64_SYSREG_TRCRSCTLR18 = 0x8891, - ARM64_SYSREG_TRCRSCTLR19 = 0x8899, - ARM64_SYSREG_TRCRSCTLR20 = 0x88A1, - ARM64_SYSREG_TRCRSCTLR21 = 0x88A9, - ARM64_SYSREG_TRCRSCTLR22 = 0x88B1, - ARM64_SYSREG_TRCRSCTLR23 = 0x88B9, - ARM64_SYSREG_TRCRSCTLR24 = 0x88C1, - ARM64_SYSREG_TRCRSCTLR25 = 0x88C9, - ARM64_SYSREG_TRCRSCTLR26 = 0x88D1, - ARM64_SYSREG_TRCRSCTLR27 = 0x88D9, - ARM64_SYSREG_TRCRSCTLR28 = 0x88E1, - ARM64_SYSREG_TRCRSCTLR29 = 0x88E9, - ARM64_SYSREG_TRCRSCTLR30 = 0x88F1, - ARM64_SYSREG_TRCRSCTLR31 = 0x88F9, - ARM64_SYSREG_TRCSSCCR0 = 0x8882, - ARM64_SYSREG_TRCSSCCR1 = 0x888A, - ARM64_SYSREG_TRCSSCCR2 = 0x8892, - ARM64_SYSREG_TRCSSCCR3 = 0x889A, - ARM64_SYSREG_TRCSSCCR4 = 0x88A2, - ARM64_SYSREG_TRCSSCCR5 = 0x88AA, - ARM64_SYSREG_TRCSSCCR6 = 0x88B2, - ARM64_SYSREG_TRCSSCCR7 = 0x88BA, - ARM64_SYSREG_TRCSSCSR0 = 0x88C2, - ARM64_SYSREG_TRCSSCSR1 = 0x88CA, - ARM64_SYSREG_TRCSSCSR2 = 0x88D2, - ARM64_SYSREG_TRCSSCSR3 = 0x88DA, - ARM64_SYSREG_TRCSSCSR4 = 0x88E2, - ARM64_SYSREG_TRCSSCSR5 = 0x88EA, - ARM64_SYSREG_TRCSSCSR6 = 0x88F2, - ARM64_SYSREG_TRCSSCSR7 = 0x88FA, - ARM64_SYSREG_TRCSSPCICR0 = 0x8883, - ARM64_SYSREG_TRCSSPCICR1 = 0x888B, - ARM64_SYSREG_TRCSSPCICR2 = 0x8893, - ARM64_SYSREG_TRCSSPCICR3 = 0x889B, - ARM64_SYSREG_TRCSSPCICR4 = 0x88A3, - ARM64_SYSREG_TRCSSPCICR5 = 0x88AB, - ARM64_SYSREG_TRCSSPCICR6 = 0x88B3, - ARM64_SYSREG_TRCSSPCICR7 = 0x88BB, - ARM64_SYSREG_TRCPDCR = 0x88A4, - ARM64_SYSREG_TRCACVR0 = 0x8900, - ARM64_SYSREG_TRCACVR1 = 0x8910, - ARM64_SYSREG_TRCACVR2 = 0x8920, - ARM64_SYSREG_TRCACVR3 = 0x8930, - ARM64_SYSREG_TRCACVR4 = 0x8940, - ARM64_SYSREG_TRCACVR5 = 0x8950, - ARM64_SYSREG_TRCACVR6 = 0x8960, - ARM64_SYSREG_TRCACVR7 = 0x8970, - ARM64_SYSREG_TRCACVR8 = 0x8901, - ARM64_SYSREG_TRCACVR9 = 0x8911, - ARM64_SYSREG_TRCACVR10 = 0x8921, - ARM64_SYSREG_TRCACVR11 = 0x8931, - ARM64_SYSREG_TRCACVR12 = 0x8941, - ARM64_SYSREG_TRCACVR13 = 0x8951, - ARM64_SYSREG_TRCACVR14 = 0x8961, - ARM64_SYSREG_TRCACVR15 = 0x8971, - ARM64_SYSREG_TRCACATR0 = 0x8902, - ARM64_SYSREG_TRCACATR1 = 0x8912, - ARM64_SYSREG_TRCACATR2 = 0x8922, - ARM64_SYSREG_TRCACATR3 = 0x8932, - ARM64_SYSREG_TRCACATR4 = 0x8942, - ARM64_SYSREG_TRCACATR5 = 0x8952, - ARM64_SYSREG_TRCACATR6 = 0x8962, - ARM64_SYSREG_TRCACATR7 = 0x8972, - ARM64_SYSREG_TRCACATR8 = 0x8903, - ARM64_SYSREG_TRCACATR9 = 0x8913, - ARM64_SYSREG_TRCACATR10 = 0x8923, - ARM64_SYSREG_TRCACATR11 = 0x8933, - ARM64_SYSREG_TRCACATR12 = 0x8943, - ARM64_SYSREG_TRCACATR13 = 0x8953, - ARM64_SYSREG_TRCACATR14 = 0x8963, - ARM64_SYSREG_TRCACATR15 = 0x8973, - ARM64_SYSREG_TRCDVCVR0 = 0x8904, - ARM64_SYSREG_TRCDVCVR1 = 0x8924, - ARM64_SYSREG_TRCDVCVR2 = 0x8944, - ARM64_SYSREG_TRCDVCVR3 = 0x8964, - ARM64_SYSREG_TRCDVCVR4 = 0x8905, - ARM64_SYSREG_TRCDVCVR5 = 0x8925, - ARM64_SYSREG_TRCDVCVR6 = 0x8945, - ARM64_SYSREG_TRCDVCVR7 = 0x8965, - ARM64_SYSREG_TRCDVCMR0 = 0x8906, - ARM64_SYSREG_TRCDVCMR1 = 0x8926, - ARM64_SYSREG_TRCDVCMR2 = 0x8946, - ARM64_SYSREG_TRCDVCMR3 = 0x8966, - ARM64_SYSREG_TRCDVCMR4 = 0x8907, - ARM64_SYSREG_TRCDVCMR5 = 0x8927, - ARM64_SYSREG_TRCDVCMR6 = 0x8947, - ARM64_SYSREG_TRCDVCMR7 = 0x8967, - ARM64_SYSREG_TRCCIDCVR0 = 0x8980, - ARM64_SYSREG_TRCCIDCVR1 = 0x8990, - ARM64_SYSREG_TRCCIDCVR2 = 0x89A0, - ARM64_SYSREG_TRCCIDCVR3 = 0x89B0, - ARM64_SYSREG_TRCCIDCVR4 = 0x89C0, - ARM64_SYSREG_TRCCIDCVR5 = 0x89D0, - ARM64_SYSREG_TRCCIDCVR6 = 0x89E0, - ARM64_SYSREG_TRCCIDCVR7 = 0x89F0, - ARM64_SYSREG_TRCVMIDCVR0 = 0x8981, - ARM64_SYSREG_TRCVMIDCVR1 = 0x8991, - ARM64_SYSREG_TRCVMIDCVR2 = 0x89A1, - ARM64_SYSREG_TRCVMIDCVR3 = 0x89B1, - ARM64_SYSREG_TRCVMIDCVR4 = 0x89C1, - ARM64_SYSREG_TRCVMIDCVR5 = 0x89D1, - ARM64_SYSREG_TRCVMIDCVR6 = 0x89E1, - ARM64_SYSREG_TRCVMIDCVR7 = 0x89F1, - ARM64_SYSREG_TRCCIDCCTLR0 = 0x8982, - ARM64_SYSREG_TRCCIDCCTLR1 = 0x898A, - ARM64_SYSREG_TRCVMIDCCTLR0 = 0x8992, - ARM64_SYSREG_TRCVMIDCCTLR1 = 0x899A, - ARM64_SYSREG_TRCITCTRL = 0x8B84, - ARM64_SYSREG_TRCCLAIMSET = 0x8BC6, - ARM64_SYSREG_TRCCLAIMCLR = 0x8BCE, - ARM64_SYSREG_ICC_BPR1_EL1 = 0xC663, - ARM64_SYSREG_ICC_BPR0_EL1 = 0xC643, - ARM64_SYSREG_ICC_PMR_EL1 = 0xC230, - ARM64_SYSREG_ICC_CTLR_EL1 = 0xC664, - ARM64_SYSREG_ICC_CTLR_EL3 = 0xF664, - ARM64_SYSREG_ICC_SRE_EL1 = 0xC665, - ARM64_SYSREG_ICC_SRE_EL2 = 0xE64D, - ARM64_SYSREG_ICC_SRE_EL3 = 0xF665, - ARM64_SYSREG_ICC_IGRPEN0_EL1 = 0xC666, - ARM64_SYSREG_ICC_IGRPEN1_EL1 = 0xC667, - ARM64_SYSREG_ICC_IGRPEN1_EL3 = 0xF667, - ARM64_SYSREG_ICC_SEIEN_EL1 = 0xC668, - ARM64_SYSREG_ICC_AP0R0_EL1 = 0xC644, - ARM64_SYSREG_ICC_AP0R1_EL1 = 0xC645, - ARM64_SYSREG_ICC_AP0R2_EL1 = 0xC646, - ARM64_SYSREG_ICC_AP0R3_EL1 = 0xC647, - ARM64_SYSREG_ICC_AP1R0_EL1 = 0xC648, - ARM64_SYSREG_ICC_AP1R1_EL1 = 0xC649, - ARM64_SYSREG_ICC_AP1R2_EL1 = 0xC64A, - ARM64_SYSREG_ICC_AP1R3_EL1 = 0xC64B, - ARM64_SYSREG_ICH_AP0R0_EL2 = 0xE640, - ARM64_SYSREG_ICH_AP0R1_EL2 = 0xE641, - ARM64_SYSREG_ICH_AP0R2_EL2 = 0xE642, - ARM64_SYSREG_ICH_AP0R3_EL2 = 0xE643, - ARM64_SYSREG_ICH_AP1R0_EL2 = 0xE648, - ARM64_SYSREG_ICH_AP1R1_EL2 = 0xE649, - ARM64_SYSREG_ICH_AP1R2_EL2 = 0xE64A, - ARM64_SYSREG_ICH_AP1R3_EL2 = 0xE64B, - ARM64_SYSREG_ICH_HCR_EL2 = 0xE658, - ARM64_SYSREG_ICH_MISR_EL2 = 0xE65A, - ARM64_SYSREG_ICH_VMCR_EL2 = 0xE65F, - ARM64_SYSREG_ICH_VSEIR_EL2 = 0xE64C, - ARM64_SYSREG_ICH_LR0_EL2 = 0xE660, - ARM64_SYSREG_ICH_LR1_EL2 = 0xE661, - ARM64_SYSREG_ICH_LR2_EL2 = 0xE662, - ARM64_SYSREG_ICH_LR3_EL2 = 0xE663, - ARM64_SYSREG_ICH_LR4_EL2 = 0xE664, - ARM64_SYSREG_ICH_LR5_EL2 = 0xE665, - ARM64_SYSREG_ICH_LR6_EL2 = 0xE666, - ARM64_SYSREG_ICH_LR7_EL2 = 0xE667, - ARM64_SYSREG_ICH_LR8_EL2 = 0xE668, - ARM64_SYSREG_ICH_LR9_EL2 = 0xE669, - ARM64_SYSREG_ICH_LR10_EL2 = 0xE66A, - ARM64_SYSREG_ICH_LR11_EL2 = 0xE66B, - ARM64_SYSREG_ICH_LR12_EL2 = 0xE66C, - ARM64_SYSREG_ICH_LR13_EL2 = 0xE66D, - ARM64_SYSREG_ICH_LR14_EL2 = 0xE66E, - ARM64_SYSREG_ICH_LR15_EL2 = 0xE66F, - ARM64_SYSREG_PAN = 0xC213, - ARM64_SYSREG_LORSA_EL1 = 0xC520, - ARM64_SYSREG_LOREA_EL1 = 0xC521, - ARM64_SYSREG_LORN_EL1 = 0xC522, - ARM64_SYSREG_LORC_EL1 = 0xC523, - ARM64_SYSREG_TTBR1_EL2 = 0xE101, - ARM64_SYSREG_CONTEXTIDR_EL2 = 0xE681, - ARM64_SYSREG_CNTHV_TVAL_EL2 = 0xE718, - ARM64_SYSREG_CNTHV_CVAL_EL2 = 0xE71A, - ARM64_SYSREG_CNTHV_CTL_EL2 = 0xE719, - ARM64_SYSREG_SCTLR_EL12 = 0xE880, - ARM64_SYSREG_CPACR_EL12 = 0xE882, - ARM64_SYSREG_TTBR0_EL12 = 0xE900, - ARM64_SYSREG_TTBR1_EL12 = 0xE901, - ARM64_SYSREG_TCR_EL12 = 0xE902, - ARM64_SYSREG_AFSR0_EL12 = 0xEA88, - ARM64_SYSREG_AFSR1_EL12 = 0xEA89, - ARM64_SYSREG_ESR_EL12 = 0xEA90, - ARM64_SYSREG_FAR_EL12 = 0xEB00, - ARM64_SYSREG_MAIR_EL12 = 0xED10, - ARM64_SYSREG_AMAIR_EL12 = 0xED18, - ARM64_SYSREG_VBAR_EL12 = 0xEE00, - ARM64_SYSREG_CONTEXTIDR_EL12 = 0xEE81, - ARM64_SYSREG_CNTKCTL_EL12 = 0xEF08, - ARM64_SYSREG_CNTP_TVAL_EL02 = 0xEF10, - ARM64_SYSREG_CNTP_CTL_EL02 = 0xEF11, - ARM64_SYSREG_CNTP_CVAL_EL02 = 0xEF12, - ARM64_SYSREG_CNTV_TVAL_EL02 = 0xEF18, - ARM64_SYSREG_CNTV_CTL_EL02 = 0xEF19, - ARM64_SYSREG_CNTV_CVAL_EL02 = 0xEF1A, - ARM64_SYSREG_SPSR_EL12 = 0xEA00, - ARM64_SYSREG_ELR_EL12 = 0xEA01, - ARM64_SYSREG_UAO = 0xC214, - ARM64_SYSREG_PMBLIMITR_EL1 = 0xC4D0, - ARM64_SYSREG_PMBPTR_EL1 = 0xC4D1, - ARM64_SYSREG_PMBSR_EL1 = 0xC4D3, - ARM64_SYSREG_PMBIDR_EL1 = 0xC4D7, - ARM64_SYSREG_PMSCR_EL2 = 0xE4C8, - ARM64_SYSREG_PMSCR_EL12 = 0xECC8, - ARM64_SYSREG_PMSCR_EL1 = 0xC4C8, - ARM64_SYSREG_PMSICR_EL1 = 0xC4CA, - ARM64_SYSREG_PMSIRR_EL1 = 0xC4CB, - ARM64_SYSREG_PMSFCR_EL1 = 0xC4CC, - ARM64_SYSREG_PMSEVFR_EL1 = 0xC4CD, - ARM64_SYSREG_PMSLATFR_EL1 = 0xC4CE, - ARM64_SYSREG_PMSIDR_EL1 = 0xC4CF, - ARM64_SYSREG_ERRSELR_EL1 = 0xC299, - ARM64_SYSREG_ERXCTLR_EL1 = 0xC2A1, - ARM64_SYSREG_ERXSTATUS_EL1 = 0xC2A2, - ARM64_SYSREG_ERXADDR_EL1 = 0xC2A3, - ARM64_SYSREG_ERXMISC0_EL1 = 0xC2A8, - ARM64_SYSREG_ERXMISC1_EL1 = 0xC2A9, - ARM64_SYSREG_DISR_EL1 = 0xC609, - ARM64_SYSREG_VDISR_EL2 = 0xE609, - ARM64_SYSREG_VSESR_EL2 = 0xE293, - ARM64_SYSREG_APIAKEYLO_EL1 = 0xC108, - ARM64_SYSREG_APIAKEYHI_EL1 = 0xC109, - ARM64_SYSREG_APIBKEYLO_EL1 = 0xC10A, - ARM64_SYSREG_APIBKEYHI_EL1 = 0xC10B, - ARM64_SYSREG_APDAKEYLO_EL1 = 0xC110, - ARM64_SYSREG_APDAKEYHI_EL1 = 0xC111, - ARM64_SYSREG_APDBKEYLO_EL1 = 0xC112, - ARM64_SYSREG_APDBKEYHI_EL1 = 0xC113, - ARM64_SYSREG_APGAKEYLO_EL1 = 0xC118, - ARM64_SYSREG_APGAKEYHI_EL1 = 0xC119, - ARM64_SYSREG_VSTCR_EL2 = 0xE132, - ARM64_SYSREG_VSTTBR_EL2 = 0xE130, - ARM64_SYSREG_CNTHVS_TVAL_EL2 = 0xE720, - ARM64_SYSREG_CNTHVS_CVAL_EL2 = 0xE722, - ARM64_SYSREG_CNTHVS_CTL_EL2 = 0xE721, - ARM64_SYSREG_CNTHPS_TVAL_EL2 = 0xE728, - ARM64_SYSREG_CNTHPS_CVAL_EL2 = 0xE72A, - ARM64_SYSREG_CNTHPS_CTL_EL2 = 0xE729, - ARM64_SYSREG_SDER32_EL2 = 0xE099, - ARM64_SYSREG_ERXPFGCTL_EL1 = 0xC2A5, - ARM64_SYSREG_ERXPFGCDN_EL1 = 0xC2A6, - ARM64_SYSREG_ERXTS_EL1 = 0xC2AF, - ARM64_SYSREG_ERXMISC2_EL1 = 0xC2AA, - ARM64_SYSREG_ERXMISC3_EL1 = 0xC2AB, - ARM64_SYSREG_ERXPFGF_EL1 = 0xC2A4, - ARM64_SYSREG_MPAM0_EL1 = 0xC529, - ARM64_SYSREG_MPAM1_EL1 = 0xC528, - ARM64_SYSREG_MPAM2_EL2 = 0xE528, - ARM64_SYSREG_MPAM3_EL3 = 0xF528, - ARM64_SYSREG_MPAM1_EL12 = 0xED28, - ARM64_SYSREG_MPAMHCR_EL2 = 0xE520, - ARM64_SYSREG_MPAMVPMV_EL2 = 0xE521, - ARM64_SYSREG_MPAMVPM0_EL2 = 0xE530, - ARM64_SYSREG_MPAMVPM1_EL2 = 0xE531, - ARM64_SYSREG_MPAMVPM2_EL2 = 0xE532, - ARM64_SYSREG_MPAMVPM3_EL2 = 0xE533, - ARM64_SYSREG_MPAMVPM4_EL2 = 0xE534, - ARM64_SYSREG_MPAMVPM5_EL2 = 0xE535, - ARM64_SYSREG_MPAMVPM6_EL2 = 0xE536, - ARM64_SYSREG_MPAMVPM7_EL2 = 0xE537, - ARM64_SYSREG_MPAMIDR_EL1 = 0xC524, - ARM64_SYSREG_AMCR_EL0 = 0xDE90, - ARM64_SYSREG_AMCFGR_EL0 = 0xDE91, - ARM64_SYSREG_AMCGCR_EL0 = 0xDE92, - ARM64_SYSREG_AMUSERENR_EL0 = 0xDE93, - ARM64_SYSREG_AMCNTENCLR0_EL0 = 0xDE94, - ARM64_SYSREG_AMCNTENSET0_EL0 = 0xDE95, - ARM64_SYSREG_AMEVCNTR00_EL0 = 0xDEA0, - ARM64_SYSREG_AMEVCNTR01_EL0 = 0xDEA1, - ARM64_SYSREG_AMEVCNTR02_EL0 = 0xDEA2, - ARM64_SYSREG_AMEVCNTR03_EL0 = 0xDEA3, - ARM64_SYSREG_AMEVTYPER00_EL0 = 0xDEB0, - ARM64_SYSREG_AMEVTYPER01_EL0 = 0xDEB1, - ARM64_SYSREG_AMEVTYPER02_EL0 = 0xDEB2, - ARM64_SYSREG_AMEVTYPER03_EL0 = 0xDEB3, - ARM64_SYSREG_AMCNTENCLR1_EL0 = 0xDE98, - ARM64_SYSREG_AMCNTENSET1_EL0 = 0xDE99, - ARM64_SYSREG_AMEVCNTR10_EL0 = 0xDEE0, - ARM64_SYSREG_AMEVCNTR11_EL0 = 0xDEE1, - ARM64_SYSREG_AMEVCNTR12_EL0 = 0xDEE2, - ARM64_SYSREG_AMEVCNTR13_EL0 = 0xDEE3, - ARM64_SYSREG_AMEVCNTR14_EL0 = 0xDEE4, - ARM64_SYSREG_AMEVCNTR15_EL0 = 0xDEE5, - ARM64_SYSREG_AMEVCNTR16_EL0 = 0xDEE6, - ARM64_SYSREG_AMEVCNTR17_EL0 = 0xDEE7, - ARM64_SYSREG_AMEVCNTR18_EL0 = 0xDEE8, - ARM64_SYSREG_AMEVCNTR19_EL0 = 0xDEE9, - ARM64_SYSREG_AMEVCNTR110_EL0 = 0xDEEA, - ARM64_SYSREG_AMEVCNTR111_EL0 = 0xDEEB, - ARM64_SYSREG_AMEVCNTR112_EL0 = 0xDEEC, - ARM64_SYSREG_AMEVCNTR113_EL0 = 0xDEED, - ARM64_SYSREG_AMEVCNTR114_EL0 = 0xDEEE, - ARM64_SYSREG_AMEVCNTR115_EL0 = 0xDEEF, - ARM64_SYSREG_AMEVTYPER10_EL0 = 0xDEF0, - ARM64_SYSREG_AMEVTYPER11_EL0 = 0xDEF1, - ARM64_SYSREG_AMEVTYPER12_EL0 = 0xDEF2, - ARM64_SYSREG_AMEVTYPER13_EL0 = 0xDEF3, - ARM64_SYSREG_AMEVTYPER14_EL0 = 0xDEF4, - ARM64_SYSREG_AMEVTYPER15_EL0 = 0xDEF5, - ARM64_SYSREG_AMEVTYPER16_EL0 = 0xDEF6, - ARM64_SYSREG_AMEVTYPER17_EL0 = 0xDEF7, - ARM64_SYSREG_AMEVTYPER18_EL0 = 0xDEF8, - ARM64_SYSREG_AMEVTYPER19_EL0 = 0xDEF9, - ARM64_SYSREG_AMEVTYPER110_EL0 = 0xDEFA, - ARM64_SYSREG_AMEVTYPER111_EL0 = 0xDEFB, - ARM64_SYSREG_AMEVTYPER112_EL0 = 0xDEFC, - ARM64_SYSREG_AMEVTYPER113_EL0 = 0xDEFD, - ARM64_SYSREG_AMEVTYPER114_EL0 = 0xDEFE, - ARM64_SYSREG_AMEVTYPER115_EL0 = 0xDEFF, - ARM64_SYSREG_TRFCR_EL1 = 0xC091, - ARM64_SYSREG_TRFCR_EL2 = 0xE091, - ARM64_SYSREG_TRFCR_EL12 = 0xE891, - ARM64_SYSREG_DIT = 0xDA15, - ARM64_SYSREG_VNCR_EL2 = 0xE110, - ARM64_SYSREG_ZCR_EL1 = 0xC090, - ARM64_SYSREG_ZCR_EL2 = 0xE090, - ARM64_SYSREG_ZCR_EL3 = 0xF090, - ARM64_SYSREG_ZCR_EL12 = 0xE890, - ARM64_SYSREG_CPM_IOACC_CTL_EL3 = 0xFF90, -} arm64_sysreg; - -/// System PState Field (MSR instruction) -typedef enum arm64_pstate { - ARM64_PSTATE_INVALID = 0, - ARM64_PSTATE_SPSEL = 0x05, - ARM64_PSTATE_DAIFSET = 0x1e, - ARM64_PSTATE_DAIFCLR = 0x1f, - ARM64_PSTATE_PAN = 0x4, - ARM64_PSTATE_UAO = 0x3, - ARM64_PSTATE_DIT = 0x1a, -} arm64_pstate; - -/// Vector arrangement specifier (for FloatingPoint/Advanced SIMD insn) -typedef enum arm64_vas { - ARM64_VAS_INVALID = 0, - ARM64_VAS_16B, - ARM64_VAS_8B, - ARM64_VAS_4B, - ARM64_VAS_1B, - ARM64_VAS_8H, - ARM64_VAS_4H, - ARM64_VAS_2H, - ARM64_VAS_1H, - ARM64_VAS_4S, - ARM64_VAS_2S, - ARM64_VAS_1S, - ARM64_VAS_2D, - ARM64_VAS_1D, - ARM64_VAS_1Q, -} arm64_vas; - -/// Memory barrier operands -typedef enum arm64_barrier_op { - ARM64_BARRIER_INVALID = 0, - ARM64_BARRIER_OSHLD = 0x1, - ARM64_BARRIER_OSHST = 0x2, - ARM64_BARRIER_OSH = 0x3, - ARM64_BARRIER_NSHLD = 0x5, - ARM64_BARRIER_NSHST = 0x6, - ARM64_BARRIER_NSH = 0x7, - ARM64_BARRIER_ISHLD = 0x9, - ARM64_BARRIER_ISHST = 0xa, - ARM64_BARRIER_ISH = 0xb, - ARM64_BARRIER_LD = 0xd, - ARM64_BARRIER_ST = 0xe, - ARM64_BARRIER_SY = 0xf -} arm64_barrier_op; - -/// Operand type for instruction's operands -typedef enum arm64_op_type { - ARM64_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - ARM64_OP_REG, ///< = CS_OP_REG (Register operand). - ARM64_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - ARM64_OP_MEM, ///< = CS_OP_MEM (Memory operand). - ARM64_OP_FP, ///< = CS_OP_FP (Floating-Point operand). - ARM64_OP_CIMM = 64, ///< C-Immediate - ARM64_OP_REG_MRS, ///< MRS register operand. - ARM64_OP_REG_MSR, ///< MSR register operand. - ARM64_OP_PSTATE, ///< PState operand. - ARM64_OP_SYS, ///< SYS operand for IC/DC/AT/TLBI instructions. - ARM64_OP_PREFETCH, ///< Prefetch operand (PRFM). - ARM64_OP_BARRIER, ///< Memory barrier operand (ISB/DMB/DSB instructions). -} arm64_op_type; - -/// TLBI operations -typedef enum arm64_tlbi_op { - ARM64_TLBI_INVALID = 0, - - ARM64_TLBI_IPAS2E1IS, - ARM64_TLBI_IPAS2LE1IS, - ARM64_TLBI_VMALLE1IS, - ARM64_TLBI_ALLE2IS, - ARM64_TLBI_ALLE3IS, - ARM64_TLBI_VAE1IS, - ARM64_TLBI_VAE2IS, - ARM64_TLBI_VAE3IS, - ARM64_TLBI_ASIDE1IS, - ARM64_TLBI_VAAE1IS, - ARM64_TLBI_ALLE1IS, - ARM64_TLBI_VALE1IS, - ARM64_TLBI_VALE2IS, - ARM64_TLBI_VALE3IS, - ARM64_TLBI_VMALLS12E1IS, - ARM64_TLBI_VAALE1IS, - ARM64_TLBI_IPAS2E1, - ARM64_TLBI_IPAS2LE1, - ARM64_TLBI_VMALLE1, - ARM64_TLBI_ALLE2, - ARM64_TLBI_ALLE3, - ARM64_TLBI_VAE1, - ARM64_TLBI_VAE2, - ARM64_TLBI_VAE3, - ARM64_TLBI_ASIDE1, - ARM64_TLBI_VAAE1, - ARM64_TLBI_ALLE1, - ARM64_TLBI_VALE1, - ARM64_TLBI_VALE2, - ARM64_TLBI_VALE3, - ARM64_TLBI_VMALLS12E1, - ARM64_TLBI_VAALE1, - ARM64_TLBI_VMALLE1OS, - ARM64_TLBI_VAE1OS, - ARM64_TLBI_ASIDE1OS, - ARM64_TLBI_VAAE1OS, - ARM64_TLBI_VALE1OS, - ARM64_TLBI_VAALE1OS, - ARM64_TLBI_IPAS2E1OS, - ARM64_TLBI_IPAS2LE1OS, - ARM64_TLBI_VAE2OS, - ARM64_TLBI_VALE2OS, - ARM64_TLBI_VMALLS12E1OS, - ARM64_TLBI_VAE3OS, - ARM64_TLBI_VALE3OS, - ARM64_TLBI_ALLE2OS, - ARM64_TLBI_ALLE1OS, - ARM64_TLBI_ALLE3OS, - ARM64_TLBI_RVAE1, - ARM64_TLBI_RVAAE1, - ARM64_TLBI_RVALE1, - ARM64_TLBI_RVAALE1, - ARM64_TLBI_RVAE1IS, - ARM64_TLBI_RVAAE1IS, - ARM64_TLBI_RVALE1IS, - ARM64_TLBI_RVAALE1IS, - ARM64_TLBI_RVAE1OS, - ARM64_TLBI_RVAAE1OS, - ARM64_TLBI_RVALE1OS, - ARM64_TLBI_RVAALE1OS, - ARM64_TLBI_RIPAS2E1IS, - ARM64_TLBI_RIPAS2LE1IS, - ARM64_TLBI_RIPAS2E1, - ARM64_TLBI_RIPAS2LE1, - ARM64_TLBI_RIPAS2E1OS, - ARM64_TLBI_RIPAS2LE1OS, - ARM64_TLBI_RVAE2, - ARM64_TLBI_RVALE2, - ARM64_TLBI_RVAE2IS, - ARM64_TLBI_RVALE2IS, - ARM64_TLBI_RVAE2OS, - ARM64_TLBI_RVALE2OS, - ARM64_TLBI_RVAE3, - ARM64_TLBI_RVALE3, - ARM64_TLBI_RVAE3IS, - ARM64_TLBI_RVALE3IS, - ARM64_TLBI_RVAE3OS, - ARM64_TLBI_RVALE3OS, -} arm64_tlbi_op; - -/// AT operations -typedef enum arm64_at_op { - ARM64_AT_S1E1R, - ARM64_AT_S1E2R, - ARM64_AT_S1E3R, - ARM64_AT_S1E1W, - ARM64_AT_S1E2W, - ARM64_AT_S1E3W, - ARM64_AT_S1E0R, - ARM64_AT_S1E0W, - ARM64_AT_S12E1R, - ARM64_AT_S12E1W, - ARM64_AT_S12E0R, - ARM64_AT_S12E0W, - ARM64_AT_S1E1RP, - ARM64_AT_S1E1WP, -} arm64_at_op; - -/// DC operations -typedef enum arm64_dc_op { - ARM64_DC_INVALID = 0, - ARM64_DC_ZVA, - ARM64_DC_IVAC, - ARM64_DC_ISW, - ARM64_DC_CVAC, - ARM64_DC_CSW, - ARM64_DC_CVAU, - ARM64_DC_CIVAC, - ARM64_DC_CISW, - ARM64_DC_CVAP, -} arm64_dc_op; - -/// IC operations -typedef enum arm64_ic_op { - ARM64_IC_INVALID = 0, - ARM64_IC_IALLUIS, - ARM64_IC_IALLU, - ARM64_IC_IVAU, -} arm64_ic_op; - -/// Prefetch operations (PRFM) -typedef enum arm64_prefetch_op { - ARM64_PRFM_INVALID = 0, - ARM64_PRFM_PLDL1KEEP = 0x00 + 1, - ARM64_PRFM_PLDL1STRM = 0x01 + 1, - ARM64_PRFM_PLDL2KEEP = 0x02 + 1, - ARM64_PRFM_PLDL2STRM = 0x03 + 1, - ARM64_PRFM_PLDL3KEEP = 0x04 + 1, - ARM64_PRFM_PLDL3STRM = 0x05 + 1, - ARM64_PRFM_PLIL1KEEP = 0x08 + 1, - ARM64_PRFM_PLIL1STRM = 0x09 + 1, - ARM64_PRFM_PLIL2KEEP = 0x0a + 1, - ARM64_PRFM_PLIL2STRM = 0x0b + 1, - ARM64_PRFM_PLIL3KEEP = 0x0c + 1, - ARM64_PRFM_PLIL3STRM = 0x0d + 1, - ARM64_PRFM_PSTL1KEEP = 0x10 + 1, - ARM64_PRFM_PSTL1STRM = 0x11 + 1, - ARM64_PRFM_PSTL2KEEP = 0x12 + 1, - ARM64_PRFM_PSTL2STRM = 0x13 + 1, - ARM64_PRFM_PSTL3KEEP = 0x14 + 1, - ARM64_PRFM_PSTL3STRM = 0x15 + 1, -} arm64_prefetch_op; - -/// ARM64 registers -typedef enum arm64_reg { - ARM64_REG_INVALID = 0, - - ARM64_REG_FFR = 1, - ARM64_REG_FP = 2, - ARM64_REG_LR = 3, - ARM64_REG_NZCV = 4, - ARM64_REG_SP = 5, - ARM64_REG_WSP = 6, - ARM64_REG_WZR = 7, - ARM64_REG_XZR = 8, - ARM64_REG_B0 = 9, - ARM64_REG_B1 = 10, - ARM64_REG_B2 = 11, - ARM64_REG_B3 = 12, - ARM64_REG_B4 = 13, - ARM64_REG_B5 = 14, - ARM64_REG_B6 = 15, - ARM64_REG_B7 = 16, - ARM64_REG_B8 = 17, - ARM64_REG_B9 = 18, - ARM64_REG_B10 = 19, - ARM64_REG_B11 = 20, - ARM64_REG_B12 = 21, - ARM64_REG_B13 = 22, - ARM64_REG_B14 = 23, - ARM64_REG_B15 = 24, - ARM64_REG_B16 = 25, - ARM64_REG_B17 = 26, - ARM64_REG_B18 = 27, - ARM64_REG_B19 = 28, - ARM64_REG_B20 = 29, - ARM64_REG_B21 = 30, - ARM64_REG_B22 = 31, - ARM64_REG_B23 = 32, - ARM64_REG_B24 = 33, - ARM64_REG_B25 = 34, - ARM64_REG_B26 = 35, - ARM64_REG_B27 = 36, - ARM64_REG_B28 = 37, - ARM64_REG_B29 = 38, - ARM64_REG_B30 = 39, - ARM64_REG_B31 = 40, - ARM64_REG_D0 = 41, - ARM64_REG_D1 = 42, - ARM64_REG_D2 = 43, - ARM64_REG_D3 = 44, - ARM64_REG_D4 = 45, - ARM64_REG_D5 = 46, - ARM64_REG_D6 = 47, - ARM64_REG_D7 = 48, - ARM64_REG_D8 = 49, - ARM64_REG_D9 = 50, - ARM64_REG_D10 = 51, - ARM64_REG_D11 = 52, - ARM64_REG_D12 = 53, - ARM64_REG_D13 = 54, - ARM64_REG_D14 = 55, - ARM64_REG_D15 = 56, - ARM64_REG_D16 = 57, - ARM64_REG_D17 = 58, - ARM64_REG_D18 = 59, - ARM64_REG_D19 = 60, - ARM64_REG_D20 = 61, - ARM64_REG_D21 = 62, - ARM64_REG_D22 = 63, - ARM64_REG_D23 = 64, - ARM64_REG_D24 = 65, - ARM64_REG_D25 = 66, - ARM64_REG_D26 = 67, - ARM64_REG_D27 = 68, - ARM64_REG_D28 = 69, - ARM64_REG_D29 = 70, - ARM64_REG_D30 = 71, - ARM64_REG_D31 = 72, - ARM64_REG_H0 = 73, - ARM64_REG_H1 = 74, - ARM64_REG_H2 = 75, - ARM64_REG_H3 = 76, - ARM64_REG_H4 = 77, - ARM64_REG_H5 = 78, - ARM64_REG_H6 = 79, - ARM64_REG_H7 = 80, - ARM64_REG_H8 = 81, - ARM64_REG_H9 = 82, - ARM64_REG_H10 = 83, - ARM64_REG_H11 = 84, - ARM64_REG_H12 = 85, - ARM64_REG_H13 = 86, - ARM64_REG_H14 = 87, - ARM64_REG_H15 = 88, - ARM64_REG_H16 = 89, - ARM64_REG_H17 = 90, - ARM64_REG_H18 = 91, - ARM64_REG_H19 = 92, - ARM64_REG_H20 = 93, - ARM64_REG_H21 = 94, - ARM64_REG_H22 = 95, - ARM64_REG_H23 = 96, - ARM64_REG_H24 = 97, - ARM64_REG_H25 = 98, - ARM64_REG_H26 = 99, - ARM64_REG_H27 = 100, - ARM64_REG_H28 = 101, - ARM64_REG_H29 = 102, - ARM64_REG_H30 = 103, - ARM64_REG_H31 = 104, - ARM64_REG_P0 = 105, - ARM64_REG_P1 = 106, - ARM64_REG_P2 = 107, - ARM64_REG_P3 = 108, - ARM64_REG_P4 = 109, - ARM64_REG_P5 = 110, - ARM64_REG_P6 = 111, - ARM64_REG_P7 = 112, - ARM64_REG_P8 = 113, - ARM64_REG_P9 = 114, - ARM64_REG_P10 = 115, - ARM64_REG_P11 = 116, - ARM64_REG_P12 = 117, - ARM64_REG_P13 = 118, - ARM64_REG_P14 = 119, - ARM64_REG_P15 = 120, - ARM64_REG_Q0 = 121, - ARM64_REG_Q1 = 122, - ARM64_REG_Q2 = 123, - ARM64_REG_Q3 = 124, - ARM64_REG_Q4 = 125, - ARM64_REG_Q5 = 126, - ARM64_REG_Q6 = 127, - ARM64_REG_Q7 = 128, - ARM64_REG_Q8 = 129, - ARM64_REG_Q9 = 130, - ARM64_REG_Q10 = 131, - ARM64_REG_Q11 = 132, - ARM64_REG_Q12 = 133, - ARM64_REG_Q13 = 134, - ARM64_REG_Q14 = 135, - ARM64_REG_Q15 = 136, - ARM64_REG_Q16 = 137, - ARM64_REG_Q17 = 138, - ARM64_REG_Q18 = 139, - ARM64_REG_Q19 = 140, - ARM64_REG_Q20 = 141, - ARM64_REG_Q21 = 142, - ARM64_REG_Q22 = 143, - ARM64_REG_Q23 = 144, - ARM64_REG_Q24 = 145, - ARM64_REG_Q25 = 146, - ARM64_REG_Q26 = 147, - ARM64_REG_Q27 = 148, - ARM64_REG_Q28 = 149, - ARM64_REG_Q29 = 150, - ARM64_REG_Q30 = 151, - ARM64_REG_Q31 = 152, - ARM64_REG_S0 = 153, - ARM64_REG_S1 = 154, - ARM64_REG_S2 = 155, - ARM64_REG_S3 = 156, - ARM64_REG_S4 = 157, - ARM64_REG_S5 = 158, - ARM64_REG_S6 = 159, - ARM64_REG_S7 = 160, - ARM64_REG_S8 = 161, - ARM64_REG_S9 = 162, - ARM64_REG_S10 = 163, - ARM64_REG_S11 = 164, - ARM64_REG_S12 = 165, - ARM64_REG_S13 = 166, - ARM64_REG_S14 = 167, - ARM64_REG_S15 = 168, - ARM64_REG_S16 = 169, - ARM64_REG_S17 = 170, - ARM64_REG_S18 = 171, - ARM64_REG_S19 = 172, - ARM64_REG_S20 = 173, - ARM64_REG_S21 = 174, - ARM64_REG_S22 = 175, - ARM64_REG_S23 = 176, - ARM64_REG_S24 = 177, - ARM64_REG_S25 = 178, - ARM64_REG_S26 = 179, - ARM64_REG_S27 = 180, - ARM64_REG_S28 = 181, - ARM64_REG_S29 = 182, - ARM64_REG_S30 = 183, - ARM64_REG_S31 = 184, - ARM64_REG_W0 = 185, - ARM64_REG_W1 = 186, - ARM64_REG_W2 = 187, - ARM64_REG_W3 = 188, - ARM64_REG_W4 = 189, - ARM64_REG_W5 = 190, - ARM64_REG_W6 = 191, - ARM64_REG_W7 = 192, - ARM64_REG_W8 = 193, - ARM64_REG_W9 = 194, - ARM64_REG_W10 = 195, - ARM64_REG_W11 = 196, - ARM64_REG_W12 = 197, - ARM64_REG_W13 = 198, - ARM64_REG_W14 = 199, - ARM64_REG_W15 = 200, - ARM64_REG_W16 = 201, - ARM64_REG_W17 = 202, - ARM64_REG_W18 = 203, - ARM64_REG_W19 = 204, - ARM64_REG_W20 = 205, - ARM64_REG_W21 = 206, - ARM64_REG_W22 = 207, - ARM64_REG_W23 = 208, - ARM64_REG_W24 = 209, - ARM64_REG_W25 = 210, - ARM64_REG_W26 = 211, - ARM64_REG_W27 = 212, - ARM64_REG_W28 = 213, - ARM64_REG_W29 = 214, - ARM64_REG_W30 = 215, - ARM64_REG_X0 = 216, - ARM64_REG_X1 = 217, - ARM64_REG_X2 = 218, - ARM64_REG_X3 = 219, - ARM64_REG_X4 = 220, - ARM64_REG_X5 = 221, - ARM64_REG_X6 = 222, - ARM64_REG_X7 = 223, - ARM64_REG_X8 = 224, - ARM64_REG_X9 = 225, - ARM64_REG_X10 = 226, - ARM64_REG_X11 = 227, - ARM64_REG_X12 = 228, - ARM64_REG_X13 = 229, - ARM64_REG_X14 = 230, - ARM64_REG_X15 = 231, - ARM64_REG_X16 = 232, - ARM64_REG_X17 = 233, - ARM64_REG_X18 = 234, - ARM64_REG_X19 = 235, - ARM64_REG_X20 = 236, - ARM64_REG_X21 = 237, - ARM64_REG_X22 = 238, - ARM64_REG_X23 = 239, - ARM64_REG_X24 = 240, - ARM64_REG_X25 = 241, - ARM64_REG_X26 = 242, - ARM64_REG_X27 = 243, - ARM64_REG_X28 = 244, - ARM64_REG_Z0 = 245, - ARM64_REG_Z1 = 246, - ARM64_REG_Z2 = 247, - ARM64_REG_Z3 = 248, - ARM64_REG_Z4 = 249, - ARM64_REG_Z5 = 250, - ARM64_REG_Z6 = 251, - ARM64_REG_Z7 = 252, - ARM64_REG_Z8 = 253, - ARM64_REG_Z9 = 254, - ARM64_REG_Z10 = 255, - ARM64_REG_Z11 = 256, - ARM64_REG_Z12 = 257, - ARM64_REG_Z13 = 258, - ARM64_REG_Z14 = 259, - ARM64_REG_Z15 = 260, - ARM64_REG_Z16 = 261, - ARM64_REG_Z17 = 262, - ARM64_REG_Z18 = 263, - ARM64_REG_Z19 = 264, - ARM64_REG_Z20 = 265, - ARM64_REG_Z21 = 266, - ARM64_REG_Z22 = 267, - ARM64_REG_Z23 = 268, - ARM64_REG_Z24 = 269, - ARM64_REG_Z25 = 270, - ARM64_REG_Z26 = 271, - ARM64_REG_Z27 = 272, - ARM64_REG_Z28 = 273, - ARM64_REG_Z29 = 274, - ARM64_REG_Z30 = 275, - ARM64_REG_Z31 = 276, - - ARM64_REG_V0, - ARM64_REG_V1, - ARM64_REG_V2, - ARM64_REG_V3, - ARM64_REG_V4, - ARM64_REG_V5, - ARM64_REG_V6, - ARM64_REG_V7, - ARM64_REG_V8, - ARM64_REG_V9, - ARM64_REG_V10, - ARM64_REG_V11, - ARM64_REG_V12, - ARM64_REG_V13, - ARM64_REG_V14, - ARM64_REG_V15, - ARM64_REG_V16, - ARM64_REG_V17, - ARM64_REG_V18, - ARM64_REG_V19, - ARM64_REG_V20, - ARM64_REG_V21, - ARM64_REG_V22, - ARM64_REG_V23, - ARM64_REG_V24, - ARM64_REG_V25, - ARM64_REG_V26, - ARM64_REG_V27, - ARM64_REG_V28, - ARM64_REG_V29, - ARM64_REG_V30, - ARM64_REG_V31, - - ARM64_REG_ENDING, // <-- mark the end of the list of registers - - // alias registers - ARM64_REG_IP0 = ARM64_REG_X16, - ARM64_REG_IP1 = ARM64_REG_X17, - ARM64_REG_X29 = ARM64_REG_FP, - ARM64_REG_X30 = ARM64_REG_LR, -} arm64_reg; - -/// Instruction's operand referring to memory -/// This is associated with ARM64_OP_MEM operand type above -typedef struct arm64_op_mem { - arm64_reg base; ///< base register - arm64_reg index; ///< index register - int32_t disp; ///< displacement/offset value -} arm64_op_mem; - -/// Instruction operand -typedef struct cs_arm64_op { - int vector_index; ///< Vector Index for some vector operands (or -1 if irrelevant) - arm64_vas vas; ///< Vector Arrangement Specifier - struct { - arm64_shifter type; ///< shifter type of this operand - unsigned int value; ///< shifter value of this operand - } shift; - arm64_extender ext; ///< extender type of this operand - arm64_op_type type; ///< operand type - union { - arm64_reg reg; ///< register value for REG operand - int64_t imm; ///< immediate value, or index for C-IMM or IMM operand - double fp; ///< floating point value for FP operand - arm64_op_mem mem; ///< base/index/scale/disp value for MEM operand - arm64_pstate pstate; ///< PState field of MSR instruction. - unsigned int sys; ///< IC/DC/AT/TLBI operation (see arm64_ic_op, arm64_dc_op, arm64_at_op, arm64_tlbi_op) - arm64_prefetch_op prefetch; ///< PRFM operation. - arm64_barrier_op barrier; ///< Memory barrier operation (ISB/DMB/DSB instructions). - }; - - /// How is this operand accessed? (READ, WRITE or READ|WRITE) - /// This field is combined of cs_ac_type. - /// NOTE: this field is irrelevant if engine is compiled in DIET mode. - uint8_t access; -} cs_arm64_op; - -/// Instruction structure -typedef struct cs_arm64 { - arm64_cc cc; ///< conditional code for this insn - bool update_flags; ///< does this insn update flags? - bool writeback; ///< does this insn request writeback? 'True' means 'yes' - - /// Number of operands of this instruction, - /// or 0 when instruction has no operand. - uint8_t op_count; - - cs_arm64_op operands[8]; ///< operands for this instruction. -} cs_arm64; - -/// ARM64 instruction -typedef enum arm64_insn { - ARM64_INS_INVALID = 0, - - ARM64_INS_ABS, - ARM64_INS_ADC, - ARM64_INS_ADCS, - ARM64_INS_ADD, - ARM64_INS_ADDHN, - ARM64_INS_ADDHN2, - ARM64_INS_ADDP, - ARM64_INS_ADDPL, - ARM64_INS_ADDS, - ARM64_INS_ADDV, - ARM64_INS_ADDVL, - ARM64_INS_ADR, - ARM64_INS_ADRP, - ARM64_INS_AESD, - ARM64_INS_AESE, - ARM64_INS_AESIMC, - ARM64_INS_AESMC, - ARM64_INS_AND, - ARM64_INS_ANDS, - ARM64_INS_ANDV, - ARM64_INS_ASR, - ARM64_INS_ASRD, - ARM64_INS_ASRR, - ARM64_INS_ASRV, - ARM64_INS_AUTDA, - ARM64_INS_AUTDB, - ARM64_INS_AUTDZA, - ARM64_INS_AUTDZB, - ARM64_INS_AUTIA, - ARM64_INS_AUTIA1716, - ARM64_INS_AUTIASP, - ARM64_INS_AUTIAZ, - ARM64_INS_AUTIB, - ARM64_INS_AUTIB1716, - ARM64_INS_AUTIBSP, - ARM64_INS_AUTIBZ, - ARM64_INS_AUTIZA, - ARM64_INS_AUTIZB, - ARM64_INS_B, - ARM64_INS_BCAX, - ARM64_INS_BFM, - ARM64_INS_BIC, - ARM64_INS_BICS, - ARM64_INS_BIF, - ARM64_INS_BIT, - ARM64_INS_BL, - ARM64_INS_BLR, - ARM64_INS_BLRAA, - ARM64_INS_BLRAAZ, - ARM64_INS_BLRAB, - ARM64_INS_BLRABZ, - ARM64_INS_BR, - ARM64_INS_BRAA, - ARM64_INS_BRAAZ, - ARM64_INS_BRAB, - ARM64_INS_BRABZ, - ARM64_INS_BRK, - ARM64_INS_BRKA, - ARM64_INS_BRKAS, - ARM64_INS_BRKB, - ARM64_INS_BRKBS, - ARM64_INS_BRKN, - ARM64_INS_BRKNS, - ARM64_INS_BRKPA, - ARM64_INS_BRKPAS, - ARM64_INS_BRKPB, - ARM64_INS_BRKPBS, - ARM64_INS_BSL, - ARM64_INS_CAS, - ARM64_INS_CASA, - ARM64_INS_CASAB, - ARM64_INS_CASAH, - ARM64_INS_CASAL, - ARM64_INS_CASALB, - ARM64_INS_CASALH, - ARM64_INS_CASB, - ARM64_INS_CASH, - ARM64_INS_CASL, - ARM64_INS_CASLB, - ARM64_INS_CASLH, - ARM64_INS_CASP, - ARM64_INS_CASPA, - ARM64_INS_CASPAL, - ARM64_INS_CASPL, - ARM64_INS_CBNZ, - ARM64_INS_CBZ, - ARM64_INS_CCMN, - ARM64_INS_CCMP, - ARM64_INS_CFINV, - ARM64_INS_CINC, - ARM64_INS_CINV, - ARM64_INS_CLASTA, - ARM64_INS_CLASTB, - ARM64_INS_CLREX, - ARM64_INS_CLS, - ARM64_INS_CLZ, - ARM64_INS_CMEQ, - ARM64_INS_CMGE, - ARM64_INS_CMGT, - ARM64_INS_CMHI, - ARM64_INS_CMHS, - ARM64_INS_CMLE, - ARM64_INS_CMLO, - ARM64_INS_CMLS, - ARM64_INS_CMLT, - ARM64_INS_CMN, - ARM64_INS_CMP, - ARM64_INS_CMPEQ, - ARM64_INS_CMPGE, - ARM64_INS_CMPGT, - ARM64_INS_CMPHI, - ARM64_INS_CMPHS, - ARM64_INS_CMPLE, - ARM64_INS_CMPLO, - ARM64_INS_CMPLS, - ARM64_INS_CMPLT, - ARM64_INS_CMPNE, - ARM64_INS_CMTST, - ARM64_INS_CNEG, - ARM64_INS_CNOT, - ARM64_INS_CNT, - ARM64_INS_CNTB, - ARM64_INS_CNTD, - ARM64_INS_CNTH, - ARM64_INS_CNTP, - ARM64_INS_CNTW, - ARM64_INS_COMPACT, - ARM64_INS_CPY, - ARM64_INS_CRC32B, - ARM64_INS_CRC32CB, - ARM64_INS_CRC32CH, - ARM64_INS_CRC32CW, - ARM64_INS_CRC32CX, - ARM64_INS_CRC32H, - ARM64_INS_CRC32W, - ARM64_INS_CRC32X, - ARM64_INS_CSDB, - ARM64_INS_CSEL, - ARM64_INS_CSET, - ARM64_INS_CSETM, - ARM64_INS_CSINC, - ARM64_INS_CSINV, - ARM64_INS_CSNEG, - ARM64_INS_CTERMEQ, - ARM64_INS_CTERMNE, - ARM64_INS_DCPS1, - ARM64_INS_DCPS2, - ARM64_INS_DCPS3, - ARM64_INS_DECB, - ARM64_INS_DECD, - ARM64_INS_DECH, - ARM64_INS_DECP, - ARM64_INS_DECW, - ARM64_INS_DMB, - ARM64_INS_DRPS, - ARM64_INS_DSB, - ARM64_INS_DUP, - ARM64_INS_DUPM, - ARM64_INS_EON, - ARM64_INS_EOR, - ARM64_INS_EOR3, - ARM64_INS_EORS, - ARM64_INS_EORV, - ARM64_INS_ERET, - ARM64_INS_ERETAA, - ARM64_INS_ERETAB, - ARM64_INS_ESB, - ARM64_INS_EXT, - ARM64_INS_EXTR, - ARM64_INS_FABD, - ARM64_INS_FABS, - ARM64_INS_FACGE, - ARM64_INS_FACGT, - ARM64_INS_FACLE, - ARM64_INS_FACLT, - ARM64_INS_FADD, - ARM64_INS_FADDA, - ARM64_INS_FADDP, - ARM64_INS_FADDV, - ARM64_INS_FCADD, - ARM64_INS_FCCMP, - ARM64_INS_FCCMPE, - ARM64_INS_FCMEQ, - ARM64_INS_FCMGE, - ARM64_INS_FCMGT, - ARM64_INS_FCMLA, - ARM64_INS_FCMLE, - ARM64_INS_FCMLT, - ARM64_INS_FCMNE, - ARM64_INS_FCMP, - ARM64_INS_FCMPE, - ARM64_INS_FCMUO, - ARM64_INS_FCPY, - ARM64_INS_FCSEL, - ARM64_INS_FCVT, - ARM64_INS_FCVTAS, - ARM64_INS_FCVTAU, - ARM64_INS_FCVTL, - ARM64_INS_FCVTL2, - ARM64_INS_FCVTMS, - ARM64_INS_FCVTMU, - ARM64_INS_FCVTN, - ARM64_INS_FCVTN2, - ARM64_INS_FCVTNS, - ARM64_INS_FCVTNU, - ARM64_INS_FCVTPS, - ARM64_INS_FCVTPU, - ARM64_INS_FCVTXN, - ARM64_INS_FCVTXN2, - ARM64_INS_FCVTZS, - ARM64_INS_FCVTZU, - ARM64_INS_FDIV, - ARM64_INS_FDIVR, - ARM64_INS_FDUP, - ARM64_INS_FEXPA, - ARM64_INS_FJCVTZS, - ARM64_INS_FMAD, - ARM64_INS_FMADD, - ARM64_INS_FMAX, - ARM64_INS_FMAXNM, - ARM64_INS_FMAXNMP, - ARM64_INS_FMAXNMV, - ARM64_INS_FMAXP, - ARM64_INS_FMAXV, - ARM64_INS_FMIN, - ARM64_INS_FMINNM, - ARM64_INS_FMINNMP, - ARM64_INS_FMINNMV, - ARM64_INS_FMINP, - ARM64_INS_FMINV, - ARM64_INS_FMLA, - ARM64_INS_FMLS, - ARM64_INS_FMOV, - ARM64_INS_FMSB, - ARM64_INS_FMSUB, - ARM64_INS_FMUL, - ARM64_INS_FMULX, - ARM64_INS_FNEG, - ARM64_INS_FNMAD, - ARM64_INS_FNMADD, - ARM64_INS_FNMLA, - ARM64_INS_FNMLS, - ARM64_INS_FNMSB, - ARM64_INS_FNMSUB, - ARM64_INS_FNMUL, - ARM64_INS_FRECPE, - ARM64_INS_FRECPS, - ARM64_INS_FRECPX, - ARM64_INS_FRINTA, - ARM64_INS_FRINTI, - ARM64_INS_FRINTM, - ARM64_INS_FRINTN, - ARM64_INS_FRINTP, - ARM64_INS_FRINTX, - ARM64_INS_FRINTZ, - ARM64_INS_FRSQRTE, - ARM64_INS_FRSQRTS, - ARM64_INS_FSCALE, - ARM64_INS_FSQRT, - ARM64_INS_FSUB, - ARM64_INS_FSUBR, - ARM64_INS_FTMAD, - ARM64_INS_FTSMUL, - ARM64_INS_FTSSEL, - ARM64_INS_HINT, - ARM64_INS_HLT, - ARM64_INS_HVC, - ARM64_INS_INCB, - ARM64_INS_INCD, - ARM64_INS_INCH, - ARM64_INS_INCP, - ARM64_INS_INCW, - ARM64_INS_INDEX, - ARM64_INS_INS, - ARM64_INS_INSR, - ARM64_INS_ISB, - ARM64_INS_LASTA, - ARM64_INS_LASTB, - ARM64_INS_LD1, - ARM64_INS_LD1B, - ARM64_INS_LD1D, - ARM64_INS_LD1H, - ARM64_INS_LD1R, - ARM64_INS_LD1RB, - ARM64_INS_LD1RD, - ARM64_INS_LD1RH, - ARM64_INS_LD1RQB, - ARM64_INS_LD1RQD, - ARM64_INS_LD1RQH, - ARM64_INS_LD1RQW, - ARM64_INS_LD1RSB, - ARM64_INS_LD1RSH, - ARM64_INS_LD1RSW, - ARM64_INS_LD1RW, - ARM64_INS_LD1SB, - ARM64_INS_LD1SH, - ARM64_INS_LD1SW, - ARM64_INS_LD1W, - ARM64_INS_LD2, - ARM64_INS_LD2B, - ARM64_INS_LD2D, - ARM64_INS_LD2H, - ARM64_INS_LD2R, - ARM64_INS_LD2W, - ARM64_INS_LD3, - ARM64_INS_LD3B, - ARM64_INS_LD3D, - ARM64_INS_LD3H, - ARM64_INS_LD3R, - ARM64_INS_LD3W, - ARM64_INS_LD4, - ARM64_INS_LD4B, - ARM64_INS_LD4D, - ARM64_INS_LD4H, - ARM64_INS_LD4R, - ARM64_INS_LD4W, - ARM64_INS_LDADD, - ARM64_INS_LDADDA, - ARM64_INS_LDADDAB, - ARM64_INS_LDADDAH, - ARM64_INS_LDADDAL, - ARM64_INS_LDADDALB, - ARM64_INS_LDADDALH, - ARM64_INS_LDADDB, - ARM64_INS_LDADDH, - ARM64_INS_LDADDL, - ARM64_INS_LDADDLB, - ARM64_INS_LDADDLH, - ARM64_INS_LDAPR, - ARM64_INS_LDAPRB, - ARM64_INS_LDAPRH, - ARM64_INS_LDAPUR, - ARM64_INS_LDAPURB, - ARM64_INS_LDAPURH, - ARM64_INS_LDAPURSB, - ARM64_INS_LDAPURSH, - ARM64_INS_LDAPURSW, - ARM64_INS_LDAR, - ARM64_INS_LDARB, - ARM64_INS_LDARH, - ARM64_INS_LDAXP, - ARM64_INS_LDAXR, - ARM64_INS_LDAXRB, - ARM64_INS_LDAXRH, - ARM64_INS_LDCLR, - ARM64_INS_LDCLRA, - ARM64_INS_LDCLRAB, - ARM64_INS_LDCLRAH, - ARM64_INS_LDCLRAL, - ARM64_INS_LDCLRALB, - ARM64_INS_LDCLRALH, - ARM64_INS_LDCLRB, - ARM64_INS_LDCLRH, - ARM64_INS_LDCLRL, - ARM64_INS_LDCLRLB, - ARM64_INS_LDCLRLH, - ARM64_INS_LDEOR, - ARM64_INS_LDEORA, - ARM64_INS_LDEORAB, - ARM64_INS_LDEORAH, - ARM64_INS_LDEORAL, - ARM64_INS_LDEORALB, - ARM64_INS_LDEORALH, - ARM64_INS_LDEORB, - ARM64_INS_LDEORH, - ARM64_INS_LDEORL, - ARM64_INS_LDEORLB, - ARM64_INS_LDEORLH, - ARM64_INS_LDFF1B, - ARM64_INS_LDFF1D, - ARM64_INS_LDFF1H, - ARM64_INS_LDFF1SB, - ARM64_INS_LDFF1SH, - ARM64_INS_LDFF1SW, - ARM64_INS_LDFF1W, - ARM64_INS_LDLAR, - ARM64_INS_LDLARB, - ARM64_INS_LDLARH, - ARM64_INS_LDNF1B, - ARM64_INS_LDNF1D, - ARM64_INS_LDNF1H, - ARM64_INS_LDNF1SB, - ARM64_INS_LDNF1SH, - ARM64_INS_LDNF1SW, - ARM64_INS_LDNF1W, - ARM64_INS_LDNP, - ARM64_INS_LDNT1B, - ARM64_INS_LDNT1D, - ARM64_INS_LDNT1H, - ARM64_INS_LDNT1W, - ARM64_INS_LDP, - ARM64_INS_LDPSW, - ARM64_INS_LDR, - ARM64_INS_LDRAA, - ARM64_INS_LDRAB, - ARM64_INS_LDRB, - ARM64_INS_LDRH, - ARM64_INS_LDRSB, - ARM64_INS_LDRSH, - ARM64_INS_LDRSW, - ARM64_INS_LDSET, - ARM64_INS_LDSETA, - ARM64_INS_LDSETAB, - ARM64_INS_LDSETAH, - ARM64_INS_LDSETAL, - ARM64_INS_LDSETALB, - ARM64_INS_LDSETALH, - ARM64_INS_LDSETB, - ARM64_INS_LDSETH, - ARM64_INS_LDSETL, - ARM64_INS_LDSETLB, - ARM64_INS_LDSETLH, - ARM64_INS_LDSMAX, - ARM64_INS_LDSMAXA, - ARM64_INS_LDSMAXAB, - ARM64_INS_LDSMAXAH, - ARM64_INS_LDSMAXAL, - ARM64_INS_LDSMAXALB, - ARM64_INS_LDSMAXALH, - ARM64_INS_LDSMAXB, - ARM64_INS_LDSMAXH, - ARM64_INS_LDSMAXL, - ARM64_INS_LDSMAXLB, - ARM64_INS_LDSMAXLH, - ARM64_INS_LDSMIN, - ARM64_INS_LDSMINA, - ARM64_INS_LDSMINAB, - ARM64_INS_LDSMINAH, - ARM64_INS_LDSMINAL, - ARM64_INS_LDSMINALB, - ARM64_INS_LDSMINALH, - ARM64_INS_LDSMINB, - ARM64_INS_LDSMINH, - ARM64_INS_LDSMINL, - ARM64_INS_LDSMINLB, - ARM64_INS_LDSMINLH, - ARM64_INS_LDTR, - ARM64_INS_LDTRB, - ARM64_INS_LDTRH, - ARM64_INS_LDTRSB, - ARM64_INS_LDTRSH, - ARM64_INS_LDTRSW, - ARM64_INS_LDUMAX, - ARM64_INS_LDUMAXA, - ARM64_INS_LDUMAXAB, - ARM64_INS_LDUMAXAH, - ARM64_INS_LDUMAXAL, - ARM64_INS_LDUMAXALB, - ARM64_INS_LDUMAXALH, - ARM64_INS_LDUMAXB, - ARM64_INS_LDUMAXH, - ARM64_INS_LDUMAXL, - ARM64_INS_LDUMAXLB, - ARM64_INS_LDUMAXLH, - ARM64_INS_LDUMIN, - ARM64_INS_LDUMINA, - ARM64_INS_LDUMINAB, - ARM64_INS_LDUMINAH, - ARM64_INS_LDUMINAL, - ARM64_INS_LDUMINALB, - ARM64_INS_LDUMINALH, - ARM64_INS_LDUMINB, - ARM64_INS_LDUMINH, - ARM64_INS_LDUMINL, - ARM64_INS_LDUMINLB, - ARM64_INS_LDUMINLH, - ARM64_INS_LDUR, - ARM64_INS_LDURB, - ARM64_INS_LDURH, - ARM64_INS_LDURSB, - ARM64_INS_LDURSH, - ARM64_INS_LDURSW, - ARM64_INS_LDXP, - ARM64_INS_LDXR, - ARM64_INS_LDXRB, - ARM64_INS_LDXRH, - ARM64_INS_LSL, - ARM64_INS_LSLR, - ARM64_INS_LSLV, - ARM64_INS_LSR, - ARM64_INS_LSRR, - ARM64_INS_LSRV, - ARM64_INS_MAD, - ARM64_INS_MADD, - ARM64_INS_MLA, - ARM64_INS_MLS, - ARM64_INS_MNEG, - ARM64_INS_MOV, - ARM64_INS_MOVI, - ARM64_INS_MOVK, - ARM64_INS_MOVN, - ARM64_INS_MOVPRFX, - ARM64_INS_MOVS, - ARM64_INS_MOVZ, - ARM64_INS_MRS, - ARM64_INS_MSB, - ARM64_INS_MSR, - ARM64_INS_MSUB, - ARM64_INS_MUL, - ARM64_INS_MVN, - ARM64_INS_MVNI, - ARM64_INS_NAND, - ARM64_INS_NANDS, - ARM64_INS_NEG, - ARM64_INS_NEGS, - ARM64_INS_NGC, - ARM64_INS_NGCS, - ARM64_INS_NOP, - ARM64_INS_NOR, - ARM64_INS_NORS, - ARM64_INS_NOT, - ARM64_INS_NOTS, - ARM64_INS_ORN, - ARM64_INS_ORNS, - ARM64_INS_ORR, - ARM64_INS_ORRS, - ARM64_INS_ORV, - ARM64_INS_PACDA, - ARM64_INS_PACDB, - ARM64_INS_PACDZA, - ARM64_INS_PACDZB, - ARM64_INS_PACGA, - ARM64_INS_PACIA, - ARM64_INS_PACIA1716, - ARM64_INS_PACIASP, - ARM64_INS_PACIAZ, - ARM64_INS_PACIB, - ARM64_INS_PACIB1716, - ARM64_INS_PACIBSP, - ARM64_INS_PACIBZ, - ARM64_INS_PACIZA, - ARM64_INS_PACIZB, - ARM64_INS_PFALSE, - ARM64_INS_PFIRST, - ARM64_INS_PMUL, - ARM64_INS_PMULL, - ARM64_INS_PMULL2, - ARM64_INS_PNEXT, - ARM64_INS_PRFB, - ARM64_INS_PRFD, - ARM64_INS_PRFH, - ARM64_INS_PRFM, - ARM64_INS_PRFUM, - ARM64_INS_PRFW, - ARM64_INS_PSB, - ARM64_INS_PTEST, - ARM64_INS_PTRUE, - ARM64_INS_PTRUES, - ARM64_INS_PUNPKHI, - ARM64_INS_PUNPKLO, - ARM64_INS_RADDHN, - ARM64_INS_RADDHN2, - ARM64_INS_RAX1, - ARM64_INS_RBIT, - ARM64_INS_RDFFR, - ARM64_INS_RDFFRS, - ARM64_INS_RDVL, - ARM64_INS_RET, - ARM64_INS_RETAA, - ARM64_INS_RETAB, - ARM64_INS_REV, - ARM64_INS_REV16, - ARM64_INS_REV32, - ARM64_INS_REV64, - ARM64_INS_REVB, - ARM64_INS_REVH, - ARM64_INS_REVW, - ARM64_INS_RMIF, - ARM64_INS_ROR, - ARM64_INS_RORV, - ARM64_INS_RSHRN, - ARM64_INS_RSHRN2, - ARM64_INS_RSUBHN, - ARM64_INS_RSUBHN2, - ARM64_INS_SABA, - ARM64_INS_SABAL, - ARM64_INS_SABAL2, - ARM64_INS_SABD, - ARM64_INS_SABDL, - ARM64_INS_SABDL2, - ARM64_INS_SADALP, - ARM64_INS_SADDL, - ARM64_INS_SADDL2, - ARM64_INS_SADDLP, - ARM64_INS_SADDLV, - ARM64_INS_SADDV, - ARM64_INS_SADDW, - ARM64_INS_SADDW2, - ARM64_INS_SBC, - ARM64_INS_SBCS, - ARM64_INS_SBFM, - ARM64_INS_SCVTF, - ARM64_INS_SDIV, - ARM64_INS_SDIVR, - ARM64_INS_SDOT, - ARM64_INS_SEL, - ARM64_INS_SETF16, - ARM64_INS_SETF8, - ARM64_INS_SETFFR, - ARM64_INS_SEV, - ARM64_INS_SEVL, - ARM64_INS_SHA1C, - ARM64_INS_SHA1H, - ARM64_INS_SHA1M, - ARM64_INS_SHA1P, - ARM64_INS_SHA1SU0, - ARM64_INS_SHA1SU1, - ARM64_INS_SHA256H, - ARM64_INS_SHA256H2, - ARM64_INS_SHA256SU0, - ARM64_INS_SHA256SU1, - ARM64_INS_SHA512H, - ARM64_INS_SHA512H2, - ARM64_INS_SHA512SU0, - ARM64_INS_SHA512SU1, - ARM64_INS_SHADD, - ARM64_INS_SHL, - ARM64_INS_SHLL, - ARM64_INS_SHLL2, - ARM64_INS_SHRN, - ARM64_INS_SHRN2, - ARM64_INS_SHSUB, - ARM64_INS_SLI, - ARM64_INS_SM3PARTW1, - ARM64_INS_SM3PARTW2, - ARM64_INS_SM3SS1, - ARM64_INS_SM3TT1A, - ARM64_INS_SM3TT1B, - ARM64_INS_SM3TT2A, - ARM64_INS_SM3TT2B, - ARM64_INS_SM4E, - ARM64_INS_SM4EKEY, - ARM64_INS_SMADDL, - ARM64_INS_SMAX, - ARM64_INS_SMAXP, - ARM64_INS_SMAXV, - ARM64_INS_SMC, - ARM64_INS_SMIN, - ARM64_INS_SMINP, - ARM64_INS_SMINV, - ARM64_INS_SMLAL, - ARM64_INS_SMLAL2, - ARM64_INS_SMLSL, - ARM64_INS_SMLSL2, - ARM64_INS_SMNEGL, - ARM64_INS_SMOV, - ARM64_INS_SMSUBL, - ARM64_INS_SMULH, - ARM64_INS_SMULL, - ARM64_INS_SMULL2, - ARM64_INS_SPLICE, - ARM64_INS_SQABS, - ARM64_INS_SQADD, - ARM64_INS_SQDECB, - ARM64_INS_SQDECD, - ARM64_INS_SQDECH, - ARM64_INS_SQDECP, - ARM64_INS_SQDECW, - ARM64_INS_SQDMLAL, - ARM64_INS_SQDMLAL2, - ARM64_INS_SQDMLSL, - ARM64_INS_SQDMLSL2, - ARM64_INS_SQDMULH, - ARM64_INS_SQDMULL, - ARM64_INS_SQDMULL2, - ARM64_INS_SQINCB, - ARM64_INS_SQINCD, - ARM64_INS_SQINCH, - ARM64_INS_SQINCP, - ARM64_INS_SQINCW, - ARM64_INS_SQNEG, - ARM64_INS_SQRDMLAH, - ARM64_INS_SQRDMLSH, - ARM64_INS_SQRDMULH, - ARM64_INS_SQRSHL, - ARM64_INS_SQRSHRN, - ARM64_INS_SQRSHRN2, - ARM64_INS_SQRSHRUN, - ARM64_INS_SQRSHRUN2, - ARM64_INS_SQSHL, - ARM64_INS_SQSHLU, - ARM64_INS_SQSHRN, - ARM64_INS_SQSHRN2, - ARM64_INS_SQSHRUN, - ARM64_INS_SQSHRUN2, - ARM64_INS_SQSUB, - ARM64_INS_SQXTN, - ARM64_INS_SQXTN2, - ARM64_INS_SQXTUN, - ARM64_INS_SQXTUN2, - ARM64_INS_SRHADD, - ARM64_INS_SRI, - ARM64_INS_SRSHL, - ARM64_INS_SRSHR, - ARM64_INS_SRSRA, - ARM64_INS_SSHL, - ARM64_INS_SSHLL, - ARM64_INS_SSHLL2, - ARM64_INS_SSHR, - ARM64_INS_SSRA, - ARM64_INS_SSUBL, - ARM64_INS_SSUBL2, - ARM64_INS_SSUBW, - ARM64_INS_SSUBW2, - ARM64_INS_ST1, - ARM64_INS_ST1B, - ARM64_INS_ST1D, - ARM64_INS_ST1H, - ARM64_INS_ST1W, - ARM64_INS_ST2, - ARM64_INS_ST2B, - ARM64_INS_ST2D, - ARM64_INS_ST2H, - ARM64_INS_ST2W, - ARM64_INS_ST3, - ARM64_INS_ST3B, - ARM64_INS_ST3D, - ARM64_INS_ST3H, - ARM64_INS_ST3W, - ARM64_INS_ST4, - ARM64_INS_ST4B, - ARM64_INS_ST4D, - ARM64_INS_ST4H, - ARM64_INS_ST4W, - ARM64_INS_STADD, - ARM64_INS_STADDB, - ARM64_INS_STADDH, - ARM64_INS_STADDL, - ARM64_INS_STADDLB, - ARM64_INS_STADDLH, - ARM64_INS_STCLR, - ARM64_INS_STCLRB, - ARM64_INS_STCLRH, - ARM64_INS_STCLRL, - ARM64_INS_STCLRLB, - ARM64_INS_STCLRLH, - ARM64_INS_STEOR, - ARM64_INS_STEORB, - ARM64_INS_STEORH, - ARM64_INS_STEORL, - ARM64_INS_STEORLB, - ARM64_INS_STEORLH, - ARM64_INS_STLLR, - ARM64_INS_STLLRB, - ARM64_INS_STLLRH, - ARM64_INS_STLR, - ARM64_INS_STLRB, - ARM64_INS_STLRH, - ARM64_INS_STLUR, - ARM64_INS_STLURB, - ARM64_INS_STLURH, - ARM64_INS_STLXP, - ARM64_INS_STLXR, - ARM64_INS_STLXRB, - ARM64_INS_STLXRH, - ARM64_INS_STNP, - ARM64_INS_STNT1B, - ARM64_INS_STNT1D, - ARM64_INS_STNT1H, - ARM64_INS_STNT1W, - ARM64_INS_STP, - ARM64_INS_STR, - ARM64_INS_STRB, - ARM64_INS_STRH, - ARM64_INS_STSET, - ARM64_INS_STSETB, - ARM64_INS_STSETH, - ARM64_INS_STSETL, - ARM64_INS_STSETLB, - ARM64_INS_STSETLH, - ARM64_INS_STSMAX, - ARM64_INS_STSMAXB, - ARM64_INS_STSMAXH, - ARM64_INS_STSMAXL, - ARM64_INS_STSMAXLB, - ARM64_INS_STSMAXLH, - ARM64_INS_STSMIN, - ARM64_INS_STSMINB, - ARM64_INS_STSMINH, - ARM64_INS_STSMINL, - ARM64_INS_STSMINLB, - ARM64_INS_STSMINLH, - ARM64_INS_STTR, - ARM64_INS_STTRB, - ARM64_INS_STTRH, - ARM64_INS_STUMAX, - ARM64_INS_STUMAXB, - ARM64_INS_STUMAXH, - ARM64_INS_STUMAXL, - ARM64_INS_STUMAXLB, - ARM64_INS_STUMAXLH, - ARM64_INS_STUMIN, - ARM64_INS_STUMINB, - ARM64_INS_STUMINH, - ARM64_INS_STUMINL, - ARM64_INS_STUMINLB, - ARM64_INS_STUMINLH, - ARM64_INS_STUR, - ARM64_INS_STURB, - ARM64_INS_STURH, - ARM64_INS_STXP, - ARM64_INS_STXR, - ARM64_INS_STXRB, - ARM64_INS_STXRH, - ARM64_INS_SUB, - ARM64_INS_SUBHN, - ARM64_INS_SUBHN2, - ARM64_INS_SUBR, - ARM64_INS_SUBS, - ARM64_INS_SUNPKHI, - ARM64_INS_SUNPKLO, - ARM64_INS_SUQADD, - ARM64_INS_SVC, - ARM64_INS_SWP, - ARM64_INS_SWPA, - ARM64_INS_SWPAB, - ARM64_INS_SWPAH, - ARM64_INS_SWPAL, - ARM64_INS_SWPALB, - ARM64_INS_SWPALH, - ARM64_INS_SWPB, - ARM64_INS_SWPH, - ARM64_INS_SWPL, - ARM64_INS_SWPLB, - ARM64_INS_SWPLH, - ARM64_INS_SXTB, - ARM64_INS_SXTH, - ARM64_INS_SXTL, - ARM64_INS_SXTL2, - ARM64_INS_SXTW, - ARM64_INS_SYS, - ARM64_INS_SYSL, - ARM64_INS_TBL, - ARM64_INS_TBNZ, - ARM64_INS_TBX, - ARM64_INS_TBZ, - ARM64_INS_TRN1, - ARM64_INS_TRN2, - ARM64_INS_TSB, - ARM64_INS_TST, - ARM64_INS_UABA, - ARM64_INS_UABAL, - ARM64_INS_UABAL2, - ARM64_INS_UABD, - ARM64_INS_UABDL, - ARM64_INS_UABDL2, - ARM64_INS_UADALP, - ARM64_INS_UADDL, - ARM64_INS_UADDL2, - ARM64_INS_UADDLP, - ARM64_INS_UADDLV, - ARM64_INS_UADDV, - ARM64_INS_UADDW, - ARM64_INS_UADDW2, - ARM64_INS_UBFM, - ARM64_INS_UCVTF, - ARM64_INS_UDIV, - ARM64_INS_UDIVR, - ARM64_INS_UDOT, - ARM64_INS_UHADD, - ARM64_INS_UHSUB, - ARM64_INS_UMADDL, - ARM64_INS_UMAX, - ARM64_INS_UMAXP, - ARM64_INS_UMAXV, - ARM64_INS_UMIN, - ARM64_INS_UMINP, - ARM64_INS_UMINV, - ARM64_INS_UMLAL, - ARM64_INS_UMLAL2, - ARM64_INS_UMLSL, - ARM64_INS_UMLSL2, - ARM64_INS_UMNEGL, - ARM64_INS_UMOV, - ARM64_INS_UMSUBL, - ARM64_INS_UMULH, - ARM64_INS_UMULL, - ARM64_INS_UMULL2, - ARM64_INS_UQADD, - ARM64_INS_UQDECB, - ARM64_INS_UQDECD, - ARM64_INS_UQDECH, - ARM64_INS_UQDECP, - ARM64_INS_UQDECW, - ARM64_INS_UQINCB, - ARM64_INS_UQINCD, - ARM64_INS_UQINCH, - ARM64_INS_UQINCP, - ARM64_INS_UQINCW, - ARM64_INS_UQRSHL, - ARM64_INS_UQRSHRN, - ARM64_INS_UQRSHRN2, - ARM64_INS_UQSHL, - ARM64_INS_UQSHRN, - ARM64_INS_UQSHRN2, - ARM64_INS_UQSUB, - ARM64_INS_UQXTN, - ARM64_INS_UQXTN2, - ARM64_INS_URECPE, - ARM64_INS_URHADD, - ARM64_INS_URSHL, - ARM64_INS_URSHR, - ARM64_INS_URSQRTE, - ARM64_INS_URSRA, - ARM64_INS_USHL, - ARM64_INS_USHLL, - ARM64_INS_USHLL2, - ARM64_INS_USHR, - ARM64_INS_USQADD, - ARM64_INS_USRA, - ARM64_INS_USUBL, - ARM64_INS_USUBL2, - ARM64_INS_USUBW, - ARM64_INS_USUBW2, - ARM64_INS_UUNPKHI, - ARM64_INS_UUNPKLO, - ARM64_INS_UXTB, - ARM64_INS_UXTH, - ARM64_INS_UXTL, - ARM64_INS_UXTL2, - ARM64_INS_UXTW, - ARM64_INS_UZP1, - ARM64_INS_UZP2, - ARM64_INS_WFE, - ARM64_INS_WFI, - ARM64_INS_WHILELE, - ARM64_INS_WHILELO, - ARM64_INS_WHILELS, - ARM64_INS_WHILELT, - ARM64_INS_WRFFR, - ARM64_INS_XAR, - ARM64_INS_XPACD, - ARM64_INS_XPACI, - ARM64_INS_XPACLRI, - ARM64_INS_XTN, - ARM64_INS_XTN2, - ARM64_INS_YIELD, - ARM64_INS_ZIP1, - ARM64_INS_ZIP2, - - // alias insn - ARM64_INS_SBFIZ, - ARM64_INS_UBFIZ, - ARM64_INS_SBFX, - ARM64_INS_UBFX, - ARM64_INS_BFI, - ARM64_INS_BFXIL, - ARM64_INS_IC, - ARM64_INS_DC, - ARM64_INS_AT, - ARM64_INS_TLBI, - - ARM64_INS_ENDING, // <-- mark the end of the list of insn -} arm64_insn; - -/// Group of ARM64 instructions -typedef enum arm64_insn_group { - ARM64_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - // Generic groups - // all jump instructions (conditional+direct+indirect jumps) - ARM64_GRP_JUMP, ///< = CS_GRP_JUMP - ARM64_GRP_CALL, - ARM64_GRP_RET, - ARM64_GRP_INT, - ARM64_GRP_PRIVILEGE = 6, ///< = CS_GRP_PRIVILEGE - ARM64_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE - ARM64_GRP_PAC, - - // Architecture-specific groups - ARM64_GRP_CRYPTO = 128, - ARM64_GRP_FPARMV8, - ARM64_GRP_NEON, - ARM64_GRP_CRC, - ARM64_GRP_AES, - ARM64_GRP_DOTPROD, - ARM64_GRP_FULLFP16, - ARM64_GRP_LSE, - ARM64_GRP_RCPC, - ARM64_GRP_RDM, - ARM64_GRP_SHA2, - ARM64_GRP_SHA3, - ARM64_GRP_SM4, - ARM64_GRP_SVE, - ARM64_GRP_V8_1A, - ARM64_GRP_V8_3A, - ARM64_GRP_V8_4A, - - ARM64_GRP_ENDING, // <-- mark the end of the list of groups -} arm64_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_M68K_H -#define CAPSTONE_M68K_H - -/* Capstone Disassembly Engine */ -/* By Daniel Collin , 2015-2016 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -#define M68K_OPERAND_COUNT 4 - -/// M68K registers and special registers -typedef enum m68k_reg { - M68K_REG_INVALID = 0, - - M68K_REG_D0, - M68K_REG_D1, - M68K_REG_D2, - M68K_REG_D3, - M68K_REG_D4, - M68K_REG_D5, - M68K_REG_D6, - M68K_REG_D7, - - M68K_REG_A0, - M68K_REG_A1, - M68K_REG_A2, - M68K_REG_A3, - M68K_REG_A4, - M68K_REG_A5, - M68K_REG_A6, - M68K_REG_A7, - - M68K_REG_FP0, - M68K_REG_FP1, - M68K_REG_FP2, - M68K_REG_FP3, - M68K_REG_FP4, - M68K_REG_FP5, - M68K_REG_FP6, - M68K_REG_FP7, - - M68K_REG_PC, - - M68K_REG_SR, - M68K_REG_CCR, - M68K_REG_SFC, - M68K_REG_DFC, - M68K_REG_USP, - M68K_REG_VBR, - M68K_REG_CACR, - M68K_REG_CAAR, - M68K_REG_MSP, - M68K_REG_ISP, - M68K_REG_TC, - M68K_REG_ITT0, - M68K_REG_ITT1, - M68K_REG_DTT0, - M68K_REG_DTT1, - M68K_REG_MMUSR, - M68K_REG_URP, - M68K_REG_SRP, - - M68K_REG_FPCR, - M68K_REG_FPSR, - M68K_REG_FPIAR, - - M68K_REG_ENDING, // <-- mark the end of the list of registers -} m68k_reg; - -/// M68K Addressing Modes -typedef enum m68k_address_mode { - M68K_AM_NONE = 0, ///< No address mode. - - M68K_AM_REG_DIRECT_DATA, ///< Register Direct - Data - M68K_AM_REG_DIRECT_ADDR, ///< Register Direct - Address - - M68K_AM_REGI_ADDR, ///< Register Indirect - Address - M68K_AM_REGI_ADDR_POST_INC, ///< Register Indirect - Address with Postincrement - M68K_AM_REGI_ADDR_PRE_DEC, ///< Register Indirect - Address with Predecrement - M68K_AM_REGI_ADDR_DISP, ///< Register Indirect - Address with Displacement - - M68K_AM_AREGI_INDEX_8_BIT_DISP, ///< Address Register Indirect With Index- 8-bit displacement - M68K_AM_AREGI_INDEX_BASE_DISP, ///< Address Register Indirect With Index- Base displacement - - M68K_AM_MEMI_POST_INDEX, ///< Memory indirect - Postindex - M68K_AM_MEMI_PRE_INDEX, ///< Memory indirect - Preindex - - M68K_AM_PCI_DISP, ///< Program Counter Indirect - with Displacement - - M68K_AM_PCI_INDEX_8_BIT_DISP, ///< Program Counter Indirect with Index - with 8-Bit Displacement - M68K_AM_PCI_INDEX_BASE_DISP, ///< Program Counter Indirect with Index - with Base Displacement - - M68K_AM_PC_MEMI_POST_INDEX, ///< Program Counter Memory Indirect - Postindexed - M68K_AM_PC_MEMI_PRE_INDEX, ///< Program Counter Memory Indirect - Preindexed - - M68K_AM_ABSOLUTE_DATA_SHORT, ///< Absolute Data Addressing - Short - M68K_AM_ABSOLUTE_DATA_LONG, ///< Absolute Data Addressing - Long - M68K_AM_IMMEDIATE, ///< Immediate value - - M68K_AM_BRANCH_DISPLACEMENT, ///< Address as displacement from (PC+2) used by branches -} m68k_address_mode; - -/// Operand type for instruction's operands -typedef enum m68k_op_type { - M68K_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - M68K_OP_REG, ///< = CS_OP_REG (Register operand). - M68K_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - M68K_OP_MEM, ///< = CS_OP_MEM (Memory operand). - M68K_OP_FP_SINGLE, ///< single precision Floating-Point operand - M68K_OP_FP_DOUBLE, ///< double precision Floating-Point operand - M68K_OP_REG_BITS, ///< Register bits move - M68K_OP_REG_PAIR, ///< Register pair in the same op (upper 4 bits for first reg, lower for second) - M68K_OP_BR_DISP, ///< Branch displacement -} m68k_op_type; - -/// Instruction's operand referring to memory -/// This is associated with M68K_OP_MEM operand type above -typedef struct m68k_op_mem { - m68k_reg base_reg; ///< base register (or M68K_REG_INVALID if irrelevant) - m68k_reg index_reg; ///< index register (or M68K_REG_INVALID if irrelevant) - m68k_reg in_base_reg; ///< indirect base register (or M68K_REG_INVALID if irrelevant) - uint32_t in_disp; ///< indirect displacement - uint32_t out_disp; ///< other displacement - int16_t disp; ///< displacement value - uint8_t scale; ///< scale for index register - uint8_t bitfield; ///< set to true if the two values below should be used - uint8_t width; ///< used for bf* instructions - uint8_t offset; ///< used for bf* instructions - uint8_t index_size; ///< 0 = w, 1 = l -} m68k_op_mem; - -/// Operand type for instruction's operands -typedef enum m68k_op_br_disp_size { - M68K_OP_BR_DISP_SIZE_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - M68K_OP_BR_DISP_SIZE_BYTE = 1, ///< signed 8-bit displacement - M68K_OP_BR_DISP_SIZE_WORD = 2, ///< signed 16-bit displacement - M68K_OP_BR_DISP_SIZE_LONG = 4, ///< signed 32-bit displacement -} m68k_op_br_disp_size; - -typedef struct m68k_op_br_disp { - int32_t disp; ///< displacement value - uint8_t disp_size; ///< Size from m68k_op_br_disp_size type above -} m68k_op_br_disp; - -/// Register pair in one operand. -typedef struct cs_m68k_op_reg_pair { - m68k_reg reg_0; - m68k_reg reg_1; -} cs_m68k_op_reg_pair; - -/// Instruction operand -typedef struct cs_m68k_op { - union { - uint64_t imm; ///< immediate value for IMM operand - double dimm; ///< double imm - float simm; ///< float imm - m68k_reg reg; ///< register value for REG operand - cs_m68k_op_reg_pair reg_pair; ///< register pair in one operand - }; - - m68k_op_mem mem; ///< data when operand is targeting memory - m68k_op_br_disp br_disp; ///< data when operand is a branch displacement - uint32_t register_bits; ///< register bits for movem etc. (always in d0-d7, a0-a7, fp0 - fp7 order) - m68k_op_type type; - m68k_address_mode address_mode; ///< M68K addressing mode for this op -} cs_m68k_op; - -/// Operation size of the CPU instructions -typedef enum m68k_cpu_size { - M68K_CPU_SIZE_NONE = 0, ///< unsized or unspecified - M68K_CPU_SIZE_BYTE = 1, ///< 1 byte in size - M68K_CPU_SIZE_WORD = 2, ///< 2 bytes in size - M68K_CPU_SIZE_LONG = 4, ///< 4 bytes in size -} m68k_cpu_size; - -/// Operation size of the FPU instructions (Notice that FPU instruction can also use CPU sizes if needed) -typedef enum m68k_fpu_size { - M68K_FPU_SIZE_NONE = 0, ///< unsized like fsave/frestore - M68K_FPU_SIZE_SINGLE = 4, ///< 4 byte in size (single float) - M68K_FPU_SIZE_DOUBLE = 8, ///< 8 byte in size (double) - M68K_FPU_SIZE_EXTENDED = 12, ///< 12 byte in size (extended real format) -} m68k_fpu_size; - -/// Type of size that is being used for the current instruction -typedef enum m68k_size_type { - M68K_SIZE_TYPE_INVALID = 0, - - M68K_SIZE_TYPE_CPU, - M68K_SIZE_TYPE_FPU, -} m68k_size_type; - -/// Operation size of the current instruction (NOT the actually size of instruction) -typedef struct m68k_op_size { - m68k_size_type type; - union { - m68k_cpu_size cpu_size; - m68k_fpu_size fpu_size; - }; -} m68k_op_size; - -/// The M68K instruction and it's operands -typedef struct cs_m68k { - // Number of operands of this instruction or 0 when instruction has no operand. - cs_m68k_op operands[M68K_OPERAND_COUNT]; ///< operands for this instruction. - m68k_op_size op_size; ///< size of data operand works on in bytes (.b, .w, .l, etc) - uint8_t op_count; ///< number of operands for the instruction -} cs_m68k; - -/// M68K instruction -typedef enum m68k_insn { - M68K_INS_INVALID = 0, - - M68K_INS_ABCD, - M68K_INS_ADD, - M68K_INS_ADDA, - M68K_INS_ADDI, - M68K_INS_ADDQ, - M68K_INS_ADDX, - M68K_INS_AND, - M68K_INS_ANDI, - M68K_INS_ASL, - M68K_INS_ASR, - M68K_INS_BHS, - M68K_INS_BLO, - M68K_INS_BHI, - M68K_INS_BLS, - M68K_INS_BCC, - M68K_INS_BCS, - M68K_INS_BNE, - M68K_INS_BEQ, - M68K_INS_BVC, - M68K_INS_BVS, - M68K_INS_BPL, - M68K_INS_BMI, - M68K_INS_BGE, - M68K_INS_BLT, - M68K_INS_BGT, - M68K_INS_BLE, - M68K_INS_BRA, - M68K_INS_BSR, - M68K_INS_BCHG, - M68K_INS_BCLR, - M68K_INS_BSET, - M68K_INS_BTST, - M68K_INS_BFCHG, - M68K_INS_BFCLR, - M68K_INS_BFEXTS, - M68K_INS_BFEXTU, - M68K_INS_BFFFO, - M68K_INS_BFINS, - M68K_INS_BFSET, - M68K_INS_BFTST, - M68K_INS_BKPT, - M68K_INS_CALLM, - M68K_INS_CAS, - M68K_INS_CAS2, - M68K_INS_CHK, - M68K_INS_CHK2, - M68K_INS_CLR, - M68K_INS_CMP, - M68K_INS_CMPA, - M68K_INS_CMPI, - M68K_INS_CMPM, - M68K_INS_CMP2, - M68K_INS_CINVL, - M68K_INS_CINVP, - M68K_INS_CINVA, - M68K_INS_CPUSHL, - M68K_INS_CPUSHP, - M68K_INS_CPUSHA, - M68K_INS_DBT, - M68K_INS_DBF, - M68K_INS_DBHI, - M68K_INS_DBLS, - M68K_INS_DBCC, - M68K_INS_DBCS, - M68K_INS_DBNE, - M68K_INS_DBEQ, - M68K_INS_DBVC, - M68K_INS_DBVS, - M68K_INS_DBPL, - M68K_INS_DBMI, - M68K_INS_DBGE, - M68K_INS_DBLT, - M68K_INS_DBGT, - M68K_INS_DBLE, - M68K_INS_DBRA, - M68K_INS_DIVS, - M68K_INS_DIVSL, - M68K_INS_DIVU, - M68K_INS_DIVUL, - M68K_INS_EOR, - M68K_INS_EORI, - M68K_INS_EXG, - M68K_INS_EXT, - M68K_INS_EXTB, - M68K_INS_FABS, - M68K_INS_FSABS, - M68K_INS_FDABS, - M68K_INS_FACOS, - M68K_INS_FADD, - M68K_INS_FSADD, - M68K_INS_FDADD, - M68K_INS_FASIN, - M68K_INS_FATAN, - M68K_INS_FATANH, - M68K_INS_FBF, - M68K_INS_FBEQ, - M68K_INS_FBOGT, - M68K_INS_FBOGE, - M68K_INS_FBOLT, - M68K_INS_FBOLE, - M68K_INS_FBOGL, - M68K_INS_FBOR, - M68K_INS_FBUN, - M68K_INS_FBUEQ, - M68K_INS_FBUGT, - M68K_INS_FBUGE, - M68K_INS_FBULT, - M68K_INS_FBULE, - M68K_INS_FBNE, - M68K_INS_FBT, - M68K_INS_FBSF, - M68K_INS_FBSEQ, - M68K_INS_FBGT, - M68K_INS_FBGE, - M68K_INS_FBLT, - M68K_INS_FBLE, - M68K_INS_FBGL, - M68K_INS_FBGLE, - M68K_INS_FBNGLE, - M68K_INS_FBNGL, - M68K_INS_FBNLE, - M68K_INS_FBNLT, - M68K_INS_FBNGE, - M68K_INS_FBNGT, - M68K_INS_FBSNE, - M68K_INS_FBST, - M68K_INS_FCMP, - M68K_INS_FCOS, - M68K_INS_FCOSH, - M68K_INS_FDBF, - M68K_INS_FDBEQ, - M68K_INS_FDBOGT, - M68K_INS_FDBOGE, - M68K_INS_FDBOLT, - M68K_INS_FDBOLE, - M68K_INS_FDBOGL, - M68K_INS_FDBOR, - M68K_INS_FDBUN, - M68K_INS_FDBUEQ, - M68K_INS_FDBUGT, - M68K_INS_FDBUGE, - M68K_INS_FDBULT, - M68K_INS_FDBULE, - M68K_INS_FDBNE, - M68K_INS_FDBT, - M68K_INS_FDBSF, - M68K_INS_FDBSEQ, - M68K_INS_FDBGT, - M68K_INS_FDBGE, - M68K_INS_FDBLT, - M68K_INS_FDBLE, - M68K_INS_FDBGL, - M68K_INS_FDBGLE, - M68K_INS_FDBNGLE, - M68K_INS_FDBNGL, - M68K_INS_FDBNLE, - M68K_INS_FDBNLT, - M68K_INS_FDBNGE, - M68K_INS_FDBNGT, - M68K_INS_FDBSNE, - M68K_INS_FDBST, - M68K_INS_FDIV, - M68K_INS_FSDIV, - M68K_INS_FDDIV, - M68K_INS_FETOX, - M68K_INS_FETOXM1, - M68K_INS_FGETEXP, - M68K_INS_FGETMAN, - M68K_INS_FINT, - M68K_INS_FINTRZ, - M68K_INS_FLOG10, - M68K_INS_FLOG2, - M68K_INS_FLOGN, - M68K_INS_FLOGNP1, - M68K_INS_FMOD, - M68K_INS_FMOVE, - M68K_INS_FSMOVE, - M68K_INS_FDMOVE, - M68K_INS_FMOVECR, - M68K_INS_FMOVEM, - M68K_INS_FMUL, - M68K_INS_FSMUL, - M68K_INS_FDMUL, - M68K_INS_FNEG, - M68K_INS_FSNEG, - M68K_INS_FDNEG, - M68K_INS_FNOP, - M68K_INS_FREM, - M68K_INS_FRESTORE, - M68K_INS_FSAVE, - M68K_INS_FSCALE, - M68K_INS_FSGLDIV, - M68K_INS_FSGLMUL, - M68K_INS_FSIN, - M68K_INS_FSINCOS, - M68K_INS_FSINH, - M68K_INS_FSQRT, - M68K_INS_FSSQRT, - M68K_INS_FDSQRT, - M68K_INS_FSF, - M68K_INS_FSBEQ, - M68K_INS_FSOGT, - M68K_INS_FSOGE, - M68K_INS_FSOLT, - M68K_INS_FSOLE, - M68K_INS_FSOGL, - M68K_INS_FSOR, - M68K_INS_FSUN, - M68K_INS_FSUEQ, - M68K_INS_FSUGT, - M68K_INS_FSUGE, - M68K_INS_FSULT, - M68K_INS_FSULE, - M68K_INS_FSNE, - M68K_INS_FST, - M68K_INS_FSSF, - M68K_INS_FSSEQ, - M68K_INS_FSGT, - M68K_INS_FSGE, - M68K_INS_FSLT, - M68K_INS_FSLE, - M68K_INS_FSGL, - M68K_INS_FSGLE, - M68K_INS_FSNGLE, - M68K_INS_FSNGL, - M68K_INS_FSNLE, - M68K_INS_FSNLT, - M68K_INS_FSNGE, - M68K_INS_FSNGT, - M68K_INS_FSSNE, - M68K_INS_FSST, - M68K_INS_FSUB, - M68K_INS_FSSUB, - M68K_INS_FDSUB, - M68K_INS_FTAN, - M68K_INS_FTANH, - M68K_INS_FTENTOX, - M68K_INS_FTRAPF, - M68K_INS_FTRAPEQ, - M68K_INS_FTRAPOGT, - M68K_INS_FTRAPOGE, - M68K_INS_FTRAPOLT, - M68K_INS_FTRAPOLE, - M68K_INS_FTRAPOGL, - M68K_INS_FTRAPOR, - M68K_INS_FTRAPUN, - M68K_INS_FTRAPUEQ, - M68K_INS_FTRAPUGT, - M68K_INS_FTRAPUGE, - M68K_INS_FTRAPULT, - M68K_INS_FTRAPULE, - M68K_INS_FTRAPNE, - M68K_INS_FTRAPT, - M68K_INS_FTRAPSF, - M68K_INS_FTRAPSEQ, - M68K_INS_FTRAPGT, - M68K_INS_FTRAPGE, - M68K_INS_FTRAPLT, - M68K_INS_FTRAPLE, - M68K_INS_FTRAPGL, - M68K_INS_FTRAPGLE, - M68K_INS_FTRAPNGLE, - M68K_INS_FTRAPNGL, - M68K_INS_FTRAPNLE, - M68K_INS_FTRAPNLT, - M68K_INS_FTRAPNGE, - M68K_INS_FTRAPNGT, - M68K_INS_FTRAPSNE, - M68K_INS_FTRAPST, - M68K_INS_FTST, - M68K_INS_FTWOTOX, - M68K_INS_HALT, - M68K_INS_ILLEGAL, - M68K_INS_JMP, - M68K_INS_JSR, - M68K_INS_LEA, - M68K_INS_LINK, - M68K_INS_LPSTOP, - M68K_INS_LSL, - M68K_INS_LSR, - M68K_INS_MOVE, - M68K_INS_MOVEA, - M68K_INS_MOVEC, - M68K_INS_MOVEM, - M68K_INS_MOVEP, - M68K_INS_MOVEQ, - M68K_INS_MOVES, - M68K_INS_MOVE16, - M68K_INS_MULS, - M68K_INS_MULU, - M68K_INS_NBCD, - M68K_INS_NEG, - M68K_INS_NEGX, - M68K_INS_NOP, - M68K_INS_NOT, - M68K_INS_OR, - M68K_INS_ORI, - M68K_INS_PACK, - M68K_INS_PEA, - M68K_INS_PFLUSH, - M68K_INS_PFLUSHA, - M68K_INS_PFLUSHAN, - M68K_INS_PFLUSHN, - M68K_INS_PLOADR, - M68K_INS_PLOADW, - M68K_INS_PLPAR, - M68K_INS_PLPAW, - M68K_INS_PMOVE, - M68K_INS_PMOVEFD, - M68K_INS_PTESTR, - M68K_INS_PTESTW, - M68K_INS_PULSE, - M68K_INS_REMS, - M68K_INS_REMU, - M68K_INS_RESET, - M68K_INS_ROL, - M68K_INS_ROR, - M68K_INS_ROXL, - M68K_INS_ROXR, - M68K_INS_RTD, - M68K_INS_RTE, - M68K_INS_RTM, - M68K_INS_RTR, - M68K_INS_RTS, - M68K_INS_SBCD, - M68K_INS_ST, - M68K_INS_SF, - M68K_INS_SHI, - M68K_INS_SLS, - M68K_INS_SCC, - M68K_INS_SHS, - M68K_INS_SCS, - M68K_INS_SLO, - M68K_INS_SNE, - M68K_INS_SEQ, - M68K_INS_SVC, - M68K_INS_SVS, - M68K_INS_SPL, - M68K_INS_SMI, - M68K_INS_SGE, - M68K_INS_SLT, - M68K_INS_SGT, - M68K_INS_SLE, - M68K_INS_STOP, - M68K_INS_SUB, - M68K_INS_SUBA, - M68K_INS_SUBI, - M68K_INS_SUBQ, - M68K_INS_SUBX, - M68K_INS_SWAP, - M68K_INS_TAS, - M68K_INS_TRAP, - M68K_INS_TRAPV, - M68K_INS_TRAPT, - M68K_INS_TRAPF, - M68K_INS_TRAPHI, - M68K_INS_TRAPLS, - M68K_INS_TRAPCC, - M68K_INS_TRAPHS, - M68K_INS_TRAPCS, - M68K_INS_TRAPLO, - M68K_INS_TRAPNE, - M68K_INS_TRAPEQ, - M68K_INS_TRAPVC, - M68K_INS_TRAPVS, - M68K_INS_TRAPPL, - M68K_INS_TRAPMI, - M68K_INS_TRAPGE, - M68K_INS_TRAPLT, - M68K_INS_TRAPGT, - M68K_INS_TRAPLE, - M68K_INS_TST, - M68K_INS_UNLK, - M68K_INS_UNPK, - M68K_INS_ENDING, // <-- mark the end of the list of instructions -} m68k_insn; - -/// Group of M68K instructions -typedef enum m68k_group_type { - M68K_GRP_INVALID = 0, ///< CS_GRUP_INVALID - M68K_GRP_JUMP, ///< = CS_GRP_JUMP - M68K_GRP_RET = 3, ///< = CS_GRP_RET - M68K_GRP_IRET = 5, ///< = CS_GRP_IRET - M68K_GRP_BRANCH_RELATIVE = 7, ///< = CS_GRP_BRANCH_RELATIVE - - M68K_GRP_ENDING,// <-- mark the end of the list of groups -} m68k_group_type; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_MIPS_H -#define CAPSTONE_MIPS_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2013-2015 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -// GCC MIPS toolchain has a default macro called "mips" which breaks -// compilation -#undef mips - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// Operand type for instruction's operands -typedef enum mips_op_type { - MIPS_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - MIPS_OP_REG, ///< = CS_OP_REG (Register operand). - MIPS_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - MIPS_OP_MEM, ///< = CS_OP_MEM (Memory operand). -} mips_op_type; - -/// MIPS registers -typedef enum mips_reg { - MIPS_REG_INVALID = 0, - // General purpose registers - MIPS_REG_PC, - - MIPS_REG_0, - MIPS_REG_1, - MIPS_REG_2, - MIPS_REG_3, - MIPS_REG_4, - MIPS_REG_5, - MIPS_REG_6, - MIPS_REG_7, - MIPS_REG_8, - MIPS_REG_9, - MIPS_REG_10, - MIPS_REG_11, - MIPS_REG_12, - MIPS_REG_13, - MIPS_REG_14, - MIPS_REG_15, - MIPS_REG_16, - MIPS_REG_17, - MIPS_REG_18, - MIPS_REG_19, - MIPS_REG_20, - MIPS_REG_21, - MIPS_REG_22, - MIPS_REG_23, - MIPS_REG_24, - MIPS_REG_25, - MIPS_REG_26, - MIPS_REG_27, - MIPS_REG_28, - MIPS_REG_29, - MIPS_REG_30, - MIPS_REG_31, - - // DSP registers - MIPS_REG_DSPCCOND, - MIPS_REG_DSPCARRY, - MIPS_REG_DSPEFI, - MIPS_REG_DSPOUTFLAG, - MIPS_REG_DSPOUTFLAG16_19, - MIPS_REG_DSPOUTFLAG20, - MIPS_REG_DSPOUTFLAG21, - MIPS_REG_DSPOUTFLAG22, - MIPS_REG_DSPOUTFLAG23, - MIPS_REG_DSPPOS, - MIPS_REG_DSPSCOUNT, - - // ACC registers - MIPS_REG_AC0, - MIPS_REG_AC1, - MIPS_REG_AC2, - MIPS_REG_AC3, - - // COP registers - MIPS_REG_CC0, - MIPS_REG_CC1, - MIPS_REG_CC2, - MIPS_REG_CC3, - MIPS_REG_CC4, - MIPS_REG_CC5, - MIPS_REG_CC6, - MIPS_REG_CC7, - - // FPU registers - MIPS_REG_F0, - MIPS_REG_F1, - MIPS_REG_F2, - MIPS_REG_F3, - MIPS_REG_F4, - MIPS_REG_F5, - MIPS_REG_F6, - MIPS_REG_F7, - MIPS_REG_F8, - MIPS_REG_F9, - MIPS_REG_F10, - MIPS_REG_F11, - MIPS_REG_F12, - MIPS_REG_F13, - MIPS_REG_F14, - MIPS_REG_F15, - MIPS_REG_F16, - MIPS_REG_F17, - MIPS_REG_F18, - MIPS_REG_F19, - MIPS_REG_F20, - MIPS_REG_F21, - MIPS_REG_F22, - MIPS_REG_F23, - MIPS_REG_F24, - MIPS_REG_F25, - MIPS_REG_F26, - MIPS_REG_F27, - MIPS_REG_F28, - MIPS_REG_F29, - MIPS_REG_F30, - MIPS_REG_F31, - - MIPS_REG_FCC0, - MIPS_REG_FCC1, - MIPS_REG_FCC2, - MIPS_REG_FCC3, - MIPS_REG_FCC4, - MIPS_REG_FCC5, - MIPS_REG_FCC6, - MIPS_REG_FCC7, - - // AFPR128 - MIPS_REG_W0, - MIPS_REG_W1, - MIPS_REG_W2, - MIPS_REG_W3, - MIPS_REG_W4, - MIPS_REG_W5, - MIPS_REG_W6, - MIPS_REG_W7, - MIPS_REG_W8, - MIPS_REG_W9, - MIPS_REG_W10, - MIPS_REG_W11, - MIPS_REG_W12, - MIPS_REG_W13, - MIPS_REG_W14, - MIPS_REG_W15, - MIPS_REG_W16, - MIPS_REG_W17, - MIPS_REG_W18, - MIPS_REG_W19, - MIPS_REG_W20, - MIPS_REG_W21, - MIPS_REG_W22, - MIPS_REG_W23, - MIPS_REG_W24, - MIPS_REG_W25, - MIPS_REG_W26, - MIPS_REG_W27, - MIPS_REG_W28, - MIPS_REG_W29, - MIPS_REG_W30, - MIPS_REG_W31, - - MIPS_REG_HI, - MIPS_REG_LO, - - MIPS_REG_P0, - MIPS_REG_P1, - MIPS_REG_P2, - - MIPS_REG_MPL0, - MIPS_REG_MPL1, - MIPS_REG_MPL2, - - MIPS_REG_ENDING, // <-- mark the end of the list or registers - - // alias registers - MIPS_REG_ZERO = MIPS_REG_0, - MIPS_REG_AT = MIPS_REG_1, - MIPS_REG_V0 = MIPS_REG_2, - MIPS_REG_V1 = MIPS_REG_3, - MIPS_REG_A0 = MIPS_REG_4, - MIPS_REG_A1 = MIPS_REG_5, - MIPS_REG_A2 = MIPS_REG_6, - MIPS_REG_A3 = MIPS_REG_7, - MIPS_REG_T0 = MIPS_REG_8, - MIPS_REG_T1 = MIPS_REG_9, - MIPS_REG_T2 = MIPS_REG_10, - MIPS_REG_T3 = MIPS_REG_11, - MIPS_REG_T4 = MIPS_REG_12, - MIPS_REG_T5 = MIPS_REG_13, - MIPS_REG_T6 = MIPS_REG_14, - MIPS_REG_T7 = MIPS_REG_15, - MIPS_REG_S0 = MIPS_REG_16, - MIPS_REG_S1 = MIPS_REG_17, - MIPS_REG_S2 = MIPS_REG_18, - MIPS_REG_S3 = MIPS_REG_19, - MIPS_REG_S4 = MIPS_REG_20, - MIPS_REG_S5 = MIPS_REG_21, - MIPS_REG_S6 = MIPS_REG_22, - MIPS_REG_S7 = MIPS_REG_23, - MIPS_REG_T8 = MIPS_REG_24, - MIPS_REG_T9 = MIPS_REG_25, - MIPS_REG_K0 = MIPS_REG_26, - MIPS_REG_K1 = MIPS_REG_27, - MIPS_REG_GP = MIPS_REG_28, - MIPS_REG_SP = MIPS_REG_29, - MIPS_REG_FP = MIPS_REG_30, MIPS_REG_S8 = MIPS_REG_30, - MIPS_REG_RA = MIPS_REG_31, - - MIPS_REG_HI0 = MIPS_REG_AC0, - MIPS_REG_HI1 = MIPS_REG_AC1, - MIPS_REG_HI2 = MIPS_REG_AC2, - MIPS_REG_HI3 = MIPS_REG_AC3, - - MIPS_REG_LO0 = MIPS_REG_HI0, - MIPS_REG_LO1 = MIPS_REG_HI1, - MIPS_REG_LO2 = MIPS_REG_HI2, - MIPS_REG_LO3 = MIPS_REG_HI3, -} mips_reg; - -/// Instruction's operand referring to memory -/// This is associated with MIPS_OP_MEM operand type above -typedef struct mips_op_mem { - mips_reg base; ///< base register - int64_t disp; ///< displacement/offset value -} mips_op_mem; - -/// Instruction operand -typedef struct cs_mips_op { - mips_op_type type; ///< operand type - union { - mips_reg reg; ///< register id for REG operand - int64_t imm; ///< immediate value for IMM operand - mips_op_mem mem; ///< base/index/scale/disp value for MEM operand - }; -} cs_mips_op; - -/// Instruction structure -typedef struct cs_mips { - /// Number of operands of this instruction, - /// or 0 when instruction has no operand. - uint8_t op_count; - cs_mips_op operands[10]; ///< operands for this instruction. -} cs_mips; - -/// MIPS instruction -typedef enum mips_insn { - MIPS_INS_INVALID = 0, - - MIPS_INS_ABSQ_S, - MIPS_INS_ADD, - MIPS_INS_ADDIUPC, - MIPS_INS_ADDIUR1SP, - MIPS_INS_ADDIUR2, - MIPS_INS_ADDIUS5, - MIPS_INS_ADDIUSP, - MIPS_INS_ADDQH, - MIPS_INS_ADDQH_R, - MIPS_INS_ADDQ, - MIPS_INS_ADDQ_S, - MIPS_INS_ADDSC, - MIPS_INS_ADDS_A, - MIPS_INS_ADDS_S, - MIPS_INS_ADDS_U, - MIPS_INS_ADDU16, - MIPS_INS_ADDUH, - MIPS_INS_ADDUH_R, - MIPS_INS_ADDU, - MIPS_INS_ADDU_S, - MIPS_INS_ADDVI, - MIPS_INS_ADDV, - MIPS_INS_ADDWC, - MIPS_INS_ADD_A, - MIPS_INS_ADDI, - MIPS_INS_ADDIU, - MIPS_INS_ALIGN, - MIPS_INS_ALUIPC, - MIPS_INS_AND, - MIPS_INS_AND16, - MIPS_INS_ANDI16, - MIPS_INS_ANDI, - MIPS_INS_APPEND, - MIPS_INS_ASUB_S, - MIPS_INS_ASUB_U, - MIPS_INS_AUI, - MIPS_INS_AUIPC, - MIPS_INS_AVER_S, - MIPS_INS_AVER_U, - MIPS_INS_AVE_S, - MIPS_INS_AVE_U, - MIPS_INS_B16, - MIPS_INS_BADDU, - MIPS_INS_BAL, - MIPS_INS_BALC, - MIPS_INS_BALIGN, - MIPS_INS_BBIT0, - MIPS_INS_BBIT032, - MIPS_INS_BBIT1, - MIPS_INS_BBIT132, - MIPS_INS_BC, - MIPS_INS_BC0F, - MIPS_INS_BC0FL, - MIPS_INS_BC0T, - MIPS_INS_BC0TL, - MIPS_INS_BC1EQZ, - MIPS_INS_BC1F, - MIPS_INS_BC1FL, - MIPS_INS_BC1NEZ, - MIPS_INS_BC1T, - MIPS_INS_BC1TL, - MIPS_INS_BC2EQZ, - MIPS_INS_BC2F, - MIPS_INS_BC2FL, - MIPS_INS_BC2NEZ, - MIPS_INS_BC2T, - MIPS_INS_BC2TL, - MIPS_INS_BC3F, - MIPS_INS_BC3FL, - MIPS_INS_BC3T, - MIPS_INS_BC3TL, - MIPS_INS_BCLRI, - MIPS_INS_BCLR, - MIPS_INS_BEQ, - MIPS_INS_BEQC, - MIPS_INS_BEQL, - MIPS_INS_BEQZ16, - MIPS_INS_BEQZALC, - MIPS_INS_BEQZC, - MIPS_INS_BGEC, - MIPS_INS_BGEUC, - MIPS_INS_BGEZ, - MIPS_INS_BGEZAL, - MIPS_INS_BGEZALC, - MIPS_INS_BGEZALL, - MIPS_INS_BGEZALS, - MIPS_INS_BGEZC, - MIPS_INS_BGEZL, - MIPS_INS_BGTZ, - MIPS_INS_BGTZALC, - MIPS_INS_BGTZC, - MIPS_INS_BGTZL, - MIPS_INS_BINSLI, - MIPS_INS_BINSL, - MIPS_INS_BINSRI, - MIPS_INS_BINSR, - MIPS_INS_BITREV, - MIPS_INS_BITSWAP, - MIPS_INS_BLEZ, - MIPS_INS_BLEZALC, - MIPS_INS_BLEZC, - MIPS_INS_BLEZL, - MIPS_INS_BLTC, - MIPS_INS_BLTUC, - MIPS_INS_BLTZ, - MIPS_INS_BLTZAL, - MIPS_INS_BLTZALC, - MIPS_INS_BLTZALL, - MIPS_INS_BLTZALS, - MIPS_INS_BLTZC, - MIPS_INS_BLTZL, - MIPS_INS_BMNZI, - MIPS_INS_BMNZ, - MIPS_INS_BMZI, - MIPS_INS_BMZ, - MIPS_INS_BNE, - MIPS_INS_BNEC, - MIPS_INS_BNEGI, - MIPS_INS_BNEG, - MIPS_INS_BNEL, - MIPS_INS_BNEZ16, - MIPS_INS_BNEZALC, - MIPS_INS_BNEZC, - MIPS_INS_BNVC, - MIPS_INS_BNZ, - MIPS_INS_BOVC, - MIPS_INS_BPOSGE32, - MIPS_INS_BREAK, - MIPS_INS_BREAK16, - MIPS_INS_BSELI, - MIPS_INS_BSEL, - MIPS_INS_BSETI, - MIPS_INS_BSET, - MIPS_INS_BZ, - MIPS_INS_BEQZ, - MIPS_INS_B, - MIPS_INS_BNEZ, - MIPS_INS_BTEQZ, - MIPS_INS_BTNEZ, - MIPS_INS_CACHE, - MIPS_INS_CEIL, - MIPS_INS_CEQI, - MIPS_INS_CEQ, - MIPS_INS_CFC1, - MIPS_INS_CFCMSA, - MIPS_INS_CINS, - MIPS_INS_CINS32, - MIPS_INS_CLASS, - MIPS_INS_CLEI_S, - MIPS_INS_CLEI_U, - MIPS_INS_CLE_S, - MIPS_INS_CLE_U, - MIPS_INS_CLO, - MIPS_INS_CLTI_S, - MIPS_INS_CLTI_U, - MIPS_INS_CLT_S, - MIPS_INS_CLT_U, - MIPS_INS_CLZ, - MIPS_INS_CMPGDU, - MIPS_INS_CMPGU, - MIPS_INS_CMPU, - MIPS_INS_CMP, - MIPS_INS_COPY_S, - MIPS_INS_COPY_U, - MIPS_INS_CTC1, - MIPS_INS_CTCMSA, - MIPS_INS_CVT, - MIPS_INS_C, - MIPS_INS_CMPI, - MIPS_INS_DADD, - MIPS_INS_DADDI, - MIPS_INS_DADDIU, - MIPS_INS_DADDU, - MIPS_INS_DAHI, - MIPS_INS_DALIGN, - MIPS_INS_DATI, - MIPS_INS_DAUI, - MIPS_INS_DBITSWAP, - MIPS_INS_DCLO, - MIPS_INS_DCLZ, - MIPS_INS_DDIV, - MIPS_INS_DDIVU, - MIPS_INS_DERET, - MIPS_INS_DEXT, - MIPS_INS_DEXTM, - MIPS_INS_DEXTU, - MIPS_INS_DI, - MIPS_INS_DINS, - MIPS_INS_DINSM, - MIPS_INS_DINSU, - MIPS_INS_DIV, - MIPS_INS_DIVU, - MIPS_INS_DIV_S, - MIPS_INS_DIV_U, - MIPS_INS_DLSA, - MIPS_INS_DMFC0, - MIPS_INS_DMFC1, - MIPS_INS_DMFC2, - MIPS_INS_DMOD, - MIPS_INS_DMODU, - MIPS_INS_DMTC0, - MIPS_INS_DMTC1, - MIPS_INS_DMTC2, - MIPS_INS_DMUH, - MIPS_INS_DMUHU, - MIPS_INS_DMUL, - MIPS_INS_DMULT, - MIPS_INS_DMULTU, - MIPS_INS_DMULU, - MIPS_INS_DOTP_S, - MIPS_INS_DOTP_U, - MIPS_INS_DPADD_S, - MIPS_INS_DPADD_U, - MIPS_INS_DPAQX_SA, - MIPS_INS_DPAQX_S, - MIPS_INS_DPAQ_SA, - MIPS_INS_DPAQ_S, - MIPS_INS_DPAU, - MIPS_INS_DPAX, - MIPS_INS_DPA, - MIPS_INS_DPOP, - MIPS_INS_DPSQX_SA, - MIPS_INS_DPSQX_S, - MIPS_INS_DPSQ_SA, - MIPS_INS_DPSQ_S, - MIPS_INS_DPSUB_S, - MIPS_INS_DPSUB_U, - MIPS_INS_DPSU, - MIPS_INS_DPSX, - MIPS_INS_DPS, - MIPS_INS_DROTR, - MIPS_INS_DROTR32, - MIPS_INS_DROTRV, - MIPS_INS_DSBH, - MIPS_INS_DSHD, - MIPS_INS_DSLL, - MIPS_INS_DSLL32, - MIPS_INS_DSLLV, - MIPS_INS_DSRA, - MIPS_INS_DSRA32, - MIPS_INS_DSRAV, - MIPS_INS_DSRL, - MIPS_INS_DSRL32, - MIPS_INS_DSRLV, - MIPS_INS_DSUB, - MIPS_INS_DSUBU, - MIPS_INS_EHB, - MIPS_INS_EI, - MIPS_INS_ERET, - MIPS_INS_EXT, - MIPS_INS_EXTP, - MIPS_INS_EXTPDP, - MIPS_INS_EXTPDPV, - MIPS_INS_EXTPV, - MIPS_INS_EXTRV_RS, - MIPS_INS_EXTRV_R, - MIPS_INS_EXTRV_S, - MIPS_INS_EXTRV, - MIPS_INS_EXTR_RS, - MIPS_INS_EXTR_R, - MIPS_INS_EXTR_S, - MIPS_INS_EXTR, - MIPS_INS_EXTS, - MIPS_INS_EXTS32, - MIPS_INS_ABS, - MIPS_INS_FADD, - MIPS_INS_FCAF, - MIPS_INS_FCEQ, - MIPS_INS_FCLASS, - MIPS_INS_FCLE, - MIPS_INS_FCLT, - MIPS_INS_FCNE, - MIPS_INS_FCOR, - MIPS_INS_FCUEQ, - MIPS_INS_FCULE, - MIPS_INS_FCULT, - MIPS_INS_FCUNE, - MIPS_INS_FCUN, - MIPS_INS_FDIV, - MIPS_INS_FEXDO, - MIPS_INS_FEXP2, - MIPS_INS_FEXUPL, - MIPS_INS_FEXUPR, - MIPS_INS_FFINT_S, - MIPS_INS_FFINT_U, - MIPS_INS_FFQL, - MIPS_INS_FFQR, - MIPS_INS_FILL, - MIPS_INS_FLOG2, - MIPS_INS_FLOOR, - MIPS_INS_FMADD, - MIPS_INS_FMAX_A, - MIPS_INS_FMAX, - MIPS_INS_FMIN_A, - MIPS_INS_FMIN, - MIPS_INS_MOV, - MIPS_INS_FMSUB, - MIPS_INS_FMUL, - MIPS_INS_MUL, - MIPS_INS_NEG, - MIPS_INS_FRCP, - MIPS_INS_FRINT, - MIPS_INS_FRSQRT, - MIPS_INS_FSAF, - MIPS_INS_FSEQ, - MIPS_INS_FSLE, - MIPS_INS_FSLT, - MIPS_INS_FSNE, - MIPS_INS_FSOR, - MIPS_INS_FSQRT, - MIPS_INS_SQRT, - MIPS_INS_FSUB, - MIPS_INS_SUB, - MIPS_INS_FSUEQ, - MIPS_INS_FSULE, - MIPS_INS_FSULT, - MIPS_INS_FSUNE, - MIPS_INS_FSUN, - MIPS_INS_FTINT_S, - MIPS_INS_FTINT_U, - MIPS_INS_FTQ, - MIPS_INS_FTRUNC_S, - MIPS_INS_FTRUNC_U, - MIPS_INS_HADD_S, - MIPS_INS_HADD_U, - MIPS_INS_HSUB_S, - MIPS_INS_HSUB_U, - MIPS_INS_ILVEV, - MIPS_INS_ILVL, - MIPS_INS_ILVOD, - MIPS_INS_ILVR, - MIPS_INS_INS, - MIPS_INS_INSERT, - MIPS_INS_INSV, - MIPS_INS_INSVE, - MIPS_INS_J, - MIPS_INS_JAL, - MIPS_INS_JALR, - MIPS_INS_JALRS16, - MIPS_INS_JALRS, - MIPS_INS_JALS, - MIPS_INS_JALX, - MIPS_INS_JIALC, - MIPS_INS_JIC, - MIPS_INS_JR, - MIPS_INS_JR16, - MIPS_INS_JRADDIUSP, - MIPS_INS_JRC, - MIPS_INS_JALRC, - MIPS_INS_LB, - MIPS_INS_LBU16, - MIPS_INS_LBUX, - MIPS_INS_LBU, - MIPS_INS_LD, - MIPS_INS_LDC1, - MIPS_INS_LDC2, - MIPS_INS_LDC3, - MIPS_INS_LDI, - MIPS_INS_LDL, - MIPS_INS_LDPC, - MIPS_INS_LDR, - MIPS_INS_LDXC1, - MIPS_INS_LH, - MIPS_INS_LHU16, - MIPS_INS_LHX, - MIPS_INS_LHU, - MIPS_INS_LI16, - MIPS_INS_LL, - MIPS_INS_LLD, - MIPS_INS_LSA, - MIPS_INS_LUXC1, - MIPS_INS_LUI, - MIPS_INS_LW, - MIPS_INS_LW16, - MIPS_INS_LWC1, - MIPS_INS_LWC2, - MIPS_INS_LWC3, - MIPS_INS_LWL, - MIPS_INS_LWM16, - MIPS_INS_LWM32, - MIPS_INS_LWPC, - MIPS_INS_LWP, - MIPS_INS_LWR, - MIPS_INS_LWUPC, - MIPS_INS_LWU, - MIPS_INS_LWX, - MIPS_INS_LWXC1, - MIPS_INS_LWXS, - MIPS_INS_LI, - MIPS_INS_MADD, - MIPS_INS_MADDF, - MIPS_INS_MADDR_Q, - MIPS_INS_MADDU, - MIPS_INS_MADDV, - MIPS_INS_MADD_Q, - MIPS_INS_MAQ_SA, - MIPS_INS_MAQ_S, - MIPS_INS_MAXA, - MIPS_INS_MAXI_S, - MIPS_INS_MAXI_U, - MIPS_INS_MAX_A, - MIPS_INS_MAX, - MIPS_INS_MAX_S, - MIPS_INS_MAX_U, - MIPS_INS_MFC0, - MIPS_INS_MFC1, - MIPS_INS_MFC2, - MIPS_INS_MFHC1, - MIPS_INS_MFHI, - MIPS_INS_MFLO, - MIPS_INS_MINA, - MIPS_INS_MINI_S, - MIPS_INS_MINI_U, - MIPS_INS_MIN_A, - MIPS_INS_MIN, - MIPS_INS_MIN_S, - MIPS_INS_MIN_U, - MIPS_INS_MOD, - MIPS_INS_MODSUB, - MIPS_INS_MODU, - MIPS_INS_MOD_S, - MIPS_INS_MOD_U, - MIPS_INS_MOVE, - MIPS_INS_MOVEP, - MIPS_INS_MOVF, - MIPS_INS_MOVN, - MIPS_INS_MOVT, - MIPS_INS_MOVZ, - MIPS_INS_MSUB, - MIPS_INS_MSUBF, - MIPS_INS_MSUBR_Q, - MIPS_INS_MSUBU, - MIPS_INS_MSUBV, - MIPS_INS_MSUB_Q, - MIPS_INS_MTC0, - MIPS_INS_MTC1, - MIPS_INS_MTC2, - MIPS_INS_MTHC1, - MIPS_INS_MTHI, - MIPS_INS_MTHLIP, - MIPS_INS_MTLO, - MIPS_INS_MTM0, - MIPS_INS_MTM1, - MIPS_INS_MTM2, - MIPS_INS_MTP0, - MIPS_INS_MTP1, - MIPS_INS_MTP2, - MIPS_INS_MUH, - MIPS_INS_MUHU, - MIPS_INS_MULEQ_S, - MIPS_INS_MULEU_S, - MIPS_INS_MULQ_RS, - MIPS_INS_MULQ_S, - MIPS_INS_MULR_Q, - MIPS_INS_MULSAQ_S, - MIPS_INS_MULSA, - MIPS_INS_MULT, - MIPS_INS_MULTU, - MIPS_INS_MULU, - MIPS_INS_MULV, - MIPS_INS_MUL_Q, - MIPS_INS_MUL_S, - MIPS_INS_NLOC, - MIPS_INS_NLZC, - MIPS_INS_NMADD, - MIPS_INS_NMSUB, - MIPS_INS_NOR, - MIPS_INS_NORI, - MIPS_INS_NOT16, - MIPS_INS_NOT, - MIPS_INS_OR, - MIPS_INS_OR16, - MIPS_INS_ORI, - MIPS_INS_PACKRL, - MIPS_INS_PAUSE, - MIPS_INS_PCKEV, - MIPS_INS_PCKOD, - MIPS_INS_PCNT, - MIPS_INS_PICK, - MIPS_INS_POP, - MIPS_INS_PRECEQU, - MIPS_INS_PRECEQ, - MIPS_INS_PRECEU, - MIPS_INS_PRECRQU_S, - MIPS_INS_PRECRQ, - MIPS_INS_PRECRQ_RS, - MIPS_INS_PRECR, - MIPS_INS_PRECR_SRA, - MIPS_INS_PRECR_SRA_R, - MIPS_INS_PREF, - MIPS_INS_PREPEND, - MIPS_INS_RADDU, - MIPS_INS_RDDSP, - MIPS_INS_RDHWR, - MIPS_INS_REPLV, - MIPS_INS_REPL, - MIPS_INS_RINT, - MIPS_INS_ROTR, - MIPS_INS_ROTRV, - MIPS_INS_ROUND, - MIPS_INS_SAT_S, - MIPS_INS_SAT_U, - MIPS_INS_SB, - MIPS_INS_SB16, - MIPS_INS_SC, - MIPS_INS_SCD, - MIPS_INS_SD, - MIPS_INS_SDBBP, - MIPS_INS_SDBBP16, - MIPS_INS_SDC1, - MIPS_INS_SDC2, - MIPS_INS_SDC3, - MIPS_INS_SDL, - MIPS_INS_SDR, - MIPS_INS_SDXC1, - MIPS_INS_SEB, - MIPS_INS_SEH, - MIPS_INS_SELEQZ, - MIPS_INS_SELNEZ, - MIPS_INS_SEL, - MIPS_INS_SEQ, - MIPS_INS_SEQI, - MIPS_INS_SH, - MIPS_INS_SH16, - MIPS_INS_SHF, - MIPS_INS_SHILO, - MIPS_INS_SHILOV, - MIPS_INS_SHLLV, - MIPS_INS_SHLLV_S, - MIPS_INS_SHLL, - MIPS_INS_SHLL_S, - MIPS_INS_SHRAV, - MIPS_INS_SHRAV_R, - MIPS_INS_SHRA, - MIPS_INS_SHRA_R, - MIPS_INS_SHRLV, - MIPS_INS_SHRL, - MIPS_INS_SLDI, - MIPS_INS_SLD, - MIPS_INS_SLL, - MIPS_INS_SLL16, - MIPS_INS_SLLI, - MIPS_INS_SLLV, - MIPS_INS_SLT, - MIPS_INS_SLTI, - MIPS_INS_SLTIU, - MIPS_INS_SLTU, - MIPS_INS_SNE, - MIPS_INS_SNEI, - MIPS_INS_SPLATI, - MIPS_INS_SPLAT, - MIPS_INS_SRA, - MIPS_INS_SRAI, - MIPS_INS_SRARI, - MIPS_INS_SRAR, - MIPS_INS_SRAV, - MIPS_INS_SRL, - MIPS_INS_SRL16, - MIPS_INS_SRLI, - MIPS_INS_SRLRI, - MIPS_INS_SRLR, - MIPS_INS_SRLV, - MIPS_INS_SSNOP, - MIPS_INS_ST, - MIPS_INS_SUBQH, - MIPS_INS_SUBQH_R, - MIPS_INS_SUBQ, - MIPS_INS_SUBQ_S, - MIPS_INS_SUBSUS_U, - MIPS_INS_SUBSUU_S, - MIPS_INS_SUBS_S, - MIPS_INS_SUBS_U, - MIPS_INS_SUBU16, - MIPS_INS_SUBUH, - MIPS_INS_SUBUH_R, - MIPS_INS_SUBU, - MIPS_INS_SUBU_S, - MIPS_INS_SUBVI, - MIPS_INS_SUBV, - MIPS_INS_SUXC1, - MIPS_INS_SW, - MIPS_INS_SW16, - MIPS_INS_SWC1, - MIPS_INS_SWC2, - MIPS_INS_SWC3, - MIPS_INS_SWL, - MIPS_INS_SWM16, - MIPS_INS_SWM32, - MIPS_INS_SWP, - MIPS_INS_SWR, - MIPS_INS_SWXC1, - MIPS_INS_SYNC, - MIPS_INS_SYNCI, - MIPS_INS_SYSCALL, - MIPS_INS_TEQ, - MIPS_INS_TEQI, - MIPS_INS_TGE, - MIPS_INS_TGEI, - MIPS_INS_TGEIU, - MIPS_INS_TGEU, - MIPS_INS_TLBP, - MIPS_INS_TLBR, - MIPS_INS_TLBWI, - MIPS_INS_TLBWR, - MIPS_INS_TLT, - MIPS_INS_TLTI, - MIPS_INS_TLTIU, - MIPS_INS_TLTU, - MIPS_INS_TNE, - MIPS_INS_TNEI, - MIPS_INS_TRUNC, - MIPS_INS_V3MULU, - MIPS_INS_VMM0, - MIPS_INS_VMULU, - MIPS_INS_VSHF, - MIPS_INS_WAIT, - MIPS_INS_WRDSP, - MIPS_INS_WSBH, - MIPS_INS_XOR, - MIPS_INS_XOR16, - MIPS_INS_XORI, - - //> some alias instructions - MIPS_INS_NOP, - MIPS_INS_NEGU, - - //> special instructions - MIPS_INS_JALR_HB, // jump and link with Hazard Barrier - MIPS_INS_JR_HB, // jump register with Hazard Barrier - - MIPS_INS_ENDING, -} mips_insn; - -/// Group of MIPS instructions -typedef enum mips_insn_group { - MIPS_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - // Generic groups - // all jump instructions (conditional+direct+indirect jumps) - MIPS_GRP_JUMP, ///< = CS_GRP_JUMP - // all call instructions - MIPS_GRP_CALL, ///< = CS_GRP_CALL - // all return instructions - MIPS_GRP_RET, ///< = CS_GRP_RET - // all interrupt instructions (int+syscall) - MIPS_GRP_INT, ///< = CS_GRP_INT - // all interrupt return instructions - MIPS_GRP_IRET, ///< = CS_GRP_IRET - // all privileged instructions - MIPS_GRP_PRIVILEGE, ///< = CS_GRP_PRIVILEGE - // all relative branching instructions - MIPS_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE - - // Architecture-specific groups - MIPS_GRP_BITCOUNT = 128, - MIPS_GRP_DSP, - MIPS_GRP_DSPR2, - MIPS_GRP_FPIDX, - MIPS_GRP_MSA, - MIPS_GRP_MIPS32R2, - MIPS_GRP_MIPS64, - MIPS_GRP_MIPS64R2, - MIPS_GRP_SEINREG, - MIPS_GRP_STDENC, - MIPS_GRP_SWAP, - MIPS_GRP_MICROMIPS, - MIPS_GRP_MIPS16MODE, - MIPS_GRP_FP64BIT, - MIPS_GRP_NONANSFPMATH, - MIPS_GRP_NOTFP64BIT, - MIPS_GRP_NOTINMICROMIPS, - MIPS_GRP_NOTNACL, - MIPS_GRP_NOTMIPS32R6, - MIPS_GRP_NOTMIPS64R6, - MIPS_GRP_CNMIPS, - MIPS_GRP_MIPS32, - MIPS_GRP_MIPS32R6, - MIPS_GRP_MIPS64R6, - MIPS_GRP_MIPS2, - MIPS_GRP_MIPS3, - MIPS_GRP_MIPS3_32, - MIPS_GRP_MIPS3_32R2, - MIPS_GRP_MIPS4_32, - MIPS_GRP_MIPS4_32R2, - MIPS_GRP_MIPS5_32R2, - MIPS_GRP_GP32BIT, - MIPS_GRP_GP64BIT, - - MIPS_GRP_ENDING, -} mips_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_PPC_H -#define CAPSTONE_PPC_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2013-2015 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// PPC branch codes for some branch instructions -typedef enum ppc_bc { - PPC_BC_INVALID = 0, - PPC_BC_LT = (0 << 5) | 12, - PPC_BC_LE = (1 << 5) | 4, - PPC_BC_EQ = (2 << 5) | 12, - PPC_BC_GE = (0 << 5) | 4, - PPC_BC_GT = (1 << 5) | 12, - PPC_BC_NE = (2 << 5) | 4, - PPC_BC_UN = (3 << 5) | 12, - PPC_BC_NU = (3 << 5) | 4, - - // extra conditions - PPC_BC_SO = (4 << 5) | 12, ///< summary overflow - PPC_BC_NS = (4 << 5) | 4, ///< not summary overflow -} ppc_bc; - -/// PPC branch hint for some branch instructions -typedef enum ppc_bh { - PPC_BH_INVALID = 0, ///< no hint - PPC_BH_PLUS, ///< PLUS hint - PPC_BH_MINUS, ///< MINUS hint -} ppc_bh; - -/// Operand type for instruction's operands -typedef enum ppc_op_type { - PPC_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - PPC_OP_REG, ///< = CS_OP_REG (Register operand). - PPC_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - PPC_OP_MEM, ///< = CS_OP_MEM (Memory operand). - PPC_OP_CRX = 64, ///< Condition Register field -} ppc_op_type; - -/// PPC registers -typedef enum ppc_reg { - PPC_REG_INVALID = 0, - - PPC_REG_CARRY = 2, - PPC_REG_CTR = 3, - PPC_REG_LR = 5, - PPC_REG_RM = 6, - PPC_REG_VRSAVE = 8, - PPC_REG_XER = 9, - PPC_REG_ZERO = 10, - PPC_REG_CR0 = 12, - PPC_REG_CR1 = 13, - PPC_REG_CR2 = 14, - PPC_REG_CR3 = 15, - PPC_REG_CR4 = 16, - PPC_REG_CR5 = 17, - PPC_REG_CR6 = 18, - PPC_REG_CR7 = 19, - PPC_REG_CTR8 = 20, - PPC_REG_F0 = 21, - PPC_REG_F1 = 22, - PPC_REG_F2 = 23, - PPC_REG_F3 = 24, - PPC_REG_F4 = 25, - PPC_REG_F5 = 26, - PPC_REG_F6 = 27, - PPC_REG_F7 = 28, - PPC_REG_F8 = 29, - PPC_REG_F9 = 30, - PPC_REG_F10 = 31, - PPC_REG_F11 = 32, - PPC_REG_F12 = 33, - PPC_REG_F13 = 34, - PPC_REG_F14 = 35, - PPC_REG_F15 = 36, - PPC_REG_F16 = 37, - PPC_REG_F17 = 38, - PPC_REG_F18 = 39, - PPC_REG_F19 = 40, - PPC_REG_F20 = 41, - PPC_REG_F21 = 42, - PPC_REG_F22 = 43, - PPC_REG_F23 = 44, - PPC_REG_F24 = 45, - PPC_REG_F25 = 46, - PPC_REG_F26 = 47, - PPC_REG_F27 = 48, - PPC_REG_F28 = 49, - PPC_REG_F29 = 50, - PPC_REG_F30 = 51, - PPC_REG_F31 = 52, - PPC_REG_LR8 = 54, - PPC_REG_Q0 = 55, - PPC_REG_Q1 = 56, - PPC_REG_Q2 = 57, - PPC_REG_Q3 = 58, - PPC_REG_Q4 = 59, - PPC_REG_Q5 = 60, - PPC_REG_Q6 = 61, - PPC_REG_Q7 = 62, - PPC_REG_Q8 = 63, - PPC_REG_Q9 = 64, - PPC_REG_Q10 = 65, - PPC_REG_Q11 = 66, - PPC_REG_Q12 = 67, - PPC_REG_Q13 = 68, - PPC_REG_Q14 = 69, - PPC_REG_Q15 = 70, - PPC_REG_Q16 = 71, - PPC_REG_Q17 = 72, - PPC_REG_Q18 = 73, - PPC_REG_Q19 = 74, - PPC_REG_Q20 = 75, - PPC_REG_Q21 = 76, - PPC_REG_Q22 = 77, - PPC_REG_Q23 = 78, - PPC_REG_Q24 = 79, - PPC_REG_Q25 = 80, - PPC_REG_Q26 = 81, - PPC_REG_Q27 = 82, - PPC_REG_Q28 = 83, - PPC_REG_Q29 = 84, - PPC_REG_Q30 = 85, - PPC_REG_Q31 = 86, - PPC_REG_R0 = 87, - PPC_REG_R1 = 88, - PPC_REG_R2 = 89, - PPC_REG_R3 = 90, - PPC_REG_R4 = 91, - PPC_REG_R5 = 92, - PPC_REG_R6 = 93, - PPC_REG_R7 = 94, - PPC_REG_R8 = 95, - PPC_REG_R9 = 96, - PPC_REG_R10 = 97, - PPC_REG_R11 = 98, - PPC_REG_R12 = 99, - PPC_REG_R13 = 100, - PPC_REG_R14 = 101, - PPC_REG_R15 = 102, - PPC_REG_R16 = 103, - PPC_REG_R17 = 104, - PPC_REG_R18 = 105, - PPC_REG_R19 = 106, - PPC_REG_R20 = 107, - PPC_REG_R21 = 108, - PPC_REG_R22 = 109, - PPC_REG_R23 = 110, - PPC_REG_R24 = 111, - PPC_REG_R25 = 112, - PPC_REG_R26 = 113, - PPC_REG_R27 = 114, - PPC_REG_R28 = 115, - PPC_REG_R29 = 116, - PPC_REG_R30 = 117, - PPC_REG_R31 = 118, - PPC_REG_V0 = 151, - PPC_REG_V1 = 152, - PPC_REG_V2 = 153, - PPC_REG_V3 = 154, - PPC_REG_V4 = 155, - PPC_REG_V5 = 156, - PPC_REG_V6 = 157, - PPC_REG_V7 = 158, - PPC_REG_V8 = 159, - PPC_REG_V9 = 160, - PPC_REG_V10 = 161, - PPC_REG_V11 = 162, - PPC_REG_V12 = 163, - PPC_REG_V13 = 164, - PPC_REG_V14 = 165, - PPC_REG_V15 = 166, - PPC_REG_V16 = 167, - PPC_REG_V17 = 168, - PPC_REG_V18 = 169, - PPC_REG_V19 = 170, - PPC_REG_V20 = 171, - PPC_REG_V21 = 172, - PPC_REG_V22 = 173, - PPC_REG_V23 = 174, - PPC_REG_V24 = 175, - PPC_REG_V25 = 176, - PPC_REG_V26 = 177, - PPC_REG_V27 = 178, - PPC_REG_V28 = 179, - PPC_REG_V29 = 180, - PPC_REG_V30 = 181, - PPC_REG_V31 = 182, - PPC_REG_VS0 = 215, - PPC_REG_VS1 = 216, - PPC_REG_VS2 = 217, - PPC_REG_VS3 = 218, - PPC_REG_VS4 = 219, - PPC_REG_VS5 = 220, - PPC_REG_VS6 = 221, - PPC_REG_VS7 = 222, - PPC_REG_VS8 = 223, - PPC_REG_VS9 = 224, - PPC_REG_VS10 = 225, - PPC_REG_VS11 = 226, - PPC_REG_VS12 = 227, - PPC_REG_VS13 = 228, - PPC_REG_VS14 = 229, - PPC_REG_VS15 = 230, - PPC_REG_VS16 = 231, - PPC_REG_VS17 = 232, - PPC_REG_VS18 = 233, - PPC_REG_VS19 = 234, - PPC_REG_VS20 = 235, - PPC_REG_VS21 = 236, - PPC_REG_VS22 = 237, - PPC_REG_VS23 = 238, - PPC_REG_VS24 = 239, - PPC_REG_VS25 = 240, - PPC_REG_VS26 = 241, - PPC_REG_VS27 = 242, - PPC_REG_VS28 = 243, - PPC_REG_VS29 = 244, - PPC_REG_VS30 = 245, - PPC_REG_VS31 = 246, - PPC_REG_VS32 = 247, - PPC_REG_VS33 = 248, - PPC_REG_VS34 = 249, - PPC_REG_VS35 = 250, - PPC_REG_VS36 = 251, - PPC_REG_VS37 = 252, - PPC_REG_VS38 = 253, - PPC_REG_VS39 = 254, - PPC_REG_VS40 = 255, - PPC_REG_VS41 = 256, - PPC_REG_VS42 = 257, - PPC_REG_VS43 = 258, - PPC_REG_VS44 = 259, - PPC_REG_VS45 = 260, - PPC_REG_VS46 = 261, - PPC_REG_VS47 = 262, - PPC_REG_VS48 = 263, - PPC_REG_VS49 = 264, - PPC_REG_VS50 = 265, - PPC_REG_VS51 = 266, - PPC_REG_VS52 = 267, - PPC_REG_VS53 = 268, - PPC_REG_VS54 = 269, - PPC_REG_VS55 = 270, - PPC_REG_VS56 = 271, - PPC_REG_VS57 = 272, - PPC_REG_VS58 = 273, - PPC_REG_VS59 = 274, - PPC_REG_VS60 = 275, - PPC_REG_VS61 = 276, - PPC_REG_VS62 = 277, - PPC_REG_VS63 = 278, - - PPC_REG_CR0EQ = 312, - PPC_REG_CR1EQ = 313, - PPC_REG_CR2EQ = 314, - PPC_REG_CR3EQ = 315, - PPC_REG_CR4EQ = 316, - PPC_REG_CR5EQ = 317, - PPC_REG_CR6EQ = 318, - PPC_REG_CR7EQ = 319, - PPC_REG_CR0GT = 320, - PPC_REG_CR1GT = 321, - PPC_REG_CR2GT = 322, - PPC_REG_CR3GT = 323, - PPC_REG_CR4GT = 324, - PPC_REG_CR5GT = 325, - PPC_REG_CR6GT = 326, - PPC_REG_CR7GT = 327, - PPC_REG_CR0LT = 328, - PPC_REG_CR1LT = 329, - PPC_REG_CR2LT = 330, - PPC_REG_CR3LT = 331, - PPC_REG_CR4LT = 332, - PPC_REG_CR5LT = 333, - PPC_REG_CR6LT = 334, - PPC_REG_CR7LT = 335, - PPC_REG_CR0UN = 336, - PPC_REG_CR1UN = 337, - PPC_REG_CR2UN = 338, - PPC_REG_CR3UN = 339, - PPC_REG_CR4UN = 340, - PPC_REG_CR5UN = 341, - PPC_REG_CR6UN = 342, - PPC_REG_CR7UN = 343, - - PPC_REG_ENDING, // <-- mark the end of the list of registers -} ppc_reg; - -/// Instruction's operand referring to memory -/// This is associated with PPC_OP_MEM operand type above -typedef struct ppc_op_mem { - ppc_reg base; ///< base register - int32_t disp; ///< displacement/offset value -} ppc_op_mem; - -typedef struct ppc_op_crx { - unsigned int scale; - ppc_reg reg; - ppc_bc cond; -} ppc_op_crx; - -/// Instruction operand -typedef struct cs_ppc_op { - ppc_op_type type; ///< operand type - union { - ppc_reg reg; ///< register value for REG operand - int64_t imm; ///< immediate value for IMM operand - ppc_op_mem mem; ///< base/disp value for MEM operand - ppc_op_crx crx; ///< operand with condition register - }; -} cs_ppc_op; - -/// Instruction structure -typedef struct cs_ppc { - /// branch code for branch instructions - ppc_bc bc; - - /// branch hint for branch instructions - ppc_bh bh; - - /// if update_cr0 = True, then this 'dot' insn updates CR0 - bool update_cr0; - - /// Number of operands of this instruction, - /// or 0 when instruction has no operand. - uint8_t op_count; - cs_ppc_op operands[8]; ///< operands for this instruction. -} cs_ppc; - -/// PPC instruction -typedef enum ppc_insn { - PPC_INS_INVALID = 0, - - PPC_INS_ADD, - PPC_INS_ADDC, - PPC_INS_ADDE, - PPC_INS_ADDI, - PPC_INS_ADDIC, - PPC_INS_ADDIS, - PPC_INS_ADDME, - PPC_INS_ADDPCIS, - PPC_INS_ADDZE, - PPC_INS_AND, - PPC_INS_ANDC, - PPC_INS_ANDI, - PPC_INS_ANDIS, - PPC_INS_ATTN, - PPC_INS_B, - PPC_INS_BA, - PPC_INS_BC, - PPC_INS_BCA, - PPC_INS_BCCTR, - PPC_INS_BCCTRL, - PPC_INS_BCDCFN, - PPC_INS_BCDCFSQ, - PPC_INS_BCDCFZ, - PPC_INS_BCDCPSGN, - PPC_INS_BCDCTN, - PPC_INS_BCDCTSQ, - PPC_INS_BCDCTZ, - PPC_INS_BCDS, - PPC_INS_BCDSETSGN, - PPC_INS_BCDSR, - PPC_INS_BCDTRUNC, - PPC_INS_BCDUS, - PPC_INS_BCDUTRUNC, - PPC_INS_BCL, - PPC_INS_BCLA, - PPC_INS_BCLR, - PPC_INS_BCLRL, - PPC_INS_BCTR, - PPC_INS_BCTRL, - PPC_INS_BDNZ, - PPC_INS_BDNZA, - PPC_INS_BDNZF, - PPC_INS_BDNZFA, - PPC_INS_BDNZFL, - PPC_INS_BDNZFLA, - PPC_INS_BDNZFLR, - PPC_INS_BDNZFLRL, - PPC_INS_BDNZL, - PPC_INS_BDNZLA, - PPC_INS_BDNZLR, - PPC_INS_BDNZLRL, - PPC_INS_BDNZT, - PPC_INS_BDNZTA, - PPC_INS_BDNZTL, - PPC_INS_BDNZTLA, - PPC_INS_BDNZTLR, - PPC_INS_BDNZTLRL, - PPC_INS_BDZ, - PPC_INS_BDZA, - PPC_INS_BDZF, - PPC_INS_BDZFA, - PPC_INS_BDZFL, - PPC_INS_BDZFLA, - PPC_INS_BDZFLR, - PPC_INS_BDZFLRL, - PPC_INS_BDZL, - PPC_INS_BDZLA, - PPC_INS_BDZLR, - PPC_INS_BDZLRL, - PPC_INS_BDZT, - PPC_INS_BDZTA, - PPC_INS_BDZTL, - PPC_INS_BDZTLA, - PPC_INS_BDZTLR, - PPC_INS_BDZTLRL, - PPC_INS_BEQ, - PPC_INS_BEQA, - PPC_INS_BEQCTR, - PPC_INS_BEQCTRL, - PPC_INS_BEQL, - PPC_INS_BEQLA, - PPC_INS_BEQLR, - PPC_INS_BEQLRL, - PPC_INS_BF, - PPC_INS_BFA, - PPC_INS_BFCTR, - PPC_INS_BFCTRL, - PPC_INS_BFL, - PPC_INS_BFLA, - PPC_INS_BFLR, - PPC_INS_BFLRL, - PPC_INS_BGE, - PPC_INS_BGEA, - PPC_INS_BGECTR, - PPC_INS_BGECTRL, - PPC_INS_BGEL, - PPC_INS_BGELA, - PPC_INS_BGELR, - PPC_INS_BGELRL, - PPC_INS_BGT, - PPC_INS_BGTA, - PPC_INS_BGTCTR, - PPC_INS_BGTCTRL, - PPC_INS_BGTL, - PPC_INS_BGTLA, - PPC_INS_BGTLR, - PPC_INS_BGTLRL, - PPC_INS_BL, - PPC_INS_BLA, - PPC_INS_BLE, - PPC_INS_BLEA, - PPC_INS_BLECTR, - PPC_INS_BLECTRL, - PPC_INS_BLEL, - PPC_INS_BLELA, - PPC_INS_BLELR, - PPC_INS_BLELRL, - PPC_INS_BLR, - PPC_INS_BLRL, - PPC_INS_BLT, - PPC_INS_BLTA, - PPC_INS_BLTCTR, - PPC_INS_BLTCTRL, - PPC_INS_BLTL, - PPC_INS_BLTLA, - PPC_INS_BLTLR, - PPC_INS_BLTLRL, - PPC_INS_BNE, - PPC_INS_BNEA, - PPC_INS_BNECTR, - PPC_INS_BNECTRL, - PPC_INS_BNEL, - PPC_INS_BNELA, - PPC_INS_BNELR, - PPC_INS_BNELRL, - PPC_INS_BNG, - PPC_INS_BNGA, - PPC_INS_BNGCTR, - PPC_INS_BNGCTRL, - PPC_INS_BNGL, - PPC_INS_BNGLA, - PPC_INS_BNGLR, - PPC_INS_BNGLRL, - PPC_INS_BNL, - PPC_INS_BNLA, - PPC_INS_BNLCTR, - PPC_INS_BNLCTRL, - PPC_INS_BNLL, - PPC_INS_BNLLA, - PPC_INS_BNLLR, - PPC_INS_BNLLRL, - PPC_INS_BNS, - PPC_INS_BNSA, - PPC_INS_BNSCTR, - PPC_INS_BNSCTRL, - PPC_INS_BNSL, - PPC_INS_BNSLA, - PPC_INS_BNSLR, - PPC_INS_BNSLRL, - PPC_INS_BNU, - PPC_INS_BNUA, - PPC_INS_BNUCTR, - PPC_INS_BNUCTRL, - PPC_INS_BNUL, - PPC_INS_BNULA, - PPC_INS_BNULR, - PPC_INS_BNULRL, - PPC_INS_BPERMD, - PPC_INS_BRINC, - PPC_INS_BSO, - PPC_INS_BSOA, - PPC_INS_BSOCTR, - PPC_INS_BSOCTRL, - PPC_INS_BSOL, - PPC_INS_BSOLA, - PPC_INS_BSOLR, - PPC_INS_BSOLRL, - PPC_INS_BT, - PPC_INS_BTA, - PPC_INS_BTCTR, - PPC_INS_BTCTRL, - PPC_INS_BTL, - PPC_INS_BTLA, - PPC_INS_BTLR, - PPC_INS_BTLRL, - PPC_INS_BUN, - PPC_INS_BUNA, - PPC_INS_BUNCTR, - PPC_INS_BUNCTRL, - PPC_INS_BUNL, - PPC_INS_BUNLA, - PPC_INS_BUNLR, - PPC_INS_BUNLRL, - PPC_INS_CLRBHRB, - PPC_INS_CLRLDI, - PPC_INS_CLRLSLDI, - PPC_INS_CLRLSLWI, - PPC_INS_CLRLWI, - PPC_INS_CLRRDI, - PPC_INS_CLRRWI, - PPC_INS_CMP, - PPC_INS_CMPB, - PPC_INS_CMPD, - PPC_INS_CMPDI, - PPC_INS_CMPEQB, - PPC_INS_CMPI, - PPC_INS_CMPL, - PPC_INS_CMPLD, - PPC_INS_CMPLDI, - PPC_INS_CMPLI, - PPC_INS_CMPLW, - PPC_INS_CMPLWI, - PPC_INS_CMPRB, - PPC_INS_CMPW, - PPC_INS_CMPWI, - PPC_INS_CNTLZD, - PPC_INS_CNTLZW, - PPC_INS_CNTTZD, - PPC_INS_CNTTZW, - PPC_INS_COPY, - PPC_INS_COPY_FIRST, - PPC_INS_CP_ABORT, - PPC_INS_CRAND, - PPC_INS_CRANDC, - PPC_INS_CRCLR, - PPC_INS_CREQV, - PPC_INS_CRMOVE, - PPC_INS_CRNAND, - PPC_INS_CRNOR, - PPC_INS_CRNOT, - PPC_INS_CROR, - PPC_INS_CRORC, - PPC_INS_CRSET, - PPC_INS_CRXOR, - PPC_INS_DARN, - PPC_INS_DCBA, - PPC_INS_DCBF, - PPC_INS_DCBFEP, - PPC_INS_DCBFL, - PPC_INS_DCBFLP, - PPC_INS_DCBI, - PPC_INS_DCBST, - PPC_INS_DCBSTEP, - PPC_INS_DCBT, - PPC_INS_DCBTCT, - PPC_INS_DCBTDS, - PPC_INS_DCBTEP, - PPC_INS_DCBTST, - PPC_INS_DCBTSTCT, - PPC_INS_DCBTSTDS, - PPC_INS_DCBTSTEP, - PPC_INS_DCBTSTT, - PPC_INS_DCBTT, - PPC_INS_DCBZ, - PPC_INS_DCBZEP, - PPC_INS_DCBZL, - PPC_INS_DCBZLEP, - PPC_INS_DCCCI, - PPC_INS_DCI, - PPC_INS_DIVD, - PPC_INS_DIVDE, - PPC_INS_DIVDEU, - PPC_INS_DIVDU, - PPC_INS_DIVW, - PPC_INS_DIVWE, - PPC_INS_DIVWEU, - PPC_INS_DIVWU, - PPC_INS_DSS, - PPC_INS_DSSALL, - PPC_INS_DST, - PPC_INS_DSTST, - PPC_INS_DSTSTT, - PPC_INS_DSTT, - PPC_INS_EFDABS, - PPC_INS_EFDADD, - PPC_INS_EFDCFS, - PPC_INS_EFDCFSF, - PPC_INS_EFDCFSI, - PPC_INS_EFDCFSID, - PPC_INS_EFDCFUF, - PPC_INS_EFDCFUI, - PPC_INS_EFDCFUID, - PPC_INS_EFDCMPEQ, - PPC_INS_EFDCMPGT, - PPC_INS_EFDCMPLT, - PPC_INS_EFDCTSF, - PPC_INS_EFDCTSI, - PPC_INS_EFDCTSIDZ, - PPC_INS_EFDCTSIZ, - PPC_INS_EFDCTUF, - PPC_INS_EFDCTUI, - PPC_INS_EFDCTUIDZ, - PPC_INS_EFDCTUIZ, - PPC_INS_EFDDIV, - PPC_INS_EFDMUL, - PPC_INS_EFDNABS, - PPC_INS_EFDNEG, - PPC_INS_EFDSUB, - PPC_INS_EFDTSTEQ, - PPC_INS_EFDTSTGT, - PPC_INS_EFDTSTLT, - PPC_INS_EFSABS, - PPC_INS_EFSADD, - PPC_INS_EFSCFD, - PPC_INS_EFSCFSF, - PPC_INS_EFSCFSI, - PPC_INS_EFSCFUF, - PPC_INS_EFSCFUI, - PPC_INS_EFSCMPEQ, - PPC_INS_EFSCMPGT, - PPC_INS_EFSCMPLT, - PPC_INS_EFSCTSF, - PPC_INS_EFSCTSI, - PPC_INS_EFSCTSIZ, - PPC_INS_EFSCTUF, - PPC_INS_EFSCTUI, - PPC_INS_EFSCTUIZ, - PPC_INS_EFSDIV, - PPC_INS_EFSMUL, - PPC_INS_EFSNABS, - PPC_INS_EFSNEG, - PPC_INS_EFSSUB, - PPC_INS_EFSTSTEQ, - PPC_INS_EFSTSTGT, - PPC_INS_EFSTSTLT, - PPC_INS_EIEIO, - PPC_INS_EQV, - PPC_INS_EVABS, - PPC_INS_EVADDIW, - PPC_INS_EVADDSMIAAW, - PPC_INS_EVADDSSIAAW, - PPC_INS_EVADDUMIAAW, - PPC_INS_EVADDUSIAAW, - PPC_INS_EVADDW, - PPC_INS_EVAND, - PPC_INS_EVANDC, - PPC_INS_EVCMPEQ, - PPC_INS_EVCMPGTS, - PPC_INS_EVCMPGTU, - PPC_INS_EVCMPLTS, - PPC_INS_EVCMPLTU, - PPC_INS_EVCNTLSW, - PPC_INS_EVCNTLZW, - PPC_INS_EVDIVWS, - PPC_INS_EVDIVWU, - PPC_INS_EVEQV, - PPC_INS_EVEXTSB, - PPC_INS_EVEXTSH, - PPC_INS_EVFSABS, - PPC_INS_EVFSADD, - PPC_INS_EVFSCFSF, - PPC_INS_EVFSCFSI, - PPC_INS_EVFSCFUF, - PPC_INS_EVFSCFUI, - PPC_INS_EVFSCMPEQ, - PPC_INS_EVFSCMPGT, - PPC_INS_EVFSCMPLT, - PPC_INS_EVFSCTSF, - PPC_INS_EVFSCTSI, - PPC_INS_EVFSCTSIZ, - PPC_INS_EVFSCTUI, - PPC_INS_EVFSDIV, - PPC_INS_EVFSMUL, - PPC_INS_EVFSNABS, - PPC_INS_EVFSNEG, - PPC_INS_EVFSSUB, - PPC_INS_EVFSTSTEQ, - PPC_INS_EVFSTSTGT, - PPC_INS_EVFSTSTLT, - PPC_INS_EVLDD, - PPC_INS_EVLDDX, - PPC_INS_EVLDH, - PPC_INS_EVLDHX, - PPC_INS_EVLDW, - PPC_INS_EVLDWX, - PPC_INS_EVLHHESPLAT, - PPC_INS_EVLHHESPLATX, - PPC_INS_EVLHHOSSPLAT, - PPC_INS_EVLHHOSSPLATX, - PPC_INS_EVLHHOUSPLAT, - PPC_INS_EVLHHOUSPLATX, - PPC_INS_EVLWHE, - PPC_INS_EVLWHEX, - PPC_INS_EVLWHOS, - PPC_INS_EVLWHOSX, - PPC_INS_EVLWHOU, - PPC_INS_EVLWHOUX, - PPC_INS_EVLWHSPLAT, - PPC_INS_EVLWHSPLATX, - PPC_INS_EVLWWSPLAT, - PPC_INS_EVLWWSPLATX, - PPC_INS_EVMERGEHI, - PPC_INS_EVMERGEHILO, - PPC_INS_EVMERGELO, - PPC_INS_EVMERGELOHI, - PPC_INS_EVMHEGSMFAA, - PPC_INS_EVMHEGSMFAN, - PPC_INS_EVMHEGSMIAA, - PPC_INS_EVMHEGSMIAN, - PPC_INS_EVMHEGUMIAA, - PPC_INS_EVMHEGUMIAN, - PPC_INS_EVMHESMF, - PPC_INS_EVMHESMFA, - PPC_INS_EVMHESMFAAW, - PPC_INS_EVMHESMFANW, - PPC_INS_EVMHESMI, - PPC_INS_EVMHESMIA, - PPC_INS_EVMHESMIAAW, - PPC_INS_EVMHESMIANW, - PPC_INS_EVMHESSF, - PPC_INS_EVMHESSFA, - PPC_INS_EVMHESSFAAW, - PPC_INS_EVMHESSFANW, - PPC_INS_EVMHESSIAAW, - PPC_INS_EVMHESSIANW, - PPC_INS_EVMHEUMI, - PPC_INS_EVMHEUMIA, - PPC_INS_EVMHEUMIAAW, - PPC_INS_EVMHEUMIANW, - PPC_INS_EVMHEUSIAAW, - PPC_INS_EVMHEUSIANW, - PPC_INS_EVMHOGSMFAA, - PPC_INS_EVMHOGSMFAN, - PPC_INS_EVMHOGSMIAA, - PPC_INS_EVMHOGSMIAN, - PPC_INS_EVMHOGUMIAA, - PPC_INS_EVMHOGUMIAN, - PPC_INS_EVMHOSMF, - PPC_INS_EVMHOSMFA, - PPC_INS_EVMHOSMFAAW, - PPC_INS_EVMHOSMFANW, - PPC_INS_EVMHOSMI, - PPC_INS_EVMHOSMIA, - PPC_INS_EVMHOSMIAAW, - PPC_INS_EVMHOSMIANW, - PPC_INS_EVMHOSSF, - PPC_INS_EVMHOSSFA, - PPC_INS_EVMHOSSFAAW, - PPC_INS_EVMHOSSFANW, - PPC_INS_EVMHOSSIAAW, - PPC_INS_EVMHOSSIANW, - PPC_INS_EVMHOUMI, - PPC_INS_EVMHOUMIA, - PPC_INS_EVMHOUMIAAW, - PPC_INS_EVMHOUMIANW, - PPC_INS_EVMHOUSIAAW, - PPC_INS_EVMHOUSIANW, - PPC_INS_EVMRA, - PPC_INS_EVMWHSMF, - PPC_INS_EVMWHSMFA, - PPC_INS_EVMWHSMI, - PPC_INS_EVMWHSMIA, - PPC_INS_EVMWHSSF, - PPC_INS_EVMWHSSFA, - PPC_INS_EVMWHUMI, - PPC_INS_EVMWHUMIA, - PPC_INS_EVMWLSMIAAW, - PPC_INS_EVMWLSMIANW, - PPC_INS_EVMWLSSIAAW, - PPC_INS_EVMWLSSIANW, - PPC_INS_EVMWLUMI, - PPC_INS_EVMWLUMIA, - PPC_INS_EVMWLUMIAAW, - PPC_INS_EVMWLUMIANW, - PPC_INS_EVMWLUSIAAW, - PPC_INS_EVMWLUSIANW, - PPC_INS_EVMWSMF, - PPC_INS_EVMWSMFA, - PPC_INS_EVMWSMFAA, - PPC_INS_EVMWSMFAN, - PPC_INS_EVMWSMI, - PPC_INS_EVMWSMIA, - PPC_INS_EVMWSMIAA, - PPC_INS_EVMWSMIAN, - PPC_INS_EVMWSSF, - PPC_INS_EVMWSSFA, - PPC_INS_EVMWSSFAA, - PPC_INS_EVMWSSFAN, - PPC_INS_EVMWUMI, - PPC_INS_EVMWUMIA, - PPC_INS_EVMWUMIAA, - PPC_INS_EVMWUMIAN, - PPC_INS_EVNAND, - PPC_INS_EVNEG, - PPC_INS_EVNOR, - PPC_INS_EVOR, - PPC_INS_EVORC, - PPC_INS_EVRLW, - PPC_INS_EVRLWI, - PPC_INS_EVRNDW, - PPC_INS_EVSEL, - PPC_INS_EVSLW, - PPC_INS_EVSLWI, - PPC_INS_EVSPLATFI, - PPC_INS_EVSPLATI, - PPC_INS_EVSRWIS, - PPC_INS_EVSRWIU, - PPC_INS_EVSRWS, - PPC_INS_EVSRWU, - PPC_INS_EVSTDD, - PPC_INS_EVSTDDX, - PPC_INS_EVSTDH, - PPC_INS_EVSTDHX, - PPC_INS_EVSTDW, - PPC_INS_EVSTDWX, - PPC_INS_EVSTWHE, - PPC_INS_EVSTWHEX, - PPC_INS_EVSTWHO, - PPC_INS_EVSTWHOX, - PPC_INS_EVSTWWE, - PPC_INS_EVSTWWEX, - PPC_INS_EVSTWWO, - PPC_INS_EVSTWWOX, - PPC_INS_EVSUBFSMIAAW, - PPC_INS_EVSUBFSSIAAW, - PPC_INS_EVSUBFUMIAAW, - PPC_INS_EVSUBFUSIAAW, - PPC_INS_EVSUBFW, - PPC_INS_EVSUBIFW, - PPC_INS_EVXOR, - PPC_INS_EXTLDI, - PPC_INS_EXTLWI, - PPC_INS_EXTRDI, - PPC_INS_EXTRWI, - PPC_INS_EXTSB, - PPC_INS_EXTSH, - PPC_INS_EXTSW, - PPC_INS_EXTSWSLI, - PPC_INS_FABS, - PPC_INS_FADD, - PPC_INS_FADDS, - PPC_INS_FCFID, - PPC_INS_FCFIDS, - PPC_INS_FCFIDU, - PPC_INS_FCFIDUS, - PPC_INS_FCMPU, - PPC_INS_FCPSGN, - PPC_INS_FCTID, - PPC_INS_FCTIDU, - PPC_INS_FCTIDUZ, - PPC_INS_FCTIDZ, - PPC_INS_FCTIW, - PPC_INS_FCTIWU, - PPC_INS_FCTIWUZ, - PPC_INS_FCTIWZ, - PPC_INS_FDIV, - PPC_INS_FDIVS, - PPC_INS_FMADD, - PPC_INS_FMADDS, - PPC_INS_FMR, - PPC_INS_FMSUB, - PPC_INS_FMSUBS, - PPC_INS_FMUL, - PPC_INS_FMULS, - PPC_INS_FNABS, - PPC_INS_FNEG, - PPC_INS_FNMADD, - PPC_INS_FNMADDS, - PPC_INS_FNMSUB, - PPC_INS_FNMSUBS, - PPC_INS_FRE, - PPC_INS_FRES, - PPC_INS_FRIM, - PPC_INS_FRIN, - PPC_INS_FRIP, - PPC_INS_FRIZ, - PPC_INS_FRSP, - PPC_INS_FRSQRTE, - PPC_INS_FRSQRTES, - PPC_INS_FSEL, - PPC_INS_FSQRT, - PPC_INS_FSQRTS, - PPC_INS_FSUB, - PPC_INS_FSUBS, - PPC_INS_FTDIV, - PPC_INS_FTSQRT, - PPC_INS_HRFID, - PPC_INS_ICBI, - PPC_INS_ICBIEP, - PPC_INS_ICBLC, - PPC_INS_ICBLQ, - PPC_INS_ICBT, - PPC_INS_ICBTLS, - PPC_INS_ICCCI, - PPC_INS_ICI, - PPC_INS_INSLWI, - PPC_INS_INSRDI, - PPC_INS_INSRWI, - PPC_INS_ISEL, - PPC_INS_ISYNC, - PPC_INS_LA, - PPC_INS_LBARX, - PPC_INS_LBEPX, - PPC_INS_LBZ, - PPC_INS_LBZCIX, - PPC_INS_LBZU, - PPC_INS_LBZUX, - PPC_INS_LBZX, - PPC_INS_LD, - PPC_INS_LDARX, - PPC_INS_LDAT, - PPC_INS_LDBRX, - PPC_INS_LDCIX, - PPC_INS_LDMX, - PPC_INS_LDU, - PPC_INS_LDUX, - PPC_INS_LDX, - PPC_INS_LFD, - PPC_INS_LFDEPX, - PPC_INS_LFDU, - PPC_INS_LFDUX, - PPC_INS_LFDX, - PPC_INS_LFIWAX, - PPC_INS_LFIWZX, - PPC_INS_LFS, - PPC_INS_LFSU, - PPC_INS_LFSUX, - PPC_INS_LFSX, - PPC_INS_LHA, - PPC_INS_LHARX, - PPC_INS_LHAU, - PPC_INS_LHAUX, - PPC_INS_LHAX, - PPC_INS_LHBRX, - PPC_INS_LHEPX, - PPC_INS_LHZ, - PPC_INS_LHZCIX, - PPC_INS_LHZU, - PPC_INS_LHZUX, - PPC_INS_LHZX, - PPC_INS_LI, - PPC_INS_LIS, - PPC_INS_LMW, - PPC_INS_LNIA, - PPC_INS_LSWI, - PPC_INS_LVEBX, - PPC_INS_LVEHX, - PPC_INS_LVEWX, - PPC_INS_LVSL, - PPC_INS_LVSR, - PPC_INS_LVX, - PPC_INS_LVXL, - PPC_INS_LWA, - PPC_INS_LWARX, - PPC_INS_LWAT, - PPC_INS_LWAUX, - PPC_INS_LWAX, - PPC_INS_LWBRX, - PPC_INS_LWEPX, - PPC_INS_LWSYNC, - PPC_INS_LWZ, - PPC_INS_LWZCIX, - PPC_INS_LWZU, - PPC_INS_LWZUX, - PPC_INS_LWZX, - PPC_INS_LXSD, - PPC_INS_LXSDX, - PPC_INS_LXSIBZX, - PPC_INS_LXSIHZX, - PPC_INS_LXSIWAX, - PPC_INS_LXSIWZX, - PPC_INS_LXSSP, - PPC_INS_LXSSPX, - PPC_INS_LXV, - PPC_INS_LXVB16X, - PPC_INS_LXVD2X, - PPC_INS_LXVDSX, - PPC_INS_LXVH8X, - PPC_INS_LXVL, - PPC_INS_LXVLL, - PPC_INS_LXVW4X, - PPC_INS_LXVWSX, - PPC_INS_LXVX, - PPC_INS_MADDHD, - PPC_INS_MADDHDU, - PPC_INS_MADDLD, - PPC_INS_MBAR, - PPC_INS_MCRF, - PPC_INS_MCRFS, - PPC_INS_MCRXRX, - PPC_INS_MFAMR, - PPC_INS_MFASR, - PPC_INS_MFBHRBE, - PPC_INS_MFBR0, - PPC_INS_MFBR1, - PPC_INS_MFBR2, - PPC_INS_MFBR3, - PPC_INS_MFBR4, - PPC_INS_MFBR5, - PPC_INS_MFBR6, - PPC_INS_MFBR7, - PPC_INS_MFCFAR, - PPC_INS_MFCR, - PPC_INS_MFCTR, - PPC_INS_MFDAR, - PPC_INS_MFDBATL, - PPC_INS_MFDBATU, - PPC_INS_MFDCCR, - PPC_INS_MFDCR, - PPC_INS_MFDEAR, - PPC_INS_MFDEC, - PPC_INS_MFDSCR, - PPC_INS_MFDSISR, - PPC_INS_MFESR, - PPC_INS_MFFPRD, - PPC_INS_MFFS, - PPC_INS_MFFSCDRN, - PPC_INS_MFFSCDRNI, - PPC_INS_MFFSCE, - PPC_INS_MFFSCRN, - PPC_INS_MFFSCRNI, - PPC_INS_MFFSL, - PPC_INS_MFIBATL, - PPC_INS_MFIBATU, - PPC_INS_MFICCR, - PPC_INS_MFLR, - PPC_INS_MFMSR, - PPC_INS_MFOCRF, - PPC_INS_MFPID, - PPC_INS_MFPMR, - PPC_INS_MFPVR, - PPC_INS_MFRTCL, - PPC_INS_MFRTCU, - PPC_INS_MFSDR1, - PPC_INS_MFSPEFSCR, - PPC_INS_MFSPR, - PPC_INS_MFSPRG, - PPC_INS_MFSPRG0, - PPC_INS_MFSPRG1, - PPC_INS_MFSPRG2, - PPC_INS_MFSPRG3, - PPC_INS_MFSPRG4, - PPC_INS_MFSPRG5, - PPC_INS_MFSPRG6, - PPC_INS_MFSPRG7, - PPC_INS_MFSR, - PPC_INS_MFSRIN, - PPC_INS_MFSRR0, - PPC_INS_MFSRR1, - PPC_INS_MFSRR2, - PPC_INS_MFSRR3, - PPC_INS_MFTB, - PPC_INS_MFTBHI, - PPC_INS_MFTBL, - PPC_INS_MFTBLO, - PPC_INS_MFTBU, - PPC_INS_MFTCR, - PPC_INS_MFVRD, - PPC_INS_MFVRSAVE, - PPC_INS_MFVSCR, - PPC_INS_MFVSRD, - PPC_INS_MFVSRLD, - PPC_INS_MFVSRWZ, - PPC_INS_MFXER, - PPC_INS_MODSD, - PPC_INS_MODSW, - PPC_INS_MODUD, - PPC_INS_MODUW, - PPC_INS_MR, - PPC_INS_MSGSYNC, - PPC_INS_MSYNC, - PPC_INS_MTAMR, - PPC_INS_MTASR, - PPC_INS_MTBR0, - PPC_INS_MTBR1, - PPC_INS_MTBR2, - PPC_INS_MTBR3, - PPC_INS_MTBR4, - PPC_INS_MTBR5, - PPC_INS_MTBR6, - PPC_INS_MTBR7, - PPC_INS_MTCFAR, - PPC_INS_MTCR, - PPC_INS_MTCRF, - PPC_INS_MTCTR, - PPC_INS_MTDAR, - PPC_INS_MTDBATL, - PPC_INS_MTDBATU, - PPC_INS_MTDCCR, - PPC_INS_MTDCR, - PPC_INS_MTDEAR, - PPC_INS_MTDEC, - PPC_INS_MTDSCR, - PPC_INS_MTDSISR, - PPC_INS_MTESR, - PPC_INS_MTFSB0, - PPC_INS_MTFSB1, - PPC_INS_MTFSF, - PPC_INS_MTFSFI, - PPC_INS_MTIBATL, - PPC_INS_MTIBATU, - PPC_INS_MTICCR, - PPC_INS_MTLR, - PPC_INS_MTMSR, - PPC_INS_MTMSRD, - PPC_INS_MTOCRF, - PPC_INS_MTPID, - PPC_INS_MTPMR, - PPC_INS_MTSDR1, - PPC_INS_MTSPEFSCR, - PPC_INS_MTSPR, - PPC_INS_MTSPRG, - PPC_INS_MTSPRG0, - PPC_INS_MTSPRG1, - PPC_INS_MTSPRG2, - PPC_INS_MTSPRG3, - PPC_INS_MTSPRG4, - PPC_INS_MTSPRG5, - PPC_INS_MTSPRG6, - PPC_INS_MTSPRG7, - PPC_INS_MTSR, - PPC_INS_MTSRIN, - PPC_INS_MTSRR0, - PPC_INS_MTSRR1, - PPC_INS_MTSRR2, - PPC_INS_MTSRR3, - PPC_INS_MTTBHI, - PPC_INS_MTTBL, - PPC_INS_MTTBLO, - PPC_INS_MTTBU, - PPC_INS_MTTCR, - PPC_INS_MTVRSAVE, - PPC_INS_MTVSCR, - PPC_INS_MTVSRD, - PPC_INS_MTVSRDD, - PPC_INS_MTVSRWA, - PPC_INS_MTVSRWS, - PPC_INS_MTVSRWZ, - PPC_INS_MTXER, - PPC_INS_MULHD, - PPC_INS_MULHDU, - PPC_INS_MULHW, - PPC_INS_MULHWU, - PPC_INS_MULLD, - PPC_INS_MULLI, - PPC_INS_MULLW, - PPC_INS_NAND, - PPC_INS_NAP, - PPC_INS_NEG, - PPC_INS_NOP, - PPC_INS_NOR, - PPC_INS_NOT, - PPC_INS_OR, - PPC_INS_ORC, - PPC_INS_ORI, - PPC_INS_ORIS, - PPC_INS_PASTE, - PPC_INS_PASTE_LAST, - PPC_INS_POPCNTB, - PPC_INS_POPCNTD, - PPC_INS_POPCNTW, - PPC_INS_PTESYNC, - PPC_INS_QVALIGNI, - PPC_INS_QVESPLATI, - PPC_INS_QVFABS, - PPC_INS_QVFADD, - PPC_INS_QVFADDS, - PPC_INS_QVFAND, - PPC_INS_QVFANDC, - PPC_INS_QVFCFID, - PPC_INS_QVFCFIDS, - PPC_INS_QVFCFIDU, - PPC_INS_QVFCFIDUS, - PPC_INS_QVFCLR, - PPC_INS_QVFCMPEQ, - PPC_INS_QVFCMPGT, - PPC_INS_QVFCMPLT, - PPC_INS_QVFCPSGN, - PPC_INS_QVFCTFB, - PPC_INS_QVFCTID, - PPC_INS_QVFCTIDU, - PPC_INS_QVFCTIDUZ, - PPC_INS_QVFCTIDZ, - PPC_INS_QVFCTIW, - PPC_INS_QVFCTIWU, - PPC_INS_QVFCTIWUZ, - PPC_INS_QVFCTIWZ, - PPC_INS_QVFEQU, - PPC_INS_QVFLOGICAL, - PPC_INS_QVFMADD, - PPC_INS_QVFMADDS, - PPC_INS_QVFMR, - PPC_INS_QVFMSUB, - PPC_INS_QVFMSUBS, - PPC_INS_QVFMUL, - PPC_INS_QVFMULS, - PPC_INS_QVFNABS, - PPC_INS_QVFNAND, - PPC_INS_QVFNEG, - PPC_INS_QVFNMADD, - PPC_INS_QVFNMADDS, - PPC_INS_QVFNMSUB, - PPC_INS_QVFNMSUBS, - PPC_INS_QVFNOR, - PPC_INS_QVFNOT, - PPC_INS_QVFOR, - PPC_INS_QVFORC, - PPC_INS_QVFPERM, - PPC_INS_QVFRE, - PPC_INS_QVFRES, - PPC_INS_QVFRIM, - PPC_INS_QVFRIN, - PPC_INS_QVFRIP, - PPC_INS_QVFRIZ, - PPC_INS_QVFRSP, - PPC_INS_QVFRSQRTE, - PPC_INS_QVFRSQRTES, - PPC_INS_QVFSEL, - PPC_INS_QVFSET, - PPC_INS_QVFSUB, - PPC_INS_QVFSUBS, - PPC_INS_QVFTSTNAN, - PPC_INS_QVFXMADD, - PPC_INS_QVFXMADDS, - PPC_INS_QVFXMUL, - PPC_INS_QVFXMULS, - PPC_INS_QVFXOR, - PPC_INS_QVFXXCPNMADD, - PPC_INS_QVFXXCPNMADDS, - PPC_INS_QVFXXMADD, - PPC_INS_QVFXXMADDS, - PPC_INS_QVFXXNPMADD, - PPC_INS_QVFXXNPMADDS, - PPC_INS_QVGPCI, - PPC_INS_QVLFCDUX, - PPC_INS_QVLFCDUXA, - PPC_INS_QVLFCDX, - PPC_INS_QVLFCDXA, - PPC_INS_QVLFCSUX, - PPC_INS_QVLFCSUXA, - PPC_INS_QVLFCSX, - PPC_INS_QVLFCSXA, - PPC_INS_QVLFDUX, - PPC_INS_QVLFDUXA, - PPC_INS_QVLFDX, - PPC_INS_QVLFDXA, - PPC_INS_QVLFIWAX, - PPC_INS_QVLFIWAXA, - PPC_INS_QVLFIWZX, - PPC_INS_QVLFIWZXA, - PPC_INS_QVLFSUX, - PPC_INS_QVLFSUXA, - PPC_INS_QVLFSX, - PPC_INS_QVLFSXA, - PPC_INS_QVLPCLDX, - PPC_INS_QVLPCLSX, - PPC_INS_QVLPCRDX, - PPC_INS_QVLPCRSX, - PPC_INS_QVSTFCDUX, - PPC_INS_QVSTFCDUXA, - PPC_INS_QVSTFCDUXI, - PPC_INS_QVSTFCDUXIA, - PPC_INS_QVSTFCDX, - PPC_INS_QVSTFCDXA, - PPC_INS_QVSTFCDXI, - PPC_INS_QVSTFCDXIA, - PPC_INS_QVSTFCSUX, - PPC_INS_QVSTFCSUXA, - PPC_INS_QVSTFCSUXI, - PPC_INS_QVSTFCSUXIA, - PPC_INS_QVSTFCSX, - PPC_INS_QVSTFCSXA, - PPC_INS_QVSTFCSXI, - PPC_INS_QVSTFCSXIA, - PPC_INS_QVSTFDUX, - PPC_INS_QVSTFDUXA, - PPC_INS_QVSTFDUXI, - PPC_INS_QVSTFDUXIA, - PPC_INS_QVSTFDX, - PPC_INS_QVSTFDXA, - PPC_INS_QVSTFDXI, - PPC_INS_QVSTFDXIA, - PPC_INS_QVSTFIWX, - PPC_INS_QVSTFIWXA, - PPC_INS_QVSTFSUX, - PPC_INS_QVSTFSUXA, - PPC_INS_QVSTFSUXI, - PPC_INS_QVSTFSUXIA, - PPC_INS_QVSTFSX, - PPC_INS_QVSTFSXA, - PPC_INS_QVSTFSXI, - PPC_INS_QVSTFSXIA, - PPC_INS_RFCI, - PPC_INS_RFDI, - PPC_INS_RFEBB, - PPC_INS_RFI, - PPC_INS_RFID, - PPC_INS_RFMCI, - PPC_INS_RLDCL, - PPC_INS_RLDCR, - PPC_INS_RLDIC, - PPC_INS_RLDICL, - PPC_INS_RLDICR, - PPC_INS_RLDIMI, - PPC_INS_RLWIMI, - PPC_INS_RLWINM, - PPC_INS_RLWNM, - PPC_INS_ROTLD, - PPC_INS_ROTLDI, - PPC_INS_ROTLW, - PPC_INS_ROTLWI, - PPC_INS_ROTRDI, - PPC_INS_ROTRWI, - PPC_INS_SC, - PPC_INS_SETB, - PPC_INS_SLBIA, - PPC_INS_SLBIE, - PPC_INS_SLBIEG, - PPC_INS_SLBMFEE, - PPC_INS_SLBMFEV, - PPC_INS_SLBMTE, - PPC_INS_SLBSYNC, - PPC_INS_SLD, - PPC_INS_SLDI, - PPC_INS_SLW, - PPC_INS_SLWI, - PPC_INS_SRAD, - PPC_INS_SRADI, - PPC_INS_SRAW, - PPC_INS_SRAWI, - PPC_INS_SRD, - PPC_INS_SRDI, - PPC_INS_SRW, - PPC_INS_SRWI, - PPC_INS_STB, - PPC_INS_STBCIX, - PPC_INS_STBCX, - PPC_INS_STBEPX, - PPC_INS_STBU, - PPC_INS_STBUX, - PPC_INS_STBX, - PPC_INS_STD, - PPC_INS_STDAT, - PPC_INS_STDBRX, - PPC_INS_STDCIX, - PPC_INS_STDCX, - PPC_INS_STDU, - PPC_INS_STDUX, - PPC_INS_STDX, - PPC_INS_STFD, - PPC_INS_STFDEPX, - PPC_INS_STFDU, - PPC_INS_STFDUX, - PPC_INS_STFDX, - PPC_INS_STFIWX, - PPC_INS_STFS, - PPC_INS_STFSU, - PPC_INS_STFSUX, - PPC_INS_STFSX, - PPC_INS_STH, - PPC_INS_STHBRX, - PPC_INS_STHCIX, - PPC_INS_STHCX, - PPC_INS_STHEPX, - PPC_INS_STHU, - PPC_INS_STHUX, - PPC_INS_STHX, - PPC_INS_STMW, - PPC_INS_STOP, - PPC_INS_STSWI, - PPC_INS_STVEBX, - PPC_INS_STVEHX, - PPC_INS_STVEWX, - PPC_INS_STVX, - PPC_INS_STVXL, - PPC_INS_STW, - PPC_INS_STWAT, - PPC_INS_STWBRX, - PPC_INS_STWCIX, - PPC_INS_STWCX, - PPC_INS_STWEPX, - PPC_INS_STWU, - PPC_INS_STWUX, - PPC_INS_STWX, - PPC_INS_STXSD, - PPC_INS_STXSDX, - PPC_INS_STXSIBX, - PPC_INS_STXSIHX, - PPC_INS_STXSIWX, - PPC_INS_STXSSP, - PPC_INS_STXSSPX, - PPC_INS_STXV, - PPC_INS_STXVB16X, - PPC_INS_STXVD2X, - PPC_INS_STXVH8X, - PPC_INS_STXVL, - PPC_INS_STXVLL, - PPC_INS_STXVW4X, - PPC_INS_STXVX, - PPC_INS_SUB, - PPC_INS_SUBC, - PPC_INS_SUBF, - PPC_INS_SUBFC, - PPC_INS_SUBFE, - PPC_INS_SUBFIC, - PPC_INS_SUBFME, - PPC_INS_SUBFZE, - PPC_INS_SUBI, - PPC_INS_SUBIC, - PPC_INS_SUBIS, - PPC_INS_SUBPCIS, - PPC_INS_SYNC, - PPC_INS_TABORT, - PPC_INS_TABORTDC, - PPC_INS_TABORTDCI, - PPC_INS_TABORTWC, - PPC_INS_TABORTWCI, - PPC_INS_TBEGIN, - PPC_INS_TCHECK, - PPC_INS_TD, - PPC_INS_TDEQ, - PPC_INS_TDEQI, - PPC_INS_TDGE, - PPC_INS_TDGEI, - PPC_INS_TDGT, - PPC_INS_TDGTI, - PPC_INS_TDI, - PPC_INS_TDLE, - PPC_INS_TDLEI, - PPC_INS_TDLGE, - PPC_INS_TDLGEI, - PPC_INS_TDLGT, - PPC_INS_TDLGTI, - PPC_INS_TDLLE, - PPC_INS_TDLLEI, - PPC_INS_TDLLT, - PPC_INS_TDLLTI, - PPC_INS_TDLNG, - PPC_INS_TDLNGI, - PPC_INS_TDLNL, - PPC_INS_TDLNLI, - PPC_INS_TDLT, - PPC_INS_TDLTI, - PPC_INS_TDNE, - PPC_INS_TDNEI, - PPC_INS_TDNG, - PPC_INS_TDNGI, - PPC_INS_TDNL, - PPC_INS_TDNLI, - PPC_INS_TDU, - PPC_INS_TDUI, - PPC_INS_TEND, - PPC_INS_TLBIA, - PPC_INS_TLBIE, - PPC_INS_TLBIEL, - PPC_INS_TLBIVAX, - PPC_INS_TLBLD, - PPC_INS_TLBLI, - PPC_INS_TLBRE, - PPC_INS_TLBREHI, - PPC_INS_TLBRELO, - PPC_INS_TLBSX, - PPC_INS_TLBSYNC, - PPC_INS_TLBWE, - PPC_INS_TLBWEHI, - PPC_INS_TLBWELO, - PPC_INS_TRAP, - PPC_INS_TRECHKPT, - PPC_INS_TRECLAIM, - PPC_INS_TSR, - PPC_INS_TW, - PPC_INS_TWEQ, - PPC_INS_TWEQI, - PPC_INS_TWGE, - PPC_INS_TWGEI, - PPC_INS_TWGT, - PPC_INS_TWGTI, - PPC_INS_TWI, - PPC_INS_TWLE, - PPC_INS_TWLEI, - PPC_INS_TWLGE, - PPC_INS_TWLGEI, - PPC_INS_TWLGT, - PPC_INS_TWLGTI, - PPC_INS_TWLLE, - PPC_INS_TWLLEI, - PPC_INS_TWLLT, - PPC_INS_TWLLTI, - PPC_INS_TWLNG, - PPC_INS_TWLNGI, - PPC_INS_TWLNL, - PPC_INS_TWLNLI, - PPC_INS_TWLT, - PPC_INS_TWLTI, - PPC_INS_TWNE, - PPC_INS_TWNEI, - PPC_INS_TWNG, - PPC_INS_TWNGI, - PPC_INS_TWNL, - PPC_INS_TWNLI, - PPC_INS_TWU, - PPC_INS_TWUI, - PPC_INS_VABSDUB, - PPC_INS_VABSDUH, - PPC_INS_VABSDUW, - PPC_INS_VADDCUQ, - PPC_INS_VADDCUW, - PPC_INS_VADDECUQ, - PPC_INS_VADDEUQM, - PPC_INS_VADDFP, - PPC_INS_VADDSBS, - PPC_INS_VADDSHS, - PPC_INS_VADDSWS, - PPC_INS_VADDUBM, - PPC_INS_VADDUBS, - PPC_INS_VADDUDM, - PPC_INS_VADDUHM, - PPC_INS_VADDUHS, - PPC_INS_VADDUQM, - PPC_INS_VADDUWM, - PPC_INS_VADDUWS, - PPC_INS_VAND, - PPC_INS_VANDC, - PPC_INS_VAVGSB, - PPC_INS_VAVGSH, - PPC_INS_VAVGSW, - PPC_INS_VAVGUB, - PPC_INS_VAVGUH, - PPC_INS_VAVGUW, - PPC_INS_VBPERMD, - PPC_INS_VBPERMQ, - PPC_INS_VCFSX, - PPC_INS_VCFUX, - PPC_INS_VCIPHER, - PPC_INS_VCIPHERLAST, - PPC_INS_VCLZB, - PPC_INS_VCLZD, - PPC_INS_VCLZH, - PPC_INS_VCLZLSBB, - PPC_INS_VCLZW, - PPC_INS_VCMPBFP, - PPC_INS_VCMPEQFP, - PPC_INS_VCMPEQUB, - PPC_INS_VCMPEQUD, - PPC_INS_VCMPEQUH, - PPC_INS_VCMPEQUW, - PPC_INS_VCMPGEFP, - PPC_INS_VCMPGTFP, - PPC_INS_VCMPGTSB, - PPC_INS_VCMPGTSD, - PPC_INS_VCMPGTSH, - PPC_INS_VCMPGTSW, - PPC_INS_VCMPGTUB, - PPC_INS_VCMPGTUD, - PPC_INS_VCMPGTUH, - PPC_INS_VCMPGTUW, - PPC_INS_VCMPNEB, - PPC_INS_VCMPNEH, - PPC_INS_VCMPNEW, - PPC_INS_VCMPNEZB, - PPC_INS_VCMPNEZH, - PPC_INS_VCMPNEZW, - PPC_INS_VCTSXS, - PPC_INS_VCTUXS, - PPC_INS_VCTZB, - PPC_INS_VCTZD, - PPC_INS_VCTZH, - PPC_INS_VCTZLSBB, - PPC_INS_VCTZW, - PPC_INS_VEQV, - PPC_INS_VEXPTEFP, - PPC_INS_VEXTRACTD, - PPC_INS_VEXTRACTUB, - PPC_INS_VEXTRACTUH, - PPC_INS_VEXTRACTUW, - PPC_INS_VEXTSB2D, - PPC_INS_VEXTSB2W, - PPC_INS_VEXTSH2D, - PPC_INS_VEXTSH2W, - PPC_INS_VEXTSW2D, - PPC_INS_VEXTUBLX, - PPC_INS_VEXTUBRX, - PPC_INS_VEXTUHLX, - PPC_INS_VEXTUHRX, - PPC_INS_VEXTUWLX, - PPC_INS_VEXTUWRX, - PPC_INS_VGBBD, - PPC_INS_VINSERTB, - PPC_INS_VINSERTD, - PPC_INS_VINSERTH, - PPC_INS_VINSERTW, - PPC_INS_VLOGEFP, - PPC_INS_VMADDFP, - PPC_INS_VMAXFP, - PPC_INS_VMAXSB, - PPC_INS_VMAXSD, - PPC_INS_VMAXSH, - PPC_INS_VMAXSW, - PPC_INS_VMAXUB, - PPC_INS_VMAXUD, - PPC_INS_VMAXUH, - PPC_INS_VMAXUW, - PPC_INS_VMHADDSHS, - PPC_INS_VMHRADDSHS, - PPC_INS_VMINFP, - PPC_INS_VMINSB, - PPC_INS_VMINSD, - PPC_INS_VMINSH, - PPC_INS_VMINSW, - PPC_INS_VMINUB, - PPC_INS_VMINUD, - PPC_INS_VMINUH, - PPC_INS_VMINUW, - PPC_INS_VMLADDUHM, - PPC_INS_VMR, - PPC_INS_VMRGEW, - PPC_INS_VMRGHB, - PPC_INS_VMRGHH, - PPC_INS_VMRGHW, - PPC_INS_VMRGLB, - PPC_INS_VMRGLH, - PPC_INS_VMRGLW, - PPC_INS_VMRGOW, - PPC_INS_VMSUMMBM, - PPC_INS_VMSUMSHM, - PPC_INS_VMSUMSHS, - PPC_INS_VMSUMUBM, - PPC_INS_VMSUMUHM, - PPC_INS_VMSUMUHS, - PPC_INS_VMUL10CUQ, - PPC_INS_VMUL10ECUQ, - PPC_INS_VMUL10EUQ, - PPC_INS_VMUL10UQ, - PPC_INS_VMULESB, - PPC_INS_VMULESH, - PPC_INS_VMULESW, - PPC_INS_VMULEUB, - PPC_INS_VMULEUH, - PPC_INS_VMULEUW, - PPC_INS_VMULOSB, - PPC_INS_VMULOSH, - PPC_INS_VMULOSW, - PPC_INS_VMULOUB, - PPC_INS_VMULOUH, - PPC_INS_VMULOUW, - PPC_INS_VMULUWM, - PPC_INS_VNAND, - PPC_INS_VNCIPHER, - PPC_INS_VNCIPHERLAST, - PPC_INS_VNEGD, - PPC_INS_VNEGW, - PPC_INS_VNMSUBFP, - PPC_INS_VNOR, - PPC_INS_VNOT, - PPC_INS_VOR, - PPC_INS_VORC, - PPC_INS_VPERM, - PPC_INS_VPERMR, - PPC_INS_VPERMXOR, - PPC_INS_VPKPX, - PPC_INS_VPKSDSS, - PPC_INS_VPKSDUS, - PPC_INS_VPKSHSS, - PPC_INS_VPKSHUS, - PPC_INS_VPKSWSS, - PPC_INS_VPKSWUS, - PPC_INS_VPKUDUM, - PPC_INS_VPKUDUS, - PPC_INS_VPKUHUM, - PPC_INS_VPKUHUS, - PPC_INS_VPKUWUM, - PPC_INS_VPKUWUS, - PPC_INS_VPMSUMB, - PPC_INS_VPMSUMD, - PPC_INS_VPMSUMH, - PPC_INS_VPMSUMW, - PPC_INS_VPOPCNTB, - PPC_INS_VPOPCNTD, - PPC_INS_VPOPCNTH, - PPC_INS_VPOPCNTW, - PPC_INS_VPRTYBD, - PPC_INS_VPRTYBQ, - PPC_INS_VPRTYBW, - PPC_INS_VREFP, - PPC_INS_VRFIM, - PPC_INS_VRFIN, - PPC_INS_VRFIP, - PPC_INS_VRFIZ, - PPC_INS_VRLB, - PPC_INS_VRLD, - PPC_INS_VRLDMI, - PPC_INS_VRLDNM, - PPC_INS_VRLH, - PPC_INS_VRLW, - PPC_INS_VRLWMI, - PPC_INS_VRLWNM, - PPC_INS_VRSQRTEFP, - PPC_INS_VSBOX, - PPC_INS_VSEL, - PPC_INS_VSHASIGMAD, - PPC_INS_VSHASIGMAW, - PPC_INS_VSL, - PPC_INS_VSLB, - PPC_INS_VSLD, - PPC_INS_VSLDOI, - PPC_INS_VSLH, - PPC_INS_VSLO, - PPC_INS_VSLV, - PPC_INS_VSLW, - PPC_INS_VSPLTB, - PPC_INS_VSPLTH, - PPC_INS_VSPLTISB, - PPC_INS_VSPLTISH, - PPC_INS_VSPLTISW, - PPC_INS_VSPLTW, - PPC_INS_VSR, - PPC_INS_VSRAB, - PPC_INS_VSRAD, - PPC_INS_VSRAH, - PPC_INS_VSRAW, - PPC_INS_VSRB, - PPC_INS_VSRD, - PPC_INS_VSRH, - PPC_INS_VSRO, - PPC_INS_VSRV, - PPC_INS_VSRW, - PPC_INS_VSUBCUQ, - PPC_INS_VSUBCUW, - PPC_INS_VSUBECUQ, - PPC_INS_VSUBEUQM, - PPC_INS_VSUBFP, - PPC_INS_VSUBSBS, - PPC_INS_VSUBSHS, - PPC_INS_VSUBSWS, - PPC_INS_VSUBUBM, - PPC_INS_VSUBUBS, - PPC_INS_VSUBUDM, - PPC_INS_VSUBUHM, - PPC_INS_VSUBUHS, - PPC_INS_VSUBUQM, - PPC_INS_VSUBUWM, - PPC_INS_VSUBUWS, - PPC_INS_VSUM2SWS, - PPC_INS_VSUM4SBS, - PPC_INS_VSUM4SHS, - PPC_INS_VSUM4UBS, - PPC_INS_VSUMSWS, - PPC_INS_VUPKHPX, - PPC_INS_VUPKHSB, - PPC_INS_VUPKHSH, - PPC_INS_VUPKHSW, - PPC_INS_VUPKLPX, - PPC_INS_VUPKLSB, - PPC_INS_VUPKLSH, - PPC_INS_VUPKLSW, - PPC_INS_VXOR, - PPC_INS_WAIT, - PPC_INS_WAITIMPL, - PPC_INS_WAITRSV, - PPC_INS_WRTEE, - PPC_INS_WRTEEI, - PPC_INS_XNOP, - PPC_INS_XOR, - PPC_INS_XORI, - PPC_INS_XORIS, - PPC_INS_XSABSDP, - PPC_INS_XSABSQP, - PPC_INS_XSADDDP, - PPC_INS_XSADDQP, - PPC_INS_XSADDQPO, - PPC_INS_XSADDSP, - PPC_INS_XSCMPEQDP, - PPC_INS_XSCMPEXPDP, - PPC_INS_XSCMPEXPQP, - PPC_INS_XSCMPGEDP, - PPC_INS_XSCMPGTDP, - PPC_INS_XSCMPODP, - PPC_INS_XSCMPOQP, - PPC_INS_XSCMPUDP, - PPC_INS_XSCMPUQP, - PPC_INS_XSCPSGNDP, - PPC_INS_XSCPSGNQP, - PPC_INS_XSCVDPHP, - PPC_INS_XSCVDPQP, - PPC_INS_XSCVDPSP, - PPC_INS_XSCVDPSPN, - PPC_INS_XSCVDPSXDS, - PPC_INS_XSCVDPSXWS, - PPC_INS_XSCVDPUXDS, - PPC_INS_XSCVDPUXWS, - PPC_INS_XSCVHPDP, - PPC_INS_XSCVQPDP, - PPC_INS_XSCVQPDPO, - PPC_INS_XSCVQPSDZ, - PPC_INS_XSCVQPSWZ, - PPC_INS_XSCVQPUDZ, - PPC_INS_XSCVQPUWZ, - PPC_INS_XSCVSDQP, - PPC_INS_XSCVSPDP, - PPC_INS_XSCVSPDPN, - PPC_INS_XSCVSXDDP, - PPC_INS_XSCVSXDSP, - PPC_INS_XSCVUDQP, - PPC_INS_XSCVUXDDP, - PPC_INS_XSCVUXDSP, - PPC_INS_XSDIVDP, - PPC_INS_XSDIVQP, - PPC_INS_XSDIVQPO, - PPC_INS_XSDIVSP, - PPC_INS_XSIEXPDP, - PPC_INS_XSIEXPQP, - PPC_INS_XSMADDADP, - PPC_INS_XSMADDASP, - PPC_INS_XSMADDMDP, - PPC_INS_XSMADDMSP, - PPC_INS_XSMADDQP, - PPC_INS_XSMADDQPO, - PPC_INS_XSMAXCDP, - PPC_INS_XSMAXDP, - PPC_INS_XSMAXJDP, - PPC_INS_XSMINCDP, - PPC_INS_XSMINDP, - PPC_INS_XSMINJDP, - PPC_INS_XSMSUBADP, - PPC_INS_XSMSUBASP, - PPC_INS_XSMSUBMDP, - PPC_INS_XSMSUBMSP, - PPC_INS_XSMSUBQP, - PPC_INS_XSMSUBQPO, - PPC_INS_XSMULDP, - PPC_INS_XSMULQP, - PPC_INS_XSMULQPO, - PPC_INS_XSMULSP, - PPC_INS_XSNABSDP, - PPC_INS_XSNABSQP, - PPC_INS_XSNEGDP, - PPC_INS_XSNEGQP, - PPC_INS_XSNMADDADP, - PPC_INS_XSNMADDASP, - PPC_INS_XSNMADDMDP, - PPC_INS_XSNMADDMSP, - PPC_INS_XSNMADDQP, - PPC_INS_XSNMADDQPO, - PPC_INS_XSNMSUBADP, - PPC_INS_XSNMSUBASP, - PPC_INS_XSNMSUBMDP, - PPC_INS_XSNMSUBMSP, - PPC_INS_XSNMSUBQP, - PPC_INS_XSNMSUBQPO, - PPC_INS_XSRDPI, - PPC_INS_XSRDPIC, - PPC_INS_XSRDPIM, - PPC_INS_XSRDPIP, - PPC_INS_XSRDPIZ, - PPC_INS_XSREDP, - PPC_INS_XSRESP, - PPC_INS_XSRQPI, - PPC_INS_XSRQPIX, - PPC_INS_XSRQPXP, - PPC_INS_XSRSP, - PPC_INS_XSRSQRTEDP, - PPC_INS_XSRSQRTESP, - PPC_INS_XSSQRTDP, - PPC_INS_XSSQRTQP, - PPC_INS_XSSQRTQPO, - PPC_INS_XSSQRTSP, - PPC_INS_XSSUBDP, - PPC_INS_XSSUBQP, - PPC_INS_XSSUBQPO, - PPC_INS_XSSUBSP, - PPC_INS_XSTDIVDP, - PPC_INS_XSTSQRTDP, - PPC_INS_XSTSTDCDP, - PPC_INS_XSTSTDCQP, - PPC_INS_XSTSTDCSP, - PPC_INS_XSXEXPDP, - PPC_INS_XSXEXPQP, - PPC_INS_XSXSIGDP, - PPC_INS_XSXSIGQP, - PPC_INS_XVABSDP, - PPC_INS_XVABSSP, - PPC_INS_XVADDDP, - PPC_INS_XVADDSP, - PPC_INS_XVCMPEQDP, - PPC_INS_XVCMPEQSP, - PPC_INS_XVCMPGEDP, - PPC_INS_XVCMPGESP, - PPC_INS_XVCMPGTDP, - PPC_INS_XVCMPGTSP, - PPC_INS_XVCPSGNDP, - PPC_INS_XVCPSGNSP, - PPC_INS_XVCVDPSP, - PPC_INS_XVCVDPSXDS, - PPC_INS_XVCVDPSXWS, - PPC_INS_XVCVDPUXDS, - PPC_INS_XVCVDPUXWS, - PPC_INS_XVCVHPSP, - PPC_INS_XVCVSPDP, - PPC_INS_XVCVSPHP, - PPC_INS_XVCVSPSXDS, - PPC_INS_XVCVSPSXWS, - PPC_INS_XVCVSPUXDS, - PPC_INS_XVCVSPUXWS, - PPC_INS_XVCVSXDDP, - PPC_INS_XVCVSXDSP, - PPC_INS_XVCVSXWDP, - PPC_INS_XVCVSXWSP, - PPC_INS_XVCVUXDDP, - PPC_INS_XVCVUXDSP, - PPC_INS_XVCVUXWDP, - PPC_INS_XVCVUXWSP, - PPC_INS_XVDIVDP, - PPC_INS_XVDIVSP, - PPC_INS_XVIEXPDP, - PPC_INS_XVIEXPSP, - PPC_INS_XVMADDADP, - PPC_INS_XVMADDASP, - PPC_INS_XVMADDMDP, - PPC_INS_XVMADDMSP, - PPC_INS_XVMAXDP, - PPC_INS_XVMAXSP, - PPC_INS_XVMINDP, - PPC_INS_XVMINSP, - PPC_INS_XVMOVDP, - PPC_INS_XVMOVSP, - PPC_INS_XVMSUBADP, - PPC_INS_XVMSUBASP, - PPC_INS_XVMSUBMDP, - PPC_INS_XVMSUBMSP, - PPC_INS_XVMULDP, - PPC_INS_XVMULSP, - PPC_INS_XVNABSDP, - PPC_INS_XVNABSSP, - PPC_INS_XVNEGDP, - PPC_INS_XVNEGSP, - PPC_INS_XVNMADDADP, - PPC_INS_XVNMADDASP, - PPC_INS_XVNMADDMDP, - PPC_INS_XVNMADDMSP, - PPC_INS_XVNMSUBADP, - PPC_INS_XVNMSUBASP, - PPC_INS_XVNMSUBMDP, - PPC_INS_XVNMSUBMSP, - PPC_INS_XVRDPI, - PPC_INS_XVRDPIC, - PPC_INS_XVRDPIM, - PPC_INS_XVRDPIP, - PPC_INS_XVRDPIZ, - PPC_INS_XVREDP, - PPC_INS_XVRESP, - PPC_INS_XVRSPI, - PPC_INS_XVRSPIC, - PPC_INS_XVRSPIM, - PPC_INS_XVRSPIP, - PPC_INS_XVRSPIZ, - PPC_INS_XVRSQRTEDP, - PPC_INS_XVRSQRTESP, - PPC_INS_XVSQRTDP, - PPC_INS_XVSQRTSP, - PPC_INS_XVSUBDP, - PPC_INS_XVSUBSP, - PPC_INS_XVTDIVDP, - PPC_INS_XVTDIVSP, - PPC_INS_XVTSQRTDP, - PPC_INS_XVTSQRTSP, - PPC_INS_XVTSTDCDP, - PPC_INS_XVTSTDCSP, - PPC_INS_XVXEXPDP, - PPC_INS_XVXEXPSP, - PPC_INS_XVXSIGDP, - PPC_INS_XVXSIGSP, - PPC_INS_XXBRD, - PPC_INS_XXBRH, - PPC_INS_XXBRQ, - PPC_INS_XXBRW, - PPC_INS_XXEXTRACTUW, - PPC_INS_XXINSERTW, - PPC_INS_XXLAND, - PPC_INS_XXLANDC, - PPC_INS_XXLEQV, - PPC_INS_XXLNAND, - PPC_INS_XXLNOR, - PPC_INS_XXLOR, - PPC_INS_XXLORC, - PPC_INS_XXLXOR, - PPC_INS_XXMRGHD, - PPC_INS_XXMRGHW, - PPC_INS_XXMRGLD, - PPC_INS_XXMRGLW, - PPC_INS_XXPERM, - PPC_INS_XXPERMDI, - PPC_INS_XXPERMR, - PPC_INS_XXSEL, - PPC_INS_XXSLDWI, - PPC_INS_XXSPLTD, - PPC_INS_XXSPLTIB, - PPC_INS_XXSPLTW, - PPC_INS_XXSWAPD, - PPC_INS_ENDING, // <-- mark the end of the list of instructions -} ppc_insn; - -/// Group of PPC instructions -typedef enum ppc_insn_group { - PPC_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - // Generic groups - // all jump instructions (conditional+direct+indirect jumps) - PPC_GRP_JUMP, ///< = CS_GRP_JUMP - - // Architecture-specific groups - PPC_GRP_ALTIVEC = 128, - PPC_GRP_MODE32, - PPC_GRP_MODE64, - PPC_GRP_BOOKE, - PPC_GRP_NOTBOOKE, - PPC_GRP_SPE, - PPC_GRP_VSX, - PPC_GRP_E500, - PPC_GRP_PPC4XX, - PPC_GRP_PPC6XX, - PPC_GRP_ICBT, - PPC_GRP_P8ALTIVEC, - PPC_GRP_P8VECTOR, - PPC_GRP_QPX, - - PPC_GRP_ENDING, // <-- mark the end of the list of groups -} ppc_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_SPARC_H -#define CAPSTONE_SPARC_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2014-2015 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -// GCC SPARC toolchain has a default macro called "sparc" which breaks -// compilation -#undef sparc - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// Enums corresponding to Sparc condition codes, both icc's and fcc's. -typedef enum sparc_cc { - SPARC_CC_INVALID = 0, ///< invalid CC (default) - // Integer condition codes - SPARC_CC_ICC_A = 8+256, ///< Always - SPARC_CC_ICC_N = 0+256, ///< Never - SPARC_CC_ICC_NE = 9+256, ///< Not Equal - SPARC_CC_ICC_E = 1+256, ///< Equal - SPARC_CC_ICC_G = 10+256, ///< Greater - SPARC_CC_ICC_LE = 2+256, ///< Less or Equal - SPARC_CC_ICC_GE = 11+256, ///< Greater or Equal - SPARC_CC_ICC_L = 3+256, ///< Less - SPARC_CC_ICC_GU = 12+256, ///< Greater Unsigned - SPARC_CC_ICC_LEU = 4+256, ///< Less or Equal Unsigned - SPARC_CC_ICC_CC = 13+256, ///< Carry Clear/Great or Equal Unsigned - SPARC_CC_ICC_CS = 5+256, ///< Carry Set/Less Unsigned - SPARC_CC_ICC_POS = 14+256, ///< Positive - SPARC_CC_ICC_NEG = 6+256, ///< Negative - SPARC_CC_ICC_VC = 15+256, ///< Overflow Clear - SPARC_CC_ICC_VS = 7+256, ///< Overflow Set - - // Floating condition codes - SPARC_CC_FCC_A = 8+16+256, ///< Always - SPARC_CC_FCC_N = 0+16+256, ///< Never - SPARC_CC_FCC_U = 7+16+256, ///< Unordered - SPARC_CC_FCC_G = 6+16+256, ///< Greater - SPARC_CC_FCC_UG = 5+16+256, ///< Unordered or Greater - SPARC_CC_FCC_L = 4+16+256, ///< Less - SPARC_CC_FCC_UL = 3+16+256, ///< Unordered or Less - SPARC_CC_FCC_LG = 2+16+256, ///< Less or Greater - SPARC_CC_FCC_NE = 1+16+256, ///< Not Equal - SPARC_CC_FCC_E = 9+16+256, ///< Equal - SPARC_CC_FCC_UE = 10+16+256, ///< Unordered or Equal - SPARC_CC_FCC_GE = 11+16+256, ///< Greater or Equal - SPARC_CC_FCC_UGE = 12+16+256, ///< Unordered or Greater or Equal - SPARC_CC_FCC_LE = 13+16+256, ///< Less or Equal - SPARC_CC_FCC_ULE = 14+16+256, ///< Unordered or Less or Equal - SPARC_CC_FCC_O = 15+16+256, ///< Ordered -} sparc_cc; - -/// Branch hint -typedef enum sparc_hint { - SPARC_HINT_INVALID = 0, ///< no hint - SPARC_HINT_A = 1 << 0, ///< annul delay slot instruction - SPARC_HINT_PT = 1 << 1, ///< branch taken - SPARC_HINT_PN = 1 << 2, ///< branch NOT taken -} sparc_hint; - -/// Operand type for instruction's operands -typedef enum sparc_op_type { - SPARC_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - SPARC_OP_REG, ///< = CS_OP_REG (Register operand). - SPARC_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - SPARC_OP_MEM, ///< = CS_OP_MEM (Memory operand). -} sparc_op_type; - -/// SPARC registers -typedef enum sparc_reg { - SPARC_REG_INVALID = 0, - - SPARC_REG_F0, - SPARC_REG_F1, - SPARC_REG_F2, - SPARC_REG_F3, - SPARC_REG_F4, - SPARC_REG_F5, - SPARC_REG_F6, - SPARC_REG_F7, - SPARC_REG_F8, - SPARC_REG_F9, - SPARC_REG_F10, - SPARC_REG_F11, - SPARC_REG_F12, - SPARC_REG_F13, - SPARC_REG_F14, - SPARC_REG_F15, - SPARC_REG_F16, - SPARC_REG_F17, - SPARC_REG_F18, - SPARC_REG_F19, - SPARC_REG_F20, - SPARC_REG_F21, - SPARC_REG_F22, - SPARC_REG_F23, - SPARC_REG_F24, - SPARC_REG_F25, - SPARC_REG_F26, - SPARC_REG_F27, - SPARC_REG_F28, - SPARC_REG_F29, - SPARC_REG_F30, - SPARC_REG_F31, - SPARC_REG_F32, - SPARC_REG_F34, - SPARC_REG_F36, - SPARC_REG_F38, - SPARC_REG_F40, - SPARC_REG_F42, - SPARC_REG_F44, - SPARC_REG_F46, - SPARC_REG_F48, - SPARC_REG_F50, - SPARC_REG_F52, - SPARC_REG_F54, - SPARC_REG_F56, - SPARC_REG_F58, - SPARC_REG_F60, - SPARC_REG_F62, - SPARC_REG_FCC0, // Floating condition codes - SPARC_REG_FCC1, - SPARC_REG_FCC2, - SPARC_REG_FCC3, - SPARC_REG_FP, - SPARC_REG_G0, - SPARC_REG_G1, - SPARC_REG_G2, - SPARC_REG_G3, - SPARC_REG_G4, - SPARC_REG_G5, - SPARC_REG_G6, - SPARC_REG_G7, - SPARC_REG_I0, - SPARC_REG_I1, - SPARC_REG_I2, - SPARC_REG_I3, - SPARC_REG_I4, - SPARC_REG_I5, - SPARC_REG_I7, - SPARC_REG_ICC, // Integer condition codes - SPARC_REG_L0, - SPARC_REG_L1, - SPARC_REG_L2, - SPARC_REG_L3, - SPARC_REG_L4, - SPARC_REG_L5, - SPARC_REG_L6, - SPARC_REG_L7, - SPARC_REG_O0, - SPARC_REG_O1, - SPARC_REG_O2, - SPARC_REG_O3, - SPARC_REG_O4, - SPARC_REG_O5, - SPARC_REG_O7, - SPARC_REG_SP, - SPARC_REG_Y, - - // special register - SPARC_REG_XCC, - - SPARC_REG_ENDING, // <-- mark the end of the list of registers - - // extras - SPARC_REG_O6 = SPARC_REG_SP, - SPARC_REG_I6 = SPARC_REG_FP, -} sparc_reg; - -/// Instruction's operand referring to memory -/// This is associated with SPARC_OP_MEM operand type above -typedef struct sparc_op_mem { - uint8_t base; ///< base register, can be safely interpreted as - ///< a value of type `sparc_reg`, but it is only - ///< one byte wide - uint8_t index; ///< index register, same conditions apply here - int32_t disp; ///< displacement/offset value -} sparc_op_mem; - -/// Instruction operand -typedef struct cs_sparc_op { - sparc_op_type type; ///< operand type - union { - sparc_reg reg; ///< register value for REG operand - int64_t imm; ///< immediate value for IMM operand - sparc_op_mem mem; ///< base/disp value for MEM operand - }; -} cs_sparc_op; - -/// Instruction structure -typedef struct cs_sparc { - sparc_cc cc; ///< code condition for this insn - sparc_hint hint; ///< branch hint: encoding as bitwise OR of sparc_hint. - /// Number of operands of this instruction, - /// or 0 when instruction has no operand. - uint8_t op_count; - cs_sparc_op operands[4]; ///< operands for this instruction. -} cs_sparc; - -/// SPARC instruction -typedef enum sparc_insn { - SPARC_INS_INVALID = 0, - - SPARC_INS_ADDCC, - SPARC_INS_ADDX, - SPARC_INS_ADDXCC, - SPARC_INS_ADDXC, - SPARC_INS_ADDXCCC, - SPARC_INS_ADD, - SPARC_INS_ALIGNADDR, - SPARC_INS_ALIGNADDRL, - SPARC_INS_ANDCC, - SPARC_INS_ANDNCC, - SPARC_INS_ANDN, - SPARC_INS_AND, - SPARC_INS_ARRAY16, - SPARC_INS_ARRAY32, - SPARC_INS_ARRAY8, - SPARC_INS_B, - SPARC_INS_JMP, - SPARC_INS_BMASK, - SPARC_INS_FB, - SPARC_INS_BRGEZ, - SPARC_INS_BRGZ, - SPARC_INS_BRLEZ, - SPARC_INS_BRLZ, - SPARC_INS_BRNZ, - SPARC_INS_BRZ, - SPARC_INS_BSHUFFLE, - SPARC_INS_CALL, - SPARC_INS_CASX, - SPARC_INS_CAS, - SPARC_INS_CMASK16, - SPARC_INS_CMASK32, - SPARC_INS_CMASK8, - SPARC_INS_CMP, - SPARC_INS_EDGE16, - SPARC_INS_EDGE16L, - SPARC_INS_EDGE16LN, - SPARC_INS_EDGE16N, - SPARC_INS_EDGE32, - SPARC_INS_EDGE32L, - SPARC_INS_EDGE32LN, - SPARC_INS_EDGE32N, - SPARC_INS_EDGE8, - SPARC_INS_EDGE8L, - SPARC_INS_EDGE8LN, - SPARC_INS_EDGE8N, - SPARC_INS_FABSD, - SPARC_INS_FABSQ, - SPARC_INS_FABSS, - SPARC_INS_FADDD, - SPARC_INS_FADDQ, - SPARC_INS_FADDS, - SPARC_INS_FALIGNDATA, - SPARC_INS_FAND, - SPARC_INS_FANDNOT1, - SPARC_INS_FANDNOT1S, - SPARC_INS_FANDNOT2, - SPARC_INS_FANDNOT2S, - SPARC_INS_FANDS, - SPARC_INS_FCHKSM16, - SPARC_INS_FCMPD, - SPARC_INS_FCMPEQ16, - SPARC_INS_FCMPEQ32, - SPARC_INS_FCMPGT16, - SPARC_INS_FCMPGT32, - SPARC_INS_FCMPLE16, - SPARC_INS_FCMPLE32, - SPARC_INS_FCMPNE16, - SPARC_INS_FCMPNE32, - SPARC_INS_FCMPQ, - SPARC_INS_FCMPS, - SPARC_INS_FDIVD, - SPARC_INS_FDIVQ, - SPARC_INS_FDIVS, - SPARC_INS_FDMULQ, - SPARC_INS_FDTOI, - SPARC_INS_FDTOQ, - SPARC_INS_FDTOS, - SPARC_INS_FDTOX, - SPARC_INS_FEXPAND, - SPARC_INS_FHADDD, - SPARC_INS_FHADDS, - SPARC_INS_FHSUBD, - SPARC_INS_FHSUBS, - SPARC_INS_FITOD, - SPARC_INS_FITOQ, - SPARC_INS_FITOS, - SPARC_INS_FLCMPD, - SPARC_INS_FLCMPS, - SPARC_INS_FLUSHW, - SPARC_INS_FMEAN16, - SPARC_INS_FMOVD, - SPARC_INS_FMOVQ, - SPARC_INS_FMOVRDGEZ, - SPARC_INS_FMOVRQGEZ, - SPARC_INS_FMOVRSGEZ, - SPARC_INS_FMOVRDGZ, - SPARC_INS_FMOVRQGZ, - SPARC_INS_FMOVRSGZ, - SPARC_INS_FMOVRDLEZ, - SPARC_INS_FMOVRQLEZ, - SPARC_INS_FMOVRSLEZ, - SPARC_INS_FMOVRDLZ, - SPARC_INS_FMOVRQLZ, - SPARC_INS_FMOVRSLZ, - SPARC_INS_FMOVRDNZ, - SPARC_INS_FMOVRQNZ, - SPARC_INS_FMOVRSNZ, - SPARC_INS_FMOVRDZ, - SPARC_INS_FMOVRQZ, - SPARC_INS_FMOVRSZ, - SPARC_INS_FMOVS, - SPARC_INS_FMUL8SUX16, - SPARC_INS_FMUL8ULX16, - SPARC_INS_FMUL8X16, - SPARC_INS_FMUL8X16AL, - SPARC_INS_FMUL8X16AU, - SPARC_INS_FMULD, - SPARC_INS_FMULD8SUX16, - SPARC_INS_FMULD8ULX16, - SPARC_INS_FMULQ, - SPARC_INS_FMULS, - SPARC_INS_FNADDD, - SPARC_INS_FNADDS, - SPARC_INS_FNAND, - SPARC_INS_FNANDS, - SPARC_INS_FNEGD, - SPARC_INS_FNEGQ, - SPARC_INS_FNEGS, - SPARC_INS_FNHADDD, - SPARC_INS_FNHADDS, - SPARC_INS_FNOR, - SPARC_INS_FNORS, - SPARC_INS_FNOT1, - SPARC_INS_FNOT1S, - SPARC_INS_FNOT2, - SPARC_INS_FNOT2S, - SPARC_INS_FONE, - SPARC_INS_FONES, - SPARC_INS_FOR, - SPARC_INS_FORNOT1, - SPARC_INS_FORNOT1S, - SPARC_INS_FORNOT2, - SPARC_INS_FORNOT2S, - SPARC_INS_FORS, - SPARC_INS_FPACK16, - SPARC_INS_FPACK32, - SPARC_INS_FPACKFIX, - SPARC_INS_FPADD16, - SPARC_INS_FPADD16S, - SPARC_INS_FPADD32, - SPARC_INS_FPADD32S, - SPARC_INS_FPADD64, - SPARC_INS_FPMERGE, - SPARC_INS_FPSUB16, - SPARC_INS_FPSUB16S, - SPARC_INS_FPSUB32, - SPARC_INS_FPSUB32S, - SPARC_INS_FQTOD, - SPARC_INS_FQTOI, - SPARC_INS_FQTOS, - SPARC_INS_FQTOX, - SPARC_INS_FSLAS16, - SPARC_INS_FSLAS32, - SPARC_INS_FSLL16, - SPARC_INS_FSLL32, - SPARC_INS_FSMULD, - SPARC_INS_FSQRTD, - SPARC_INS_FSQRTQ, - SPARC_INS_FSQRTS, - SPARC_INS_FSRA16, - SPARC_INS_FSRA32, - SPARC_INS_FSRC1, - SPARC_INS_FSRC1S, - SPARC_INS_FSRC2, - SPARC_INS_FSRC2S, - SPARC_INS_FSRL16, - SPARC_INS_FSRL32, - SPARC_INS_FSTOD, - SPARC_INS_FSTOI, - SPARC_INS_FSTOQ, - SPARC_INS_FSTOX, - SPARC_INS_FSUBD, - SPARC_INS_FSUBQ, - SPARC_INS_FSUBS, - SPARC_INS_FXNOR, - SPARC_INS_FXNORS, - SPARC_INS_FXOR, - SPARC_INS_FXORS, - SPARC_INS_FXTOD, - SPARC_INS_FXTOQ, - SPARC_INS_FXTOS, - SPARC_INS_FZERO, - SPARC_INS_FZEROS, - SPARC_INS_JMPL, - SPARC_INS_LDD, - SPARC_INS_LD, - SPARC_INS_LDQ, - SPARC_INS_LDSB, - SPARC_INS_LDSH, - SPARC_INS_LDSW, - SPARC_INS_LDUB, - SPARC_INS_LDUH, - SPARC_INS_LDX, - SPARC_INS_LZCNT, - SPARC_INS_MEMBAR, - SPARC_INS_MOVDTOX, - SPARC_INS_MOV, - SPARC_INS_MOVRGEZ, - SPARC_INS_MOVRGZ, - SPARC_INS_MOVRLEZ, - SPARC_INS_MOVRLZ, - SPARC_INS_MOVRNZ, - SPARC_INS_MOVRZ, - SPARC_INS_MOVSTOSW, - SPARC_INS_MOVSTOUW, - SPARC_INS_MULX, - SPARC_INS_NOP, - SPARC_INS_ORCC, - SPARC_INS_ORNCC, - SPARC_INS_ORN, - SPARC_INS_OR, - SPARC_INS_PDIST, - SPARC_INS_PDISTN, - SPARC_INS_POPC, - SPARC_INS_RD, - SPARC_INS_RESTORE, - SPARC_INS_RETT, - SPARC_INS_SAVE, - SPARC_INS_SDIVCC, - SPARC_INS_SDIVX, - SPARC_INS_SDIV, - SPARC_INS_SETHI, - SPARC_INS_SHUTDOWN, - SPARC_INS_SIAM, - SPARC_INS_SLLX, - SPARC_INS_SLL, - SPARC_INS_SMULCC, - SPARC_INS_SMUL, - SPARC_INS_SRAX, - SPARC_INS_SRA, - SPARC_INS_SRLX, - SPARC_INS_SRL, - SPARC_INS_STBAR, - SPARC_INS_STB, - SPARC_INS_STD, - SPARC_INS_ST, - SPARC_INS_STH, - SPARC_INS_STQ, - SPARC_INS_STX, - SPARC_INS_SUBCC, - SPARC_INS_SUBX, - SPARC_INS_SUBXCC, - SPARC_INS_SUB, - SPARC_INS_SWAP, - SPARC_INS_TADDCCTV, - SPARC_INS_TADDCC, - SPARC_INS_T, - SPARC_INS_TSUBCCTV, - SPARC_INS_TSUBCC, - SPARC_INS_UDIVCC, - SPARC_INS_UDIVX, - SPARC_INS_UDIV, - SPARC_INS_UMULCC, - SPARC_INS_UMULXHI, - SPARC_INS_UMUL, - SPARC_INS_UNIMP, - SPARC_INS_FCMPED, - SPARC_INS_FCMPEQ, - SPARC_INS_FCMPES, - SPARC_INS_WR, - SPARC_INS_XMULX, - SPARC_INS_XMULXHI, - SPARC_INS_XNORCC, - SPARC_INS_XNOR, - SPARC_INS_XORCC, - SPARC_INS_XOR, - - // alias instructions - SPARC_INS_RET, - SPARC_INS_RETL, - - SPARC_INS_ENDING, // <-- mark the end of the list of instructions -} sparc_insn; - -/// Group of SPARC instructions -typedef enum sparc_insn_group { - SPARC_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - // Generic groups - // all jump instructions (conditional+direct+indirect jumps) - SPARC_GRP_JUMP, ///< = CS_GRP_JUMP - - // Architecture-specific groups - SPARC_GRP_HARDQUAD = 128, - SPARC_GRP_V9, - SPARC_GRP_VIS, - SPARC_GRP_VIS2, - SPARC_GRP_VIS3, - SPARC_GRP_32BIT, - SPARC_GRP_64BIT, - - SPARC_GRP_ENDING, // <-- mark the end of the list of groups -} sparc_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_SYSTEMZ_H -#define CAPSTONE_SYSTEMZ_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2014-2015 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// Enums corresponding to SystemZ condition codes -typedef enum sysz_cc { - SYSZ_CC_INVALID = 0, ///< invalid CC (default) - - SYSZ_CC_O, - SYSZ_CC_H, - SYSZ_CC_NLE, - SYSZ_CC_L, - SYSZ_CC_NHE, - SYSZ_CC_LH, - SYSZ_CC_NE, - SYSZ_CC_E, - SYSZ_CC_NLH, - SYSZ_CC_HE, - SYSZ_CC_NL, - SYSZ_CC_LE, - SYSZ_CC_NH, - SYSZ_CC_NO, -} sysz_cc; - -/// Operand type for instruction's operands -typedef enum sysz_op_type { - SYSZ_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - SYSZ_OP_REG, ///< = CS_OP_REG (Register operand). - SYSZ_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - SYSZ_OP_MEM, ///< = CS_OP_MEM (Memory operand). - SYSZ_OP_ACREG = 64, ///< Access register operand. -} sysz_op_type; - -/// SystemZ registers -typedef enum sysz_reg { - SYSZ_REG_INVALID = 0, - - SYSZ_REG_0, - SYSZ_REG_1, - SYSZ_REG_2, - SYSZ_REG_3, - SYSZ_REG_4, - SYSZ_REG_5, - SYSZ_REG_6, - SYSZ_REG_7, - SYSZ_REG_8, - SYSZ_REG_9, - SYSZ_REG_10, - SYSZ_REG_11, - SYSZ_REG_12, - SYSZ_REG_13, - SYSZ_REG_14, - SYSZ_REG_15, - SYSZ_REG_CC, - SYSZ_REG_F0, - SYSZ_REG_F1, - SYSZ_REG_F2, - SYSZ_REG_F3, - SYSZ_REG_F4, - SYSZ_REG_F5, - SYSZ_REG_F6, - SYSZ_REG_F7, - SYSZ_REG_F8, - SYSZ_REG_F9, - SYSZ_REG_F10, - SYSZ_REG_F11, - SYSZ_REG_F12, - SYSZ_REG_F13, - SYSZ_REG_F14, - SYSZ_REG_F15, - - SYSZ_REG_R0L, - - SYSZ_REG_A0, - SYSZ_REG_A1, - SYSZ_REG_A2, - SYSZ_REG_A3, - SYSZ_REG_A4, - SYSZ_REG_A5, - SYSZ_REG_A6, - SYSZ_REG_A7, - SYSZ_REG_A8, - SYSZ_REG_A9, - SYSZ_REG_A10, - SYSZ_REG_A11, - SYSZ_REG_A12, - SYSZ_REG_A13, - SYSZ_REG_A14, - SYSZ_REG_A15, - SYSZ_REG_C0, - SYSZ_REG_C1, - SYSZ_REG_C2, - SYSZ_REG_C3, - SYSZ_REG_C4, - SYSZ_REG_C5, - SYSZ_REG_C6, - SYSZ_REG_C7, - SYSZ_REG_C8, - SYSZ_REG_C9, - SYSZ_REG_C10, - SYSZ_REG_C11, - SYSZ_REG_C12, - SYSZ_REG_C13, - SYSZ_REG_C14, - SYSZ_REG_C15, - SYSZ_REG_V0, - SYSZ_REG_V1, - SYSZ_REG_V2, - SYSZ_REG_V3, - SYSZ_REG_V4, - SYSZ_REG_V5, - SYSZ_REG_V6, - SYSZ_REG_V7, - SYSZ_REG_V8, - SYSZ_REG_V9, - SYSZ_REG_V10, - SYSZ_REG_V11, - SYSZ_REG_V12, - SYSZ_REG_V13, - SYSZ_REG_V14, - SYSZ_REG_V15, - SYSZ_REG_V16, - SYSZ_REG_V17, - SYSZ_REG_V18, - SYSZ_REG_V19, - SYSZ_REG_V20, - SYSZ_REG_V21, - SYSZ_REG_V22, - SYSZ_REG_V23, - SYSZ_REG_V24, - SYSZ_REG_V25, - SYSZ_REG_V26, - SYSZ_REG_V27, - SYSZ_REG_V28, - SYSZ_REG_V29, - SYSZ_REG_V30, - SYSZ_REG_V31, - SYSZ_REG_F16, - SYSZ_REG_F17, - SYSZ_REG_F18, - SYSZ_REG_F19, - SYSZ_REG_F20, - SYSZ_REG_F21, - SYSZ_REG_F22, - SYSZ_REG_F23, - SYSZ_REG_F24, - SYSZ_REG_F25, - SYSZ_REG_F26, - SYSZ_REG_F27, - SYSZ_REG_F28, - SYSZ_REG_F29, - SYSZ_REG_F30, - SYSZ_REG_F31, - SYSZ_REG_F0Q, - SYSZ_REG_F4Q, - - SYSZ_REG_ENDING, -} sysz_reg; - -/// Instruction's operand referring to memory -/// This is associated with SYSZ_OP_MEM operand type above -typedef struct sysz_op_mem { - uint8_t base; ///< base register, can be safely interpreted as - ///< a value of type `sysz_reg`, but it is only - ///< one byte wide - uint8_t index; ///< index register, same conditions apply here - uint64_t length; ///< BDLAddr operand - int64_t disp; ///< displacement/offset value -} sysz_op_mem; - -/// Instruction operand -typedef struct cs_sysz_op { - sysz_op_type type; ///< operand type - union { - sysz_reg reg; ///< register value for REG operand - int64_t imm; ///< immediate value for IMM operand - sysz_op_mem mem; ///< base/disp value for MEM operand - }; -} cs_sysz_op; - -// Instruction structure -typedef struct cs_sysz { - sysz_cc cc; ///< Code condition - /// Number of operands of this instruction, - /// or 0 when instruction has no operand. - uint8_t op_count; - cs_sysz_op operands[6]; ///< operands for this instruction. -} cs_sysz; - -/// SystemZ instruction -typedef enum sysz_insn { - SYSZ_INS_INVALID = 0, - - SYSZ_INS_A, - SYSZ_INS_ADB, - SYSZ_INS_ADBR, - SYSZ_INS_AEB, - SYSZ_INS_AEBR, - SYSZ_INS_AFI, - SYSZ_INS_AG, - SYSZ_INS_AGF, - SYSZ_INS_AGFI, - SYSZ_INS_AGFR, - SYSZ_INS_AGHI, - SYSZ_INS_AGHIK, - SYSZ_INS_AGR, - SYSZ_INS_AGRK, - SYSZ_INS_AGSI, - SYSZ_INS_AH, - SYSZ_INS_AHI, - SYSZ_INS_AHIK, - SYSZ_INS_AHY, - SYSZ_INS_AIH, - SYSZ_INS_AL, - SYSZ_INS_ALC, - SYSZ_INS_ALCG, - SYSZ_INS_ALCGR, - SYSZ_INS_ALCR, - SYSZ_INS_ALFI, - SYSZ_INS_ALG, - SYSZ_INS_ALGF, - SYSZ_INS_ALGFI, - SYSZ_INS_ALGFR, - SYSZ_INS_ALGHSIK, - SYSZ_INS_ALGR, - SYSZ_INS_ALGRK, - SYSZ_INS_ALHSIK, - SYSZ_INS_ALR, - SYSZ_INS_ALRK, - SYSZ_INS_ALY, - SYSZ_INS_AR, - SYSZ_INS_ARK, - SYSZ_INS_ASI, - SYSZ_INS_AXBR, - SYSZ_INS_AY, - SYSZ_INS_BCR, - SYSZ_INS_BRC, - SYSZ_INS_BRCL, - SYSZ_INS_CGIJ, - SYSZ_INS_CGRJ, - SYSZ_INS_CIJ, - SYSZ_INS_CLGIJ, - SYSZ_INS_CLGRJ, - SYSZ_INS_CLIJ, - SYSZ_INS_CLRJ, - SYSZ_INS_CRJ, - SYSZ_INS_BER, - SYSZ_INS_JE, - SYSZ_INS_JGE, - SYSZ_INS_LOCE, - SYSZ_INS_LOCGE, - SYSZ_INS_LOCGRE, - SYSZ_INS_LOCRE, - SYSZ_INS_STOCE, - SYSZ_INS_STOCGE, - SYSZ_INS_BHR, - SYSZ_INS_BHER, - SYSZ_INS_JHE, - SYSZ_INS_JGHE, - SYSZ_INS_LOCHE, - SYSZ_INS_LOCGHE, - SYSZ_INS_LOCGRHE, - SYSZ_INS_LOCRHE, - SYSZ_INS_STOCHE, - SYSZ_INS_STOCGHE, - SYSZ_INS_JH, - SYSZ_INS_JGH, - SYSZ_INS_LOCH, - SYSZ_INS_LOCGH, - SYSZ_INS_LOCGRH, - SYSZ_INS_LOCRH, - SYSZ_INS_STOCH, - SYSZ_INS_STOCGH, - SYSZ_INS_CGIJNLH, - SYSZ_INS_CGRJNLH, - SYSZ_INS_CIJNLH, - SYSZ_INS_CLGIJNLH, - SYSZ_INS_CLGRJNLH, - SYSZ_INS_CLIJNLH, - SYSZ_INS_CLRJNLH, - SYSZ_INS_CRJNLH, - SYSZ_INS_CGIJE, - SYSZ_INS_CGRJE, - SYSZ_INS_CIJE, - SYSZ_INS_CLGIJE, - SYSZ_INS_CLGRJE, - SYSZ_INS_CLIJE, - SYSZ_INS_CLRJE, - SYSZ_INS_CRJE, - SYSZ_INS_CGIJNLE, - SYSZ_INS_CGRJNLE, - SYSZ_INS_CIJNLE, - SYSZ_INS_CLGIJNLE, - SYSZ_INS_CLGRJNLE, - SYSZ_INS_CLIJNLE, - SYSZ_INS_CLRJNLE, - SYSZ_INS_CRJNLE, - SYSZ_INS_CGIJH, - SYSZ_INS_CGRJH, - SYSZ_INS_CIJH, - SYSZ_INS_CLGIJH, - SYSZ_INS_CLGRJH, - SYSZ_INS_CLIJH, - SYSZ_INS_CLRJH, - SYSZ_INS_CRJH, - SYSZ_INS_CGIJNL, - SYSZ_INS_CGRJNL, - SYSZ_INS_CIJNL, - SYSZ_INS_CLGIJNL, - SYSZ_INS_CLGRJNL, - SYSZ_INS_CLIJNL, - SYSZ_INS_CLRJNL, - SYSZ_INS_CRJNL, - SYSZ_INS_CGIJHE, - SYSZ_INS_CGRJHE, - SYSZ_INS_CIJHE, - SYSZ_INS_CLGIJHE, - SYSZ_INS_CLGRJHE, - SYSZ_INS_CLIJHE, - SYSZ_INS_CLRJHE, - SYSZ_INS_CRJHE, - SYSZ_INS_CGIJNHE, - SYSZ_INS_CGRJNHE, - SYSZ_INS_CIJNHE, - SYSZ_INS_CLGIJNHE, - SYSZ_INS_CLGRJNHE, - SYSZ_INS_CLIJNHE, - SYSZ_INS_CLRJNHE, - SYSZ_INS_CRJNHE, - SYSZ_INS_CGIJL, - SYSZ_INS_CGRJL, - SYSZ_INS_CIJL, - SYSZ_INS_CLGIJL, - SYSZ_INS_CLGRJL, - SYSZ_INS_CLIJL, - SYSZ_INS_CLRJL, - SYSZ_INS_CRJL, - SYSZ_INS_CGIJNH, - SYSZ_INS_CGRJNH, - SYSZ_INS_CIJNH, - SYSZ_INS_CLGIJNH, - SYSZ_INS_CLGRJNH, - SYSZ_INS_CLIJNH, - SYSZ_INS_CLRJNH, - SYSZ_INS_CRJNH, - SYSZ_INS_CGIJLE, - SYSZ_INS_CGRJLE, - SYSZ_INS_CIJLE, - SYSZ_INS_CLGIJLE, - SYSZ_INS_CLGRJLE, - SYSZ_INS_CLIJLE, - SYSZ_INS_CLRJLE, - SYSZ_INS_CRJLE, - SYSZ_INS_CGIJNE, - SYSZ_INS_CGRJNE, - SYSZ_INS_CIJNE, - SYSZ_INS_CLGIJNE, - SYSZ_INS_CLGRJNE, - SYSZ_INS_CLIJNE, - SYSZ_INS_CLRJNE, - SYSZ_INS_CRJNE, - SYSZ_INS_CGIJLH, - SYSZ_INS_CGRJLH, - SYSZ_INS_CIJLH, - SYSZ_INS_CLGIJLH, - SYSZ_INS_CLGRJLH, - SYSZ_INS_CLIJLH, - SYSZ_INS_CLRJLH, - SYSZ_INS_CRJLH, - SYSZ_INS_BLR, - SYSZ_INS_BLER, - SYSZ_INS_JLE, - SYSZ_INS_JGLE, - SYSZ_INS_LOCLE, - SYSZ_INS_LOCGLE, - SYSZ_INS_LOCGRLE, - SYSZ_INS_LOCRLE, - SYSZ_INS_STOCLE, - SYSZ_INS_STOCGLE, - SYSZ_INS_BLHR, - SYSZ_INS_JLH, - SYSZ_INS_JGLH, - SYSZ_INS_LOCLH, - SYSZ_INS_LOCGLH, - SYSZ_INS_LOCGRLH, - SYSZ_INS_LOCRLH, - SYSZ_INS_STOCLH, - SYSZ_INS_STOCGLH, - SYSZ_INS_JL, - SYSZ_INS_JGL, - SYSZ_INS_LOCL, - SYSZ_INS_LOCGL, - SYSZ_INS_LOCGRL, - SYSZ_INS_LOCRL, - SYSZ_INS_LOC, - SYSZ_INS_LOCG, - SYSZ_INS_LOCGR, - SYSZ_INS_LOCR, - SYSZ_INS_STOCL, - SYSZ_INS_STOCGL, - SYSZ_INS_BNER, - SYSZ_INS_JNE, - SYSZ_INS_JGNE, - SYSZ_INS_LOCNE, - SYSZ_INS_LOCGNE, - SYSZ_INS_LOCGRNE, - SYSZ_INS_LOCRNE, - SYSZ_INS_STOCNE, - SYSZ_INS_STOCGNE, - SYSZ_INS_BNHR, - SYSZ_INS_BNHER, - SYSZ_INS_JNHE, - SYSZ_INS_JGNHE, - SYSZ_INS_LOCNHE, - SYSZ_INS_LOCGNHE, - SYSZ_INS_LOCGRNHE, - SYSZ_INS_LOCRNHE, - SYSZ_INS_STOCNHE, - SYSZ_INS_STOCGNHE, - SYSZ_INS_JNH, - SYSZ_INS_JGNH, - SYSZ_INS_LOCNH, - SYSZ_INS_LOCGNH, - SYSZ_INS_LOCGRNH, - SYSZ_INS_LOCRNH, - SYSZ_INS_STOCNH, - SYSZ_INS_STOCGNH, - SYSZ_INS_BNLR, - SYSZ_INS_BNLER, - SYSZ_INS_JNLE, - SYSZ_INS_JGNLE, - SYSZ_INS_LOCNLE, - SYSZ_INS_LOCGNLE, - SYSZ_INS_LOCGRNLE, - SYSZ_INS_LOCRNLE, - SYSZ_INS_STOCNLE, - SYSZ_INS_STOCGNLE, - SYSZ_INS_BNLHR, - SYSZ_INS_JNLH, - SYSZ_INS_JGNLH, - SYSZ_INS_LOCNLH, - SYSZ_INS_LOCGNLH, - SYSZ_INS_LOCGRNLH, - SYSZ_INS_LOCRNLH, - SYSZ_INS_STOCNLH, - SYSZ_INS_STOCGNLH, - SYSZ_INS_JNL, - SYSZ_INS_JGNL, - SYSZ_INS_LOCNL, - SYSZ_INS_LOCGNL, - SYSZ_INS_LOCGRNL, - SYSZ_INS_LOCRNL, - SYSZ_INS_STOCNL, - SYSZ_INS_STOCGNL, - SYSZ_INS_BNOR, - SYSZ_INS_JNO, - SYSZ_INS_JGNO, - SYSZ_INS_LOCNO, - SYSZ_INS_LOCGNO, - SYSZ_INS_LOCGRNO, - SYSZ_INS_LOCRNO, - SYSZ_INS_STOCNO, - SYSZ_INS_STOCGNO, - SYSZ_INS_BOR, - SYSZ_INS_JO, - SYSZ_INS_JGO, - SYSZ_INS_LOCO, - SYSZ_INS_LOCGO, - SYSZ_INS_LOCGRO, - SYSZ_INS_LOCRO, - SYSZ_INS_STOCO, - SYSZ_INS_STOCGO, - SYSZ_INS_STOC, - SYSZ_INS_STOCG, - SYSZ_INS_BASR, - SYSZ_INS_BR, - SYSZ_INS_BRAS, - SYSZ_INS_BRASL, - SYSZ_INS_J, - SYSZ_INS_JG, - SYSZ_INS_BRCT, - SYSZ_INS_BRCTG, - SYSZ_INS_C, - SYSZ_INS_CDB, - SYSZ_INS_CDBR, - SYSZ_INS_CDFBR, - SYSZ_INS_CDGBR, - SYSZ_INS_CDLFBR, - SYSZ_INS_CDLGBR, - SYSZ_INS_CEB, - SYSZ_INS_CEBR, - SYSZ_INS_CEFBR, - SYSZ_INS_CEGBR, - SYSZ_INS_CELFBR, - SYSZ_INS_CELGBR, - SYSZ_INS_CFDBR, - SYSZ_INS_CFEBR, - SYSZ_INS_CFI, - SYSZ_INS_CFXBR, - SYSZ_INS_CG, - SYSZ_INS_CGDBR, - SYSZ_INS_CGEBR, - SYSZ_INS_CGF, - SYSZ_INS_CGFI, - SYSZ_INS_CGFR, - SYSZ_INS_CGFRL, - SYSZ_INS_CGH, - SYSZ_INS_CGHI, - SYSZ_INS_CGHRL, - SYSZ_INS_CGHSI, - SYSZ_INS_CGR, - SYSZ_INS_CGRL, - SYSZ_INS_CGXBR, - SYSZ_INS_CH, - SYSZ_INS_CHF, - SYSZ_INS_CHHSI, - SYSZ_INS_CHI, - SYSZ_INS_CHRL, - SYSZ_INS_CHSI, - SYSZ_INS_CHY, - SYSZ_INS_CIH, - SYSZ_INS_CL, - SYSZ_INS_CLC, - SYSZ_INS_CLFDBR, - SYSZ_INS_CLFEBR, - SYSZ_INS_CLFHSI, - SYSZ_INS_CLFI, - SYSZ_INS_CLFXBR, - SYSZ_INS_CLG, - SYSZ_INS_CLGDBR, - SYSZ_INS_CLGEBR, - SYSZ_INS_CLGF, - SYSZ_INS_CLGFI, - SYSZ_INS_CLGFR, - SYSZ_INS_CLGFRL, - SYSZ_INS_CLGHRL, - SYSZ_INS_CLGHSI, - SYSZ_INS_CLGR, - SYSZ_INS_CLGRL, - SYSZ_INS_CLGXBR, - SYSZ_INS_CLHF, - SYSZ_INS_CLHHSI, - SYSZ_INS_CLHRL, - SYSZ_INS_CLI, - SYSZ_INS_CLIH, - SYSZ_INS_CLIY, - SYSZ_INS_CLR, - SYSZ_INS_CLRL, - SYSZ_INS_CLST, - SYSZ_INS_CLY, - SYSZ_INS_CPSDR, - SYSZ_INS_CR, - SYSZ_INS_CRL, - SYSZ_INS_CS, - SYSZ_INS_CSG, - SYSZ_INS_CSY, - SYSZ_INS_CXBR, - SYSZ_INS_CXFBR, - SYSZ_INS_CXGBR, - SYSZ_INS_CXLFBR, - SYSZ_INS_CXLGBR, - SYSZ_INS_CY, - SYSZ_INS_DDB, - SYSZ_INS_DDBR, - SYSZ_INS_DEB, - SYSZ_INS_DEBR, - SYSZ_INS_DL, - SYSZ_INS_DLG, - SYSZ_INS_DLGR, - SYSZ_INS_DLR, - SYSZ_INS_DSG, - SYSZ_INS_DSGF, - SYSZ_INS_DSGFR, - SYSZ_INS_DSGR, - SYSZ_INS_DXBR, - SYSZ_INS_EAR, - SYSZ_INS_FIDBR, - SYSZ_INS_FIDBRA, - SYSZ_INS_FIEBR, - SYSZ_INS_FIEBRA, - SYSZ_INS_FIXBR, - SYSZ_INS_FIXBRA, - SYSZ_INS_FLOGR, - SYSZ_INS_IC, - SYSZ_INS_ICY, - SYSZ_INS_IIHF, - SYSZ_INS_IIHH, - SYSZ_INS_IIHL, - SYSZ_INS_IILF, - SYSZ_INS_IILH, - SYSZ_INS_IILL, - SYSZ_INS_IPM, - SYSZ_INS_L, - SYSZ_INS_LA, - SYSZ_INS_LAA, - SYSZ_INS_LAAG, - SYSZ_INS_LAAL, - SYSZ_INS_LAALG, - SYSZ_INS_LAN, - SYSZ_INS_LANG, - SYSZ_INS_LAO, - SYSZ_INS_LAOG, - SYSZ_INS_LARL, - SYSZ_INS_LAX, - SYSZ_INS_LAXG, - SYSZ_INS_LAY, - SYSZ_INS_LB, - SYSZ_INS_LBH, - SYSZ_INS_LBR, - SYSZ_INS_LCDBR, - SYSZ_INS_LCEBR, - SYSZ_INS_LCGFR, - SYSZ_INS_LCGR, - SYSZ_INS_LCR, - SYSZ_INS_LCXBR, - SYSZ_INS_LD, - SYSZ_INS_LDEB, - SYSZ_INS_LDEBR, - SYSZ_INS_LDGR, - SYSZ_INS_LDR, - SYSZ_INS_LDXBR, - SYSZ_INS_LDXBRA, - SYSZ_INS_LDY, - SYSZ_INS_LE, - SYSZ_INS_LEDBR, - SYSZ_INS_LEDBRA, - SYSZ_INS_LER, - SYSZ_INS_LEXBR, - SYSZ_INS_LEXBRA, - SYSZ_INS_LEY, - SYSZ_INS_LFH, - SYSZ_INS_LG, - SYSZ_INS_LGB, - SYSZ_INS_LGBR, - SYSZ_INS_LGDR, - SYSZ_INS_LGF, - SYSZ_INS_LGFI, - SYSZ_INS_LGFR, - SYSZ_INS_LGFRL, - SYSZ_INS_LGH, - SYSZ_INS_LGHI, - SYSZ_INS_LGHR, - SYSZ_INS_LGHRL, - SYSZ_INS_LGR, - SYSZ_INS_LGRL, - SYSZ_INS_LH, - SYSZ_INS_LHH, - SYSZ_INS_LHI, - SYSZ_INS_LHR, - SYSZ_INS_LHRL, - SYSZ_INS_LHY, - SYSZ_INS_LLC, - SYSZ_INS_LLCH, - SYSZ_INS_LLCR, - SYSZ_INS_LLGC, - SYSZ_INS_LLGCR, - SYSZ_INS_LLGF, - SYSZ_INS_LLGFR, - SYSZ_INS_LLGFRL, - SYSZ_INS_LLGH, - SYSZ_INS_LLGHR, - SYSZ_INS_LLGHRL, - SYSZ_INS_LLH, - SYSZ_INS_LLHH, - SYSZ_INS_LLHR, - SYSZ_INS_LLHRL, - SYSZ_INS_LLIHF, - SYSZ_INS_LLIHH, - SYSZ_INS_LLIHL, - SYSZ_INS_LLILF, - SYSZ_INS_LLILH, - SYSZ_INS_LLILL, - SYSZ_INS_LMG, - SYSZ_INS_LNDBR, - SYSZ_INS_LNEBR, - SYSZ_INS_LNGFR, - SYSZ_INS_LNGR, - SYSZ_INS_LNR, - SYSZ_INS_LNXBR, - SYSZ_INS_LPDBR, - SYSZ_INS_LPEBR, - SYSZ_INS_LPGFR, - SYSZ_INS_LPGR, - SYSZ_INS_LPR, - SYSZ_INS_LPXBR, - SYSZ_INS_LR, - SYSZ_INS_LRL, - SYSZ_INS_LRV, - SYSZ_INS_LRVG, - SYSZ_INS_LRVGR, - SYSZ_INS_LRVR, - SYSZ_INS_LT, - SYSZ_INS_LTDBR, - SYSZ_INS_LTEBR, - SYSZ_INS_LTG, - SYSZ_INS_LTGF, - SYSZ_INS_LTGFR, - SYSZ_INS_LTGR, - SYSZ_INS_LTR, - SYSZ_INS_LTXBR, - SYSZ_INS_LXDB, - SYSZ_INS_LXDBR, - SYSZ_INS_LXEB, - SYSZ_INS_LXEBR, - SYSZ_INS_LXR, - SYSZ_INS_LY, - SYSZ_INS_LZDR, - SYSZ_INS_LZER, - SYSZ_INS_LZXR, - SYSZ_INS_MADB, - SYSZ_INS_MADBR, - SYSZ_INS_MAEB, - SYSZ_INS_MAEBR, - SYSZ_INS_MDB, - SYSZ_INS_MDBR, - SYSZ_INS_MDEB, - SYSZ_INS_MDEBR, - SYSZ_INS_MEEB, - SYSZ_INS_MEEBR, - SYSZ_INS_MGHI, - SYSZ_INS_MH, - SYSZ_INS_MHI, - SYSZ_INS_MHY, - SYSZ_INS_MLG, - SYSZ_INS_MLGR, - SYSZ_INS_MS, - SYSZ_INS_MSDB, - SYSZ_INS_MSDBR, - SYSZ_INS_MSEB, - SYSZ_INS_MSEBR, - SYSZ_INS_MSFI, - SYSZ_INS_MSG, - SYSZ_INS_MSGF, - SYSZ_INS_MSGFI, - SYSZ_INS_MSGFR, - SYSZ_INS_MSGR, - SYSZ_INS_MSR, - SYSZ_INS_MSY, - SYSZ_INS_MVC, - SYSZ_INS_MVGHI, - SYSZ_INS_MVHHI, - SYSZ_INS_MVHI, - SYSZ_INS_MVI, - SYSZ_INS_MVIY, - SYSZ_INS_MVST, - SYSZ_INS_MXBR, - SYSZ_INS_MXDB, - SYSZ_INS_MXDBR, - SYSZ_INS_N, - SYSZ_INS_NC, - SYSZ_INS_NG, - SYSZ_INS_NGR, - SYSZ_INS_NGRK, - SYSZ_INS_NI, - SYSZ_INS_NIHF, - SYSZ_INS_NIHH, - SYSZ_INS_NIHL, - SYSZ_INS_NILF, - SYSZ_INS_NILH, - SYSZ_INS_NILL, - SYSZ_INS_NIY, - SYSZ_INS_NR, - SYSZ_INS_NRK, - SYSZ_INS_NY, - SYSZ_INS_O, - SYSZ_INS_OC, - SYSZ_INS_OG, - SYSZ_INS_OGR, - SYSZ_INS_OGRK, - SYSZ_INS_OI, - SYSZ_INS_OIHF, - SYSZ_INS_OIHH, - SYSZ_INS_OIHL, - SYSZ_INS_OILF, - SYSZ_INS_OILH, - SYSZ_INS_OILL, - SYSZ_INS_OIY, - SYSZ_INS_OR, - SYSZ_INS_ORK, - SYSZ_INS_OY, - SYSZ_INS_PFD, - SYSZ_INS_PFDRL, - SYSZ_INS_RISBG, - SYSZ_INS_RISBHG, - SYSZ_INS_RISBLG, - SYSZ_INS_RLL, - SYSZ_INS_RLLG, - SYSZ_INS_RNSBG, - SYSZ_INS_ROSBG, - SYSZ_INS_RXSBG, - SYSZ_INS_S, - SYSZ_INS_SDB, - SYSZ_INS_SDBR, - SYSZ_INS_SEB, - SYSZ_INS_SEBR, - SYSZ_INS_SG, - SYSZ_INS_SGF, - SYSZ_INS_SGFR, - SYSZ_INS_SGR, - SYSZ_INS_SGRK, - SYSZ_INS_SH, - SYSZ_INS_SHY, - SYSZ_INS_SL, - SYSZ_INS_SLB, - SYSZ_INS_SLBG, - SYSZ_INS_SLBR, - SYSZ_INS_SLFI, - SYSZ_INS_SLG, - SYSZ_INS_SLBGR, - SYSZ_INS_SLGF, - SYSZ_INS_SLGFI, - SYSZ_INS_SLGFR, - SYSZ_INS_SLGR, - SYSZ_INS_SLGRK, - SYSZ_INS_SLL, - SYSZ_INS_SLLG, - SYSZ_INS_SLLK, - SYSZ_INS_SLR, - SYSZ_INS_SLRK, - SYSZ_INS_SLY, - SYSZ_INS_SQDB, - SYSZ_INS_SQDBR, - SYSZ_INS_SQEB, - SYSZ_INS_SQEBR, - SYSZ_INS_SQXBR, - SYSZ_INS_SR, - SYSZ_INS_SRA, - SYSZ_INS_SRAG, - SYSZ_INS_SRAK, - SYSZ_INS_SRK, - SYSZ_INS_SRL, - SYSZ_INS_SRLG, - SYSZ_INS_SRLK, - SYSZ_INS_SRST, - SYSZ_INS_ST, - SYSZ_INS_STC, - SYSZ_INS_STCH, - SYSZ_INS_STCY, - SYSZ_INS_STD, - SYSZ_INS_STDY, - SYSZ_INS_STE, - SYSZ_INS_STEY, - SYSZ_INS_STFH, - SYSZ_INS_STG, - SYSZ_INS_STGRL, - SYSZ_INS_STH, - SYSZ_INS_STHH, - SYSZ_INS_STHRL, - SYSZ_INS_STHY, - SYSZ_INS_STMG, - SYSZ_INS_STRL, - SYSZ_INS_STRV, - SYSZ_INS_STRVG, - SYSZ_INS_STY, - SYSZ_INS_SXBR, - SYSZ_INS_SY, - SYSZ_INS_TM, - SYSZ_INS_TMHH, - SYSZ_INS_TMHL, - SYSZ_INS_TMLH, - SYSZ_INS_TMLL, - SYSZ_INS_TMY, - SYSZ_INS_X, - SYSZ_INS_XC, - SYSZ_INS_XG, - SYSZ_INS_XGR, - SYSZ_INS_XGRK, - SYSZ_INS_XI, - SYSZ_INS_XIHF, - SYSZ_INS_XILF, - SYSZ_INS_XIY, - SYSZ_INS_XR, - SYSZ_INS_XRK, - SYSZ_INS_XY, - SYSZ_INS_AD, - SYSZ_INS_ADR, - SYSZ_INS_ADTR, - SYSZ_INS_ADTRA, - SYSZ_INS_AE, - SYSZ_INS_AER, - SYSZ_INS_AGH, - SYSZ_INS_AHHHR, - SYSZ_INS_AHHLR, - SYSZ_INS_ALGSI, - SYSZ_INS_ALHHHR, - SYSZ_INS_ALHHLR, - SYSZ_INS_ALSI, - SYSZ_INS_ALSIH, - SYSZ_INS_ALSIHN, - SYSZ_INS_AP, - SYSZ_INS_AU, - SYSZ_INS_AUR, - SYSZ_INS_AW, - SYSZ_INS_AWR, - SYSZ_INS_AXR, - SYSZ_INS_AXTR, - SYSZ_INS_AXTRA, - SYSZ_INS_B, - SYSZ_INS_BAKR, - SYSZ_INS_BAL, - SYSZ_INS_BALR, - SYSZ_INS_BAS, - SYSZ_INS_BASSM, - SYSZ_INS_BC, - SYSZ_INS_BCT, - SYSZ_INS_BCTG, - SYSZ_INS_BCTGR, - SYSZ_INS_BCTR, - SYSZ_INS_BE, - SYSZ_INS_BH, - SYSZ_INS_BHE, - SYSZ_INS_BI, - SYSZ_INS_BIC, - SYSZ_INS_BIE, - SYSZ_INS_BIH, - SYSZ_INS_BIHE, - SYSZ_INS_BIL, - SYSZ_INS_BILE, - SYSZ_INS_BILH, - SYSZ_INS_BIM, - SYSZ_INS_BINE, - SYSZ_INS_BINH, - SYSZ_INS_BINHE, - SYSZ_INS_BINL, - SYSZ_INS_BINLE, - SYSZ_INS_BINLH, - SYSZ_INS_BINM, - SYSZ_INS_BINO, - SYSZ_INS_BINP, - SYSZ_INS_BINZ, - SYSZ_INS_BIO, - SYSZ_INS_BIP, - SYSZ_INS_BIZ, - SYSZ_INS_BL, - SYSZ_INS_BLE, - SYSZ_INS_BLH, - SYSZ_INS_BM, - SYSZ_INS_BMR, - SYSZ_INS_BNE, - SYSZ_INS_BNH, - SYSZ_INS_BNHE, - SYSZ_INS_BNL, - SYSZ_INS_BNLE, - SYSZ_INS_BNLH, - SYSZ_INS_BNM, - SYSZ_INS_BNMR, - SYSZ_INS_BNO, - SYSZ_INS_BNP, - SYSZ_INS_BNPR, - SYSZ_INS_BNZ, - SYSZ_INS_BNZR, - SYSZ_INS_BO, - SYSZ_INS_BP, - SYSZ_INS_BPP, - SYSZ_INS_BPR, - SYSZ_INS_BPRP, - SYSZ_INS_BRCTH, - SYSZ_INS_BRXH, - SYSZ_INS_BRXHG, - SYSZ_INS_BRXLE, - SYSZ_INS_BRXLG, - SYSZ_INS_BSA, - SYSZ_INS_BSG, - SYSZ_INS_BSM, - SYSZ_INS_BXH, - SYSZ_INS_BXHG, - SYSZ_INS_BXLE, - SYSZ_INS_BXLEG, - SYSZ_INS_BZ, - SYSZ_INS_BZR, - SYSZ_INS_CD, - SYSZ_INS_CDFBRA, - SYSZ_INS_CDFR, - SYSZ_INS_CDFTR, - SYSZ_INS_CDGBRA, - SYSZ_INS_CDGR, - SYSZ_INS_CDGTR, - SYSZ_INS_CDGTRA, - SYSZ_INS_CDLFTR, - SYSZ_INS_CDLGTR, - SYSZ_INS_CDPT, - SYSZ_INS_CDR, - SYSZ_INS_CDS, - SYSZ_INS_CDSG, - SYSZ_INS_CDSTR, - SYSZ_INS_CDSY, - SYSZ_INS_CDTR, - SYSZ_INS_CDUTR, - SYSZ_INS_CDZT, - SYSZ_INS_CE, - SYSZ_INS_CEDTR, - SYSZ_INS_CEFBRA, - SYSZ_INS_CEFR, - SYSZ_INS_CEGBRA, - SYSZ_INS_CEGR, - SYSZ_INS_CER, - SYSZ_INS_CEXTR, - SYSZ_INS_CFC, - SYSZ_INS_CFDBRA, - SYSZ_INS_CFDR, - SYSZ_INS_CFDTR, - SYSZ_INS_CFEBRA, - SYSZ_INS_CFER, - SYSZ_INS_CFXBRA, - SYSZ_INS_CFXR, - SYSZ_INS_CFXTR, - SYSZ_INS_CGDBRA, - SYSZ_INS_CGDR, - SYSZ_INS_CGDTR, - SYSZ_INS_CGDTRA, - SYSZ_INS_CGEBRA, - SYSZ_INS_CGER, - SYSZ_INS_CGIB, - SYSZ_INS_CGIBE, - SYSZ_INS_CGIBH, - SYSZ_INS_CGIBHE, - SYSZ_INS_CGIBL, - SYSZ_INS_CGIBLE, - SYSZ_INS_CGIBLH, - SYSZ_INS_CGIBNE, - SYSZ_INS_CGIBNH, - SYSZ_INS_CGIBNHE, - SYSZ_INS_CGIBNL, - SYSZ_INS_CGIBNLE, - SYSZ_INS_CGIBNLH, - SYSZ_INS_CGIT, - SYSZ_INS_CGITE, - SYSZ_INS_CGITH, - SYSZ_INS_CGITHE, - SYSZ_INS_CGITL, - SYSZ_INS_CGITLE, - SYSZ_INS_CGITLH, - SYSZ_INS_CGITNE, - SYSZ_INS_CGITNH, - SYSZ_INS_CGITNHE, - SYSZ_INS_CGITNL, - SYSZ_INS_CGITNLE, - SYSZ_INS_CGITNLH, - SYSZ_INS_CGRB, - SYSZ_INS_CGRBE, - SYSZ_INS_CGRBH, - SYSZ_INS_CGRBHE, - SYSZ_INS_CGRBL, - SYSZ_INS_CGRBLE, - SYSZ_INS_CGRBLH, - SYSZ_INS_CGRBNE, - SYSZ_INS_CGRBNH, - SYSZ_INS_CGRBNHE, - SYSZ_INS_CGRBNL, - SYSZ_INS_CGRBNLE, - SYSZ_INS_CGRBNLH, - SYSZ_INS_CGRT, - SYSZ_INS_CGRTE, - SYSZ_INS_CGRTH, - SYSZ_INS_CGRTHE, - SYSZ_INS_CGRTL, - SYSZ_INS_CGRTLE, - SYSZ_INS_CGRTLH, - SYSZ_INS_CGRTNE, - SYSZ_INS_CGRTNH, - SYSZ_INS_CGRTNHE, - SYSZ_INS_CGRTNL, - SYSZ_INS_CGRTNLE, - SYSZ_INS_CGRTNLH, - SYSZ_INS_CGXBRA, - SYSZ_INS_CGXR, - SYSZ_INS_CGXTR, - SYSZ_INS_CGXTRA, - SYSZ_INS_CHHR, - SYSZ_INS_CHLR, - SYSZ_INS_CIB, - SYSZ_INS_CIBE, - SYSZ_INS_CIBH, - SYSZ_INS_CIBHE, - SYSZ_INS_CIBL, - SYSZ_INS_CIBLE, - SYSZ_INS_CIBLH, - SYSZ_INS_CIBNE, - SYSZ_INS_CIBNH, - SYSZ_INS_CIBNHE, - SYSZ_INS_CIBNL, - SYSZ_INS_CIBNLE, - SYSZ_INS_CIBNLH, - SYSZ_INS_CIT, - SYSZ_INS_CITE, - SYSZ_INS_CITH, - SYSZ_INS_CITHE, - SYSZ_INS_CITL, - SYSZ_INS_CITLE, - SYSZ_INS_CITLH, - SYSZ_INS_CITNE, - SYSZ_INS_CITNH, - SYSZ_INS_CITNHE, - SYSZ_INS_CITNL, - SYSZ_INS_CITNLE, - SYSZ_INS_CITNLH, - SYSZ_INS_CKSM, - SYSZ_INS_CLCL, - SYSZ_INS_CLCLE, - SYSZ_INS_CLCLU, - SYSZ_INS_CLFDTR, - SYSZ_INS_CLFIT, - SYSZ_INS_CLFITE, - SYSZ_INS_CLFITH, - SYSZ_INS_CLFITHE, - SYSZ_INS_CLFITL, - SYSZ_INS_CLFITLE, - SYSZ_INS_CLFITLH, - SYSZ_INS_CLFITNE, - SYSZ_INS_CLFITNH, - SYSZ_INS_CLFITNHE, - SYSZ_INS_CLFITNL, - SYSZ_INS_CLFITNLE, - SYSZ_INS_CLFITNLH, - SYSZ_INS_CLFXTR, - SYSZ_INS_CLGDTR, - SYSZ_INS_CLGIB, - SYSZ_INS_CLGIBE, - SYSZ_INS_CLGIBH, - SYSZ_INS_CLGIBHE, - SYSZ_INS_CLGIBL, - SYSZ_INS_CLGIBLE, - SYSZ_INS_CLGIBLH, - SYSZ_INS_CLGIBNE, - SYSZ_INS_CLGIBNH, - SYSZ_INS_CLGIBNHE, - SYSZ_INS_CLGIBNL, - SYSZ_INS_CLGIBNLE, - SYSZ_INS_CLGIBNLH, - SYSZ_INS_CLGIT, - SYSZ_INS_CLGITE, - SYSZ_INS_CLGITH, - SYSZ_INS_CLGITHE, - SYSZ_INS_CLGITL, - SYSZ_INS_CLGITLE, - SYSZ_INS_CLGITLH, - SYSZ_INS_CLGITNE, - SYSZ_INS_CLGITNH, - SYSZ_INS_CLGITNHE, - SYSZ_INS_CLGITNL, - SYSZ_INS_CLGITNLE, - SYSZ_INS_CLGITNLH, - SYSZ_INS_CLGRB, - SYSZ_INS_CLGRBE, - SYSZ_INS_CLGRBH, - SYSZ_INS_CLGRBHE, - SYSZ_INS_CLGRBL, - SYSZ_INS_CLGRBLE, - SYSZ_INS_CLGRBLH, - SYSZ_INS_CLGRBNE, - SYSZ_INS_CLGRBNH, - SYSZ_INS_CLGRBNHE, - SYSZ_INS_CLGRBNL, - SYSZ_INS_CLGRBNLE, - SYSZ_INS_CLGRBNLH, - SYSZ_INS_CLGRT, - SYSZ_INS_CLGRTE, - SYSZ_INS_CLGRTH, - SYSZ_INS_CLGRTHE, - SYSZ_INS_CLGRTL, - SYSZ_INS_CLGRTLE, - SYSZ_INS_CLGRTLH, - SYSZ_INS_CLGRTNE, - SYSZ_INS_CLGRTNH, - SYSZ_INS_CLGRTNHE, - SYSZ_INS_CLGRTNL, - SYSZ_INS_CLGRTNLE, - SYSZ_INS_CLGRTNLH, - SYSZ_INS_CLGT, - SYSZ_INS_CLGTE, - SYSZ_INS_CLGTH, - SYSZ_INS_CLGTHE, - SYSZ_INS_CLGTL, - SYSZ_INS_CLGTLE, - SYSZ_INS_CLGTLH, - SYSZ_INS_CLGTNE, - SYSZ_INS_CLGTNH, - SYSZ_INS_CLGTNHE, - SYSZ_INS_CLGTNL, - SYSZ_INS_CLGTNLE, - SYSZ_INS_CLGTNLH, - SYSZ_INS_CLGXTR, - SYSZ_INS_CLHHR, - SYSZ_INS_CLHLR, - SYSZ_INS_CLIB, - SYSZ_INS_CLIBE, - SYSZ_INS_CLIBH, - SYSZ_INS_CLIBHE, - SYSZ_INS_CLIBL, - SYSZ_INS_CLIBLE, - SYSZ_INS_CLIBLH, - SYSZ_INS_CLIBNE, - SYSZ_INS_CLIBNH, - SYSZ_INS_CLIBNHE, - SYSZ_INS_CLIBNL, - SYSZ_INS_CLIBNLE, - SYSZ_INS_CLIBNLH, - SYSZ_INS_CLM, - SYSZ_INS_CLMH, - SYSZ_INS_CLMY, - SYSZ_INS_CLRB, - SYSZ_INS_CLRBE, - SYSZ_INS_CLRBH, - SYSZ_INS_CLRBHE, - SYSZ_INS_CLRBL, - SYSZ_INS_CLRBLE, - SYSZ_INS_CLRBLH, - SYSZ_INS_CLRBNE, - SYSZ_INS_CLRBNH, - SYSZ_INS_CLRBNHE, - SYSZ_INS_CLRBNL, - SYSZ_INS_CLRBNLE, - SYSZ_INS_CLRBNLH, - SYSZ_INS_CLRT, - SYSZ_INS_CLRTE, - SYSZ_INS_CLRTH, - SYSZ_INS_CLRTHE, - SYSZ_INS_CLRTL, - SYSZ_INS_CLRTLE, - SYSZ_INS_CLRTLH, - SYSZ_INS_CLRTNE, - SYSZ_INS_CLRTNH, - SYSZ_INS_CLRTNHE, - SYSZ_INS_CLRTNL, - SYSZ_INS_CLRTNLE, - SYSZ_INS_CLRTNLH, - SYSZ_INS_CLT, - SYSZ_INS_CLTE, - SYSZ_INS_CLTH, - SYSZ_INS_CLTHE, - SYSZ_INS_CLTL, - SYSZ_INS_CLTLE, - SYSZ_INS_CLTLH, - SYSZ_INS_CLTNE, - SYSZ_INS_CLTNH, - SYSZ_INS_CLTNHE, - SYSZ_INS_CLTNL, - SYSZ_INS_CLTNLE, - SYSZ_INS_CLTNLH, - SYSZ_INS_CMPSC, - SYSZ_INS_CP, - SYSZ_INS_CPDT, - SYSZ_INS_CPXT, - SYSZ_INS_CPYA, - SYSZ_INS_CRB, - SYSZ_INS_CRBE, - SYSZ_INS_CRBH, - SYSZ_INS_CRBHE, - SYSZ_INS_CRBL, - SYSZ_INS_CRBLE, - SYSZ_INS_CRBLH, - SYSZ_INS_CRBNE, - SYSZ_INS_CRBNH, - SYSZ_INS_CRBNHE, - SYSZ_INS_CRBNL, - SYSZ_INS_CRBNLE, - SYSZ_INS_CRBNLH, - SYSZ_INS_CRDTE, - SYSZ_INS_CRT, - SYSZ_INS_CRTE, - SYSZ_INS_CRTH, - SYSZ_INS_CRTHE, - SYSZ_INS_CRTL, - SYSZ_INS_CRTLE, - SYSZ_INS_CRTLH, - SYSZ_INS_CRTNE, - SYSZ_INS_CRTNH, - SYSZ_INS_CRTNHE, - SYSZ_INS_CRTNL, - SYSZ_INS_CRTNLE, - SYSZ_INS_CRTNLH, - SYSZ_INS_CSCH, - SYSZ_INS_CSDTR, - SYSZ_INS_CSP, - SYSZ_INS_CSPG, - SYSZ_INS_CSST, - SYSZ_INS_CSXTR, - SYSZ_INS_CU12, - SYSZ_INS_CU14, - SYSZ_INS_CU21, - SYSZ_INS_CU24, - SYSZ_INS_CU41, - SYSZ_INS_CU42, - SYSZ_INS_CUDTR, - SYSZ_INS_CUSE, - SYSZ_INS_CUTFU, - SYSZ_INS_CUUTF, - SYSZ_INS_CUXTR, - SYSZ_INS_CVB, - SYSZ_INS_CVBG, - SYSZ_INS_CVBY, - SYSZ_INS_CVD, - SYSZ_INS_CVDG, - SYSZ_INS_CVDY, - SYSZ_INS_CXFBRA, - SYSZ_INS_CXFR, - SYSZ_INS_CXFTR, - SYSZ_INS_CXGBRA, - SYSZ_INS_CXGR, - SYSZ_INS_CXGTR, - SYSZ_INS_CXGTRA, - SYSZ_INS_CXLFTR, - SYSZ_INS_CXLGTR, - SYSZ_INS_CXPT, - SYSZ_INS_CXR, - SYSZ_INS_CXSTR, - SYSZ_INS_CXTR, - SYSZ_INS_CXUTR, - SYSZ_INS_CXZT, - SYSZ_INS_CZDT, - SYSZ_INS_CZXT, - SYSZ_INS_D, - SYSZ_INS_DD, - SYSZ_INS_DDR, - SYSZ_INS_DDTR, - SYSZ_INS_DDTRA, - SYSZ_INS_DE, - SYSZ_INS_DER, - SYSZ_INS_DIAG, - SYSZ_INS_DIDBR, - SYSZ_INS_DIEBR, - SYSZ_INS_DP, - SYSZ_INS_DR, - SYSZ_INS_DXR, - SYSZ_INS_DXTR, - SYSZ_INS_DXTRA, - SYSZ_INS_ECAG, - SYSZ_INS_ECCTR, - SYSZ_INS_ECPGA, - SYSZ_INS_ECTG, - SYSZ_INS_ED, - SYSZ_INS_EDMK, - SYSZ_INS_EEDTR, - SYSZ_INS_EEXTR, - SYSZ_INS_EFPC, - SYSZ_INS_EPAIR, - SYSZ_INS_EPAR, - SYSZ_INS_EPCTR, - SYSZ_INS_EPSW, - SYSZ_INS_EREG, - SYSZ_INS_EREGG, - SYSZ_INS_ESAIR, - SYSZ_INS_ESAR, - SYSZ_INS_ESDTR, - SYSZ_INS_ESEA, - SYSZ_INS_ESTA, - SYSZ_INS_ESXTR, - SYSZ_INS_ETND, - SYSZ_INS_EX, - SYSZ_INS_EXRL, - SYSZ_INS_FIDR, - SYSZ_INS_FIDTR, - SYSZ_INS_FIER, - SYSZ_INS_FIXR, - SYSZ_INS_FIXTR, - SYSZ_INS_HDR, - SYSZ_INS_HER, - SYSZ_INS_HSCH, - SYSZ_INS_IAC, - SYSZ_INS_ICM, - SYSZ_INS_ICMH, - SYSZ_INS_ICMY, - SYSZ_INS_IDTE, - SYSZ_INS_IEDTR, - SYSZ_INS_IEXTR, - SYSZ_INS_IPK, - SYSZ_INS_IPTE, - SYSZ_INS_IRBM, - SYSZ_INS_ISKE, - SYSZ_INS_IVSK, - SYSZ_INS_JGM, - SYSZ_INS_JGNM, - SYSZ_INS_JGNP, - SYSZ_INS_JGNZ, - SYSZ_INS_JGP, - SYSZ_INS_JGZ, - SYSZ_INS_JM, - SYSZ_INS_JNM, - SYSZ_INS_JNP, - SYSZ_INS_JNZ, - SYSZ_INS_JP, - SYSZ_INS_JZ, - SYSZ_INS_KDB, - SYSZ_INS_KDBR, - SYSZ_INS_KDTR, - SYSZ_INS_KEB, - SYSZ_INS_KEBR, - SYSZ_INS_KIMD, - SYSZ_INS_KLMD, - SYSZ_INS_KM, - SYSZ_INS_KMA, - SYSZ_INS_KMAC, - SYSZ_INS_KMC, - SYSZ_INS_KMCTR, - SYSZ_INS_KMF, - SYSZ_INS_KMO, - SYSZ_INS_KXBR, - SYSZ_INS_KXTR, - SYSZ_INS_LAE, - SYSZ_INS_LAEY, - SYSZ_INS_LAM, - SYSZ_INS_LAMY, - SYSZ_INS_LASP, - SYSZ_INS_LAT, - SYSZ_INS_LCBB, - SYSZ_INS_LCCTL, - SYSZ_INS_LCDFR, - SYSZ_INS_LCDR, - SYSZ_INS_LCER, - SYSZ_INS_LCTL, - SYSZ_INS_LCTLG, - SYSZ_INS_LCXR, - SYSZ_INS_LDE, - SYSZ_INS_LDER, - SYSZ_INS_LDETR, - SYSZ_INS_LDXR, - SYSZ_INS_LDXTR, - SYSZ_INS_LEDR, - SYSZ_INS_LEDTR, - SYSZ_INS_LEXR, - SYSZ_INS_LFAS, - SYSZ_INS_LFHAT, - SYSZ_INS_LFPC, - SYSZ_INS_LGAT, - SYSZ_INS_LGG, - SYSZ_INS_LGSC, - SYSZ_INS_LLGFAT, - SYSZ_INS_LLGFSG, - SYSZ_INS_LLGT, - SYSZ_INS_LLGTAT, - SYSZ_INS_LLGTR, - SYSZ_INS_LLZRGF, - SYSZ_INS_LM, - SYSZ_INS_LMD, - SYSZ_INS_LMH, - SYSZ_INS_LMY, - SYSZ_INS_LNDFR, - SYSZ_INS_LNDR, - SYSZ_INS_LNER, - SYSZ_INS_LNXR, - SYSZ_INS_LOCFH, - SYSZ_INS_LOCFHE, - SYSZ_INS_LOCFHH, - SYSZ_INS_LOCFHHE, - SYSZ_INS_LOCFHL, - SYSZ_INS_LOCFHLE, - SYSZ_INS_LOCFHLH, - SYSZ_INS_LOCFHM, - SYSZ_INS_LOCFHNE, - SYSZ_INS_LOCFHNH, - SYSZ_INS_LOCFHNHE, - SYSZ_INS_LOCFHNL, - SYSZ_INS_LOCFHNLE, - SYSZ_INS_LOCFHNLH, - SYSZ_INS_LOCFHNM, - SYSZ_INS_LOCFHNO, - SYSZ_INS_LOCFHNP, - SYSZ_INS_LOCFHNZ, - SYSZ_INS_LOCFHO, - SYSZ_INS_LOCFHP, - SYSZ_INS_LOCFHR, - SYSZ_INS_LOCFHRE, - SYSZ_INS_LOCFHRH, - SYSZ_INS_LOCFHRHE, - SYSZ_INS_LOCFHRL, - SYSZ_INS_LOCFHRLE, - SYSZ_INS_LOCFHRLH, - SYSZ_INS_LOCFHRM, - SYSZ_INS_LOCFHRNE, - SYSZ_INS_LOCFHRNH, - SYSZ_INS_LOCFHRNHE, - SYSZ_INS_LOCFHRNL, - SYSZ_INS_LOCFHRNLE, - SYSZ_INS_LOCFHRNLH, - SYSZ_INS_LOCFHRNM, - SYSZ_INS_LOCFHRNO, - SYSZ_INS_LOCFHRNP, - SYSZ_INS_LOCFHRNZ, - SYSZ_INS_LOCFHRO, - SYSZ_INS_LOCFHRP, - SYSZ_INS_LOCFHRZ, - SYSZ_INS_LOCFHZ, - SYSZ_INS_LOCGHI, - SYSZ_INS_LOCGHIE, - SYSZ_INS_LOCGHIH, - SYSZ_INS_LOCGHIHE, - SYSZ_INS_LOCGHIL, - SYSZ_INS_LOCGHILE, - SYSZ_INS_LOCGHILH, - SYSZ_INS_LOCGHIM, - SYSZ_INS_LOCGHINE, - SYSZ_INS_LOCGHINH, - SYSZ_INS_LOCGHINHE, - SYSZ_INS_LOCGHINL, - SYSZ_INS_LOCGHINLE, - SYSZ_INS_LOCGHINLH, - SYSZ_INS_LOCGHINM, - SYSZ_INS_LOCGHINO, - SYSZ_INS_LOCGHINP, - SYSZ_INS_LOCGHINZ, - SYSZ_INS_LOCGHIO, - SYSZ_INS_LOCGHIP, - SYSZ_INS_LOCGHIZ, - SYSZ_INS_LOCGM, - SYSZ_INS_LOCGNM, - SYSZ_INS_LOCGNP, - SYSZ_INS_LOCGNZ, - SYSZ_INS_LOCGP, - SYSZ_INS_LOCGRM, - SYSZ_INS_LOCGRNM, - SYSZ_INS_LOCGRNP, - SYSZ_INS_LOCGRNZ, - SYSZ_INS_LOCGRP, - SYSZ_INS_LOCGRZ, - SYSZ_INS_LOCGZ, - SYSZ_INS_LOCHHI, - SYSZ_INS_LOCHHIE, - SYSZ_INS_LOCHHIH, - SYSZ_INS_LOCHHIHE, - SYSZ_INS_LOCHHIL, - SYSZ_INS_LOCHHILE, - SYSZ_INS_LOCHHILH, - SYSZ_INS_LOCHHIM, - SYSZ_INS_LOCHHINE, - SYSZ_INS_LOCHHINH, - SYSZ_INS_LOCHHINHE, - SYSZ_INS_LOCHHINL, - SYSZ_INS_LOCHHINLE, - SYSZ_INS_LOCHHINLH, - SYSZ_INS_LOCHHINM, - SYSZ_INS_LOCHHINO, - SYSZ_INS_LOCHHINP, - SYSZ_INS_LOCHHINZ, - SYSZ_INS_LOCHHIO, - SYSZ_INS_LOCHHIP, - SYSZ_INS_LOCHHIZ, - SYSZ_INS_LOCHI, - SYSZ_INS_LOCHIE, - SYSZ_INS_LOCHIH, - SYSZ_INS_LOCHIHE, - SYSZ_INS_LOCHIL, - SYSZ_INS_LOCHILE, - SYSZ_INS_LOCHILH, - SYSZ_INS_LOCHIM, - SYSZ_INS_LOCHINE, - SYSZ_INS_LOCHINH, - SYSZ_INS_LOCHINHE, - SYSZ_INS_LOCHINL, - SYSZ_INS_LOCHINLE, - SYSZ_INS_LOCHINLH, - SYSZ_INS_LOCHINM, - SYSZ_INS_LOCHINO, - SYSZ_INS_LOCHINP, - SYSZ_INS_LOCHINZ, - SYSZ_INS_LOCHIO, - SYSZ_INS_LOCHIP, - SYSZ_INS_LOCHIZ, - SYSZ_INS_LOCM, - SYSZ_INS_LOCNM, - SYSZ_INS_LOCNP, - SYSZ_INS_LOCNZ, - SYSZ_INS_LOCP, - SYSZ_INS_LOCRM, - SYSZ_INS_LOCRNM, - SYSZ_INS_LOCRNP, - SYSZ_INS_LOCRNZ, - SYSZ_INS_LOCRP, - SYSZ_INS_LOCRZ, - SYSZ_INS_LOCZ, - SYSZ_INS_LPCTL, - SYSZ_INS_LPD, - SYSZ_INS_LPDFR, - SYSZ_INS_LPDG, - SYSZ_INS_LPDR, - SYSZ_INS_LPER, - SYSZ_INS_LPP, - SYSZ_INS_LPQ, - SYSZ_INS_LPSW, - SYSZ_INS_LPSWE, - SYSZ_INS_LPTEA, - SYSZ_INS_LPXR, - SYSZ_INS_LRA, - SYSZ_INS_LRAG, - SYSZ_INS_LRAY, - SYSZ_INS_LRDR, - SYSZ_INS_LRER, - SYSZ_INS_LRVH, - SYSZ_INS_LSCTL, - SYSZ_INS_LTDR, - SYSZ_INS_LTDTR, - SYSZ_INS_LTER, - SYSZ_INS_LTXR, - SYSZ_INS_LTXTR, - SYSZ_INS_LURA, - SYSZ_INS_LURAG, - SYSZ_INS_LXD, - SYSZ_INS_LXDR, - SYSZ_INS_LXDTR, - SYSZ_INS_LXE, - SYSZ_INS_LXER, - SYSZ_INS_LZRF, - SYSZ_INS_LZRG, - SYSZ_INS_M, - SYSZ_INS_MAD, - SYSZ_INS_MADR, - SYSZ_INS_MAE, - SYSZ_INS_MAER, - SYSZ_INS_MAY, - SYSZ_INS_MAYH, - SYSZ_INS_MAYHR, - SYSZ_INS_MAYL, - SYSZ_INS_MAYLR, - SYSZ_INS_MAYR, - SYSZ_INS_MC, - SYSZ_INS_MD, - SYSZ_INS_MDE, - SYSZ_INS_MDER, - SYSZ_INS_MDR, - SYSZ_INS_MDTR, - SYSZ_INS_MDTRA, - SYSZ_INS_ME, - SYSZ_INS_MEE, - SYSZ_INS_MEER, - SYSZ_INS_MER, - SYSZ_INS_MFY, - SYSZ_INS_MG, - SYSZ_INS_MGH, - SYSZ_INS_MGRK, - SYSZ_INS_ML, - SYSZ_INS_MLR, - SYSZ_INS_MP, - SYSZ_INS_MR, - SYSZ_INS_MSC, - SYSZ_INS_MSCH, - SYSZ_INS_MSD, - SYSZ_INS_MSDR, - SYSZ_INS_MSE, - SYSZ_INS_MSER, - SYSZ_INS_MSGC, - SYSZ_INS_MSGRKC, - SYSZ_INS_MSRKC, - SYSZ_INS_MSTA, - SYSZ_INS_MVCDK, - SYSZ_INS_MVCIN, - SYSZ_INS_MVCK, - SYSZ_INS_MVCL, - SYSZ_INS_MVCLE, - SYSZ_INS_MVCLU, - SYSZ_INS_MVCOS, - SYSZ_INS_MVCP, - SYSZ_INS_MVCS, - SYSZ_INS_MVCSK, - SYSZ_INS_MVN, - SYSZ_INS_MVO, - SYSZ_INS_MVPG, - SYSZ_INS_MVZ, - SYSZ_INS_MXD, - SYSZ_INS_MXDR, - SYSZ_INS_MXR, - SYSZ_INS_MXTR, - SYSZ_INS_MXTRA, - SYSZ_INS_MY, - SYSZ_INS_MYH, - SYSZ_INS_MYHR, - SYSZ_INS_MYL, - SYSZ_INS_MYLR, - SYSZ_INS_MYR, - SYSZ_INS_NIAI, - SYSZ_INS_NTSTG, - SYSZ_INS_PACK, - SYSZ_INS_PALB, - SYSZ_INS_PC, - SYSZ_INS_PCC, - SYSZ_INS_PCKMO, - SYSZ_INS_PFMF, - SYSZ_INS_PFPO, - SYSZ_INS_PGIN, - SYSZ_INS_PGOUT, - SYSZ_INS_PKA, - SYSZ_INS_PKU, - SYSZ_INS_PLO, - SYSZ_INS_POPCNT, - SYSZ_INS_PPA, - SYSZ_INS_PPNO, - SYSZ_INS_PR, - SYSZ_INS_PRNO, - SYSZ_INS_PT, - SYSZ_INS_PTF, - SYSZ_INS_PTFF, - SYSZ_INS_PTI, - SYSZ_INS_PTLB, - SYSZ_INS_QADTR, - SYSZ_INS_QAXTR, - SYSZ_INS_QCTRI, - SYSZ_INS_QSI, - SYSZ_INS_RCHP, - SYSZ_INS_RISBGN, - SYSZ_INS_RP, - SYSZ_INS_RRBE, - SYSZ_INS_RRBM, - SYSZ_INS_RRDTR, - SYSZ_INS_RRXTR, - SYSZ_INS_RSCH, - SYSZ_INS_SAC, - SYSZ_INS_SACF, - SYSZ_INS_SAL, - SYSZ_INS_SAM24, - SYSZ_INS_SAM31, - SYSZ_INS_SAM64, - SYSZ_INS_SAR, - SYSZ_INS_SCCTR, - SYSZ_INS_SCHM, - SYSZ_INS_SCK, - SYSZ_INS_SCKC, - SYSZ_INS_SCKPF, - SYSZ_INS_SD, - SYSZ_INS_SDR, - SYSZ_INS_SDTR, - SYSZ_INS_SDTRA, - SYSZ_INS_SE, - SYSZ_INS_SER, - SYSZ_INS_SFASR, - SYSZ_INS_SFPC, - SYSZ_INS_SGH, - SYSZ_INS_SHHHR, - SYSZ_INS_SHHLR, - SYSZ_INS_SIE, - SYSZ_INS_SIGA, - SYSZ_INS_SIGP, - SYSZ_INS_SLA, - SYSZ_INS_SLAG, - SYSZ_INS_SLAK, - SYSZ_INS_SLDA, - SYSZ_INS_SLDL, - SYSZ_INS_SLDT, - SYSZ_INS_SLHHHR, - SYSZ_INS_SLHHLR, - SYSZ_INS_SLXT, - SYSZ_INS_SP, - SYSZ_INS_SPCTR, - SYSZ_INS_SPKA, - SYSZ_INS_SPM, - SYSZ_INS_SPT, - SYSZ_INS_SPX, - SYSZ_INS_SQD, - SYSZ_INS_SQDR, - SYSZ_INS_SQE, - SYSZ_INS_SQER, - SYSZ_INS_SQXR, - SYSZ_INS_SRDA, - SYSZ_INS_SRDL, - SYSZ_INS_SRDT, - SYSZ_INS_SRNM, - SYSZ_INS_SRNMB, - SYSZ_INS_SRNMT, - SYSZ_INS_SRP, - SYSZ_INS_SRSTU, - SYSZ_INS_SRXT, - SYSZ_INS_SSAIR, - SYSZ_INS_SSAR, - SYSZ_INS_SSCH, - SYSZ_INS_SSKE, - SYSZ_INS_SSM, - SYSZ_INS_STAM, - SYSZ_INS_STAMY, - SYSZ_INS_STAP, - SYSZ_INS_STCK, - SYSZ_INS_STCKC, - SYSZ_INS_STCKE, - SYSZ_INS_STCKF, - SYSZ_INS_STCM, - SYSZ_INS_STCMH, - SYSZ_INS_STCMY, - SYSZ_INS_STCPS, - SYSZ_INS_STCRW, - SYSZ_INS_STCTG, - SYSZ_INS_STCTL, - SYSZ_INS_STFL, - SYSZ_INS_STFLE, - SYSZ_INS_STFPC, - SYSZ_INS_STGSC, - SYSZ_INS_STIDP, - SYSZ_INS_STM, - SYSZ_INS_STMH, - SYSZ_INS_STMY, - SYSZ_INS_STNSM, - SYSZ_INS_STOCFH, - SYSZ_INS_STOCFHE, - SYSZ_INS_STOCFHH, - SYSZ_INS_STOCFHHE, - SYSZ_INS_STOCFHL, - SYSZ_INS_STOCFHLE, - SYSZ_INS_STOCFHLH, - SYSZ_INS_STOCFHM, - SYSZ_INS_STOCFHNE, - SYSZ_INS_STOCFHNH, - SYSZ_INS_STOCFHNHE, - SYSZ_INS_STOCFHNL, - SYSZ_INS_STOCFHNLE, - SYSZ_INS_STOCFHNLH, - SYSZ_INS_STOCFHNM, - SYSZ_INS_STOCFHNO, - SYSZ_INS_STOCFHNP, - SYSZ_INS_STOCFHNZ, - SYSZ_INS_STOCFHO, - SYSZ_INS_STOCFHP, - SYSZ_INS_STOCFHZ, - SYSZ_INS_STOCGM, - SYSZ_INS_STOCGNM, - SYSZ_INS_STOCGNP, - SYSZ_INS_STOCGNZ, - SYSZ_INS_STOCGP, - SYSZ_INS_STOCGZ, - SYSZ_INS_STOCM, - SYSZ_INS_STOCNM, - SYSZ_INS_STOCNP, - SYSZ_INS_STOCNZ, - SYSZ_INS_STOCP, - SYSZ_INS_STOCZ, - SYSZ_INS_STOSM, - SYSZ_INS_STPQ, - SYSZ_INS_STPT, - SYSZ_INS_STPX, - SYSZ_INS_STRAG, - SYSZ_INS_STRVH, - SYSZ_INS_STSCH, - SYSZ_INS_STSI, - SYSZ_INS_STURA, - SYSZ_INS_STURG, - SYSZ_INS_SU, - SYSZ_INS_SUR, - SYSZ_INS_SVC, - SYSZ_INS_SW, - SYSZ_INS_SWR, - SYSZ_INS_SXR, - SYSZ_INS_SXTR, - SYSZ_INS_SXTRA, - SYSZ_INS_TABORT, - SYSZ_INS_TAM, - SYSZ_INS_TAR, - SYSZ_INS_TB, - SYSZ_INS_TBDR, - SYSZ_INS_TBEDR, - SYSZ_INS_TBEGIN, - SYSZ_INS_TBEGINC, - SYSZ_INS_TCDB, - SYSZ_INS_TCEB, - SYSZ_INS_TCXB, - SYSZ_INS_TDCDT, - SYSZ_INS_TDCET, - SYSZ_INS_TDCXT, - SYSZ_INS_TDGDT, - SYSZ_INS_TDGET, - SYSZ_INS_TDGXT, - SYSZ_INS_TEND, - SYSZ_INS_THDER, - SYSZ_INS_THDR, - SYSZ_INS_TP, - SYSZ_INS_TPI, - SYSZ_INS_TPROT, - SYSZ_INS_TR, - SYSZ_INS_TRACE, - SYSZ_INS_TRACG, - SYSZ_INS_TRAP2, - SYSZ_INS_TRAP4, - SYSZ_INS_TRE, - SYSZ_INS_TROO, - SYSZ_INS_TROT, - SYSZ_INS_TRT, - SYSZ_INS_TRTE, - SYSZ_INS_TRTO, - SYSZ_INS_TRTR, - SYSZ_INS_TRTRE, - SYSZ_INS_TRTT, - SYSZ_INS_TS, - SYSZ_INS_TSCH, - SYSZ_INS_UNPK, - SYSZ_INS_UNPKA, - SYSZ_INS_UNPKU, - SYSZ_INS_UPT, - SYSZ_INS_VA, - SYSZ_INS_VAB, - SYSZ_INS_VAC, - SYSZ_INS_VACC, - SYSZ_INS_VACCB, - SYSZ_INS_VACCC, - SYSZ_INS_VACCCQ, - SYSZ_INS_VACCF, - SYSZ_INS_VACCG, - SYSZ_INS_VACCH, - SYSZ_INS_VACCQ, - SYSZ_INS_VACQ, - SYSZ_INS_VAF, - SYSZ_INS_VAG, - SYSZ_INS_VAH, - SYSZ_INS_VAP, - SYSZ_INS_VAQ, - SYSZ_INS_VAVG, - SYSZ_INS_VAVGB, - SYSZ_INS_VAVGF, - SYSZ_INS_VAVGG, - SYSZ_INS_VAVGH, - SYSZ_INS_VAVGL, - SYSZ_INS_VAVGLB, - SYSZ_INS_VAVGLF, - SYSZ_INS_VAVGLG, - SYSZ_INS_VAVGLH, - SYSZ_INS_VBPERM, - SYSZ_INS_VCDG, - SYSZ_INS_VCDGB, - SYSZ_INS_VCDLG, - SYSZ_INS_VCDLGB, - SYSZ_INS_VCEQ, - SYSZ_INS_VCEQB, - SYSZ_INS_VCEQBS, - SYSZ_INS_VCEQF, - SYSZ_INS_VCEQFS, - SYSZ_INS_VCEQG, - SYSZ_INS_VCEQGS, - SYSZ_INS_VCEQH, - SYSZ_INS_VCEQHS, - SYSZ_INS_VCGD, - SYSZ_INS_VCGDB, - SYSZ_INS_VCH, - SYSZ_INS_VCHB, - SYSZ_INS_VCHBS, - SYSZ_INS_VCHF, - SYSZ_INS_VCHFS, - SYSZ_INS_VCHG, - SYSZ_INS_VCHGS, - SYSZ_INS_VCHH, - SYSZ_INS_VCHHS, - SYSZ_INS_VCHL, - SYSZ_INS_VCHLB, - SYSZ_INS_VCHLBS, - SYSZ_INS_VCHLF, - SYSZ_INS_VCHLFS, - SYSZ_INS_VCHLG, - SYSZ_INS_VCHLGS, - SYSZ_INS_VCHLH, - SYSZ_INS_VCHLHS, - SYSZ_INS_VCKSM, - SYSZ_INS_VCLGD, - SYSZ_INS_VCLGDB, - SYSZ_INS_VCLZ, - SYSZ_INS_VCLZB, - SYSZ_INS_VCLZF, - SYSZ_INS_VCLZG, - SYSZ_INS_VCLZH, - SYSZ_INS_VCP, - SYSZ_INS_VCTZ, - SYSZ_INS_VCTZB, - SYSZ_INS_VCTZF, - SYSZ_INS_VCTZG, - SYSZ_INS_VCTZH, - SYSZ_INS_VCVB, - SYSZ_INS_VCVBG, - SYSZ_INS_VCVD, - SYSZ_INS_VCVDG, - SYSZ_INS_VDP, - SYSZ_INS_VEC, - SYSZ_INS_VECB, - SYSZ_INS_VECF, - SYSZ_INS_VECG, - SYSZ_INS_VECH, - SYSZ_INS_VECL, - SYSZ_INS_VECLB, - SYSZ_INS_VECLF, - SYSZ_INS_VECLG, - SYSZ_INS_VECLH, - SYSZ_INS_VERIM, - SYSZ_INS_VERIMB, - SYSZ_INS_VERIMF, - SYSZ_INS_VERIMG, - SYSZ_INS_VERIMH, - SYSZ_INS_VERLL, - SYSZ_INS_VERLLB, - SYSZ_INS_VERLLF, - SYSZ_INS_VERLLG, - SYSZ_INS_VERLLH, - SYSZ_INS_VERLLV, - SYSZ_INS_VERLLVB, - SYSZ_INS_VERLLVF, - SYSZ_INS_VERLLVG, - SYSZ_INS_VERLLVH, - SYSZ_INS_VESL, - SYSZ_INS_VESLB, - SYSZ_INS_VESLF, - SYSZ_INS_VESLG, - SYSZ_INS_VESLH, - SYSZ_INS_VESLV, - SYSZ_INS_VESLVB, - SYSZ_INS_VESLVF, - SYSZ_INS_VESLVG, - SYSZ_INS_VESLVH, - SYSZ_INS_VESRA, - SYSZ_INS_VESRAB, - SYSZ_INS_VESRAF, - SYSZ_INS_VESRAG, - SYSZ_INS_VESRAH, - SYSZ_INS_VESRAV, - SYSZ_INS_VESRAVB, - SYSZ_INS_VESRAVF, - SYSZ_INS_VESRAVG, - SYSZ_INS_VESRAVH, - SYSZ_INS_VESRL, - SYSZ_INS_VESRLB, - SYSZ_INS_VESRLF, - SYSZ_INS_VESRLG, - SYSZ_INS_VESRLH, - SYSZ_INS_VESRLV, - SYSZ_INS_VESRLVB, - SYSZ_INS_VESRLVF, - SYSZ_INS_VESRLVG, - SYSZ_INS_VESRLVH, - SYSZ_INS_VFA, - SYSZ_INS_VFADB, - SYSZ_INS_VFAE, - SYSZ_INS_VFAEB, - SYSZ_INS_VFAEBS, - SYSZ_INS_VFAEF, - SYSZ_INS_VFAEFS, - SYSZ_INS_VFAEH, - SYSZ_INS_VFAEHS, - SYSZ_INS_VFAEZB, - SYSZ_INS_VFAEZBS, - SYSZ_INS_VFAEZF, - SYSZ_INS_VFAEZFS, - SYSZ_INS_VFAEZH, - SYSZ_INS_VFAEZHS, - SYSZ_INS_VFASB, - SYSZ_INS_VFCE, - SYSZ_INS_VFCEDB, - SYSZ_INS_VFCEDBS, - SYSZ_INS_VFCESB, - SYSZ_INS_VFCESBS, - SYSZ_INS_VFCH, - SYSZ_INS_VFCHDB, - SYSZ_INS_VFCHDBS, - SYSZ_INS_VFCHE, - SYSZ_INS_VFCHEDB, - SYSZ_INS_VFCHEDBS, - SYSZ_INS_VFCHESB, - SYSZ_INS_VFCHESBS, - SYSZ_INS_VFCHSB, - SYSZ_INS_VFCHSBS, - SYSZ_INS_VFD, - SYSZ_INS_VFDDB, - SYSZ_INS_VFDSB, - SYSZ_INS_VFEE, - SYSZ_INS_VFEEB, - SYSZ_INS_VFEEBS, - SYSZ_INS_VFEEF, - SYSZ_INS_VFEEFS, - SYSZ_INS_VFEEH, - SYSZ_INS_VFEEHS, - SYSZ_INS_VFEEZB, - SYSZ_INS_VFEEZBS, - SYSZ_INS_VFEEZF, - SYSZ_INS_VFEEZFS, - SYSZ_INS_VFEEZH, - SYSZ_INS_VFEEZHS, - SYSZ_INS_VFENE, - SYSZ_INS_VFENEB, - SYSZ_INS_VFENEBS, - SYSZ_INS_VFENEF, - SYSZ_INS_VFENEFS, - SYSZ_INS_VFENEH, - SYSZ_INS_VFENEHS, - SYSZ_INS_VFENEZB, - SYSZ_INS_VFENEZBS, - SYSZ_INS_VFENEZF, - SYSZ_INS_VFENEZFS, - SYSZ_INS_VFENEZH, - SYSZ_INS_VFENEZHS, - SYSZ_INS_VFI, - SYSZ_INS_VFIDB, - SYSZ_INS_VFISB, - SYSZ_INS_VFKEDB, - SYSZ_INS_VFKEDBS, - SYSZ_INS_VFKESB, - SYSZ_INS_VFKESBS, - SYSZ_INS_VFKHDB, - SYSZ_INS_VFKHDBS, - SYSZ_INS_VFKHEDB, - SYSZ_INS_VFKHEDBS, - SYSZ_INS_VFKHESB, - SYSZ_INS_VFKHESBS, - SYSZ_INS_VFKHSB, - SYSZ_INS_VFKHSBS, - SYSZ_INS_VFLCDB, - SYSZ_INS_VFLCSB, - SYSZ_INS_VFLL, - SYSZ_INS_VFLLS, - SYSZ_INS_VFLNDB, - SYSZ_INS_VFLNSB, - SYSZ_INS_VFLPDB, - SYSZ_INS_VFLPSB, - SYSZ_INS_VFLR, - SYSZ_INS_VFLRD, - SYSZ_INS_VFM, - SYSZ_INS_VFMA, - SYSZ_INS_VFMADB, - SYSZ_INS_VFMASB, - SYSZ_INS_VFMAX, - SYSZ_INS_VFMAXDB, - SYSZ_INS_VFMAXSB, - SYSZ_INS_VFMDB, - SYSZ_INS_VFMIN, - SYSZ_INS_VFMINDB, - SYSZ_INS_VFMINSB, - SYSZ_INS_VFMS, - SYSZ_INS_VFMSB, - SYSZ_INS_VFMSDB, - SYSZ_INS_VFMSSB, - SYSZ_INS_VFNMA, - SYSZ_INS_VFNMADB, - SYSZ_INS_VFNMASB, - SYSZ_INS_VFNMS, - SYSZ_INS_VFNMSDB, - SYSZ_INS_VFNMSSB, - SYSZ_INS_VFPSO, - SYSZ_INS_VFPSODB, - SYSZ_INS_VFPSOSB, - SYSZ_INS_VFS, - SYSZ_INS_VFSDB, - SYSZ_INS_VFSQ, - SYSZ_INS_VFSQDB, - SYSZ_INS_VFSQSB, - SYSZ_INS_VFSSB, - SYSZ_INS_VFTCI, - SYSZ_INS_VFTCIDB, - SYSZ_INS_VFTCISB, - SYSZ_INS_VGBM, - SYSZ_INS_VGEF, - SYSZ_INS_VGEG, - SYSZ_INS_VGFM, - SYSZ_INS_VGFMA, - SYSZ_INS_VGFMAB, - SYSZ_INS_VGFMAF, - SYSZ_INS_VGFMAG, - SYSZ_INS_VGFMAH, - SYSZ_INS_VGFMB, - SYSZ_INS_VGFMF, - SYSZ_INS_VGFMG, - SYSZ_INS_VGFMH, - SYSZ_INS_VGM, - SYSZ_INS_VGMB, - SYSZ_INS_VGMF, - SYSZ_INS_VGMG, - SYSZ_INS_VGMH, - SYSZ_INS_VISTR, - SYSZ_INS_VISTRB, - SYSZ_INS_VISTRBS, - SYSZ_INS_VISTRF, - SYSZ_INS_VISTRFS, - SYSZ_INS_VISTRH, - SYSZ_INS_VISTRHS, - SYSZ_INS_VL, - SYSZ_INS_VLBB, - SYSZ_INS_VLC, - SYSZ_INS_VLCB, - SYSZ_INS_VLCF, - SYSZ_INS_VLCG, - SYSZ_INS_VLCH, - SYSZ_INS_VLDE, - SYSZ_INS_VLDEB, - SYSZ_INS_VLEB, - SYSZ_INS_VLED, - SYSZ_INS_VLEDB, - SYSZ_INS_VLEF, - SYSZ_INS_VLEG, - SYSZ_INS_VLEH, - SYSZ_INS_VLEIB, - SYSZ_INS_VLEIF, - SYSZ_INS_VLEIG, - SYSZ_INS_VLEIH, - SYSZ_INS_VLGV, - SYSZ_INS_VLGVB, - SYSZ_INS_VLGVF, - SYSZ_INS_VLGVG, - SYSZ_INS_VLGVH, - SYSZ_INS_VLIP, - SYSZ_INS_VLL, - SYSZ_INS_VLLEZ, - SYSZ_INS_VLLEZB, - SYSZ_INS_VLLEZF, - SYSZ_INS_VLLEZG, - SYSZ_INS_VLLEZH, - SYSZ_INS_VLLEZLF, - SYSZ_INS_VLM, - SYSZ_INS_VLP, - SYSZ_INS_VLPB, - SYSZ_INS_VLPF, - SYSZ_INS_VLPG, - SYSZ_INS_VLPH, - SYSZ_INS_VLR, - SYSZ_INS_VLREP, - SYSZ_INS_VLREPB, - SYSZ_INS_VLREPF, - SYSZ_INS_VLREPG, - SYSZ_INS_VLREPH, - SYSZ_INS_VLRL, - SYSZ_INS_VLRLR, - SYSZ_INS_VLVG, - SYSZ_INS_VLVGB, - SYSZ_INS_VLVGF, - SYSZ_INS_VLVGG, - SYSZ_INS_VLVGH, - SYSZ_INS_VLVGP, - SYSZ_INS_VMAE, - SYSZ_INS_VMAEB, - SYSZ_INS_VMAEF, - SYSZ_INS_VMAEH, - SYSZ_INS_VMAH, - SYSZ_INS_VMAHB, - SYSZ_INS_VMAHF, - SYSZ_INS_VMAHH, - SYSZ_INS_VMAL, - SYSZ_INS_VMALB, - SYSZ_INS_VMALE, - SYSZ_INS_VMALEB, - SYSZ_INS_VMALEF, - SYSZ_INS_VMALEH, - SYSZ_INS_VMALF, - SYSZ_INS_VMALH, - SYSZ_INS_VMALHB, - SYSZ_INS_VMALHF, - SYSZ_INS_VMALHH, - SYSZ_INS_VMALHW, - SYSZ_INS_VMALO, - SYSZ_INS_VMALOB, - SYSZ_INS_VMALOF, - SYSZ_INS_VMALOH, - SYSZ_INS_VMAO, - SYSZ_INS_VMAOB, - SYSZ_INS_VMAOF, - SYSZ_INS_VMAOH, - SYSZ_INS_VME, - SYSZ_INS_VMEB, - SYSZ_INS_VMEF, - SYSZ_INS_VMEH, - SYSZ_INS_VMH, - SYSZ_INS_VMHB, - SYSZ_INS_VMHF, - SYSZ_INS_VMHH, - SYSZ_INS_VML, - SYSZ_INS_VMLB, - SYSZ_INS_VMLE, - SYSZ_INS_VMLEB, - SYSZ_INS_VMLEF, - SYSZ_INS_VMLEH, - SYSZ_INS_VMLF, - SYSZ_INS_VMLH, - SYSZ_INS_VMLHB, - SYSZ_INS_VMLHF, - SYSZ_INS_VMLHH, - SYSZ_INS_VMLHW, - SYSZ_INS_VMLO, - SYSZ_INS_VMLOB, - SYSZ_INS_VMLOF, - SYSZ_INS_VMLOH, - SYSZ_INS_VMN, - SYSZ_INS_VMNB, - SYSZ_INS_VMNF, - SYSZ_INS_VMNG, - SYSZ_INS_VMNH, - SYSZ_INS_VMNL, - SYSZ_INS_VMNLB, - SYSZ_INS_VMNLF, - SYSZ_INS_VMNLG, - SYSZ_INS_VMNLH, - SYSZ_INS_VMO, - SYSZ_INS_VMOB, - SYSZ_INS_VMOF, - SYSZ_INS_VMOH, - SYSZ_INS_VMP, - SYSZ_INS_VMRH, - SYSZ_INS_VMRHB, - SYSZ_INS_VMRHF, - SYSZ_INS_VMRHG, - SYSZ_INS_VMRHH, - SYSZ_INS_VMRL, - SYSZ_INS_VMRLB, - SYSZ_INS_VMRLF, - SYSZ_INS_VMRLG, - SYSZ_INS_VMRLH, - SYSZ_INS_VMSL, - SYSZ_INS_VMSLG, - SYSZ_INS_VMSP, - SYSZ_INS_VMX, - SYSZ_INS_VMXB, - SYSZ_INS_VMXF, - SYSZ_INS_VMXG, - SYSZ_INS_VMXH, - SYSZ_INS_VMXL, - SYSZ_INS_VMXLB, - SYSZ_INS_VMXLF, - SYSZ_INS_VMXLG, - SYSZ_INS_VMXLH, - SYSZ_INS_VN, - SYSZ_INS_VNC, - SYSZ_INS_VNN, - SYSZ_INS_VNO, - SYSZ_INS_VNX, - SYSZ_INS_VO, - SYSZ_INS_VOC, - SYSZ_INS_VONE, - SYSZ_INS_VPDI, - SYSZ_INS_VPERM, - SYSZ_INS_VPK, - SYSZ_INS_VPKF, - SYSZ_INS_VPKG, - SYSZ_INS_VPKH, - SYSZ_INS_VPKLS, - SYSZ_INS_VPKLSF, - SYSZ_INS_VPKLSFS, - SYSZ_INS_VPKLSG, - SYSZ_INS_VPKLSGS, - SYSZ_INS_VPKLSH, - SYSZ_INS_VPKLSHS, - SYSZ_INS_VPKS, - SYSZ_INS_VPKSF, - SYSZ_INS_VPKSFS, - SYSZ_INS_VPKSG, - SYSZ_INS_VPKSGS, - SYSZ_INS_VPKSH, - SYSZ_INS_VPKSHS, - SYSZ_INS_VPKZ, - SYSZ_INS_VPOPCT, - SYSZ_INS_VPOPCTB, - SYSZ_INS_VPOPCTF, - SYSZ_INS_VPOPCTG, - SYSZ_INS_VPOPCTH, - SYSZ_INS_VPSOP, - SYSZ_INS_VREP, - SYSZ_INS_VREPB, - SYSZ_INS_VREPF, - SYSZ_INS_VREPG, - SYSZ_INS_VREPH, - SYSZ_INS_VREPI, - SYSZ_INS_VREPIB, - SYSZ_INS_VREPIF, - SYSZ_INS_VREPIG, - SYSZ_INS_VREPIH, - SYSZ_INS_VRP, - SYSZ_INS_VS, - SYSZ_INS_VSB, - SYSZ_INS_VSBCBI, - SYSZ_INS_VSBCBIQ, - SYSZ_INS_VSBI, - SYSZ_INS_VSBIQ, - SYSZ_INS_VSCBI, - SYSZ_INS_VSCBIB, - SYSZ_INS_VSCBIF, - SYSZ_INS_VSCBIG, - SYSZ_INS_VSCBIH, - SYSZ_INS_VSCBIQ, - SYSZ_INS_VSCEF, - SYSZ_INS_VSCEG, - SYSZ_INS_VSDP, - SYSZ_INS_VSEG, - SYSZ_INS_VSEGB, - SYSZ_INS_VSEGF, - SYSZ_INS_VSEGH, - SYSZ_INS_VSEL, - SYSZ_INS_VSF, - SYSZ_INS_VSG, - SYSZ_INS_VSH, - SYSZ_INS_VSL, - SYSZ_INS_VSLB, - SYSZ_INS_VSLDB, - SYSZ_INS_VSP, - SYSZ_INS_VSQ, - SYSZ_INS_VSRA, - SYSZ_INS_VSRAB, - SYSZ_INS_VSRL, - SYSZ_INS_VSRLB, - SYSZ_INS_VSRP, - SYSZ_INS_VST, - SYSZ_INS_VSTEB, - SYSZ_INS_VSTEF, - SYSZ_INS_VSTEG, - SYSZ_INS_VSTEH, - SYSZ_INS_VSTL, - SYSZ_INS_VSTM, - SYSZ_INS_VSTRC, - SYSZ_INS_VSTRCB, - SYSZ_INS_VSTRCBS, - SYSZ_INS_VSTRCF, - SYSZ_INS_VSTRCFS, - SYSZ_INS_VSTRCH, - SYSZ_INS_VSTRCHS, - SYSZ_INS_VSTRCZB, - SYSZ_INS_VSTRCZBS, - SYSZ_INS_VSTRCZF, - SYSZ_INS_VSTRCZFS, - SYSZ_INS_VSTRCZH, - SYSZ_INS_VSTRCZHS, - SYSZ_INS_VSTRL, - SYSZ_INS_VSTRLR, - SYSZ_INS_VSUM, - SYSZ_INS_VSUMB, - SYSZ_INS_VSUMG, - SYSZ_INS_VSUMGF, - SYSZ_INS_VSUMGH, - SYSZ_INS_VSUMH, - SYSZ_INS_VSUMQ, - SYSZ_INS_VSUMQF, - SYSZ_INS_VSUMQG, - SYSZ_INS_VTM, - SYSZ_INS_VTP, - SYSZ_INS_VUPH, - SYSZ_INS_VUPHB, - SYSZ_INS_VUPHF, - SYSZ_INS_VUPHH, - SYSZ_INS_VUPKZ, - SYSZ_INS_VUPL, - SYSZ_INS_VUPLB, - SYSZ_INS_VUPLF, - SYSZ_INS_VUPLH, - SYSZ_INS_VUPLHB, - SYSZ_INS_VUPLHF, - SYSZ_INS_VUPLHH, - SYSZ_INS_VUPLHW, - SYSZ_INS_VUPLL, - SYSZ_INS_VUPLLB, - SYSZ_INS_VUPLLF, - SYSZ_INS_VUPLLH, - SYSZ_INS_VX, - SYSZ_INS_VZERO, - SYSZ_INS_WCDGB, - SYSZ_INS_WCDLGB, - SYSZ_INS_WCGDB, - SYSZ_INS_WCLGDB, - SYSZ_INS_WFADB, - SYSZ_INS_WFASB, - SYSZ_INS_WFAXB, - SYSZ_INS_WFC, - SYSZ_INS_WFCDB, - SYSZ_INS_WFCEDB, - SYSZ_INS_WFCEDBS, - SYSZ_INS_WFCESB, - SYSZ_INS_WFCESBS, - SYSZ_INS_WFCEXB, - SYSZ_INS_WFCEXBS, - SYSZ_INS_WFCHDB, - SYSZ_INS_WFCHDBS, - SYSZ_INS_WFCHEDB, - SYSZ_INS_WFCHEDBS, - SYSZ_INS_WFCHESB, - SYSZ_INS_WFCHESBS, - SYSZ_INS_WFCHEXB, - SYSZ_INS_WFCHEXBS, - SYSZ_INS_WFCHSB, - SYSZ_INS_WFCHSBS, - SYSZ_INS_WFCHXB, - SYSZ_INS_WFCHXBS, - SYSZ_INS_WFCSB, - SYSZ_INS_WFCXB, - SYSZ_INS_WFDDB, - SYSZ_INS_WFDSB, - SYSZ_INS_WFDXB, - SYSZ_INS_WFIDB, - SYSZ_INS_WFISB, - SYSZ_INS_WFIXB, - SYSZ_INS_WFK, - SYSZ_INS_WFKDB, - SYSZ_INS_WFKEDB, - SYSZ_INS_WFKEDBS, - SYSZ_INS_WFKESB, - SYSZ_INS_WFKESBS, - SYSZ_INS_WFKEXB, - SYSZ_INS_WFKEXBS, - SYSZ_INS_WFKHDB, - SYSZ_INS_WFKHDBS, - SYSZ_INS_WFKHEDB, - SYSZ_INS_WFKHEDBS, - SYSZ_INS_WFKHESB, - SYSZ_INS_WFKHESBS, - SYSZ_INS_WFKHEXB, - SYSZ_INS_WFKHEXBS, - SYSZ_INS_WFKHSB, - SYSZ_INS_WFKHSBS, - SYSZ_INS_WFKHXB, - SYSZ_INS_WFKHXBS, - SYSZ_INS_WFKSB, - SYSZ_INS_WFKXB, - SYSZ_INS_WFLCDB, - SYSZ_INS_WFLCSB, - SYSZ_INS_WFLCXB, - SYSZ_INS_WFLLD, - SYSZ_INS_WFLLS, - SYSZ_INS_WFLNDB, - SYSZ_INS_WFLNSB, - SYSZ_INS_WFLNXB, - SYSZ_INS_WFLPDB, - SYSZ_INS_WFLPSB, - SYSZ_INS_WFLPXB, - SYSZ_INS_WFLRD, - SYSZ_INS_WFLRX, - SYSZ_INS_WFMADB, - SYSZ_INS_WFMASB, - SYSZ_INS_WFMAXB, - SYSZ_INS_WFMAXDB, - SYSZ_INS_WFMAXSB, - SYSZ_INS_WFMAXXB, - SYSZ_INS_WFMDB, - SYSZ_INS_WFMINDB, - SYSZ_INS_WFMINSB, - SYSZ_INS_WFMINXB, - SYSZ_INS_WFMSB, - SYSZ_INS_WFMSDB, - SYSZ_INS_WFMSSB, - SYSZ_INS_WFMSXB, - SYSZ_INS_WFMXB, - SYSZ_INS_WFNMADB, - SYSZ_INS_WFNMASB, - SYSZ_INS_WFNMAXB, - SYSZ_INS_WFNMSDB, - SYSZ_INS_WFNMSSB, - SYSZ_INS_WFNMSXB, - SYSZ_INS_WFPSODB, - SYSZ_INS_WFPSOSB, - SYSZ_INS_WFPSOXB, - SYSZ_INS_WFSDB, - SYSZ_INS_WFSQDB, - SYSZ_INS_WFSQSB, - SYSZ_INS_WFSQXB, - SYSZ_INS_WFSSB, - SYSZ_INS_WFSXB, - SYSZ_INS_WFTCIDB, - SYSZ_INS_WFTCISB, - SYSZ_INS_WFTCIXB, - SYSZ_INS_WLDEB, - SYSZ_INS_WLEDB, - SYSZ_INS_XSCH, - SYSZ_INS_ZAP, - - SYSZ_INS_ENDING, // <-- mark the end of the list of instructions -} sysz_insn; - -/// Group of SystemZ instructions -typedef enum sysz_insn_group { - SYSZ_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - // Generic groups - // all jump instructions (conditional+direct+indirect jumps) - SYSZ_GRP_JUMP, ///< = CS_GRP_JUMP - - // Architecture-specific groups - SYSZ_GRP_DISTINCTOPS = 128, - SYSZ_GRP_FPEXTENSION, - SYSZ_GRP_HIGHWORD, - SYSZ_GRP_INTERLOCKEDACCESS1, - SYSZ_GRP_LOADSTOREONCOND, - SYSZ_GRP_DFPPACKEDCONVERSION, - SYSZ_GRP_DFPZONEDCONVERSION, - SYSZ_GRP_ENHANCEDDAT2, - SYSZ_GRP_EXECUTIONHINT, - SYSZ_GRP_GUARDEDSTORAGE, - SYSZ_GRP_INSERTREFERENCEBITSMULTIPLE, - SYSZ_GRP_LOADANDTRAP, - SYSZ_GRP_LOADANDZERORIGHTMOSTBYTE, - SYSZ_GRP_LOADSTOREONCOND2, - SYSZ_GRP_MESSAGESECURITYASSIST3, - SYSZ_GRP_MESSAGESECURITYASSIST4, - SYSZ_GRP_MESSAGESECURITYASSIST5, - SYSZ_GRP_MESSAGESECURITYASSIST7, - SYSZ_GRP_MESSAGESECURITYASSIST8, - SYSZ_GRP_MISCELLANEOUSEXTENSIONS, - SYSZ_GRP_MISCELLANEOUSEXTENSIONS2, - SYSZ_GRP_NOVECTOR, - SYSZ_GRP_POPULATIONCOUNT, - SYSZ_GRP_PROCESSORASSIST, - SYSZ_GRP_RESETREFERENCEBITSMULTIPLE, - SYSZ_GRP_TRANSACTIONALEXECUTION, - SYSZ_GRP_VECTOR, - SYSZ_GRP_VECTORENHANCEMENTS1, - SYSZ_GRP_VECTORPACKEDDECIMAL, - - SYSZ_GRP_ENDING, // <-- mark the end of the list of groups -} sysz_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_X86_H -#define CAPSTONE_X86_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2013-2015 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -/// Calculate relative address for X86-64, given cs_insn structure -#define X86_REL_ADDR(insn) (((insn).detail->x86.operands[0].type == X86_OP_IMM) \ - ? (uint64_t)((insn).detail->x86.operands[0].imm) \ - : (((insn).address + (insn).size) + (uint64_t)(insn).detail->x86.disp)) - -/// X86 registers -typedef enum x86_reg { - X86_REG_INVALID = 0, - X86_REG_AH, X86_REG_AL, X86_REG_AX, X86_REG_BH, X86_REG_BL, - X86_REG_BP, X86_REG_BPL, X86_REG_BX, X86_REG_CH, X86_REG_CL, - X86_REG_CS, X86_REG_CX, X86_REG_DH, X86_REG_DI, X86_REG_DIL, - X86_REG_DL, X86_REG_DS, X86_REG_DX, X86_REG_EAX, X86_REG_EBP, - X86_REG_EBX, X86_REG_ECX, X86_REG_EDI, X86_REG_EDX, X86_REG_EFLAGS, - X86_REG_EIP, X86_REG_EIZ, X86_REG_ES, X86_REG_ESI, X86_REG_ESP, - X86_REG_FPSW, X86_REG_FS, X86_REG_GS, X86_REG_IP, X86_REG_RAX, - X86_REG_RBP, X86_REG_RBX, X86_REG_RCX, X86_REG_RDI, X86_REG_RDX, - X86_REG_RIP, X86_REG_RIZ, X86_REG_RSI, X86_REG_RSP, X86_REG_SI, - X86_REG_SIL, X86_REG_SP, X86_REG_SPL, X86_REG_SS, X86_REG_CR0, - X86_REG_CR1, X86_REG_CR2, X86_REG_CR3, X86_REG_CR4, X86_REG_CR5, - X86_REG_CR6, X86_REG_CR7, X86_REG_CR8, X86_REG_CR9, X86_REG_CR10, - X86_REG_CR11, X86_REG_CR12, X86_REG_CR13, X86_REG_CR14, X86_REG_CR15, - X86_REG_DR0, X86_REG_DR1, X86_REG_DR2, X86_REG_DR3, X86_REG_DR4, - X86_REG_DR5, X86_REG_DR6, X86_REG_DR7, X86_REG_DR8, X86_REG_DR9, - X86_REG_DR10, X86_REG_DR11, X86_REG_DR12, X86_REG_DR13, X86_REG_DR14, - X86_REG_DR15, X86_REG_FP0, X86_REG_FP1, X86_REG_FP2, X86_REG_FP3, - X86_REG_FP4, X86_REG_FP5, X86_REG_FP6, X86_REG_FP7, - X86_REG_K0, X86_REG_K1, X86_REG_K2, X86_REG_K3, X86_REG_K4, - X86_REG_K5, X86_REG_K6, X86_REG_K7, X86_REG_MM0, X86_REG_MM1, - X86_REG_MM2, X86_REG_MM3, X86_REG_MM4, X86_REG_MM5, X86_REG_MM6, - X86_REG_MM7, X86_REG_R8, X86_REG_R9, X86_REG_R10, X86_REG_R11, - X86_REG_R12, X86_REG_R13, X86_REG_R14, X86_REG_R15, - X86_REG_ST0, X86_REG_ST1, X86_REG_ST2, X86_REG_ST3, - X86_REG_ST4, X86_REG_ST5, X86_REG_ST6, X86_REG_ST7, - X86_REG_XMM0, X86_REG_XMM1, X86_REG_XMM2, X86_REG_XMM3, X86_REG_XMM4, - X86_REG_XMM5, X86_REG_XMM6, X86_REG_XMM7, X86_REG_XMM8, X86_REG_XMM9, - X86_REG_XMM10, X86_REG_XMM11, X86_REG_XMM12, X86_REG_XMM13, X86_REG_XMM14, - X86_REG_XMM15, X86_REG_XMM16, X86_REG_XMM17, X86_REG_XMM18, X86_REG_XMM19, - X86_REG_XMM20, X86_REG_XMM21, X86_REG_XMM22, X86_REG_XMM23, X86_REG_XMM24, - X86_REG_XMM25, X86_REG_XMM26, X86_REG_XMM27, X86_REG_XMM28, X86_REG_XMM29, - X86_REG_XMM30, X86_REG_XMM31, X86_REG_YMM0, X86_REG_YMM1, X86_REG_YMM2, - X86_REG_YMM3, X86_REG_YMM4, X86_REG_YMM5, X86_REG_YMM6, X86_REG_YMM7, - X86_REG_YMM8, X86_REG_YMM9, X86_REG_YMM10, X86_REG_YMM11, X86_REG_YMM12, - X86_REG_YMM13, X86_REG_YMM14, X86_REG_YMM15, X86_REG_YMM16, X86_REG_YMM17, - X86_REG_YMM18, X86_REG_YMM19, X86_REG_YMM20, X86_REG_YMM21, X86_REG_YMM22, - X86_REG_YMM23, X86_REG_YMM24, X86_REG_YMM25, X86_REG_YMM26, X86_REG_YMM27, - X86_REG_YMM28, X86_REG_YMM29, X86_REG_YMM30, X86_REG_YMM31, X86_REG_ZMM0, - X86_REG_ZMM1, X86_REG_ZMM2, X86_REG_ZMM3, X86_REG_ZMM4, X86_REG_ZMM5, - X86_REG_ZMM6, X86_REG_ZMM7, X86_REG_ZMM8, X86_REG_ZMM9, X86_REG_ZMM10, - X86_REG_ZMM11, X86_REG_ZMM12, X86_REG_ZMM13, X86_REG_ZMM14, X86_REG_ZMM15, - X86_REG_ZMM16, X86_REG_ZMM17, X86_REG_ZMM18, X86_REG_ZMM19, X86_REG_ZMM20, - X86_REG_ZMM21, X86_REG_ZMM22, X86_REG_ZMM23, X86_REG_ZMM24, X86_REG_ZMM25, - X86_REG_ZMM26, X86_REG_ZMM27, X86_REG_ZMM28, X86_REG_ZMM29, X86_REG_ZMM30, - X86_REG_ZMM31, X86_REG_R8B, X86_REG_R9B, X86_REG_R10B, X86_REG_R11B, - X86_REG_R12B, X86_REG_R13B, X86_REG_R14B, X86_REG_R15B, X86_REG_R8D, - X86_REG_R9D, X86_REG_R10D, X86_REG_R11D, X86_REG_R12D, X86_REG_R13D, - X86_REG_R14D, X86_REG_R15D, X86_REG_R8W, X86_REG_R9W, X86_REG_R10W, - X86_REG_R11W, X86_REG_R12W, X86_REG_R13W, X86_REG_R14W, X86_REG_R15W, - X86_REG_BND0, X86_REG_BND1, X86_REG_BND2, X86_REG_BND3, - - X86_REG_ENDING // <-- mark the end of the list of registers -} x86_reg; - -// Sub-flags of EFLAGS -#define X86_EFLAGS_MODIFY_AF (1ULL << 0) -#define X86_EFLAGS_MODIFY_CF (1ULL << 1) -#define X86_EFLAGS_MODIFY_SF (1ULL << 2) -#define X86_EFLAGS_MODIFY_ZF (1ULL << 3) -#define X86_EFLAGS_MODIFY_PF (1ULL << 4) -#define X86_EFLAGS_MODIFY_OF (1ULL << 5) -#define X86_EFLAGS_MODIFY_TF (1ULL << 6) -#define X86_EFLAGS_MODIFY_IF (1ULL << 7) -#define X86_EFLAGS_MODIFY_DF (1ULL << 8) -#define X86_EFLAGS_MODIFY_NT (1ULL << 9) -#define X86_EFLAGS_MODIFY_RF (1ULL << 10) -#define X86_EFLAGS_PRIOR_OF (1ULL << 11) -#define X86_EFLAGS_PRIOR_SF (1ULL << 12) -#define X86_EFLAGS_PRIOR_ZF (1ULL << 13) -#define X86_EFLAGS_PRIOR_AF (1ULL << 14) -#define X86_EFLAGS_PRIOR_PF (1ULL << 15) -#define X86_EFLAGS_PRIOR_CF (1ULL << 16) -#define X86_EFLAGS_PRIOR_TF (1ULL << 17) -#define X86_EFLAGS_PRIOR_IF (1ULL << 18) -#define X86_EFLAGS_PRIOR_DF (1ULL << 19) -#define X86_EFLAGS_PRIOR_NT (1ULL << 20) -#define X86_EFLAGS_RESET_OF (1ULL << 21) -#define X86_EFLAGS_RESET_CF (1ULL << 22) -#define X86_EFLAGS_RESET_DF (1ULL << 23) -#define X86_EFLAGS_RESET_IF (1ULL << 24) -#define X86_EFLAGS_RESET_SF (1ULL << 25) -#define X86_EFLAGS_RESET_AF (1ULL << 26) -#define X86_EFLAGS_RESET_TF (1ULL << 27) -#define X86_EFLAGS_RESET_NT (1ULL << 28) -#define X86_EFLAGS_RESET_PF (1ULL << 29) -#define X86_EFLAGS_SET_CF (1ULL << 30) -#define X86_EFLAGS_SET_DF (1ULL << 31) -#define X86_EFLAGS_SET_IF (1ULL << 32) -#define X86_EFLAGS_TEST_OF (1ULL << 33) -#define X86_EFLAGS_TEST_SF (1ULL << 34) -#define X86_EFLAGS_TEST_ZF (1ULL << 35) -#define X86_EFLAGS_TEST_PF (1ULL << 36) -#define X86_EFLAGS_TEST_CF (1ULL << 37) -#define X86_EFLAGS_TEST_NT (1ULL << 38) -#define X86_EFLAGS_TEST_DF (1ULL << 39) -#define X86_EFLAGS_UNDEFINED_OF (1ULL << 40) -#define X86_EFLAGS_UNDEFINED_SF (1ULL << 41) -#define X86_EFLAGS_UNDEFINED_ZF (1ULL << 42) -#define X86_EFLAGS_UNDEFINED_PF (1ULL << 43) -#define X86_EFLAGS_UNDEFINED_AF (1ULL << 44) -#define X86_EFLAGS_UNDEFINED_CF (1ULL << 45) -#define X86_EFLAGS_RESET_RF (1ULL << 46) -#define X86_EFLAGS_TEST_RF (1ULL << 47) -#define X86_EFLAGS_TEST_IF (1ULL << 48) -#define X86_EFLAGS_TEST_TF (1ULL << 49) -#define X86_EFLAGS_TEST_AF (1ULL << 50) -#define X86_EFLAGS_RESET_ZF (1ULL << 51) -#define X86_EFLAGS_SET_OF (1ULL << 52) -#define X86_EFLAGS_SET_SF (1ULL << 53) -#define X86_EFLAGS_SET_ZF (1ULL << 54) -#define X86_EFLAGS_SET_AF (1ULL << 55) -#define X86_EFLAGS_SET_PF (1ULL << 56) -#define X86_EFLAGS_RESET_0F (1ULL << 57) -#define X86_EFLAGS_RESET_AC (1ULL << 58) - -#define X86_FPU_FLAGS_MODIFY_C0 (1ULL << 0) -#define X86_FPU_FLAGS_MODIFY_C1 (1ULL << 1) -#define X86_FPU_FLAGS_MODIFY_C2 (1ULL << 2) -#define X86_FPU_FLAGS_MODIFY_C3 (1ULL << 3) -#define X86_FPU_FLAGS_RESET_C0 (1ULL << 4) -#define X86_FPU_FLAGS_RESET_C1 (1ULL << 5) -#define X86_FPU_FLAGS_RESET_C2 (1ULL << 6) -#define X86_FPU_FLAGS_RESET_C3 (1ULL << 7) -#define X86_FPU_FLAGS_SET_C0 (1ULL << 8) -#define X86_FPU_FLAGS_SET_C1 (1ULL << 9) -#define X86_FPU_FLAGS_SET_C2 (1ULL << 10) -#define X86_FPU_FLAGS_SET_C3 (1ULL << 11) -#define X86_FPU_FLAGS_UNDEFINED_C0 (1ULL << 12) -#define X86_FPU_FLAGS_UNDEFINED_C1 (1ULL << 13) -#define X86_FPU_FLAGS_UNDEFINED_C2 (1ULL << 14) -#define X86_FPU_FLAGS_UNDEFINED_C3 (1ULL << 15) -#define X86_FPU_FLAGS_TEST_C0 (1ULL << 16) -#define X86_FPU_FLAGS_TEST_C1 (1ULL << 17) -#define X86_FPU_FLAGS_TEST_C2 (1ULL << 18) -#define X86_FPU_FLAGS_TEST_C3 (1ULL << 19) - - -/// Operand type for instruction's operands -typedef enum x86_op_type { - X86_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - X86_OP_REG, ///< = CS_OP_REG (Register operand). - X86_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - X86_OP_MEM, ///< = CS_OP_MEM (Memory operand). -} x86_op_type; - -/// XOP Code Condition type -typedef enum x86_xop_cc { - X86_XOP_CC_INVALID = 0, ///< Uninitialized. - X86_XOP_CC_LT, - X86_XOP_CC_LE, - X86_XOP_CC_GT, - X86_XOP_CC_GE, - X86_XOP_CC_EQ, - X86_XOP_CC_NEQ, - X86_XOP_CC_FALSE, - X86_XOP_CC_TRUE, -} x86_xop_cc; - -/// AVX broadcast type -typedef enum x86_avx_bcast { - X86_AVX_BCAST_INVALID = 0, ///< Uninitialized. - X86_AVX_BCAST_2, ///< AVX512 broadcast type {1to2} - X86_AVX_BCAST_4, ///< AVX512 broadcast type {1to4} - X86_AVX_BCAST_8, ///< AVX512 broadcast type {1to8} - X86_AVX_BCAST_16, ///< AVX512 broadcast type {1to16} -} x86_avx_bcast; - -/// SSE Code Condition type -typedef enum x86_sse_cc { - X86_SSE_CC_INVALID = 0, ///< Uninitialized. - X86_SSE_CC_EQ, - X86_SSE_CC_LT, - X86_SSE_CC_LE, - X86_SSE_CC_UNORD, - X86_SSE_CC_NEQ, - X86_SSE_CC_NLT, - X86_SSE_CC_NLE, - X86_SSE_CC_ORD, -} x86_sse_cc; - -/// AVX Code Condition type -typedef enum x86_avx_cc { - X86_AVX_CC_INVALID = 0, ///< Uninitialized. - X86_AVX_CC_EQ, - X86_AVX_CC_LT, - X86_AVX_CC_LE, - X86_AVX_CC_UNORD, - X86_AVX_CC_NEQ, - X86_AVX_CC_NLT, - X86_AVX_CC_NLE, - X86_AVX_CC_ORD, - X86_AVX_CC_EQ_UQ, - X86_AVX_CC_NGE, - X86_AVX_CC_NGT, - X86_AVX_CC_FALSE, - X86_AVX_CC_NEQ_OQ, - X86_AVX_CC_GE, - X86_AVX_CC_GT, - X86_AVX_CC_TRUE, - X86_AVX_CC_EQ_OS, - X86_AVX_CC_LT_OQ, - X86_AVX_CC_LE_OQ, - X86_AVX_CC_UNORD_S, - X86_AVX_CC_NEQ_US, - X86_AVX_CC_NLT_UQ, - X86_AVX_CC_NLE_UQ, - X86_AVX_CC_ORD_S, - X86_AVX_CC_EQ_US, - X86_AVX_CC_NGE_UQ, - X86_AVX_CC_NGT_UQ, - X86_AVX_CC_FALSE_OS, - X86_AVX_CC_NEQ_OS, - X86_AVX_CC_GE_OQ, - X86_AVX_CC_GT_OQ, - X86_AVX_CC_TRUE_US, -} x86_avx_cc; - -/// AVX static rounding mode type -typedef enum x86_avx_rm { - X86_AVX_RM_INVALID = 0, ///< Uninitialized. - X86_AVX_RM_RN, ///< Round to nearest - X86_AVX_RM_RD, ///< Round down - X86_AVX_RM_RU, ///< Round up - X86_AVX_RM_RZ, ///< Round toward zero -} x86_avx_rm; - -/// Instruction prefixes - to be used in cs_x86.prefix[] -typedef enum x86_prefix { - X86_PREFIX_LOCK = 0xf0, ///< lock (cs_x86.prefix[0] - X86_PREFIX_REP = 0xf3, ///< rep (cs_x86.prefix[0] - X86_PREFIX_REPE = 0xf3, ///< repe/repz (cs_x86.prefix[0] - X86_PREFIX_REPNE = 0xf2, ///< repne/repnz (cs_x86.prefix[0] - - X86_PREFIX_CS = 0x2e, ///< segment override CS (cs_x86.prefix[1] - X86_PREFIX_SS = 0x36, ///< segment override SS (cs_x86.prefix[1] - X86_PREFIX_DS = 0x3e, ///< segment override DS (cs_x86.prefix[1] - X86_PREFIX_ES = 0x26, ///< segment override ES (cs_x86.prefix[1] - X86_PREFIX_FS = 0x64, ///< segment override FS (cs_x86.prefix[1] - X86_PREFIX_GS = 0x65, ///< segment override GS (cs_x86.prefix[1] - - X86_PREFIX_OPSIZE = 0x66, ///< operand-size override (cs_x86.prefix[2] - X86_PREFIX_ADDRSIZE = 0x67, ///< address-size override (cs_x86.prefix[3] -} x86_prefix; - -/// Instruction's operand referring to memory -/// This is associated with X86_OP_MEM operand type above -typedef struct x86_op_mem { - x86_reg segment; ///< segment register (or X86_REG_INVALID if irrelevant) - x86_reg base; ///< base register (or X86_REG_INVALID if irrelevant) - x86_reg index; ///< index register (or X86_REG_INVALID if irrelevant) - int scale; ///< scale for index register - int64_t disp; ///< displacement value -} x86_op_mem; - -/// Instruction operand -typedef struct cs_x86_op { - x86_op_type type; ///< operand type - union { - x86_reg reg; ///< register value for REG operand - int64_t imm; ///< immediate value for IMM operand - x86_op_mem mem; ///< base/index/scale/disp value for MEM operand - }; - - /// size of this operand (in bytes). - uint8_t size; - - /// How is this operand accessed? (READ, WRITE or READ|WRITE) - /// This field is combined of cs_ac_type. - /// NOTE: this field is irrelevant if engine is compiled in DIET mode. - uint8_t access; - - /// AVX broadcast type, or 0 if irrelevant - x86_avx_bcast avx_bcast; - - /// AVX zero opmask {z} - bool avx_zero_opmask; -} cs_x86_op; - -typedef struct cs_x86_encoding { - /// ModR/M offset, or 0 when irrelevant - uint8_t modrm_offset; - - /// Displacement offset, or 0 when irrelevant. - uint8_t disp_offset; - uint8_t disp_size; - - /// Immediate offset, or 0 when irrelevant. - uint8_t imm_offset; - uint8_t imm_size; -} cs_x86_encoding; - -/// Instruction structure -typedef struct cs_x86 { - /// Instruction prefix, which can be up to 4 bytes. - /// A prefix byte gets value 0 when irrelevant. - /// prefix[0] indicates REP/REPNE/LOCK prefix (See X86_PREFIX_REP/REPNE/LOCK above) - /// prefix[1] indicates segment override (irrelevant for x86_64): - /// See X86_PREFIX_CS/SS/DS/ES/FS/GS above. - /// prefix[2] indicates operand-size override (X86_PREFIX_OPSIZE) - /// prefix[3] indicates address-size override (X86_PREFIX_ADDRSIZE) - uint8_t prefix[4]; - - /// Instruction opcode, which can be from 1 to 4 bytes in size. - /// This contains VEX opcode as well. - /// An trailing opcode byte gets value 0 when irrelevant. - uint8_t opcode[4]; - - /// REX prefix: only a non-zero value is relevant for x86_64 - uint8_t rex; - - /// Address size, which can be overridden with above prefix[5]. - uint8_t addr_size; - - /// ModR/M byte - uint8_t modrm; - - /// SIB value, or 0 when irrelevant. - uint8_t sib; - - /// Displacement value, valid if encoding.disp_offset != 0 - int64_t disp; - - /// SIB index register, or X86_REG_INVALID when irrelevant. - x86_reg sib_index; - /// SIB scale, only applicable if sib_index is valid. - int8_t sib_scale; - /// SIB base register, or X86_REG_INVALID when irrelevant. - x86_reg sib_base; - - /// XOP Code Condition - x86_xop_cc xop_cc; - - /// SSE Code Condition - x86_sse_cc sse_cc; - - /// AVX Code Condition - x86_avx_cc avx_cc; - - /// AVX Suppress all Exception - bool avx_sae; - - /// AVX static rounding mode - x86_avx_rm avx_rm; - - - union { - /// EFLAGS updated by this instruction. - /// This can be formed from OR combination of X86_EFLAGS_* symbols in x86.h - uint64_t eflags; - /// FPU_FLAGS updated by this instruction. - /// This can be formed from OR combination of X86_FPU_FLAGS_* symbols in x86.h - uint64_t fpu_flags; - }; - - /// Number of operands of this instruction, - /// or 0 when instruction has no operand. - uint8_t op_count; - - cs_x86_op operands[8]; ///< operands for this instruction. - - cs_x86_encoding encoding; ///< encoding information -} cs_x86; - -/// X86 instructions -typedef enum x86_insn { - X86_INS_INVALID = 0, - - X86_INS_AAA, - X86_INS_AAD, - X86_INS_AAM, - X86_INS_AAS, - X86_INS_FABS, - X86_INS_ADC, - X86_INS_ADCX, - X86_INS_ADD, - X86_INS_ADDPD, - X86_INS_ADDPS, - X86_INS_ADDSD, - X86_INS_ADDSS, - X86_INS_ADDSUBPD, - X86_INS_ADDSUBPS, - X86_INS_FADD, - X86_INS_FIADD, - X86_INS_ADOX, - X86_INS_AESDECLAST, - X86_INS_AESDEC, - X86_INS_AESENCLAST, - X86_INS_AESENC, - X86_INS_AESIMC, - X86_INS_AESKEYGENASSIST, - X86_INS_AND, - X86_INS_ANDN, - X86_INS_ANDNPD, - X86_INS_ANDNPS, - X86_INS_ANDPD, - X86_INS_ANDPS, - X86_INS_ARPL, - X86_INS_BEXTR, - X86_INS_BLCFILL, - X86_INS_BLCI, - X86_INS_BLCIC, - X86_INS_BLCMSK, - X86_INS_BLCS, - X86_INS_BLENDPD, - X86_INS_BLENDPS, - X86_INS_BLENDVPD, - X86_INS_BLENDVPS, - X86_INS_BLSFILL, - X86_INS_BLSI, - X86_INS_BLSIC, - X86_INS_BLSMSK, - X86_INS_BLSR, - X86_INS_BNDCL, - X86_INS_BNDCN, - X86_INS_BNDCU, - X86_INS_BNDLDX, - X86_INS_BNDMK, - X86_INS_BNDMOV, - X86_INS_BNDSTX, - X86_INS_BOUND, - X86_INS_BSF, - X86_INS_BSR, - X86_INS_BSWAP, - X86_INS_BT, - X86_INS_BTC, - X86_INS_BTR, - X86_INS_BTS, - X86_INS_BZHI, - X86_INS_CALL, - X86_INS_CBW, - X86_INS_CDQ, - X86_INS_CDQE, - X86_INS_FCHS, - X86_INS_CLAC, - X86_INS_CLC, - X86_INS_CLD, - X86_INS_CLDEMOTE, - X86_INS_CLFLUSH, - X86_INS_CLFLUSHOPT, - X86_INS_CLGI, - X86_INS_CLI, - X86_INS_CLRSSBSY, - X86_INS_CLTS, - X86_INS_CLWB, - X86_INS_CLZERO, - X86_INS_CMC, - X86_INS_CMOVA, - X86_INS_CMOVAE, - X86_INS_CMOVB, - X86_INS_CMOVBE, - X86_INS_FCMOVBE, - X86_INS_FCMOVB, - X86_INS_CMOVE, - X86_INS_FCMOVE, - X86_INS_CMOVG, - X86_INS_CMOVGE, - X86_INS_CMOVL, - X86_INS_CMOVLE, - X86_INS_FCMOVNBE, - X86_INS_FCMOVNB, - X86_INS_CMOVNE, - X86_INS_FCMOVNE, - X86_INS_CMOVNO, - X86_INS_CMOVNP, - X86_INS_FCMOVNU, - X86_INS_FCMOVNP, - X86_INS_CMOVNS, - X86_INS_CMOVO, - X86_INS_CMOVP, - X86_INS_FCMOVU, - X86_INS_CMOVS, - X86_INS_CMP, - X86_INS_CMPPD, - X86_INS_CMPPS, - X86_INS_CMPSB, - X86_INS_CMPSD, - X86_INS_CMPSQ, - X86_INS_CMPSS, - X86_INS_CMPSW, - X86_INS_CMPXCHG16B, - X86_INS_CMPXCHG, - X86_INS_CMPXCHG8B, - X86_INS_COMISD, - X86_INS_COMISS, - X86_INS_FCOMP, - X86_INS_FCOMPI, - X86_INS_FCOMI, - X86_INS_FCOM, - X86_INS_FCOS, - X86_INS_CPUID, - X86_INS_CQO, - X86_INS_CRC32, - X86_INS_CVTDQ2PD, - X86_INS_CVTDQ2PS, - X86_INS_CVTPD2DQ, - X86_INS_CVTPD2PS, - X86_INS_CVTPS2DQ, - X86_INS_CVTPS2PD, - X86_INS_CVTSD2SI, - X86_INS_CVTSD2SS, - X86_INS_CVTSI2SD, - X86_INS_CVTSI2SS, - X86_INS_CVTSS2SD, - X86_INS_CVTSS2SI, - X86_INS_CVTTPD2DQ, - X86_INS_CVTTPS2DQ, - X86_INS_CVTTSD2SI, - X86_INS_CVTTSS2SI, - X86_INS_CWD, - X86_INS_CWDE, - X86_INS_DAA, - X86_INS_DAS, - X86_INS_DATA16, - X86_INS_DEC, - X86_INS_DIV, - X86_INS_DIVPD, - X86_INS_DIVPS, - X86_INS_FDIVR, - X86_INS_FIDIVR, - X86_INS_FDIVRP, - X86_INS_DIVSD, - X86_INS_DIVSS, - X86_INS_FDIV, - X86_INS_FIDIV, - X86_INS_FDIVP, - X86_INS_DPPD, - X86_INS_DPPS, - X86_INS_ENCLS, - X86_INS_ENCLU, - X86_INS_ENCLV, - X86_INS_ENDBR32, - X86_INS_ENDBR64, - X86_INS_ENTER, - X86_INS_EXTRACTPS, - X86_INS_EXTRQ, - X86_INS_F2XM1, - X86_INS_LCALL, - X86_INS_LJMP, - X86_INS_JMP, - X86_INS_FBLD, - X86_INS_FBSTP, - X86_INS_FCOMPP, - X86_INS_FDECSTP, - X86_INS_FDISI8087_NOP, - X86_INS_FEMMS, - X86_INS_FENI8087_NOP, - X86_INS_FFREE, - X86_INS_FFREEP, - X86_INS_FICOM, - X86_INS_FICOMP, - X86_INS_FINCSTP, - X86_INS_FLDCW, - X86_INS_FLDENV, - X86_INS_FLDL2E, - X86_INS_FLDL2T, - X86_INS_FLDLG2, - X86_INS_FLDLN2, - X86_INS_FLDPI, - X86_INS_FNCLEX, - X86_INS_FNINIT, - X86_INS_FNOP, - X86_INS_FNSTCW, - X86_INS_FNSTSW, - X86_INS_FPATAN, - X86_INS_FSTPNCE, - X86_INS_FPREM, - X86_INS_FPREM1, - X86_INS_FPTAN, - X86_INS_FRNDINT, - X86_INS_FRSTOR, - X86_INS_FNSAVE, - X86_INS_FSCALE, - X86_INS_FSETPM, - X86_INS_FSINCOS, - X86_INS_FNSTENV, - X86_INS_FXAM, - X86_INS_FXRSTOR, - X86_INS_FXRSTOR64, - X86_INS_FXSAVE, - X86_INS_FXSAVE64, - X86_INS_FXTRACT, - X86_INS_FYL2X, - X86_INS_FYL2XP1, - X86_INS_GETSEC, - X86_INS_GF2P8AFFINEINVQB, - X86_INS_GF2P8AFFINEQB, - X86_INS_GF2P8MULB, - X86_INS_HADDPD, - X86_INS_HADDPS, - X86_INS_HLT, - X86_INS_HSUBPD, - X86_INS_HSUBPS, - X86_INS_IDIV, - X86_INS_FILD, - X86_INS_IMUL, - X86_INS_IN, - X86_INS_INC, - X86_INS_INCSSPD, - X86_INS_INCSSPQ, - X86_INS_INSB, - X86_INS_INSERTPS, - X86_INS_INSERTQ, - X86_INS_INSD, - X86_INS_INSW, - X86_INS_INT, - X86_INS_INT1, - X86_INS_INT3, - X86_INS_INTO, - X86_INS_INVD, - X86_INS_INVEPT, - X86_INS_INVLPG, - X86_INS_INVLPGA, - X86_INS_INVPCID, - X86_INS_INVVPID, - X86_INS_IRET, - X86_INS_IRETD, - X86_INS_IRETQ, - X86_INS_FISTTP, - X86_INS_FIST, - X86_INS_FISTP, - X86_INS_JAE, - X86_INS_JA, - X86_INS_JBE, - X86_INS_JB, - X86_INS_JCXZ, - X86_INS_JECXZ, - X86_INS_JE, - X86_INS_JGE, - X86_INS_JG, - X86_INS_JLE, - X86_INS_JL, - X86_INS_JNE, - X86_INS_JNO, - X86_INS_JNP, - X86_INS_JNS, - X86_INS_JO, - X86_INS_JP, - X86_INS_JRCXZ, - X86_INS_JS, - X86_INS_KADDB, - X86_INS_KADDD, - X86_INS_KADDQ, - X86_INS_KADDW, - X86_INS_KANDB, - X86_INS_KANDD, - X86_INS_KANDNB, - X86_INS_KANDND, - X86_INS_KANDNQ, - X86_INS_KANDNW, - X86_INS_KANDQ, - X86_INS_KANDW, - X86_INS_KMOVB, - X86_INS_KMOVD, - X86_INS_KMOVQ, - X86_INS_KMOVW, - X86_INS_KNOTB, - X86_INS_KNOTD, - X86_INS_KNOTQ, - X86_INS_KNOTW, - X86_INS_KORB, - X86_INS_KORD, - X86_INS_KORQ, - X86_INS_KORTESTB, - X86_INS_KORTESTD, - X86_INS_KORTESTQ, - X86_INS_KORTESTW, - X86_INS_KORW, - X86_INS_KSHIFTLB, - X86_INS_KSHIFTLD, - X86_INS_KSHIFTLQ, - X86_INS_KSHIFTLW, - X86_INS_KSHIFTRB, - X86_INS_KSHIFTRD, - X86_INS_KSHIFTRQ, - X86_INS_KSHIFTRW, - X86_INS_KTESTB, - X86_INS_KTESTD, - X86_INS_KTESTQ, - X86_INS_KTESTW, - X86_INS_KUNPCKBW, - X86_INS_KUNPCKDQ, - X86_INS_KUNPCKWD, - X86_INS_KXNORB, - X86_INS_KXNORD, - X86_INS_KXNORQ, - X86_INS_KXNORW, - X86_INS_KXORB, - X86_INS_KXORD, - X86_INS_KXORQ, - X86_INS_KXORW, - X86_INS_LAHF, - X86_INS_LAR, - X86_INS_LDDQU, - X86_INS_LDMXCSR, - X86_INS_LDS, - X86_INS_FLDZ, - X86_INS_FLD1, - X86_INS_FLD, - X86_INS_LEA, - X86_INS_LEAVE, - X86_INS_LES, - X86_INS_LFENCE, - X86_INS_LFS, - X86_INS_LGDT, - X86_INS_LGS, - X86_INS_LIDT, - X86_INS_LLDT, - X86_INS_LLWPCB, - X86_INS_LMSW, - X86_INS_LOCK, - X86_INS_LODSB, - X86_INS_LODSD, - X86_INS_LODSQ, - X86_INS_LODSW, - X86_INS_LOOP, - X86_INS_LOOPE, - X86_INS_LOOPNE, - X86_INS_RETF, - X86_INS_RETFQ, - X86_INS_LSL, - X86_INS_LSS, - X86_INS_LTR, - X86_INS_LWPINS, - X86_INS_LWPVAL, - X86_INS_LZCNT, - X86_INS_MASKMOVDQU, - X86_INS_MAXPD, - X86_INS_MAXPS, - X86_INS_MAXSD, - X86_INS_MAXSS, - X86_INS_MFENCE, - X86_INS_MINPD, - X86_INS_MINPS, - X86_INS_MINSD, - X86_INS_MINSS, - X86_INS_CVTPD2PI, - X86_INS_CVTPI2PD, - X86_INS_CVTPI2PS, - X86_INS_CVTPS2PI, - X86_INS_CVTTPD2PI, - X86_INS_CVTTPS2PI, - X86_INS_EMMS, - X86_INS_MASKMOVQ, - X86_INS_MOVD, - X86_INS_MOVQ, - X86_INS_MOVDQ2Q, - X86_INS_MOVNTQ, - X86_INS_MOVQ2DQ, - X86_INS_PABSB, - X86_INS_PABSD, - X86_INS_PABSW, - X86_INS_PACKSSDW, - X86_INS_PACKSSWB, - X86_INS_PACKUSWB, - X86_INS_PADDB, - X86_INS_PADDD, - X86_INS_PADDQ, - X86_INS_PADDSB, - X86_INS_PADDSW, - X86_INS_PADDUSB, - X86_INS_PADDUSW, - X86_INS_PADDW, - X86_INS_PALIGNR, - X86_INS_PANDN, - X86_INS_PAND, - X86_INS_PAVGB, - X86_INS_PAVGW, - X86_INS_PCMPEQB, - X86_INS_PCMPEQD, - X86_INS_PCMPEQW, - X86_INS_PCMPGTB, - X86_INS_PCMPGTD, - X86_INS_PCMPGTW, - X86_INS_PEXTRW, - X86_INS_PHADDD, - X86_INS_PHADDSW, - X86_INS_PHADDW, - X86_INS_PHSUBD, - X86_INS_PHSUBSW, - X86_INS_PHSUBW, - X86_INS_PINSRW, - X86_INS_PMADDUBSW, - X86_INS_PMADDWD, - X86_INS_PMAXSW, - X86_INS_PMAXUB, - X86_INS_PMINSW, - X86_INS_PMINUB, - X86_INS_PMOVMSKB, - X86_INS_PMULHRSW, - X86_INS_PMULHUW, - X86_INS_PMULHW, - X86_INS_PMULLW, - X86_INS_PMULUDQ, - X86_INS_POR, - X86_INS_PSADBW, - X86_INS_PSHUFB, - X86_INS_PSHUFW, - X86_INS_PSIGNB, - X86_INS_PSIGND, - X86_INS_PSIGNW, - X86_INS_PSLLD, - X86_INS_PSLLQ, - X86_INS_PSLLW, - X86_INS_PSRAD, - X86_INS_PSRAW, - X86_INS_PSRLD, - X86_INS_PSRLQ, - X86_INS_PSRLW, - X86_INS_PSUBB, - X86_INS_PSUBD, - X86_INS_PSUBQ, - X86_INS_PSUBSB, - X86_INS_PSUBSW, - X86_INS_PSUBUSB, - X86_INS_PSUBUSW, - X86_INS_PSUBW, - X86_INS_PUNPCKHBW, - X86_INS_PUNPCKHDQ, - X86_INS_PUNPCKHWD, - X86_INS_PUNPCKLBW, - X86_INS_PUNPCKLDQ, - X86_INS_PUNPCKLWD, - X86_INS_PXOR, - X86_INS_MONITORX, - X86_INS_MONITOR, - X86_INS_MONTMUL, - X86_INS_MOV, - X86_INS_MOVABS, - X86_INS_MOVAPD, - X86_INS_MOVAPS, - X86_INS_MOVBE, - X86_INS_MOVDDUP, - X86_INS_MOVDIR64B, - X86_INS_MOVDIRI, - X86_INS_MOVDQA, - X86_INS_MOVDQU, - X86_INS_MOVHLPS, - X86_INS_MOVHPD, - X86_INS_MOVHPS, - X86_INS_MOVLHPS, - X86_INS_MOVLPD, - X86_INS_MOVLPS, - X86_INS_MOVMSKPD, - X86_INS_MOVMSKPS, - X86_INS_MOVNTDQA, - X86_INS_MOVNTDQ, - X86_INS_MOVNTI, - X86_INS_MOVNTPD, - X86_INS_MOVNTPS, - X86_INS_MOVNTSD, - X86_INS_MOVNTSS, - X86_INS_MOVSB, - X86_INS_MOVSD, - X86_INS_MOVSHDUP, - X86_INS_MOVSLDUP, - X86_INS_MOVSQ, - X86_INS_MOVSS, - X86_INS_MOVSW, - X86_INS_MOVSX, - X86_INS_MOVSXD, - X86_INS_MOVUPD, - X86_INS_MOVUPS, - X86_INS_MOVZX, - X86_INS_MPSADBW, - X86_INS_MUL, - X86_INS_MULPD, - X86_INS_MULPS, - X86_INS_MULSD, - X86_INS_MULSS, - X86_INS_MULX, - X86_INS_FMUL, - X86_INS_FIMUL, - X86_INS_FMULP, - X86_INS_MWAITX, - X86_INS_MWAIT, - X86_INS_NEG, - X86_INS_NOP, - X86_INS_NOT, - X86_INS_OR, - X86_INS_ORPD, - X86_INS_ORPS, - X86_INS_OUT, - X86_INS_OUTSB, - X86_INS_OUTSD, - X86_INS_OUTSW, - X86_INS_PACKUSDW, - X86_INS_PAUSE, - X86_INS_PAVGUSB, - X86_INS_PBLENDVB, - X86_INS_PBLENDW, - X86_INS_PCLMULQDQ, - X86_INS_PCMPEQQ, - X86_INS_PCMPESTRI, - X86_INS_PCMPESTRM, - X86_INS_PCMPGTQ, - X86_INS_PCMPISTRI, - X86_INS_PCMPISTRM, - X86_INS_PCONFIG, - X86_INS_PDEP, - X86_INS_PEXT, - X86_INS_PEXTRB, - X86_INS_PEXTRD, - X86_INS_PEXTRQ, - X86_INS_PF2ID, - X86_INS_PF2IW, - X86_INS_PFACC, - X86_INS_PFADD, - X86_INS_PFCMPEQ, - X86_INS_PFCMPGE, - X86_INS_PFCMPGT, - X86_INS_PFMAX, - X86_INS_PFMIN, - X86_INS_PFMUL, - X86_INS_PFNACC, - X86_INS_PFPNACC, - X86_INS_PFRCPIT1, - X86_INS_PFRCPIT2, - X86_INS_PFRCP, - X86_INS_PFRSQIT1, - X86_INS_PFRSQRT, - X86_INS_PFSUBR, - X86_INS_PFSUB, - X86_INS_PHMINPOSUW, - X86_INS_PI2FD, - X86_INS_PI2FW, - X86_INS_PINSRB, - X86_INS_PINSRD, - X86_INS_PINSRQ, - X86_INS_PMAXSB, - X86_INS_PMAXSD, - X86_INS_PMAXUD, - X86_INS_PMAXUW, - X86_INS_PMINSB, - X86_INS_PMINSD, - X86_INS_PMINUD, - X86_INS_PMINUW, - X86_INS_PMOVSXBD, - X86_INS_PMOVSXBQ, - X86_INS_PMOVSXBW, - X86_INS_PMOVSXDQ, - X86_INS_PMOVSXWD, - X86_INS_PMOVSXWQ, - X86_INS_PMOVZXBD, - X86_INS_PMOVZXBQ, - X86_INS_PMOVZXBW, - X86_INS_PMOVZXDQ, - X86_INS_PMOVZXWD, - X86_INS_PMOVZXWQ, - X86_INS_PMULDQ, - X86_INS_PMULHRW, - X86_INS_PMULLD, - X86_INS_POP, - X86_INS_POPAW, - X86_INS_POPAL, - X86_INS_POPCNT, - X86_INS_POPF, - X86_INS_POPFD, - X86_INS_POPFQ, - X86_INS_PREFETCH, - X86_INS_PREFETCHNTA, - X86_INS_PREFETCHT0, - X86_INS_PREFETCHT1, - X86_INS_PREFETCHT2, - X86_INS_PREFETCHW, - X86_INS_PREFETCHWT1, - X86_INS_PSHUFD, - X86_INS_PSHUFHW, - X86_INS_PSHUFLW, - X86_INS_PSLLDQ, - X86_INS_PSRLDQ, - X86_INS_PSWAPD, - X86_INS_PTEST, - X86_INS_PTWRITE, - X86_INS_PUNPCKHQDQ, - X86_INS_PUNPCKLQDQ, - X86_INS_PUSH, - X86_INS_PUSHAW, - X86_INS_PUSHAL, - X86_INS_PUSHF, - X86_INS_PUSHFD, - X86_INS_PUSHFQ, - X86_INS_RCL, - X86_INS_RCPPS, - X86_INS_RCPSS, - X86_INS_RCR, - X86_INS_RDFSBASE, - X86_INS_RDGSBASE, - X86_INS_RDMSR, - X86_INS_RDPID, - X86_INS_RDPKRU, - X86_INS_RDPMC, - X86_INS_RDRAND, - X86_INS_RDSEED, - X86_INS_RDSSPD, - X86_INS_RDSSPQ, - X86_INS_RDTSC, - X86_INS_RDTSCP, - X86_INS_REPNE, - X86_INS_REP, - X86_INS_RET, - X86_INS_REX64, - X86_INS_ROL, - X86_INS_ROR, - X86_INS_RORX, - X86_INS_ROUNDPD, - X86_INS_ROUNDPS, - X86_INS_ROUNDSD, - X86_INS_ROUNDSS, - X86_INS_RSM, - X86_INS_RSQRTPS, - X86_INS_RSQRTSS, - X86_INS_RSTORSSP, - X86_INS_SAHF, - X86_INS_SAL, - X86_INS_SALC, - X86_INS_SAR, - X86_INS_SARX, - X86_INS_SAVEPREVSSP, - X86_INS_SBB, - X86_INS_SCASB, - X86_INS_SCASD, - X86_INS_SCASQ, - X86_INS_SCASW, - X86_INS_SETAE, - X86_INS_SETA, - X86_INS_SETBE, - X86_INS_SETB, - X86_INS_SETE, - X86_INS_SETGE, - X86_INS_SETG, - X86_INS_SETLE, - X86_INS_SETL, - X86_INS_SETNE, - X86_INS_SETNO, - X86_INS_SETNP, - X86_INS_SETNS, - X86_INS_SETO, - X86_INS_SETP, - X86_INS_SETSSBSY, - X86_INS_SETS, - X86_INS_SFENCE, - X86_INS_SGDT, - X86_INS_SHA1MSG1, - X86_INS_SHA1MSG2, - X86_INS_SHA1NEXTE, - X86_INS_SHA1RNDS4, - X86_INS_SHA256MSG1, - X86_INS_SHA256MSG2, - X86_INS_SHA256RNDS2, - X86_INS_SHL, - X86_INS_SHLD, - X86_INS_SHLX, - X86_INS_SHR, - X86_INS_SHRD, - X86_INS_SHRX, - X86_INS_SHUFPD, - X86_INS_SHUFPS, - X86_INS_SIDT, - X86_INS_FSIN, - X86_INS_SKINIT, - X86_INS_SLDT, - X86_INS_SLWPCB, - X86_INS_SMSW, - X86_INS_SQRTPD, - X86_INS_SQRTPS, - X86_INS_SQRTSD, - X86_INS_SQRTSS, - X86_INS_FSQRT, - X86_INS_STAC, - X86_INS_STC, - X86_INS_STD, - X86_INS_STGI, - X86_INS_STI, - X86_INS_STMXCSR, - X86_INS_STOSB, - X86_INS_STOSD, - X86_INS_STOSQ, - X86_INS_STOSW, - X86_INS_STR, - X86_INS_FST, - X86_INS_FSTP, - X86_INS_SUB, - X86_INS_SUBPD, - X86_INS_SUBPS, - X86_INS_FSUBR, - X86_INS_FISUBR, - X86_INS_FSUBRP, - X86_INS_SUBSD, - X86_INS_SUBSS, - X86_INS_FSUB, - X86_INS_FISUB, - X86_INS_FSUBP, - X86_INS_SWAPGS, - X86_INS_SYSCALL, - X86_INS_SYSENTER, - X86_INS_SYSEXIT, - X86_INS_SYSEXITQ, - X86_INS_SYSRET, - X86_INS_SYSRETQ, - X86_INS_T1MSKC, - X86_INS_TEST, - X86_INS_TPAUSE, - X86_INS_FTST, - X86_INS_TZCNT, - X86_INS_TZMSK, - X86_INS_UCOMISD, - X86_INS_UCOMISS, - X86_INS_FUCOMPI, - X86_INS_FUCOMI, - X86_INS_FUCOMPP, - X86_INS_FUCOMP, - X86_INS_FUCOM, - X86_INS_UD0, - X86_INS_UD1, - X86_INS_UD2, - X86_INS_UMONITOR, - X86_INS_UMWAIT, - X86_INS_UNPCKHPD, - X86_INS_UNPCKHPS, - X86_INS_UNPCKLPD, - X86_INS_UNPCKLPS, - X86_INS_V4FMADDPS, - X86_INS_V4FMADDSS, - X86_INS_V4FNMADDPS, - X86_INS_V4FNMADDSS, - X86_INS_VADDPD, - X86_INS_VADDPS, - X86_INS_VADDSD, - X86_INS_VADDSS, - X86_INS_VADDSUBPD, - X86_INS_VADDSUBPS, - X86_INS_VAESDECLAST, - X86_INS_VAESDEC, - X86_INS_VAESENCLAST, - X86_INS_VAESENC, - X86_INS_VAESIMC, - X86_INS_VAESKEYGENASSIST, - X86_INS_VALIGND, - X86_INS_VALIGNQ, - X86_INS_VANDNPD, - X86_INS_VANDNPS, - X86_INS_VANDPD, - X86_INS_VANDPS, - X86_INS_VBLENDMPD, - X86_INS_VBLENDMPS, - X86_INS_VBLENDPD, - X86_INS_VBLENDPS, - X86_INS_VBLENDVPD, - X86_INS_VBLENDVPS, - X86_INS_VBROADCASTF128, - X86_INS_VBROADCASTF32X2, - X86_INS_VBROADCASTF32X4, - X86_INS_VBROADCASTF32X8, - X86_INS_VBROADCASTF64X2, - X86_INS_VBROADCASTF64X4, - X86_INS_VBROADCASTI128, - X86_INS_VBROADCASTI32X2, - X86_INS_VBROADCASTI32X4, - X86_INS_VBROADCASTI32X8, - X86_INS_VBROADCASTI64X2, - X86_INS_VBROADCASTI64X4, - X86_INS_VBROADCASTSD, - X86_INS_VBROADCASTSS, - X86_INS_VCMP, - X86_INS_VCMPPD, - X86_INS_VCMPPS, - X86_INS_VCMPSD, - X86_INS_VCMPSS, - X86_INS_VCOMISD, - X86_INS_VCOMISS, - X86_INS_VCOMPRESSPD, - X86_INS_VCOMPRESSPS, - X86_INS_VCVTDQ2PD, - X86_INS_VCVTDQ2PS, - X86_INS_VCVTPD2DQ, - X86_INS_VCVTPD2PS, - X86_INS_VCVTPD2QQ, - X86_INS_VCVTPD2UDQ, - X86_INS_VCVTPD2UQQ, - X86_INS_VCVTPH2PS, - X86_INS_VCVTPS2DQ, - X86_INS_VCVTPS2PD, - X86_INS_VCVTPS2PH, - X86_INS_VCVTPS2QQ, - X86_INS_VCVTPS2UDQ, - X86_INS_VCVTPS2UQQ, - X86_INS_VCVTQQ2PD, - X86_INS_VCVTQQ2PS, - X86_INS_VCVTSD2SI, - X86_INS_VCVTSD2SS, - X86_INS_VCVTSD2USI, - X86_INS_VCVTSI2SD, - X86_INS_VCVTSI2SS, - X86_INS_VCVTSS2SD, - X86_INS_VCVTSS2SI, - X86_INS_VCVTSS2USI, - X86_INS_VCVTTPD2DQ, - X86_INS_VCVTTPD2QQ, - X86_INS_VCVTTPD2UDQ, - X86_INS_VCVTTPD2UQQ, - X86_INS_VCVTTPS2DQ, - X86_INS_VCVTTPS2QQ, - X86_INS_VCVTTPS2UDQ, - X86_INS_VCVTTPS2UQQ, - X86_INS_VCVTTSD2SI, - X86_INS_VCVTTSD2USI, - X86_INS_VCVTTSS2SI, - X86_INS_VCVTTSS2USI, - X86_INS_VCVTUDQ2PD, - X86_INS_VCVTUDQ2PS, - X86_INS_VCVTUQQ2PD, - X86_INS_VCVTUQQ2PS, - X86_INS_VCVTUSI2SD, - X86_INS_VCVTUSI2SS, - X86_INS_VDBPSADBW, - X86_INS_VDIVPD, - X86_INS_VDIVPS, - X86_INS_VDIVSD, - X86_INS_VDIVSS, - X86_INS_VDPPD, - X86_INS_VDPPS, - X86_INS_VERR, - X86_INS_VERW, - X86_INS_VEXP2PD, - X86_INS_VEXP2PS, - X86_INS_VEXPANDPD, - X86_INS_VEXPANDPS, - X86_INS_VEXTRACTF128, - X86_INS_VEXTRACTF32X4, - X86_INS_VEXTRACTF32X8, - X86_INS_VEXTRACTF64X2, - X86_INS_VEXTRACTF64X4, - X86_INS_VEXTRACTI128, - X86_INS_VEXTRACTI32X4, - X86_INS_VEXTRACTI32X8, - X86_INS_VEXTRACTI64X2, - X86_INS_VEXTRACTI64X4, - X86_INS_VEXTRACTPS, - X86_INS_VFIXUPIMMPD, - X86_INS_VFIXUPIMMPS, - X86_INS_VFIXUPIMMSD, - X86_INS_VFIXUPIMMSS, - X86_INS_VFMADD132PD, - X86_INS_VFMADD132PS, - X86_INS_VFMADD132SD, - X86_INS_VFMADD132SS, - X86_INS_VFMADD213PD, - X86_INS_VFMADD213PS, - X86_INS_VFMADD213SD, - X86_INS_VFMADD213SS, - X86_INS_VFMADD231PD, - X86_INS_VFMADD231PS, - X86_INS_VFMADD231SD, - X86_INS_VFMADD231SS, - X86_INS_VFMADDPD, - X86_INS_VFMADDPS, - X86_INS_VFMADDSD, - X86_INS_VFMADDSS, - X86_INS_VFMADDSUB132PD, - X86_INS_VFMADDSUB132PS, - X86_INS_VFMADDSUB213PD, - X86_INS_VFMADDSUB213PS, - X86_INS_VFMADDSUB231PD, - X86_INS_VFMADDSUB231PS, - X86_INS_VFMADDSUBPD, - X86_INS_VFMADDSUBPS, - X86_INS_VFMSUB132PD, - X86_INS_VFMSUB132PS, - X86_INS_VFMSUB132SD, - X86_INS_VFMSUB132SS, - X86_INS_VFMSUB213PD, - X86_INS_VFMSUB213PS, - X86_INS_VFMSUB213SD, - X86_INS_VFMSUB213SS, - X86_INS_VFMSUB231PD, - X86_INS_VFMSUB231PS, - X86_INS_VFMSUB231SD, - X86_INS_VFMSUB231SS, - X86_INS_VFMSUBADD132PD, - X86_INS_VFMSUBADD132PS, - X86_INS_VFMSUBADD213PD, - X86_INS_VFMSUBADD213PS, - X86_INS_VFMSUBADD231PD, - X86_INS_VFMSUBADD231PS, - X86_INS_VFMSUBADDPD, - X86_INS_VFMSUBADDPS, - X86_INS_VFMSUBPD, - X86_INS_VFMSUBPS, - X86_INS_VFMSUBSD, - X86_INS_VFMSUBSS, - X86_INS_VFNMADD132PD, - X86_INS_VFNMADD132PS, - X86_INS_VFNMADD132SD, - X86_INS_VFNMADD132SS, - X86_INS_VFNMADD213PD, - X86_INS_VFNMADD213PS, - X86_INS_VFNMADD213SD, - X86_INS_VFNMADD213SS, - X86_INS_VFNMADD231PD, - X86_INS_VFNMADD231PS, - X86_INS_VFNMADD231SD, - X86_INS_VFNMADD231SS, - X86_INS_VFNMADDPD, - X86_INS_VFNMADDPS, - X86_INS_VFNMADDSD, - X86_INS_VFNMADDSS, - X86_INS_VFNMSUB132PD, - X86_INS_VFNMSUB132PS, - X86_INS_VFNMSUB132SD, - X86_INS_VFNMSUB132SS, - X86_INS_VFNMSUB213PD, - X86_INS_VFNMSUB213PS, - X86_INS_VFNMSUB213SD, - X86_INS_VFNMSUB213SS, - X86_INS_VFNMSUB231PD, - X86_INS_VFNMSUB231PS, - X86_INS_VFNMSUB231SD, - X86_INS_VFNMSUB231SS, - X86_INS_VFNMSUBPD, - X86_INS_VFNMSUBPS, - X86_INS_VFNMSUBSD, - X86_INS_VFNMSUBSS, - X86_INS_VFPCLASSPD, - X86_INS_VFPCLASSPS, - X86_INS_VFPCLASSSD, - X86_INS_VFPCLASSSS, - X86_INS_VFRCZPD, - X86_INS_VFRCZPS, - X86_INS_VFRCZSD, - X86_INS_VFRCZSS, - X86_INS_VGATHERDPD, - X86_INS_VGATHERDPS, - X86_INS_VGATHERPF0DPD, - X86_INS_VGATHERPF0DPS, - X86_INS_VGATHERPF0QPD, - X86_INS_VGATHERPF0QPS, - X86_INS_VGATHERPF1DPD, - X86_INS_VGATHERPF1DPS, - X86_INS_VGATHERPF1QPD, - X86_INS_VGATHERPF1QPS, - X86_INS_VGATHERQPD, - X86_INS_VGATHERQPS, - X86_INS_VGETEXPPD, - X86_INS_VGETEXPPS, - X86_INS_VGETEXPSD, - X86_INS_VGETEXPSS, - X86_INS_VGETMANTPD, - X86_INS_VGETMANTPS, - X86_INS_VGETMANTSD, - X86_INS_VGETMANTSS, - X86_INS_VGF2P8AFFINEINVQB, - X86_INS_VGF2P8AFFINEQB, - X86_INS_VGF2P8MULB, - X86_INS_VHADDPD, - X86_INS_VHADDPS, - X86_INS_VHSUBPD, - X86_INS_VHSUBPS, - X86_INS_VINSERTF128, - X86_INS_VINSERTF32X4, - X86_INS_VINSERTF32X8, - X86_INS_VINSERTF64X2, - X86_INS_VINSERTF64X4, - X86_INS_VINSERTI128, - X86_INS_VINSERTI32X4, - X86_INS_VINSERTI32X8, - X86_INS_VINSERTI64X2, - X86_INS_VINSERTI64X4, - X86_INS_VINSERTPS, - X86_INS_VLDDQU, - X86_INS_VLDMXCSR, - X86_INS_VMASKMOVDQU, - X86_INS_VMASKMOVPD, - X86_INS_VMASKMOVPS, - X86_INS_VMAXPD, - X86_INS_VMAXPS, - X86_INS_VMAXSD, - X86_INS_VMAXSS, - X86_INS_VMCALL, - X86_INS_VMCLEAR, - X86_INS_VMFUNC, - X86_INS_VMINPD, - X86_INS_VMINPS, - X86_INS_VMINSD, - X86_INS_VMINSS, - X86_INS_VMLAUNCH, - X86_INS_VMLOAD, - X86_INS_VMMCALL, - X86_INS_VMOVQ, - X86_INS_VMOVAPD, - X86_INS_VMOVAPS, - X86_INS_VMOVDDUP, - X86_INS_VMOVD, - X86_INS_VMOVDQA32, - X86_INS_VMOVDQA64, - X86_INS_VMOVDQA, - X86_INS_VMOVDQU16, - X86_INS_VMOVDQU32, - X86_INS_VMOVDQU64, - X86_INS_VMOVDQU8, - X86_INS_VMOVDQU, - X86_INS_VMOVHLPS, - X86_INS_VMOVHPD, - X86_INS_VMOVHPS, - X86_INS_VMOVLHPS, - X86_INS_VMOVLPD, - X86_INS_VMOVLPS, - X86_INS_VMOVMSKPD, - X86_INS_VMOVMSKPS, - X86_INS_VMOVNTDQA, - X86_INS_VMOVNTDQ, - X86_INS_VMOVNTPD, - X86_INS_VMOVNTPS, - X86_INS_VMOVSD, - X86_INS_VMOVSHDUP, - X86_INS_VMOVSLDUP, - X86_INS_VMOVSS, - X86_INS_VMOVUPD, - X86_INS_VMOVUPS, - X86_INS_VMPSADBW, - X86_INS_VMPTRLD, - X86_INS_VMPTRST, - X86_INS_VMREAD, - X86_INS_VMRESUME, - X86_INS_VMRUN, - X86_INS_VMSAVE, - X86_INS_VMULPD, - X86_INS_VMULPS, - X86_INS_VMULSD, - X86_INS_VMULSS, - X86_INS_VMWRITE, - X86_INS_VMXOFF, - X86_INS_VMXON, - X86_INS_VORPD, - X86_INS_VORPS, - X86_INS_VP4DPWSSDS, - X86_INS_VP4DPWSSD, - X86_INS_VPABSB, - X86_INS_VPABSD, - X86_INS_VPABSQ, - X86_INS_VPABSW, - X86_INS_VPACKSSDW, - X86_INS_VPACKSSWB, - X86_INS_VPACKUSDW, - X86_INS_VPACKUSWB, - X86_INS_VPADDB, - X86_INS_VPADDD, - X86_INS_VPADDQ, - X86_INS_VPADDSB, - X86_INS_VPADDSW, - X86_INS_VPADDUSB, - X86_INS_VPADDUSW, - X86_INS_VPADDW, - X86_INS_VPALIGNR, - X86_INS_VPANDD, - X86_INS_VPANDND, - X86_INS_VPANDNQ, - X86_INS_VPANDN, - X86_INS_VPANDQ, - X86_INS_VPAND, - X86_INS_VPAVGB, - X86_INS_VPAVGW, - X86_INS_VPBLENDD, - X86_INS_VPBLENDMB, - X86_INS_VPBLENDMD, - X86_INS_VPBLENDMQ, - X86_INS_VPBLENDMW, - X86_INS_VPBLENDVB, - X86_INS_VPBLENDW, - X86_INS_VPBROADCASTB, - X86_INS_VPBROADCASTD, - X86_INS_VPBROADCASTMB2Q, - X86_INS_VPBROADCASTMW2D, - X86_INS_VPBROADCASTQ, - X86_INS_VPBROADCASTW, - X86_INS_VPCLMULQDQ, - X86_INS_VPCMOV, - X86_INS_VPCMP, - X86_INS_VPCMPB, - X86_INS_VPCMPD, - X86_INS_VPCMPEQB, - X86_INS_VPCMPEQD, - X86_INS_VPCMPEQQ, - X86_INS_VPCMPEQW, - X86_INS_VPCMPESTRI, - X86_INS_VPCMPESTRM, - X86_INS_VPCMPGTB, - X86_INS_VPCMPGTD, - X86_INS_VPCMPGTQ, - X86_INS_VPCMPGTW, - X86_INS_VPCMPISTRI, - X86_INS_VPCMPISTRM, - X86_INS_VPCMPQ, - X86_INS_VPCMPUB, - X86_INS_VPCMPUD, - X86_INS_VPCMPUQ, - X86_INS_VPCMPUW, - X86_INS_VPCMPW, - X86_INS_VPCOM, - X86_INS_VPCOMB, - X86_INS_VPCOMD, - X86_INS_VPCOMPRESSB, - X86_INS_VPCOMPRESSD, - X86_INS_VPCOMPRESSQ, - X86_INS_VPCOMPRESSW, - X86_INS_VPCOMQ, - X86_INS_VPCOMUB, - X86_INS_VPCOMUD, - X86_INS_VPCOMUQ, - X86_INS_VPCOMUW, - X86_INS_VPCOMW, - X86_INS_VPCONFLICTD, - X86_INS_VPCONFLICTQ, - X86_INS_VPDPBUSDS, - X86_INS_VPDPBUSD, - X86_INS_VPDPWSSDS, - X86_INS_VPDPWSSD, - X86_INS_VPERM2F128, - X86_INS_VPERM2I128, - X86_INS_VPERMB, - X86_INS_VPERMD, - X86_INS_VPERMI2B, - X86_INS_VPERMI2D, - X86_INS_VPERMI2PD, - X86_INS_VPERMI2PS, - X86_INS_VPERMI2Q, - X86_INS_VPERMI2W, - X86_INS_VPERMIL2PD, - X86_INS_VPERMILPD, - X86_INS_VPERMIL2PS, - X86_INS_VPERMILPS, - X86_INS_VPERMPD, - X86_INS_VPERMPS, - X86_INS_VPERMQ, - X86_INS_VPERMT2B, - X86_INS_VPERMT2D, - X86_INS_VPERMT2PD, - X86_INS_VPERMT2PS, - X86_INS_VPERMT2Q, - X86_INS_VPERMT2W, - X86_INS_VPERMW, - X86_INS_VPEXPANDB, - X86_INS_VPEXPANDD, - X86_INS_VPEXPANDQ, - X86_INS_VPEXPANDW, - X86_INS_VPEXTRB, - X86_INS_VPEXTRD, - X86_INS_VPEXTRQ, - X86_INS_VPEXTRW, - X86_INS_VPGATHERDD, - X86_INS_VPGATHERDQ, - X86_INS_VPGATHERQD, - X86_INS_VPGATHERQQ, - X86_INS_VPHADDBD, - X86_INS_VPHADDBQ, - X86_INS_VPHADDBW, - X86_INS_VPHADDDQ, - X86_INS_VPHADDD, - X86_INS_VPHADDSW, - X86_INS_VPHADDUBD, - X86_INS_VPHADDUBQ, - X86_INS_VPHADDUBW, - X86_INS_VPHADDUDQ, - X86_INS_VPHADDUWD, - X86_INS_VPHADDUWQ, - X86_INS_VPHADDWD, - X86_INS_VPHADDWQ, - X86_INS_VPHADDW, - X86_INS_VPHMINPOSUW, - X86_INS_VPHSUBBW, - X86_INS_VPHSUBDQ, - X86_INS_VPHSUBD, - X86_INS_VPHSUBSW, - X86_INS_VPHSUBWD, - X86_INS_VPHSUBW, - X86_INS_VPINSRB, - X86_INS_VPINSRD, - X86_INS_VPINSRQ, - X86_INS_VPINSRW, - X86_INS_VPLZCNTD, - X86_INS_VPLZCNTQ, - X86_INS_VPMACSDD, - X86_INS_VPMACSDQH, - X86_INS_VPMACSDQL, - X86_INS_VPMACSSDD, - X86_INS_VPMACSSDQH, - X86_INS_VPMACSSDQL, - X86_INS_VPMACSSWD, - X86_INS_VPMACSSWW, - X86_INS_VPMACSWD, - X86_INS_VPMACSWW, - X86_INS_VPMADCSSWD, - X86_INS_VPMADCSWD, - X86_INS_VPMADD52HUQ, - X86_INS_VPMADD52LUQ, - X86_INS_VPMADDUBSW, - X86_INS_VPMADDWD, - X86_INS_VPMASKMOVD, - X86_INS_VPMASKMOVQ, - X86_INS_VPMAXSB, - X86_INS_VPMAXSD, - X86_INS_VPMAXSQ, - X86_INS_VPMAXSW, - X86_INS_VPMAXUB, - X86_INS_VPMAXUD, - X86_INS_VPMAXUQ, - X86_INS_VPMAXUW, - X86_INS_VPMINSB, - X86_INS_VPMINSD, - X86_INS_VPMINSQ, - X86_INS_VPMINSW, - X86_INS_VPMINUB, - X86_INS_VPMINUD, - X86_INS_VPMINUQ, - X86_INS_VPMINUW, - X86_INS_VPMOVB2M, - X86_INS_VPMOVD2M, - X86_INS_VPMOVDB, - X86_INS_VPMOVDW, - X86_INS_VPMOVM2B, - X86_INS_VPMOVM2D, - X86_INS_VPMOVM2Q, - X86_INS_VPMOVM2W, - X86_INS_VPMOVMSKB, - X86_INS_VPMOVQ2M, - X86_INS_VPMOVQB, - X86_INS_VPMOVQD, - X86_INS_VPMOVQW, - X86_INS_VPMOVSDB, - X86_INS_VPMOVSDW, - X86_INS_VPMOVSQB, - X86_INS_VPMOVSQD, - X86_INS_VPMOVSQW, - X86_INS_VPMOVSWB, - X86_INS_VPMOVSXBD, - X86_INS_VPMOVSXBQ, - X86_INS_VPMOVSXBW, - X86_INS_VPMOVSXDQ, - X86_INS_VPMOVSXWD, - X86_INS_VPMOVSXWQ, - X86_INS_VPMOVUSDB, - X86_INS_VPMOVUSDW, - X86_INS_VPMOVUSQB, - X86_INS_VPMOVUSQD, - X86_INS_VPMOVUSQW, - X86_INS_VPMOVUSWB, - X86_INS_VPMOVW2M, - X86_INS_VPMOVWB, - X86_INS_VPMOVZXBD, - X86_INS_VPMOVZXBQ, - X86_INS_VPMOVZXBW, - X86_INS_VPMOVZXDQ, - X86_INS_VPMOVZXWD, - X86_INS_VPMOVZXWQ, - X86_INS_VPMULDQ, - X86_INS_VPMULHRSW, - X86_INS_VPMULHUW, - X86_INS_VPMULHW, - X86_INS_VPMULLD, - X86_INS_VPMULLQ, - X86_INS_VPMULLW, - X86_INS_VPMULTISHIFTQB, - X86_INS_VPMULUDQ, - X86_INS_VPOPCNTB, - X86_INS_VPOPCNTD, - X86_INS_VPOPCNTQ, - X86_INS_VPOPCNTW, - X86_INS_VPORD, - X86_INS_VPORQ, - X86_INS_VPOR, - X86_INS_VPPERM, - X86_INS_VPROLD, - X86_INS_VPROLQ, - X86_INS_VPROLVD, - X86_INS_VPROLVQ, - X86_INS_VPRORD, - X86_INS_VPRORQ, - X86_INS_VPRORVD, - X86_INS_VPRORVQ, - X86_INS_VPROTB, - X86_INS_VPROTD, - X86_INS_VPROTQ, - X86_INS_VPROTW, - X86_INS_VPSADBW, - X86_INS_VPSCATTERDD, - X86_INS_VPSCATTERDQ, - X86_INS_VPSCATTERQD, - X86_INS_VPSCATTERQQ, - X86_INS_VPSHAB, - X86_INS_VPSHAD, - X86_INS_VPSHAQ, - X86_INS_VPSHAW, - X86_INS_VPSHLB, - X86_INS_VPSHLDD, - X86_INS_VPSHLDQ, - X86_INS_VPSHLDVD, - X86_INS_VPSHLDVQ, - X86_INS_VPSHLDVW, - X86_INS_VPSHLDW, - X86_INS_VPSHLD, - X86_INS_VPSHLQ, - X86_INS_VPSHLW, - X86_INS_VPSHRDD, - X86_INS_VPSHRDQ, - X86_INS_VPSHRDVD, - X86_INS_VPSHRDVQ, - X86_INS_VPSHRDVW, - X86_INS_VPSHRDW, - X86_INS_VPSHUFBITQMB, - X86_INS_VPSHUFB, - X86_INS_VPSHUFD, - X86_INS_VPSHUFHW, - X86_INS_VPSHUFLW, - X86_INS_VPSIGNB, - X86_INS_VPSIGND, - X86_INS_VPSIGNW, - X86_INS_VPSLLDQ, - X86_INS_VPSLLD, - X86_INS_VPSLLQ, - X86_INS_VPSLLVD, - X86_INS_VPSLLVQ, - X86_INS_VPSLLVW, - X86_INS_VPSLLW, - X86_INS_VPSRAD, - X86_INS_VPSRAQ, - X86_INS_VPSRAVD, - X86_INS_VPSRAVQ, - X86_INS_VPSRAVW, - X86_INS_VPSRAW, - X86_INS_VPSRLDQ, - X86_INS_VPSRLD, - X86_INS_VPSRLQ, - X86_INS_VPSRLVD, - X86_INS_VPSRLVQ, - X86_INS_VPSRLVW, - X86_INS_VPSRLW, - X86_INS_VPSUBB, - X86_INS_VPSUBD, - X86_INS_VPSUBQ, - X86_INS_VPSUBSB, - X86_INS_VPSUBSW, - X86_INS_VPSUBUSB, - X86_INS_VPSUBUSW, - X86_INS_VPSUBW, - X86_INS_VPTERNLOGD, - X86_INS_VPTERNLOGQ, - X86_INS_VPTESTMB, - X86_INS_VPTESTMD, - X86_INS_VPTESTMQ, - X86_INS_VPTESTMW, - X86_INS_VPTESTNMB, - X86_INS_VPTESTNMD, - X86_INS_VPTESTNMQ, - X86_INS_VPTESTNMW, - X86_INS_VPTEST, - X86_INS_VPUNPCKHBW, - X86_INS_VPUNPCKHDQ, - X86_INS_VPUNPCKHQDQ, - X86_INS_VPUNPCKHWD, - X86_INS_VPUNPCKLBW, - X86_INS_VPUNPCKLDQ, - X86_INS_VPUNPCKLQDQ, - X86_INS_VPUNPCKLWD, - X86_INS_VPXORD, - X86_INS_VPXORQ, - X86_INS_VPXOR, - X86_INS_VRANGEPD, - X86_INS_VRANGEPS, - X86_INS_VRANGESD, - X86_INS_VRANGESS, - X86_INS_VRCP14PD, - X86_INS_VRCP14PS, - X86_INS_VRCP14SD, - X86_INS_VRCP14SS, - X86_INS_VRCP28PD, - X86_INS_VRCP28PS, - X86_INS_VRCP28SD, - X86_INS_VRCP28SS, - X86_INS_VRCPPS, - X86_INS_VRCPSS, - X86_INS_VREDUCEPD, - X86_INS_VREDUCEPS, - X86_INS_VREDUCESD, - X86_INS_VREDUCESS, - X86_INS_VRNDSCALEPD, - X86_INS_VRNDSCALEPS, - X86_INS_VRNDSCALESD, - X86_INS_VRNDSCALESS, - X86_INS_VROUNDPD, - X86_INS_VROUNDPS, - X86_INS_VROUNDSD, - X86_INS_VROUNDSS, - X86_INS_VRSQRT14PD, - X86_INS_VRSQRT14PS, - X86_INS_VRSQRT14SD, - X86_INS_VRSQRT14SS, - X86_INS_VRSQRT28PD, - X86_INS_VRSQRT28PS, - X86_INS_VRSQRT28SD, - X86_INS_VRSQRT28SS, - X86_INS_VRSQRTPS, - X86_INS_VRSQRTSS, - X86_INS_VSCALEFPD, - X86_INS_VSCALEFPS, - X86_INS_VSCALEFSD, - X86_INS_VSCALEFSS, - X86_INS_VSCATTERDPD, - X86_INS_VSCATTERDPS, - X86_INS_VSCATTERPF0DPD, - X86_INS_VSCATTERPF0DPS, - X86_INS_VSCATTERPF0QPD, - X86_INS_VSCATTERPF0QPS, - X86_INS_VSCATTERPF1DPD, - X86_INS_VSCATTERPF1DPS, - X86_INS_VSCATTERPF1QPD, - X86_INS_VSCATTERPF1QPS, - X86_INS_VSCATTERQPD, - X86_INS_VSCATTERQPS, - X86_INS_VSHUFF32X4, - X86_INS_VSHUFF64X2, - X86_INS_VSHUFI32X4, - X86_INS_VSHUFI64X2, - X86_INS_VSHUFPD, - X86_INS_VSHUFPS, - X86_INS_VSQRTPD, - X86_INS_VSQRTPS, - X86_INS_VSQRTSD, - X86_INS_VSQRTSS, - X86_INS_VSTMXCSR, - X86_INS_VSUBPD, - X86_INS_VSUBPS, - X86_INS_VSUBSD, - X86_INS_VSUBSS, - X86_INS_VTESTPD, - X86_INS_VTESTPS, - X86_INS_VUCOMISD, - X86_INS_VUCOMISS, - X86_INS_VUNPCKHPD, - X86_INS_VUNPCKHPS, - X86_INS_VUNPCKLPD, - X86_INS_VUNPCKLPS, - X86_INS_VXORPD, - X86_INS_VXORPS, - X86_INS_VZEROALL, - X86_INS_VZEROUPPER, - X86_INS_WAIT, - X86_INS_WBINVD, - X86_INS_WBNOINVD, - X86_INS_WRFSBASE, - X86_INS_WRGSBASE, - X86_INS_WRMSR, - X86_INS_WRPKRU, - X86_INS_WRSSD, - X86_INS_WRSSQ, - X86_INS_WRUSSD, - X86_INS_WRUSSQ, - X86_INS_XABORT, - X86_INS_XACQUIRE, - X86_INS_XADD, - X86_INS_XBEGIN, - X86_INS_XCHG, - X86_INS_FXCH, - X86_INS_XCRYPTCBC, - X86_INS_XCRYPTCFB, - X86_INS_XCRYPTCTR, - X86_INS_XCRYPTECB, - X86_INS_XCRYPTOFB, - X86_INS_XEND, - X86_INS_XGETBV, - X86_INS_XLATB, - X86_INS_XOR, - X86_INS_XORPD, - X86_INS_XORPS, - X86_INS_XRELEASE, - X86_INS_XRSTOR, - X86_INS_XRSTOR64, - X86_INS_XRSTORS, - X86_INS_XRSTORS64, - X86_INS_XSAVE, - X86_INS_XSAVE64, - X86_INS_XSAVEC, - X86_INS_XSAVEC64, - X86_INS_XSAVEOPT, - X86_INS_XSAVEOPT64, - X86_INS_XSAVES, - X86_INS_XSAVES64, - X86_INS_XSETBV, - X86_INS_XSHA1, - X86_INS_XSHA256, - X86_INS_XSTORE, - X86_INS_XTEST, - - X86_INS_ENDING, // mark the end of the list of insn -} x86_insn; - -/// Group of X86 instructions -typedef enum x86_insn_group { - X86_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - // Generic groups - // all jump instructions (conditional+direct+indirect jumps) - X86_GRP_JUMP, ///< = CS_GRP_JUMP - // all call instructions - X86_GRP_CALL, ///< = CS_GRP_CALL - // all return instructions - X86_GRP_RET, ///< = CS_GRP_RET - // all interrupt instructions (int+syscall) - X86_GRP_INT, ///< = CS_GRP_INT - // all interrupt return instructions - X86_GRP_IRET, ///< = CS_GRP_IRET - // all privileged instructions - X86_GRP_PRIVILEGE, ///< = CS_GRP_PRIVILEGE - // all relative branching instructions - X86_GRP_BRANCH_RELATIVE, ///< = CS_GRP_BRANCH_RELATIVE - - // Architecture-specific groups - X86_GRP_VM = 128, ///< all virtualization instructions (VT-x + AMD-V) - X86_GRP_3DNOW, - X86_GRP_AES, - X86_GRP_ADX, - X86_GRP_AVX, - X86_GRP_AVX2, - X86_GRP_AVX512, - X86_GRP_BMI, - X86_GRP_BMI2, - X86_GRP_CMOV, - X86_GRP_F16C, - X86_GRP_FMA, - X86_GRP_FMA4, - X86_GRP_FSGSBASE, - X86_GRP_HLE, - X86_GRP_MMX, - X86_GRP_MODE32, - X86_GRP_MODE64, - X86_GRP_RTM, - X86_GRP_SHA, - X86_GRP_SSE1, - X86_GRP_SSE2, - X86_GRP_SSE3, - X86_GRP_SSE41, - X86_GRP_SSE42, - X86_GRP_SSE4A, - X86_GRP_SSSE3, - X86_GRP_PCLMUL, - X86_GRP_XOP, - X86_GRP_CDI, - X86_GRP_ERI, - X86_GRP_TBM, - X86_GRP_16BITMODE, - X86_GRP_NOT64BITMODE, - X86_GRP_SGX, - X86_GRP_DQI, - X86_GRP_BWI, - X86_GRP_PFI, - X86_GRP_VLX, - X86_GRP_SMAP, - X86_GRP_NOVLX, - X86_GRP_FPU, - - X86_GRP_ENDING -} x86_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_XCORE_H -#define CAPSTONE_XCORE_H - -/* Capstone Disassembly Engine */ -/* By Nguyen Anh Quynh , 2014-2015 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// Operand type for instruction's operands -typedef enum xcore_op_type { - XCORE_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - XCORE_OP_REG, ///< = CS_OP_REG (Register operand). - XCORE_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - XCORE_OP_MEM, ///< = CS_OP_MEM (Memory operand). -} xcore_op_type; - -/// XCore registers -typedef enum xcore_reg { - XCORE_REG_INVALID = 0, - - XCORE_REG_CP, - XCORE_REG_DP, - XCORE_REG_LR, - XCORE_REG_SP, - XCORE_REG_R0, - XCORE_REG_R1, - XCORE_REG_R2, - XCORE_REG_R3, - XCORE_REG_R4, - XCORE_REG_R5, - XCORE_REG_R6, - XCORE_REG_R7, - XCORE_REG_R8, - XCORE_REG_R9, - XCORE_REG_R10, - XCORE_REG_R11, - - // pseudo registers - XCORE_REG_PC, ///< pc - - // internal thread registers - // see The-XMOS-XS1-Architecture(X7879A).pdf - XCORE_REG_SCP, ///< save pc - XCORE_REG_SSR, //< save status - XCORE_REG_ET, //< exception type - XCORE_REG_ED, //< exception data - XCORE_REG_SED, //< save exception data - XCORE_REG_KEP, //< kernel entry pointer - XCORE_REG_KSP, //< kernel stack pointer - XCORE_REG_ID, //< thread ID - - XCORE_REG_ENDING, // <-- mark the end of the list of registers -} xcore_reg; - -/// Instruction's operand referring to memory -/// This is associated with XCORE_OP_MEM operand type above -typedef struct xcore_op_mem { - uint8_t base; ///< base register, can be safely interpreted as - ///< a value of type `xcore_reg`, but it is only - ///< one byte wide - uint8_t index; ///< index register, same conditions apply here - int32_t disp; ///< displacement/offset value - int direct; ///< +1: forward, -1: backward -} xcore_op_mem; - -/// Instruction operand -typedef struct cs_xcore_op { - xcore_op_type type; ///< operand type - union { - xcore_reg reg; ///< register value for REG operand - int32_t imm; ///< immediate value for IMM operand - xcore_op_mem mem; ///< base/disp value for MEM operand - }; -} cs_xcore_op; - -/// Instruction structure -typedef struct cs_xcore { - /// Number of operands of this instruction, - /// or 0 when instruction has no operand. - uint8_t op_count; - cs_xcore_op operands[8]; ///< operands for this instruction. -} cs_xcore; - -/// XCore instruction -typedef enum xcore_insn { - XCORE_INS_INVALID = 0, - - XCORE_INS_ADD, - XCORE_INS_ANDNOT, - XCORE_INS_AND, - XCORE_INS_ASHR, - XCORE_INS_BAU, - XCORE_INS_BITREV, - XCORE_INS_BLA, - XCORE_INS_BLAT, - XCORE_INS_BL, - XCORE_INS_BF, - XCORE_INS_BT, - XCORE_INS_BU, - XCORE_INS_BRU, - XCORE_INS_BYTEREV, - XCORE_INS_CHKCT, - XCORE_INS_CLRE, - XCORE_INS_CLRPT, - XCORE_INS_CLRSR, - XCORE_INS_CLZ, - XCORE_INS_CRC8, - XCORE_INS_CRC32, - XCORE_INS_DCALL, - XCORE_INS_DENTSP, - XCORE_INS_DGETREG, - XCORE_INS_DIVS, - XCORE_INS_DIVU, - XCORE_INS_DRESTSP, - XCORE_INS_DRET, - XCORE_INS_ECALLF, - XCORE_INS_ECALLT, - XCORE_INS_EDU, - XCORE_INS_EEF, - XCORE_INS_EET, - XCORE_INS_EEU, - XCORE_INS_ENDIN, - XCORE_INS_ENTSP, - XCORE_INS_EQ, - XCORE_INS_EXTDP, - XCORE_INS_EXTSP, - XCORE_INS_FREER, - XCORE_INS_FREET, - XCORE_INS_GETD, - XCORE_INS_GET, - XCORE_INS_GETN, - XCORE_INS_GETR, - XCORE_INS_GETSR, - XCORE_INS_GETST, - XCORE_INS_GETTS, - XCORE_INS_INCT, - XCORE_INS_INIT, - XCORE_INS_INPW, - XCORE_INS_INSHR, - XCORE_INS_INT, - XCORE_INS_IN, - XCORE_INS_KCALL, - XCORE_INS_KENTSP, - XCORE_INS_KRESTSP, - XCORE_INS_KRET, - XCORE_INS_LADD, - XCORE_INS_LD16S, - XCORE_INS_LD8U, - XCORE_INS_LDA16, - XCORE_INS_LDAP, - XCORE_INS_LDAW, - XCORE_INS_LDC, - XCORE_INS_LDW, - XCORE_INS_LDIVU, - XCORE_INS_LMUL, - XCORE_INS_LSS, - XCORE_INS_LSUB, - XCORE_INS_LSU, - XCORE_INS_MACCS, - XCORE_INS_MACCU, - XCORE_INS_MJOIN, - XCORE_INS_MKMSK, - XCORE_INS_MSYNC, - XCORE_INS_MUL, - XCORE_INS_NEG, - XCORE_INS_NOT, - XCORE_INS_OR, - XCORE_INS_OUTCT, - XCORE_INS_OUTPW, - XCORE_INS_OUTSHR, - XCORE_INS_OUTT, - XCORE_INS_OUT, - XCORE_INS_PEEK, - XCORE_INS_REMS, - XCORE_INS_REMU, - XCORE_INS_RETSP, - XCORE_INS_SETCLK, - XCORE_INS_SET, - XCORE_INS_SETC, - XCORE_INS_SETD, - XCORE_INS_SETEV, - XCORE_INS_SETN, - XCORE_INS_SETPSC, - XCORE_INS_SETPT, - XCORE_INS_SETRDY, - XCORE_INS_SETSR, - XCORE_INS_SETTW, - XCORE_INS_SETV, - XCORE_INS_SEXT, - XCORE_INS_SHL, - XCORE_INS_SHR, - XCORE_INS_SSYNC, - XCORE_INS_ST16, - XCORE_INS_ST8, - XCORE_INS_STW, - XCORE_INS_SUB, - XCORE_INS_SYNCR, - XCORE_INS_TESTCT, - XCORE_INS_TESTLCL, - XCORE_INS_TESTWCT, - XCORE_INS_TSETMR, - XCORE_INS_START, - XCORE_INS_WAITEF, - XCORE_INS_WAITET, - XCORE_INS_WAITEU, - XCORE_INS_XOR, - XCORE_INS_ZEXT, - - XCORE_INS_ENDING, // <-- mark the end of the list of instructions -} xcore_insn; - -/// Group of XCore instructions -typedef enum xcore_insn_group { - XCORE_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - // Generic groups - // all jump instructions (conditional+direct+indirect jumps) - XCORE_GRP_JUMP, ///< = CS_GRP_JUMP - - XCORE_GRP_ENDING, // <-- mark the end of the list of groups -} xcore_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -/* Capstone Disassembly Engine */ -/* TMS320C64x Backend by Fotis Loukos 2016 */ - -#ifndef CAPSTONE_TMS320C64X_H -#define CAPSTONE_TMS320C64X_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -typedef enum tms320c64x_op_type { - TMS320C64X_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - TMS320C64X_OP_REG, ///< = CS_OP_REG (Register operand). - TMS320C64X_OP_IMM, ///< = CS_OP_IMM (Immediate operand). - TMS320C64X_OP_MEM, ///< = CS_OP_MEM (Memory operand). - TMS320C64X_OP_REGPAIR = 64, ///< Register pair for double word ops -} tms320c64x_op_type; - -typedef enum tms320c64x_mem_disp { - TMS320C64X_MEM_DISP_INVALID = 0, - TMS320C64X_MEM_DISP_CONSTANT, - TMS320C64X_MEM_DISP_REGISTER, -} tms320c64x_mem_disp; - -typedef enum tms320c64x_mem_dir { - TMS320C64X_MEM_DIR_INVALID = 0, - TMS320C64X_MEM_DIR_FW, - TMS320C64X_MEM_DIR_BW, -} tms320c64x_mem_dir; - -typedef enum tms320c64x_mem_mod { - TMS320C64X_MEM_MOD_INVALID = 0, - TMS320C64X_MEM_MOD_NO, - TMS320C64X_MEM_MOD_PRE, - TMS320C64X_MEM_MOD_POST, -} tms320c64x_mem_mod; - -typedef struct tms320c64x_op_mem { - unsigned int base; ///< base register - unsigned int disp; ///< displacement/offset value - unsigned int unit; ///< unit of base and offset register - unsigned int scaled; ///< offset scaled - unsigned int disptype; ///< displacement type - unsigned int direction; ///< direction - unsigned int modify; ///< modification -} tms320c64x_op_mem; - -typedef struct cs_tms320c64x_op { - tms320c64x_op_type type; ///< operand type - union { - unsigned int reg; ///< register value for REG operand or first register for REGPAIR operand - int32_t imm; ///< immediate value for IMM operand - tms320c64x_op_mem mem; ///< base/disp value for MEM operand - }; -} cs_tms320c64x_op; - -typedef struct cs_tms320c64x { - uint8_t op_count; - cs_tms320c64x_op operands[8]; ///< operands for this instruction. - struct { - unsigned int reg; - unsigned int zero; - } condition; - struct { - unsigned int unit; - unsigned int side; - unsigned int crosspath; - } funit; - unsigned int parallel; -} cs_tms320c64x; - -typedef enum tms320c64x_reg { - TMS320C64X_REG_INVALID = 0, - - TMS320C64X_REG_AMR, - TMS320C64X_REG_CSR, - TMS320C64X_REG_DIER, - TMS320C64X_REG_DNUM, - TMS320C64X_REG_ECR, - TMS320C64X_REG_GFPGFR, - TMS320C64X_REG_GPLYA, - TMS320C64X_REG_GPLYB, - TMS320C64X_REG_ICR, - TMS320C64X_REG_IER, - TMS320C64X_REG_IERR, - TMS320C64X_REG_ILC, - TMS320C64X_REG_IRP, - TMS320C64X_REG_ISR, - TMS320C64X_REG_ISTP, - TMS320C64X_REG_ITSR, - TMS320C64X_REG_NRP, - TMS320C64X_REG_NTSR, - TMS320C64X_REG_REP, - TMS320C64X_REG_RILC, - TMS320C64X_REG_SSR, - TMS320C64X_REG_TSCH, - TMS320C64X_REG_TSCL, - TMS320C64X_REG_TSR, - TMS320C64X_REG_A0, - TMS320C64X_REG_A1, - TMS320C64X_REG_A2, - TMS320C64X_REG_A3, - TMS320C64X_REG_A4, - TMS320C64X_REG_A5, - TMS320C64X_REG_A6, - TMS320C64X_REG_A7, - TMS320C64X_REG_A8, - TMS320C64X_REG_A9, - TMS320C64X_REG_A10, - TMS320C64X_REG_A11, - TMS320C64X_REG_A12, - TMS320C64X_REG_A13, - TMS320C64X_REG_A14, - TMS320C64X_REG_A15, - TMS320C64X_REG_A16, - TMS320C64X_REG_A17, - TMS320C64X_REG_A18, - TMS320C64X_REG_A19, - TMS320C64X_REG_A20, - TMS320C64X_REG_A21, - TMS320C64X_REG_A22, - TMS320C64X_REG_A23, - TMS320C64X_REG_A24, - TMS320C64X_REG_A25, - TMS320C64X_REG_A26, - TMS320C64X_REG_A27, - TMS320C64X_REG_A28, - TMS320C64X_REG_A29, - TMS320C64X_REG_A30, - TMS320C64X_REG_A31, - TMS320C64X_REG_B0, - TMS320C64X_REG_B1, - TMS320C64X_REG_B2, - TMS320C64X_REG_B3, - TMS320C64X_REG_B4, - TMS320C64X_REG_B5, - TMS320C64X_REG_B6, - TMS320C64X_REG_B7, - TMS320C64X_REG_B8, - TMS320C64X_REG_B9, - TMS320C64X_REG_B10, - TMS320C64X_REG_B11, - TMS320C64X_REG_B12, - TMS320C64X_REG_B13, - TMS320C64X_REG_B14, - TMS320C64X_REG_B15, - TMS320C64X_REG_B16, - TMS320C64X_REG_B17, - TMS320C64X_REG_B18, - TMS320C64X_REG_B19, - TMS320C64X_REG_B20, - TMS320C64X_REG_B21, - TMS320C64X_REG_B22, - TMS320C64X_REG_B23, - TMS320C64X_REG_B24, - TMS320C64X_REG_B25, - TMS320C64X_REG_B26, - TMS320C64X_REG_B27, - TMS320C64X_REG_B28, - TMS320C64X_REG_B29, - TMS320C64X_REG_B30, - TMS320C64X_REG_B31, - TMS320C64X_REG_PCE1, - - TMS320C64X_REG_ENDING, // <-- mark the end of the list of registers - - // Alias registers - TMS320C64X_REG_EFR = TMS320C64X_REG_ECR, - TMS320C64X_REG_IFR = TMS320C64X_REG_ISR, -} tms320c64x_reg; - -typedef enum tms320c64x_insn { - TMS320C64X_INS_INVALID = 0, - - TMS320C64X_INS_ABS, - TMS320C64X_INS_ABS2, - TMS320C64X_INS_ADD, - TMS320C64X_INS_ADD2, - TMS320C64X_INS_ADD4, - TMS320C64X_INS_ADDAB, - TMS320C64X_INS_ADDAD, - TMS320C64X_INS_ADDAH, - TMS320C64X_INS_ADDAW, - TMS320C64X_INS_ADDK, - TMS320C64X_INS_ADDKPC, - TMS320C64X_INS_ADDU, - TMS320C64X_INS_AND, - TMS320C64X_INS_ANDN, - TMS320C64X_INS_AVG2, - TMS320C64X_INS_AVGU4, - TMS320C64X_INS_B, - TMS320C64X_INS_BDEC, - TMS320C64X_INS_BITC4, - TMS320C64X_INS_BNOP, - TMS320C64X_INS_BPOS, - TMS320C64X_INS_CLR, - TMS320C64X_INS_CMPEQ, - TMS320C64X_INS_CMPEQ2, - TMS320C64X_INS_CMPEQ4, - TMS320C64X_INS_CMPGT, - TMS320C64X_INS_CMPGT2, - TMS320C64X_INS_CMPGTU4, - TMS320C64X_INS_CMPLT, - TMS320C64X_INS_CMPLTU, - TMS320C64X_INS_DEAL, - TMS320C64X_INS_DOTP2, - TMS320C64X_INS_DOTPN2, - TMS320C64X_INS_DOTPNRSU2, - TMS320C64X_INS_DOTPRSU2, - TMS320C64X_INS_DOTPSU4, - TMS320C64X_INS_DOTPU4, - TMS320C64X_INS_EXT, - TMS320C64X_INS_EXTU, - TMS320C64X_INS_GMPGTU, - TMS320C64X_INS_GMPY4, - TMS320C64X_INS_LDB, - TMS320C64X_INS_LDBU, - TMS320C64X_INS_LDDW, - TMS320C64X_INS_LDH, - TMS320C64X_INS_LDHU, - TMS320C64X_INS_LDNDW, - TMS320C64X_INS_LDNW, - TMS320C64X_INS_LDW, - TMS320C64X_INS_LMBD, - TMS320C64X_INS_MAX2, - TMS320C64X_INS_MAXU4, - TMS320C64X_INS_MIN2, - TMS320C64X_INS_MINU4, - TMS320C64X_INS_MPY, - TMS320C64X_INS_MPY2, - TMS320C64X_INS_MPYH, - TMS320C64X_INS_MPYHI, - TMS320C64X_INS_MPYHIR, - TMS320C64X_INS_MPYHL, - TMS320C64X_INS_MPYHLU, - TMS320C64X_INS_MPYHSLU, - TMS320C64X_INS_MPYHSU, - TMS320C64X_INS_MPYHU, - TMS320C64X_INS_MPYHULS, - TMS320C64X_INS_MPYHUS, - TMS320C64X_INS_MPYLH, - TMS320C64X_INS_MPYLHU, - TMS320C64X_INS_MPYLI, - TMS320C64X_INS_MPYLIR, - TMS320C64X_INS_MPYLSHU, - TMS320C64X_INS_MPYLUHS, - TMS320C64X_INS_MPYSU, - TMS320C64X_INS_MPYSU4, - TMS320C64X_INS_MPYU, - TMS320C64X_INS_MPYU4, - TMS320C64X_INS_MPYUS, - TMS320C64X_INS_MVC, - TMS320C64X_INS_MVD, - TMS320C64X_INS_MVK, - TMS320C64X_INS_MVKL, - TMS320C64X_INS_MVKLH, - TMS320C64X_INS_NOP, - TMS320C64X_INS_NORM, - TMS320C64X_INS_OR, - TMS320C64X_INS_PACK2, - TMS320C64X_INS_PACKH2, - TMS320C64X_INS_PACKH4, - TMS320C64X_INS_PACKHL2, - TMS320C64X_INS_PACKL4, - TMS320C64X_INS_PACKLH2, - TMS320C64X_INS_ROTL, - TMS320C64X_INS_SADD, - TMS320C64X_INS_SADD2, - TMS320C64X_INS_SADDU4, - TMS320C64X_INS_SADDUS2, - TMS320C64X_INS_SAT, - TMS320C64X_INS_SET, - TMS320C64X_INS_SHFL, - TMS320C64X_INS_SHL, - TMS320C64X_INS_SHLMB, - TMS320C64X_INS_SHR, - TMS320C64X_INS_SHR2, - TMS320C64X_INS_SHRMB, - TMS320C64X_INS_SHRU, - TMS320C64X_INS_SHRU2, - TMS320C64X_INS_SMPY, - TMS320C64X_INS_SMPY2, - TMS320C64X_INS_SMPYH, - TMS320C64X_INS_SMPYHL, - TMS320C64X_INS_SMPYLH, - TMS320C64X_INS_SPACK2, - TMS320C64X_INS_SPACKU4, - TMS320C64X_INS_SSHL, - TMS320C64X_INS_SSHVL, - TMS320C64X_INS_SSHVR, - TMS320C64X_INS_SSUB, - TMS320C64X_INS_STB, - TMS320C64X_INS_STDW, - TMS320C64X_INS_STH, - TMS320C64X_INS_STNDW, - TMS320C64X_INS_STNW, - TMS320C64X_INS_STW, - TMS320C64X_INS_SUB, - TMS320C64X_INS_SUB2, - TMS320C64X_INS_SUB4, - TMS320C64X_INS_SUBAB, - TMS320C64X_INS_SUBABS4, - TMS320C64X_INS_SUBAH, - TMS320C64X_INS_SUBAW, - TMS320C64X_INS_SUBC, - TMS320C64X_INS_SUBU, - TMS320C64X_INS_SWAP4, - TMS320C64X_INS_UNPKHU4, - TMS320C64X_INS_UNPKLU4, - TMS320C64X_INS_XOR, - TMS320C64X_INS_XPND2, - TMS320C64X_INS_XPND4, - // Aliases - TMS320C64X_INS_IDLE, - TMS320C64X_INS_MV, - TMS320C64X_INS_NEG, - TMS320C64X_INS_NOT, - TMS320C64X_INS_SWAP2, - TMS320C64X_INS_ZERO, - - TMS320C64X_INS_ENDING, // <-- mark the end of the list of instructions -} tms320c64x_insn; - -typedef enum tms320c64x_insn_group { - TMS320C64X_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - TMS320C64X_GRP_JUMP, ///< = CS_GRP_JUMP - - TMS320C64X_GRP_FUNIT_D = 128, - TMS320C64X_GRP_FUNIT_L, - TMS320C64X_GRP_FUNIT_M, - TMS320C64X_GRP_FUNIT_S, - TMS320C64X_GRP_FUNIT_NO, - - TMS320C64X_GRP_ENDING, // <-- mark the end of the list of groups -} tms320c64x_insn_group; - -typedef enum tms320c64x_funit { - TMS320C64X_FUNIT_INVALID = 0, - TMS320C64X_FUNIT_D, - TMS320C64X_FUNIT_L, - TMS320C64X_FUNIT_M, - TMS320C64X_FUNIT_S, - TMS320C64X_FUNIT_NO -} tms320c64x_funit; - -#ifdef __cplusplus -} -#endif - -#endif - -#ifndef CAPSTONE_M680X_H -#define CAPSTONE_M680X_H - -/* Capstone Disassembly Engine */ -/* M680X Backend by Wolfgang Schwotzer 2017 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -#define M680X_OPERAND_COUNT 9 - -/// M680X registers and special registers -typedef enum m680x_reg { - M680X_REG_INVALID = 0, - - M680X_REG_A, ///< M6800/1/2/3/9, HD6301/9 - M680X_REG_B, ///< M6800/1/2/3/9, HD6301/9 - M680X_REG_E, ///< HD6309 - M680X_REG_F, ///< HD6309 - M680X_REG_0, ///< HD6309 - - M680X_REG_D, ///< M6801/3/9, HD6301/9 - M680X_REG_W, ///< HD6309 - - M680X_REG_CC, ///< M6800/1/2/3/9, M6301/9 - M680X_REG_DP, ///< M6809/M6309 - M680X_REG_MD, ///< M6309 - - M680X_REG_HX, ///< M6808 - M680X_REG_H, ///< M6808 - M680X_REG_X, ///< M6800/1/2/3/9, M6301/9 - M680X_REG_Y, ///< M6809/M6309 - M680X_REG_S, ///< M6809/M6309 - M680X_REG_U, ///< M6809/M6309 - M680X_REG_V, ///< M6309 - - M680X_REG_Q, ///< M6309 - - M680X_REG_PC, ///< M6800/1/2/3/9, M6301/9 - - M680X_REG_TMP2, ///< CPU12 - M680X_REG_TMP3, ///< CPU12 - - M680X_REG_ENDING, ///< <-- mark the end of the list of registers -} m680x_reg; - -/// Operand type for instruction's operands -typedef enum m680x_op_type { - M680X_OP_INVALID = 0, ///< = CS_OP_INVALID (Uninitialized). - M680X_OP_REGISTER, ///< = Register operand. - M680X_OP_IMMEDIATE, ///< = Immediate operand. - M680X_OP_INDEXED, ///< = Indexed addressing operand. - M680X_OP_EXTENDED, ///< = Extended addressing operand. - M680X_OP_DIRECT, ///< = Direct addressing operand. - M680X_OP_RELATIVE, ///< = Relative addressing operand. - M680X_OP_CONSTANT, ///< = constant operand (Displayed as number only). - ///< Used e.g. for a bit index or page number. -} m680x_op_type; - -// Supported bit values for mem.idx.offset_bits -#define M680X_OFFSET_NONE 0 -#define M680X_OFFSET_BITS_5 5 -#define M680X_OFFSET_BITS_8 8 -#define M680X_OFFSET_BITS_9 9 -#define M680X_OFFSET_BITS_16 16 - -// Supported bit flags for mem.idx.flags -// These flags can be combined -#define M680X_IDX_INDIRECT 1 -#define M680X_IDX_NO_COMMA 2 -#define M680X_IDX_POST_INC_DEC 4 - -/// Instruction's operand referring to indexed addressing -typedef struct m680x_op_idx { - m680x_reg base_reg; ///< base register (or M680X_REG_INVALID if - ///< irrelevant) - m680x_reg offset_reg; ///< offset register (or M680X_REG_INVALID if - ///< irrelevant) - int16_t offset; ///< 5-,8- or 16-bit offset. See also offset_bits. - uint16_t offset_addr; ///< = offset addr. if base_reg == M680X_REG_PC. - ///< calculated as offset + PC - uint8_t offset_bits; ///< offset width in bits for indexed addressing - int8_t inc_dec; ///< inc. or dec. value: - ///< 0: no inc-/decrement - ///< 1 .. 8: increment by 1 .. 8 - ///< -1 .. -8: decrement by 1 .. 8 - ///< if flag M680X_IDX_POST_INC_DEC set it is post - ///< inc-/decrement otherwise pre inc-/decrement - uint8_t flags; ///< 8-bit flags (see above) -} m680x_op_idx; - -/// Instruction's memory operand referring to relative addressing (Bcc/LBcc) -typedef struct m680x_op_rel { - uint16_t address; ///< The absolute address. - ///< calculated as PC + offset. PC is the first - ///< address after the instruction. - int16_t offset; ///< the offset/displacement value -} m680x_op_rel; - -/// Instruction's operand referring to extended addressing -typedef struct m680x_op_ext { - uint16_t address; ///< The absolute address - bool indirect; ///< true if extended indirect addressing -} m680x_op_ext; - -/// Instruction operand -typedef struct cs_m680x_op { - m680x_op_type type; - union { - int32_t imm; ///< immediate value for IMM operand - m680x_reg reg; ///< register value for REG operand - m680x_op_idx idx; ///< Indexed addressing operand - m680x_op_rel rel; ///< Relative address. operand (Bcc/LBcc) - m680x_op_ext ext; ///< Extended address - uint8_t direct_addr; ///<, 2013-2018 */ - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// Instruction structure -typedef struct cs_evm { - unsigned char pop; ///< number of items popped from the stack - unsigned char push; ///< number of items pushed into the stack - unsigned int fee; ///< gas fee for the instruction -} cs_evm; - -/// EVM instruction -typedef enum evm_insn { - EVM_INS_STOP = 0, - EVM_INS_ADD = 1, - EVM_INS_MUL = 2, - EVM_INS_SUB = 3, - EVM_INS_DIV = 4, - EVM_INS_SDIV = 5, - EVM_INS_MOD = 6, - EVM_INS_SMOD = 7, - EVM_INS_ADDMOD = 8, - EVM_INS_MULMOD = 9, - EVM_INS_EXP = 10, - EVM_INS_SIGNEXTEND = 11, - EVM_INS_LT = 16, - EVM_INS_GT = 17, - EVM_INS_SLT = 18, - EVM_INS_SGT = 19, - EVM_INS_EQ = 20, - EVM_INS_ISZERO = 21, - EVM_INS_AND = 22, - EVM_INS_OR = 23, - EVM_INS_XOR = 24, - EVM_INS_NOT = 25, - EVM_INS_BYTE = 26, - EVM_INS_SHA3 = 32, - EVM_INS_ADDRESS = 48, - EVM_INS_BALANCE = 49, - EVM_INS_ORIGIN = 50, - EVM_INS_CALLER = 51, - EVM_INS_CALLVALUE = 52, - EVM_INS_CALLDATALOAD = 53, - EVM_INS_CALLDATASIZE = 54, - EVM_INS_CALLDATACOPY = 55, - EVM_INS_CODESIZE = 56, - EVM_INS_CODECOPY = 57, - EVM_INS_GASPRICE = 58, - EVM_INS_EXTCODESIZE = 59, - EVM_INS_EXTCODECOPY = 60, - EVM_INS_RETURNDATASIZE = 61, - EVM_INS_RETURNDATACOPY = 62, - EVM_INS_BLOCKHASH = 64, - EVM_INS_COINBASE = 65, - EVM_INS_TIMESTAMP = 66, - EVM_INS_NUMBER = 67, - EVM_INS_DIFFICULTY = 68, - EVM_INS_GASLIMIT = 69, - EVM_INS_POP = 80, - EVM_INS_MLOAD = 81, - EVM_INS_MSTORE = 82, - EVM_INS_MSTORE8 = 83, - EVM_INS_SLOAD = 84, - EVM_INS_SSTORE = 85, - EVM_INS_JUMP = 86, - EVM_INS_JUMPI = 87, - EVM_INS_PC = 88, - EVM_INS_MSIZE = 89, - EVM_INS_GAS = 90, - EVM_INS_JUMPDEST = 91, - EVM_INS_PUSH1 = 96, - EVM_INS_PUSH2 = 97, - EVM_INS_PUSH3 = 98, - EVM_INS_PUSH4 = 99, - EVM_INS_PUSH5 = 100, - EVM_INS_PUSH6 = 101, - EVM_INS_PUSH7 = 102, - EVM_INS_PUSH8 = 103, - EVM_INS_PUSH9 = 104, - EVM_INS_PUSH10 = 105, - EVM_INS_PUSH11 = 106, - EVM_INS_PUSH12 = 107, - EVM_INS_PUSH13 = 108, - EVM_INS_PUSH14 = 109, - EVM_INS_PUSH15 = 110, - EVM_INS_PUSH16 = 111, - EVM_INS_PUSH17 = 112, - EVM_INS_PUSH18 = 113, - EVM_INS_PUSH19 = 114, - EVM_INS_PUSH20 = 115, - EVM_INS_PUSH21 = 116, - EVM_INS_PUSH22 = 117, - EVM_INS_PUSH23 = 118, - EVM_INS_PUSH24 = 119, - EVM_INS_PUSH25 = 120, - EVM_INS_PUSH26 = 121, - EVM_INS_PUSH27 = 122, - EVM_INS_PUSH28 = 123, - EVM_INS_PUSH29 = 124, - EVM_INS_PUSH30 = 125, - EVM_INS_PUSH31 = 126, - EVM_INS_PUSH32 = 127, - EVM_INS_DUP1 = 128, - EVM_INS_DUP2 = 129, - EVM_INS_DUP3 = 130, - EVM_INS_DUP4 = 131, - EVM_INS_DUP5 = 132, - EVM_INS_DUP6 = 133, - EVM_INS_DUP7 = 134, - EVM_INS_DUP8 = 135, - EVM_INS_DUP9 = 136, - EVM_INS_DUP10 = 137, - EVM_INS_DUP11 = 138, - EVM_INS_DUP12 = 139, - EVM_INS_DUP13 = 140, - EVM_INS_DUP14 = 141, - EVM_INS_DUP15 = 142, - EVM_INS_DUP16 = 143, - EVM_INS_SWAP1 = 144, - EVM_INS_SWAP2 = 145, - EVM_INS_SWAP3 = 146, - EVM_INS_SWAP4 = 147, - EVM_INS_SWAP5 = 148, - EVM_INS_SWAP6 = 149, - EVM_INS_SWAP7 = 150, - EVM_INS_SWAP8 = 151, - EVM_INS_SWAP9 = 152, - EVM_INS_SWAP10 = 153, - EVM_INS_SWAP11 = 154, - EVM_INS_SWAP12 = 155, - EVM_INS_SWAP13 = 156, - EVM_INS_SWAP14 = 157, - EVM_INS_SWAP15 = 158, - EVM_INS_SWAP16 = 159, - EVM_INS_LOG0 = 160, - EVM_INS_LOG1 = 161, - EVM_INS_LOG2 = 162, - EVM_INS_LOG3 = 163, - EVM_INS_LOG4 = 164, - EVM_INS_CREATE = 240, - EVM_INS_CALL = 241, - EVM_INS_CALLCODE = 242, - EVM_INS_RETURN = 243, - EVM_INS_DELEGATECALL = 244, - EVM_INS_CALLBLACKBOX = 245, - EVM_INS_STATICCALL = 250, - EVM_INS_REVERT = 253, - EVM_INS_SUICIDE = 255, - - EVM_INS_INVALID = 512, - EVM_INS_ENDING, // <-- mark the end of the list of instructions -} evm_insn; - -/// Group of EVM instructions -typedef enum evm_insn_group { - EVM_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - EVM_GRP_JUMP, ///< all jump instructions - - EVM_GRP_MATH = 8, ///< math instructions - EVM_GRP_STACK_WRITE, ///< instructions write to stack - EVM_GRP_STACK_READ, ///< instructions read from stack - EVM_GRP_MEM_WRITE, ///< instructions write to memory - EVM_GRP_MEM_READ, ///< instructions read from memory - EVM_GRP_STORE_WRITE, ///< instructions write to storage - EVM_GRP_STORE_READ, ///< instructions read from storage - EVM_GRP_HALT, ///< instructions halt execution - - EVM_GRP_ENDING, ///< <-- mark the end of the list of groups -} evm_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_RISCV_H -#define CAPSTONE_RISCV_H - -/* Capstone Disassembly Engine */ -/* RISC-V Backend By Rodrigo Cortes Porto & - Shawn Chang , HardenedLinux@2018 */ - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_MSC_VER) || !defined(_KERNEL_MODE) -#include -#endif - - -// GCC MIPS toolchain has a default macro called "mips" which breaks -// compilation -//#undef riscv - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -//> Operand type for instruction's operands -typedef enum riscv_op_type { - RISCV_OP_INVALID = 0, // = CS_OP_INVALID (Uninitialized). - RISCV_OP_REG, // = CS_OP_REG (Register operand). - RISCV_OP_IMM, // = CS_OP_IMM (Immediate operand). - RISCV_OP_MEM, // = CS_OP_MEM (Memory operand). -} riscv_op_type; - -// Instruction's operand referring to memory -// This is associated with RISCV_OP_MEM operand type above -typedef struct riscv_op_mem { - unsigned int base; // base register - int64_t disp; // displacement/offset value -} riscv_op_mem; - -// Instruction operand -typedef struct cs_riscv_op { - riscv_op_type type; // operand type - union { - unsigned int reg; // register value for REG operand - int64_t imm; // immediate value for IMM operand - riscv_op_mem mem; // base/disp value for MEM operand - }; -} cs_riscv_op; - -// Instruction structure -typedef struct cs_riscv { - // Does this instruction need effective address or not. - bool need_effective_addr; - // Number of operands of this instruction, - // or 0 when instruction has no operand. - uint8_t op_count; - cs_riscv_op operands[8]; // operands for this instruction. -} cs_riscv; - -//> RISCV registers -typedef enum riscv_reg { - RISCV_REG_INVALID = 0, - //> General purpose registers - RISCV_REG_X0, // "zero" - RISCV_REG_ZERO = RISCV_REG_X0, // "zero" - RISCV_REG_X1, // "ra" - RISCV_REG_RA = RISCV_REG_X1, // "ra" - RISCV_REG_X2, // "sp" - RISCV_REG_SP = RISCV_REG_X2, // "sp" - RISCV_REG_X3, // "gp" - RISCV_REG_GP = RISCV_REG_X3, // "gp" - RISCV_REG_X4, // "tp" - RISCV_REG_TP = RISCV_REG_X4, // "tp" - RISCV_REG_X5, // "t0" - RISCV_REG_T0 = RISCV_REG_X5, // "t0" - RISCV_REG_X6, // "t1" - RISCV_REG_T1 = RISCV_REG_X6, // "t1" - RISCV_REG_X7, // "t2" - RISCV_REG_T2 = RISCV_REG_X7, // "t2" - RISCV_REG_X8, // "s0/fp" - RISCV_REG_S0 = RISCV_REG_X8, // "s0" - RISCV_REG_FP = RISCV_REG_X8, // "fp" - RISCV_REG_X9, // "s1" - RISCV_REG_S1 = RISCV_REG_X9, // "s1" - RISCV_REG_X10, // "a0" - RISCV_REG_A0 = RISCV_REG_X10, // "a0" - RISCV_REG_X11, // "a1" - RISCV_REG_A1 = RISCV_REG_X11, // "a1" - RISCV_REG_X12, // "a2" - RISCV_REG_A2 = RISCV_REG_X12, // "a2" - RISCV_REG_X13, // "a3" - RISCV_REG_A3 = RISCV_REG_X13, // "a3" - RISCV_REG_X14, // "a4" - RISCV_REG_A4 = RISCV_REG_X14, // "a4" - RISCV_REG_X15, // "a5" - RISCV_REG_A5 = RISCV_REG_X15, // "a5" - RISCV_REG_X16, // "a6" - RISCV_REG_A6 = RISCV_REG_X16, // "a6" - RISCV_REG_X17, // "a7" - RISCV_REG_A7 = RISCV_REG_X17, // "a7" - RISCV_REG_X18, // "s2" - RISCV_REG_S2 = RISCV_REG_X18, // "s2" - RISCV_REG_X19, // "s3" - RISCV_REG_S3 = RISCV_REG_X19, // "s3" - RISCV_REG_X20, // "s4" - RISCV_REG_S4 = RISCV_REG_X20, // "s4" - RISCV_REG_X21, // "s5" - RISCV_REG_S5 = RISCV_REG_X21, // "s5" - RISCV_REG_X22, // "s6" - RISCV_REG_S6 = RISCV_REG_X22, // "s6" - RISCV_REG_X23, // "s7" - RISCV_REG_S7 = RISCV_REG_X23, // "s7" - RISCV_REG_X24, // "s8" - RISCV_REG_S8 = RISCV_REG_X24, // "s8" - RISCV_REG_X25, // "s9" - RISCV_REG_S9 = RISCV_REG_X25, // "s9" - RISCV_REG_X26, // "s10" - RISCV_REG_S10 = RISCV_REG_X26, // "s10" - RISCV_REG_X27, // "s11" - RISCV_REG_S11 = RISCV_REG_X27, // "s11" - RISCV_REG_X28, // "t3" - RISCV_REG_T3 = RISCV_REG_X28, // "t3" - RISCV_REG_X29, // "t4" - RISCV_REG_T4 = RISCV_REG_X29, // "t4" - RISCV_REG_X30, // "t5" - RISCV_REG_T5 = RISCV_REG_X30, // "t5" - RISCV_REG_X31, // "t6" - RISCV_REG_T6 = RISCV_REG_X31, // "t6" - - //> Floating-point registers - RISCV_REG_F0_32, // "ft0" - RISCV_REG_F0_64, // "ft0" - RISCV_REG_F1_32, // "ft1" - RISCV_REG_F1_64, // "ft1" - RISCV_REG_F2_32, // "ft2" - RISCV_REG_F2_64, // "ft2" - RISCV_REG_F3_32, // "ft3" - RISCV_REG_F3_64, // "ft3" - RISCV_REG_F4_32, // "ft4" - RISCV_REG_F4_64, // "ft4" - RISCV_REG_F5_32, // "ft5" - RISCV_REG_F5_64, // "ft5" - RISCV_REG_F6_32, // "ft6" - RISCV_REG_F6_64, // "ft6" - RISCV_REG_F7_32, // "ft7" - RISCV_REG_F7_64, // "ft7" - RISCV_REG_F8_32, // "fs0" - RISCV_REG_F8_64, // "fs0" - RISCV_REG_F9_32, // "fs1" - RISCV_REG_F9_64, // "fs1" - RISCV_REG_F10_32, // "fa0" - RISCV_REG_F10_64, // "fa0" - RISCV_REG_F11_32, // "fa1" - RISCV_REG_F11_64, // "fa1" - RISCV_REG_F12_32, // "fa2" - RISCV_REG_F12_64, // "fa2" - RISCV_REG_F13_32, // "fa3" - RISCV_REG_F13_64, // "fa3" - RISCV_REG_F14_32, // "fa4" - RISCV_REG_F14_64, // "fa4" - RISCV_REG_F15_32, // "fa5" - RISCV_REG_F15_64, // "fa5" - RISCV_REG_F16_32, // "fa6" - RISCV_REG_F16_64, // "fa6" - RISCV_REG_F17_32, // "fa7" - RISCV_REG_F17_64, // "fa7" - RISCV_REG_F18_32, // "fs2" - RISCV_REG_F18_64, // "fs2" - RISCV_REG_F19_32, // "fs3" - RISCV_REG_F19_64, // "fs3" - RISCV_REG_F20_32, // "fs4" - RISCV_REG_F20_64, // "fs4" - RISCV_REG_F21_32, // "fs5" - RISCV_REG_F21_64, // "fs5" - RISCV_REG_F22_32, // "fs6" - RISCV_REG_F22_64, // "fs6" - RISCV_REG_F23_32, // "fs7" - RISCV_REG_F23_64, // "fs7" - RISCV_REG_F24_32, // "fs8" - RISCV_REG_F24_64, // "fs8" - RISCV_REG_F25_32, // "fs9" - RISCV_REG_F25_64, // "fs9" - RISCV_REG_F26_32, // "fs10" - RISCV_REG_F26_64, // "fs10" - RISCV_REG_F27_32, // "fs11" - RISCV_REG_F27_64, // "fs11" - RISCV_REG_F28_32, // "ft8" - RISCV_REG_F28_64, // "ft8" - RISCV_REG_F29_32, // "ft9" - RISCV_REG_F29_64, // "ft9" - RISCV_REG_F30_32, // "ft10" - RISCV_REG_F30_64, // "ft10" - RISCV_REG_F31_32, // "ft11" - RISCV_REG_F31_64, // "ft11" - - RISCV_REG_ENDING, // <-- mark the end of the list or registers -} riscv_reg; - -//> RISCV instruction -typedef enum riscv_insn { - RISCV_INS_INVALID = 0, - - RISCV_INS_ADD, - RISCV_INS_ADDI, - RISCV_INS_ADDIW, - RISCV_INS_ADDW, - RISCV_INS_AMOADD_D, - RISCV_INS_AMOADD_D_AQ, - RISCV_INS_AMOADD_D_AQ_RL, - RISCV_INS_AMOADD_D_RL, - RISCV_INS_AMOADD_W, - RISCV_INS_AMOADD_W_AQ, - RISCV_INS_AMOADD_W_AQ_RL, - RISCV_INS_AMOADD_W_RL, - RISCV_INS_AMOAND_D, - RISCV_INS_AMOAND_D_AQ, - RISCV_INS_AMOAND_D_AQ_RL, - RISCV_INS_AMOAND_D_RL, - RISCV_INS_AMOAND_W, - RISCV_INS_AMOAND_W_AQ, - RISCV_INS_AMOAND_W_AQ_RL, - RISCV_INS_AMOAND_W_RL, - RISCV_INS_AMOMAXU_D, - RISCV_INS_AMOMAXU_D_AQ, - RISCV_INS_AMOMAXU_D_AQ_RL, - RISCV_INS_AMOMAXU_D_RL, - RISCV_INS_AMOMAXU_W, - RISCV_INS_AMOMAXU_W_AQ, - RISCV_INS_AMOMAXU_W_AQ_RL, - RISCV_INS_AMOMAXU_W_RL, - RISCV_INS_AMOMAX_D, - RISCV_INS_AMOMAX_D_AQ, - RISCV_INS_AMOMAX_D_AQ_RL, - RISCV_INS_AMOMAX_D_RL, - RISCV_INS_AMOMAX_W, - RISCV_INS_AMOMAX_W_AQ, - RISCV_INS_AMOMAX_W_AQ_RL, - RISCV_INS_AMOMAX_W_RL, - RISCV_INS_AMOMINU_D, - RISCV_INS_AMOMINU_D_AQ, - RISCV_INS_AMOMINU_D_AQ_RL, - RISCV_INS_AMOMINU_D_RL, - RISCV_INS_AMOMINU_W, - RISCV_INS_AMOMINU_W_AQ, - RISCV_INS_AMOMINU_W_AQ_RL, - RISCV_INS_AMOMINU_W_RL, - RISCV_INS_AMOMIN_D, - RISCV_INS_AMOMIN_D_AQ, - RISCV_INS_AMOMIN_D_AQ_RL, - RISCV_INS_AMOMIN_D_RL, - RISCV_INS_AMOMIN_W, - RISCV_INS_AMOMIN_W_AQ, - RISCV_INS_AMOMIN_W_AQ_RL, - RISCV_INS_AMOMIN_W_RL, - RISCV_INS_AMOOR_D, - RISCV_INS_AMOOR_D_AQ, - RISCV_INS_AMOOR_D_AQ_RL, - RISCV_INS_AMOOR_D_RL, - RISCV_INS_AMOOR_W, - RISCV_INS_AMOOR_W_AQ, - RISCV_INS_AMOOR_W_AQ_RL, - RISCV_INS_AMOOR_W_RL, - RISCV_INS_AMOSWAP_D, - RISCV_INS_AMOSWAP_D_AQ, - RISCV_INS_AMOSWAP_D_AQ_RL, - RISCV_INS_AMOSWAP_D_RL, - RISCV_INS_AMOSWAP_W, - RISCV_INS_AMOSWAP_W_AQ, - RISCV_INS_AMOSWAP_W_AQ_RL, - RISCV_INS_AMOSWAP_W_RL, - RISCV_INS_AMOXOR_D, - RISCV_INS_AMOXOR_D_AQ, - RISCV_INS_AMOXOR_D_AQ_RL, - RISCV_INS_AMOXOR_D_RL, - RISCV_INS_AMOXOR_W, - RISCV_INS_AMOXOR_W_AQ, - RISCV_INS_AMOXOR_W_AQ_RL, - RISCV_INS_AMOXOR_W_RL, - RISCV_INS_AND, - RISCV_INS_ANDI, - RISCV_INS_AUIPC, - RISCV_INS_BEQ, - RISCV_INS_BGE, - RISCV_INS_BGEU, - RISCV_INS_BLT, - RISCV_INS_BLTU, - RISCV_INS_BNE, - RISCV_INS_CSRRC, - RISCV_INS_CSRRCI, - RISCV_INS_CSRRS, - RISCV_INS_CSRRSI, - RISCV_INS_CSRRW, - RISCV_INS_CSRRWI, - RISCV_INS_C_ADD, - RISCV_INS_C_ADDI, - RISCV_INS_C_ADDI16SP, - RISCV_INS_C_ADDI4SPN, - RISCV_INS_C_ADDIW, - RISCV_INS_C_ADDW, - RISCV_INS_C_AND, - RISCV_INS_C_ANDI, - RISCV_INS_C_BEQZ, - RISCV_INS_C_BNEZ, - RISCV_INS_C_EBREAK, - RISCV_INS_C_FLD, - RISCV_INS_C_FLDSP, - RISCV_INS_C_FLW, - RISCV_INS_C_FLWSP, - RISCV_INS_C_FSD, - RISCV_INS_C_FSDSP, - RISCV_INS_C_FSW, - RISCV_INS_C_FSWSP, - RISCV_INS_C_J, - RISCV_INS_C_JAL, - RISCV_INS_C_JALR, - RISCV_INS_C_JR, - RISCV_INS_C_LD, - RISCV_INS_C_LDSP, - RISCV_INS_C_LI, - RISCV_INS_C_LUI, - RISCV_INS_C_LW, - RISCV_INS_C_LWSP, - RISCV_INS_C_MV, - RISCV_INS_C_NOP, - RISCV_INS_C_OR, - RISCV_INS_C_SD, - RISCV_INS_C_SDSP, - RISCV_INS_C_SLLI, - RISCV_INS_C_SRAI, - RISCV_INS_C_SRLI, - RISCV_INS_C_SUB, - RISCV_INS_C_SUBW, - RISCV_INS_C_SW, - RISCV_INS_C_SWSP, - RISCV_INS_C_UNIMP, - RISCV_INS_C_XOR, - RISCV_INS_DIV, - RISCV_INS_DIVU, - RISCV_INS_DIVUW, - RISCV_INS_DIVW, - RISCV_INS_EBREAK, - RISCV_INS_ECALL, - RISCV_INS_FADD_D, - RISCV_INS_FADD_S, - RISCV_INS_FCLASS_D, - RISCV_INS_FCLASS_S, - RISCV_INS_FCVT_D_L, - RISCV_INS_FCVT_D_LU, - RISCV_INS_FCVT_D_S, - RISCV_INS_FCVT_D_W, - RISCV_INS_FCVT_D_WU, - RISCV_INS_FCVT_LU_D, - RISCV_INS_FCVT_LU_S, - RISCV_INS_FCVT_L_D, - RISCV_INS_FCVT_L_S, - RISCV_INS_FCVT_S_D, - RISCV_INS_FCVT_S_L, - RISCV_INS_FCVT_S_LU, - RISCV_INS_FCVT_S_W, - RISCV_INS_FCVT_S_WU, - RISCV_INS_FCVT_WU_D, - RISCV_INS_FCVT_WU_S, - RISCV_INS_FCVT_W_D, - RISCV_INS_FCVT_W_S, - RISCV_INS_FDIV_D, - RISCV_INS_FDIV_S, - RISCV_INS_FENCE, - RISCV_INS_FENCE_I, - RISCV_INS_FENCE_TSO, - RISCV_INS_FEQ_D, - RISCV_INS_FEQ_S, - RISCV_INS_FLD, - RISCV_INS_FLE_D, - RISCV_INS_FLE_S, - RISCV_INS_FLT_D, - RISCV_INS_FLT_S, - RISCV_INS_FLW, - RISCV_INS_FMADD_D, - RISCV_INS_FMADD_S, - RISCV_INS_FMAX_D, - RISCV_INS_FMAX_S, - RISCV_INS_FMIN_D, - RISCV_INS_FMIN_S, - RISCV_INS_FMSUB_D, - RISCV_INS_FMSUB_S, - RISCV_INS_FMUL_D, - RISCV_INS_FMUL_S, - RISCV_INS_FMV_D_X, - RISCV_INS_FMV_W_X, - RISCV_INS_FMV_X_D, - RISCV_INS_FMV_X_W, - RISCV_INS_FNMADD_D, - RISCV_INS_FNMADD_S, - RISCV_INS_FNMSUB_D, - RISCV_INS_FNMSUB_S, - RISCV_INS_FSD, - RISCV_INS_FSGNJN_D, - RISCV_INS_FSGNJN_S, - RISCV_INS_FSGNJX_D, - RISCV_INS_FSGNJX_S, - RISCV_INS_FSGNJ_D, - RISCV_INS_FSGNJ_S, - RISCV_INS_FSQRT_D, - RISCV_INS_FSQRT_S, - RISCV_INS_FSUB_D, - RISCV_INS_FSUB_S, - RISCV_INS_FSW, - RISCV_INS_JAL, - RISCV_INS_JALR, - RISCV_INS_LB, - RISCV_INS_LBU, - RISCV_INS_LD, - RISCV_INS_LH, - RISCV_INS_LHU, - RISCV_INS_LR_D, - RISCV_INS_LR_D_AQ, - RISCV_INS_LR_D_AQ_RL, - RISCV_INS_LR_D_RL, - RISCV_INS_LR_W, - RISCV_INS_LR_W_AQ, - RISCV_INS_LR_W_AQ_RL, - RISCV_INS_LR_W_RL, - RISCV_INS_LUI, - RISCV_INS_LW, - RISCV_INS_LWU, - RISCV_INS_MRET, - RISCV_INS_MUL, - RISCV_INS_MULH, - RISCV_INS_MULHSU, - RISCV_INS_MULHU, - RISCV_INS_MULW, - RISCV_INS_OR, - RISCV_INS_ORI, - RISCV_INS_REM, - RISCV_INS_REMU, - RISCV_INS_REMUW, - RISCV_INS_REMW, - RISCV_INS_SB, - RISCV_INS_SC_D, - RISCV_INS_SC_D_AQ, - RISCV_INS_SC_D_AQ_RL, - RISCV_INS_SC_D_RL, - RISCV_INS_SC_W, - RISCV_INS_SC_W_AQ, - RISCV_INS_SC_W_AQ_RL, - RISCV_INS_SC_W_RL, - RISCV_INS_SD, - RISCV_INS_SFENCE_VMA, - RISCV_INS_SH, - RISCV_INS_SLL, - RISCV_INS_SLLI, - RISCV_INS_SLLIW, - RISCV_INS_SLLW, - RISCV_INS_SLT, - RISCV_INS_SLTI, - RISCV_INS_SLTIU, - RISCV_INS_SLTU, - RISCV_INS_SRA, - RISCV_INS_SRAI, - RISCV_INS_SRAIW, - RISCV_INS_SRAW, - RISCV_INS_SRET, - RISCV_INS_SRL, - RISCV_INS_SRLI, - RISCV_INS_SRLIW, - RISCV_INS_SRLW, - RISCV_INS_SUB, - RISCV_INS_SUBW, - RISCV_INS_SW, - RISCV_INS_UNIMP, - RISCV_INS_URET, - RISCV_INS_WFI, - RISCV_INS_XOR, - RISCV_INS_XORI, - - RISCV_INS_ENDING, -} riscv_insn; - -//> Group of RISCV instructions -typedef enum riscv_insn_group { - RISCV_GRP_INVALID = 0, // = CS_GRP_INVALID - RISCV_GRP_JUMP, - - RISCV_GRP_ISRV32 = 128, - RISCV_GRP_ISRV64, - RISCV_GRP_HASSTDEXTA, - RISCV_GRP_HASSTDEXTC, - RISCV_GRP_HASSTDEXTD, - RISCV_GRP_HASSTDEXTF, - RISCV_GRP_HASSTDEXTM, - /* - RISCV_GRP_ISRVA, - RISCV_GRP_ISRVC, - RISCV_GRP_ISRVD, - RISCV_GRP_ISRVCD, - RISCV_GRP_ISRVF, - RISCV_GRP_ISRV32C, - RISCV_GRP_ISRV32CF, - RISCV_GRP_ISRVM, - RISCV_GRP_ISRV64A, - RISCV_GRP_ISRV64C, - RISCV_GRP_ISRV64D, - RISCV_GRP_ISRV64F, - RISCV_GRP_ISRV64M, - */ - RISCV_GRP_ENDING, -} riscv_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif - -/* Capstone Disassembly Engine */ -/* By Spike , xwings 2019 */ - -#ifndef CAPSTONE_WASM_H -#define CAPSTONE_WASM_H - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -typedef enum wasm_op_type { - WASM_OP_INVALID = 0, - WASM_OP_NONE, - WASM_OP_INT7, - WASM_OP_VARUINT32, - WASM_OP_VARUINT64, - WASM_OP_UINT32, - WASM_OP_UINT64, - WASM_OP_IMM, - WASM_OP_BRTABLE, -} wasm_op_type; - -typedef struct cs_wasm_brtable { - uint32_t length; - uint64_t address; - uint32_t default_target; -} cs_wasm_brtable; - -typedef struct cs_wasm_op { - wasm_op_type type; - uint32_t size; - union { - int8_t int7; - uint32_t varuint32; - uint64_t varuint64; - uint32_t uint32; - uint64_t uint64; - uint32_t immediate[2]; - cs_wasm_brtable brtable; - }; -} cs_wasm_op; - -/// Instruction structure -typedef struct cs_wasm { - uint8_t op_count; - cs_wasm_op operands[2]; -} cs_wasm; - -/// WASM instruction -typedef enum wasm_insn { - WASM_INS_UNREACHABLE = 0x0, - WASM_INS_NOP = 0x1, - WASM_INS_BLOCK = 0x2, - WASM_INS_LOOP = 0x3, - WASM_INS_IF = 0x4, - WASM_INS_ELSE = 0x5, - WASM_INS_END = 0xb, - WASM_INS_BR = 0xc, - WASM_INS_BR_IF = 0xd, - WASM_INS_BR_TABLE = 0xe, - WASM_INS_RETURN = 0xf, - WASM_INS_CALL = 0x10, - WASM_INS_CALL_INDIRECT = 0x11, - WASM_INS_DROP = 0x1a, - WASM_INS_SELECT = 0x1b, - WASM_INS_GET_LOCAL = 0x20, - WASM_INS_SET_LOCAL = 0x21, - WASM_INS_TEE_LOCAL = 0x22, - WASM_INS_GET_GLOBAL = 0x23, - WASM_INS_SET_GLOBAL = 0x24, - WASM_INS_I32_LOAD = 0x28, - WASM_INS_I64_LOAD = 0x29, - WASM_INS_F32_LOAD = 0x2a, - WASM_INS_F64_LOAD = 0x2b, - WASM_INS_I32_LOAD8_S = 0x2c, - WASM_INS_I32_LOAD8_U = 0x2d, - WASM_INS_I32_LOAD16_S = 0x2e, - WASM_INS_I32_LOAD16_U = 0x2f, - WASM_INS_I64_LOAD8_S = 0x30, - WASM_INS_I64_LOAD8_U = 0x31, - WASM_INS_I64_LOAD16_S = 0x32, - WASM_INS_I64_LOAD16_U = 0x33, - WASM_INS_I64_LOAD32_S = 0x34, - WASM_INS_I64_LOAD32_U = 0x35, - WASM_INS_I32_STORE = 0x36, - WASM_INS_I64_STORE = 0x37, - WASM_INS_F32_STORE = 0x38, - WASM_INS_F64_STORE = 0x39, - WASM_INS_I32_STORE8 = 0x3a, - WASM_INS_I32_STORE16 = 0x3b, - WASM_INS_I64_STORE8 = 0x3c, - WASM_INS_I64_STORE16 = 0x3d, - WASM_INS_I64_STORE32 = 0x3e, - WASM_INS_CURRENT_MEMORY = 0x3f, - WASM_INS_GROW_MEMORY = 0x40, - WASM_INS_I32_CONST = 0x41, - WASM_INS_I64_CONST = 0x42, - WASM_INS_F32_CONST = 0x43, - WASM_INS_F64_CONST = 0x44, - WASM_INS_I32_EQZ = 0x45, - WASM_INS_I32_EQ = 0x46, - WASM_INS_I32_NE = 0x47, - WASM_INS_I32_LT_S = 0x48, - WASM_INS_I32_LT_U = 0x49, - WASM_INS_I32_GT_S = 0x4a, - WASM_INS_I32_GT_U = 0x4b, - WASM_INS_I32_LE_S = 0x4c, - WASM_INS_I32_LE_U = 0x4d, - WASM_INS_I32_GE_S = 0x4e, - WASM_INS_I32_GE_U = 0x4f, - WASM_INS_I64_EQZ = 0x50, - WASM_INS_I64_EQ = 0x51, - WASM_INS_I64_NE = 0x52, - WASM_INS_I64_LT_S = 0x53, - WASM_INS_I64_LT_U = 0x54, - WASN_INS_I64_GT_S = 0x55, - WASM_INS_I64_GT_U = 0x56, - WASM_INS_I64_LE_S = 0x57, - WASM_INS_I64_LE_U = 0x58, - WASM_INS_I64_GE_S = 0x59, - WASM_INS_I64_GE_U = 0x5a, - WASM_INS_F32_EQ = 0x5b, - WASM_INS_F32_NE = 0x5c, - WASM_INS_F32_LT = 0x5d, - WASM_INS_F32_GT = 0x5e, - WASM_INS_F32_LE = 0x5f, - WASM_INS_F32_GE = 0x60, - WASM_INS_F64_EQ = 0x61, - WASM_INS_F64_NE = 0x62, - WASM_INS_F64_LT = 0x63, - WASM_INS_F64_GT = 0x64, - WASM_INS_F64_LE = 0x65, - WASM_INS_F64_GE = 0x66, - WASM_INS_I32_CLZ = 0x67, - WASM_INS_I32_CTZ = 0x68, - WASM_INS_I32_POPCNT = 0x69, - WASM_INS_I32_ADD = 0x6a, - WASM_INS_I32_SUB = 0x6b, - WASM_INS_I32_MUL = 0x6c, - WASM_INS_I32_DIV_S = 0x6d, - WASM_INS_I32_DIV_U = 0x6e, - WASM_INS_I32_REM_S = 0x6f, - WASM_INS_I32_REM_U = 0x70, - WASM_INS_I32_AND = 0x71, - WASM_INS_I32_OR = 0x72, - WASM_INS_I32_XOR = 0x73, - WASM_INS_I32_SHL = 0x74, - WASM_INS_I32_SHR_S = 0x75, - WASM_INS_I32_SHR_U = 0x76, - WASM_INS_I32_ROTL = 0x77, - WASM_INS_I32_ROTR = 0x78, - WASM_INS_I64_CLZ = 0x79, - WASM_INS_I64_CTZ = 0x7a, - WASM_INS_I64_POPCNT = 0x7b, - WASM_INS_I64_ADD = 0x7c, - WASM_INS_I64_SUB = 0x7d, - WASM_INS_I64_MUL = 0x7e, - WASM_INS_I64_DIV_S = 0x7f, - WASM_INS_I64_DIV_U = 0x80, - WASM_INS_I64_REM_S = 0x81, - WASM_INS_I64_REM_U = 0x82, - WASM_INS_I64_AND = 0x83, - WASM_INS_I64_OR = 0x84, - WASM_INS_I64_XOR = 0x85, - WASM_INS_I64_SHL = 0x86, - WASM_INS_I64_SHR_S = 0x87, - WASM_INS_I64_SHR_U = 0x88, - WASM_INS_I64_ROTL = 0x89, - WASM_INS_I64_ROTR = 0x8a, - WASM_INS_F32_ABS = 0x8b, - WASM_INS_F32_NEG = 0x8c, - WASM_INS_F32_CEIL = 0x8d, - WASM_INS_F32_FLOOR = 0x8e, - WASM_INS_F32_TRUNC = 0x8f, - WASM_INS_F32_NEAREST = 0x90, - WASM_INS_F32_SQRT = 0x91, - WASM_INS_F32_ADD = 0x92, - WASM_INS_F32_SUB = 0x93, - WASM_INS_F32_MUL = 0x94, - WASM_INS_F32_DIV = 0x95, - WASM_INS_F32_MIN = 0x96, - WASM_INS_F32_MAX = 0x97, - WASM_INS_F32_COPYSIGN = 0x98, - WASM_INS_F64_ABS = 0x99, - WASM_INS_F64_NEG = 0x9a, - WASM_INS_F64_CEIL = 0x9b, - WASM_INS_F64_FLOOR = 0x9c, - WASM_INS_F64_TRUNC = 0x9d, - WASM_INS_F64_NEAREST = 0x9e, - WASM_INS_F64_SQRT = 0x9f, - WASM_INS_F64_ADD = 0xa0, - WASM_INS_F64_SUB = 0xa1, - WASM_INS_F64_MUL = 0xa2, - WASM_INS_F64_DIV = 0xa3, - WASM_INS_F64_MIN = 0xa4, - WASM_INS_F64_MAX = 0xa5, - WASM_INS_F64_COPYSIGN = 0xa6, - WASM_INS_I32_WARP_I64 = 0xa7, - WASP_INS_I32_TRUNC_S_F32 = 0xa8, - WASM_INS_I32_TRUNC_U_F32 = 0xa9, - WASM_INS_I32_TRUNC_S_F64 = 0xaa, - WASM_INS_I32_TRUNC_U_F64 = 0xab, - WASM_INS_I64_EXTEND_S_I32 = 0xac, - WASM_INS_I64_EXTEND_U_I32 = 0xad, - WASM_INS_I64_TRUNC_S_F32 = 0xae, - WASM_INS_I64_TRUNC_U_F32 = 0xaf, - WASM_INS_I64_TRUNC_S_F64 = 0xb0, - WASM_INS_I64_TRUNC_U_F64 = 0xb1, - WASM_INS_F32_CONVERT_S_I32 = 0xb2, - WASM_INS_F32_CONVERT_U_I32 = 0xb3, - WASM_INS_F32_CONVERT_S_I64 = 0xb4, - WASM_INS_F32_CONVERT_U_I64 = 0xb5, - WASM_INS_F32_DEMOTE_F64 = 0xb6, - WASM_INS_F64_CONVERT_S_I32 = 0xb7, - WASM_INS_F64_CONVERT_U_I32 = 0xb8, - WASM_INS_F64_CONVERT_S_I64 = 0xb9, - WASM_INS_F64_CONVERT_U_I64 = 0xba, - WASM_INS_F64_PROMOTE_F32 = 0xbb, - WASM_INS_I32_REINTERPRET_F32 = 0xbc, - WASM_INS_I64_REINTERPRET_F64 = 0xbd, - WASM_INS_F32_REINTERPRET_I32 = 0xbe, - WASM_INS_F64_REINTERPRET_I64 = 0xbf, - WASM_INS_INVALID = 512, - WASM_INS_ENDING, -} wasm_insn; - -/// Group of WASM instructions -typedef enum wasm_insn_group { - WASM_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - WASM_GRP_NUMBERIC = 8, - WASM_GRP_PARAMETRIC, - WASM_GRP_VARIABLE, - WASM_GRP_MEMORY, - WASM_GRP_CONTROL, - - WASM_GRP_ENDING, ///< <-- mark the end of the list of groups -} wasm_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif -#ifndef CAPSTONE_MOS65XX_H -#define CAPSTONE_MOS65XX_H - -/* Capstone Disassembly Engine */ -/* By Sebastian Macke , 2019 */ - -#ifndef CAPSTONE_BPF_H -#define CAPSTONE_BPF_H - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifdef _MSC_VER -#pragma warning(disable:4201) -#endif - -/// Operand type for instruction's operands -typedef enum bpf_op_type { - BPF_OP_INVALID = 0, - - BPF_OP_REG, - BPF_OP_IMM, - BPF_OP_OFF, - BPF_OP_MEM, - BPF_OP_MMEM, ///< M[k] in cBPF - BPF_OP_MSH, ///< corresponds to cBPF's BPF_MSH mode - BPF_OP_EXT, ///< cBPF's extension (not eBPF) -} bpf_op_type; - -/// BPF registers -typedef enum bpf_reg { - BPF_REG_INVALID = 0, - - ///< cBPF - BPF_REG_A, - BPF_REG_X, - - ///< eBPF - BPF_REG_R0, - BPF_REG_R1, - BPF_REG_R2, - BPF_REG_R3, - BPF_REG_R4, - BPF_REG_R5, - BPF_REG_R6, - BPF_REG_R7, - BPF_REG_R8, - BPF_REG_R9, - BPF_REG_R10, - - BPF_REG_ENDING, -} bpf_reg; - -/// Instruction's operand referring to memory -/// This is associated with BPF_OP_MEM operand type above -typedef struct bpf_op_mem { - bpf_reg base; ///< base register - uint32_t disp; ///< offset value -} bpf_op_mem; - -typedef enum bpf_ext_type { - BPF_EXT_INVALID = 0, - - BPF_EXT_LEN, -} bpf_ext_type; - -/// Instruction operand -typedef struct cs_bpf_op { - bpf_op_type type; - union { - uint8_t reg; ///< register value for REG operand - uint64_t imm; ///< immediate value IMM operand - uint32_t off; ///< offset value, used in jump & call - bpf_op_mem mem; ///< base/disp value for MEM operand - /* cBPF only */ - uint32_t mmem; ///< M[k] in cBPF - uint32_t msh; ///< corresponds to cBPF's BPF_MSH mode - uint32_t ext; ///< cBPF's extension (not eBPF) - }; - - /// How is this operand accessed? (READ, WRITE or READ|WRITE) - /// This field is combined of cs_ac_type. - /// NOTE: this field is irrelevant if engine is compiled in DIET mode. - uint8_t access; -} cs_bpf_op; - -/// Instruction structure -typedef struct cs_bpf { - uint8_t op_count; - cs_bpf_op operands[4]; -} cs_bpf; - -/// BPF instruction -typedef enum bpf_insn { - BPF_INS_INVALID = 0, - - ///< ALU - BPF_INS_ADD, - BPF_INS_SUB, - BPF_INS_MUL, - BPF_INS_DIV, - BPF_INS_OR, - BPF_INS_AND, - BPF_INS_LSH, - BPF_INS_RSH, - BPF_INS_NEG, - BPF_INS_MOD, - BPF_INS_XOR, - BPF_INS_MOV, ///< eBPF only - BPF_INS_ARSH, ///< eBPF only - - ///< ALU64, eBPF only - BPF_INS_ADD64, - BPF_INS_SUB64, - BPF_INS_MUL64, - BPF_INS_DIV64, - BPF_INS_OR64, - BPF_INS_AND64, - BPF_INS_LSH64, - BPF_INS_RSH64, - BPF_INS_NEG64, - BPF_INS_MOD64, - BPF_INS_XOR64, - BPF_INS_MOV64, - BPF_INS_ARSH64, - - ///< Byteswap, eBPF only - BPF_INS_LE16, - BPF_INS_LE32, - BPF_INS_LE64, - BPF_INS_BE16, - BPF_INS_BE32, - BPF_INS_BE64, - - ///< Load - BPF_INS_LDW, ///< eBPF only - BPF_INS_LDH, - BPF_INS_LDB, - BPF_INS_LDDW, ///< eBPF only: load 64-bit imm - BPF_INS_LDXW, ///< eBPF only - BPF_INS_LDXH, ///< eBPF only - BPF_INS_LDXB, ///< eBPF only - BPF_INS_LDXDW, ///< eBPF only - - ///< Store - BPF_INS_STW, ///< eBPF only - BPF_INS_STH, ///< eBPF only - BPF_INS_STB, ///< eBPF only - BPF_INS_STDW, ///< eBPF only - BPF_INS_STXW, ///< eBPF only - BPF_INS_STXH, ///< eBPF only - BPF_INS_STXB, ///< eBPF only - BPF_INS_STXDW, ///< eBPF only - BPF_INS_XADDW, ///< eBPF only - BPF_INS_XADDDW, ///< eBPF only - - ///< Jump - BPF_INS_JMP, - BPF_INS_JEQ, - BPF_INS_JGT, - BPF_INS_JGE, - BPF_INS_JSET, - BPF_INS_JNE, ///< eBPF only - BPF_INS_JSGT, ///< eBPF only - BPF_INS_JSGE, ///< eBPF only - BPF_INS_CALL, ///< eBPF only - BPF_INS_EXIT, ///< eBPF only - BPF_INS_JLT, ///< eBPF only - BPF_INS_JLE, ///< eBPF only - BPF_INS_JSLT, ///< eBPF only - BPF_INS_JSLE, ///< eBPF only - - ///< Return, cBPF only - BPF_INS_RET, - - ///< Misc, cBPF only - BPF_INS_TAX, - BPF_INS_TXA, - - BPF_INS_ENDING, - - // alias instructions - BPF_INS_LD = BPF_INS_LDW, ///< cBPF only - BPF_INS_LDX = BPF_INS_LDXW, ///< cBPF only - BPF_INS_ST = BPF_INS_STW, ///< cBPF only - BPF_INS_STX = BPF_INS_STXW, ///< cBPF only -} bpf_insn; - -/// Group of BPF instructions -typedef enum bpf_insn_group { - BPF_GRP_INVALID = 0, ///< = CS_GRP_INVALID - - BPF_GRP_LOAD, - BPF_GRP_STORE, - BPF_GRP_ALU, - BPF_GRP_JUMP, - BPF_GRP_CALL, ///< eBPF only - BPF_GRP_RETURN, - BPF_GRP_MISC, ///< cBPF only - - BPF_GRP_ENDING, -} bpf_insn_group; - -#ifdef __cplusplus -} -#endif - -#endif - -/// NOTE: All information in cs_detail is only available when CS_OPT_DETAIL = CS_OPT_ON -/// Initialized as memset(., 0, offsetof(cs_detail, ARCH)+sizeof(cs_ARCH)) -/// by ARCH_getInstruction in arch/ARCH/ARCHDisassembler.c -/// if cs_detail changes, in particular if a field is added after the union, -/// then update arch/ARCH/ARCHDisassembler.c accordingly -typedef struct cs_detail { - uint16_t regs_read[16]; ///< list of implicit registers read by this insn - uint8_t regs_read_count; ///< number of implicit registers read by this insn - - uint16_t regs_write[20]; ///< list of implicit registers modified by this insn - uint8_t regs_write_count; ///< number of implicit registers modified by this insn - - uint8_t groups[8]; ///< list of group this instruction belong to - uint8_t groups_count; ///< number of groups this insn belongs to - - /// Architecture-specific instruction info - union { - cs_x86 x86; ///< X86 architecture, including 16-bit, 32-bit & 64-bit mode - cs_arm64 arm64; ///< ARM64 architecture (aka AArch64) - cs_arm arm; ///< ARM architecture (including Thumb/Thumb2) - cs_m68k m68k; ///< M68K architecture - cs_mips mips; ///< MIPS architecture - cs_ppc ppc; ///< PowerPC architecture - cs_sparc sparc; ///< Sparc architecture - cs_sysz sysz; ///< SystemZ architecture - cs_xcore xcore; ///< XCore architecture - cs_tms320c64x tms320c64x; ///< TMS320C64x architecture - cs_m680x m680x; ///< M680X architecture - cs_evm evm; ///< Ethereum architecture - cs_mos65xx mos65xx; ///< MOS65XX architecture (including MOS6502) - cs_wasm wasm; ///< Web Assembly architecture - cs_bpf bpf; ///< Berkeley Packet Filter architecture (including eBPF) - cs_riscv riscv; ///< RISCV architecture - }; -} cs_detail; - -/// Detail information of disassembled instruction -typedef struct cs_insn { - /// Instruction ID (basically a numeric ID for the instruction mnemonic) - /// Find the instruction id in the '[ARCH]_insn' enum in the header file - /// of corresponding architecture, such as 'arm_insn' in arm.h for ARM, - /// 'x86_insn' in x86.h for X86, etc... - /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF - /// NOTE: in Skipdata mode, "data" instruction has 0 for this id field. - unsigned int id; - - /// Address (EIP) of this instruction - /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF - uint64_t address; - - /// Size of this instruction - /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF - uint16_t size; - - /// Machine bytes of this instruction, with number of bytes indicated by @size above - /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF - uint8_t bytes[24]; - - /// Ascii text of instruction mnemonic - /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF - char mnemonic[CS_MNEMONIC_SIZE]; - - /// Ascii text of instruction operands - /// This information is available even when CS_OPT_DETAIL = CS_OPT_OFF - char op_str[160]; - - /// Pointer to cs_detail. - /// NOTE: detail pointer is only valid when both requirements below are met: - /// (1) CS_OP_DETAIL = CS_OPT_ON - /// (2) Engine is not in Skipdata mode (CS_OP_SKIPDATA option set to CS_OPT_ON) - /// - /// NOTE 2: when in Skipdata mode, or when detail mode is OFF, even if this pointer - /// is not NULL, its content is still irrelevant. - cs_detail *detail; -} cs_insn; - - -/// Calculate the offset of a disassembled instruction in its buffer, given its position -/// in its array of disassembled insn -/// NOTE: this macro works with position (>=1), not index -#define CS_INSN_OFFSET(insns, post) (insns[post - 1].address - insns[0].address) - - -/// All type of errors encountered by Capstone API. -/// These are values returned by cs_errno() -typedef enum cs_err { - CS_ERR_OK = 0, ///< No error: everything was fine - CS_ERR_MEM, ///< Out-Of-Memory error: cs_open(), cs_disasm(), cs_disasm_iter() - CS_ERR_ARCH, ///< Unsupported architecture: cs_open() - CS_ERR_HANDLE, ///< Invalid handle: cs_op_count(), cs_op_index() - CS_ERR_CSH, ///< Invalid csh argument: cs_close(), cs_errno(), cs_option() - CS_ERR_MODE, ///< Invalid/unsupported mode: cs_open() - CS_ERR_OPTION, ///< Invalid/unsupported option: cs_option() - CS_ERR_DETAIL, ///< Information is unavailable because detail option is OFF - CS_ERR_MEMSETUP, ///< Dynamic memory management uninitialized (see CS_OPT_MEM) - CS_ERR_VERSION, ///< Unsupported version (bindings) - CS_ERR_DIET, ///< Access irrelevant data in "diet" engine - CS_ERR_SKIPDATA, ///< Access irrelevant data for "data" instruction in SKIPDATA mode - CS_ERR_X86_ATT, ///< X86 AT&T syntax is unsupported (opt-out at compile time) - CS_ERR_X86_INTEL, ///< X86 Intel syntax is unsupported (opt-out at compile time) - CS_ERR_X86_MASM, ///< X86 Masm syntax is unsupported (opt-out at compile time) -} cs_err; - -/** - Return combined API version & major and minor version numbers. - - @major: major number of API version - @minor: minor number of API version - - @return hexical number as (major << 8 | minor), which encodes both - major & minor versions. - NOTE: This returned value can be compared with version number made - with macro CS_MAKE_VERSION - - For example, second API version would return 1 in @major, and 1 in @minor - The return value would be 0x0101 - - NOTE: if you only care about returned value, but not major and minor values, - set both @major & @minor arguments to NULL. -*/ -CAPSTONE_EXPORT -unsigned int CAPSTONE_API cs_version(int *major, int *minor); - - -/** - This API can be used to either ask for archs supported by this library, - or check to see if the library was compile with 'diet' option (or called - in 'diet' mode). - - To check if a particular arch is supported by this library, set @query to - arch mode (CS_ARCH_* value). - To verify if this library supports all the archs, use CS_ARCH_ALL. - - To check if this library is in 'diet' mode, set @query to CS_SUPPORT_DIET. - - @return True if this library supports the given arch, or in 'diet' mode. -*/ -CAPSTONE_EXPORT -bool CAPSTONE_API cs_support(int query); - -/** - Initialize CS handle: this must be done before any usage of CS. - - @arch: architecture type (CS_ARCH_*) - @mode: hardware mode. This is combined of CS_MODE_* - @handle: pointer to handle, which will be updated at return time - - @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum - for detailed error). -*/ -CAPSTONE_EXPORT -cs_err CAPSTONE_API cs_open(cs_arch arch, cs_mode mode, csh *handle); - -/** - Close CS handle: MUST do to release the handle when it is not used anymore. - NOTE: this must be only called when there is no longer usage of Capstone, - not even access to cs_insn array. The reason is the this API releases some - cached memory, thus access to any Capstone API after cs_close() might crash - your application. - - In fact,this API invalidate @handle by ZERO out its value (i.e *handle = 0). - - @handle: pointer to a handle returned by cs_open() - - @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum - for detailed error). -*/ -CAPSTONE_EXPORT -cs_err CAPSTONE_API cs_close(csh *handle); - -/** - Set option for disassembling engine at runtime - - @handle: handle returned by cs_open() - @type: type of option to be set - @value: option value corresponding with @type - - @return: CS_ERR_OK on success, or other value on failure. - Refer to cs_err enum for detailed error. - - NOTE: in the case of CS_OPT_MEM, handle's value can be anything, - so that cs_option(handle, CS_OPT_MEM, value) can (i.e must) be called - even before cs_open() -*/ -CAPSTONE_EXPORT -cs_err CAPSTONE_API cs_option(csh handle, cs_opt_type type, size_t value); - -/** - Report the last error number when some API function fail. - Like glibc's errno, cs_errno might not retain its old value once accessed. - - @handle: handle returned by cs_open() - - @return: error code of cs_err enum type (CS_ERR_*, see above) -*/ -CAPSTONE_EXPORT -cs_err CAPSTONE_API cs_errno(csh handle); - - -/** - Return a string describing given error code. - - @code: error code (see CS_ERR_* above) - - @return: returns a pointer to a string that describes the error code - passed in the argument @code -*/ -CAPSTONE_EXPORT -const char * CAPSTONE_API cs_strerror(cs_err code); - -/** - Disassemble binary code, given the code buffer, size, address and number - of instructions to be decoded. - This API dynamically allocate memory to contain disassembled instruction. - Resulting instructions will be put into @*insn - - NOTE 1: this API will automatically determine memory needed to contain - output disassembled instructions in @insn. - - NOTE 2: caller must free the allocated memory itself to avoid memory leaking. - - NOTE 3: for system with scarce memory to be dynamically allocated such as - OS kernel or firmware, the API cs_disasm_iter() might be a better choice than - cs_disasm(). The reason is that with cs_disasm(), based on limited available - memory, we have to calculate in advance how many instructions to be disassembled, - which complicates things. This is especially troublesome for the case @count=0, - when cs_disasm() runs uncontrollably (until either end of input buffer, or - when it encounters an invalid instruction). - - @handle: handle returned by cs_open() - @code: buffer containing raw binary code to be disassembled. - @code_size: size of the above code buffer. - @address: address of the first instruction in given raw code buffer. - @insn: array of instructions filled in by this API. - NOTE: @insn will be allocated by this function, and should be freed - with cs_free() API. - @count: number of instructions to be disassembled, or 0 to get all of them - - @return: the number of successfully disassembled instructions, - or 0 if this function failed to disassemble the given code - - On failure, call cs_errno() for error code. -*/ -CAPSTONE_EXPORT -size_t CAPSTONE_API cs_disasm(csh handle, - const uint8_t *code, size_t code_size, - uint64_t address, - size_t count, - cs_insn **insn); - -/** - Free memory allocated by cs_malloc() or cs_disasm() (argument @insn) - - @insn: pointer returned by @insn argument in cs_disasm() or cs_malloc() - @count: number of cs_insn structures returned by cs_disasm(), or 1 - to free memory allocated by cs_malloc(). -*/ -CAPSTONE_EXPORT -void CAPSTONE_API cs_free(cs_insn *insn, size_t count); - - -/** - Allocate memory for 1 instruction to be used by cs_disasm_iter(). - - @handle: handle returned by cs_open() - - NOTE: when no longer in use, you can reclaim the memory allocated for - this instruction with cs_free(insn, 1) -*/ -CAPSTONE_EXPORT -cs_insn * CAPSTONE_API cs_malloc(csh handle); - -/** - Fast API to disassemble binary code, given the code buffer, size, address - and number of instructions to be decoded. - This API puts the resulting instruction into a given cache in @insn. - See tests/test_iter.c for sample code demonstrating this API. - - NOTE 1: this API will update @code, @size & @address to point to the next - instruction in the input buffer. Therefore, it is convenient to use - cs_disasm_iter() inside a loop to quickly iterate all the instructions. - While decoding one instruction at a time can also be achieved with - cs_disasm(count=1), some benchmarks shown that cs_disasm_iter() can be 30% - faster on random input. - - NOTE 2: the cache in @insn can be created with cs_malloc() API. - - NOTE 3: for system with scarce memory to be dynamically allocated such as - OS kernel or firmware, this API is recommended over cs_disasm(), which - allocates memory based on the number of instructions to be disassembled. - The reason is that with cs_disasm(), based on limited available memory, - we have to calculate in advance how many instructions to be disassembled, - which complicates things. This is especially troublesome for the case - @count=0, when cs_disasm() runs uncontrollably (until either end of input - buffer, or when it encounters an invalid instruction). - - @handle: handle returned by cs_open() - @code: buffer containing raw binary code to be disassembled - @size: size of above code - @address: address of the first insn in given raw code buffer - @insn: pointer to instruction to be filled in by this API. - - @return: true if this API successfully decode 1 instruction, - or false otherwise. - - On failure, call cs_errno() for error code. -*/ -CAPSTONE_EXPORT -bool CAPSTONE_API cs_disasm_iter(csh handle, - const uint8_t **code, size_t *size, - uint64_t *address, cs_insn *insn); - -/** - Return friendly name of register in a string. - Find the instruction id from header file of corresponding architecture (arm.h for ARM, - x86.h for X86, ...) - - WARN: when in 'diet' mode, this API is irrelevant because engine does not - store register name. - - @handle: handle returned by cs_open() - @reg_id: register id - - @return: string name of the register, or NULL if @reg_id is invalid. -*/ -CAPSTONE_EXPORT -const char * CAPSTONE_API cs_reg_name(csh handle, unsigned int reg_id); - -/** - Return friendly name of an instruction in a string. - Find the instruction id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) - - WARN: when in 'diet' mode, this API is irrelevant because the engine does not - store instruction name. - - @handle: handle returned by cs_open() - @insn_id: instruction id - - @return: string name of the instruction, or NULL if @insn_id is invalid. -*/ -CAPSTONE_EXPORT -const char * CAPSTONE_API cs_insn_name(csh handle, unsigned int insn_id); - -/** - Return friendly name of a group id (that an instruction can belong to) - Find the group id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) - - WARN: when in 'diet' mode, this API is irrelevant because the engine does not - store group name. - - @handle: handle returned by cs_open() - @group_id: group id - - @return: string name of the group, or NULL if @group_id is invalid. -*/ -CAPSTONE_EXPORT -const char * CAPSTONE_API cs_group_name(csh handle, unsigned int group_id); - -/** - Check if a disassembled instruction belong to a particular group. - Find the group id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) - Internally, this simply verifies if @group_id matches any member of insn->groups array. - - NOTE: this API is only valid when detail option is ON (which is OFF by default). - - WARN: when in 'diet' mode, this API is irrelevant because the engine does not - update @groups array. - - @handle: handle returned by cs_open() - @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() - @group_id: group that you want to check if this instruction belong to. - - @return: true if this instruction indeed belongs to the given group, or false otherwise. -*/ -CAPSTONE_EXPORT -bool CAPSTONE_API cs_insn_group(csh handle, const cs_insn *insn, unsigned int group_id); - -/** - Check if a disassembled instruction IMPLICITLY used a particular register. - Find the register id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) - Internally, this simply verifies if @reg_id matches any member of insn->regs_read array. - - NOTE: this API is only valid when detail option is ON (which is OFF by default) - - WARN: when in 'diet' mode, this API is irrelevant because the engine does not - update @regs_read array. - - @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() - @reg_id: register that you want to check if this instruction used it. - - @return: true if this instruction indeed implicitly used the given register, or false otherwise. -*/ -CAPSTONE_EXPORT -bool CAPSTONE_API cs_reg_read(csh handle, const cs_insn *insn, unsigned int reg_id); - -/** - Check if a disassembled instruction IMPLICITLY modified a particular register. - Find the register id from header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) - Internally, this simply verifies if @reg_id matches any member of insn->regs_write array. - - NOTE: this API is only valid when detail option is ON (which is OFF by default) - - WARN: when in 'diet' mode, this API is irrelevant because the engine does not - update @regs_write array. - - @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() - @reg_id: register that you want to check if this instruction modified it. - - @return: true if this instruction indeed implicitly modified the given register, or false otherwise. -*/ -CAPSTONE_EXPORT -bool CAPSTONE_API cs_reg_write(csh handle, const cs_insn *insn, unsigned int reg_id); - -/** - Count the number of operands of a given type. - Find the operand type in header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) - - NOTE: this API is only valid when detail option is ON (which is OFF by default) - - @handle: handle returned by cs_open() - @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() - @op_type: Operand type to be found. - - @return: number of operands of given type @op_type in instruction @insn, - or -1 on failure. -*/ -CAPSTONE_EXPORT -int CAPSTONE_API cs_op_count(csh handle, const cs_insn *insn, unsigned int op_type); - -/** - Retrieve the position of operand of given type in .operands[] array. - Later, the operand can be accessed using the returned position. - Find the operand type in header file of corresponding architecture (arm.h for ARM, x86.h for X86, ...) - - NOTE: this API is only valid when detail option is ON (which is OFF by default) - - @handle: handle returned by cs_open() - @insn: disassembled instruction structure received from cs_disasm() or cs_disasm_iter() - @op_type: Operand type to be found. - @position: position of the operand to be found. This must be in the range - [1, cs_op_count(handle, insn, op_type)] - - @return: index of operand of given type @op_type in .operands[] array - in instruction @insn, or -1 on failure. -*/ -CAPSTONE_EXPORT -int CAPSTONE_API cs_op_index(csh handle, const cs_insn *insn, unsigned int op_type, - unsigned int position); - -/// Type of array to keep the list of registers -typedef uint16_t cs_regs[64]; - -/** - Retrieve all the registers accessed by an instruction, either explicitly or - implicitly. - - WARN: when in 'diet' mode, this API is irrelevant because engine does not - store registers. - - @handle: handle returned by cs_open() - @insn: disassembled instruction structure returned from cs_disasm() or cs_disasm_iter() - @regs_read: on return, this array contains all registers read by instruction. - @regs_read_count: number of registers kept inside @regs_read array. - @regs_write: on return, this array contains all registers written by instruction. - @regs_write_count: number of registers kept inside @regs_write array. - - @return CS_ERR_OK on success, or other value on failure (refer to cs_err enum - for detailed error). -*/ -CAPSTONE_EXPORT -cs_err CAPSTONE_API cs_regs_access(csh handle, const cs_insn *insn, - cs_regs regs_read, uint8_t *regs_read_count, - cs_regs regs_write, uint8_t *regs_write_count); - -#ifdef __cplusplus -} -#endif - -#endif -/* - * Copyright (C) 2009-2019 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_X86_WRITER_H__ -#define __GUM_X86_WRITER_H__ - - - -G_BEGIN_DECLS - -typedef struct _GumX86Writer GumX86Writer; -typedef guint GumCpuReg; -typedef guint GumPtrTarget; - -struct _GumX86Writer -{ - volatile gint ref_count; - - GumCpuType target_cpu; - GumAbiType target_abi; - - guint8 * base; - guint8 * code; - GumAddress pc; - - GumMetalHashTable * label_defs; - GumMetalArray label_refs; -}; - -enum _GumCpuReg -{ - /* 32 bit */ - GUM_REG_EAX = 0, - GUM_REG_ECX, - GUM_REG_EDX, - GUM_REG_EBX, - GUM_REG_ESP, - GUM_REG_EBP, - GUM_REG_ESI, - GUM_REG_EDI, - - GUM_REG_R8D, - GUM_REG_R9D, - GUM_REG_R10D, - GUM_REG_R11D, - GUM_REG_R12D, - GUM_REG_R13D, - GUM_REG_R14D, - GUM_REG_R15D, - - GUM_REG_EIP, - - /* 64 bit */ - GUM_REG_RAX, - GUM_REG_RCX, - GUM_REG_RDX, - GUM_REG_RBX, - GUM_REG_RSP, - GUM_REG_RBP, - GUM_REG_RSI, - GUM_REG_RDI, - - GUM_REG_R8, - GUM_REG_R9, - GUM_REG_R10, - GUM_REG_R11, - GUM_REG_R12, - GUM_REG_R13, - GUM_REG_R14, - GUM_REG_R15, - - GUM_REG_RIP, - - /* Meta */ - GUM_REG_XAX, - GUM_REG_XCX, - GUM_REG_XDX, - GUM_REG_XBX, - GUM_REG_XSP, - GUM_REG_XBP, - GUM_REG_XSI, - GUM_REG_XDI, - - GUM_REG_XIP, - - GUM_REG_NONE -}; - -enum _GumPtrTarget -{ - GUM_PTR_BYTE, - GUM_PTR_DWORD, - GUM_PTR_QWORD -}; - -GUM_API GumX86Writer * gum_x86_writer_new (gpointer code_address); -GUM_API GumX86Writer * gum_x86_writer_ref (GumX86Writer * writer); -GUM_API void gum_x86_writer_unref (GumX86Writer * writer); - -GUM_API void gum_x86_writer_init (GumX86Writer * writer, - gpointer code_address); -GUM_API void gum_x86_writer_clear (GumX86Writer * writer); - -GUM_API void gum_x86_writer_reset (GumX86Writer * writer, - gpointer code_address); -GUM_API void gum_x86_writer_set_target_cpu (GumX86Writer * self, - GumCpuType cpu_type); -GUM_API void gum_x86_writer_set_target_abi (GumX86Writer * self, - GumAbiType abi_type); - -GUM_API gpointer gum_x86_writer_cur (GumX86Writer * self); -GUM_API guint gum_x86_writer_offset (GumX86Writer * self); - -GUM_API gboolean gum_x86_writer_flush (GumX86Writer * self); - -GUM_API GumCpuReg gum_x86_writer_get_cpu_register_for_nth_argument ( - GumX86Writer * self, guint n); - -GUM_API gboolean gum_x86_writer_put_label (GumX86Writer * self, - gconstpointer id); - -GUM_API gboolean gum_x86_writer_can_branch_directly_between (GumAddress from, - GumAddress to); -GUM_API gboolean gum_x86_writer_put_call_address_with_arguments ( - GumX86Writer * self, GumCallingConvention conv, GumAddress func, - guint n_args, ...); -GUM_API gboolean gum_x86_writer_put_call_address_with_arguments_array ( - GumX86Writer * self, GumCallingConvention conv, GumAddress func, - guint n_args, const GumArgument * args); -GUM_API gboolean gum_x86_writer_put_call_address_with_aligned_arguments ( - GumX86Writer * self, GumCallingConvention conv, GumAddress func, - guint n_args, ...); -GUM_API gboolean gum_x86_writer_put_call_address_with_aligned_arguments_array ( - GumX86Writer * self, GumCallingConvention conv, GumAddress func, - guint n_args, const GumArgument * args); -GUM_API gboolean gum_x86_writer_put_call_reg_with_arguments ( - GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, - guint n_args, ...); -GUM_API gboolean gum_x86_writer_put_call_reg_with_arguments_array ( - GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, - guint n_args, const GumArgument * args); -GUM_API gboolean gum_x86_writer_put_call_reg_with_aligned_arguments ( - GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, - guint n_args, ...); -GUM_API gboolean gum_x86_writer_put_call_reg_with_aligned_arguments_array ( - GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, - guint n_args, const GumArgument * args); -GUM_API gboolean gum_x86_writer_put_call_reg_offset_ptr_with_arguments ( - GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, - gssize offset, guint n_args, ...); -GUM_API gboolean gum_x86_writer_put_call_reg_offset_ptr_with_arguments_array ( - GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, - gssize offset, guint n_args, const GumArgument * args); -GUM_API gboolean gum_x86_writer_put_call_reg_offset_ptr_with_aligned_arguments ( - GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, - gssize offset, guint n_args, ...); -GUM_API gboolean - gum_x86_writer_put_call_reg_offset_ptr_with_aligned_arguments_array ( - GumX86Writer * self, GumCallingConvention conv, GumCpuReg reg, - gssize offset, guint n_args, const GumArgument * args); -GUM_API gboolean gum_x86_writer_put_call_address (GumX86Writer * self, - GumAddress address); -GUM_API gboolean gum_x86_writer_put_call_reg (GumX86Writer * self, - GumCpuReg reg); -GUM_API gboolean gum_x86_writer_put_call_reg_offset_ptr (GumX86Writer * self, - GumCpuReg reg, gssize offset); -GUM_API gboolean gum_x86_writer_put_call_indirect (GumX86Writer * self, - GumAddress addr); -GUM_API gboolean gum_x86_writer_put_call_indirect_label (GumX86Writer * self, - gconstpointer label_id); -GUM_API void gum_x86_writer_put_call_near_label (GumX86Writer * self, - gconstpointer label_id); -GUM_API void gum_x86_writer_put_leave (GumX86Writer * self); -GUM_API void gum_x86_writer_put_ret (GumX86Writer * self); -GUM_API void gum_x86_writer_put_ret_imm (GumX86Writer * self, - guint16 imm_value); -GUM_API gboolean gum_x86_writer_put_jmp_address (GumX86Writer * self, - GumAddress address); -GUM_API void gum_x86_writer_put_jmp_short_label (GumX86Writer * self, - gconstpointer label_id); -GUM_API void gum_x86_writer_put_jmp_near_label (GumX86Writer * self, - gconstpointer label_id); -GUM_API gboolean gum_x86_writer_put_jmp_reg (GumX86Writer * self, - GumCpuReg reg); -GUM_API gboolean gum_x86_writer_put_jmp_reg_ptr (GumX86Writer * self, - GumCpuReg reg); -GUM_API gboolean gum_x86_writer_put_jmp_reg_offset_ptr (GumX86Writer * self, - GumCpuReg reg, gssize offset); -GUM_API gboolean gum_x86_writer_put_jmp_near_ptr (GumX86Writer * self, - GumAddress address); -GUM_API gboolean gum_x86_writer_put_jcc_short (GumX86Writer * self, - x86_insn instruction_id, gconstpointer target, GumBranchHint hint); -GUM_API gboolean gum_x86_writer_put_jcc_near (GumX86Writer * self, - x86_insn instruction_id, gconstpointer target, GumBranchHint hint); -GUM_API void gum_x86_writer_put_jcc_short_label (GumX86Writer * self, - x86_insn instruction_id, gconstpointer label_id, GumBranchHint hint); -GUM_API void gum_x86_writer_put_jcc_near_label (GumX86Writer * self, - x86_insn instruction_id, gconstpointer label_id, GumBranchHint hint); - -GUM_API gboolean gum_x86_writer_put_add_reg_imm (GumX86Writer * self, - GumCpuReg reg, gssize imm_value); -GUM_API gboolean gum_x86_writer_put_add_reg_reg (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_add_reg_near_ptr (GumX86Writer * self, - GumCpuReg dst_reg, GumAddress src_address); -GUM_API gboolean gum_x86_writer_put_sub_reg_imm (GumX86Writer * self, - GumCpuReg reg, gssize imm_value); -GUM_API gboolean gum_x86_writer_put_sub_reg_reg (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_sub_reg_near_ptr (GumX86Writer * self, - GumCpuReg dst_reg, GumAddress src_address); -GUM_API gboolean gum_x86_writer_put_inc_reg (GumX86Writer * self, - GumCpuReg reg); -GUM_API gboolean gum_x86_writer_put_dec_reg (GumX86Writer * self, - GumCpuReg reg); -GUM_API gboolean gum_x86_writer_put_inc_reg_ptr (GumX86Writer * self, - GumPtrTarget target, GumCpuReg reg); -GUM_API gboolean gum_x86_writer_put_dec_reg_ptr (GumX86Writer * self, - GumPtrTarget target, GumCpuReg reg); -GUM_API gboolean gum_x86_writer_put_lock_xadd_reg_ptr_reg (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_lock_cmpxchg_reg_ptr_reg ( - GumX86Writer * self, GumCpuReg dst_reg, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_lock_inc_imm32_ptr (GumX86Writer * self, - gpointer target); -GUM_API gboolean gum_x86_writer_put_lock_dec_imm32_ptr (GumX86Writer * self, - gpointer target); - -GUM_API gboolean gum_x86_writer_put_and_reg_reg (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_and_reg_u32 (GumX86Writer * self, - GumCpuReg reg, guint32 imm_value); -GUM_API gboolean gum_x86_writer_put_shl_reg_u8 (GumX86Writer * self, - GumCpuReg reg, guint8 imm_value); -GUM_API gboolean gum_x86_writer_put_shr_reg_u8 (GumX86Writer * self, - GumCpuReg reg, guint8 imm_value); -GUM_API gboolean gum_x86_writer_put_xor_reg_reg (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg); - -GUM_API gboolean gum_x86_writer_put_mov_reg_reg (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_mov_reg_u32 (GumX86Writer * self, - GumCpuReg dst_reg, guint32 imm_value); -GUM_API gboolean gum_x86_writer_put_mov_reg_u64 (GumX86Writer * self, - GumCpuReg dst_reg, guint64 imm_value); -GUM_API void gum_x86_writer_put_mov_reg_address (GumX86Writer * self, - GumCpuReg dst_reg, GumAddress address); -GUM_API void gum_x86_writer_put_mov_reg_ptr_u32 (GumX86Writer * self, - GumCpuReg dst_reg, guint32 imm_value); -GUM_API gboolean gum_x86_writer_put_mov_reg_offset_ptr_u32 (GumX86Writer * self, - GumCpuReg dst_reg, gssize dst_offset, guint32 imm_value); -GUM_API void gum_x86_writer_put_mov_reg_ptr_reg (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_mov_reg_offset_ptr_reg (GumX86Writer * self, - GumCpuReg dst_reg, gssize dst_offset, GumCpuReg src_reg); -GUM_API void gum_x86_writer_put_mov_reg_reg_ptr (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_mov_reg_reg_offset_ptr (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg, gssize src_offset); -GUM_API gboolean gum_x86_writer_put_mov_reg_base_index_scale_offset_ptr ( - GumX86Writer * self, GumCpuReg dst_reg, GumCpuReg base_reg, - GumCpuReg index_reg, guint8 scale, gssize offset); - -GUM_API gboolean gum_x86_writer_put_mov_reg_near_ptr (GumX86Writer * self, - GumCpuReg dst_reg, GumAddress src_address); -GUM_API gboolean gum_x86_writer_put_mov_near_ptr_reg (GumX86Writer * self, - GumAddress dst_address, GumCpuReg src_reg); - -GUM_API gboolean gum_x86_writer_put_mov_fs_u32_ptr_reg (GumX86Writer * self, - guint32 fs_offset, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_mov_reg_fs_u32_ptr (GumX86Writer * self, - GumCpuReg dst_reg, guint32 fs_offset); -GUM_API gboolean gum_x86_writer_put_mov_gs_u32_ptr_reg (GumX86Writer * self, - guint32 fs_offset, GumCpuReg src_reg); -GUM_API gboolean gum_x86_writer_put_mov_reg_gs_u32_ptr (GumX86Writer * self, - GumCpuReg dst_reg, guint32 fs_offset); - -GUM_API void gum_x86_writer_put_movq_xmm0_esp_offset_ptr (GumX86Writer * self, - gint8 offset); -GUM_API void gum_x86_writer_put_movq_eax_offset_ptr_xmm0 (GumX86Writer * self, - gint8 offset); -GUM_API void gum_x86_writer_put_movdqu_xmm0_esp_offset_ptr (GumX86Writer * self, - gint8 offset); -GUM_API void gum_x86_writer_put_movdqu_eax_offset_ptr_xmm0 (GumX86Writer * self, - gint8 offset); - -GUM_API gboolean gum_x86_writer_put_lea_reg_reg_offset (GumX86Writer * self, - GumCpuReg dst_reg, GumCpuReg src_reg, gssize src_offset); - -GUM_API gboolean gum_x86_writer_put_xchg_reg_reg_ptr (GumX86Writer * self, - GumCpuReg left_reg, GumCpuReg right_reg); - -GUM_API void gum_x86_writer_put_push_u32 (GumX86Writer * self, - guint32 imm_value); -GUM_API gboolean gum_x86_writer_put_push_near_ptr (GumX86Writer * self, - GumAddress address); -GUM_API gboolean gum_x86_writer_put_push_reg (GumX86Writer * self, - GumCpuReg reg); -GUM_API gboolean gum_x86_writer_put_pop_reg (GumX86Writer * self, - GumCpuReg reg); -GUM_API void gum_x86_writer_put_push_imm_ptr (GumX86Writer * self, - gconstpointer imm_ptr); -GUM_API void gum_x86_writer_put_pushax (GumX86Writer * self); -GUM_API void gum_x86_writer_put_popax (GumX86Writer * self); -GUM_API void gum_x86_writer_put_pushfx (GumX86Writer * self); -GUM_API void gum_x86_writer_put_popfx (GumX86Writer * self); - -GUM_API gboolean gum_x86_writer_put_test_reg_reg (GumX86Writer * self, - GumCpuReg reg_a, GumCpuReg reg_b); -GUM_API gboolean gum_x86_writer_put_test_reg_u32 (GumX86Writer * self, - GumCpuReg reg, guint32 imm_value); -GUM_API gboolean gum_x86_writer_put_cmp_reg_i32 (GumX86Writer * self, - GumCpuReg reg, gint32 imm_value); -GUM_API gboolean gum_x86_writer_put_cmp_reg_offset_ptr_reg (GumX86Writer * self, - GumCpuReg reg_a, gssize offset, GumCpuReg reg_b); -GUM_API void gum_x86_writer_put_cmp_imm_ptr_imm_u32 (GumX86Writer * self, - gconstpointer imm_ptr, guint32 imm_value); -GUM_API gboolean gum_x86_writer_put_cmp_reg_reg (GumX86Writer * self, - GumCpuReg reg_a, GumCpuReg reg_b); -GUM_API void gum_x86_writer_put_clc (GumX86Writer * self); -GUM_API void gum_x86_writer_put_stc (GumX86Writer * self); -GUM_API void gum_x86_writer_put_cld (GumX86Writer * self); -GUM_API void gum_x86_writer_put_std (GumX86Writer * self); - -GUM_API void gum_x86_writer_put_cpuid (GumX86Writer * self); -GUM_API void gum_x86_writer_put_lfence (GumX86Writer * self); -GUM_API void gum_x86_writer_put_rdtsc (GumX86Writer * self); -GUM_API void gum_x86_writer_put_pause (GumX86Writer * self); -GUM_API void gum_x86_writer_put_nop (GumX86Writer * self); -GUM_API void gum_x86_writer_put_breakpoint (GumX86Writer * self); -GUM_API void gum_x86_writer_put_padding (GumX86Writer * self, guint n); -GUM_API void gum_x86_writer_put_nop_padding (GumX86Writer * self, guint n); - -GUM_API void gum_x86_writer_put_u8 (GumX86Writer * self, guint8 value); -GUM_API void gum_x86_writer_put_s8 (GumX86Writer * self, gint8 value); -GUM_API void gum_x86_writer_put_bytes (GumX86Writer * self, const guint8 * data, - guint n); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2010-2020 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_ARM_WRITER_H__ -#define __GUM_ARM_WRITER_H__ - - -#define GUM_ARM_B_MAX_DISTANCE 0x01fffffc - -G_BEGIN_DECLS - -typedef struct _GumArmWriter GumArmWriter; - -struct _GumArmWriter -{ - volatile gint ref_count; - - GumOS target_os; - - guint32 * base; - guint32 * code; - GumAddress pc; - - GumMetalHashTable * label_defs; - GumMetalArray label_refs; - GumMetalArray literal_refs; - const guint32 * earliest_literal_insn; -}; - -GUM_API GumArmWriter * gum_arm_writer_new (gpointer code_address); -GUM_API GumArmWriter * gum_arm_writer_ref (GumArmWriter * writer); -GUM_API void gum_arm_writer_unref (GumArmWriter * writer); - -GUM_API void gum_arm_writer_init (GumArmWriter * writer, gpointer code_address); -GUM_API void gum_arm_writer_clear (GumArmWriter * writer); - -GUM_API void gum_arm_writer_reset (GumArmWriter * writer, - gpointer code_address); -GUM_API void gum_arm_writer_set_target_os (GumArmWriter * self, GumOS os); - -GUM_API gpointer gum_arm_writer_cur (GumArmWriter * self); -GUM_API guint gum_arm_writer_offset (GumArmWriter * self); -GUM_API void gum_arm_writer_skip (GumArmWriter * self, guint n_bytes); - -GUM_API gboolean gum_arm_writer_flush (GumArmWriter * self); - -GUM_API gboolean gum_arm_writer_put_label (GumArmWriter * self, - gconstpointer id); - -GUM_API void gum_arm_writer_put_call_address_with_arguments ( - GumArmWriter * self, GumAddress func, guint n_args, ...); -GUM_API void gum_arm_writer_put_call_address_with_arguments_array ( - GumArmWriter * self, GumAddress func, guint n_args, - const GumArgument * args); - -GUM_API void gum_arm_writer_put_branch_address (GumArmWriter * self, - GumAddress address); - -GUM_API gboolean gum_arm_writer_can_branch_directly_between ( - GumArmWriter * self, GumAddress from, GumAddress to); -GUM_API gboolean gum_arm_writer_put_b_imm (GumArmWriter * self, - GumAddress target); -GUM_API gboolean gum_arm_writer_put_b_cond_imm (GumArmWriter * self, - arm_cc cc, GumAddress target); -GUM_API void gum_arm_writer_put_b_label (GumArmWriter * self, - gconstpointer label_id); -GUM_API void gum_arm_writer_put_b_cond_label (GumArmWriter * self, - arm_cc cc, gconstpointer label_id); -GUM_API gboolean gum_arm_writer_put_bl_imm (GumArmWriter * self, - GumAddress target); -GUM_API gboolean gum_arm_writer_put_blx_imm (GumArmWriter * self, - GumAddress target); -GUM_API void gum_arm_writer_put_bl_label (GumArmWriter * self, - gconstpointer label_id); -GUM_API void gum_arm_writer_put_bx_reg (GumArmWriter * self, arm_reg reg); -GUM_API void gum_arm_writer_put_blx_reg (GumArmWriter * self, arm_reg reg); -GUM_API void gum_arm_writer_put_ret (GumArmWriter * self); - -GUM_API void gum_arm_writer_put_push_registers (GumArmWriter * self, guint n, - ...); -GUM_API void gum_arm_writer_put_pop_registers (GumArmWriter * self, guint n, - ...); - -GUM_API gboolean gum_arm_writer_put_ldr_reg_address (GumArmWriter * self, - arm_reg reg, GumAddress address); -GUM_API gboolean gum_arm_writer_put_ldr_reg_u32 (GumArmWriter * self, - arm_reg reg, guint32 val); -GUM_API gboolean gum_arm_writer_put_ldr_reg_reg_offset (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg, gssize src_offset); -GUM_API gboolean gum_arm_writer_put_ldr_cond_reg_reg_offset ( - GumArmWriter * self, arm_cc cc, arm_reg dst_reg, arm_reg src_reg, - gssize src_offset); -GUM_API void gum_arm_writer_put_ldmia_reg_mask (GumArmWriter * self, - arm_reg reg, guint16 mask); -GUM_API gboolean gum_arm_writer_put_str_reg_reg_offset ( - GumArmWriter * self, arm_reg src_reg, arm_reg dst_reg, - gssize dst_offset); -GUM_API gboolean gum_arm_writer_put_str_cond_reg_reg_offset ( - GumArmWriter * self, arm_cc cc, arm_reg src_reg, - arm_reg dst_reg, gssize dst_offset); -GUM_API void gum_arm_writer_put_mov_reg_reg (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg); -GUM_API void gum_arm_writer_put_mov_reg_reg_shift (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg, arm_shifter shift, - guint16 shift_value); -GUM_API void gum_arm_writer_put_mov_reg_cpsr (GumArmWriter * self, arm_reg reg); -GUM_API void gum_arm_writer_put_mov_cpsr_reg (GumArmWriter * self, arm_reg reg); -GUM_API void gum_arm_writer_put_add_reg_u16 (GumArmWriter * self, - arm_reg dst_reg, guint16 val); -GUM_API void gum_arm_writer_put_add_reg_u32 (GumArmWriter * self, - arm_reg dst_reg, guint32 val); -GUM_API void gum_arm_writer_put_add_reg_reg_imm (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg, guint32 imm_val); -GUM_API void gum_arm_writer_put_add_reg_reg_reg (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg1, arm_reg src_reg2); -GUM_API void gum_arm_writer_put_add_reg_reg_reg_shift (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg1, arm_reg src_reg2, arm_shifter shift, - guint16 shift_value); -GUM_API void gum_arm_writer_put_sub_reg_u16 (GumArmWriter * self, - arm_reg dst_reg, guint16 val); -GUM_API void gum_arm_writer_put_sub_reg_u32 (GumArmWriter * self, - arm_reg dst_reg, guint32 val); -GUM_API void gum_arm_writer_put_sub_reg_reg_imm (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg, guint32 imm_val); -GUM_API void gum_arm_writer_put_sub_reg_reg_reg (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg1, arm_reg src_reg2); -GUM_API void gum_arm_writer_put_rsb_reg_reg_imm (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg, guint32 imm_val); -GUM_API void gum_arm_writer_put_ands_reg_reg_imm (GumArmWriter * self, - arm_reg dst_reg, arm_reg src_reg, guint32 imm_val); -GUM_API void gum_arm_writer_put_cmp_reg_imm (GumArmWriter * self, - arm_reg dst_reg, guint32 imm_val); - -GUM_API void gum_arm_writer_put_nop (GumArmWriter * self); -GUM_API void gum_arm_writer_put_breakpoint (GumArmWriter * self); -GUM_API void gum_arm_writer_put_brk_imm (GumArmWriter * self, - guint16 imm); - -GUM_API void gum_arm_writer_put_instruction (GumArmWriter * self, guint32 insn); -GUM_API gboolean gum_arm_writer_put_bytes (GumArmWriter * self, - const guint8 * data, guint n); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2010-2019 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_THUMB_WRITER_H__ -#define __GUM_THUMB_WRITER_H__ - - -#define GUM_THUMB_B_MAX_DISTANCE 0x00fffffe - -G_BEGIN_DECLS - -typedef struct _GumThumbWriter GumThumbWriter; - -struct _GumThumbWriter -{ - volatile gint ref_count; - - GumOS target_os; - - guint16 * base; - guint16 * code; - GumAddress pc; - - GumMetalHashTable * label_defs; - GumMetalArray label_refs; - GumMetalArray literal_refs; - const guint16 * earliest_literal_insn; -}; - -GUM_API GumThumbWriter * gum_thumb_writer_new (gpointer code_address); -GUM_API GumThumbWriter * gum_thumb_writer_ref (GumThumbWriter * writer); -GUM_API void gum_thumb_writer_unref (GumThumbWriter * writer); - -GUM_API void gum_thumb_writer_init (GumThumbWriter * writer, - gpointer code_address); -GUM_API void gum_thumb_writer_clear (GumThumbWriter * writer); - -GUM_API void gum_thumb_writer_reset (GumThumbWriter * writer, - gpointer code_address); -GUM_API void gum_thumb_writer_set_target_os (GumThumbWriter * self, GumOS os); - -GUM_API gpointer gum_thumb_writer_cur (GumThumbWriter * self); -GUM_API guint gum_thumb_writer_offset (GumThumbWriter * self); -GUM_API void gum_thumb_writer_skip (GumThumbWriter * self, guint n_bytes); - -GUM_API gboolean gum_thumb_writer_flush (GumThumbWriter * self); - -GUM_API gboolean gum_thumb_writer_put_label (GumThumbWriter * self, - gconstpointer id); -GUM_API gboolean gum_thumb_writer_commit_label (GumThumbWriter * self, - gconstpointer id); - -GUM_API void gum_thumb_writer_put_call_address_with_arguments ( - GumThumbWriter * self, GumAddress func, guint n_args, ...); -GUM_API void gum_thumb_writer_put_call_address_with_arguments_array ( - GumThumbWriter * self, GumAddress func, guint n_args, - const GumArgument * args); -GUM_API void gum_thumb_writer_put_call_reg_with_arguments ( - GumThumbWriter * self, arm_reg reg, guint n_args, ...); -GUM_API void gum_thumb_writer_put_call_reg_with_arguments_array ( - GumThumbWriter * self, arm_reg reg, guint n_args, const GumArgument * args); - -GUM_API void gum_thumb_writer_put_branch_address (GumThumbWriter * self, - GumAddress address); - -GUM_API gboolean gum_thumb_writer_can_branch_directly_between ( - GumThumbWriter * self, GumAddress from, GumAddress to); -GUM_API void gum_thumb_writer_put_b_imm (GumThumbWriter * self, - GumAddress target); -GUM_API void gum_thumb_writer_put_b_label (GumThumbWriter * self, - gconstpointer label_id); -GUM_API void gum_thumb_writer_put_b_label_wide (GumThumbWriter * self, - gconstpointer label_id); -GUM_API void gum_thumb_writer_put_bx_reg (GumThumbWriter * self, arm_reg reg); -GUM_API void gum_thumb_writer_put_bl_imm (GumThumbWriter * self, - GumAddress target); -GUM_API void gum_thumb_writer_put_bl_label (GumThumbWriter * self, - gconstpointer label_id); -GUM_API void gum_thumb_writer_put_blx_imm (GumThumbWriter * self, - GumAddress target); -GUM_API void gum_thumb_writer_put_blx_reg (GumThumbWriter * self, arm_reg reg); -GUM_API void gum_thumb_writer_put_cmp_reg_imm (GumThumbWriter * self, - arm_reg reg, guint8 imm_value); -GUM_API void gum_thumb_writer_put_beq_label (GumThumbWriter * self, - gconstpointer label_id); -GUM_API void gum_thumb_writer_put_bne_label (GumThumbWriter * self, - gconstpointer label_id); -GUM_API void gum_thumb_writer_put_b_cond_label (GumThumbWriter * self, - arm_cc cc, gconstpointer label_id); -GUM_API void gum_thumb_writer_put_b_cond_label_wide (GumThumbWriter * self, - arm_cc cc, gconstpointer label_id); -GUM_API void gum_thumb_writer_put_cbz_reg_label (GumThumbWriter * self, - arm_reg reg, gconstpointer label_id); -GUM_API void gum_thumb_writer_put_cbnz_reg_label (GumThumbWriter * self, - arm_reg reg, gconstpointer label_id); - -GUM_API gboolean gum_thumb_writer_put_push_regs (GumThumbWriter * self, - guint n_regs, arm_reg first_reg, ...); -GUM_API gboolean gum_thumb_writer_put_push_regs_array (GumThumbWriter * self, - guint n_regs, const arm_reg * regs); -GUM_API gboolean gum_thumb_writer_put_pop_regs (GumThumbWriter * self, - guint n_regs, arm_reg first_reg, ...); -GUM_API gboolean gum_thumb_writer_put_pop_regs_array (GumThumbWriter * self, - guint n_regs, const arm_reg * regs); -GUM_API gboolean gum_thumb_writer_put_ldr_reg_address (GumThumbWriter * self, - arm_reg reg, GumAddress address); -GUM_API gboolean gum_thumb_writer_put_ldr_reg_u32 (GumThumbWriter * self, - arm_reg reg, guint32 val); -GUM_API void gum_thumb_writer_put_ldr_reg_reg (GumThumbWriter * self, - arm_reg dst_reg, arm_reg src_reg); -GUM_API gboolean gum_thumb_writer_put_ldr_reg_reg_offset (GumThumbWriter * self, - arm_reg dst_reg, arm_reg src_reg, gsize src_offset); -GUM_API void gum_thumb_writer_put_ldrb_reg_reg (GumThumbWriter * self, - arm_reg dst_reg, arm_reg src_reg); -void gum_thumb_writer_put_ldrh_reg_reg (GumThumbWriter * self, arm_reg dst_reg, - arm_reg src_reg); -GUM_API gboolean gum_thumb_writer_put_vldr_reg_reg_offset ( - GumThumbWriter * self, arm_reg dst_reg, arm_reg src_reg, gssize src_offset); -GUM_API void gum_thumb_writer_put_ldmia_reg_mask (GumThumbWriter * self, - arm_reg reg, guint16 mask); -GUM_API void gum_thumb_writer_put_str_reg_reg (GumThumbWriter * self, - arm_reg src_reg, arm_reg dst_reg); -GUM_API gboolean gum_thumb_writer_put_str_reg_reg_offset (GumThumbWriter * self, - arm_reg src_reg, arm_reg dst_reg, gsize dst_offset); -GUM_API void gum_thumb_writer_put_mov_reg_reg (GumThumbWriter * self, - arm_reg dst_reg, arm_reg src_reg); -GUM_API void gum_thumb_writer_put_mov_reg_u8 (GumThumbWriter * self, - arm_reg dst_reg, guint8 imm_value); -GUM_API void gum_thumb_writer_put_mov_reg_cpsr (GumThumbWriter * self, - arm_reg reg); -GUM_API void gum_thumb_writer_put_mov_cpsr_reg (GumThumbWriter * self, - arm_reg reg); -GUM_API gboolean gum_thumb_writer_put_add_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, gssize imm_value); -GUM_API void gum_thumb_writer_put_add_reg_reg (GumThumbWriter * self, - arm_reg dst_reg, arm_reg src_reg); -GUM_API void gum_thumb_writer_put_add_reg_reg_reg (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, arm_reg right_reg); -GUM_API gboolean gum_thumb_writer_put_add_reg_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, gssize right_value); -GUM_API gboolean gum_thumb_writer_put_sub_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, gssize imm_value); -GUM_API void gum_thumb_writer_put_sub_reg_reg (GumThumbWriter * self, - arm_reg dst_reg, arm_reg src_reg); -GUM_API void gum_thumb_writer_put_sub_reg_reg_reg (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, arm_reg right_reg); -GUM_API gboolean gum_thumb_writer_put_sub_reg_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, gssize right_value); -GUM_API gboolean gum_thumb_writer_put_and_reg_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, gssize right_value); -GUM_API gboolean gum_thumb_writer_put_or_reg_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, gssize right_value); -GUM_API gboolean gum_thumb_writer_put_lsl_reg_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, guint8 right_value); -GUM_API gboolean gum_thumb_writer_put_lsls_reg_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, guint8 right_value); -GUM_API gboolean gum_thumb_writer_put_lsrs_reg_reg_imm (GumThumbWriter * self, - arm_reg dst_reg, arm_reg left_reg, guint8 right_value); -GUM_API gboolean gum_thumb_writer_put_mrs_reg_reg (GumThumbWriter * self, - arm_reg dst_reg, arm_sysreg src_reg); -GUM_API gboolean gum_thumb_writer_put_msr_reg_reg (GumThumbWriter * self, - arm_sysreg dst_reg, arm_reg src_reg); - -GUM_API void gum_thumb_writer_put_nop (GumThumbWriter * self); -GUM_API void gum_thumb_writer_put_bkpt_imm (GumThumbWriter * self, guint8 imm); -GUM_API void gum_thumb_writer_put_breakpoint (GumThumbWriter * self); - -GUM_API void gum_thumb_writer_put_instruction (GumThumbWriter * self, - guint16 insn); -GUM_API void gum_thumb_writer_put_instruction_wide (GumThumbWriter * self, - guint16 upper, guint16 lower); -GUM_API gboolean gum_thumb_writer_put_bytes (GumThumbWriter * self, - const guint8 * data, guint n); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2014-2020 Ole André Vadla Ravnås - * Copyright (C) 2017 Antonio Ken Iannillo - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_ARM64_WRITER_H__ -#define __GUM_ARM64_WRITER_H__ - - -#define GUM_ARM64_ADRP_MAX_DISTANCE 0xfffff000 -#define GUM_ARM64_B_MAX_DISTANCE 0x07fffffc - -G_BEGIN_DECLS - -typedef struct _GumArm64Writer GumArm64Writer; -typedef guint GumArm64IndexMode; - -struct _GumArm64Writer -{ - volatile gint ref_count; - - GumOS target_os; - GumPtrauthSupport ptrauth_support; - GumAddress (* sign) (GumAddress value); - - guint32 * base; - guint32 * code; - GumAddress pc; - - GumMetalHashTable * label_defs; - GumMetalArray label_refs; - GumMetalArray literal_refs; - const guint32 * earliest_literal_insn; -}; - -enum _GumArm64IndexMode -{ - GUM_INDEX_POST_ADJUST = 1, - GUM_INDEX_SIGNED_OFFSET = 2, - GUM_INDEX_PRE_ADJUST = 3, -}; - -GUM_API GumArm64Writer * gum_arm64_writer_new (gpointer code_address); -GUM_API GumArm64Writer * gum_arm64_writer_ref (GumArm64Writer * writer); -GUM_API void gum_arm64_writer_unref (GumArm64Writer * writer); - -GUM_API void gum_arm64_writer_init (GumArm64Writer * writer, - gpointer code_address); -GUM_API void gum_arm64_writer_clear (GumArm64Writer * writer); - -GUM_API void gum_arm64_writer_reset (GumArm64Writer * writer, - gpointer code_address); - -GUM_API gpointer gum_arm64_writer_cur (GumArm64Writer * self); -GUM_API guint gum_arm64_writer_offset (GumArm64Writer * self); -GUM_API void gum_arm64_writer_skip (GumArm64Writer * self, guint n_bytes); - -GUM_API gboolean gum_arm64_writer_flush (GumArm64Writer * self); - -GUM_API gboolean gum_arm64_writer_put_label (GumArm64Writer * self, - gconstpointer id); - -GUM_API void gum_arm64_writer_put_call_address_with_arguments ( - GumArm64Writer * self, GumAddress func, guint n_args, ...); -GUM_API void gum_arm64_writer_put_call_address_with_arguments_array ( - GumArm64Writer * self, GumAddress func, guint n_args, - const GumArgument * args); -GUM_API void gum_arm64_writer_put_call_reg_with_arguments ( - GumArm64Writer * self, arm64_reg reg, guint n_args, ...); -GUM_API void gum_arm64_writer_put_call_reg_with_arguments_array ( - GumArm64Writer * self, arm64_reg reg, guint n_args, - const GumArgument * args); - -GUM_API void gum_arm64_writer_put_branch_address (GumArm64Writer * self, - GumAddress address); - -GUM_API gboolean gum_arm64_writer_can_branch_directly_between ( - GumArm64Writer * self, GumAddress from, GumAddress to); -GUM_API gboolean gum_arm64_writer_put_b_imm (GumArm64Writer * self, - GumAddress address); -GUM_API void gum_arm64_writer_put_b_label (GumArm64Writer * self, - gconstpointer label_id); -GUM_API void gum_arm64_writer_put_b_cond_label (GumArm64Writer * self, - arm64_cc cc, gconstpointer label_id); -GUM_API gboolean gum_arm64_writer_put_bl_imm (GumArm64Writer * self, - GumAddress address); -GUM_API void gum_arm64_writer_put_bl_label (GumArm64Writer * self, - gconstpointer label_id); -GUM_API gboolean gum_arm64_writer_put_br_reg (GumArm64Writer * self, - arm64_reg reg); -GUM_API gboolean gum_arm64_writer_put_br_reg_no_auth (GumArm64Writer * self, - arm64_reg reg); -GUM_API gboolean gum_arm64_writer_put_blr_reg (GumArm64Writer * self, - arm64_reg reg); -GUM_API gboolean gum_arm64_writer_put_blr_reg_no_auth (GumArm64Writer * self, - arm64_reg reg); -GUM_API void gum_arm64_writer_put_ret (GumArm64Writer * self); -GUM_API void gum_arm64_writer_put_cbz_reg_label (GumArm64Writer * self, - arm64_reg reg, gconstpointer label_id); -GUM_API void gum_arm64_writer_put_cbnz_reg_label (GumArm64Writer * self, - arm64_reg reg, gconstpointer label_id); -GUM_API void gum_arm64_writer_put_tbz_reg_imm_label (GumArm64Writer * self, - arm64_reg reg, guint bit, gconstpointer label_id); -GUM_API void gum_arm64_writer_put_tbnz_reg_imm_label (GumArm64Writer * self, - arm64_reg reg, guint bit, gconstpointer label_id); - -GUM_API gboolean gum_arm64_writer_put_push_reg_reg (GumArm64Writer * self, - arm64_reg reg_a, arm64_reg reg_b); -GUM_API gboolean gum_arm64_writer_put_pop_reg_reg (GumArm64Writer * self, - arm64_reg reg_a, arm64_reg reg_b); -GUM_API void gum_arm64_writer_put_push_all_x_registers (GumArm64Writer * self); -GUM_API void gum_arm64_writer_put_pop_all_x_registers (GumArm64Writer * self); -GUM_API void gum_arm64_writer_put_push_all_q_registers (GumArm64Writer * self); -GUM_API void gum_arm64_writer_put_pop_all_q_registers (GumArm64Writer * self); - -GUM_API gboolean gum_arm64_writer_put_ldr_reg_address (GumArm64Writer * self, - arm64_reg reg, GumAddress address); -GUM_API gboolean gum_arm64_writer_put_ldr_reg_u64 (GumArm64Writer * self, - arm64_reg reg, guint64 val); -GUM_API guint gum_arm64_writer_put_ldr_reg_ref (GumArm64Writer * self, - arm64_reg reg); -GUM_API void gum_arm64_writer_put_ldr_reg_value (GumArm64Writer * self, - guint ref, GumAddress value); -GUM_API gboolean gum_arm64_writer_put_ldr_reg_reg_offset (GumArm64Writer * self, - arm64_reg dst_reg, arm64_reg src_reg, gsize src_offset); -GUM_API gboolean gum_arm64_writer_put_ldrsw_reg_reg_offset ( - GumArm64Writer * self, arm64_reg dst_reg, arm64_reg src_reg, - gsize src_offset); -GUM_API gboolean gum_arm64_writer_put_adrp_reg_address (GumArm64Writer * self, - arm64_reg reg, GumAddress address); -GUM_API gboolean gum_arm64_writer_put_str_reg_reg_offset (GumArm64Writer * self, - arm64_reg src_reg, arm64_reg dst_reg, gsize dst_offset); -GUM_API gboolean gum_arm64_writer_put_ldp_reg_reg_reg_offset ( - GumArm64Writer * self, arm64_reg reg_a, arm64_reg reg_b, arm64_reg reg_src, - gssize src_offset, GumArm64IndexMode mode); -GUM_API gboolean gum_arm64_writer_put_stp_reg_reg_reg_offset ( - GumArm64Writer * self, arm64_reg reg_a, arm64_reg reg_b, arm64_reg reg_dst, - gssize dst_offset, GumArm64IndexMode mode); -GUM_API gboolean gum_arm64_writer_put_mov_reg_reg (GumArm64Writer * self, - arm64_reg dst_reg, arm64_reg src_reg); -GUM_API gboolean gum_arm64_writer_put_uxtw_reg_reg (GumArm64Writer * self, - arm64_reg dst_reg, arm64_reg src_reg); -GUM_API gboolean gum_arm64_writer_put_add_reg_reg_imm (GumArm64Writer * self, - arm64_reg dst_reg, arm64_reg left_reg, gsize right_value); -GUM_API gboolean gum_arm64_writer_put_add_reg_reg_reg (GumArm64Writer * self, - arm64_reg dst_reg, arm64_reg left_reg, arm64_reg right_reg); -GUM_API gboolean gum_arm64_writer_put_sub_reg_reg_imm (GumArm64Writer * self, - arm64_reg dst_reg, arm64_reg left_reg, gsize right_value); -GUM_API gboolean gum_arm64_writer_put_sub_reg_reg_reg (GumArm64Writer * self, - arm64_reg dst_reg, arm64_reg left_reg, arm64_reg right_reg); -GUM_API gboolean gum_arm64_writer_put_and_reg_reg_imm (GumArm64Writer * self, - arm64_reg dst_reg, arm64_reg left_reg, gsize right_value); -GUM_API gboolean gum_arm64_writer_put_tst_reg_imm (GumArm64Writer * self, - arm64_reg reg, guint64 imm_value); -GUM_API gboolean gum_arm64_writer_put_cmp_reg_reg (GumArm64Writer * self, - arm64_reg reg_a, arm64_reg reg_b); - -GUM_API gboolean gum_arm64_writer_put_xpaci_reg (GumArm64Writer * self, - arm64_reg reg); - -GUM_API void gum_arm64_writer_put_nop (GumArm64Writer * self); -GUM_API void gum_arm64_writer_put_brk_imm (GumArm64Writer * self, guint16 imm); - -GUM_API void gum_arm64_writer_put_instruction (GumArm64Writer * self, - guint32 insn); -GUM_API gboolean gum_arm64_writer_put_bytes (GumArm64Writer * self, - const guint8 * data, guint n); - -GUM_API GumAddress gum_arm64_writer_sign (GumArm64Writer * self, - GumAddress value); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2014-2019 Ole André Vadla Ravnås - * Copyright (C) 2019 Jon Wilson - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_MIPS_WRITER_H__ -#define __GUM_MIPS_WRITER_H__ - - -#define GUM_MIPS_J_MAX_DISTANCE (1 << 28) - -G_BEGIN_DECLS - -typedef struct _GumMipsWriter GumMipsWriter; - -struct _GumMipsWriter -{ - volatile gint ref_count; - - guint32 * base; - guint32 * code; - GumAddress pc; - - GumMetalHashTable * label_defs; - GumMetalArray label_refs; -}; - -GUM_API GumMipsWriter * gum_mips_writer_new (gpointer code_address); -GUM_API GumMipsWriter * gum_mips_writer_ref (GumMipsWriter * writer); -GUM_API void gum_mips_writer_unref (GumMipsWriter * writer); - -GUM_API void gum_mips_writer_init (GumMipsWriter * writer, - gpointer code_address); -GUM_API void gum_mips_writer_clear (GumMipsWriter * writer); - -GUM_API void gum_mips_writer_reset (GumMipsWriter * writer, - gpointer code_address); - -GUM_API gpointer gum_mips_writer_cur (GumMipsWriter * self); -GUM_API guint gum_mips_writer_offset (GumMipsWriter * self); -GUM_API void gum_mips_writer_skip (GumMipsWriter * self, guint n_bytes); - -GUM_API gboolean gum_mips_writer_flush (GumMipsWriter * self); - -GUM_API gboolean gum_mips_writer_put_label (GumMipsWriter * self, - gconstpointer id); - -GUM_API void gum_mips_writer_put_call_address_with_arguments ( - GumMipsWriter * self, GumAddress func, guint n_args, ...); -GUM_API void gum_mips_writer_put_call_address_with_arguments_array ( - GumMipsWriter * self, GumAddress func, guint n_args, - const GumArgument * args); -GUM_API void gum_mips_writer_put_call_reg_with_arguments (GumMipsWriter * self, - mips_reg reg, guint n_args, ...); -GUM_API void gum_mips_writer_put_call_reg_with_arguments_array ( - GumMipsWriter * self, mips_reg reg, guint n_args, const GumArgument * args); - -GUM_API gboolean gum_mips_writer_can_branch_directly_between (GumAddress from, - GumAddress to); -GUM_API gboolean gum_mips_writer_put_j_address (GumMipsWriter * self, - GumAddress address); -GUM_API gboolean gum_mips_writer_put_j_address_without_nop ( - GumMipsWriter * self, GumAddress address); -GUM_API void gum_mips_writer_put_j_label (GumMipsWriter * self, - gconstpointer label_id); -GUM_API void gum_mips_writer_put_jr_reg (GumMipsWriter * self, mips_reg reg); -GUM_API void gum_mips_writer_put_jal_address (GumMipsWriter * self, - guint32 address); -GUM_API void gum_mips_writer_put_jalr_reg (GumMipsWriter * self, mips_reg reg); -GUM_API void gum_mips_writer_put_b_offset (GumMipsWriter * self, gint32 offset); -GUM_API void gum_mips_writer_put_beq_reg_reg_label (GumMipsWriter * self, - mips_reg right_reg, mips_reg left_reg, gconstpointer label_id); -GUM_API void gum_mips_writer_put_ret (GumMipsWriter * self); - -GUM_API void gum_mips_writer_put_la_reg_address (GumMipsWriter * self, - mips_reg reg, GumAddress address); -GUM_API void gum_mips_writer_put_lui_reg_imm (GumMipsWriter * self, - mips_reg reg, guint imm); -GUM_API void gum_mips_writer_put_dsll_reg_reg (GumMipsWriter * self, - mips_reg dst_reg, mips_reg src_reg, guint amount); -GUM_API void gum_mips_writer_put_ori_reg_reg_imm (GumMipsWriter * self, - mips_reg rt, mips_reg rs, guint imm); -GUM_API void gum_mips_writer_put_ld_reg_reg_offset (GumMipsWriter * self, - mips_reg dst_reg, mips_reg src_reg, gsize src_offset); -GUM_API void gum_mips_writer_put_lw_reg_reg_offset (GumMipsWriter * self, - mips_reg dst_reg, mips_reg src_reg, gsize src_offset); -GUM_API void gum_mips_writer_put_sw_reg_reg_offset (GumMipsWriter * self, - mips_reg src_reg, mips_reg dst_reg, gsize dst_offset); -GUM_API void gum_mips_writer_put_move_reg_reg (GumMipsWriter * self, - mips_reg dst_reg, mips_reg src_reg); -GUM_API void gum_mips_writer_put_addu_reg_reg_reg (GumMipsWriter * self, - mips_reg dst_reg, mips_reg left_reg, mips_reg right_reg); -GUM_API void gum_mips_writer_put_addi_reg_reg_imm (GumMipsWriter * self, - mips_reg dst_reg, mips_reg left_reg, gint32 imm); -GUM_API void gum_mips_writer_put_addi_reg_imm (GumMipsWriter * self, - mips_reg dst_reg, gint32 imm); -GUM_API void gum_mips_writer_put_sub_reg_reg_imm (GumMipsWriter * self, - mips_reg dst_reg, mips_reg left_reg, gint32 imm); - -GUM_API void gum_mips_writer_put_push_reg (GumMipsWriter * self, mips_reg reg); -GUM_API void gum_mips_writer_put_pop_reg (GumMipsWriter * self, mips_reg reg); - -GUM_API void gum_mips_writer_put_mfhi_reg (GumMipsWriter * self, mips_reg reg); -GUM_API void gum_mips_writer_put_mflo_reg (GumMipsWriter * self, mips_reg reg); -GUM_API void gum_mips_writer_put_mthi_reg (GumMipsWriter * self, mips_reg reg); -GUM_API void gum_mips_writer_put_mtlo_reg (GumMipsWriter * self, mips_reg reg); - -GUM_API void gum_mips_writer_put_nop (GumMipsWriter * self); -GUM_API void gum_mips_writer_put_break (GumMipsWriter * self); - -GUM_API void gum_mips_writer_put_prologue_trampoline (GumMipsWriter * self, - mips_reg reg, GumAddress address); - -GUM_API void gum_mips_writer_put_instruction (GumMipsWriter * self, - guint32 insn); -GUM_API gboolean gum_mips_writer_put_bytes (GumMipsWriter * self, - const guint8 * data, guint n); - -G_END_DECLS - -#endif - -G_BEGIN_DECLS - -#define GUM_TYPE_STALKER (gum_stalker_get_type ()) -G_DECLARE_FINAL_TYPE (GumStalker, gum_stalker, GUM, STALKER, GObject) - -#define GUM_TYPE_STALKER_TRANSFORMER (gum_stalker_transformer_get_type ()) -G_DECLARE_INTERFACE (GumStalkerTransformer, gum_stalker_transformer, GUM, - STALKER_TRANSFORMER, GObject) - -#define GUM_TYPE_DEFAULT_STALKER_TRANSFORMER \ - (gum_default_stalker_transformer_get_type ()) -G_DECLARE_FINAL_TYPE (GumDefaultStalkerTransformer, - gum_default_stalker_transformer, GUM, DEFAULT_STALKER_TRANSFORMER, - GObject) - -#define GUM_TYPE_CALLBACK_STALKER_TRANSFORMER \ - (gum_callback_stalker_transformer_get_type ()) -G_DECLARE_FINAL_TYPE (GumCallbackStalkerTransformer, - gum_callback_stalker_transformer, GUM, CALLBACK_STALKER_TRANSFORMER, - GObject) - -typedef struct _GumStalkerIterator GumStalkerIterator; -typedef struct _GumStalkerOutput GumStalkerOutput; -typedef union _GumStalkerWriter GumStalkerWriter; -typedef void (* GumStalkerTransformerCallback) (GumStalkerIterator * iterator, - GumStalkerOutput * output, gpointer user_data); -typedef void (* GumStalkerCallout) (GumCpuContext * cpu_context, - gpointer user_data); - -typedef guint GumProbeId; -typedef struct _GumCallSite GumCallSite; -typedef void (* GumCallProbeCallback) (GumCallSite * site, gpointer user_data); - -struct _GumStalkerTransformerInterface -{ - GTypeInterface parent; - - void (* transform_block) (GumStalkerTransformer * self, - GumStalkerIterator * iterator, GumStalkerOutput * output); -}; - -union _GumStalkerWriter -{ - gpointer instance; - GumX86Writer * x86; - GumArmWriter * arm; - GumThumbWriter * thumb; - GumArm64Writer * arm64; - GumMipsWriter * mips; -}; - -struct _GumStalkerOutput -{ - GumStalkerWriter writer; - GumInstructionEncoding encoding; -}; - -struct _GumCallSite -{ - gpointer block_address; - gpointer stack_data; - GumCpuContext * cpu_context; -}; - -GUM_API gboolean gum_stalker_is_supported (void); - -GUM_API GumStalker * gum_stalker_new (void); - -GUM_API void gum_stalker_exclude (GumStalker * self, - const GumMemoryRange * range); - -GUM_API gint gum_stalker_get_trust_threshold (GumStalker * self); -GUM_API void gum_stalker_set_trust_threshold (GumStalker * self, - gint trust_threshold); - -GUM_API void gum_stalker_flush (GumStalker * self); -GUM_API void gum_stalker_stop (GumStalker * self); -GUM_API gboolean gum_stalker_garbage_collect (GumStalker * self); - -GUM_API void gum_stalker_follow_me (GumStalker * self, - GumStalkerTransformer * transformer, GumEventSink * sink); -GUM_API void gum_stalker_unfollow_me (GumStalker * self); -GUM_API gboolean gum_stalker_is_following_me (GumStalker * self); - -GUM_API void gum_stalker_follow (GumStalker * self, GumThreadId thread_id, - GumStalkerTransformer * transformer, GumEventSink * sink); -GUM_API void gum_stalker_unfollow (GumStalker * self, GumThreadId thread_id); - -GUM_API void gum_stalker_activate (GumStalker * self, gconstpointer target); -GUM_API void gum_stalker_deactivate (GumStalker * self); - -GUM_API GumProbeId gum_stalker_add_call_probe (GumStalker * self, - gpointer target_address, GumCallProbeCallback callback, gpointer data, - GDestroyNotify notify); -GUM_API void gum_stalker_remove_call_probe (GumStalker * self, - GumProbeId id); - -#define gum_call_site_get_nth_argument(s, n) \ - gum_cpu_context_get_nth_argument ((s)->cpu_context, n) -#define gum_call_site_replace_nth_argument(s, n, v) \ - gum_cpu_context_replace_nth_argument ((s)->cpu_context, n, v) - -GUM_API GumStalkerTransformer * gum_stalker_transformer_make_default (void); -GUM_API GumStalkerTransformer * gum_stalker_transformer_make_from_callback ( - GumStalkerTransformerCallback callback, gpointer data, - GDestroyNotify data_destroy); - -GUM_API void gum_stalker_transformer_transform_block ( - GumStalkerTransformer * self, GumStalkerIterator * iterator, - GumStalkerOutput * output); - -GUM_API gboolean gum_stalker_iterator_next (GumStalkerIterator * self, - const cs_insn ** insn); -GUM_API void gum_stalker_iterator_keep (GumStalkerIterator * self); -GUM_API void gum_stalker_iterator_put_callout (GumStalkerIterator * self, - GumStalkerCallout callout, gpointer data, GDestroyNotify data_destroy); - -GUM_API void gum_stalker_set_counters_enabled (gboolean enabled); -GUM_API void gum_stalker_dump_counters (void); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2008-2010 Ole André Vadla Ravnås - * Copyright (C) 2008 Christian Berentsen - * Copyright (C) 2020 Matt Oh - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_SYMBOL_UTIL_H__ -#define __GUM_SYMBOL_UTIL_H__ - - -typedef struct _GumDebugSymbolDetails GumDebugSymbolDetails; - -struct _GumDebugSymbolDetails -{ - GumAddress address; - gchar module_name[GUM_MAX_PATH + 1]; - gchar symbol_name[GUM_MAX_SYMBOL_NAME + 1]; - gchar file_name[GUM_MAX_PATH + 1]; - guint line_number; -}; - -G_BEGIN_DECLS - -GUM_API gboolean gum_symbol_details_from_address (gpointer address, - GumDebugSymbolDetails * details); -GUM_API gchar * gum_symbol_name_from_address (gpointer address); - -GUM_API gpointer gum_find_function (const gchar * name); -GUM_API GArray * gum_find_functions_named (const gchar * name); -GUM_API GArray * gum_find_functions_matching (const gchar * str); -GUM_API gboolean gum_load_symbols (const gchar * path); - -G_END_DECLS - -#endif -/* - * Copyright (C) 2010-2014 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_SYS_INTERNALS_H__ -#define __GUM_SYS_INTERNALS_H__ - - -#ifdef G_OS_WIN32 - -# if GLIB_SIZEOF_VOID_P == 4 -# define GUM_TEB_OFFSET_SELF 0x0018 -# define GUM_TEB_OFFSET_TID 0x0024 -# else -# define GUM_TEB_OFFSET_SELF 0x0030 -# define GUM_TEB_OFFSET_TID 0x0048 -# endif - -#endif - -#endif -/* - * Copyright (C) 2010-2017 Ole André Vadla Ravnås - * - * Licence: wxWindows Library Licence, Version 3.1 - */ - -#ifndef __GUM_TLS_H__ -#define __GUM_TLS_H__ - - -G_BEGIN_DECLS - -typedef gsize GumTlsKey; - -GUM_API GumTlsKey gum_tls_key_new (void); -GUM_API void gum_tls_key_free (GumTlsKey key); - -GUM_API gpointer gum_tls_key_get_value (GumTlsKey key); -GUM_API void gum_tls_key_set_value (GumTlsKey key, gpointer value); - -G_END_DECLS - -#endif - -G_BEGIN_DECLS - -GUM_API void gum_init (void); -GUM_API void gum_shutdown (void); -GUM_API void gum_deinit (void); - -GUM_API void gum_init_embedded (void); -GUM_API void gum_deinit_embedded (void); - -GUM_API void gum_prepare_to_fork (void); -GUM_API void gum_recover_from_fork_in_parent (void); -GUM_API void gum_recover_from_fork_in_child (void); - -G_END_DECLS - -#endif diff --git a/utils/afl_frida/android/libfrida-gum.a b/utils/afl_frida/android/libfrida-gum.a deleted file mode 100644 index 2da655c8..00000000 Binary files a/utils/afl_frida/android/libfrida-gum.a and /dev/null differ -- cgit 1.4.1 From f380487bb49a66b1fac513cad344f1be5df10959 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 20 Jan 2021 13:51:57 +0100 Subject: wip --- src/afl-fuzz-redqueen.c | 518 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 452 insertions(+), 66 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index bf41863e..7ac0290a 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -517,6 +517,149 @@ static int strntoull(const char *str, size_t sz, char **end, int base, } +static u8 hex_table_up[16] = {'0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; +static u8 hex_table_low[16] = {'0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; +static u8 hex_table[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, + 0, 0, 0, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15}; + +// tests 2 bytes at location +static int is_hex(const char *str) { + + u32 i; + + for (i = 0; i < 2; i++) { + + switch (str[i]) { + + case '0' ... '9': + case 'A' ... 'F': + case 'a' ... 'f': + break; + default: + return 0; + + } + + } + + return 1; + +} + +// tests 4 bytes at location +static int is_base64(const char *str) { + + u32 i; + + for (i = 0; i < 4; i++) { + + switch (str[i]) { + + case '0' ... '9': + case 'A' ... 'Z': + case 'a' ... 'z': + case '+': + case '/': + break; + default: + return 0; + + } + + } + + return 1; + +} + +static u8 base64_encode_table[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static u8 base64_decode_table[] = { + 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51}; + +static u32 from_base64(u8 *src, u8 *dst, u32 dst_len) { + + u32 i, j, v; + u32 len = ((dst_len / 3) << 2); + u32 ret = 0; + + for (i = 0, j = 0; i < len; i += 4, j += 3) { + + v = base64_decode_table[src[i] - 43]; + v = (v << 6) | base64_decode_table[src[i + 1] - 43]; + v = src[i + 2] == '=' ? v << 6 + : (v << 6) | base64_decode_table[src[i + 2] - 43]; + v = src[i + 3] == '=' ? v << 6 + : (v << 6) | base64_decode_table[src[i + 3] - 43]; + + dst[j] = (v >> 16) & 0xFF; + ++ret; + + if (src[i + 2] != '=') { + + dst[j + 1] = (v >> 8) & 0xFF; + ++ret; + + } + + if (src[i + 3] != '=') { + + dst[j + 2] = v & 0xFF; + ++ret; + + } + + } + + return ret; + +} + +static void to_base64(u8 *src, u8 *dst, u32 dst_len) { + + u32 i, j, v; + u32 len = (dst_len >> 2) * 3; + + for (i = 0, j = 0; i < len; i += 3, j += 4) { + + v = src[i]; + v = i + 1 < len ? v << 8 | src[i + 1] : v << 8; + v = i + 2 < len ? v << 8 | src[i + 2] : v << 8; + + dst[j] = base64_encode_table[(v >> 18) & 0x3F]; + dst[j + 1] = base64_encode_table[(v >> 12) & 0x3F]; + if (i + 1 < len) { + + dst[j + 2] = base64_encode_table[(v >> 6) & 0x3F]; + + } else { + + dst[j + 2] = '='; + + } + + if (i + 2 < len) { + + dst[j + 3] = base64_encode_table[v & 0x3F]; + + } else { + + dst[j + 3] = '='; + + } + + } + +} + #endif static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, @@ -525,29 +668,6 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, u8 do_reverse, u8 lvl, u8 *status) { - // (void)(changed_val); // TODO - // we can use the information in changed_val to see if there is a - // computable i2s transformation. - // if (pattern != o_pattern && repl != changed_val) { - - // u64 in_diff = pattern - o_pattern, out_diff = repl - changed_val; - // if (in_diff != out_diff) { - - // switch(in_diff) { - - // detect uppercase <-> lowercase, base64, hex encoding, etc.: - // repl = reverse_transform(TYPE, pattern); - // } - // } - // } - // not 100% but would have a chance to be detected - - // fprintf(stderr, - // "Encode: %llx->%llx into %llx(<-%llx) at idx=%u " - // "taint_len=%u shape=%u attr=%u\n", - // o_pattern, pattern, repl, changed_val, idx, taint_len, - // h->shape + 1, attr); - u64 *buf_64 = (u64 *)&buf[idx]; u32 *buf_32 = (u32 *)&buf[idx]; u16 *buf_16 = (u16 *)&buf[idx]; @@ -559,6 +679,12 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u32 its_len = MIN(len - idx, taint_len); + // fprintf(stderr, + // "Encode: %llx->%llx into %llx(<-%llx) at idx=%u " + // "taint_len=%u shape=%u attr=%u\n", + // o_pattern, pattern, repl, changed_val, idx, taint_len, + // h->shape + 1, attr); + #ifdef TRANSFORM // reverse atoi()/strnu?toll() is expensive, so we only to it in lvl 3 if (lvl & LVL3) { @@ -1581,71 +1707,215 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, #ifndef COMBINE (void)(cbuf); #endif +#ifndef TRANSFORM + (void)(changed_val); +#endif - u32 i = 0; + u8 save[40]; + u32 saved_idx = idx, pre, from = 0, to = 0, i; u32 its_len = MIN((u32)32, len - idx); its_len = MIN(its_len, taint_len); - u8 save[32]; - memcpy(save, &buf[idx], its_len); + u32 saved_its_len = its_len; - if (lvl == LVL1) { + if (lvl & LVL3) { - for (i = 0; i < its_len; ++i) { + u32 max_to = MIN(4U, idx); + if (!(lvl & LVL1) && max_to) { from = 1; } + to = max_to; - if ((pattern[i] != buf[idx + i] && o_pattern[i] != orig_buf[idx + i]) || - *status == 1) { + } - break; + memcpy(save, &buf[saved_idx - to], its_len + to); - } +#ifdef _DEBUG + fprintf(stderr, "RTN TRANSFORM idx=%u lvl=%02x", idx, lvl); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", orig_buf[idx + j]); + fprintf(stderr, " -> "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", o_pattern[j]); + fprintf(stderr, " <= "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", repl[j]); + fprintf(stderr, "\n"); + fprintf(stderr, " "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", buf[idx + j]); + fprintf(stderr, " -> "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", pattern[j]); + fprintf(stderr, " <= "); + for (j = 0; j < 8; j++) + fprintf(stderr, "%02x", changed_val[j]); + fprintf(stderr, "\n"); +#endif - buf[idx + i] = repl[i]; + // Try to match the replace value up to 4 bytes before the current idx. + // This allows matching of eg.: + // if (memcmp(user_val, "TEST") == 0) + // if (memcmp(user_val, "TEST-VALUE") == 0) ... + // We only do this in lvl 3, otherwise we only do direct matching - if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + for (pre = from; pre <= to; pre++) { + + if (*status != 1 && (!pre || !memcmp(buf + saved_idx - pre, repl, pre))) { + + idx = saved_idx - pre; + its_len = saved_its_len + pre; + + for (i = 0; i < its_len; ++i) { + + if ((pattern[i] != buf[idx + i] && o_pattern[i] != orig_buf[idx + i]) || + *status == 1) { + + break; + + } + + buf[idx + i] = repl[i]; + + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } #ifdef COMBINE - if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } + if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } #endif + } + + memcpy(&buf[idx], save + to - pre, i); + } } +#ifdef TRANSFORM + if (*status == 1) return 0; if (lvl & LVL3) { - u8 toupper = 0, tolower = 0, xor = 0, arith = 0; - u8 xor_val[32], arith_val[32]; u32 j; + u32 toupper = 0, tolower = 0, xor = 0, arith = 0, tohex = 0, tob64 = 0; + u32 fromhex = 0, fromb64 = 0; + u32 from_0 = 0, from_x = 0, from_X = 0, from_slash = 0, from_lf = 0, + from_cr = 0, from_up = 0; + u32 to_0 = 0, to_x = 0, to_slash = 0, to_lf = 0, to_cr = 0, to_up = 0; + u8 xor_val[32], arith_val[32], tmp[48]; + + idx = saved_idx; + its_len = saved_its_len; + + memcpy(save, &buf[idx], its_len); -#ifdef _DEBUG - fprintf(stderr, "RTN TRANSFORM idx=%u ", idx); - for (j = 0; j < 8; j++) - fprintf(stderr, "%02x", orig_buf[idx + j]); - fprintf(stderr, " -> "); - for (j = 0; j < 8; j++) - fprintf(stderr, "%02x", o_pattern[j]); - fprintf(stderr, " <= "); - for (j = 0; j < 8; j++) - fprintf(stderr, "%02x", repl[j]); - fprintf(stderr, "\n"); - fprintf(stderr, " "); - for (j = 0; j < 8; j++) - fprintf(stderr, "%02x", buf[idx + j]); - fprintf(stderr, " -> "); - for (j = 0; j < 8; j++) - fprintf(stderr, "%02x", pattern[j]); - fprintf(stderr, " <= "); - for (j = 0; j < 8; j++) - fprintf(stderr, "%02x", changed_val[j]); - fprintf(stderr, "\n"); -#endif for (i = 0; i < its_len; ++i) { xor_val[i] = pattern[i] ^ buf[idx + i]; arith_val[i] = pattern[i] - buf[idx + i]; + if (i == 0) { + + if (orig_buf[idx] == '0') { + + from_0 = 1; + + } else if (orig_buf[idx] == '\\') { + + from_slash = 1; + + } + + if (repl[0] == '0') { + + to_0 = 1; + + } else if (repl[0] == '\\') { + + to_slash = 1; + + } + + } else if (i == 1) { + + if (orig_buf[idx + 1] == 'x') { + + from_x = 1; + + } else if (orig_buf[idx + 1] == 'X') { + + from_X = from_x = 1; + + } + + if (repl[1] == 'x' || repl[1] == 'X') { to_x = 1; } + + } else { + + if (orig_buf[idx + i] == '\n') { ++from_lf; } + if (orig_buf[idx + i] == '\r') { ++from_cr; } + if (repl[i] == '\n') { ++to_lf; } + if (repl[i] == '\r') { ++to_cr; } + + } + + if (i) { + + if (!(i % 2)) { + + if (i < 16 && is_hex(repl + (i << 1))) { + + tohex += 2; + + if (!to_up) { + + if (repl[i] >= 'A' && repl[i] <= 'F') + to_up = 1; + else if (repl[i] >= 'a' && repl[i] <= 'f') + to_up = 2; + if (repl[i - 1] >= 'A' && repl[i - 1] <= 'F') + to_up = 1; + else if (repl[i - 1] >= 'a' && repl[i - 1] <= 'f') + to_up = 2; + + } + + } + + if (len > idx + i && is_hex(orig_buf + idx + i)) { + + fromhex += 2; + + if (!from_up) { + + if (orig_buf[idx + i] >= 'A' && orig_buf[idx + i] <= 'F') + from_up = 1; + else if (orig_buf[idx + i] >= 'a' && orig_buf[idx + i] <= 'f') + from_up = 2; + if (orig_buf[idx + i - 1] >= 'A' && orig_buf[idx + i - 1] <= 'F') + from_up = 1; + else if (orig_buf[idx + i - 1] >= 'a' && + orig_buf[idx + i - 1] <= 'f') + from_up = 2; + + } + + } + + } + + if (!(i % 3) && i + to_lf + to_cr < 24) { + + if (is_base64(repl + i + to_lf + to_cr)) tob64 += 3; + + } + + if (!(i % 4) && i < 24) { + + if (is_base64(orig_buf + idx + i)) fromb64 += 4; + + } + + } + if ((o_pattern[i] ^ orig_buf[idx + i]) == xor_val[i] && xor_val[i]) { ++xor; @@ -1672,10 +1942,124 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } -#ifdef _DEBUG - fprintf(stderr, "RTN loop=%u %u %u %u %u (%u %u)\n", i, xor, arith, - tolower, toupper, arith_val[i], xor_val[i]); -#endif + // #ifdef _DEBUG + fprintf( + stderr, + "RTN loop=%u xor=%u arith=%u tolower=%u toupper=%u tohex=%u tob64=%u " + "fromhex=%u fromb64=%u to_0=%u to_slash=%u to_x=%u to_lf=%u to_cr=%u " + "from_0=%u from_slash=%u from_x=%u from_lf=%u from_cr=%u\n", + i, xor, arith, tolower, toupper, tohex, tob64, fromhex, fromb64, to_0, + to_slash, to_x, to_lf, to_cr, from_0, from_slash, from_x, from_lf, + from_cr); + // #endif + + // input is base64 and converted to binary? convert repl to base64! + if (i && !(i % 4) && i < 24 && fromb64 > i) { + + to_base64(repl, tmp, i); + memcpy(buf + idx, tmp, i); + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + fprintf(stderr, "RTN ATTEMPT fromb64 %u result %u\n", fromb64, *status); + + } + + // input is converted to base64? decode repl with base64! + if (i && !(i % 3) && i < 24 && tob64 > i) { + + u32 olen = from_base64(repl, tmp, i); + memcpy(buf + idx, tmp, olen); + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + fprintf(stderr, "RTN ATTEMPT tob64 %u result %u\n", tob64, *status); + + } + + // input is converted to hex? convert repl to binary! + if (i && !(i % 2) && i < 16 && tohex && tohex > i) { + + u32 off; + if (to_slash + to_x + to_0 == 2) { + + off = 2; + + } else { + + off = 0; + + } + + for (j = 0; j < i / 2; j++) + tmp[j] = (hex_table[repl[off + (j << 1)] - '0'] << 4) + + hex_table[repl[off + (j << 1) + 1] - '0']; + + memcpy(buf + idx, tmp, i / 2); + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + fprintf(stderr, "RTN ATTEMPT tohex %u result %u\n", tohex, *status); + + } + + // input is hex and converted to binary? convert repl to hex! + if (i && !(i % 2) && i < 16 && fromhex && + fromhex + from_slash + from_x + from_0 > i) { + + u8 off = 0; + if (from_slash && from_x) { + + tmp[0] = '\\'; + if (from_X) { + + tmp[1] = 'X'; + + } else { + + tmp[1] = 'x'; + + } + + off = 2; + + } else if (from_0 && from_x) { + + tmp[0] = '0'; + if (from_X) { + + tmp[1] = 'X'; + + } else { + + tmp[1] = 'x'; + + } + + off = 2; + + } + + if (to_up == 1) { + + for (j = 0; j <= i; j++) { + + tmp[off + (j << 1)] = hex_table_up[repl[j] >> 4]; + tmp[off + (j << 1) + 1] = hex_table_up[repl[j] % 16]; + + } + + } else { + + for (j = 0; j <= i; j++) { + + tmp[off + (j << 1)] = hex_table_low[repl[j] >> 4]; + tmp[off + (j << 1) + 1] = hex_table_low[repl[j] % 16]; + + } + + } + + memcpy(buf + idx, tmp, (i << 1) + off); + if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } + fprintf(stderr, "RTN ATTEMPT fromhex %u result %u\n", fromhex, *status); + memcpy(buf + idx, save, (i << 1) + off); + + } if (xor > i) { @@ -1715,9 +2099,9 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } -#ifdef COMBINE + #ifdef COMBINE if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } -#endif + #endif if ((i >= xor&&i >= arith &&i >= tolower &&i >= toupper) || repl[i] != changed_val[i] || *status == 1) { @@ -1728,9 +2112,11 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } + memcpy(&buf[idx], save, i); + } - memcpy(&buf[idx], save, i); +#endif return 0; -- cgit 1.4.1 From 5174eb6741f1f08e1ac020d4413d90fba50b1819 Mon Sep 17 00:00:00 2001 From: vishesh-sharma-123 <77101111+vishesh-sharma-123@users.noreply.github.com> Date: Wed, 20 Jan 2021 22:31:21 +0530 Subject: Update README.md typo and correction in link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 204eaf92..4aeb0699 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ behaviours and defaults: 2. [How to compile and install afl++](#building-and-installing-afl) 3. [How to fuzz a target](#how-to-fuzz-with-afl) 4. [Fuzzing binary-only targets](#fuzzing-binary-only-targets) - 5. [Good examples and writeups of afl++ usages](#-examples-and-writeups) + 5. [Good examples and writeups of afl++ usages](#good-examples-and-writeups) 6. [Branches](#branches) 7. [Want to help?](#help-wanted) 8. [Detailed help and description of afl++](#challenges-of-guided-fuzzing) -- cgit 1.4.1 From d20a50a41307a7af346e69c93c8b30a3f369a2d4 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 20 Jan 2021 20:59:17 +0100 Subject: hex en/decode works now --- instrumentation/afl-compiler-rt.o.c | 18 ++++---- src/afl-forkserver.c | 8 +++- src/afl-fuzz-redqueen.c | 85 ++++++++++++++++++++----------------- 3 files changed, 60 insertions(+), 51 deletions(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index a290f110..de01cb69 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1546,15 +1546,15 @@ static int area_is_mapped(void *ptr, size_t len) { void __cmplog_rtn_hook(u8 *ptr1, u8 *ptr2) { /* - u32 i; - if (!area_is_mapped(ptr1, 32) || !area_is_mapped(ptr2, 32)) return; - fprintf(stderr, "rtn arg0="); - for (i = 0; i < 8; i++) - fprintf(stderr, "%02x", ptr1[i]); - fprintf(stderr, " arg1="); - for (i = 0; i < 8; i++) - fprintf(stderr, "%02x", ptr2[i]); - fprintf(stderr, "\n"); + u32 i; + if (!area_is_mapped(ptr1, 32) || !area_is_mapped(ptr2, 32)) return; + fprintf(stderr, "rtn arg0="); + for (i = 0; i < 8; i++) + fprintf(stderr, "%02x", ptr1[i]); + fprintf(stderr, " arg1="); + for (i = 0; i < 8; i++) + fprintf(stderr, "%02x", ptr2[i]); + fprintf(stderr, "\n"); */ if (unlikely(!__afl_cmp_map)) return; diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c index c1b3d02f..50e4139b 100644 --- a/src/afl-forkserver.c +++ b/src/afl-forkserver.c @@ -59,8 +59,6 @@ static list_t fsrv_list = {.element_prealloc_count = 0}; static void fsrv_exec_child(afl_forkserver_t *fsrv, char **argv) { if (fsrv->qemu_mode) { setenv("AFL_DISABLE_LLVM_INSTRUMENTATION", "1", 0); } - - unsetenv(CMPLOG_SHM_ENV_VAR); // we do not want that in non-cmplog fsrv execv(fsrv->target_path, argv); @@ -398,6 +396,12 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, struct rlimit r; + if (!fsrv->cmplog_binary && fsrv->qemu_mode == false) { + + unsetenv(CMPLOG_SHM_ENV_VAR); // we do not want that in non-cmplog fsrv + + } + /* Umpf. On OpenBSD, the default fd limit for root users is set to soft 128. Let's try to fix that... */ if (!getrlimit(RLIMIT_NOFILE, &r) && r.rlim_cur < FORKSRV_FD + 2) { diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 7ac0290a..96a27f66 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -30,9 +30,9 @@ //#define _DEBUG #define COMBINE -//#define CMPLOG_INTROSPECTION +#define CMPLOG_INTROSPECTION //#define ARITHMETIC_LESSER_GREATER -//#define TRANSFORM +#define TRANSFORM // CMP attribute enum enum { @@ -579,6 +579,7 @@ static int is_base64(const char *str) { static u8 base64_encode_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static u8 base64_decode_table[] = { + 62, 0, 0, 0, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, @@ -1712,7 +1713,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, #endif u8 save[40]; - u32 saved_idx = idx, pre, from = 0, to = 0, i; + u32 saved_idx = idx, pre, from = 0, to = 0, i, j; u32 its_len = MIN((u32)32, len - idx); its_len = MIN(its_len, taint_len); u32 saved_its_len = its_len; @@ -1728,7 +1729,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, memcpy(save, &buf[saved_idx - to], its_len + to); #ifdef _DEBUG - fprintf(stderr, "RTN TRANSFORM idx=%u lvl=%02x", idx, lvl); + fprintf(stderr, "RTN T idx=%u lvl=%02x ", idx, lvl); for (j = 0; j < 8; j++) fprintf(stderr, "%02x", orig_buf[idx + j]); fprintf(stderr, " -> "); @@ -1738,7 +1739,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, for (j = 0; j < 8; j++) fprintf(stderr, "%02x", repl[j]); fprintf(stderr, "\n"); - fprintf(stderr, " "); + fprintf(stderr, " "); for (j = 0; j < 8; j++) fprintf(stderr, "%02x", buf[idx + j]); fprintf(stderr, " -> "); @@ -1794,7 +1795,6 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if (lvl & LVL3) { - u32 j; u32 toupper = 0, tolower = 0, xor = 0, arith = 0, tohex = 0, tob64 = 0; u32 fromhex = 0, fromb64 = 0; u32 from_0 = 0, from_x = 0, from_X = 0, from_slash = 0, from_lf = 0, @@ -1857,28 +1857,28 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - if (i) { + if (i < 16 && is_hex(repl + (i << 1))) { - if (!(i % 2)) { + ++tohex; - if (i < 16 && is_hex(repl + (i << 1))) { + if (!to_up) { - tohex += 2; + if (repl[i << 1] >= 'A' && repl[i << 1] <= 'F') + to_up = 1; + else if (repl[i << 1] >= 'a' && repl[i << 1] <= 'f') + to_up = 2; + if (repl[(i << 1) + 1] >= 'A' && repl[(i << 1) + 1] <= 'F') + to_up = 1; + else if (repl[(i << 1) + 1] >= 'a' && repl[(i << 1) + 1] <= 'f') + to_up = 2; - if (!to_up) { + } - if (repl[i] >= 'A' && repl[i] <= 'F') - to_up = 1; - else if (repl[i] >= 'a' && repl[i] <= 'f') - to_up = 2; - if (repl[i - 1] >= 'A' && repl[i - 1] <= 'F') - to_up = 1; - else if (repl[i - 1] >= 'a' && repl[i - 1] <= 'f') - to_up = 2; + } - } + if (i) { - } + if ((i % 2)) { if (len > idx + i && is_hex(orig_buf + idx + i)) { @@ -1902,13 +1902,13 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - if (!(i % 3) && i + to_lf + to_cr < 24) { + if (i % 3 == 2 && i + to_lf + to_cr < 24) { if (is_base64(repl + i + to_lf + to_cr)) tob64 += 3; } - if (!(i % 4) && i < 24) { + if (i % 4 == 3 && i < 24) { if (is_base64(orig_buf + idx + i)) fromb64 += 4; @@ -1956,25 +1956,26 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, // input is base64 and converted to binary? convert repl to base64! if (i && !(i % 4) && i < 24 && fromb64 > i) { - to_base64(repl, tmp, i); - memcpy(buf + idx, tmp, i); + to_base64(repl, tmp, i + 1); + memcpy(buf + idx, tmp, i + 1); if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - fprintf(stderr, "RTN ATTEMPT fromb64 %u result %u\n", fromb64, *status); + // fprintf(stderr, "RTN ATTEMPT fromb64 %u result %u\n", fromb64, + // *status); } // input is converted to base64? decode repl with base64! if (i && !(i % 3) && i < 24 && tob64 > i) { - u32 olen = from_base64(repl, tmp, i); + u32 olen = from_base64(repl, tmp, i + 1); memcpy(buf + idx, tmp, olen); if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - fprintf(stderr, "RTN ATTEMPT tob64 %u result %u\n", tob64, *status); + // fprintf(stderr, "RTN ATTEMPT tob64 %u result %u\n", tob64, *status); } // input is converted to hex? convert repl to binary! - if (i && !(i % 2) && i < 16 && tohex && tohex > i) { + if (i < 16 && tohex > i) { u32 off; if (to_slash + to_x + to_0 == 2) { @@ -1987,18 +1988,18 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - for (j = 0; j < i / 2; j++) + for (j = 0; j <= i; j++) tmp[j] = (hex_table[repl[off + (j << 1)] - '0'] << 4) + hex_table[repl[off + (j << 1) + 1] - '0']; - memcpy(buf + idx, tmp, i / 2); + memcpy(buf + idx, tmp, i + 1); if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - fprintf(stderr, "RTN ATTEMPT tohex %u result %u\n", tohex, *status); + // fprintf(stderr, "RTN ATTEMPT tohex %u result %u\n", tohex, *status); } // input is hex and converted to binary? convert repl to hex! - if (i && !(i % 2) && i < 16 && fromhex && + if (i && (i % 2) && i < 16 && fromhex && fromhex + from_slash + from_x + from_0 > i) { u8 off = 0; @@ -2036,7 +2037,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if (to_up == 1) { - for (j = 0; j <= i; j++) { + for (j = 0; j <= (i >> 1); j++) { tmp[off + (j << 1)] = hex_table_up[repl[j] >> 4]; tmp[off + (j << 1) + 1] = hex_table_up[repl[j] % 16]; @@ -2045,7 +2046,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } else { - for (j = 0; j <= i; j++) { + for (j = 0; j <= (i >> 1); j++) { tmp[off + (j << 1)] = hex_table_low[repl[j] >> 4]; tmp[off + (j << 1) + 1] = hex_table_low[repl[j] % 16]; @@ -2054,10 +2055,11 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - memcpy(buf + idx, tmp, (i << 1) + off); + memcpy(buf + idx, tmp, i + 1 + off); if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - fprintf(stderr, "RTN ATTEMPT fromhex %u result %u\n", fromhex, *status); - memcpy(buf + idx, save, (i << 1) + off); + // fprintf(stderr, "RTN ATTEMPT fromhex %u result %u\n", fromhex, + // *status); + memcpy(buf + idx + i, save + i, i + 1 + off); } @@ -2100,10 +2102,13 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } #ifdef COMBINE - if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } + if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i + 1); } #endif - if ((i >= xor&&i >= arith &&i >= tolower &&i >= toupper) || + if ((i >= 7 && + (i >= xor&&i >= arith &&i >= tolower &&i >= toupper &&i > tohex &&i > + (1 + fromhex + from_0 + from_x + from_slash) && + i > tob64 + 3 && i > fromb64 + 3)) || repl[i] != changed_val[i] || *status == 1) { break; -- cgit 1.4.1 From cf5fee7c526ff104cc44b0029aad4395342fa4f2 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 20 Jan 2021 21:03:55 +0100 Subject: remove debug output --- src/afl-fuzz-redqueen.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 96a27f66..f958bb71 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -819,7 +819,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - if (*status == 1) { fprintf(stderr, "FOUND!\n"); } + // if (*status == 1) { fprintf(stderr, "FOUND!\n"); } } @@ -847,7 +847,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - if (*status == 1) { fprintf(stderr, "FOUND!\n"); } + // if (*status == 1) { fprintf(stderr, "FOUND!\n"); } } @@ -894,7 +894,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - if (*status == 1) { fprintf(stderr, "FOUND!\n"); } + // if (*status == 1) { fprintf(stderr, "FOUND!\n"); } } @@ -941,7 +941,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } - if (*status == 1) { fprintf(stderr, "FOUND!\n"); } + // if (*status == 1) { fprintf(stderr, "FOUND!\n"); } } @@ -1942,7 +1942,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - // #ifdef _DEBUG + #ifdef _DEBUG fprintf( stderr, "RTN loop=%u xor=%u arith=%u tolower=%u toupper=%u tohex=%u tob64=%u " @@ -1951,7 +1951,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, i, xor, arith, tolower, toupper, tohex, tob64, fromhex, fromb64, to_0, to_slash, to_x, to_lf, to_cr, from_0, from_slash, from_x, from_lf, from_cr); - // #endif + #endif // input is base64 and converted to binary? convert repl to base64! if (i && !(i % 4) && i < 24 && fromb64 > i) { -- cgit 1.4.1 From f7c93d741c09f5049e1da4b9d83acabbde104c46 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 03:52:46 +0100 Subject: base64 solving done --- src/afl-fuzz-redqueen.c | 79 +++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index f958bb71..8ffd39da 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -30,7 +30,7 @@ //#define _DEBUG #define COMBINE -#define CMPLOG_INTROSPECTION +//#define CMPLOG_INTROSPECTION //#define ARITHMETIC_LESSER_GREATER #define TRANSFORM @@ -564,6 +564,7 @@ static int is_base64(const char *str) { case 'a' ... 'z': case '+': case '/': + case '=': break; default: return 0; @@ -1797,9 +1798,8 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, u32 toupper = 0, tolower = 0, xor = 0, arith = 0, tohex = 0, tob64 = 0; u32 fromhex = 0, fromb64 = 0; - u32 from_0 = 0, from_x = 0, from_X = 0, from_slash = 0, from_lf = 0, - from_cr = 0, from_up = 0; - u32 to_0 = 0, to_x = 0, to_slash = 0, to_lf = 0, to_cr = 0, to_up = 0; + u32 from_0 = 0, from_x = 0, from_X = 0, from_slash = 0, from_up = 0; + u32 to_0 = 0, to_x = 0, to_slash = 0, to_up = 0; u8 xor_val[32], arith_val[32], tmp[48]; idx = saved_idx; @@ -1848,13 +1848,6 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if (repl[1] == 'x' || repl[1] == 'X') { to_x = 1; } - } else { - - if (orig_buf[idx + i] == '\n') { ++from_lf; } - if (orig_buf[idx + i] == '\r') { ++from_cr; } - if (repl[i] == '\n') { ++to_lf; } - if (repl[i] == '\r') { ++to_cr; } - } if (i < 16 && is_hex(repl + (i << 1))) { @@ -1876,43 +1869,39 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - if (i) { - - if ((i % 2)) { - - if (len > idx + i && is_hex(orig_buf + idx + i)) { + if ((i % 2)) { - fromhex += 2; + if (len > idx + i && is_hex(orig_buf + idx + i)) { - if (!from_up) { + fromhex += 2; - if (orig_buf[idx + i] >= 'A' && orig_buf[idx + i] <= 'F') - from_up = 1; - else if (orig_buf[idx + i] >= 'a' && orig_buf[idx + i] <= 'f') - from_up = 2; - if (orig_buf[idx + i - 1] >= 'A' && orig_buf[idx + i - 1] <= 'F') - from_up = 1; - else if (orig_buf[idx + i - 1] >= 'a' && - orig_buf[idx + i - 1] <= 'f') - from_up = 2; + if (!from_up) { - } + if (orig_buf[idx + i] >= 'A' && orig_buf[idx + i] <= 'F') + from_up = 1; + else if (orig_buf[idx + i] >= 'a' && orig_buf[idx + i] <= 'f') + from_up = 2; + if (orig_buf[idx + i - 1] >= 'A' && orig_buf[idx + i - 1] <= 'F') + from_up = 1; + else if (orig_buf[idx + i - 1] >= 'a' && + orig_buf[idx + i - 1] <= 'f') + from_up = 2; } } - if (i % 3 == 2 && i + to_lf + to_cr < 24) { + } - if (is_base64(repl + i + to_lf + to_cr)) tob64 += 3; + if (i % 3 == 2 && i < 24) { - } + if (is_base64(repl + ((i / 3) << 2))) tob64 += 3; - if (i % 4 == 3 && i < 24) { + } - if (is_base64(orig_buf + idx + i)) fromb64 += 4; + if (i % 4 == 3 && i < 24) { - } + if (is_base64(orig_buf + idx + i - 3)) fromb64 += 4; } @@ -1943,18 +1932,17 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } #ifdef _DEBUG - fprintf( - stderr, - "RTN loop=%u xor=%u arith=%u tolower=%u toupper=%u tohex=%u tob64=%u " - "fromhex=%u fromb64=%u to_0=%u to_slash=%u to_x=%u to_lf=%u to_cr=%u " - "from_0=%u from_slash=%u from_x=%u from_lf=%u from_cr=%u\n", - i, xor, arith, tolower, toupper, tohex, tob64, fromhex, fromb64, to_0, - to_slash, to_x, to_lf, to_cr, from_0, from_slash, from_x, from_lf, - from_cr); + fprintf(stderr, + "RTN idx=%u loop=%u xor=%u arith=%u tolower=%u toupper=%u " + "tohex=%u tob64=%u " + "fromhex=%u fromb64=%u to_0=%u to_slash=%u to_x=%u " + "from_0=%u from_slash=%u from_x=%u\n", + idx, i, xor, arith, tolower, toupper, tohex, tob64, fromhex, + fromb64, to_0, to_slash, to_x, from_0, from_slash, from_x); #endif // input is base64 and converted to binary? convert repl to base64! - if (i && !(i % 4) && i < 24 && fromb64 > i) { + if ((i % 4) == 3 && i < 24 && fromb64 > i) { to_base64(repl, tmp, i + 1); memcpy(buf + idx, tmp, i + 1); @@ -1965,12 +1953,13 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } // input is converted to base64? decode repl with base64! - if (i && !(i % 3) && i < 24 && tob64 > i) { + if ((i % 3) == 2 && i < 24 && tob64 > i) { u32 olen = from_base64(repl, tmp, i + 1); memcpy(buf + idx, tmp, olen); if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - // fprintf(stderr, "RTN ATTEMPT tob64 %u result %u\n", tob64, *status); + // fprintf(stderr, "RTN ATTEMPT tob64 %u idx=%u result %u\n", tob64, + // idx, *status); } -- cgit 1.4.1 From ba47bee25207436db8e2b98ef2d02801967980ca Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 11:41:25 +0100 Subject: pre merge changes --- src/afl-fuzz-redqueen.c | 57 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 8ffd39da..d631332a 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -29,10 +29,11 @@ #include "cmplog.h" //#define _DEBUG -#define COMBINE +//#define COMBINE //#define CMPLOG_INTROSPECTION //#define ARITHMETIC_LESSER_GREATER -#define TRANSFORM +//#define TRANSFORM +//#define TRANSFORM_BASE64 // CMP attribute enum enum { @@ -51,9 +52,9 @@ enum { // CMPLOG LVL enum { - LVL1 = 1, - LVL2 = 2, - LVL3 = 4 + LVL1 = 1, // Integer solving + LVL2 = 2, // FP solving + LVL3 = 4 // expensive tranformations }; @@ -238,6 +239,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 start_time = get_cur_time(); #endif + u32 screen_update = 1000000 / afl->queue_cur->exec_us; u64 orig_hit_cnt, new_hit_cnt, exec_cksum; orig_hit_cnt = afl->queued_paths + afl->unique_crashes; @@ -315,7 +317,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, } - ++afl->stage_cur; + if (++afl->stage_cur % screen_update) { show_stats(afl); }; } @@ -550,6 +552,7 @@ static int is_hex(const char *str) { } + #ifdef TRANSFORM_BASE64 // tests 4 bytes at location static int is_base64(const char *str) { @@ -662,6 +665,8 @@ static void to_base64(u8 *src, u8 *dst, u32 dst_len) { } + #endif + #endif static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, @@ -1728,6 +1733,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } memcpy(save, &buf[saved_idx - to], its_len + to); + (void)(j); #ifdef _DEBUG fprintf(stderr, "RTN T idx=%u lvl=%02x ", idx, lvl); @@ -1796,8 +1802,10 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if (lvl & LVL3) { - u32 toupper = 0, tolower = 0, xor = 0, arith = 0, tohex = 0, tob64 = 0; - u32 fromhex = 0, fromb64 = 0; + u32 toupper = 0, tolower = 0, xor = 0, arith = 0, tohex = 0, fromhex = 0; + #ifdef TRANSFORM_BASE64 + u32 tob64 = 0, fromb64 = 0; + #endif u32 from_0 = 0, from_x = 0, from_X = 0, from_slash = 0, from_up = 0; u32 to_0 = 0, to_x = 0, to_slash = 0, to_up = 0; u8 xor_val[32], arith_val[32], tmp[48]; @@ -1893,6 +1901,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } + #ifdef TRANSFORM_BASE64 if (i % 3 == 2 && i < 24) { if (is_base64(repl + ((i / 3) << 2))) tob64 += 3; @@ -1905,6 +1914,8 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } + #endif + if ((o_pattern[i] ^ orig_buf[idx + i]) == xor_val[i] && xor_val[i]) { ++xor; @@ -1934,13 +1945,17 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, #ifdef _DEBUG fprintf(stderr, "RTN idx=%u loop=%u xor=%u arith=%u tolower=%u toupper=%u " - "tohex=%u tob64=%u " - "fromhex=%u fromb64=%u to_0=%u to_slash=%u to_x=%u " + "tohex=%u fromhex=%u to_0=%u to_slash=%u to_x=%u " "from_0=%u from_slash=%u from_x=%u\n", - idx, i, xor, arith, tolower, toupper, tohex, tob64, fromhex, - fromb64, to_0, to_slash, to_x, from_0, from_slash, from_x); + idx, i, xor, arith, tolower, toupper, tohex, fromhex, to_0, + to_slash, to_x, from_0, from_slash, from_x); + #ifdef TRANSFORM_BASE64 + fprintf(stderr, "RTN idx=%u loop=%u tob64=%u from64=%u\n", tob64, + fromb64); + #endif #endif + #ifdef TRANSFORM_BASE64 // input is base64 and converted to binary? convert repl to base64! if ((i % 4) == 3 && i < 24 && fromb64 > i) { @@ -1963,6 +1978,8 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } + #endif + // input is converted to hex? convert repl to binary! if (i < 16 && tohex > i) { @@ -2096,8 +2113,11 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if ((i >= 7 && (i >= xor&&i >= arith &&i >= tolower &&i >= toupper &&i > tohex &&i > - (1 + fromhex + from_0 + from_x + from_slash) && - i > tob64 + 3 && i > fromb64 + 3)) || + (fromhex + from_0 + from_x + from_slash + 1) + #ifdef TRANSFORM_BASE64 + && i > tob64 + 3 && i > fromb64 + 4 + #endif + )) || repl[i] != changed_val[i] || *status == 1) { break; @@ -2348,6 +2368,8 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { u64 orig_hit_cnt, new_hit_cnt; u64 orig_execs = afl->fsrv.total_execs; orig_hit_cnt = afl->queued_paths + afl->unique_crashes; + u64 screen_update = 1000000 / afl->queue_cur->exec_us, + execs = afl->fsrv.total_execs; afl->stage_name = "input-to-state"; afl->stage_short = "its"; @@ -2440,6 +2462,13 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } + if (afl->fsrv.total_execs - execs > screen_update) { + + execs = afl->fsrv.total_execs; + show_stats(afl); + + } + } r = 0; -- cgit 1.4.1 From 0d472adef0cbe68cec128b7b15e508f0bb05455d Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 12:02:50 +0100 Subject: temp conflict resolve --- src/afl-cc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index d44f069a..2ce986c7 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -856,8 +856,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_OFF()=__afl_coverage_off()"; cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_DISCARD()=__afl_coverage_discard()"; - cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_ABORT()=__afl_coverage_abort()"; - + cc_params[cc_par_cnt++] = "-D__AFL_COVERAGE_SKIP()=__afl_coverage_skip()"; cc_params[cc_par_cnt++] = "-D__AFL_FUZZ_TESTCASE_BUF=(__afl_fuzz_ptr ? __afl_fuzz_ptr : " "__afl_fuzz_alt_ptr)"; -- cgit 1.4.1 From 1ee0946f692927eaaed9c8db1d006d8eb38631c3 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 12:11:12 +0100 Subject: update changelog --- docs/Changelog.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 60f09ca5..daae7c47 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -11,22 +11,27 @@ sending a mail to . ### Version ++3.01a (dev) - Mac OS ARM64 support - - New selective instrumentation option with __AFL_COVERAGE_... commands + - Android support fixed and updated by Joey Jiaojg - thanks! + - New selective instrumentation option with __AFL_COVERAGE_* commands to be placed in the source code. Check out instrumentation/README.instrument_list.md - afl-fuzz + - upgraded cmplog/redqueen: solving for floating point, solving + transformations (e.g. toupper, tolower, to/from hex, xor, + arithmetics, etc.). this is costly hence new command line option + -l that sets the intensity (values 1 to 3). recommended is 1 or 2. - fix crash for very, very fast targets+systems (thanks to mhlakhani for reporting) - if determinstic mode is active (-D, or -M without -d) then we sync after every queue entry as this can take very long time otherwise - better detection if a target needs a large shared map - - switched to a faster RNG + - switched to an even faster RNG - added hghwng's patch for faster trace map analysis - afl-cc - allow instrumenting LLVMFuzzerTestOneInput - fixed endless loop for allow/blocklist lines starting with a comment (thanks to Zherya for reporting) - - cmplog/redqueen now also tracks floats/doubles + - cmplog/redqueen now also tracks floating point, _ExtInt() + 128bit - added AFL_LLVM_INSTRUMENT option NATIVE for native clang pc-guard support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang @@ -35,7 +40,7 @@ sending a mail to . already building with all cores, the gcc plugin needs only one. - added dummy Makefile to instrumentation/ - Updated utils/afl_frida to be 5% faster - - Added AFL_KILL_SIGNAL env variable for custom targets (thanks @v-p-b) + - Added AFL_KILL_SIGNAL env variable (thanks @v-p-b) ### Version ++3.00c (release) - llvm_mode/ and gcc_plugin/ moved to instrumentation/ -- cgit 1.4.1 From 3903dac1f5c0ce40965d40c956d79e46463654ea Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 14:17:08 +0100 Subject: fix gcc plugin test --- test/test-gcc-plugin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-gcc-plugin.sh b/test/test-gcc-plugin.sh index 0157d89f..58000e92 100755 --- a/test/test-gcc-plugin.sh +++ b/test/test-gcc-plugin.sh @@ -19,14 +19,14 @@ test -e ../afl-gcc-fast -a -e ../afl-compiler-rt.o && { } || { $ECHO "$GREEN[+] gcc_plugin instrumentation present and working correctly" TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain.gccpi 2>&1 | grep Captur | awk '{print$3}'` - test "$TUPLES" -gt 2 -a "$TUPLES" -lt 9 && { + test "$TUPLES" -gt 1 -a "$TUPLES" -lt 9 && { $ECHO "$GREEN[+] gcc_plugin run reported $TUPLES instrumented locations which is fine" } || { $ECHO "$RED[!] gcc_plugin instrumentation produces a weird numbers: $TUPLES" $ECHO "$YELLOW[-] this is a known issue in gcc, not afl++. It is not flagged as an error because travis builds would all fail otherwise :-(" #CODE=1 } - test "$TUPLES" -lt 3 && SKIP=1 + test "$TUPLES" -lt 2 && SKIP=1 true } } || { -- cgit 1.4.1 From e8c1b43a3de7ae3d173c749c3be4e58a95d3372b Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 15:24:34 +0100 Subject: fix docs --- docs/env_variables.md | 2 +- src/afl-fuzz.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/env_variables.md b/docs/env_variables.md index 26128b01..baf69e6a 100644 --- a/docs/env_variables.md +++ b/docs/env_variables.md @@ -519,7 +519,7 @@ The corpus minimization script offers very little customization: a modest security risk on multi-user systems with rogue users, but should be safe on dedicated fuzzing boxes. -# #6) Settings for afl-tmin +## 7) Settings for afl-tmin Virtually nothing to play with. Well, in QEMU mode (`-Q`), `AFL_PATH` will be searched for afl-qemu-trace. In addition to this, `TMPDIR` may be used if a diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 95bc0694..9a8159bd 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -123,7 +123,7 @@ static void usage(u8 *argv0, int more_help) { "it.\n" " if using QEMU, just use -c 0.\n" " -l cmplog_level - set the complexity/intensivity of CmpLog.\n" - " Values: 1 (default), 2 (intensive) and 3 (heavy)\n\n" + " Values: 1 (integer+string), 2 (+FP) and 3 (+transform)\n\n" "Fuzzing behavior settings:\n" " -Z - sequential queue selection instead of weighted " -- cgit 1.4.1 From 43edd969d8edeac874e28bf535e56a10867a2410 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Thu, 21 Jan 2021 16:57:19 +0100 Subject: fix qemu x86 cmplog issue --- qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/qemuafl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index 9d6d7dba..a3db2bfa 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -6ea7398ee3 +62928c65b7 diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index 21ff3438..62928c65 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit 21ff34383764a8c6f66509b3b8d5282468c721e1 +Subproject commit 62928c65b75f93926c00361a595362e00cc025ff -- cgit 1.4.1 From b850951c726258053c5635d6597704cf346fe3c4 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 17:15:14 +0100 Subject: code format and not setting sanitizers if debug and settings present --- src/afl-cc.c | 8 ++++---- src/afl-forkserver.c | 53 +++++++++++++++++++++++++++------------------------ src/afl-fuzz-bitmap.c | 6 +----- src/afl-fuzz-stats.c | 2 ++ src/afl-fuzz.c | 12 ++++++++---- src/afl-ld-lto.c | 2 +- 6 files changed, 44 insertions(+), 39 deletions(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index b0b11f48..8e7af0f9 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -586,9 +586,9 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (instrument_mode == INSTRUMENT_PCGUARD) { #if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0) -#ifdef __ANDROID__ + #ifdef __ANDROID__ cc_params[cc_par_cnt++] = "-fsanitize-coverage=trace-pc-guard"; -#else + #else if (have_instr_list) { if (!be_quiet) @@ -608,7 +608,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { } -#endif + #endif #else #if LLVM_MAJOR >= 4 if (!be_quiet) @@ -1036,7 +1036,7 @@ int main(int argc, char **argv, char **envp) { #endif #ifdef __ANDROID__ - have_llvm = 1; + have_llvm = 1; #endif if ((ptr = find_object("afl-gcc-pass.so", argv[0])) != NULL) { diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c index 50e4139b..d4484de7 100644 --- a/src/afl-forkserver.c +++ b/src/afl-forkserver.c @@ -484,38 +484,41 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, /* Set sane defaults for ASAN if nothing else specified. */ - setenv("ASAN_OPTIONS", - "abort_on_error=1:" - "detect_leaks=0:" - "malloc_context_size=0:" - "symbolize=0:" - "allocator_may_return_null=1:" - "handle_segv=0:" - "handle_sigbus=0:" - "handle_abort=0:" - "handle_sigfpe=0:" - "handle_sigill=0", - 0); + if (!afl->debug || !getenv("ASAN_OPTIONS")) + setenv("ASAN_OPTIONS", + "abort_on_error=1:" + "detect_leaks=0:" + "malloc_context_size=0:" + "symbolize=0:" + "allocator_may_return_null=1:" + "handle_segv=0:" + "handle_sigbus=0:" + "handle_abort=0:" + "handle_sigfpe=0:" + "handle_sigill=0", + 0); /* Set sane defaults for UBSAN if nothing else specified. */ - setenv("UBSAN_OPTIONS", - "halt_on_error=1:" - "abort_on_error=1:" - "malloc_context_size=0:" - "allocator_may_return_null=1:" - "symbolize=0:" - "handle_segv=0:" - "handle_sigbus=0:" - "handle_abort=0:" - "handle_sigfpe=0:" - "handle_sigill=0", - 0); + if (!afl->debug || !getenv("UBSAN_OPTIONS")) + setenv("UBSAN_OPTIONS", + "halt_on_error=1:" + "abort_on_error=1:" + "malloc_context_size=0:" + "allocator_may_return_null=1:" + "symbolize=0:" + "handle_segv=0:" + "handle_sigbus=0:" + "handle_abort=0:" + "handle_sigfpe=0:" + "handle_sigill=0", + 0); /* MSAN is tricky, because it doesn't support abort_on_error=1 at this point. So, we do this in a very hacky way. */ - setenv("MSAN_OPTIONS", + if (!afl->debug || !getenv("MSAN_OPTIONS")) + setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":" "symbolize=0:" "abort_on_error=1:" diff --git a/src/afl-fuzz-bitmap.c b/src/afl-fuzz-bitmap.c index 586f3990..0c4a114e 100644 --- a/src/afl-fuzz-bitmap.c +++ b/src/afl-fuzz-bitmap.c @@ -700,11 +700,7 @@ save_if_interesting(afl_state_t *afl, void *mem, u32 len, u8 fault) { if (likely(!afl->non_instrumented_mode)) { - if (!classified) { - - classify_counts(&afl->fsrv); - - } + if (!classified) { classify_counts(&afl->fsrv); } simplify_trace(afl, afl->fsrv.trace_bits); diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index e67bace9..82da8176 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -60,8 +60,10 @@ void write_setup_file(afl_state_t *afl, u32 argc, char **argv) { if (i) fprintf(f, " "); #ifdef __ANDROID__ if (memchr(argv[i], '\'', sizeof(argv[i]))) { + #else if (index(argv[i], '\'')) { + #endif fprintf(f, "'"); diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 9a8159bd..2a59bbe4 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -123,7 +123,8 @@ static void usage(u8 *argv0, int more_help) { "it.\n" " if using QEMU, just use -c 0.\n" " -l cmplog_level - set the complexity/intensivity of CmpLog.\n" - " Values: 1 (integer+string), 2 (+FP) and 3 (+transform)\n\n" + " Values: 1 (integer+string), 2 (+FP) and 3 " + "(+transform)\n\n" "Fuzzing behavior settings:\n" " -Z - sequential queue selection instead of weighted " @@ -584,7 +585,8 @@ int main(int argc, char **argv_orig, char **envp) { if (afl->timeout_given) { FATAL("Multiple -t options not supported"); } - if (!optarg || sscanf(optarg, "%u%c", &afl->fsrv.exec_tmout, &suffix) < 1 || + if (!optarg || + sscanf(optarg, "%u%c", &afl->fsrv.exec_tmout, &suffix) < 1 || optarg[0] == '-') { FATAL("Bad syntax used for -t"); @@ -766,7 +768,8 @@ int main(int argc, char **argv_orig, char **envp) { case 'V': { afl->most_time_key = 1; - if (!optarg || sscanf(optarg, "%llu", &afl->most_time) < 1 || optarg[0] == '-') { + if (!optarg || sscanf(optarg, "%llu", &afl->most_time) < 1 || + optarg[0] == '-') { FATAL("Bad syntax used for -V"); @@ -777,7 +780,8 @@ int main(int argc, char **argv_orig, char **envp) { case 'E': { afl->most_execs_key = 1; - if (!optarg || sscanf(optarg, "%llu", &afl->most_execs) < 1 || optarg[0] == '-') { + if (!optarg || sscanf(optarg, "%llu", &afl->most_execs) < 1 || + optarg[0] == '-') { FATAL("Bad syntax used for -E"); diff --git a/src/afl-ld-lto.c b/src/afl-ld-lto.c index 0671d1c4..49c04e4a 100644 --- a/src/afl-ld-lto.c +++ b/src/afl-ld-lto.c @@ -252,7 +252,7 @@ static void edit_params(int argc, char **argv) { int main(int argc, char **argv) { - s32 pid, i, status; + s32 pid, i, status; char thecwd[PATH_MAX]; if (getenv("AFL_LD_CALLER") != NULL) { -- cgit 1.4.1 From 040bf5a61db5fa939c6e2a884207f18b62bf1522 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 18:26:08 +0100 Subject: fix silly mistake --- src/afl-forkserver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c index d4484de7..4ee88216 100644 --- a/src/afl-forkserver.c +++ b/src/afl-forkserver.c @@ -484,7 +484,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, /* Set sane defaults for ASAN if nothing else specified. */ - if (!afl->debug || !getenv("ASAN_OPTIONS")) + if (!getenv("ASAN_OPTIONS")) setenv("ASAN_OPTIONS", "abort_on_error=1:" "detect_leaks=0:" @@ -500,7 +500,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, /* Set sane defaults for UBSAN if nothing else specified. */ - if (!afl->debug || !getenv("UBSAN_OPTIONS")) + if (!getenv("UBSAN_OPTIONS")) setenv("UBSAN_OPTIONS", "halt_on_error=1:" "abort_on_error=1:" @@ -517,7 +517,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, /* MSAN is tricky, because it doesn't support abort_on_error=1 at this point. So, we do this in a very hacky way. */ - if (!afl->debug || !getenv("MSAN_OPTIONS")) + if (!getenv("MSAN_OPTIONS")) setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":" "symbolize=0:" -- cgit 1.4.1 From 60764ebdf15be0affdd3040135fc6eb36e10d677 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 18:43:06 +0100 Subject: forkserver debug flag support --- include/forkserver.h | 2 ++ src/afl-forkserver.c | 9 +++++---- src/afl-fuzz.c | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/forkserver.h b/include/forkserver.h index 3019e289..d2fcaa20 100644 --- a/include/forkserver.h +++ b/include/forkserver.h @@ -83,6 +83,8 @@ typedef struct afl_forkserver { bool uses_asan; /* Target uses ASAN? */ + bool debug; /* debug mode? */ + bool uses_crash_exitcode; /* Custom crash exitcode specified? */ u8 crash_exitcode; /* The crash exitcode specified */ diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c index 4ee88216..1f5685b0 100644 --- a/src/afl-forkserver.c +++ b/src/afl-forkserver.c @@ -91,7 +91,7 @@ void afl_fsrv_init(afl_forkserver_t *fsrv) { fsrv->map_size = get_map_size(); fsrv->use_fauxsrv = false; fsrv->last_run_timed_out = false; - + fsrv->debug = false; fsrv->uses_crash_exitcode = false; fsrv->uses_asan = false; @@ -117,6 +117,7 @@ void afl_fsrv_init_dup(afl_forkserver_t *fsrv_to, afl_forkserver_t *from) { fsrv_to->uses_crash_exitcode = from->uses_crash_exitcode; fsrv_to->crash_exitcode = from->crash_exitcode; fsrv_to->kill_signal = from->kill_signal; + fsrv_to->debug = from->debug; // These are forkserver specific. fsrv_to->out_dir_fd = -1; @@ -484,7 +485,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, /* Set sane defaults for ASAN if nothing else specified. */ - if (!getenv("ASAN_OPTIONS")) + if (fsrv->debug == true && !getenv("ASAN_OPTIONS")) setenv("ASAN_OPTIONS", "abort_on_error=1:" "detect_leaks=0:" @@ -500,7 +501,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, /* Set sane defaults for UBSAN if nothing else specified. */ - if (!getenv("UBSAN_OPTIONS")) + if (fsrv->debug == true && !getenv("UBSAN_OPTIONS")) setenv("UBSAN_OPTIONS", "halt_on_error=1:" "abort_on_error=1:" @@ -517,7 +518,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, /* MSAN is tricky, because it doesn't support abort_on_error=1 at this point. So, we do this in a very hacky way. */ - if (!getenv("MSAN_OPTIONS")) + if (fsrv->debug == true && !getenv("MSAN_OPTIONS")) setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":" "symbolize=0:" diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 2a59bbe4..9b62e961 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -339,6 +339,7 @@ int main(int argc, char **argv_orig, char **envp) { afl_state_init(afl, map_size); afl->debug = debug; afl_fsrv_init(&afl->fsrv); + if (debug) { afl->fsrv.debug = true ; } read_afl_environment(afl, envp); if (afl->shm.map_size) { afl->fsrv.map_size = afl->shm.map_size; } -- cgit 1.4.1 From 30148bc1a9938cc29047d198eab72818cd037e3c Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 19:58:25 +0100 Subject: fix afl-showmap and gcc plugin test --- src/afl-showmap.c | 9 ++++++--- test/test-gcc-plugin.sh | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/afl-showmap.c b/src/afl-showmap.c index ee6d6de9..ab47c602 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -85,6 +85,7 @@ static u8 quiet_mode, /* Hide non-essential messages? */ keep_cores, /* Allow coredumps? */ remove_shm = 1, /* remove shmem? */ collect_coverage, /* collect coverage */ + have_coverage, /* have coverage? */ no_classify; /* do not classify counts */ static volatile u8 stop_soon, /* Ctrl-C pressed? */ @@ -316,7 +317,8 @@ static void showmap_run_target_forkserver(afl_forkserver_t *fsrv, u8 *mem, } - if (fsrv->trace_bits[0] == 1) { fsrv->trace_bits[0] = 0; } + if (fsrv->trace_bits[0] == 1) { fsrv->trace_bits[0] = 0; have_coverage = 1; } + else { have_coverage = 0; } if (!no_classify) { classify_counts(fsrv); } @@ -491,7 +493,8 @@ static void showmap_run_target(afl_forkserver_t *fsrv, char **argv) { } - if (fsrv->trace_bits[0] == 1) { fsrv->trace_bits[0] = 0; } + if (fsrv->trace_bits[0] == 1) { fsrv->trace_bits[0] = 0; have_coverage = 1; } + else { have_coverage = 0; } if (!no_classify) { classify_counts(fsrv); } @@ -1232,7 +1235,7 @@ int main(int argc, char **argv_orig, char **envp) { if (!quiet_mode || collect_coverage) { - if (!tcnt) { FATAL("No instrumentation detected" cRST); } + if (!tcnt && !have_coverage) { FATAL("No instrumentation detected" cRST); } OKF("Captured %u tuples (highest value %u, total values %llu) in " "'%s'." cRST, tcnt, highest, total, out_file); diff --git a/test/test-gcc-plugin.sh b/test/test-gcc-plugin.sh index 58000e92..cce6336b 100755 --- a/test/test-gcc-plugin.sh +++ b/test/test-gcc-plugin.sh @@ -86,15 +86,15 @@ test -e ../afl-gcc-fast -a -e ../afl-compiler-rt.o && { # now for the special gcc_plugin things echo foobar.c > instrumentlist.txt AFL_GCC_INSTRUMENT_FILE=instrumentlist.txt ../afl-gcc-fast -o test-compcov test-compcov.c > /dev/null 2>&1 - test -e test-compcov && test_compcov_binary_functionality ./test-compcov && { - echo 1 | ../afl-showmap -m ${MEM_LIMIT} -o - -r -- ./test-compcov 2>&1 | grep -q "Captured 1 tuples" && { + test -x test-compcov && test_compcov_binary_functionality ./test-compcov && { + echo 1 | ../afl-showmap -m ${MEM_LIMIT} -o - -r -- ./test-compcov 2>&1 | grep -q "Captured 0 tuples" && { $ECHO "$GREEN[+] gcc_plugin instrumentlist feature works correctly" } || { $ECHO "$RED[!] gcc_plugin instrumentlist feature failed" CODE=1 } } || { - $ECHO "$RED[!] gcc_plugin instrumentlist feature compilation failed" + $ECHO "$RED[!] gcc_plugin instrumentlist feature compilation failed." CODE=1 } rm -f test-compcov test.out instrumentlist.txt -- cgit 1.4.1 From 2ef8dc4378c08fc65a610fd5c70535d3e23fc487 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 21 Jan 2021 21:42:15 +0100 Subject: afl-cmin -m none --- afl-cmin | 4 +--- afl-cmin.bash | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/afl-cmin b/afl-cmin index 726e90ab..ffefaead 100755 --- a/afl-cmin +++ b/afl-cmin @@ -183,14 +183,12 @@ BEGIN { if (_go_c == "Q") { if (qemu_mode) { print "Option "_go_c" is only allowed once" > "/dev/stderr"} extra_par = extra_par " -Q" - if ( !mem_limit_given ) mem_limit = "250" qemu_mode = 1 continue } else if (_go_c == "U") { if (unicorn_mode) { print "Option "_go_c" is only allowed once" > "/dev/stderr"} extra_par = extra_par " -U" - if ( !mem_limit_given ) mem_limit = "250" unicorn_mode = 1 continue } else @@ -200,7 +198,7 @@ BEGIN { usage() } # while options - if (!mem_limit) mem_limit = 200 + if (!mem_limit) mem_limit = "none" if (!timeout) timeout = "none" # get program args diff --git a/afl-cmin.bash b/afl-cmin.bash index fb50f1fc..dae21939 100755 --- a/afl-cmin.bash +++ b/afl-cmin.bash @@ -45,7 +45,7 @@ echo # Process command-line options... -MEM_LIMIT=200 +MEM_LIMIT=none TIMEOUT=none unset IN_DIR OUT_DIR STDIN_FILE EXTRA_PAR MEM_LIMIT_GIVEN \ @@ -85,12 +85,10 @@ while getopts "+i:o:f:m:t:eQUCh" opt; do ;; "Q") EXTRA_PAR="$EXTRA_PAR -Q" - test "$MEM_LIMIT_GIVEN" = "" && MEM_LIMIT=250 QEMU_MODE=1 ;; "U") EXTRA_PAR="$EXTRA_PAR -U" - test "$MEM_LIMIT_GIVEN" = "" && MEM_LIMIT=250 UNICORN_MODE=1 ;; "?") -- cgit 1.4.1 From 0a12d519f7d914f16ead8d31f426f814021ec3dc Mon Sep 17 00:00:00 2001 From: Edznux Date: Fri, 22 Jan 2021 00:18:56 +0100 Subject: Add better doc for AFL_STATSD_TAGS_FLAVOR --- docs/env_variables.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/env_variables.md b/docs/env_variables.md index baf69e6a..66d85749 100644 --- a/docs/env_variables.md +++ b/docs/env_variables.md @@ -431,13 +431,18 @@ checks or alter some of the more exotic semantics of the tool: normally done when starting up the forkserver and causes a pretty significant performance drop. - - Setting `AFL_STATSD` enable StatsD metrics collection. + - Setting `AFL_STATSD` enables StatsD metrics collection. By default AFL++ will send these metrics over UDP to 127.0.0.1:8125. - The host and port are configurable with `AFL_STATSD_HOST` and `AFL_STATSD_PORT` - respectively. - To get the most out of this, you should provide `AFL_STATSD_TAGS_FLAVOR` that - matches your StatsD server. - Available flavors are `dogstatsd`, `librato`, `signalfx` and `influxdb`. + The host and port are configurable with `AFL_STATSD_HOST` and `AFL_STATSD_PORT` respectively. + To enable tags (banner and afl_version) you should provide `AFL_STATSD_TAGS_FLAVOR` that matches + your StatsD server (see `AFL_STATSD_TAGS_FLAVOR`) + + - Setting `AFL_STATSD_TAGS_FLAVOR` to one of `dogstatsd`, `librato`, `signalfx` or `influxdb` + allows you to add tags to your fuzzing instances. This is especially useful when running + multiple instances (`-M/-S` for example). Applied tags are `banner` and `afl_version`. + `banner` corresponds to the name of the fuzzer provided through `-M/-S`. + `afl_version` corresponds to the currently running afl version (e.g `++3.0c`). + Default (empty/non present) will add no tags to the metrics. - Setting `AFL_CRASH_EXITCODE` sets the exit code afl treats as crash. For example, if `AFL_CRASH_EXITCODE='-1'` is set, each input resulting -- cgit 1.4.1 From ac21e4dd7304c3306a9acb5fa6ac051d3ab64b20 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 22 Jan 2021 00:41:23 +0100 Subject: typos --- README.md | 4 ++-- docs/Changelog.md | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ce48f336..2806b734 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,11 @@ ## Major changes in afl++ 3.0 -With afl++ 3.0 we introduced changes that breaks some previous afl and afl++ +With afl++ 3.0 we introduced changes that break some previous afl and afl++ behaviours and defaults: * There are no llvm_mode and gcc_plugin subdirectories anymore and there is - only one compiler: afl-cc. All previous compilers now symlink to this. + only one compiler: afl-cc. All previous compilers now symlink to this one. All instrumentation source code is now in the `instrumentation/` folder. * The gcc_plugin was replaced with a new version submitted by AdaCore that supports more features. Thank you! diff --git a/docs/Changelog.md b/docs/Changelog.md index daae7c47..63e8e66e 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -35,7 +35,8 @@ sending a mail to . - added AFL_LLVM_INSTRUMENT option NATIVE for native clang pc-guard support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang - - warn on any _AFL and __AFL env var + - changed default: no memory limit for afl-cmin and afl-cmin.bash + - warn on any _AFL and __AFL env vars - LLVM mode is now compiled with -j4, unicorn with all cores. qemu was already building with all cores, the gcc plugin needs only one. - added dummy Makefile to instrumentation/ -- cgit 1.4.1 From 46010a87049bdf32ef23b08d25c186aba3aae442 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 22 Jan 2021 13:50:16 +0100 Subject: prepare for cmplog rtn std::string support for llvm and g++ --- instrumentation/afl-compiler-rt.o.c | 65 +++++++++++++++++++++++++++++++++ instrumentation/cmplog-routines-pass.cc | 5 +++ 2 files changed, 70 insertions(+) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 14da4caa..322141ba 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1594,6 +1594,71 @@ void __cmplog_rtn_hook(u8 *ptr1, u8 *ptr2) { } +// gcc libstdc++ +// _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc +static u8 *get_gcc_stdstring(u8 *string) { + + u32 *len = (u32 *)(string + 8); + + if (*len < 16) { // in structure + + return (string + 16); + + } else { // in memory + + u8 **ptr = (u8 **)string; + return (*ptr); + + } + +} + +// llvm libc++ _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocator +// IcEEE7compareEmmPKcm +static u8 *get_llvm_stdstring(u8 *string) { + + // length is in: if ((string[0] & 1) == 0) u8 len = (string[0] >> 1); + // or: if (string[0] & 1) u32 *len = (u32 *) (string + 8); + + if (string[0] & 1) { // in memory + + u8 **ptr = (u8 **)(string + 16); + return (*ptr); + + } else { // in structure + + return (string + 1); + + } + +} + +void __cmplog_rtn_gcc_stdstring_cstring(u8 *stdstring, u8 *cstring) { + + __cmplog_rtn_hook(get_gcc_stdstring(stdstring), cstring); + +} + +void __cmplog_rtn_gcc_stdstring_stdstring(u8 *stdstring1, u8 *stdstring2) { + + __cmplog_rtn_hook(get_gcc_stdstring(stdstring1), + get_gcc_stdstring(stdstring2)); + +} + +void __cmplog_rtn_llvm_stdstring_cstring(u8 *stdstring, u8 *cstring) { + + __cmplog_rtn_hook(get_llvm_stdstring(stdstring), cstring); + +} + +void __cmplog_rtn_llvm_stdstring_stdstring(u8 *stdstring1, u8 *stdstring2) { + + __cmplog_rtn_hook(get_llvm_stdstring(stdstring1), + get_llvm_stdstring(stdstring2)); + +} + /* COVERAGE manipulation features */ // this variable is then used in the shm setup to create an additional map diff --git a/instrumentation/cmplog-routines-pass.cc b/instrumentation/cmplog-routines-pass.cc index e92883ae..8adf42d5 100644 --- a/instrumentation/cmplog-routines-pass.cc +++ b/instrumentation/cmplog-routines-pass.cc @@ -131,6 +131,11 @@ bool CmpLogRoutines::hookRtns(Module &M) { FunctionType *FT = Callee->getFunctionType(); + // _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEmmPKcm + // => libc++ => llvm => __cmplog_rtn_llvm_stdstring_cstring(u8 *stdstring1, u8 *stdstring2) + // _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc + // => libstdc++ => gcc => __cmplog_rtn_gcc_stdstring_cstring + bool isPtrRtn = FT->getNumParams() >= 2 && !FT->getReturnType()->isVoidTy() && FT->getParamType(0) == FT->getParamType(1) && -- cgit 1.4.1 From baf1ac2e69145d9e411f13df8ab4e7060f2f2685 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 22 Jan 2021 15:58:12 +0100 Subject: basic cmplog std::string support --- docs/Changelog.md | 2 + instrumentation/afl-compiler-rt.o.c | 4 +- instrumentation/cmplog-routines-pass.cc | 214 ++++++++++++++++++++++++++++++-- 3 files changed, 209 insertions(+), 11 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 63e8e66e..2b8b0e8d 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -32,6 +32,8 @@ sending a mail to . - fixed endless loop for allow/blocklist lines starting with a comment (thanks to Zherya for reporting) - cmplog/redqueen now also tracks floating point, _ExtInt() + 128bit + - cmplog/redqueen can now process basic libc++ and libstdc++ + std::string comparisons (though no position or length type variants) - added AFL_LLVM_INSTRUMENT option NATIVE for native clang pc-guard support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 322141ba..433a1d89 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1549,10 +1549,10 @@ void __cmplog_rtn_hook(u8 *ptr1, u8 *ptr2) { u32 i; if (!area_is_mapped(ptr1, 32) || !area_is_mapped(ptr2, 32)) return; fprintf(stderr, "rtn arg0="); - for (i = 0; i < 8; i++) + for (i = 0; i < 24; i++) fprintf(stderr, "%02x", ptr1[i]); fprintf(stderr, " arg1="); - for (i = 0; i < 8; i++) + for (i = 0; i < 24; i++) fprintf(stderr, "%02x", ptr2[i]); fprintf(stderr, "\n"); */ diff --git a/instrumentation/cmplog-routines-pass.cc b/instrumentation/cmplog-routines-pass.cc index 8adf42d5..9d6999ca 100644 --- a/instrumentation/cmplog-routines-pass.cc +++ b/instrumentation/cmplog-routines-pass.cc @@ -87,7 +87,7 @@ char CmpLogRoutines::ID = 0; bool CmpLogRoutines::hookRtns(Module &M) { - std::vector calls; + std::vector calls, llvmStdStd, llvmStdC, gccStdStd, gccStdC; LLVMContext & C = M.getContext(); Type *VoidTy = Type::getVoidTy(C); @@ -112,6 +112,78 @@ bool CmpLogRoutines::hookRtns(Module &M) { FunctionCallee cmplogHookFn = c; #endif +#if LLVM_VERSION_MAJOR < 9 + Constant * +#else + FunctionCallee +#endif + c1 = M.getOrInsertFunction("__cmplog_rtn_llvm_stdstring_stdstring", + VoidTy, i8PtrTy, i8PtrTy +#if LLVM_VERSION_MAJOR < 5 + , + NULL +#endif + ); +#if LLVM_VERSION_MAJOR < 9 + Function *cmplogLlvmStdStd = cast(c1); +#else + FunctionCallee cmplogLlvmStdStd = c1; +#endif + +#if LLVM_VERSION_MAJOR < 9 + Constant * +#else + FunctionCallee +#endif + c2 = M.getOrInsertFunction("__cmplog_rtn_llvm_stdstring_cstring", VoidTy, + i8PtrTy, i8PtrTy +#if LLVM_VERSION_MAJOR < 5 + , + NULL +#endif + ); +#if LLVM_VERSION_MAJOR < 9 + Function *cmplogLlvmStdC = cast(c2); +#else + FunctionCallee cmplogLlvmStdC = c2; +#endif + +#if LLVM_VERSION_MAJOR < 9 + Constant * +#else + FunctionCallee +#endif + c3 = M.getOrInsertFunction("__cmplog_rtn_gcc_stdstring_stdstring", VoidTy, + i8PtrTy, i8PtrTy +#if LLVM_VERSION_MAJOR < 5 + , + NULL +#endif + ); +#if LLVM_VERSION_MAJOR < 9 + Function *cmplogGccStdStd = cast(c3); +#else + FunctionCallee cmplogGccStdStd = c3; +#endif + +#if LLVM_VERSION_MAJOR < 9 + Constant * +#else + FunctionCallee +#endif + c4 = M.getOrInsertFunction("__cmplog_rtn_gcc_stdstring_cstring", VoidTy, + i8PtrTy, i8PtrTy +#if LLVM_VERSION_MAJOR < 5 + , + NULL +#endif + ); +#if LLVM_VERSION_MAJOR < 9 + Function *cmplogGccStdC = cast(c4); +#else + FunctionCallee cmplogGccStdC = c4; +#endif + /* iterate over all functions, bbs and instruction and add suitable calls */ for (auto &F : M) { @@ -131,19 +203,67 @@ bool CmpLogRoutines::hookRtns(Module &M) { FunctionType *FT = Callee->getFunctionType(); - // _ZNKSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE7compareEmmPKcm - // => libc++ => llvm => __cmplog_rtn_llvm_stdstring_cstring(u8 *stdstring1, u8 *stdstring2) - // _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc - // => libstdc++ => gcc => __cmplog_rtn_gcc_stdstring_cstring - bool isPtrRtn = FT->getNumParams() >= 2 && !FT->getReturnType()->isVoidTy() && FT->getParamType(0) == FT->getParamType(1) && FT->getParamType(0)->isPointerTy(); - if (!isPtrRtn) continue; - - calls.push_back(callInst); + bool isGccStdStringStdString = + Callee->getName().find("__is_charIT_EE7__value") != + std::string::npos && + Callee->getName().find( + "St7__cxx1112basic_stringIS2_St11char_traits") != + std::string::npos && + FT->getNumParams() >= 2 && + FT->getParamType(0) == FT->getParamType(1) && + FT->getParamType(0)->isPointerTy(); + + bool isGccStdStringCString = + Callee->getName().find( + "St7__cxx1112basic_stringIcSt11char_" + "traitsIcESaIcEE7compareEPK") != std::string::npos && + FT->getNumParams() >= 2 && FT->getParamType(0)->isPointerTy() && + FT->getParamType(1)->isPointerTy(); + + bool isLlvmStdStringStdString = + Callee->getName().find("_ZNSt3__1eqINS") != std::string::npos && + Callee->getName().find("_12basic_stringIcNS_11char_traits") != + std::string::npos && + FT->getNumParams() >= 2 && FT->getParamType(0)->isPointerTy() && + FT->getParamType(1)->isPointerTy(); + + bool isLlvmStdStringCString = + Callee->getName().find("ZNSt3__1eqIcNS") != std::string::npos && + Callee->getName().find("_12basic_stringI") != std::string::npos && + FT->getNumParams() >= 2 && FT->getParamType(0)->isPointerTy() && + FT->getParamType(1)->isPointerTy(); + + /* + fprintf(stderr, "F:%s C:%s argc:%u\n", + F.getName().str().c_str(), Callee->getName().str().c_str(), + FT->getNumParams()); fprintf(stderr, "ptr0:%u ptr1:%u ptr2:%u\n", + FT->getParamType(0)->isPointerTy(), + FT->getParamType(1)->isPointerTy(), + FT->getNumParams() > 2 ? FT->getParamType(2)->isPointerTy() + : 22 ); + */ + + if (isGccStdStringCString || isGccStdStringStdString || + isLlvmStdStringStdString || isLlvmStdStringCString) { + + isPtrRtn = false; + + fprintf(stderr, "%u %u %u %u\n", isGccStdStringCString, + isGccStdStringStdString, isLlvmStdStringStdString, + isLlvmStdStringCString); + + } + + if (isPtrRtn) { calls.push_back(callInst); } + if (isGccStdStringStdString) { gccStdStd.push_back(callInst); } + if (isGccStdStringCString) { gccStdC.push_back(callInst); } + if (isLlvmStdStringStdString) { llvmStdStd.push_back(callInst); } + if (isLlvmStdStringCString) { llvmStdC.push_back(callInst); } } @@ -179,6 +299,82 @@ bool CmpLogRoutines::hookRtns(Module &M) { } + for (auto &callInst : gccStdStd) { + + Value *v1P = callInst->getArgOperand(0), *v2P = callInst->getArgOperand(1); + + IRBuilder<> IRB(callInst->getParent()); + IRB.SetInsertPoint(callInst); + + std::vector args; + Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy); + Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy); + args.push_back(v1Pcasted); + args.push_back(v2Pcasted); + + IRB.CreateCall(cmplogGccStdStd, args); + + // errs() << callInst->getCalledFunction()->getName() << "\n"; + + } + + for (auto &callInst : gccStdC) { + + Value *v1P = callInst->getArgOperand(0), *v2P = callInst->getArgOperand(1); + + IRBuilder<> IRB(callInst->getParent()); + IRB.SetInsertPoint(callInst); + + std::vector args; + Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy); + Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy); + args.push_back(v1Pcasted); + args.push_back(v2Pcasted); + + IRB.CreateCall(cmplogGccStdC, args); + + // errs() << callInst->getCalledFunction()->getName() << "\n"; + + } + + for (auto &callInst : llvmStdStd) { + + Value *v1P = callInst->getArgOperand(0), *v2P = callInst->getArgOperand(1); + + IRBuilder<> IRB(callInst->getParent()); + IRB.SetInsertPoint(callInst); + + std::vector args; + Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy); + Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy); + args.push_back(v1Pcasted); + args.push_back(v2Pcasted); + + IRB.CreateCall(cmplogLlvmStdStd, args); + + // errs() << callInst->getCalledFunction()->getName() << "\n"; + + } + + for (auto &callInst : llvmStdC) { + + Value *v1P = callInst->getArgOperand(0), *v2P = callInst->getArgOperand(1); + + IRBuilder<> IRB(callInst->getParent()); + IRB.SetInsertPoint(callInst); + + std::vector args; + Value * v1Pcasted = IRB.CreatePointerCast(v1P, i8PtrTy); + Value * v2Pcasted = IRB.CreatePointerCast(v2P, i8PtrTy); + args.push_back(v1Pcasted); + args.push_back(v2Pcasted); + + IRB.CreateCall(cmplogLlvmStdC, args); + + // errs() << callInst->getCalledFunction()->getName() << "\n"; + + } + return true; } -- cgit 1.4.1 From 9ed533a0e3908a40e3abc28b95c6f5bd4e413c44 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 22 Jan 2021 16:01:00 +0100 Subject: fix debug output --- instrumentation/cmplog-routines-pass.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/instrumentation/cmplog-routines-pass.cc b/instrumentation/cmplog-routines-pass.cc index 9d6999ca..9f19b062 100644 --- a/instrumentation/cmplog-routines-pass.cc +++ b/instrumentation/cmplog-routines-pass.cc @@ -253,10 +253,6 @@ bool CmpLogRoutines::hookRtns(Module &M) { isPtrRtn = false; - fprintf(stderr, "%u %u %u %u\n", isGccStdStringCString, - isGccStdStringStdString, isLlvmStdStringStdString, - isLlvmStdStringCString); - } if (isPtrRtn) { calls.push_back(callInst); } -- cgit 1.4.1 From 1c19804834d2ea4f169be0a99b8ce493a2f10167 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 22 Jan 2021 16:41:31 +0100 Subject: fix for cmplog stdstring --- instrumentation/cmplog-routines-pass.cc | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/instrumentation/cmplog-routines-pass.cc b/instrumentation/cmplog-routines-pass.cc index 9f19b062..a5992c9a 100644 --- a/instrumentation/cmplog-routines-pass.cc +++ b/instrumentation/cmplog-routines-pass.cc @@ -226,26 +226,32 @@ bool CmpLogRoutines::hookRtns(Module &M) { FT->getParamType(1)->isPointerTy(); bool isLlvmStdStringStdString = - Callee->getName().find("_ZNSt3__1eqINS") != std::string::npos && - Callee->getName().find("_12basic_stringIcNS_11char_traits") != - std::string::npos && + Callee->getName().find("_ZNSt3__1eqI") != std::string::npos && + Callee->getName().find("_12basic_stringI") != std::string::npos && + Callee->getName().find("_11char_traits") != std::string::npos && FT->getNumParams() >= 2 && FT->getParamType(0)->isPointerTy() && FT->getParamType(1)->isPointerTy(); bool isLlvmStdStringCString = - Callee->getName().find("ZNSt3__1eqIcNS") != std::string::npos && + Callee->getName().find("_ZNSt3__1eqI") != std::string::npos && Callee->getName().find("_12basic_stringI") != std::string::npos && FT->getNumParams() >= 2 && FT->getParamType(0)->isPointerTy() && FT->getParamType(1)->isPointerTy(); /* - fprintf(stderr, "F:%s C:%s argc:%u\n", - F.getName().str().c_str(), Callee->getName().str().c_str(), - FT->getNumParams()); fprintf(stderr, "ptr0:%u ptr1:%u ptr2:%u\n", - FT->getParamType(0)->isPointerTy(), - FT->getParamType(1)->isPointerTy(), - FT->getNumParams() > 2 ? FT->getParamType(2)->isPointerTy() - : 22 ); + { + + fprintf(stderr, "F:%s C:%s argc:%u\n", + F.getName().str().c_str(), + Callee->getName().str().c_str(), FT->getNumParams()); + fprintf(stderr, "ptr0:%u ptr1:%u ptr2:%u\n", + FT->getParamType(0)->isPointerTy(), + FT->getParamType(1)->isPointerTy(), + FT->getNumParams() > 2 ? + FT->getParamType(2)->isPointerTy() : 22 ); + + } + */ if (isGccStdStringCString || isGccStdStringStdString || @@ -269,7 +275,10 @@ bool CmpLogRoutines::hookRtns(Module &M) { } - if (!calls.size()) return false; + if (!calls.size() && !gccStdStd.size() && !gccStdC.size() && + !llvmStdStd.size() && !llvmStdC.size()) + return false; + /* if (!be_quiet) errs() << "Hooking " << calls.size() -- cgit 1.4.1 From 258ae1632af49d9ee68b1ce1a6c74d9e92245bcf Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 22 Jan 2021 21:10:23 +0100 Subject: stack 2 heap --- src/afl-fuzz-init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index cbff6d7e..b1a24f2f 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -810,7 +810,7 @@ void perform_dry_run(afl_state_t *afl) { while (q) { - u8 use_mem[MAX_FILE]; + u8 *use_mem = afl_realloc(AFL_BUF_PARAM(in), MAX_FILE); u8 res; s32 fd; -- cgit 1.4.1 From c4118e869df19aa514a46d4cf9ee90e9d4f76382 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 23 Jan 2021 00:02:59 +0100 Subject: unicorn speedtest initial commit --- unicorn_mode/samples/speedtest/.gitignore | 6 + unicorn_mode/samples/speedtest/Makefile | 17 + unicorn_mode/samples/speedtest/README.md | 65 ++++ unicorn_mode/samples/speedtest/c/Makefile | 53 +++ unicorn_mode/samples/speedtest/c/harness.c | 390 +++++++++++++++++++++++ unicorn_mode/samples/speedtest/get_offsets.py | 77 +++++ unicorn_mode/samples/speedtest/python/Makefile | 8 + unicorn_mode/samples/speedtest/python/harness.py | 277 ++++++++++++++++ unicorn_mode/samples/speedtest/rust/.gitignore | 1 + unicorn_mode/samples/speedtest/rust/Cargo.lock | 80 +++++ unicorn_mode/samples/speedtest/rust/Cargo.toml | 13 + unicorn_mode/samples/speedtest/rust/src/main.rs | 231 ++++++++++++++ unicorn_mode/samples/speedtest/sample_inputs/a | 1 + unicorn_mode/samples/speedtest/target.c | 77 +++++ unicorn_mode/unicornafl | 2 +- 15 files changed, 1297 insertions(+), 1 deletion(-) create mode 100644 unicorn_mode/samples/speedtest/.gitignore create mode 100644 unicorn_mode/samples/speedtest/Makefile create mode 100644 unicorn_mode/samples/speedtest/README.md create mode 100644 unicorn_mode/samples/speedtest/c/Makefile create mode 100644 unicorn_mode/samples/speedtest/c/harness.c create mode 100644 unicorn_mode/samples/speedtest/get_offsets.py create mode 100644 unicorn_mode/samples/speedtest/python/Makefile create mode 100644 unicorn_mode/samples/speedtest/python/harness.py create mode 100644 unicorn_mode/samples/speedtest/rust/.gitignore create mode 100644 unicorn_mode/samples/speedtest/rust/Cargo.lock create mode 100644 unicorn_mode/samples/speedtest/rust/Cargo.toml create mode 100644 unicorn_mode/samples/speedtest/rust/src/main.rs create mode 100644 unicorn_mode/samples/speedtest/sample_inputs/a create mode 100644 unicorn_mode/samples/speedtest/target.c diff --git a/unicorn_mode/samples/speedtest/.gitignore b/unicorn_mode/samples/speedtest/.gitignore new file mode 100644 index 00000000..78310c60 --- /dev/null +++ b/unicorn_mode/samples/speedtest/.gitignore @@ -0,0 +1,6 @@ +output +harness +harness-debug +target +target.o +target.offsets.* diff --git a/unicorn_mode/samples/speedtest/Makefile b/unicorn_mode/samples/speedtest/Makefile new file mode 100644 index 00000000..23f5cb07 --- /dev/null +++ b/unicorn_mode/samples/speedtest/Makefile @@ -0,0 +1,17 @@ +CFLAGS += -Wall -Werror -Wextra -Wpedantic -Og -g -fPIE + +.PHONY: all clean + +all: target target.offsets.main + +clean: + rm -rf *.o target target.offsets.* + +target.o: target.c + ${CC} ${CFLAGS} -c target.c -o $@ + +target: target.o + ${CC} ${CFLAGS} target.o -o $@ + +target.offsets.main: target + ./get_offsets.py \ No newline at end of file diff --git a/unicorn_mode/samples/speedtest/README.md b/unicorn_mode/samples/speedtest/README.md new file mode 100644 index 00000000..3c1184a2 --- /dev/null +++ b/unicorn_mode/samples/speedtest/README.md @@ -0,0 +1,65 @@ +# Speedtest + +This is a simple sample harness for a non-crashing file, +to show the raw speed of C, Rust, and Python harnesses. + +## Compiling... + +Make sure, you built unicornafl first (`../../build_unicorn_support.sh`). +Then, follow these individual steps: + +### Rust + +```bash +cd rust +cargo build --release +../../../afl-fuzz -i ../sample_inputs -o out -- ./target/release/harness @@ +``` + +### C + +```bash +cd c +make +../../../afl-fuzz -i ../sample_inputs -o out -- ./harness @@ +``` + +### python + +```bash +cd python +../../../afl-fuzz -i ../sample_inputs -o out -U -- python3 ./harness.py @@ +``` + +## Results + +TODO: add results here. + + +## Compiling speedtest_target.c + +You shouldn't need to compile simple_target.c since a X86_64 binary version is +pre-built and shipped in this sample folder. This file documents how the binary +was built in case you want to rebuild it or recompile it for any reason. + +The pre-built binary (simple_target_x86_64.bin) was built using -g -O0 in gcc. + +We then load the binary and execute the main function directly. + +## Addresses for the harness: +To find the address (in hex) of main, run: +```bash +objdump -M intel -D target | grep '
:' | cut -d" " -f1 +``` +To find all call sites to magicfn, run: +```bash +objdump -M intel -D target | grep '$' | cut -d":" -f1 +``` +For malloc callsites: +```bash +objdump -M intel -D target | grep '$' | cut -d":" -f1 +``` +And free callsites: +```bash +objdump -M intel -D target | grep '$' | cut -d":" -f1 +``` diff --git a/unicorn_mode/samples/speedtest/c/Makefile b/unicorn_mode/samples/speedtest/c/Makefile new file mode 100644 index 00000000..6038f107 --- /dev/null +++ b/unicorn_mode/samples/speedtest/c/Makefile @@ -0,0 +1,53 @@ +# UnicornAFL Usage +# Original Unicorn Example Makefile by Nguyen Anh Quynh , 2015 +# Adapted for AFL++ by domenukk , 2020 +.POSIX: +UNAME_S =$(shell uname -s)# GNU make +UNAME_S:sh=uname -s # BSD make +_UNIQ=_QINU_ + +LIBDIR = ../../../unicornafl +BIN_EXT = +AR_EXT = a + +# Verbose output? +V ?= 0 + +CFLAGS += -Wall -Werror -Wextra -Wno-unused-parameter -I../../../unicornafl/include + +LDFLAGS += -L$(LIBDIR) -lpthread -lm + +_LRT = $(_UNIQ)$(UNAME_S:Linux=) +__LRT = $(_LRT:$(_UNIQ)=-lrt) +LRT = $(__LRT:$(_UNIQ)=) + +LDFLAGS += $(LRT) + +_CC = $(_UNIQ)$(CROSS) +__CC = $(_CC:$(_UNIQ)=$(CC)) +MYCC = $(__CC:$(_UNIQ)$(CROSS)=$(CROSS)gcc) + +.PHONY: all clean + +all: fuzz + +clean: + rm -rf *.o harness harness-debug + +harness.o: harness.c ../../../unicornafl/include/unicorn/*.h + ${MYCC} ${CFLAGS} -O3 -c harness.c -o $@ + +harness-debug.o: harness.c ../../../unicornafl/include/unicorn/*.h + ${MYCC} ${CFLAGS} -fsanitize=address -g -Og -c harness.c -o $@ + +harness: harness.o + ${MYCC} -L${LIBDIR} harness.o ../../../unicornafl/libunicornafl.a $(LDFLAGS) -o $@ + +harness-debug: harness-debug.o + ${MYCC} -fsanitize=address -g -Og -L${LIBDIR} harness-debug.o ../../../unicornafl/libunicornafl.a $(LDFLAGS) -o harness-debug + +../target: + $(MAKE) -C .. + +fuzz: ../target harness + SKIP_BINCHECK=1 ../../../../afl-fuzz -i ../sample_inputs -o ./output -- ./harness @@ diff --git a/unicorn_mode/samples/speedtest/c/harness.c b/unicorn_mode/samples/speedtest/c/harness.c new file mode 100644 index 00000000..e8de3d80 --- /dev/null +++ b/unicorn_mode/samples/speedtest/c/harness.c @@ -0,0 +1,390 @@ +/* + Simple test harness for AFL++'s unicornafl c mode. + + This loads the simple_target_x86_64 binary into + Unicorn's memory map for emulation, places the specified input into + argv[1], sets up argv, and argc and executes 'main()'. + If run inside AFL, afl_fuzz automatically does the "right thing" + + Run under AFL as follows: + + $ cd /unicorn_mode/samples/simple/ + $ make + $ ../../../afl-fuzz -m none -i sample_inputs -o out -- ./harness @@ +*/ + +// This is not your everyday Unicorn. +#define UNICORN_AFL + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +// Path to the file containing the binary to emulate +#define BINARY_FILE ("../target") + +// Memory map for the code to be tested +// Arbitrary address where code to test will be loaded +static const int64_t BASE_ADDRESS = 0x0; +// Max size for the code (64kb) +static const int64_t CODE_SIZE_MAX = 0x00010000; +// Location where the input will be placed (make sure the emulated program knows this somehow, too ;) ) +static const int64_t INPUT_ADDRESS = 0x00100000; +// Maximum size for our input +static const int64_t INPUT_MAX = 0x00100000; +// Where our pseudo-heap is at +static const int64_t HEAP_ADDRESS = 0x00200000; +// Maximum allowable size for the heap +static const int64_t HEAP_SIZE_MAX = 0x000F0000; +// Address of the stack (Some random address again) +static const int64_t STACK_ADDRESS = 0x00400000; +// Size of the stack (arbitrarily chosen, just make it big enough) +static const int64_t STACK_SIZE = 0x000F0000; + +// Alignment for unicorn mappings (seems to be needed) +static const int64_t ALIGNMENT = 0x1000; + +static void hook_block(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { + printf(">>> Tracing basic block at 0x%"PRIx64 ", block size = 0x%x\n", address, size); +} + +static void hook_code(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { + printf(">>> Tracing instruction at 0x%"PRIx64 ", instruction size = 0x%x\n", address, size); +} + +/* Unicorn page needs to be 0x1000 aligned, apparently */ +static uint64_t pad(uint64_t size) { + if (size % ALIGNMENT == 0) { return size; } + return ((size / ALIGNMENT) + 1) * ALIGNMENT; +} + +/* returns the filesize in bytes, -1 or error. */ +static off_t afl_mmap_file(char *filename, char **buf_ptr) { + + off_t ret = -1; + + int fd = open(filename, O_RDONLY); + + struct stat st = {0}; + if (fstat(fd, &st)) goto exit; + + off_t in_len = st.st_size; + if (in_len == -1) { + /* This can only ever happen on 32 bit if the file is exactly 4gb. */ + fprintf(stderr, "Filesize of %s too large\n", filename); + goto exit; + } + + *buf_ptr = mmap(0, in_len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); + + if (*buf_ptr != MAP_FAILED) ret = in_len; + +exit: + close(fd); + return ret; + +} + +/* Place the input at the right spot inside unicorn. + This code path is *HOT*, do as little work as possible! */ +static bool place_input_callback( + uc_engine *uc, + char *input, + size_t input_len, + uint32_t persistent_round, + void *data +){ + // printf("Placing input with len %ld to %x\n", input_len, DATA_ADDRESS); + if (input_len >= INPUT_MAX) { + // Test input too short or too long, ignore this testcase + return false; + } + + // We need a valid c string, make sure it never goes out of bounds. + input[input_len-1] = '\0'; + + // Write the testcase to unicorn. + uc_mem_write(uc, INPUT_ADDRESS, input, input_len); + + return true; +} + +// exit in case the unicorn-internal mmap fails. +static void mem_map_checked(uc_engine *uc, uint64_t addr, size_t size, uint32_t mode) { + size = pad(size); + //printf("SIZE %llx, align: %llx\n", size, ALIGNMENT); + uc_err err = uc_mem_map(uc, addr, size, mode); + if (err != UC_ERR_OK) { + printf("Error mapping %ld bytes at 0x%lx: %s (mode: %d)\n", size, addr, uc_strerror(err), mode); + exit(1); + } +} + +// allocates an array, reads all addrs to the given array ptr, returns a size +ssize_t read_all_addrs(char *path, uint64_t *addrs, size_t max_count) { + + FILE *f = fopen(path, "r"); + if (!f) { + perror("fopen"); + fprintf(stderr, "Could not read %s, make sure you ran ./get_offsets.py\n", path); + exit(-1); + } + for (size_t i = 0; i < max_count; i++) { + bool end = false; + if(fscanf(f, "%lx", &addrs[i]) == EOF) { + end = true; + i--; + } else if (fgetc(f) == EOF) { + end = true; + } + if (end) { + printf("Set %ld addrs for %s\n", i + 1, path); + fclose(f); + return i + 1; + } + } + return max_count; +} + +// Read all addresses from the given file, and set a hook for them. +void set_all_hooks(uc_engine *uc, char *hook_file, void *hook_fn) { + + FILE *f = fopen(hook_file, "r"); + if (!f) { + fprintf(stderr, "Could not read %s, make sure you ran ./get_offsets.py\n", hook_file); + exit(-1); + } + uint64_t hook_addr; + for (int hook_count = 0; 1; hook_count++) { + if(fscanf(f, "%lx", &hook_addr) == EOF) { + printf("Set %d hooks for %s\n", hook_count, hook_file); + fclose(f); + return; + } + printf("got new hook addr %lx (count: %d) ohbytw: sizeof %lx\n", hook_addr, hook_count, sizeof(uc_hook)); + hook_addr += BASE_ADDRESS; + // We'll leek these hooks like a good citizen. + uc_hook *hook = calloc(1, sizeof(uc_hook)); + if (!hook) { + perror("calloc"); + exit(-1); + } + uc_hook_add(uc, hook, UC_HOOK_CODE, hook_fn, NULL, hook_addr, hook_addr); + // guzzle up newline + if (fgetc(f) == EOF) { + printf("Set %d hooks for %s\n", hook_count, hook_file); + fclose(f); + return; + } + } + +} + +// This is a fancy print function that we're just going to skip for fuzzing. +static void hook_magicfn(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { + address += size; + uc_reg_write(uc, UC_X86_REG_RIP, &address); +} + +static bool already_allocated = false; + +// We use a very simple malloc/free stub here, that only works for exactly one allocation at a time. +static void hook_malloc(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { + if (already_allocated) { + printf("Double malloc, not supported right now!\n"); + abort(); + } + // read the first param. + uint64_t malloc_size; + uc_reg_read(uc, UC_X86_REG_RDI, &malloc_size); + if (malloc_size > HEAP_SIZE_MAX) { + printf("Tried to allocated %ld bytes, but we only support up to %ld\n", malloc_size, HEAP_SIZE_MAX); + abort(); + } + uc_reg_write(uc, UC_X86_REG_RAX, &HEAP_ADDRESS); + address += size; + uc_reg_write(uc, UC_X86_REG_RIP, &address); + already_allocated = true; +} + +// No real free, just set the "used"-flag to false. +static void hook_free(uc_engine *uc, uint64_t address, uint32_t size, void *user_data) { + if (!already_allocated) { + printf("Double free detected. Real bug?\n"); + abort(); + } + // read the first param. + uint64_t free_ptr; + uc_reg_read(uc, UC_X86_REG_RDI, &free_ptr); + if (free_ptr != HEAP_ADDRESS) { + printf("Tried to free wrong mem region: 0x%lx at code loc 0x%lx\n", free_ptr, address); + abort(); + } + address += size; + uc_reg_write(uc, UC_X86_REG_RIP, &address); + already_allocated = false; +} + +int main(int argc, char **argv, char **envp) { + if (argc == 1) { + printf("Test harness to measure speed against Rust and python. Usage: harness [-t] \n"); + exit(1); + } + bool tracing = false; + char *filename = argv[1]; + if (argc > 2 && !strcmp(argv[1], "-t")) { + tracing = true; + filename = argv[2]; + } + + uc_engine *uc; + uc_err err; + uc_hook hooks[2]; + char *file_contents; + + // Initialize emulator in X86_64 mode + err = uc_open(UC_ARCH_X86, UC_MODE_64, &uc); + if (err) { + printf("Failed on uc_open() with error returned: %u (%s)\n", + err, uc_strerror(err)); + return -1; + } + + // If we want tracing output, set the callbacks here + if (tracing) { + // tracing all basic blocks with customized callback + uc_hook_add(uc, &hooks[0], UC_HOOK_BLOCK, hook_block, NULL, 1, 0); + uc_hook_add(uc, &hooks[1], UC_HOOK_CODE, hook_code, NULL, 1, 0); + } + + printf("The input testcase is set to %s\n", filename); + + + printf("Loading target from %s\n", BINARY_FILE); + off_t len = afl_mmap_file(BINARY_FILE, &file_contents); + printf("Binary file size: %lx\n", len); + if (len < 0) { + perror("Could not read binary to emulate"); + return -2; + } + if (len == 0) { + fprintf(stderr, "File at '%s' is empty\n", BINARY_FILE); + return -3; + } + if (len > CODE_SIZE_MAX) { + fprintf(stderr, "Binary too large, increase CODE_SIZE_MAX\n"); + return -4; + } + + // Map memory. + mem_map_checked(uc, BASE_ADDRESS, len, UC_PROT_ALL); + fflush(stdout); + + // write machine code to be emulated to memory + if (uc_mem_write(uc, BASE_ADDRESS, file_contents, len) != UC_ERR_OK) { + puts("Error writing to CODE"); + exit(-1); + } + + // Release copied contents + munmap(file_contents, len); + + // Set the program counter to the start of the code + FILE *f = fopen("../target.offsets.main", "r"); + if (!f) { + perror("fopen"); + puts("Could not read offset to main function, make sure you ran ./get_offsets.py"); + exit(-1); + } + uint64_t start_address; + if(fscanf(f, "%lx", &start_address) == EOF) { + puts("Start address not found in target.offests.main"); + exit(-1); + } + fclose(f); + start_address += BASE_ADDRESS; + printf("Execution will start at 0x%lx", start_address); + // Set the program counter to the start of the code + uc_reg_write(uc, UC_X86_REG_RIP, &start_address); // address of entry point of main() + + // Setup the Stack + mem_map_checked(uc, STACK_ADDRESS, STACK_SIZE, UC_PROT_READ | UC_PROT_WRITE); + // Setup the stack pointer, but allocate two pointers for the pointers to input + uint64_t val = STACK_ADDRESS + STACK_SIZE - 16; + //printf("Stack at %lu\n", stack_val); + uc_reg_write(uc, UC_X86_REG_RSP, &val); + + // reserve some space for our input data + mem_map_checked(uc, INPUT_ADDRESS, INPUT_MAX, UC_PROT_READ); + + // argc = 2 + val = 2; + uc_reg_write(uc, UC_X86_REG_RDI, &val); + //RSI points to our little 2 QWORD space at the beginning of the stack... + val = STACK_ADDRESS + STACK_SIZE - 16; + uc_reg_write(uc, UC_X86_REG_RSI, &val); + + //... which points to the Input. Write the ptr to mem in little endian. + uint32_t addr_little = STACK_ADDRESS; +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + // The chances you are on a big_endian system aren't too high, but still... + __builtin_bswap32(addr_little); +#endif + + uc_mem_write(uc, STACK_ADDRESS + STACK_SIZE - 16, (char *)&addr_little, 4); + + set_all_hooks(uc, "../target.offsets.malloc", hook_malloc); + set_all_hooks(uc, "../target.offsets.magicfn", hook_magicfn); + set_all_hooks(uc, "../target.offsets.free", hook_free); + + int exit_count_max = 100; + // we don't need more exits for now. + uint64_t exits[exit_count_max]; + + ssize_t exit_count = read_all_addrs("../target.offsets.main_ends", exits, exit_count_max); + if (exit_count < 1) { + printf("Could not find exits! aborting.\n"); + abort(); + } + + printf("Starting to fuzz. Running from addr %ld to one of these %ld exits:\n", start_address, exit_count); + for (ssize_t i = 0; i < exit_count; i++) { + printf(" exit %ld: %ld\n", i, exits[i]); + } + + fflush(stdout); + + // let's gooo + uc_afl_ret afl_ret = uc_afl_fuzz( + uc, // The unicorn instance we prepared + filename, // Filename of the input to process. In AFL this is usually the '@@' placeholder, outside it's any input file. + place_input_callback, // Callback that places the input (automatically loaded from the file at filename) in the unicorninstance + exits, // Where to exit (this is an array) + exit_count, // Count of end addresses + NULL, // Optional calback to run after each exec + false, // true, if the optional callback should be run also for non-crashes + 1000, // For persistent mode: How many rounds to run + NULL // additional data pointer + ); + switch(afl_ret) { + case UC_AFL_RET_ERROR: + printf("Error starting to fuzz"); + return -3; + break; + case UC_AFL_RET_NO_AFL: + printf("No AFL attached - We are done with a single run."); + break; + default: + break; + } + return 0; +} diff --git a/unicorn_mode/samples/speedtest/get_offsets.py b/unicorn_mode/samples/speedtest/get_offsets.py new file mode 100644 index 00000000..c9dc76df --- /dev/null +++ b/unicorn_mode/samples/speedtest/get_offsets.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 + +"""This simple script uses objdump to parse important addresses from the target""" +import shlex +import subprocess + +objdump_output = subprocess.check_output( + shlex.split("objdump -M intel -D target") +).decode() +main_loc = None +main_ends = [] +main_ended = False +magicfn_calls = [] +malloc_calls = [] +free_calls = [] +strlen_calls = [] + + +def line2addr(line): + return "0x" + line.split(":", 1)[0].strip() + + +last_line = None +for line in objdump_output.split("\n"): + line = line.strip() + + def read_addr_if_endswith(findme, list_to): + """ + Look, for example, for the addr like: + 12a9: e8 f2 fd ff ff call 10a0 + """ + if line.endswith(findme): + list_to.append(line2addr(line)) + + if main_loc is not None and main_ended is False: + # We want to know where main ends. An empty line in objdump. + if len(line) == 0: + main_ends.append(line2addr(last_line)) + main_ended = True + elif "ret" in line: + main_ends.append(line2addr(line)) + + if "
:" in line: + if main_loc is not None: + raise Exception("Found multiple main functions, odd target!") + # main_loc is the label, so it's parsed differntly (i.e. `0000000000001220
:`) + main_loc = "0x" + line.strip().split(" ", 1)[0].strip() + else: + [ + read_addr_if_endswith(*x) + for x in [ + ("", free_calls), + ("", malloc_calls), + ("", strlen_calls), + ("", magicfn_calls), + ] + ] + + last_line = line + +if main_loc is None: + raise ( + "Could not find main in ./target! Make sure objdump is installed and the target is compiled." + ) + +with open("target.offsets.main", "w") as f: + f.write(main_loc) +with open("target.offsets.main_ends", "w") as f: + f.write("\n".join(main_ends)) +with open("target.offsets.magicfn", "w") as f: + f.write("\n".join(magicfn_calls)) +with open("target.offsets.malloc", "w") as f: + f.write("\n".join(malloc_calls)) +with open("target.offsets.free", "w") as f: + f.write("\n".join(free_calls)) +with open("target.offsets.strlen", "w") as f: + f.write("\n".join(strlen_calls)) diff --git a/unicorn_mode/samples/speedtest/python/Makefile b/unicorn_mode/samples/speedtest/python/Makefile new file mode 100644 index 00000000..4282c6cb --- /dev/null +++ b/unicorn_mode/samples/speedtest/python/Makefile @@ -0,0 +1,8 @@ +all: fuzz + +../target: + $(MAKE) -C .. + +fuzz: ../target + rm -rf ./ouptput + ../../../../afl-fuzz -s 1 -U -i ../sample_inputs -o ./output -- python3 harness.py @@ diff --git a/unicorn_mode/samples/speedtest/python/harness.py b/unicorn_mode/samples/speedtest/python/harness.py new file mode 100644 index 00000000..f72eb32b --- /dev/null +++ b/unicorn_mode/samples/speedtest/python/harness.py @@ -0,0 +1,277 @@ +#!/usr/bin/env python3 +""" + Simple test harness for AFL's Unicorn Mode. + + This loads the speedtest target binary (precompiled X64 code) into + Unicorn's memory map for emulation, places the specified input into + Argv, and executes main. + There should not be any crashes - it's a speedtest against Rust and c. + + Before running this harness, call make in the parent folder. + + Run under AFL as follows: + + $ cd /unicorn_mode/samples/speedtest/python + $ ../../../../afl-fuzz -U -i ../sample_inputs -o ./output -- python3 harness.py @@ +""" + +import argparse +import os +import struct + +from unicornafl import * +from unicornafl.unicorn_const import UC_ARCH_X86, UC_HOOK_CODE, UC_MODE_64 +from unicornafl.x86_const import ( + UC_X86_REG_RAX, + UC_X86_REG_RDI, + UC_X86_REG_RIP, + UC_X86_REG_RSI, + UC_X86_REG_RSP, +) + +# Memory map for the code to be tested +BASE_ADDRESS = 0x0 # Arbitrary address where the (PIE) target binary will be loaded to +CODE_SIZE_MAX = 0x00010000 # Max size for the code (64kb) +INPUT_ADDRESS = 0x00100000 # where we put our stuff +INPUT_MAX = 0x00100000 # max size for our input +HEAP_ADDRESS = 0x00200000 # Heap addr +HEAP_SIZE_MAX = 0x000F0000 # Maximum allowable size for the heap +STACK_ADDRESS = 0x00400000 # Address of the stack (arbitrarily chosen) +STACK_SIZE = 0x000F0000 # Size of the stack (arbitrarily chosen) + +target_path = os.path.abspath( + os.path.join(os.path.dirname(os.path.abspath(__file__)), "..") +) +target_bin = os.path.join(target_path, "target") + + +def get_offsets_for(name): + full_path = os.path.join(target_path, f"target.offsets.{name}") + with open(full_path) as f: + return [int(x, 16) + BASE_ADDRESS for x in f.readlines()] + + +# Read all offsets from our objdump file +main_offset = get_offsets_for("main")[0] +main_ends = get_offsets_for("main_ends") +malloc_callsites = get_offsets_for("malloc") +free_callsites = get_offsets_for("free") +magicfn_callsites = get_offsets_for("magicfn") +# Joke's on me: strlen got inlined by my compiler +strlen_callsites = get_offsets_for("strlen") + +try: + # If Capstone is installed then we'll dump disassembly, otherwise just dump the binary. + from capstone import * + + cs = Cs(CS_ARCH_MIPS, CS_MODE_MIPS32 + CS_MODE_BIG_ENDIAN) + + def unicorn_debug_instruction(uc, address, size, user_data): + mem = uc.mem_read(address, size) + for (cs_address, cs_size, cs_mnemonic, cs_opstr) in cs.disasm_lite( + bytes(mem), size + ): + print(" Instr: {:#016x}:\t{}\t{}".format(address, cs_mnemonic, cs_opstr)) + + +except ImportError: + + def unicorn_debug_instruction(uc, address, size, user_data): + print(" Instr: addr=0x{0:016x}, size=0x{1:016x}".format(address, size)) + + +def unicorn_debug_block(uc, address, size, user_data): + print("Basic Block: addr=0x{0:016x}, size=0x{1:016x}".format(address, size)) + + +def unicorn_debug_mem_access(uc, access, address, size, value, user_data): + if access == UC_MEM_WRITE: + print( + " >>> Write: addr=0x{0:016x} size={1} data=0x{2:016x}".format( + address, size, value + ) + ) + else: + print(" >>> Read: addr=0x{0:016x} size={1}".format(address, size)) + + +def unicorn_debug_mem_invalid_access(uc, access, address, size, value, user_data): + if access == UC_MEM_WRITE_UNMAPPED: + print( + " >>> INVALID Write: addr=0x{0:016x} size={1} data=0x{2:016x}".format( + address, size, value + ) + ) + else: + print( + " >>> INVALID Read: addr=0x{0:016x} size={1}".format(address, size) + ) + + +already_allocated = False + + +def malloc_hook(uc, address, size, user_data): + """ + We use a very simple malloc/free stub here, that only works for exactly one allocation at a time. + """ + global already_allocated + if already_allocated: + print("Double malloc, not supported right now!") + os.abort() + # read the first param + malloc_size = uc.reg_read(UC_X86_REG_RDI) + if malloc_size > HEAP_SIZE_MAX: + print( + f"Tried to allocate {malloc_size} bytes, aint't nobody got space for that! (We may only allocate up to {HEAP_SIZE_MAX})" + ) + os.abort() + uc.reg_write(UC_X86_REG_RAX, HEAP_ADDRESS) + uc.reg_write(UC_X86_REG_RIP, address + size) + already_allocated = True + + +def free_hook(uc, address, size, user_data): + """ + No real free, just set the "used"-flag to false. + """ + global already_allocated + if not already_allocated: + print("Double free detected. Real bug?") + os.abort() + # read the first param + free_ptr = uc.reg_read(UC_X86_REG_RDI) + if free_ptr != HEAP_ADDRESS: + print( + f"Tried to free wrong mem region: {hex(free_ptr)} at code loc {hex(address)}" + ) + os.abort() + uc.reg_write(UC_X86_REG_RIP, address + size) + already_allocated = False + + +# def strlen_hook(uc, address, size, user_data): +# """ +# No real strlen, we know the len is == our input. +# This completely ignores '\0', but for this target, do we really care? +# """ +# global input_len +# print(f"Returning len {input_len}") +# uc.reg_write(UC_X86_REG_RAX, input_len) +# uc.reg_write(UC_X86_REG_RIP, address + size) + + +def magicfn_hook(uc, address, size, user_data): + """ + This is a fancy print function that we're just going to skip for fuzzing. + """ + uc.reg_write(UC_X86_REG_RIP, address + size) + + +def main(): + + parser = argparse.ArgumentParser(description="Test harness for simple_target.bin") + parser.add_argument( + "input_file", + type=str, + help="Path to the file containing the mutated input to load", + ) + parser.add_argument( + "-t", + "--trace", + default=False, + action="store_true", + help="Enables debug tracing", + ) + args = parser.parse_args() + + # Instantiate a MIPS32 big endian Unicorn Engine instance + uc = Uc(UC_ARCH_X86, UC_MODE_64) + + if args.trace: + uc.hook_add(UC_HOOK_BLOCK, unicorn_debug_block) + uc.hook_add(UC_HOOK_CODE, unicorn_debug_instruction) + uc.hook_add(UC_HOOK_MEM_WRITE | UC_HOOK_MEM_READ, unicorn_debug_mem_access) + uc.hook_add( + UC_HOOK_MEM_WRITE_UNMAPPED | UC_HOOK_MEM_READ_INVALID, + unicorn_debug_mem_invalid_access, + ) + + print("The input testcase is set to {}".format(args.input_file)) + + # --------------------------------------------------- + # Load the binary to emulate and map it into memory + with open(target_bin, "rb") as f: + binary_code = f.read() + + # Apply constraints to the mutated input + if len(binary_code) > CODE_SIZE_MAX: + print("Binary code is too large (> {} bytes)".format(CODE_SIZE_MAX)) + return + + # Write the binary to its place in mem + uc.mem_map(BASE_ADDRESS, CODE_SIZE_MAX) + uc.mem_write(BASE_ADDRESS, binary_code) + + # Set the program counter to the start of the code + uc.reg_write(UC_X86_REG_RIP, main_offset) + + # Setup the stack. + uc.mem_map(STACK_ADDRESS, STACK_SIZE) + # Setup the stack pointer, but allocate two pointers for the pointers to input. + uc.reg_write(UC_X86_REG_RSP, STACK_ADDRESS + STACK_SIZE - 16) + + # Setup our input space, and push the pointer to it in the function params + uc.mem_map(INPUT_ADDRESS, INPUT_MAX) + # We have argc = 2 + uc.reg_write(UC_X86_REG_RDI, 2) + # RSI points to our little 2 QWORD space at the beginning of the stack... + uc.reg_write(UC_X86_REG_RSI, STACK_ADDRESS + STACK_SIZE - 16) + # ... which points to the Input. Write the ptr to mem in little endian. + uc.mem_write(STACK_ADDRESS + STACK_SIZE - 16, struct.pack(" INPUT_MAX: + #print("Test input is too long (> {} bytes)") + return False + + # print(f"Placing input: {input} in round {persistent_round}") + + # Make sure the string is always 0-terminated (as it would be "in the wild") + input[-1] = b'\0' + + # Write the mutated command into the data buffer + uc.mem_write(INPUT_ADDRESS, input) + #uc.reg_write(UC_X86_REG_RIP, main_offset) + + print(f"Starting to fuzz. Running from addr {main_offset} to one of {main_ends}") + # Start the fuzzer. + uc.afl_fuzz(args.input_file, place_input_callback, main_ends, persistent_iters=1000) + + +if __name__ == "__main__": + main() diff --git a/unicorn_mode/samples/speedtest/rust/.gitignore b/unicorn_mode/samples/speedtest/rust/.gitignore new file mode 100644 index 00000000..eb5a316c --- /dev/null +++ b/unicorn_mode/samples/speedtest/rust/.gitignore @@ -0,0 +1 @@ +target diff --git a/unicorn_mode/samples/speedtest/rust/Cargo.lock b/unicorn_mode/samples/speedtest/rust/Cargo.lock new file mode 100644 index 00000000..5887facf --- /dev/null +++ b/unicorn_mode/samples/speedtest/rust/Cargo.lock @@ -0,0 +1,80 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "build-helper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" +dependencies = [ + "semver", +] + +[[package]] +name = "capstone" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031ba51c39151a1d6336ec859646153187204b0147c7b3f6fe2de636f1b8dbb3" +dependencies = [ + "capstone-sys", +] + +[[package]] +name = "capstone-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fae25eddcb80e24f98c35952c37a91ff7f8d0f60dbbdafb9763e8d5cc566b8d7" +dependencies = [ + "cc", +] + +[[package]] +name = "cc" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" + +[[package]] +name = "libc" +version = "0.2.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" + +[[package]] +name = "semver" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "unicornafl" +version = "1.0.0" +dependencies = [ + "bitflags", + "build-helper", + "capstone", + "libc", +] + +[[package]] +name = "unicornafl_harness" +version = "0.1.0" +dependencies = [ + "capstone", + "libc", + "unicornafl", +] diff --git a/unicorn_mode/samples/speedtest/rust/Cargo.toml b/unicorn_mode/samples/speedtest/rust/Cargo.toml new file mode 100644 index 00000000..111ce9c8 --- /dev/null +++ b/unicorn_mode/samples/speedtest/rust/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "unicornafl_harness" +version = "0.1.0" +authors = ["Dominik Maier "] +edition = "2018" + +[dependencies] +unicornafl = { path = "../../../unicornafl/bindings/rust/", version="1.0.0" } +capstone="0.6.0" +libc="0.2.66" + +[profile.release] +panic = "abort" \ No newline at end of file diff --git a/unicorn_mode/samples/speedtest/rust/src/main.rs b/unicorn_mode/samples/speedtest/rust/src/main.rs new file mode 100644 index 00000000..f13cb253 --- /dev/null +++ b/unicorn_mode/samples/speedtest/rust/src/main.rs @@ -0,0 +1,231 @@ +extern crate capstone; +extern crate libc; + +use core::cell::{Cell, RefCell}; +use libc::{c_void, munmap}; +use std::{ + env, + fs::File, + io::{self, Read}, + process::abort, +}; + +use unicornafl::{ + unicorn_const::{uc_error, Arch, Mode, Permission}, + utils::*, + RegisterX86::*, +}; + +const BINARY: &str = &"../target"; + +// Memory map for the code to be tested +// Arbitrary address where code to test will be loaded +const BASE_ADDRESS: u64 = 0x0; +// Max size for the code (64kb) +const CODE_SIZE_MAX: u64 = 0x00010000; +// Location where the input will be placed (make sure the uclated program knows this somehow, too ;) ) +const INPUT_ADDRESS: u64 = 0x00100000; +// Maximum size for our input +const INPUT_MAX: u64 = 0x00100000; +// Where our pseudo-heap is at +const HEAP_ADDRESS: u64 = 0x00200000; +// Maximum allowable size for the heap +const HEAP_SIZE_MAX: u64 = 0x000F0000; +// Address of the stack (Some random address again) +const STACK_ADDRESS: u64 = 0x00400000; +// Size of the stack (arbitrarily chosen, just make it big enough) +const STACK_SIZE: u64 = 0x000F0000; + +macro_rules! hook { + ($addr:expr, $func:expr) => { + uc.add_code_hook($addr, $addr, Box::new($func)) + .expect(&format!("failed to set {} hook", stringify!($func))); + }; + ($addr:expr, $func:expr, $opt_name:expr) => { + uc.add_code_hook($addr, $addr, Box::new($func)) + .expect(&format!("failed to set {} hook", $opt_name)); + }; +} + +fn read_file(filename: &str) -> Result, io::Error> { + let mut f = File::open(filename)?; + let mut buffer = Vec::new(); + f.read_to_end(&mut buffer)?; + Ok(buffer) +} + +/// Our location parser +fn parse_locs(loc_name: &str) -> Result, io::Error> { + let contents = &read_file(&format!("../target.offsets.{}", loc_name))?; + str_from_u8_unchecked(&contents) + .split("\n") + .filter_map(|x| u64::from_str_radix(x, 16)) + .collect() +} + +// find null terminated string in vec +pub unsafe fn str_from_u8_unchecked(utf8_src: &[u8]) -> &str { + let nul_range_end = utf8_src + .iter() + .position(|&c| c == b'\0') + .unwrap_or(utf8_src.len()); + ::std::str::from_utf8_unchecked(&utf8_src[0..nul_range_end]) +} + +fn align(size: u64) -> u64 { + const ALIGNMENT: u64 = 0x1000; + if size % ALIGNMENT == 0 { + size + } else { + ((size / ALIGNMENT) + 1) * ALIGNMENT + } +} + +fn main() { + let args: Vec = env::args().collect(); + if args.len() == 1 { + println!("Missing parameter (@@ for AFL)"); + return; + } + let input_file = &args[1]; + println!("The input testcase is set to {}", input_file); + uclate(input_file).unwrap(); +} + +fn uclate(input_file: &str) -> Result<(), io::Error> { + let mut uc = Unicorn::new(Arch::X86, Mode::MODE_64, 0)?; + + let binary = read_file(BINARY).expect(&format!("Could not read modem image: {}", BINARY)); + let aligned_binary_size = align(binary.len() as u64); + // Apply constraints to the mutated input + if binary.len() as u64 > CODE_SIZE_MAX { + println!("Binary code is too large (> {} bytes)", CODE_SIZE_MAX); + Ok(()) + } + + // Write the binary to its place in mem + uc.mem_map( + BASE_ADDRESS, + CODE_SIZE_MAX, + Permission::READ | Permission::WRITE, + )?; + uc.mem_write(BASE_ADDR, binary); + + // Set the program counter to the start of the code + let main_locs = parse_locs("main")?; + uc.reg_write(RIP, main_locs[0])?; + + // Setup the stack. + uc.mem_map( + STACK_ADDRESS, + STACK_SIZE as usize, + Permission::READ | Permission::WRITE, + )?; + // Setup the stack pointer, but allocate two pointers for the pointers to input. + uc.reg_write(RSP, STACK_ADDRESS + STACK_SIZE - 16)?; + + // Setup our input space, and push the pointer to it in the function params + uc.mem_map(INPUT_ADDRESS, INPUT_MAX as usize, Permission::READ)?; + // We have argc = 2 + uc.reg_write(RDI, 2)?; + // RSI points to our little 2 QWORD space at the beginning of the stack... + uc.reg_write(RSI, STACK_ADDRESS + STACK_SIZE - 16)?; + // ... which points to the Input. Write the ptr to mem in little endian. + uc.mem_write( + STACK_ADDRESS + STACK_SIZE - 16, + (INPUT_ADDRESS as u32).to_le_bytes(), + )?; + + let already_allocated = Cell::new(false); + + let already_allocated_malloc = already_allocated.clone(); + let hook_malloc = move |mut uc: Unicorn, addr: u64, size: u32| { + if already_allocated_malloc.get() { + println!("Double malloc, not supported right now!"); + abort(); + } + // read the first param + let malloc_size = uc.reg_read(RDI).unwrap(); + if malloc_size > HEAP_SIZE_MAX { + println!( + "Tried to allocate {} bytes, but we may only allocate up to {}", + malloc_size, HEAP_SIZE_MAX + ); + abort(); + } + uc.reg_write(RAX, HEAP_ADDRESS).unwrap(); + uc.reg_write(RIP, addr + size as u64).unwrap(); + already_allocated_malloc.set(true); + }; + + let already_allocated_free = already_allocated.clone(); + let hook_free = move |mut uc: Unicorn, addr: u64, size: u32| { + if already_allocated_free.get() { + println!("Double free detected. Real bug?"); + abort(); + } + // read the first param + let free_ptr = uc.reg_read(RDI).unwrap(); + if free_ptr != HEAP_ADDRESS { + println!( + "Tried to free wrong mem region {:x} at code loc {:x}", + free_ptr, addr + ); + abort(); + } + uc.reg_write(RIP, addr + size as u64); + already_allocated_free.set(false); + }; + + /* + BEGIN FUNCTION HOOKS + */ + + let hook_magicfn = + move |mut uc: Unicorn, addr: u64, size: u32| uc.reg_write(RIP, address + size as u64); + + for addr in parse_locs("malloc")? { + hook!(addr, hook_malloc, "malloc"); + } + + for addr in parse_locs("free")? { + hook!(addr, hook_free, "free"); + } + + for addr in parse_locs("magicfn")? { + hook!(addr, hook_magicfn, "magicfn"); + } + + let place_input_callback = |mut uc: Unicorn, afl_input: &[u8], _persistent_round: i32| { + // apply constraints to the mutated input + if afl_input.len() > INPUT_MAX as usize { + //println!("Skipping testcase with leng {}", afl_input.len()); + return false; + } + + // TODO: afl_input[-1] = b'\0' + uc.mem_write(INPUT_ADDRESS, afl_input).unwrap(); + true + }; + + let crash_validation_callback = + |uc: Unicorn, result: uc_error, _input: &[u8], _: i32| result != uc_error::OK; + + end_addrs = parse_locs("main_ends")?; + + let ret = uc.afl_fuzz( + input_file, + Box::new(place_input_callback), + &end_addrs, + Box::new(crash_validation_callback), + false, + 1, + ); + + match ret { + Ok(_) => {} + Err(e) => panic!(format!("found non-ok unicorn exit: {:?}", e)), + } + + Ok(()) +} diff --git a/unicorn_mode/samples/speedtest/sample_inputs/a b/unicorn_mode/samples/speedtest/sample_inputs/a new file mode 100644 index 00000000..78981922 --- /dev/null +++ b/unicorn_mode/samples/speedtest/sample_inputs/a @@ -0,0 +1 @@ +a diff --git a/unicorn_mode/samples/speedtest/target.c b/unicorn_mode/samples/speedtest/target.c new file mode 100644 index 00000000..8359a110 --- /dev/null +++ b/unicorn_mode/samples/speedtest/target.c @@ -0,0 +1,77 @@ +/* + * Sample target file to test afl-unicorn fuzzing capabilities. + * This is a very trivial example that will, however, never crash. + * Crashing would change the execution speed. + * + */ +#include +#include +#include +#include + +// Random print function we can hook in our harness to test hook speeds. +char magicfn(char to_print) { + puts("Printing a char, just minding my own business: "); + putchar(to_print); + putchar('\n'); + return to_print; +} + +int main(int argc, char** argv) { + if (argc < 2) { + printf("Gimme input pl0x!\n"); + return -1; + } + + // Make sure the hooks work... + char *test = malloc(1024); + if (!test) { + printf("Uh-Oh, malloc doesn't work!"); + abort(); + } + free(test); + + char *data_buf = argv[1]; + // We can start the unicorn hooking here. + uint64_t data_len = strlen(data_buf); + if (data_len < 20) return -2; + + for (; data_len --> 0 ;) { + char *buf_cpy = NULL; + if (data_len) { + buf_cpy = malloc(data_len); + if (!buf_cpy) { + puts("Oof, malloc failed! :/"); + abort(); + } + memcpy(buf_cpy, data_buf, data_len); + } + if (data_len >= 18) { + free(buf_cpy); + continue; + } + if (data_len > 2 && data_len < 18) { + buf_cpy[data_len - 1] = (char) 0x90; + } else if (data_buf[9] == (char) 0x90 && data_buf[10] != 0x00 && buf_cpy[11] == (char) 0x90) { + // Cause a crash if data[10] is not zero, but [9] and [11] are zero + unsigned char valid_read = buf_cpy[10]; + if (magicfn(valid_read) != valid_read) { + puts("Oof, the hook for data_buf[10] is broken?"); + abort(); + } + } + free(buf_cpy); + } + if (data_buf[0] > 0x10 && data_buf[0] < 0x20 && data_buf[1] > data_buf[2]) { + // Cause an 'invalid read' crash if (0x10 < data[0] < 0x20) and data[1] > data[2] + unsigned char valid_read = data_buf[0]; + if (magicfn(valid_read) != valid_read) { + puts("Oof, the hook for data_buf[0] is broken?"); + abort(); + } + } + + magicfn('q'); + + return 0; +} diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 83d1b426..0dd17c58 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 83d1b426be5d373edcc81576f58a10f617df143f +Subproject commit 0dd17c58d51ed6dc69a367adbe8d2dca4d224c4d -- cgit 1.4.1 From e37e43295280cf5e90ab2b47b5ccf0b2d926c4bb Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 23 Jan 2021 00:10:59 +0100 Subject: updated uc ref --- unicorn_mode/UNICORNAFL_VERSION | 2 +- unicorn_mode/update_uc_ref.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unicorn_mode/UNICORNAFL_VERSION b/unicorn_mode/UNICORNAFL_VERSION index 2dbc30b8..f1fb7f18 100644 --- a/unicorn_mode/UNICORNAFL_VERSION +++ b/unicorn_mode/UNICORNAFL_VERSION @@ -1 +1 @@ -83d1b426 +0dd17c58 diff --git a/unicorn_mode/update_uc_ref.sh b/unicorn_mode/update_uc_ref.sh index a2613942..7c1c7778 100755 --- a/unicorn_mode/update_uc_ref.sh +++ b/unicorn_mode/update_uc_ref.sh @@ -19,7 +19,7 @@ if [ "$NEW_VERSION" = "-h" ]; then exit 1 fi -git submodule init && git submodule update || exit 1 +git submodule init && git submodule update unicornafl || exit 1 cd ./unicornafl || exit 1 git fetch origin dev 1>/dev/null || exit 1 git stash 1>/dev/null 2>/dev/null -- cgit 1.4.1 From b0a8bc28d2465292c5d1aff2e1d87ffeb65a2324 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 23 Jan 2021 00:13:32 +0100 Subject: changelog --- docs/Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/Changelog.md b/docs/Changelog.md index 63e8e66e..97f816b6 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -35,6 +35,9 @@ sending a mail to . - added AFL_LLVM_INSTRUMENT option NATIVE for native clang pc-guard support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang + - unicornafl + - Substential speed gains in python bindings for certain use cases + - Added a new example harness to compare python, c, and rust bindings - changed default: no memory limit for afl-cmin and afl-cmin.bash - warn on any _AFL and __AFL env vars - LLVM mode is now compiled with -j4, unicorn with all cores. qemu was -- cgit 1.4.1 From fea02869891ec0a0b29bd1d50669d822d60d823c Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 23 Jan 2021 06:03:15 +0100 Subject: tried to fix rust example --- unicorn_mode/samples/speedtest/rust/src/main.rs | 94 ++++++++++++------------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/unicorn_mode/samples/speedtest/rust/src/main.rs b/unicorn_mode/samples/speedtest/rust/src/main.rs index f13cb253..0a1dfd25 100644 --- a/unicorn_mode/samples/speedtest/rust/src/main.rs +++ b/unicorn_mode/samples/speedtest/rust/src/main.rs @@ -1,8 +1,7 @@ extern crate capstone; extern crate libc; -use core::cell::{Cell, RefCell}; -use libc::{c_void, munmap}; +use core::cell::Cell; use std::{ env, fs::File, @@ -12,8 +11,8 @@ use std::{ use unicornafl::{ unicorn_const::{uc_error, Arch, Mode, Permission}, - utils::*, - RegisterX86::*, + RegisterX86::{self, *}, + Unicorn, UnicornHandle, }; const BINARY: &str = &"../target"; @@ -36,17 +35,6 @@ const STACK_ADDRESS: u64 = 0x00400000; // Size of the stack (arbitrarily chosen, just make it big enough) const STACK_SIZE: u64 = 0x000F0000; -macro_rules! hook { - ($addr:expr, $func:expr) => { - uc.add_code_hook($addr, $addr, Box::new($func)) - .expect(&format!("failed to set {} hook", stringify!($func))); - }; - ($addr:expr, $func:expr, $opt_name:expr) => { - uc.add_code_hook($addr, $addr, Box::new($func)) - .expect(&format!("failed to set {} hook", $opt_name)); - }; -} - fn read_file(filename: &str) -> Result, io::Error> { let mut f = File::open(filename)?; let mut buffer = Vec::new(); @@ -57,10 +45,10 @@ fn read_file(filename: &str) -> Result, io::Error> { /// Our location parser fn parse_locs(loc_name: &str) -> Result, io::Error> { let contents = &read_file(&format!("../target.offsets.{}", loc_name))?; - str_from_u8_unchecked(&contents) + Ok(str_from_u8_unchecked(&contents) .split("\n") - .filter_map(|x| u64::from_str_radix(x, 16)) - .collect() + .flat_map(|x| u64::from_str_radix(x, 16)) + .collect()) } // find null terminated string in vec @@ -89,31 +77,31 @@ fn main() { } let input_file = &args[1]; println!("The input testcase is set to {}", input_file); - uclate(input_file).unwrap(); + fuzz(input_file).unwrap(); } -fn uclate(input_file: &str) -> Result<(), io::Error> { - let mut uc = Unicorn::new(Arch::X86, Mode::MODE_64, 0)?; +fn fuzz(input_file: &str) -> Result<(), uc_error> { + let unicorn = Unicorn::new(Arch::X86, Mode::MODE_64, 0)?; + let mut uc = unicorn.borrow(); let binary = read_file(BINARY).expect(&format!("Could not read modem image: {}", BINARY)); let aligned_binary_size = align(binary.len() as u64); // Apply constraints to the mutated input if binary.len() as u64 > CODE_SIZE_MAX { println!("Binary code is too large (> {} bytes)", CODE_SIZE_MAX); - Ok(()) } // Write the binary to its place in mem uc.mem_map( BASE_ADDRESS, - CODE_SIZE_MAX, + CODE_SIZE_MAX as usize, Permission::READ | Permission::WRITE, )?; - uc.mem_write(BASE_ADDR, binary); + uc.mem_write(BASE_ADDRESS, &binary); // Set the program counter to the start of the code - let main_locs = parse_locs("main")?; - uc.reg_write(RIP, main_locs[0])?; + let main_locs = parse_locs("main").unwrap(); + uc.reg_write(RegisterX86::RIP as i32, main_locs[0])?; // Setup the stack. uc.mem_map( @@ -122,30 +110,32 @@ fn uclate(input_file: &str) -> Result<(), io::Error> { Permission::READ | Permission::WRITE, )?; // Setup the stack pointer, but allocate two pointers for the pointers to input. - uc.reg_write(RSP, STACK_ADDRESS + STACK_SIZE - 16)?; + uc.reg_write(RSP as i32, STACK_ADDRESS + STACK_SIZE - 16)?; // Setup our input space, and push the pointer to it in the function params uc.mem_map(INPUT_ADDRESS, INPUT_MAX as usize, Permission::READ)?; // We have argc = 2 - uc.reg_write(RDI, 2)?; + uc.reg_write(RDI as i32, 2)?; // RSI points to our little 2 QWORD space at the beginning of the stack... - uc.reg_write(RSI, STACK_ADDRESS + STACK_SIZE - 16)?; + uc.reg_write(RSI as i32, STACK_ADDRESS + STACK_SIZE - 16)?; // ... which points to the Input. Write the ptr to mem in little endian. uc.mem_write( STACK_ADDRESS + STACK_SIZE - 16, - (INPUT_ADDRESS as u32).to_le_bytes(), + &(INPUT_ADDRESS as u32).to_le_bytes(), )?; let already_allocated = Cell::new(false); let already_allocated_malloc = already_allocated.clone(); - let hook_malloc = move |mut uc: Unicorn, addr: u64, size: u32| { + // We use a very simple malloc/free stub here, + // that only works for exactly one allocation at a time. + let hook_malloc = move |mut uc: UnicornHandle<'_, _>, addr: u64, size: u32| { if already_allocated_malloc.get() { println!("Double malloc, not supported right now!"); abort(); } // read the first param - let malloc_size = uc.reg_read(RDI).unwrap(); + let malloc_size = uc.reg_read(RDI as i32).unwrap(); if malloc_size > HEAP_SIZE_MAX { println!( "Tried to allocate {} bytes, but we may only allocate up to {}", @@ -153,19 +143,21 @@ fn uclate(input_file: &str) -> Result<(), io::Error> { ); abort(); } - uc.reg_write(RAX, HEAP_ADDRESS).unwrap(); - uc.reg_write(RIP, addr + size as u64).unwrap(); + uc.reg_write(RAX as i32, HEAP_ADDRESS).unwrap(); + uc.reg_write(RIP as i32, addr + size as u64).unwrap(); already_allocated_malloc.set(true); + Ok(()); }; let already_allocated_free = already_allocated.clone(); - let hook_free = move |mut uc: Unicorn, addr: u64, size: u32| { + // No real free, just set the "used"-flag to false. + let hook_free = move |mut uc: UnicornHandle<'_, _>, addr, size| { if already_allocated_free.get() { println!("Double free detected. Real bug?"); abort(); } // read the first param - let free_ptr = uc.reg_read(RDI).unwrap(); + let free_ptr = uc.reg_read(RDI as i32).unwrap(); if free_ptr != HEAP_ADDRESS { println!( "Tried to free wrong mem region {:x} at code loc {:x}", @@ -173,30 +165,35 @@ fn uclate(input_file: &str) -> Result<(), io::Error> { ); abort(); } - uc.reg_write(RIP, addr + size as u64); + uc.reg_write(RIP as i32, addr + size as u64); already_allocated_free.set(false); + Ok(()) }; /* BEGIN FUNCTION HOOKS */ - let hook_magicfn = - move |mut uc: Unicorn, addr: u64, size: u32| uc.reg_write(RIP, address + size as u64); + // This is a fancy print function that we're just going to skip for fuzzing. + let hook_magicfn = move |mut uc: UnicornHandle<'_, _>, addr, size| { + uc.reg_write(RIP as i32, addr + size as u64); + Ok(()) + }; - for addr in parse_locs("malloc")? { - hook!(addr, hook_malloc, "malloc"); + for addr in parse_locs("malloc").unwrap() { + //hook!(addr, hook_malloc, "malloc"); + uc.add_code_hook(addr, addr, Box::new(hook_malloc))?; } - for addr in parse_locs("free")? { - hook!(addr, hook_free, "free"); + for addr in parse_locs("free").unwrap() { + uc.add_code_hook(addr, addr, Box::new(hook_free))?; } - for addr in parse_locs("magicfn")? { - hook!(addr, hook_magicfn, "magicfn"); + for addr in parse_locs("magicfn").unwrap() { + uc.add_code_hook(addr, addr, Box::new(hook_magicfn))?; } - let place_input_callback = |mut uc: Unicorn, afl_input: &[u8], _persistent_round: i32| { + let place_input_callback = |mut uc, afl_input, _persistent_round| { // apply constraints to the mutated input if afl_input.len() > INPUT_MAX as usize { //println!("Skipping testcase with leng {}", afl_input.len()); @@ -208,10 +205,9 @@ fn uclate(input_file: &str) -> Result<(), io::Error> { true }; - let crash_validation_callback = - |uc: Unicorn, result: uc_error, _input: &[u8], _: i32| result != uc_error::OK; + let crash_validation_callback = |uc, result, _input, _persistent_round| result != uc_error::OK; - end_addrs = parse_locs("main_ends")?; + let end_addrs = parse_locs("main_ends").unwrap(); let ret = uc.afl_fuzz( input_file, -- cgit 1.4.1 From 46cef4bc110f103ab9edc99f488ddecc968173df Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 23 Jan 2021 06:39:55 +0100 Subject: fixed rust example --- unicorn_mode/samples/speedtest/c/Makefile | 3 +- unicorn_mode/samples/speedtest/rust/Cargo.toml | 10 ++-- unicorn_mode/samples/speedtest/rust/Makefile | 17 +++++++ unicorn_mode/samples/speedtest/rust/src/main.rs | 65 ++++++++++++------------- 4 files changed, 57 insertions(+), 38 deletions(-) create mode 100644 unicorn_mode/samples/speedtest/rust/Makefile diff --git a/unicorn_mode/samples/speedtest/c/Makefile b/unicorn_mode/samples/speedtest/c/Makefile index 6038f107..ce784d4f 100644 --- a/unicorn_mode/samples/speedtest/c/Makefile +++ b/unicorn_mode/samples/speedtest/c/Makefile @@ -50,4 +50,5 @@ harness-debug: harness-debug.o $(MAKE) -C .. fuzz: ../target harness - SKIP_BINCHECK=1 ../../../../afl-fuzz -i ../sample_inputs -o ./output -- ./harness @@ + rm -rf ./output + SKIP_BINCHECK=1 ../../../../afl-fuzz -s 1 -i ../sample_inputs -o ./output -- ./harness @@ diff --git a/unicorn_mode/samples/speedtest/rust/Cargo.toml b/unicorn_mode/samples/speedtest/rust/Cargo.toml index 111ce9c8..c19ee0a1 100644 --- a/unicorn_mode/samples/speedtest/rust/Cargo.toml +++ b/unicorn_mode/samples/speedtest/rust/Cargo.toml @@ -4,10 +4,12 @@ version = "0.1.0" authors = ["Dominik Maier "] edition = "2018" +[profile.release] +lto = true +opt-level = 3 +panic = "abort" + [dependencies] unicornafl = { path = "../../../unicornafl/bindings/rust/", version="1.0.0" } capstone="0.6.0" -libc="0.2.66" - -[profile.release] -panic = "abort" \ No newline at end of file +libc="0.2.66" \ No newline at end of file diff --git a/unicorn_mode/samples/speedtest/rust/Makefile b/unicorn_mode/samples/speedtest/rust/Makefile new file mode 100644 index 00000000..fe18d6ee --- /dev/null +++ b/unicorn_mode/samples/speedtest/rust/Makefile @@ -0,0 +1,17 @@ +all: fuzz + +clean: + cargo clean + +./target/release/unicornafl_harness: ./src/main.rs + cargo build --release + +./target/debug/unicornafl_harness: ./src/main.rs + cargo build + +../target: + $(MAKE) -c .. + +fuzz: ../target ./target/release/unicornafl_harness + rm -rf ./output + SKIP_BINCHECK=1 ../../../../afl-fuzz -s 1 -i ../sample_inputs -o ./output -- ./target/release/unicornafl_harness @@ diff --git a/unicorn_mode/samples/speedtest/rust/src/main.rs b/unicorn_mode/samples/speedtest/rust/src/main.rs index 0a1dfd25..516c54d1 100644 --- a/unicorn_mode/samples/speedtest/rust/src/main.rs +++ b/unicorn_mode/samples/speedtest/rust/src/main.rs @@ -7,6 +7,7 @@ use std::{ fs::File, io::{self, Read}, process::abort, + str, }; use unicornafl::{ @@ -45,19 +46,24 @@ fn read_file(filename: &str) -> Result, io::Error> { /// Our location parser fn parse_locs(loc_name: &str) -> Result, io::Error> { let contents = &read_file(&format!("../target.offsets.{}", loc_name))?; + //println!("Read: {:?}", contents); Ok(str_from_u8_unchecked(&contents) .split("\n") - .flat_map(|x| u64::from_str_radix(x, 16)) + .map(|x| { + //println!("Trying to convert {}", &x[2..]); + let result = u64::from_str_radix(&x[2..], 16); + result.unwrap() + }) .collect()) } // find null terminated string in vec -pub unsafe fn str_from_u8_unchecked(utf8_src: &[u8]) -> &str { +pub fn str_from_u8_unchecked(utf8_src: &[u8]) -> &str { let nul_range_end = utf8_src .iter() .position(|&c| c == b'\0') .unwrap_or(utf8_src.len()); - ::std::str::from_utf8_unchecked(&utf8_src[0..nul_range_end]) + unsafe { str::from_utf8_unchecked(&utf8_src[0..nul_range_end]) } } fn align(size: u64) -> u64 { @@ -81,26 +87,23 @@ fn main() { } fn fuzz(input_file: &str) -> Result<(), uc_error> { - let unicorn = Unicorn::new(Arch::X86, Mode::MODE_64, 0)?; - let mut uc = unicorn.borrow(); + let mut unicorn = Unicorn::new(Arch::X86, Mode::MODE_64, 0)?; + let mut uc: UnicornHandle<'_, _> = unicorn.borrow(); let binary = read_file(BINARY).expect(&format!("Could not read modem image: {}", BINARY)); - let aligned_binary_size = align(binary.len() as u64); + let _aligned_binary_size = align(binary.len() as u64); // Apply constraints to the mutated input if binary.len() as u64 > CODE_SIZE_MAX { println!("Binary code is too large (> {} bytes)", CODE_SIZE_MAX); } // Write the binary to its place in mem - uc.mem_map( - BASE_ADDRESS, - CODE_SIZE_MAX as usize, - Permission::READ | Permission::WRITE, - )?; - uc.mem_write(BASE_ADDRESS, &binary); + uc.mem_map(BASE_ADDRESS, CODE_SIZE_MAX as usize, Permission::ALL)?; + uc.mem_write(BASE_ADDRESS, &binary)?; // Set the program counter to the start of the code let main_locs = parse_locs("main").unwrap(); + //println!("Entry Point: {:x}", main_locs[0]); uc.reg_write(RegisterX86::RIP as i32, main_locs[0])?; // Setup the stack. @@ -146,7 +149,6 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> { uc.reg_write(RAX as i32, HEAP_ADDRESS).unwrap(); uc.reg_write(RIP as i32, addr + size as u64).unwrap(); already_allocated_malloc.set(true); - Ok(()); }; let already_allocated_free = already_allocated.clone(); @@ -165,9 +167,8 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> { ); abort(); } - uc.reg_write(RIP as i32, addr + size as u64); + uc.reg_write(RIP as i32, addr + size as u64).unwrap(); already_allocated_free.set(false); - Ok(()) }; /* @@ -176,36 +177,34 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> { // This is a fancy print function that we're just going to skip for fuzzing. let hook_magicfn = move |mut uc: UnicornHandle<'_, _>, addr, size| { - uc.reg_write(RIP as i32, addr + size as u64); - Ok(()) + uc.reg_write(RIP as i32, addr + size as u64).unwrap(); }; for addr in parse_locs("malloc").unwrap() { //hook!(addr, hook_malloc, "malloc"); - uc.add_code_hook(addr, addr, Box::new(hook_malloc))?; + uc.add_code_hook(addr, addr, Box::new(hook_malloc.clone()))?; } for addr in parse_locs("free").unwrap() { - uc.add_code_hook(addr, addr, Box::new(hook_free))?; + uc.add_code_hook(addr, addr, Box::new(hook_free.clone()))?; } for addr in parse_locs("magicfn").unwrap() { - uc.add_code_hook(addr, addr, Box::new(hook_magicfn))?; + uc.add_code_hook(addr, addr, Box::new(hook_magicfn.clone()))?; } - let place_input_callback = |mut uc, afl_input, _persistent_round| { - // apply constraints to the mutated input - if afl_input.len() > INPUT_MAX as usize { - //println!("Skipping testcase with leng {}", afl_input.len()); - return false; - } - - // TODO: afl_input[-1] = b'\0' - uc.mem_write(INPUT_ADDRESS, afl_input).unwrap(); - true - }; - - let crash_validation_callback = |uc, result, _input, _persistent_round| result != uc_error::OK; + let place_input_callback = + |mut uc: UnicornHandle<'_, _>, afl_input: &[u8], _persistent_round| { + // apply constraints to the mutated input + if afl_input.len() > INPUT_MAX as usize { + //println!("Skipping testcase with leng {}", afl_input.len()); + return false; + } + + // TODO: afl_input[-1] = b'\0' + uc.mem_write(INPUT_ADDRESS, afl_input).unwrap(); + true + }; let end_addrs = parse_locs("main_ends").unwrap(); -- cgit 1.4.1 From 4179affe2c7ee2e49f41619f1b8fe59bd4240354 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 23 Jan 2021 06:42:55 +0100 Subject: enabled persistent mode --- unicorn_mode/samples/speedtest/rust/src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unicorn_mode/samples/speedtest/rust/src/main.rs b/unicorn_mode/samples/speedtest/rust/src/main.rs index 516c54d1..8e31d2e2 100644 --- a/unicorn_mode/samples/speedtest/rust/src/main.rs +++ b/unicorn_mode/samples/speedtest/rust/src/main.rs @@ -206,6 +206,11 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> { true }; + let crash_validation_callback = + |_uc: UnicornHandle<'_, _>, result, _input: &[u8], _persistent_round| { + result != uc_error::OK + }; + let end_addrs = parse_locs("main_ends").unwrap(); let ret = uc.afl_fuzz( @@ -214,7 +219,7 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> { &end_addrs, Box::new(crash_validation_callback), false, - 1, + 1000, ); match ret { -- cgit 1.4.1 From 0a3a708f9bf7b9f192d236c792a13cec2aa54a16 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sat, 23 Jan 2021 10:01:09 +0100 Subject: less stack mem req --- src/afl-fuzz-init.c | 3 ++- src/afl-fuzz-queue.c | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index b1a24f2f..fed58eb6 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -807,10 +807,10 @@ void perform_dry_run(afl_state_t *afl) { struct queue_entry *q = afl->queue; u32 cal_failures = 0; u8 * skip_crashes = afl->afl_env.afl_skip_crashes; + u8 * use_mem; while (q) { - u8 *use_mem = afl_realloc(AFL_BUF_PARAM(in), MAX_FILE); u8 res; s32 fd; @@ -829,6 +829,7 @@ void perform_dry_run(afl_state_t *afl) { if (fd < 0) { PFATAL("Unable to open '%s'", q->fname); } u32 read_len = MIN(q->len, (u32)MAX_FILE); + use_mem = afl_realloc(AFL_BUF_PARAM(in), read_len); if (read(fd, use_mem, read_len) != (ssize_t)read_len) { FATAL("Short read from '%s'", q->fname); diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c index aec57a6e..90f969d9 100644 --- a/src/afl-fuzz-queue.c +++ b/src/afl-fuzz-queue.c @@ -313,17 +313,18 @@ void mark_as_redundant(afl_state_t *afl, struct queue_entry *q, u8 state) { /* check if ascii or UTF-8 */ -static u8 check_if_text(struct queue_entry *q) { +static u8 check_if_text(afl_state_t *afl, struct queue_entry *q) { if (q->len < AFL_TXT_MIN_LEN) return 0; - u8 buf[MAX_FILE]; + u8 *buf; int fd; u32 len = q->len, offset = 0, ascii = 0, utf8 = 0; ssize_t comp; if (len >= MAX_FILE) len = MAX_FILE - 1; if ((fd = open(q->fname, O_RDONLY)) < 0) return 0; + buf = afl_realloc(AFL_BUF_PARAM(in_scratch), len); comp = read(fd, buf, len); close(fd); if (comp != (ssize_t)len) return 0; @@ -487,7 +488,7 @@ void add_to_queue(afl_state_t *afl, u8 *fname, u32 len, u8 passed_det) { } /* only redqueen currently uses is_ascii */ - if (afl->shm.cmplog_mode) q->is_ascii = check_if_text(q); + if (afl->shm.cmplog_mode) q->is_ascii = check_if_text(afl, q); } -- cgit 1.4.1 From 08c716da9c29497a65da4021c18941ee36d18087 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 23 Jan 2021 19:39:16 +0100 Subject: removed lock' --- unicorn_mode/samples/speedtest/rust/Cargo.lock | 80 -------------------------- 1 file changed, 80 deletions(-) delete mode 100644 unicorn_mode/samples/speedtest/rust/Cargo.lock diff --git a/unicorn_mode/samples/speedtest/rust/Cargo.lock b/unicorn_mode/samples/speedtest/rust/Cargo.lock deleted file mode 100644 index 5887facf..00000000 --- a/unicorn_mode/samples/speedtest/rust/Cargo.lock +++ /dev/null @@ -1,80 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "build-helper" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" -dependencies = [ - "semver", -] - -[[package]] -name = "capstone" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "031ba51c39151a1d6336ec859646153187204b0147c7b3f6fe2de636f1b8dbb3" -dependencies = [ - "capstone-sys", -] - -[[package]] -name = "capstone-sys" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fae25eddcb80e24f98c35952c37a91ff7f8d0f60dbbdafb9763e8d5cc566b8d7" -dependencies = [ - "cc", -] - -[[package]] -name = "cc" -version = "1.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" - -[[package]] -name = "libc" -version = "0.2.82" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" - -[[package]] -name = "semver" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "unicornafl" -version = "1.0.0" -dependencies = [ - "bitflags", - "build-helper", - "capstone", - "libc", -] - -[[package]] -name = "unicornafl_harness" -version = "0.1.0" -dependencies = [ - "capstone", - "libc", - "unicornafl", -] -- cgit 1.4.1 From e82cd40440001493dfe4673a59a13166dd70d81a Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 23 Jan 2021 19:39:34 +0100 Subject: added cargo lock --- unicorn_mode/samples/speedtest/rust/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/unicorn_mode/samples/speedtest/rust/.gitignore b/unicorn_mode/samples/speedtest/rust/.gitignore index eb5a316c..a9d37c56 100644 --- a/unicorn_mode/samples/speedtest/rust/.gitignore +++ b/unicorn_mode/samples/speedtest/rust/.gitignore @@ -1 +1,2 @@ target +Cargo.lock -- cgit 1.4.1 From afc15965c00b6b2646902d8073cf9c925862b853 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Mon, 25 Jan 2021 02:01:34 +0100 Subject: updated unicornalf, bindings --- docs/Changelog.md | 1 + unicorn_mode/UNICORNAFL_VERSION | 2 +- unicorn_mode/samples/speedtest/rust/src/main.rs | 5 +++-- unicorn_mode/unicornafl | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 062dd785..12f81571 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -39,6 +39,7 @@ sending a mail to . CLANG for old afl-clang - unicornafl - Substential speed gains in python bindings for certain use cases + - Improved rust bindings - Added a new example harness to compare python, c, and rust bindings - changed default: no memory limit for afl-cmin and afl-cmin.bash - warn on any _AFL and __AFL env vars diff --git a/unicorn_mode/UNICORNAFL_VERSION b/unicorn_mode/UNICORNAFL_VERSION index f1fb7f18..a02531ec 100644 --- a/unicorn_mode/UNICORNAFL_VERSION +++ b/unicorn_mode/UNICORNAFL_VERSION @@ -1 +1 @@ -0dd17c58 +2a54500c diff --git a/unicorn_mode/samples/speedtest/rust/src/main.rs b/unicorn_mode/samples/speedtest/rust/src/main.rs index 8e31d2e2..1e35ff0b 100644 --- a/unicorn_mode/samples/speedtest/rust/src/main.rs +++ b/unicorn_mode/samples/speedtest/rust/src/main.rs @@ -194,18 +194,19 @@ fn fuzz(input_file: &str) -> Result<(), uc_error> { } let place_input_callback = - |mut uc: UnicornHandle<'_, _>, afl_input: &[u8], _persistent_round| { + |mut uc: UnicornHandle<'_, _>, afl_input: &mut [u8], _persistent_round| { // apply constraints to the mutated input if afl_input.len() > INPUT_MAX as usize { //println!("Skipping testcase with leng {}", afl_input.len()); return false; } - // TODO: afl_input[-1] = b'\0' + afl_input[afl_input.len() - 1] = b'\0'; uc.mem_write(INPUT_ADDRESS, afl_input).unwrap(); true }; + // return true if the last run should be counted as crash let crash_validation_callback = |_uc: UnicornHandle<'_, _>, result, _input: &[u8], _persistent_round| { result != uc_error::OK diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 0dd17c58..2a54500c 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 0dd17c58d51ed6dc69a367adbe8d2dca4d224c4d +Subproject commit 2a54500c08758d29caacd1ccf47d034d9faa4a18 -- cgit 1.4.1 From 52af7caf8af97c170f13a2c6a9131fccf3a417b9 Mon Sep 17 00:00:00 2001 From: Edouard SCHWEISGUTH Date: Mon, 25 Jan 2021 02:07:51 +0100 Subject: Add StatsD readme (#702) * Adding draft notes for statsd readme * Add statsd dashboard json template & image. --- docs/rpc_statsd.md | 143 +++ docs/statsd/grafana-afl++.json | 1816 +++++++++++++++++++++++++++++++++ docs/visualization/StatsD-grafana.png | Bin 0 -> 163646 bytes 3 files changed, 1959 insertions(+) create mode 100644 docs/rpc_statsd.md create mode 100644 docs/statsd/grafana-afl++.json create mode 100644 docs/visualization/StatsD-grafana.png diff --git a/docs/rpc_statsd.md b/docs/rpc_statsd.md new file mode 100644 index 00000000..26544ff5 --- /dev/null +++ b/docs/rpc_statsd.md @@ -0,0 +1,143 @@ +# Remote monitoring with StatsD + +StatsD allows you to receive and aggregate metrics from a wide range of application and retransmit them to the backend of your choice. +This enables you to create nice and readable dashboards containing all the information you need on your fuzzer instances. +No need to write your own statistics parsing system, deploy and maintain it to all your instances, sync with your graph rendering system... + +The available metrics are : +- cycle_done +- cycles_wo_finds +- execs_done +- execs_per_sec +- paths_total +- paths_favored +- paths_found +- paths_imported +- max_depth +- cur_path +- pending_favs +- pending_total +- variable_paths +- unique_crashes +- unique_hangs +- total_crashes +- slowest_exec_ms +- edges_found +- var_byte_count +- havoc_expansion + +Compared to the default integrated UI, these metrics give you the opportunity to visualize trends and fuzzing state over time. +By doing so, you might be able to see when the fuzzing process has reached a state of no progress, visualize what are the "best strategies" +(according to your own criteria) for your targets, etc. And doing so without requiring to log into each instance manually. + +An example visualisation may look like the following: +![StatsD Grafana](./visualization/StatsD-grafana.png) + +*Notes: The exact same dashboard can be imported with [this JSON template](./statsd/grafana-afl++.json).* + +## How to use + +To enable the StatsD reporting on your fuzzer instances, you need to set the environment variable `AFL_STATSD=1`. + +Setting `AFL_STATSD_TAGS_FLAVOR` to the provider of your choice will assign tags / labels to each metric based on their format. +The possible values are `dogstatsd`, `librato`, `signalfx` or `influxdb`. +For more information on these env vars, check out `docs/env_variables.md`. + +The simplest way of using this feature is to use any metric provider and change the host/port of your StatsD daemon, +with `AFL_STATSD_HOST` and `AFL_STATSD_PORT`, if required (defaults are `localhost` and port `8125`). +To get started, here are some instruction with free and open source tools. +The following setup is based on Prometheus, statsd_exporter and Grafana. +Grafana here is not mandatory, but gives you some nice graphs and features. + +Depending on your setup and infrastructure, you may want to run these applications not on your fuzzer instances. +Only one instance of these 3 application is required for all your fuzzers. + +To simplify everything, we will use Docker and docker-compose. +Make sure you have them both installed. On most common Linux distributions, it's as simple as: + +```sh +curl -fsSL https://get.docker.com -o get-docker.sh +sh get-docker.sh +``` + +Once that's done, we can create the infrastructure. +Create and move into the directory of your choice. This will store all the configurations files required. + +First, create a `docker-compose.yml` containing the following: +```yml +version: '3' + +networks: + statsd-net: + driver: bridge + +services: + prometheus: + image: prom/prometheus + container_name: prometheus + volumes: + - ./prometheus.yml:/prometheus.yml + command: + - '--config.file=/prometheus.yml' + restart: unless-stopped + ports: + - "9090:9090" + networks: + - statsd-net + + statsd_exporter: + image: prom/statsd-exporter + container_name: statsd_exporter + volumes: + - ./statsd_mapping.yml:/statsd_mapping.yml + command: + - "--statsd.mapping-config=/statsd_mapping.yml" + ports: + - "9102:9102/tcp" + - "8125:9125/udp" + networks: + - statsd-net + + grafana: + image: grafana/grafana + container_name: grafana + restart: unless-stopped + ports: + - "3000:3000" + networks: + - statsd-net +``` + +Then `prometheus.yml` +```yml +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: 'fuzzing_metrics' + static_configs: + - targets: ['statsd_exporter:9102'] +``` + +And finally `statsd_mapping.yml` +```yml +mappings: +- match: "fuzzing.*" + name: "fuzzing" + labels: + type: "$1" +``` + +Run `docker-compose up -d`. + +Everything should be now setup, you are now able to run your fuzzers with + +``` +AFL_STATSD_TAGS_FLAVOR=dogstatsd AFL_STATSD=1 afl-fuzz -M test-fuzzer-1 -i i -o o ./bin/my-application @@ +AFL_STATSD_TAGS_FLAVOR=dogstatsd AFL_STATSD=1 afl-fuzz -S test-fuzzer-2 -i i -o o ./bin/my-application @@ +... +``` + +This setup may be modified before use in production environment. Depending on your needs: addind passwords, creating volumes for storage, +tweaking the metrics gathering to get host metrics (CPU, RAM ...). \ No newline at end of file diff --git a/docs/statsd/grafana-afl++.json b/docs/statsd/grafana-afl++.json new file mode 100644 index 00000000..96e824de --- /dev/null +++ b/docs/statsd/grafana-afl++.json @@ -0,0 +1,1816 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 1, + "links": [], + "panels": [ + { + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 16, + "title": "Row title", + "type": "row" + }, + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [ + 500 + ], + "type": "lt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": [ + "A", + "5m", + "now" + ] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "5m", + "frequency": "1m", + "handler": 1, + "name": "Slow exec per sec", + "noDataState": "no_data", + "notifications": [] + }, + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 10, + "x": 0, + "y": 1 + }, + "hiddenSeries": false, + "id": 12, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"execs_per_sec\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "lt", + "value": 500 + } + ], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Exec/s", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 10, + "x": 10, + "y": 1 + }, + "hiddenSeries": false, + "id": 8, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"total_crashes\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Total Crashes", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 4, + "x": 20, + "y": 1 + }, + "hiddenSeries": false, + "id": 19, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"var_byte_count\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Var Byte Count", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 10, + "x": 0, + "y": 7 + }, + "hiddenSeries": false, + "id": 10, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"unique_crashes\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Unique Crashes", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 6, + "w": 10, + "x": 10, + "y": 7 + }, + "hiddenSeries": false, + "id": 14, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"unique_hangs\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Unique Hangs", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 0, + "y": 13 + }, + "hiddenSeries": false, + "id": 23, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"slowest_exec_ms\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Slowest Exec Ms", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 5, + "y": 13 + }, + "hiddenSeries": false, + "id": 4, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"cycle_done\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Cycles dones", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 10, + "y": 13 + }, + "hiddenSeries": false, + "id": 13, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"execs_done\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Total Execs", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 15, + "y": 13 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"cur_path\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Curent path", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 0, + "y": 18 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"cycles_wo_finds\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Cycles done without find", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 5, + "y": 18 + }, + "hiddenSeries": false, + "id": 25, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"paths_favored\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Path Favored", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 10, + "y": 18 + }, + "hiddenSeries": false, + "id": 22, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"havoc_expansion\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Havoc Expansion", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 15, + "y": 18 + }, + "hiddenSeries": false, + "id": 17, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"edges_found\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Edges Found", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 0, + "y": 23 + }, + "hiddenSeries": false, + "id": 24, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"paths_imported\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Path Imported", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 5, + "y": 23 + }, + "hiddenSeries": false, + "id": 21, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"pending_total\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Pending Total", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 10, + "y": 23 + }, + "hiddenSeries": false, + "id": 20, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"pending_favs\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Pending favs", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 5, + "w": 5, + "x": 15, + "y": 23 + }, + "hiddenSeries": false, + "id": 18, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": false, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.3.7", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "expr": "fuzzing{type=\"max_depth\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [ + { + "colorMode": "background6", + "fill": true, + "fillColor": "rgba(234, 112, 112, 0.12)", + "line": false, + "lineColor": "rgba(237, 46, 24, 0.60)", + "op": "time" + } + ], + "timeShift": null, + "title": "Max Depth", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": false, + "schemaVersion": 26, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-30m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "Fuzzing", + "uid": "sRI6PCfGz", + "version": 2 +} \ No newline at end of file diff --git a/docs/visualization/StatsD-grafana.png b/docs/visualization/StatsD-grafana.png new file mode 100644 index 00000000..1bdc1722 Binary files /dev/null and b/docs/visualization/StatsD-grafana.png differ -- cgit 1.4.1 From 822aea3cb497a971598f535b16dbd0c63c6d0e01 Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Mon, 25 Jan 2021 04:24:43 +0100 Subject: unicorn fix --- unicorn_mode/UNICORNAFL_VERSION | 2 +- unicorn_mode/samples/simple/simple_test_harness.py | 2 +- unicorn_mode/unicornafl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unicorn_mode/UNICORNAFL_VERSION b/unicorn_mode/UNICORNAFL_VERSION index a02531ec..4d8a03b2 100644 --- a/unicorn_mode/UNICORNAFL_VERSION +++ b/unicorn_mode/UNICORNAFL_VERSION @@ -1 +1 @@ -2a54500c +80d31ef3 diff --git a/unicorn_mode/samples/simple/simple_test_harness.py b/unicorn_mode/samples/simple/simple_test_harness.py index f4002ca8..4a673daf 100644 --- a/unicorn_mode/samples/simple/simple_test_harness.py +++ b/unicorn_mode/samples/simple/simple_test_harness.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """ Simple test harness for AFL's Unicorn Mode. diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 2a54500c..80d31ef3 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 2a54500c08758d29caacd1ccf47d034d9faa4a18 +Subproject commit 80d31ef367f7a1a75fc48e08e129d10f2ffa0498 -- cgit 1.4.1 From 9a7531942dd02797c69dd23ee8e13f504a8a30a7 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 25 Jan 2021 10:04:21 +0100 Subject: fix rpc_stats.md --- docs/Changelog.md | 2 ++ docs/rpc_statsd.md | 6 +++--- docs/visualization/StatsD-grafana.png | Bin 163646 -> 0 bytes docs/visualization/statsd-grafana.png | Bin 0 -> 163646 bytes 4 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 docs/visualization/StatsD-grafana.png create mode 100644 docs/visualization/statsd-grafana.png diff --git a/docs/Changelog.md b/docs/Changelog.md index 12f81571..5c6b0663 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -48,6 +48,8 @@ sending a mail to . - added dummy Makefile to instrumentation/ - Updated utils/afl_frida to be 5% faster - Added AFL_KILL_SIGNAL env variable (thanks @v-p-b) + - @Edznux added a nice documentation on how to use rpc.statsd with + afl++ in docs/rpc_statsd.md, thanks! ### Version ++3.00c (release) - llvm_mode/ and gcc_plugin/ moved to instrumentation/ diff --git a/docs/rpc_statsd.md b/docs/rpc_statsd.md index 26544ff5..02f72be6 100644 --- a/docs/rpc_statsd.md +++ b/docs/rpc_statsd.md @@ -31,9 +31,9 @@ By doing so, you might be able to see when the fuzzing process has reached a sta (according to your own criteria) for your targets, etc. And doing so without requiring to log into each instance manually. An example visualisation may look like the following: -![StatsD Grafana](./visualization/StatsD-grafana.png) +![StatsD Grafana](visualization/statsd-grafana.png) -*Notes: The exact same dashboard can be imported with [this JSON template](./statsd/grafana-afl++.json).* +*Notes: The exact same dashboard can be imported with [this JSON template](statsd/grafana-afl++.json).* ## How to use @@ -140,4 +140,4 @@ AFL_STATSD_TAGS_FLAVOR=dogstatsd AFL_STATSD=1 afl-fuzz -S test-fuzzer-2 -i i -o ``` This setup may be modified before use in production environment. Depending on your needs: addind passwords, creating volumes for storage, -tweaking the metrics gathering to get host metrics (CPU, RAM ...). \ No newline at end of file +tweaking the metrics gathering to get host metrics (CPU, RAM ...). diff --git a/docs/visualization/StatsD-grafana.png b/docs/visualization/StatsD-grafana.png deleted file mode 100644 index 1bdc1722..00000000 Binary files a/docs/visualization/StatsD-grafana.png and /dev/null differ diff --git a/docs/visualization/statsd-grafana.png b/docs/visualization/statsd-grafana.png new file mode 100644 index 00000000..1bdc1722 Binary files /dev/null and b/docs/visualization/statsd-grafana.png differ -- cgit 1.4.1 From cd8668ad3ace7d5e369d492197a7da787183c056 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 25 Jan 2021 13:55:09 +0100 Subject: mopt fix --- src/afl-fuzz-one.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c index 4ce22c08..a7262eec 100644 --- a/src/afl-fuzz-one.c +++ b/src/afl-fuzz-one.c @@ -4781,8 +4781,7 @@ pacemaker_fuzzing: } - afl->stage_cycles_puppet_v2[afl->swarm_now] - [STAGE_OverWriteExtra]++; + MOpt_globals.cycles_v2[STAGE_OverWriteExtra]++; break; @@ -4837,8 +4836,7 @@ pacemaker_fuzzing: memcpy(out_buf + insert_at, ptr, extra_len); temp_len += extra_len; - afl->stage_cycles_puppet_v2[afl->swarm_now][STAGE_InsertExtra] += - 1; + MOpt_globals.cycles_v2[STAGE_InsertExtra]++; break; } @@ -4920,7 +4918,7 @@ pacemaker_fuzzing: } - afl->stage_cycles_puppet_v2[afl->swarm_now][STAGE_Splice]++; + MOpt_globals.cycles_v2[STAGE_Splice]++; break; } // end of default: -- cgit 1.4.1 From 7c381a782e3bb05335df745ea6130c0a668463da Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 25 Jan 2021 20:18:42 +0100 Subject: enable cmplog combine --- src/afl-fuzz-redqueen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index d631332a..6721b8ef 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -29,7 +29,7 @@ #include "cmplog.h" //#define _DEBUG -//#define COMBINE +#define COMBINE //#define CMPLOG_INTROSPECTION //#define ARITHMETIC_LESSER_GREATER //#define TRANSFORM -- cgit 1.4.1 From e0663c91b9cbf1bdc46593dec4ba11224e6847d7 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 26 Jan 2021 12:15:13 +0100 Subject: wip fix --- src/afl-fuzz-init.c | 23 ++++++++++++++++++----- src/afl-fuzz-one.c | 13 +++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index fed58eb6..2cb152a9 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -1026,6 +1026,14 @@ void perform_dry_run(afl_state_t *afl) { /* Remove from fuzzing queue but keep for splicing */ struct queue_entry *p = afl->queue; + + if (!p->disabled && !p->was_fuzzed) { + + --afl->pending_not_fuzzed; + --afl->active_paths; + + } + p->disabled = 1; p->perf_score = 0; while (p && p->next != q) @@ -1036,9 +1044,6 @@ void perform_dry_run(afl_state_t *afl) { else afl->queue = q->next; - --afl->pending_not_fuzzed; - --afl->active_paths; - afl->max_depth = 0; p = afl->queue; while (p) { @@ -1123,8 +1128,16 @@ restart_outer_cull_loop: if (!p->cal_failed && p->exec_cksum == q->exec_cksum) { duplicates = 1; - --afl->pending_not_fuzzed; - afl->active_paths--; + if (!p->disabled && !q->disabled && !p->was_fuzzed && !q->was_fuzzed) { + + --afl->pending_not_fuzzed; + afl->active_paths--; + + } else { + + FATAL("disabled entry? this should not happen, please report!"); + + } // We do not remove any of the memory allocated because for // splicing the data might still be interesting. diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c index a7262eec..af768183 100644 --- a/src/afl-fuzz-one.c +++ b/src/afl-fuzz-one.c @@ -2782,11 +2782,16 @@ abandon_entry: cycle and have not seen this entry before. */ if (!afl->stop_soon && !afl->queue_cur->cal_failed && - (afl->queue_cur->was_fuzzed == 0 || afl->queue_cur->fuzz_level == 0)) { + (afl->queue_cur->was_fuzzed == 0 || afl->queue_cur->fuzz_level == 0) && + !afl->queue_cur->disabled) { - --afl->pending_not_fuzzed; - afl->queue_cur->was_fuzzed = 1; - if (afl->queue_cur->favored) { --afl->pending_favored; } + if (!afl->queue_cur->was_fuzzed) { + + --afl->pending_not_fuzzed; + afl->queue_cur->was_fuzzed = 1; + if (afl->queue_cur->favored) { --afl->pending_favored; } + + } } -- cgit 1.4.1 From 9c393adbb953fe5bf6809e5b0feca7be2f52b7f8 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 26 Jan 2021 17:12:11 +0100 Subject: real fix plus code format --- include/android-ashmem.h | 84 +++++++++++++++++++++++---------------------- src/afl-fuzz-init.c | 28 +++++++++------ src/afl-fuzz-queue.c | 2 +- src/afl-fuzz.c | 2 +- src/afl-showmap.c | 24 ++++++++++--- utils/afl_frida/afl-frida.c | 78 ++++++++++++++++++++++------------------- 6 files changed, 125 insertions(+), 93 deletions(-) diff --git a/include/android-ashmem.h b/include/android-ashmem.h index 6939e06d..91699b27 100644 --- a/include/android-ashmem.h +++ b/include/android-ashmem.h @@ -1,81 +1,83 @@ #ifdef __ANDROID__ -#ifndef _ANDROID_ASHMEM_H -#define _ANDROID_ASHMEM_H - -#include -#include -#include -#include - -#if __ANDROID_API__ >= 26 -#define shmat bionic_shmat -#define shmctl bionic_shmctl -#define shmdt bionic_shmdt -#define shmget bionic_shmget -#endif -#include -#undef shmat -#undef shmctl -#undef shmdt -#undef shmget -#include - -#define ASHMEM_DEVICE "/dev/ashmem" + #ifndef _ANDROID_ASHMEM_H + #define _ANDROID_ASHMEM_H + + #include + #include + #include + #include + + #if __ANDROID_API__ >= 26 + #define shmat bionic_shmat + #define shmctl bionic_shmctl + #define shmdt bionic_shmdt + #define shmget bionic_shmget + #endif + #include + #undef shmat + #undef shmctl + #undef shmdt + #undef shmget + #include + + #define ASHMEM_DEVICE "/dev/ashmem" int shmctl(int __shmid, int __cmd, struct shmid_ds *__buf) { + int ret = 0; if (__cmd == IPC_RMID) { - int length = ioctl(__shmid, ASHMEM_GET_SIZE, NULL); + + int length = ioctl(__shmid, ASHMEM_GET_SIZE, NULL); struct ashmem_pin pin = {0, length}; ret = ioctl(__shmid, ASHMEM_UNPIN, &pin); close(__shmid); + } return ret; + } int shmget(key_t __key, size_t __size, int __shmflg) { - (void) __shmflg; - int fd, ret; + + (void)__shmflg; + int fd, ret; char ourkey[11]; fd = open(ASHMEM_DEVICE, O_RDWR); - if (fd < 0) - return fd; + if (fd < 0) return fd; sprintf(ourkey, "%d", __key); ret = ioctl(fd, ASHMEM_SET_NAME, ourkey); - if (ret < 0) - goto error; + if (ret < 0) goto error; ret = ioctl(fd, ASHMEM_SET_SIZE, __size); - if (ret < 0) - goto error; + if (ret < 0) goto error; return fd; error: close(fd); return ret; + } void *shmat(int __shmid, const void *__shmaddr, int __shmflg) { - (void) __shmflg; - int size; + + (void)__shmflg; + int size; void *ptr; size = ioctl(__shmid, ASHMEM_GET_SIZE, NULL); - if (size < 0) { - return NULL; - } + if (size < 0) { return NULL; } ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, __shmid, 0); - if (ptr == MAP_FAILED) { - return NULL; - } + if (ptr == MAP_FAILED) { return NULL; } return ptr; + } -#endif /* !_ANDROID_ASHMEM_H */ -#endif /* !__ANDROID__ */ + #endif /* !_ANDROID_ASHMEM_H */ +#endif /* !__ANDROID__ */ + diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 2cb152a9..ed2010cd 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -1027,7 +1027,7 @@ void perform_dry_run(afl_state_t *afl) { struct queue_entry *p = afl->queue; - if (!p->disabled && !p->was_fuzzed) { + if (!p->was_fuzzed) { --afl->pending_not_fuzzed; --afl->active_paths; @@ -1128,16 +1128,6 @@ restart_outer_cull_loop: if (!p->cal_failed && p->exec_cksum == q->exec_cksum) { duplicates = 1; - if (!p->disabled && !q->disabled && !p->was_fuzzed && !q->was_fuzzed) { - - --afl->pending_not_fuzzed; - afl->active_paths--; - - } else { - - FATAL("disabled entry? this should not happen, please report!"); - - } // We do not remove any of the memory allocated because for // splicing the data might still be interesting. @@ -1147,6 +1137,14 @@ restart_outer_cull_loop: // we keep the shorter file if (p->len >= q->len) { + if (!p->was_fuzzed) { + + p->was_fuzzed = 1; + --afl->pending_not_fuzzed; + afl->active_paths--; + + } + p->disabled = 1; p->perf_score = 0; q->next = p->next; @@ -1154,6 +1152,14 @@ restart_outer_cull_loop: } else { + if (!q->was_fuzzed) { + + q->was_fuzzed = 1; + --afl->pending_not_fuzzed; + afl->active_paths--; + + } + q->disabled = 1; q->perf_score = 0; if (prev) diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c index 90f969d9..4442b400 100644 --- a/src/afl-fuzz-queue.c +++ b/src/afl-fuzz-queue.c @@ -317,7 +317,7 @@ static u8 check_if_text(afl_state_t *afl, struct queue_entry *q) { if (q->len < AFL_TXT_MIN_LEN) return 0; - u8 *buf; + u8 * buf; int fd; u32 len = q->len, offset = 0, ascii = 0, utf8 = 0; ssize_t comp; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 9b62e961..ecf69728 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -339,7 +339,7 @@ int main(int argc, char **argv_orig, char **envp) { afl_state_init(afl, map_size); afl->debug = debug; afl_fsrv_init(&afl->fsrv); - if (debug) { afl->fsrv.debug = true ; } + if (debug) { afl->fsrv.debug = true; } read_afl_environment(afl, envp); if (afl->shm.map_size) { afl->fsrv.map_size = afl->shm.map_size; } diff --git a/src/afl-showmap.c b/src/afl-showmap.c index ab47c602..5a0b6ecf 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -317,8 +317,16 @@ static void showmap_run_target_forkserver(afl_forkserver_t *fsrv, u8 *mem, } - if (fsrv->trace_bits[0] == 1) { fsrv->trace_bits[0] = 0; have_coverage = 1; } - else { have_coverage = 0; } + if (fsrv->trace_bits[0] == 1) { + + fsrv->trace_bits[0] = 0; + have_coverage = 1; + + } else { + + have_coverage = 0; + + } if (!no_classify) { classify_counts(fsrv); } @@ -493,8 +501,16 @@ static void showmap_run_target(afl_forkserver_t *fsrv, char **argv) { } - if (fsrv->trace_bits[0] == 1) { fsrv->trace_bits[0] = 0; have_coverage = 1; } - else { have_coverage = 0; } + if (fsrv->trace_bits[0] == 1) { + + fsrv->trace_bits[0] = 0; + have_coverage = 1; + + } else { + + have_coverage = 0; + + } if (!no_classify) { classify_counts(fsrv); } diff --git a/utils/afl_frida/afl-frida.c b/utils/afl_frida/afl-frida.c index 087f18e8..bf39be1c 100644 --- a/utils/afl_frida/afl-frida.c +++ b/utils/afl_frida/afl-frida.c @@ -153,7 +153,7 @@ static int enumerate_ranges(const GumRangeDetails *details, } -int main(int argc, char** argv) { +int main(int argc, char **argv) { #ifndef __APPLE__ (void)personality(ADDR_NO_RANDOMIZE); // disable ASLR @@ -166,10 +166,15 @@ int main(int argc, char** argv) { void *dl = NULL; if (argc > 2) { + dl = dlopen(argv[1], RTLD_LAZY); + } else { + dl = dlopen(TARGET_LIBRARY, RTLD_LAZY); + } + if (!dl) { if (argc > 2) @@ -197,17 +202,18 @@ int main(int argc, char** argv) { // END STEP 2 if (!getenv("AFL_FRIDA_TEST_INPUT")) { + gum_init_embedded(); if (!gum_stalker_is_supported()) { - + gum_deinit_embedded(); return 1; - + } - + GumStalker *stalker = gum_stalker_new(); - - GumAddress base_address; + + GumAddress base_address; if (argc > 2) base_address = gum_module_find_base_address(argv[1]); else @@ -215,87 +221,89 @@ int main(int argc, char** argv) { GumMemoryRange code_range; if (argc > 2) gum_module_enumerate_ranges(argv[1], GUM_PAGE_RX, enumerate_ranges, - &code_range); + &code_range); else gum_module_enumerate_ranges(TARGET_LIBRARY, GUM_PAGE_RX, enumerate_ranges, - &code_range); - + &code_range); + guint64 code_start = code_range.base_address; guint64 code_end = code_range.base_address + code_range.size; range_t instr_range = {0, code_start, code_end}; - + printf("Frida instrumentation: base=0x%lx instrumenting=0x%lx-%lx\n", base_address, code_start, code_end); if (!code_start || !code_end) { - + if (argc > 2) fprintf(stderr, "Error: no valid memory address found for %s\n", - argv[1]); + argv[1]); else fprintf(stderr, "Error: no valid memory address found for %s\n", - TARGET_LIBRARY); + TARGET_LIBRARY); exit(-1); - + } - + GumStalkerTransformer *transformer = gum_stalker_transformer_make_from_callback(instr_basic_block, &instr_range, NULL); - + // to ensure that the signatures are not optimized out memcpy(__afl_area_ptr, (void *)AFL_PERSISTENT, sizeof(AFL_PERSISTENT) + 1); memcpy(__afl_area_ptr + 32, (void *)AFL_DEFER_FORKSVR, sizeof(AFL_DEFER_FORKSVR) + 1); __afl_manual_init(); - + // // any expensive target library initialization that has to be done just once // - put that here // - + gum_stalker_follow_me(stalker, transformer, NULL); - + while (__afl_persistent_loop(UINT32_MAX) != 0) { - + previous_pc = 0; // Required! - - #ifdef _DEBUG + +#ifdef _DEBUG fprintf(stderr, "CLIENT crc: %016llx len: %u\n", hash64(__afl_fuzz_ptr, *__afl_fuzz_len), *__afl_fuzz_len); fprintf(stderr, "RECV:"); for (int i = 0; i < *__afl_fuzz_len; i++) fprintf(stderr, "%02x", __afl_fuzz_ptr[i]); fprintf(stderr, "\n"); - #endif - +#endif + // STEP 3: ensure the minimum length is present and setup the target // function to fuzz. - + if (*__afl_fuzz_len > 0) { - + __afl_fuzz_ptr[*__afl_fuzz_len] = 0; // if you need to null terminate (*o_function)(__afl_fuzz_ptr, *__afl_fuzz_len); - + } - + // END STEP 3 - + } - + gum_stalker_unfollow_me(stalker); - + while (gum_stalker_garbage_collect(stalker)) g_usleep(10000); - + g_object_unref(stalker); g_object_unref(transformer); gum_deinit_embedded(); } else { - char buf[8*1024] = {0}; - int count = read(0, buf, sizeof(buf)); - buf[8*1024-1] = '\0'; + + char buf[8 * 1024] = {0}; + int count = read(0, buf, sizeof(buf)); + buf[8 * 1024 - 1] = '\0'; (*o_function)(buf, count); + } return 0; -- cgit 1.4.1 From 36b5336152cd886d911f4299c3154b7817c94838 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 26 Jan 2021 22:45:59 +0100 Subject: better foreign sync name --- src/afl-fuzz-init.c | 15 ++++++++++++++- src/afl-fuzz-redqueen.c | 4 ++-- src/afl-fuzz.c | 10 ++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index ed2010cd..4f59a42f 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -460,6 +460,7 @@ void read_foreign_testcases(afl_state_t *afl, int first) { u32 i, iter; u8 val_buf[2][STRINGIFY_VAL_SIZE_MAX]; + u8 foreign_name[16]; for (iter = 0; iter < afl->foreign_sync_cnt; iter++) { @@ -468,6 +469,18 @@ void read_foreign_testcases(afl_state_t *afl, int first) { if (first) ACTF("Scanning '%s'...", afl->foreign_syncs[iter].dir); time_t ctime_max = 0; + u8 * name = rindex(afl->foreign_syncs[iter].dir, '/'); + if (!name) { name = afl->foreign_syncs[iter].dir; } + if (!strcmp(name, "queue") || !strcmp(name, "out") || + !strcmp(name, "default")) { + + snprintf(foreign_name, sizeof(foreign_name), "foreign_%u", iter); + + } else { + + snprintf(foreign_name, sizeof(foreign_name), "%s_%u", name, iter); + + } /* We use scandir() + alphasort() rather than readdir() because otherwise, the ordering of test cases would vary somewhat randomly and would be @@ -581,7 +594,7 @@ void read_foreign_testcases(afl_state_t *afl, int first) { write_to_testcase(afl, mem, st.st_size); fault = fuzz_run_target(afl, &afl->fsrv, afl->fsrv.exec_tmout); - afl->syncing_party = "foreign"; + afl->syncing_party = foreign_name; afl->queued_imported += save_if_interesting(afl, mem, st.st_size, fault); afl->syncing_party = 0; diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 6721b8ef..34db7231 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -249,7 +249,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, afl->stage_cur = 0; // in colorization we do not classify counts, hence we have to calculate - // the original checksum! + // the original checksum. if (unlikely(get_exec_checksum(afl, buf, len, &exec_cksum))) { goto checksum_fail; @@ -2368,7 +2368,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { u64 orig_hit_cnt, new_hit_cnt; u64 orig_execs = afl->fsrv.total_execs; orig_hit_cnt = afl->queued_paths + afl->unique_crashes; - u64 screen_update = 1000000 / afl->queue_cur->exec_us, + u64 screen_update = 100000 / afl->queue_cur->exec_us, execs = afl->fsrv.total_execs; afl->stage_name = "input-to-state"; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index ecf69728..b92aa2a7 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -559,6 +559,16 @@ int main(int argc, char **argv_orig, char **envp) { FATAL("Maximum %u entried of -F option can be specified", FOREIGN_SYNCS_MAX); afl->foreign_syncs[afl->foreign_sync_cnt].dir = optarg; + while (afl->foreign_syncs[afl->foreign_sync_cnt] + .dir[strlen(afl->foreign_syncs[afl->foreign_sync_cnt].dir) - + 1] == '/') { + + afl->foreign_syncs[afl->foreign_sync_cnt] + .dir[strlen(afl->foreign_syncs[afl->foreign_sync_cnt].dir) - 1] = + 0; + + } + afl->foreign_sync_cnt++; break; -- cgit 1.4.1 From a754694ac4fa7b4016fb9de3253b0f3fe691fdf1 Mon Sep 17 00:00:00 2001 From: fuzzah <60884276+fuzzah@users.noreply.github.com> Date: Wed, 27 Jan 2021 05:48:59 +0300 Subject: include limits.h to fix build on BSD systems --- src/afl-ld-lto.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/afl-ld-lto.c b/src/afl-ld-lto.c index 49c04e4a..1fb01600 100644 --- a/src/afl-ld-lto.c +++ b/src/afl-ld-lto.c @@ -45,6 +45,11 @@ #include +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ + defined(__DragonFly__) + #include +#endif + #ifdef __APPLE__ #include #endif -- cgit 1.4.1 From d046b28f2fb5981ce4a28ddcfac6ec3405624450 Mon Sep 17 00:00:00 2001 From: Adrian Panasiuk <4141848+ampanasiuk@users.noreply.github.com> Date: Wed, 27 Jan 2021 01:12:13 +0000 Subject: Fix "src" attribute in sync stage filenames (#703) --- src/afl-fuzz-run.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/afl-fuzz-run.c b/src/afl-fuzz-run.c index 17c305ed..97cb7415 100644 --- a/src/afl-fuzz-run.c +++ b/src/afl-fuzz-run.c @@ -627,9 +627,8 @@ void sync_fuzzers(afl_state_t *afl) { } if (m >= n) { goto close_sync; } // nothing new - o = n - 1; - while (o >= m) { + for (o = m; o < n; o++) { s32 fd; struct stat st; @@ -637,7 +636,6 @@ void sync_fuzzers(afl_state_t *afl) { snprintf(path, sizeof(path), "%s/%s", qd_path, namelist[o]->d_name); afl->syncing_case = next_min_accept; next_min_accept++; - o--; /* Allow this to fail in case the other fuzzer is resuming or so... */ -- cgit 1.4.1 From f571f074a858ee0cce6664f2003e42adb75c3697 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 27 Jan 2021 08:21:22 +0100 Subject: update envs --- include/envs.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/envs.h b/include/envs.h index 97367fae..756cd737 100644 --- a/include/envs.h +++ b/include/envs.h @@ -42,11 +42,13 @@ static char *afl_environment_variables[] = { "AFL_DEBUG_GDB", "AFL_DISABLE_TRIM", "AFL_DONT_OPTIMIZE", + "AFL_DRIVER_STDERR_DUPLICATE_FILENAME", "AFL_DUMB_FORKSRV", "AFL_ENTRYPOINT", "AFL_EXIT_WHEN_DONE", "AFL_FAST_CAL", "AFL_FORCE_UI", + "AFL_FUZZER_ARGS". // oss-fuzz "AFL_GCC_ALLOWLIST", "AFL_GCC_DENYLIST", "AFL_GCC_BLOCKLIST", -- cgit 1.4.1 From 2044c7e2b548e2747fde5deff65c78dd05e2ec8d Mon Sep 17 00:00:00 2001 From: van Hauser Date: Wed, 27 Jan 2021 08:41:45 +0100 Subject: fix include --- include/envs.h | 2 +- src/afl-fuzz-init.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/envs.h b/include/envs.h index 756cd737..931cff15 100644 --- a/include/envs.h +++ b/include/envs.h @@ -48,7 +48,7 @@ static char *afl_environment_variables[] = { "AFL_EXIT_WHEN_DONE", "AFL_FAST_CAL", "AFL_FORCE_UI", - "AFL_FUZZER_ARGS". // oss-fuzz + "AFL_FUZZER_ARGS", // oss-fuzz "AFL_GCC_ALLOWLIST", "AFL_GCC_DENYLIST", "AFL_GCC_BLOCKLIST", diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 4f59a42f..a428923d 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -482,9 +482,8 @@ void read_foreign_testcases(afl_state_t *afl, int first) { } - /* We use scandir() + alphasort() rather than readdir() because otherwise, - the ordering of test cases would vary somewhat randomly and would be - difficult to control. */ + /* We do not use sorting yet and do a more expensive ctime check instead. + a ctimesort() implementation would be better though. */ nl_cnt = scandir(afl->foreign_syncs[iter].dir, &nl, NULL, NULL); -- cgit 1.4.1 From 9bc8c7518f9d3ac784365b095de9df761af7dda9 Mon Sep 17 00:00:00 2001 From: "Josh Bundt (tr0gd0r)" Date: Wed, 27 Jan 2021 22:39:33 -0500 Subject: enable warnings for LTO mode 's/warn /warning /' --- GNUmakefile.llvm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GNUmakefile.llvm b/GNUmakefile.llvm index 3554c8bf..a9092579 100644 --- a/GNUmakefile.llvm +++ b/GNUmakefile.llvm @@ -208,12 +208,12 @@ ifeq "$(LLVM_LTO)" "1" ifneq "$(shell readlink $(LLVM_BINDIR)/ld.lld 2>&1)" "" AFL_REAL_LD = $(LLVM_BINDIR)/ld.lld else - $(warn ld.lld not found, cannot enable LTO mode) + $(warning ld.lld not found, cannot enable LTO mode) LLVM_LTO = 0 endif endif else - $(warn clang option -flto is not working - maybe LLVMgold.so not found - cannot enable LTO mode) + $(warning clang option -flto is not working - maybe LLVMgold.so not found - cannot enable LTO mode) LLVM_LTO = 0 endif endif @@ -226,7 +226,7 @@ ifeq "$(LLVM_LTO)" "1" AFL_CLANG_LDPATH=1 endif else - $(warn -fuse-ld is not working, cannot enable LTO mode) + $(warning -fuse-ld is not working, cannot enable LTO mode) LLVM_LTO = 0 endif endif -- cgit 1.4.1 From 47f62eb0ca087bf26e79f2f0ce5935eda2599064 Mon Sep 17 00:00:00 2001 From: Joey Jiaojg <77719320+joeyjiaojg@users.noreply.github.com> Date: Thu, 28 Jan 2021 12:51:45 +0800 Subject: Fix dev branch for android (#710) * android: replace rindex with strrchr * android: support 64bit only due to 128bit integer not supported by 32bit system Co-authored-by: joeyjiaojg@qq.com --- Android.bp | 4 +++- src/afl-fuzz-init.c | 2 +- utils/afl_untracer/afl-untracer.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Android.bp b/Android.bp index 5d6f0433..ee076d1e 100644 --- a/Android.bp +++ b/Android.bp @@ -36,6 +36,7 @@ cc_defaults { cc_binary { name: "afl-fuzz", host_supported: true, + compile_multilib: "64", defaults: [ "afl-defaults", @@ -64,6 +65,7 @@ cc_binary { "src/afl-common.c", "src/afl-sharedmem.c", "src/afl-forkserver.c", + "src/afl-performance.c", ], } @@ -152,7 +154,7 @@ cc_binary_host { cc_library_static { name: "afl-llvm-rt", - compile_multilib: "both", + compile_multilib: "64", vendor_available: true, host_supported: true, recovery_available: true, diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index a428923d..5f5e65cd 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -469,7 +469,7 @@ void read_foreign_testcases(afl_state_t *afl, int first) { if (first) ACTF("Scanning '%s'...", afl->foreign_syncs[iter].dir); time_t ctime_max = 0; - u8 * name = rindex(afl->foreign_syncs[iter].dir, '/'); + u8 * name = strrchr(afl->foreign_syncs[iter].dir, '/'); if (!name) { name = afl->foreign_syncs[iter].dir; } if (!strcmp(name, "queue") || !strcmp(name, "out") || !strcmp(name, "default")) { diff --git a/utils/afl_untracer/afl-untracer.c b/utils/afl_untracer/afl-untracer.c index 695f8dd1..f3894a06 100644 --- a/utils/afl_untracer/afl-untracer.c +++ b/utils/afl_untracer/afl-untracer.c @@ -143,7 +143,7 @@ void read_library_information(void) { b = buf; m = index(buf, '-'); e = index(buf, ' '); - if ((n = rindex(buf, '/')) == NULL) n = rindex(buf, ' '); + if ((n = strrchr(buf, '/')) == NULL) n = strrchr(buf, ' '); if (n && ((*n >= '0' && *n <= '9') || *n == '[' || *n == '{' || *n == '(')) n = NULL; -- cgit 1.4.1 From ad63ba49c181dd97786745913c6b2ade5ae69728 Mon Sep 17 00:00:00 2001 From: Yuan Date: Thu, 28 Jan 2021 17:21:54 +0800 Subject: Fix getopt arg string There is no '-P' case here. --- src/afl-fuzz.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index b92aa2a7..a1f749b5 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -357,7 +357,7 @@ int main(int argc, char **argv_orig, char **envp) { while ((opt = getopt( argc, argv, - "+b:B:c:CdDe:E:hi:I:f:F:l:L:m:M:nNo:p:P:RQs:S:t:T:UV:Wx:Z")) > + "+b:B:c:CdDe:E:hi:I:f:F:l:L:m:M:nNo:p:RQs:S:t:T:UV:Wx:Z")) > 0) { switch (opt) { -- cgit 1.4.1 From a61a30dee03aced16d117150c4dbfd7079de7e68 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 28 Jan 2021 14:11:33 +0100 Subject: fix another pending_not_fuzzed location --- src/afl-fuzz-extras.c | 2 +- src/afl-fuzz-init.c | 5 +++-- src/afl-fuzz-one.c | 4 ++-- src/afl-fuzz.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/afl-fuzz-extras.c b/src/afl-fuzz-extras.c index a3583651..7ecad233 100644 --- a/src/afl-fuzz-extras.c +++ b/src/afl-fuzz-extras.c @@ -413,7 +413,7 @@ void dedup_extras(afl_state_t *afl) { if (j + 1 < afl->extras_cnt) // not at the end of the list? memmove((char *)&afl->extras[j], (char *)&afl->extras[j + 1], (afl->extras_cnt - j - 1) * sizeof(struct extra_data)); - afl->extras_cnt--; + --afl->extras_cnt; goto restart_dedup; // restart if several duplicates are in a row } diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 5f5e65cd..84f81112 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -1041,6 +1041,7 @@ void perform_dry_run(afl_state_t *afl) { if (!p->was_fuzzed) { + p->was_fuzzed = 1; --afl->pending_not_fuzzed; --afl->active_paths; @@ -1153,7 +1154,7 @@ restart_outer_cull_loop: p->was_fuzzed = 1; --afl->pending_not_fuzzed; - afl->active_paths--; + --afl->active_paths; } @@ -1168,7 +1169,7 @@ restart_outer_cull_loop: q->was_fuzzed = 1; --afl->pending_not_fuzzed; - afl->active_paths--; + --afl->active_paths; } diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c index af768183..ff766158 100644 --- a/src/afl-fuzz-one.c +++ b/src/afl-fuzz-one.c @@ -530,7 +530,7 @@ u8 fuzz_one_original(afl_state_t *afl) { len = afl->queue_cur->len; /* maybe current entry is not ready for splicing anymore */ - if (unlikely(len <= 4 && old_len > 4)) afl->ready_for_splicing_count--; + if (unlikely(len <= 4 && old_len > 4)) --afl->ready_for_splicing_count; } @@ -2958,7 +2958,7 @@ static u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) { len = afl->queue_cur->len; /* maybe current entry is not ready for splicing anymore */ - if (unlikely(len <= 4 && old_len > 4)) afl->ready_for_splicing_count--; + if (unlikely(len <= 4 && old_len > 4)) --afl->ready_for_splicing_count; } diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index a1f749b5..e856730e 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1636,7 +1636,7 @@ int main(int argc, char **argv_orig, char **envp) { (afl->old_seed_selection && !afl->queue_cur))) { ++afl->queue_cycle; - runs_in_current_cycle = 0; + runs_in_current_cycle = (u32)-1; afl->cur_skipped_paths = 0; if (unlikely(afl->old_seed_selection)) { -- cgit 1.4.1 From 2a9fcd2a87bf11bc019c8d6be2b6eda77b772ee2 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 28 Jan 2021 18:01:27 +0100 Subject: warn on afl-gcc/afl-clang instrumentation --- src/afl-cc.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/afl-cc.c b/src/afl-cc.c index 8e7af0f9..ff0f3c07 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -1788,6 +1788,15 @@ int main(int argc, char **argv, char **envp) { } + if (!be_quiet && (compiler_mode == GCC || compiler_mode == CLANG)) { + + WARNF( + "You are using outdated instrumentation, install LLVM and/or " + "gcc-plugin and use afl-clang-fast/afl-clang-lto/afl-gcc-fast " + "instead!"); + + } + if (debug) { DEBUGF("cd '%s';", getthecwd()); -- cgit 1.4.1 From d5a170655f913da851f2a572b522b8d5ae76c292 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Thu, 28 Jan 2021 19:08:36 +0100 Subject: update qemuafl --- qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/qemuafl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index a3db2bfa..c7f33eea 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -62928c65b7 +a5113bb078 diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index 62928c65..a5113bb0 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit 62928c65b75f93926c00361a595362e00cc025ff +Subproject commit a5113bb0787f09950985b821f682042c2eb367b8 -- cgit 1.4.1 From ce673ccab3f2ca438f879c1d2e63988eb9737a35 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Thu, 28 Jan 2021 19:19:57 +0100 Subject: remove snapshot reference --- src/afl-cc.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index ff0f3c07..b5dcb632 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -1438,34 +1438,34 @@ int main(int argc, char **argv, char **envp) { " CC=afl-cc CXX=afl-c++ meson\n\n"); SAYF( - " |---------------- FEATURES " - "---------------|\n" - "MODES: NCC PERSIST SNAP DICT LAF " + " |------------- FEATURES " + "-------------|\n" + "MODES: NCC PERSIST DICT LAF " "CMPLOG SELECT\n" " [LTO] llvm LTO: %s%s\n" - " PCGUARD DEFAULT yes yes yes yes yes yes " + " PCGUARD DEFAULT yes yes yes yes yes " " yes\n" - " CLASSIC yes yes yes yes yes yes " + " CLASSIC yes yes yes yes yes " " yes\n" " [LLVM] llvm: %s%s\n" - " PCGUARD %s yes yes yes module yes yes " + " PCGUARD %s yes yes module yes yes " "extern\n" - " CLASSIC %s no yes yes module yes yes " + " CLASSIC %s no yes module yes yes " "yes\n" " - NORMAL\n" " - CTX\n" " - NGRAM-{2-16}\n" - " INSTRIM no yes yes module yes yes " + " INSTRIM no yes module yes yes " " yes\n" " - NORMAL\n" " - CTX\n" " - NGRAM-{2-16}\n" " [GCC_PLUGIN] gcc plugin: %s%s\n" - " CLASSIC DEFAULT no yes yes no no no " - " yes\n" + " CLASSIC DEFAULT no yes no no no " + "yes\n" " [GCC/CLANG] simple gcc/clang: %s%s\n" - " CLASSIC DEFAULT no no no no no no " - " no\n\n", + " CLASSIC DEFAULT no no no no no " + "no\n\n", have_lto ? "AVAILABLE" : "unavailable!", compiler_mode == LTO ? " [SELECTED]" : "", have_llvm ? "AVAILABLE" : "unavailable!", @@ -1520,9 +1520,6 @@ int main(int argc, char **argv, char **envp) { " (instrumentation/README.lto.md)\n" " PERSIST: persistent mode support [code] (huge speed increase!)\n" " (instrumentation/README.persistent_mode.md)\n" - " SNAP: linux lkm snapshot module support [automatic] (speed " - "increase)\n" - " (https://github.com/AFLplusplus/AFL-Snapshot-LKM/)\n" " DICT: dictionary in the target [yes=automatic or llvm module " "pass]\n" " (instrumentation/README.lto.md + " -- cgit 1.4.1 From 0c616087e01c17247f2ab8ca378208e4e3c4403c Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 29 Jan 2021 10:17:32 +0100 Subject: Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 31 +++++++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..d62da0a8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,31 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**IMPORTANT** +1. You have verified that the issue to be present in the current `dev` branch +2. Please supply the command line options and relevant environment variables, e.g. a copy-paste of the contents of `out/default/fuzzer_setup` + +Thank you for making afl++ better! + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. ... +2. ... + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screen output/Screenshots** +If applicable, add copy-paste of the screen output or screenshot that shows the issue. Please ensure the output is in **English** and not in Chinese, Russian, German, etc. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..bbcbbe7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. -- cgit 1.4.1 From 1b1006ddd418192cfbf5d613b49edd53b424ded5 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 13:04:03 +0100 Subject: qemuafl --- qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/qemuafl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index c7f33eea..d57730bc 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -a5113bb078 +1d494849ff diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index a5113bb0..1d494849 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit a5113bb0787f09950985b821f682042c2eb367b8 +Subproject commit 1d494849ff353d35951954e6d8f78a220300f79d -- cgit 1.4.1 From d21ca3e48095ebba72e2c40aff1437a49882a415 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 15:14:20 +0100 Subject: libqasan and use target cross compiler to compile target qemu libs --- qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/build_qemu_support.sh | 21 +- qemu_mode/libqasan/Makefile | 44 + qemu_mode/libqasan/README.md | 1 + qemu_mode/libqasan/dlmalloc.c | 6332 +++++++++++++++++++++++++++++++++++++ qemu_mode/libqasan/hooks.c | 659 ++++ qemu_mode/libqasan/libqasan.c | 94 + qemu_mode/libqasan/libqasan.h | 131 + qemu_mode/libqasan/malloc.c | 315 ++ qemu_mode/libqasan/map_macro.h | 74 + qemu_mode/libqasan/patch.c | 243 ++ qemu_mode/libqasan/string.c | 339 ++ qemu_mode/libqasan/uninstrument.c | 83 + qemu_mode/qemuafl | 2 +- qemu_mode/unsigaction/Makefile | 12 +- 15 files changed, 8338 insertions(+), 14 deletions(-) create mode 100644 qemu_mode/libqasan/Makefile create mode 100644 qemu_mode/libqasan/README.md create mode 100644 qemu_mode/libqasan/dlmalloc.c create mode 100644 qemu_mode/libqasan/hooks.c create mode 100644 qemu_mode/libqasan/libqasan.c create mode 100644 qemu_mode/libqasan/libqasan.h create mode 100644 qemu_mode/libqasan/malloc.c create mode 100644 qemu_mode/libqasan/map_macro.h create mode 100644 qemu_mode/libqasan/patch.c create mode 100644 qemu_mode/libqasan/string.c create mode 100644 qemu_mode/libqasan/uninstrument.c diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index d57730bc..1bdaf108 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -1d494849ff +a8a45d93f5 diff --git a/qemu_mode/build_qemu_support.sh b/qemu_mode/build_qemu_support.sh index 608db9e4..cef6ca07 100755 --- a/qemu_mode/build_qemu_support.sh +++ b/qemu_mode/build_qemu_support.sh @@ -360,10 +360,23 @@ else fi -echo "[+] Building libcompcov ..." -make -C libcompcov && echo "[+] libcompcov ready" -echo "[+] Building unsigaction ..." -make -C unsigaction && echo "[+] unsigaction ready" +ORIG_CROSS="$CROSS" + +if [ "$ORIG_CROSS" = "" ]; then + CROSS=$CPU_TARGET-linux-gnu-gcc +fi + +if ! command -v "$CROSS" &> /dev/null +then + echo "[!] Cross compiler $CROSS could not be found, cannot compile libcompcov libqasan and unsigaction" +else + echo "[+] Building libcompcov ..." + make -C libcompcov CC=$CROSS && echo "[+] libcompcov ready" + echo "[+] Building unsigaction ..." + make -C unsigaction CC=$CROSS && echo "[+] unsigaction ready" + echo "[+] Building libqasan ..." + make -C libqasan CC=$CROSS && echo "[+] unsigaction ready" +fi echo "[+] All done for qemu_mode, enjoy!" diff --git a/qemu_mode/libqasan/Makefile b/qemu_mode/libqasan/Makefile new file mode 100644 index 00000000..f91debb6 --- /dev/null +++ b/qemu_mode/libqasan/Makefile @@ -0,0 +1,44 @@ +# +# american fuzzy lop++ - libqasan +# ------------------------------- +# +# Written by Andrea Fioraldi +# +# Copyright 2019-2020 Andrea Fioraldi. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# + +PREFIX ?= /usr/local +HELPER_PATH = $(PREFIX)/lib/afl +DOC_PATH ?= $(PREFIX)/share/doc/afl +MAN_PATH ?= $(PREFIX)/share/man/man8 + +VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2) + +CFLAGS += -I ../qemuafl/qemuafl/ +CFLAGS += -Wno-int-to-void-pointer-cast -ggdb +LDFLAGS += -ldl -pthread + +SRC := libqasan.c hooks.c malloc.c string.c uninstrument.c patch.c dlmalloc.c +HDR := libqasan.h + +all: libqasan.so + +libqasan.so: $(HDR) $(SRC) + $(CC) $(CFLAGS) -fPIC -shared $(SRC) -o ../../$@ $(LDFLAGS) + +.NOTPARALLEL: clean + +clean: + rm -f *.o *.so *~ a.out core core.[1-9][0-9]* + rm -f ../../libqasan.so + +install: all + install -m 755 ../../libqasan.so $${DESTDIR}$(HELPER_PATH) + install -m 644 -T README.md $${DESTDIR}$(DOC_PATH)/README.qasan.md + diff --git a/qemu_mode/libqasan/README.md b/qemu_mode/libqasan/README.md new file mode 100644 index 00000000..1333ed77 --- /dev/null +++ b/qemu_mode/libqasan/README.md @@ -0,0 +1 @@ +TODO diff --git a/qemu_mode/libqasan/dlmalloc.c b/qemu_mode/libqasan/dlmalloc.c new file mode 100644 index 00000000..0cdd4a90 --- /dev/null +++ b/qemu_mode/libqasan/dlmalloc.c @@ -0,0 +1,6332 @@ +/* + This is a version (aka dlmalloc) of malloc/free/realloc written by + Doug Lea and released to the public domain, as explained at + http://creativecommons.org/publicdomain/zero/1.0/ Send questions, + comments, complaints, performance data, etc to dl@cs.oswego.edu + +* Version 2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea + Note: There may be an updated version of this malloc obtainable at + ftp://gee.cs.oswego.edu/pub/misc/malloc.c + Check before installing! + +* Quickstart + + This library is all in one file to simplify the most common usage: + ftp it, compile it (-O3), and link it into another program. All of + the compile-time options default to reasonable values for use on + most platforms. You might later want to step through various + compile-time and dynamic tuning options. + + For convenience, an include file for code using this malloc is at: + ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.6.h + You don't really need this .h file unless you call functions not + defined in your system include files. The .h file contains only the + excerpts from this file needed for using this malloc on ANSI C/C++ + systems, so long as you haven't changed compile-time options about + naming and tuning parameters. If you do, then you can create your + own malloc.h that does include all settings by cutting at the point + indicated below. Note that you may already by default be using a C + library containing a malloc that is based on some version of this + malloc (for example in linux). You might still want to use the one + in this file to customize settings or to avoid overheads associated + with library versions. + +* Vital statistics: + + Supported pointer/size_t representation: 4 or 8 bytes + size_t MUST be an unsigned type of the same width as + pointers. (If you are using an ancient system that declares + size_t as a signed type, or need it to be a different width + than pointers, you can use a previous release of this malloc + (e.g. 2.7.2) supporting these.) + + Alignment: 8 bytes (minimum) + This suffices for nearly all current machines and C compilers. + However, you can define MALLOC_ALIGNMENT to be wider than this + if necessary (up to 128bytes), at the expense of using more space. + + Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes) + 8 or 16 bytes (if 8byte sizes) + Each malloced chunk has a hidden word of overhead holding size + and status information, and additional cross-check word + if FOOTERS is defined. + + Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead) + 8-byte ptrs: 32 bytes (including overhead) + + Even a request for zero bytes (i.e., malloc(0)) returns a + pointer to something of the minimum allocatable size. + The maximum overhead wastage (i.e., number of extra bytes + allocated than were requested in malloc) is less than or equal + to the minimum size, except for requests >= mmap_threshold that + are serviced via mmap(), where the worst case wastage is about + 32 bytes plus the remainder from a system page (the minimal + mmap unit); typically 4096 or 8192 bytes. + + Security: static-safe; optionally more or less + The "security" of malloc refers to the ability of malicious + code to accentuate the effects of errors (for example, freeing + space that is not currently malloc'ed or overwriting past the + ends of chunks) in code that calls malloc. This malloc + guarantees not to modify any memory locations below the base of + heap, i.e., static variables, even in the presence of usage + errors. The routines additionally detect most improper frees + and reallocs. All this holds as long as the static bookkeeping + for malloc itself is not corrupted by some other means. This + is only one aspect of security -- these checks do not, and + cannot, detect all possible programming errors. + + If FOOTERS is defined nonzero, then each allocated chunk + carries an additional check word to verify that it was malloced + from its space. These check words are the same within each + execution of a program using malloc, but differ across + executions, so externally crafted fake chunks cannot be + freed. This improves security by rejecting frees/reallocs that + could corrupt heap memory, in addition to the checks preventing + writes to statics that are always on. This may further improve + security at the expense of time and space overhead. (Note that + FOOTERS may also be worth using with MSPACES.) + + By default detected errors cause the program to abort (calling + "abort()"). You can override this to instead proceed past + errors by defining PROCEED_ON_ERROR. In this case, a bad free + has no effect, and a malloc that encounters a bad address + caused by user overwrites will ignore the bad address by + dropping pointers and indices to all known memory. This may + be appropriate for programs that should continue if at all + possible in the face of programming errors, although they may + run out of memory because dropped memory is never reclaimed. + + If you don't like either of these options, you can define + CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything + else. And if if you are sure that your program using malloc has + no errors or vulnerabilities, you can define INSECURE to 1, + which might (or might not) provide a small performance improvement. + + It is also possible to limit the maximum total allocatable + space, using malloc_set_footprint_limit. This is not + designed as a security feature in itself (calls to set limits + are not screened or privileged), but may be useful as one + aspect of a secure implementation. + + Thread-safety: NOT thread-safe unless USE_LOCKS defined non-zero + When USE_LOCKS is defined, each public call to malloc, free, + etc is surrounded with a lock. By default, this uses a plain + pthread mutex, win32 critical section, or a spin-lock if if + available for the platform and not disabled by setting + USE_SPIN_LOCKS=0. However, if USE_RECURSIVE_LOCKS is defined, + recursive versions are used instead (which are not required for + base functionality but may be needed in layered extensions). + Using a global lock is not especially fast, and can be a major + bottleneck. It is designed only to provide minimal protection + in concurrent environments, and to provide a basis for + extensions. If you are using malloc in a concurrent program, + consider instead using nedmalloc + (http://www.nedprod.com/programs/portable/nedmalloc/) or + ptmalloc (See http://www.malloc.de), which are derived from + versions of this malloc. + + System requirements: Any combination of MORECORE and/or MMAP/MUNMAP + This malloc can use unix sbrk or any emulation (invoked using + the CALL_MORECORE macro) and/or mmap/munmap or any emulation + (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system + memory. On most unix systems, it tends to work best if both + MORECORE and MMAP are enabled. On Win32, it uses emulations + based on VirtualAlloc. It also uses common C library functions + like memset. + + Compliance: I believe it is compliant with the Single Unix Specification + (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably + others as well. + +* Overview of algorithms + + This is not the fastest, most space-conserving, most portable, or + most tunable malloc ever written. However it is among the fastest + while also being among the most space-conserving, portable and + tunable. Consistent balance across these factors results in a good + general-purpose allocator for malloc-intensive programs. + + In most ways, this malloc is a best-fit allocator. Generally, it + chooses the best-fitting existing chunk for a request, with ties + broken in approximately least-recently-used order. (This strategy + normally maintains low fragmentation.) However, for requests less + than 256bytes, it deviates from best-fit when there is not an + exactly fitting available chunk by preferring to use space adjacent + to that used for the previous small request, as well as by breaking + ties in approximately most-recently-used order. (These enhance + locality of series of small allocations.) And for very large requests + (>= 256Kb by default), it relies on system memory mapping + facilities, if supported. (This helps avoid carrying around and + possibly fragmenting memory used only for large chunks.) + + All operations (except malloc_stats and mallinfo) have execution + times that are bounded by a constant factor of the number of bits in + a size_t, not counting any clearing in calloc or copying in realloc, + or actions surrounding MORECORE and MMAP that have times + proportional to the number of non-contiguous regions returned by + system allocation routines, which is often just 1. In real-time + applications, you can optionally suppress segment traversals using + NO_SEGMENT_TRAVERSAL, which assures bounded execution even when + system allocators return non-contiguous spaces, at the typical + expense of carrying around more memory and increased fragmentation. + + The implementation is not very modular and seriously overuses + macros. Perhaps someday all C compilers will do as good a job + inlining modular code as can now be done by brute-force expansion, + but now, enough of them seem not to. + + Some compilers issue a lot of warnings about code that is + dead/unreachable only on some platforms, and also about intentional + uses of negation on unsigned types. All known cases of each can be + ignored. + + For a longer but out of date high-level description, see + http://gee.cs.oswego.edu/dl/html/malloc.html + +* MSPACES + If MSPACES is defined, then in addition to malloc, free, etc., + this file also defines mspace_malloc, mspace_free, etc. These + are versions of malloc routines that take an "mspace" argument + obtained using create_mspace, to control all internal bookkeeping. + If ONLY_MSPACES is defined, only these versions are compiled. + So if you would like to use this allocator for only some allocations, + and your system malloc for others, you can compile with + ONLY_MSPACES and then do something like... + static mspace mymspace = create_mspace(0,0); // for example + #define mymalloc(bytes) mspace_malloc(mymspace, bytes) + + (Note: If you only need one instance of an mspace, you can instead + use "USE_DL_PREFIX" to relabel the global malloc.) + + You can similarly create thread-local allocators by storing + mspaces as thread-locals. For example: + static __thread mspace tlms = 0; + void* tlmalloc(size_t bytes) { + if (tlms == 0) tlms = create_mspace(0, 0); + return mspace_malloc(tlms, bytes); + } + void tlfree(void* mem) { mspace_free(tlms, mem); } + + Unless FOOTERS is defined, each mspace is completely independent. + You cannot allocate from one and free to another (although + conformance is only weakly checked, so usage errors are not always + caught). If FOOTERS is defined, then each chunk carries around a tag + indicating its originating mspace, and frees are directed to their + originating spaces. Normally, this requires use of locks. + + ------------------------- Compile-time options --------------------------- + +Be careful in setting #define values for numerical constants of type +size_t. On some systems, literal values are not automatically extended +to size_t precision unless they are explicitly casted. You can also +use the symbolic values MAX_SIZE_T, SIZE_T_ONE, etc below. + +WIN32 default: defined if _WIN32 defined + Defining WIN32 sets up defaults for MS environment and compilers. + Otherwise defaults are for unix. Beware that there seem to be some + cases where this malloc might not be a pure drop-in replacement for + Win32 malloc: Random-looking failures from Win32 GDI API's (eg; + SetDIBits()) may be due to bugs in some video driver implementations + when pixel buffers are malloc()ed, and the region spans more than + one VirtualAlloc()ed region. Because dlmalloc uses a small (64Kb) + default granularity, pixel buffers may straddle virtual allocation + regions more often than when using the Microsoft allocator. You can + avoid this by using VirtualAlloc() and VirtualFree() for all pixel + buffers rather than using malloc(). If this is not possible, + recompile this malloc with a larger DEFAULT_GRANULARITY. Note: + in cases where MSC and gcc (cygwin) are known to differ on WIN32, + conditions use _MSC_VER to distinguish them. + +DLMALLOC_EXPORT default: extern + Defines how public APIs are declared. If you want to export via a + Windows DLL, you might define this as + #define DLMALLOC_EXPORT extern __declspec(dllexport) + If you want a POSIX ELF shared object, you might use + #define DLMALLOC_EXPORT extern __attribute__((visibility("default"))) + +MALLOC_ALIGNMENT default: (size_t)(2 * sizeof(void *)) + Controls the minimum alignment for malloc'ed chunks. It must be a + power of two and at least 8, even on machines for which smaller + alignments would suffice. It may be defined as larger than this + though. Note however that code and data structures are optimized for + the case of 8-byte alignment. + +MSPACES default: 0 (false) + If true, compile in support for independent allocation spaces. + This is only supported if HAVE_MMAP is true. + +ONLY_MSPACES default: 0 (false) + If true, only compile in mspace versions, not regular versions. + +USE_LOCKS default: 0 (false) + Causes each call to each public routine to be surrounded with + pthread or WIN32 mutex lock/unlock. (If set true, this can be + overridden on a per-mspace basis for mspace versions.) If set to a + non-zero value other than 1, locks are used, but their + implementation is left out, so lock functions must be supplied manually, + as described below. + +USE_SPIN_LOCKS default: 1 iff USE_LOCKS and spin locks available + If true, uses custom spin locks for locking. This is currently + supported only gcc >= 4.1, older gccs on x86 platforms, and recent + MS compilers. Otherwise, posix locks or win32 critical sections are + used. + +USE_RECURSIVE_LOCKS default: not defined + If defined nonzero, uses recursive (aka reentrant) locks, otherwise + uses plain mutexes. This is not required for malloc proper, but may + be needed for layered allocators such as nedmalloc. + +LOCK_AT_FORK default: not defined + If defined nonzero, performs pthread_atfork upon initialization + to initialize child lock while holding parent lock. The implementation + assumes that pthread locks (not custom locks) are being used. In other + cases, you may need to customize the implementation. + +FOOTERS default: 0 + If true, provide extra checking and dispatching by placing + information in the footers of allocated chunks. This adds + space and time overhead. + +INSECURE default: 0 + If true, omit checks for usage errors and heap space overwrites. + +USE_DL_PREFIX default: NOT defined + Causes compiler to prefix all public routines with the string 'dl'. + This can be useful when you only want to use this malloc in one part + of a program, using your regular system malloc elsewhere. + +MALLOC_INSPECT_ALL default: NOT defined + If defined, compiles malloc_inspect_all and mspace_inspect_all, that + perform traversal of all heap space. Unless access to these + functions is otherwise restricted, you probably do not want to + include them in secure implementations. + +ABORT default: defined as abort() + Defines how to abort on failed checks. On most systems, a failed + check cannot die with an "assert" or even print an informative + message, because the underlying print routines in turn call malloc, + which will fail again. Generally, the best policy is to simply call + abort(). It's not very useful to do more than this because many + errors due to overwriting will show up as address faults (null, odd + addresses etc) rather than malloc-triggered checks, so will also + abort. Also, most compilers know that abort() does not return, so + can better optimize code conditionally calling it. + +PROCEED_ON_ERROR default: defined as 0 (false) + Controls whether detected bad addresses cause them to bypassed + rather than aborting. If set, detected bad arguments to free and + realloc are ignored. And all bookkeeping information is zeroed out + upon a detected overwrite of freed heap space, thus losing the + ability to ever return it from malloc again, but enabling the + application to proceed. If PROCEED_ON_ERROR is defined, the + static variable malloc_corruption_error_count is compiled in + and can be examined to see if errors have occurred. This option + generates slower code than the default abort policy. + +DEBUG default: NOT defined + The DEBUG setting is mainly intended for people trying to modify + this code or diagnose problems when porting to new platforms. + However, it may also be able to better isolate user errors than just + using runtime checks. The assertions in the check routines spell + out in more detail the assumptions and invariants underlying the + algorithms. The checking is fairly extensive, and will slow down + execution noticeably. Calling malloc_stats or mallinfo with DEBUG + set will attempt to check every non-mmapped allocated and free chunk + in the course of computing the summaries. + +ABORT_ON_ASSERT_FAILURE default: defined as 1 (true) + Debugging assertion failures can be nearly impossible if your + version of the assert macro causes malloc to be called, which will + lead to a cascade of further failures, blowing the runtime stack. + ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(), + which will usually make debugging easier. + +MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32 + The action to take before "return 0" when malloc fails to be able to + return memory because there is none available. + +HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES + True if this system supports sbrk or an emulation of it. + +MORECORE default: sbrk + The name of the sbrk-style system routine to call to obtain more + memory. See below for guidance on writing custom MORECORE + functions. The type of the argument to sbrk/MORECORE varies across + systems. It cannot be size_t, because it supports negative + arguments, so it is normally the signed type of the same width as + size_t (sometimes declared as "intptr_t"). It doesn't much matter + though. Internally, we only call it with arguments less than half + the max value of a size_t, which should work across all reasonable + possibilities, although sometimes generating compiler warnings. + +MORECORE_CONTIGUOUS default: 1 (true) if HAVE_MORECORE + If true, take advantage of fact that consecutive calls to MORECORE + with positive arguments always return contiguous increasing + addresses. This is true of unix sbrk. It does not hurt too much to + set it true anyway, since malloc copes with non-contiguities. + Setting it false when definitely non-contiguous saves time + and possibly wasted space it would take to discover this though. + +MORECORE_CANNOT_TRIM default: NOT defined + True if MORECORE cannot release space back to the system when given + negative arguments. This is generally necessary only if you are + using a hand-crafted MORECORE function that cannot handle negative + arguments. + +NO_SEGMENT_TRAVERSAL default: 0 + If non-zero, suppresses traversals of memory segments + returned by either MORECORE or CALL_MMAP. This disables + merging of segments that are contiguous, and selectively + releasing them to the OS if unused, but bounds execution times. + +HAVE_MMAP default: 1 (true) + True if this system supports mmap or an emulation of it. If so, and + HAVE_MORECORE is not true, MMAP is used for all system + allocation. If set and HAVE_MORECORE is true as well, MMAP is + primarily used to directly allocate very large blocks. It is also + used as a backup strategy in cases where MORECORE fails to provide + space from system. Note: A single call to MUNMAP is assumed to be + able to unmap memory that may have be allocated using multiple calls + to MMAP, so long as they are adjacent. + +HAVE_MREMAP default: 1 on linux, else 0 + If true realloc() uses mremap() to re-allocate large blocks and + extend or shrink allocation spaces. + +MMAP_CLEARS default: 1 except on WINCE. + True if mmap clears memory so calloc doesn't need to. This is true + for standard unix mmap using /dev/zero and on WIN32 except for WINCE. + +USE_BUILTIN_FFS default: 0 (i.e., not used) + Causes malloc to use the builtin ffs() function to compute indices. + Some compilers may recognize and intrinsify ffs to be faster than the + supplied C version. Also, the case of x86 using gcc is special-cased + to an asm instruction, so is already as fast as it can be, and so + this setting has no effect. Similarly for Win32 under recent MS compilers. + (On most x86s, the asm version is only slightly faster than the C version.) + +malloc_getpagesize default: derive from system includes, or 4096. + The system page size. To the extent possible, this malloc manages + memory from the system in page-size units. This may be (and + usually is) a function rather than a constant. This is ignored + if WIN32, where page size is determined using getSystemInfo during + initialization. + +USE_DEV_RANDOM default: 0 (i.e., not used) + Causes malloc to use /dev/random to initialize secure magic seed for + stamping footers. Otherwise, the current time is used. + +NO_MALLINFO default: 0 + If defined, don't compile "mallinfo". This can be a simple way + of dealing with mismatches between system declarations and + those in this file. + +MALLINFO_FIELD_TYPE default: size_t + The type of the fields in the mallinfo struct. This was originally + defined as "int" in SVID etc, but is more usefully defined as + size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set + +NO_MALLOC_STATS default: 0 + If defined, don't compile "malloc_stats". This avoids calls to + fprintf and bringing in stdio dependencies you might not want. + +REALLOC_ZERO_BYTES_FREES default: not defined + This should be set if a call to realloc with zero bytes should + be the same as a call to free. Some people think it should. Otherwise, + since this malloc returns a unique pointer for malloc(0), so does + realloc(p, 0). + +LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H +LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H +LACKS_STDLIB_H LACKS_SCHED_H LACKS_TIME_H default: NOT defined unless on WIN32 + Define these if your system does not have these header files. + You might need to manually insert some of the declarations they provide. + +DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS, + system_info.dwAllocationGranularity in WIN32, + otherwise 64K. + Also settable using mallopt(M_GRANULARITY, x) + The unit for allocating and deallocating memory from the system. On + most systems with contiguous MORECORE, there is no reason to + make this more than a page. However, systems with MMAP tend to + either require or encourage larger granularities. You can increase + this value to prevent system allocation functions to be called so + often, especially if they are slow. The value must be at least one + page and must be a power of two. Setting to 0 causes initialization + to either page size or win32 region size. (Note: In previous + versions of malloc, the equivalent of this option was called + "TOP_PAD") + +DEFAULT_TRIM_THRESHOLD default: 2MB + Also settable using mallopt(M_TRIM_THRESHOLD, x) + The maximum amount of unused top-most memory to keep before + releasing via malloc_trim in free(). Automatic trimming is mainly + useful in long-lived programs using contiguous MORECORE. Because + trimming via sbrk can be slow on some systems, and can sometimes be + wasteful (in cases where programs immediately afterward allocate + more large chunks) the value should be high enough so that your + overall system performance would improve by releasing this much + memory. As a rough guide, you might set to a value close to the + average size of a process (program) running on your system. + Releasing this much memory would allow such a process to run in + memory. Generally, it is worth tuning trim thresholds when a + program undergoes phases where several large chunks are allocated + and released in ways that can reuse each other's storage, perhaps + mixed with phases where there are no such chunks at all. The trim + value must be greater than page size to have any useful effect. To + disable trimming completely, you can set to MAX_SIZE_T. Note that the trick + some people use of mallocing a huge space and then freeing it at + program startup, in an attempt to reserve system memory, doesn't + have the intended effect under automatic trimming, since that memory + will immediately be returned to the system. + +DEFAULT_MMAP_THRESHOLD default: 256K + Also settable using mallopt(M_MMAP_THRESHOLD, x) + The request size threshold for using MMAP to directly service a + request. Requests of at least this size that cannot be allocated + using already-existing space will be serviced via mmap. (If enough + normal freed space already exists it is used instead.) Using mmap + segregates relatively large chunks of memory so that they can be + individually obtained and released from the host system. A request + serviced through mmap is never reused by any other request (at least + not directly; the system may just so happen to remap successive + requests to the same locations). Segregating space in this way has + the benefits that: Mmapped space can always be individually released + back to the system, which helps keep the system level memory demands + of a long-lived program low. Also, mapped memory doesn't become + `locked' between other chunks, as can happen with normally allocated + chunks, which means that even trimming via malloc_trim would not + release them. However, it has the disadvantage that the space + cannot be reclaimed, consolidated, and then used to service later + requests, as happens with normal chunks. The advantages of mmap + nearly always outweigh disadvantages for "large" chunks, but the + value of "large" may vary across systems. The default is an + empirically derived value that works well in most systems. You can + disable mmap by setting to MAX_SIZE_T. + +MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP + The number of consolidated frees between checks to release + unused segments when freeing. When using non-contiguous segments, + especially with multiple mspaces, checking only for topmost space + doesn't always suffice to trigger trimming. To compensate for this, + free() will, with a period of MAX_RELEASE_CHECK_RATE (or the + current number of segments, if greater) try to release unused + segments to the OS when freeing chunks that result in + consolidation. The best value for this parameter is a compromise + between slowing down frees with relatively costly checks that + rarely trigger versus holding on to unused memory. To effectively + disable, set to MAX_SIZE_T. This may lead to a very slight speed + improvement at the expense of carrying around more memory. +*/ + +#define USE_DL_PREFIX + +/* Version identifier to allow people to support multiple versions */ +#ifndef DLMALLOC_VERSION +#define DLMALLOC_VERSION 20806 +#endif /* DLMALLOC_VERSION */ + +#ifndef DLMALLOC_EXPORT +#define DLMALLOC_EXPORT extern +#endif + +#ifndef WIN32 +#ifdef _WIN32 +#define WIN32 1 +#endif /* _WIN32 */ +#ifdef _WIN32_WCE +#define LACKS_FCNTL_H +#define WIN32 1 +#endif /* _WIN32_WCE */ +#endif /* WIN32 */ +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#include +#define HAVE_MMAP 1 +#define HAVE_MORECORE 0 +#define LACKS_UNISTD_H +#define LACKS_SYS_PARAM_H +#define LACKS_SYS_MMAN_H +#define LACKS_STRING_H +#define LACKS_STRINGS_H +#define LACKS_SYS_TYPES_H +#define LACKS_ERRNO_H +#define LACKS_SCHED_H +#ifndef MALLOC_FAILURE_ACTION +#define MALLOC_FAILURE_ACTION +#endif /* MALLOC_FAILURE_ACTION */ +#ifndef MMAP_CLEARS +#ifdef _WIN32_WCE /* WINCE reportedly does not clear */ +#define MMAP_CLEARS 0 +#else +#define MMAP_CLEARS 1 +#endif /* _WIN32_WCE */ +#endif /*MMAP_CLEARS */ +#endif /* WIN32 */ + +#if defined(DARWIN) || defined(_DARWIN) +/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ +#ifndef HAVE_MORECORE +#define HAVE_MORECORE 0 +#define HAVE_MMAP 1 +/* OSX allocators provide 16 byte alignment */ +#ifndef MALLOC_ALIGNMENT +#define MALLOC_ALIGNMENT ((size_t)16U) +#endif +#endif /* HAVE_MORECORE */ +#endif /* DARWIN */ + +#ifndef LACKS_SYS_TYPES_H +#include /* For size_t */ +#endif /* LACKS_SYS_TYPES_H */ + +/* The maximum possible size_t value has all bits set */ +#define MAX_SIZE_T (~(size_t)0) + +#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ +#define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ + (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) +#endif /* USE_LOCKS */ + +#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ +#if ((defined(__GNUC__) && \ + ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ + defined(__i386__) || defined(__x86_64__))) || \ + (defined(_MSC_VER) && _MSC_VER>=1310)) +#ifndef USE_SPIN_LOCKS +#define USE_SPIN_LOCKS 1 +#endif /* USE_SPIN_LOCKS */ +#elif USE_SPIN_LOCKS +#error "USE_SPIN_LOCKS defined without implementation" +#endif /* ... locks available... */ +#elif !defined(USE_SPIN_LOCKS) +#define USE_SPIN_LOCKS 0 +#endif /* USE_LOCKS */ + +#ifndef ONLY_MSPACES +#define ONLY_MSPACES 0 +#endif /* ONLY_MSPACES */ +#ifndef MSPACES +#if ONLY_MSPACES +#define MSPACES 1 +#else /* ONLY_MSPACES */ +#define MSPACES 0 +#endif /* ONLY_MSPACES */ +#endif /* MSPACES */ +#ifndef MALLOC_ALIGNMENT +#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) +#endif /* MALLOC_ALIGNMENT */ +#ifndef FOOTERS +#define FOOTERS 0 +#endif /* FOOTERS */ +#ifndef ABORT +#define ABORT abort() +#endif /* ABORT */ +#ifndef ABORT_ON_ASSERT_FAILURE +#define ABORT_ON_ASSERT_FAILURE 1 +#endif /* ABORT_ON_ASSERT_FAILURE */ +#ifndef PROCEED_ON_ERROR +#define PROCEED_ON_ERROR 0 +#endif /* PROCEED_ON_ERROR */ + +#ifndef INSECURE +#define INSECURE 0 +#endif /* INSECURE */ +#ifndef MALLOC_INSPECT_ALL +#define MALLOC_INSPECT_ALL 0 +#endif /* MALLOC_INSPECT_ALL */ +#ifndef HAVE_MMAP +#define HAVE_MMAP 1 +#endif /* HAVE_MMAP */ +#ifndef MMAP_CLEARS +#define MMAP_CLEARS 1 +#endif /* MMAP_CLEARS */ +#ifndef HAVE_MREMAP +#ifdef linux +#define HAVE_MREMAP 1 +#define _GNU_SOURCE /* Turns on mremap() definition */ +#else /* linux */ +#define HAVE_MREMAP 0 +#endif /* linux */ +#endif /* HAVE_MREMAP */ +#ifndef MALLOC_FAILURE_ACTION +#define MALLOC_FAILURE_ACTION errno = ENOMEM; +#endif /* MALLOC_FAILURE_ACTION */ +#ifndef HAVE_MORECORE +#if ONLY_MSPACES +#define HAVE_MORECORE 0 +#else /* ONLY_MSPACES */ +#define HAVE_MORECORE 1 +#endif /* ONLY_MSPACES */ +#endif /* HAVE_MORECORE */ +#if !HAVE_MORECORE +#define MORECORE_CONTIGUOUS 0 +#else /* !HAVE_MORECORE */ +#define MORECORE_DEFAULT sbrk +#ifndef MORECORE_CONTIGUOUS +#define MORECORE_CONTIGUOUS 1 +#endif /* MORECORE_CONTIGUOUS */ +#endif /* HAVE_MORECORE */ +#ifndef DEFAULT_GRANULARITY +#if (MORECORE_CONTIGUOUS || defined(WIN32)) +#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ +#else /* MORECORE_CONTIGUOUS */ +#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) +#endif /* MORECORE_CONTIGUOUS */ +#endif /* DEFAULT_GRANULARITY */ +#ifndef DEFAULT_TRIM_THRESHOLD +#ifndef MORECORE_CANNOT_TRIM +#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) +#else /* MORECORE_CANNOT_TRIM */ +#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T +#endif /* MORECORE_CANNOT_TRIM */ +#endif /* DEFAULT_TRIM_THRESHOLD */ +#ifndef DEFAULT_MMAP_THRESHOLD +#if HAVE_MMAP +#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) +#else /* HAVE_MMAP */ +#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T +#endif /* HAVE_MMAP */ +#endif /* DEFAULT_MMAP_THRESHOLD */ +#ifndef MAX_RELEASE_CHECK_RATE +#if HAVE_MMAP +#define MAX_RELEASE_CHECK_RATE 4095 +#else +#define MAX_RELEASE_CHECK_RATE MAX_SIZE_T +#endif /* HAVE_MMAP */ +#endif /* MAX_RELEASE_CHECK_RATE */ +#ifndef USE_BUILTIN_FFS +#define USE_BUILTIN_FFS 0 +#endif /* USE_BUILTIN_FFS */ +#ifndef USE_DEV_RANDOM +#define USE_DEV_RANDOM 0 +#endif /* USE_DEV_RANDOM */ +#ifndef NO_MALLINFO +#define NO_MALLINFO 0 +#endif /* NO_MALLINFO */ +#ifndef MALLINFO_FIELD_TYPE +#define MALLINFO_FIELD_TYPE size_t +#endif /* MALLINFO_FIELD_TYPE */ +#ifndef NO_MALLOC_STATS +#define NO_MALLOC_STATS 0 +#endif /* NO_MALLOC_STATS */ +#ifndef NO_SEGMENT_TRAVERSAL +#define NO_SEGMENT_TRAVERSAL 0 +#endif /* NO_SEGMENT_TRAVERSAL */ + +/* + mallopt tuning options. SVID/XPG defines four standard parameter + numbers for mallopt, normally defined in malloc.h. None of these + are used in this malloc, so setting them has no effect. But this + malloc does support the following options. +*/ + +#undef M_TRIM_THRESHOLD +#undef M_GRANULARITY +#undef M_MMAP_THRESHOLD +#define M_TRIM_THRESHOLD (-1) +#define M_GRANULARITY (-2) +#define M_MMAP_THRESHOLD (-3) + +/* ------------------------ Mallinfo declarations ------------------------ */ + +#if !NO_MALLINFO +/* + This version of malloc supports the standard SVID/XPG mallinfo + routine that returns a struct containing usage properties and + statistics. It should work on any system that has a + /usr/include/malloc.h defining struct mallinfo. The main + declaration needed is the mallinfo struct that is returned (by-copy) + by mallinfo(). The malloinfo struct contains a bunch of fields that + are not even meaningful in this version of malloc. These fields are + are instead filled by mallinfo() with other numbers that might be of + interest. + + HAVE_USR_INCLUDE_MALLOC_H should be set if you have a + /usr/include/malloc.h file that includes a declaration of struct + mallinfo. If so, it is included; else a compliant version is + declared below. These must be precisely the same for mallinfo() to + work. The original SVID version of this struct, defined on most + systems with mallinfo, declares all fields as ints. But some others + define as unsigned long. If your system defines the fields using a + type of different width than listed here, you MUST #include your + system version and #define HAVE_USR_INCLUDE_MALLOC_H. +*/ + +/* #define HAVE_USR_INCLUDE_MALLOC_H */ + +#ifdef HAVE_USR_INCLUDE_MALLOC_H +#include "/usr/include/malloc.h" +#else /* HAVE_USR_INCLUDE_MALLOC_H */ +#ifndef STRUCT_MALLINFO_DECLARED +/* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */ +#define _STRUCT_MALLINFO +#define STRUCT_MALLINFO_DECLARED 1 +struct mallinfo { + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ +}; +#endif /* STRUCT_MALLINFO_DECLARED */ +#endif /* HAVE_USR_INCLUDE_MALLOC_H */ +#endif /* NO_MALLINFO */ + +/* + Try to persuade compilers to inline. The most critical functions for + inlining are defined as macros, so these aren't used for them. +*/ + +#ifndef FORCEINLINE + #if defined(__GNUC__) +#define FORCEINLINE __inline __attribute__ ((always_inline)) + #elif defined(_MSC_VER) + #define FORCEINLINE __forceinline + #endif +#endif +#ifndef NOINLINE + #if defined(__GNUC__) + #define NOINLINE __attribute__ ((noinline)) + #elif defined(_MSC_VER) + #define NOINLINE __declspec(noinline) + #else + #define NOINLINE + #endif +#endif + +#ifdef __cplusplus +extern "C" { +#ifndef FORCEINLINE + #define FORCEINLINE inline +#endif +#endif /* __cplusplus */ +#ifndef FORCEINLINE + #define FORCEINLINE +#endif + +#if !ONLY_MSPACES + +/* ------------------- Declarations of public routines ------------------- */ + +#ifndef USE_DL_PREFIX +#define dlcalloc calloc +#define dlfree free +#define dlmalloc malloc +#define dlmemalign memalign +#define dlposix_memalign posix_memalign +#define dlrealloc realloc +#define dlrealloc_in_place realloc_in_place +#define dlvalloc valloc +#define dlpvalloc pvalloc +#define dlmallinfo mallinfo +#define dlmallopt mallopt +#define dlmalloc_trim malloc_trim +#define dlmalloc_stats malloc_stats +#define dlmalloc_usable_size malloc_usable_size +#define dlmalloc_footprint malloc_footprint +#define dlmalloc_max_footprint malloc_max_footprint +#define dlmalloc_footprint_limit malloc_footprint_limit +#define dlmalloc_set_footprint_limit malloc_set_footprint_limit +#define dlmalloc_inspect_all malloc_inspect_all +#define dlindependent_calloc independent_calloc +#define dlindependent_comalloc independent_comalloc +#define dlbulk_free bulk_free +#endif /* USE_DL_PREFIX */ + +/* + malloc(size_t n) + Returns a pointer to a newly allocated chunk of at least n bytes, or + null if no space is available, in which case errno is set to ENOMEM + on ANSI C systems. + + If n is zero, malloc returns a minimum-sized chunk. (The minimum + size is 16 bytes on most 32bit systems, and 32 bytes on 64bit + systems.) Note that size_t is an unsigned type, so calls with + arguments that would be negative if signed are interpreted as + requests for huge amounts of space, which will often fail. The + maximum supported value of n differs across systems, but is in all + cases less than the maximum representable value of a size_t. +*/ +DLMALLOC_EXPORT void* dlmalloc(size_t); + +/* + free(void* p) + Releases the chunk of memory pointed to by p, that had been previously + allocated using malloc or a related routine such as realloc. + It has no effect if p is null. If p was not malloced or already + freed, free(p) will by default cause the current program to abort. +*/ +DLMALLOC_EXPORT void dlfree(void*); + +/* + calloc(size_t n_elements, size_t element_size); + Returns a pointer to n_elements * element_size bytes, with all locations + set to zero. +*/ +DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); + +/* + realloc(void* p, size_t n) + Returns a pointer to a chunk of size n that contains the same data + as does chunk p up to the minimum of (n, p's size) bytes, or null + if no space is available. + + The returned pointer may or may not be the same as p. The algorithm + prefers extending p in most cases when possible, otherwise it + employs the equivalent of a malloc-copy-free sequence. + + If p is null, realloc is equivalent to malloc. + + If space is not available, realloc returns null, errno is set (if on + ANSI) and p is NOT freed. + + if n is for fewer bytes than already held by p, the newly unused + space is lopped off and freed if possible. realloc with a size + argument of zero (re)allocates a minimum-sized chunk. + + The old unix realloc convention of allowing the last-free'd chunk + to be used as an argument to realloc is not supported. +*/ +DLMALLOC_EXPORT void* dlrealloc(void*, size_t); + +/* + realloc_in_place(void* p, size_t n) + Resizes the space allocated for p to size n, only if this can be + done without moving p (i.e., only if there is adjacent space + available if n is greater than p's current allocated size, or n is + less than or equal to p's size). This may be used instead of plain + realloc if an alternative allocation strategy is needed upon failure + to expand space; for example, reallocation of a buffer that must be + memory-aligned or cleared. You can use realloc_in_place to trigger + these alternatives only when needed. + + Returns p if successful; otherwise null. +*/ +DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); + +/* + memalign(size_t alignment, size_t n); + Returns a pointer to a newly allocated chunk of n bytes, aligned + in accord with the alignment argument. + + The alignment argument should be a power of two. If the argument is + not a power of two, the nearest greater power is used. + 8-byte alignment is guaranteed by normal malloc calls, so don't + bother calling memalign with an argument of 8 or less. + + Overreliance on memalign is a sure way to fragment space. +*/ +DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); + +/* + int posix_memalign(void** pp, size_t alignment, size_t n); + Allocates a chunk of n bytes, aligned in accord with the alignment + argument. Differs from memalign only in that it (1) assigns the + allocated memory to *pp rather than returning it, (2) fails and + returns EINVAL if the alignment is not a power of two (3) fails and + returns ENOMEM if memory cannot be allocated. +*/ +DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t); + +/* + valloc(size_t n); + Equivalent to memalign(pagesize, n), where pagesize is the page + size of the system. If the pagesize is unknown, 4096 is used. +*/ +DLMALLOC_EXPORT void* dlvalloc(size_t); + +/* + mallopt(int parameter_number, int parameter_value) + Sets tunable parameters The format is to provide a + (parameter-number, parameter-value) pair. mallopt then sets the + corresponding parameter to the argument value if it can (i.e., so + long as the value is meaningful), and returns 1 if successful else + 0. To workaround the fact that mallopt is specified to use int, + not size_t parameters, the value -1 is specially treated as the + maximum unsigned size_t value. + + SVID/XPG/ANSI defines four standard param numbers for mallopt, + normally defined in malloc.h. None of these are use in this malloc, + so setting them has no effect. But this malloc also supports other + options in mallopt. See below for details. Briefly, supported + parameters are as follows (listed defaults are for "typical" + configurations). + + Symbol param # default allowed param values + M_TRIM_THRESHOLD -1 2*1024*1024 any (-1 disables) + M_GRANULARITY -2 page size any power of 2 >= page size + M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support) +*/ +DLMALLOC_EXPORT int dlmallopt(int, int); + +/* + malloc_footprint(); + Returns the number of bytes obtained from the system. The total + number of bytes allocated by malloc, realloc etc., is less than this + value. Unlike mallinfo, this function returns only a precomputed + result, so can be called frequently to monitor memory consumption. + Even if locks are otherwise defined, this function does not use them, + so results might not be up to date. +*/ +DLMALLOC_EXPORT size_t dlmalloc_footprint(void); + +/* + malloc_max_footprint(); + Returns the maximum number of bytes obtained from the system. This + value will be greater than current footprint if deallocated space + has been reclaimed by the system. The peak number of bytes allocated + by malloc, realloc etc., is less than this value. Unlike mallinfo, + this function returns only a precomputed result, so can be called + frequently to monitor memory consumption. Even if locks are + otherwise defined, this function does not use them, so results might + not be up to date. +*/ +DLMALLOC_EXPORT size_t dlmalloc_max_footprint(void); + +/* + malloc_footprint_limit(); + Returns the number of bytes that the heap is allowed to obtain from + the system, returning the last value returned by + malloc_set_footprint_limit, or the maximum size_t value if + never set. The returned value reflects a permission. There is no + guarantee that this number of bytes can actually be obtained from + the system. +*/ +DLMALLOC_EXPORT size_t dlmalloc_footprint_limit(); + +/* + malloc_set_footprint_limit(); + Sets the maximum number of bytes to obtain from the system, causing + failure returns from malloc and related functions upon attempts to + exceed this value. The argument value may be subject to page + rounding to an enforceable limit; this actual value is returned. + Using an argument of the maximum possible size_t effectively + disables checks. If the argument is less than or equal to the + current malloc_footprint, then all future allocations that require + additional system memory will fail. However, invocation cannot + retroactively deallocate existing used memory. +*/ +DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); + +#if MALLOC_INSPECT_ALL +/* + malloc_inspect_all(void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg); + Traverses the heap and calls the given handler for each managed + region, skipping all bytes that are (or may be) used for bookkeeping + purposes. Traversal does not include include chunks that have been + directly memory mapped. Each reported region begins at the start + address, and continues up to but not including the end address. The + first used_bytes of the region contain allocated data. If + used_bytes is zero, the region is unallocated. The handler is + invoked with the given callback argument. If locks are defined, they + are held during the entire traversal. It is a bad idea to invoke + other malloc functions from within the handler. + + For example, to count the number of in-use chunks with size greater + than 1000, you could write: + static int count = 0; + void count_chunks(void* start, void* end, size_t used, void* arg) { + if (used >= 1000) ++count; + } + then: + malloc_inspect_all(count_chunks, NULL); + + malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined. +*/ +DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), + void* arg); + +#endif /* MALLOC_INSPECT_ALL */ + +#if !NO_MALLINFO +/* + mallinfo() + Returns (by copy) a struct containing various summary statistics: + + arena: current total non-mmapped bytes allocated from system + ordblks: the number of free chunks + smblks: always zero. + hblks: current number of mmapped regions + hblkhd: total bytes held in mmapped regions + usmblks: the maximum total allocated space. This will be greater + than current total if trimming has occurred. + fsmblks: always zero + uordblks: current total allocated space (normal or mmapped) + fordblks: total free space + keepcost: the maximum number of bytes that could ideally be released + back to system via malloc_trim. ("ideally" means that + it ignores page restrictions etc.) + + Because these fields are ints, but internal bookkeeping may + be kept as longs, the reported values may wrap around zero and + thus be inaccurate. +*/ +DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); +#endif /* NO_MALLINFO */ + +/* + independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); + + independent_calloc is similar to calloc, but instead of returning a + single cleared space, it returns an array of pointers to n_elements + independent elements that can hold contents of size elem_size, each + of which starts out cleared, and can be independently freed, + realloc'ed etc. The elements are guaranteed to be adjacently + allocated (this is not guaranteed to occur with multiple callocs or + mallocs), which may also improve cache locality in some + applications. + + The "chunks" argument is optional (i.e., may be null, which is + probably the most typical usage). If it is null, the returned array + is itself dynamically allocated and should also be freed when it is + no longer needed. Otherwise, the chunks array must be of at least + n_elements in length. It is filled in with the pointers to the + chunks. + + In either case, independent_calloc returns this pointer array, or + null if the allocation failed. If n_elements is zero and "chunks" + is null, it returns a chunk representing an array with zero elements + (which should be freed if not wanted). + + Each element must be freed when it is no longer needed. This can be + done all at once using bulk_free. + + independent_calloc simplifies and speeds up implementations of many + kinds of pools. It may also be useful when constructing large data + structures that initially have a fixed number of fixed-sized nodes, + but the number is not known at compile time, and some of the nodes + may later need to be freed. For example: + + struct Node { int item; struct Node* next; }; + + struct Node* build_list() { + struct Node** pool; + int n = read_number_of_nodes_needed(); + if (n <= 0) return 0; + pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); + if (pool == 0) die(); + // organize into a linked list... + struct Node* first = pool[0]; + for (i = 0; i < n-1; ++i) + pool[i]->next = pool[i+1]; + free(pool); // Can now free the array (or not, if it is needed later) + return first; + } +*/ +DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); + +/* + independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); + + independent_comalloc allocates, all at once, a set of n_elements + chunks with sizes indicated in the "sizes" array. It returns + an array of pointers to these elements, each of which can be + independently freed, realloc'ed etc. The elements are guaranteed to + be adjacently allocated (this is not guaranteed to occur with + multiple callocs or mallocs), which may also improve cache locality + in some applications. + + The "chunks" argument is optional (i.e., may be null). If it is null + the returned array is itself dynamically allocated and should also + be freed when it is no longer needed. Otherwise, the chunks array + must be of at least n_elements in length. It is filled in with the + pointers to the chunks. + + In either case, independent_comalloc returns this pointer array, or + null if the allocation failed. If n_elements is zero and chunks is + null, it returns a chunk representing an array with zero elements + (which should be freed if not wanted). + + Each element must be freed when it is no longer needed. This can be + done all at once using bulk_free. + + independent_comallac differs from independent_calloc in that each + element may have a different size, and also that it does not + automatically clear elements. + + independent_comalloc can be used to speed up allocation in cases + where several structs or objects must always be allocated at the + same time. For example: + + struct Head { ... } + struct Foot { ... } + + void send_message(char* msg) { + int msglen = strlen(msg); + size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; + void* chunks[3]; + if (independent_comalloc(3, sizes, chunks) == 0) + die(); + struct Head* head = (struct Head*)(chunks[0]); + char* body = (char*)(chunks[1]); + struct Foot* foot = (struct Foot*)(chunks[2]); + // ... + } + + In general though, independent_comalloc is worth using only for + larger values of n_elements. For small values, you probably won't + detect enough difference from series of malloc calls to bother. + + Overuse of independent_comalloc can increase overall memory usage, + since it cannot reuse existing noncontiguous small chunks that + might be available for some of the elements. +*/ +DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); + +/* + bulk_free(void* array[], size_t n_elements) + Frees and clears (sets to null) each non-null pointer in the given + array. This is likely to be faster than freeing them one-by-one. + If footers are used, pointers that have been allocated in different + mspaces are not freed or cleared, and the count of all such pointers + is returned. For large arrays of pointers with poor locality, it + may be worthwhile to sort this array before calling bulk_free. +*/ +DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements); + +/* + pvalloc(size_t n); + Equivalent to valloc(minimum-page-that-holds(n)), that is, + round up n to nearest pagesize. + */ +DLMALLOC_EXPORT void* dlpvalloc(size_t); + +/* + malloc_trim(size_t pad); + + If possible, gives memory back to the system (via negative arguments + to sbrk) if there is unused memory at the `high' end of the malloc + pool or in unused MMAP segments. You can call this after freeing + large blocks of memory to potentially reduce the system-level memory + requirements of a program. However, it cannot guarantee to reduce + memory. Under some allocation patterns, some large free blocks of + memory will be locked between two used chunks, so they cannot be + given back to the system. + + The `pad' argument to malloc_trim represents the amount of free + trailing space to leave untrimmed. If this argument is zero, only + the minimum amount of memory to maintain internal data structures + will be left. Non-zero arguments can be supplied to maintain enough + trailing space to service future expected allocations without having + to re-obtain memory from the system. + + Malloc_trim returns 1 if it actually released any memory, else 0. +*/ +DLMALLOC_EXPORT int dlmalloc_trim(size_t); + +/* + malloc_stats(); + Prints on stderr the amount of space obtained from the system (both + via sbrk and mmap), the maximum amount (which may be more than + current if malloc_trim and/or munmap got called), and the current + number of bytes allocated via malloc (or realloc, etc) but not yet + freed. Note that this is the number of bytes allocated, not the + number requested. It will be larger than the number requested + because of alignment and bookkeeping overhead. Because it includes + alignment wastage as being in use, this figure may be greater than + zero even when no user-level chunks are allocated. + + The reported current and maximum system memory can be inaccurate if + a program makes other calls to system memory allocation functions + (normally sbrk) outside of malloc. + + malloc_stats prints only the most commonly interesting statistics. + More information can be obtained by calling mallinfo. +*/ +DLMALLOC_EXPORT void dlmalloc_stats(void); + +/* + malloc_usable_size(void* p); + + Returns the number of bytes you can actually use in + an allocated chunk, which may be more than you requested (although + often not) due to alignment and minimum size constraints. + You can use this many bytes without worrying about + overwriting other allocated objects. This is not a particularly great + programming practice. malloc_usable_size can be more useful in + debugging and assertions, for example: + + p = malloc(n); + assert(malloc_usable_size(p) >= 256); +*/ +size_t dlmalloc_usable_size(void*); + +#endif /* ONLY_MSPACES */ + +#if MSPACES + +/* + mspace is an opaque type representing an independent + region of space that supports mspace_malloc, etc. +*/ +typedef void* mspace; + +/* + create_mspace creates and returns a new independent space with the + given initial capacity, or, if 0, the default granularity size. It + returns null if there is no system memory available to create the + space. If argument locked is non-zero, the space uses a separate + lock to control access. The capacity of the space will grow + dynamically as needed to service mspace_malloc requests. You can + control the sizes of incremental increases of this space by + compiling with a different DEFAULT_GRANULARITY or dynamically + setting with mallopt(M_GRANULARITY, value). +*/ +DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked); + +/* + destroy_mspace destroys the given space, and attempts to return all + of its memory back to the system, returning the total number of + bytes freed. After destruction, the results of access to all memory + used by the space become undefined. +*/ +DLMALLOC_EXPORT size_t destroy_mspace(mspace msp); + +/* + create_mspace_with_base uses the memory supplied as the initial base + of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this + space is used for bookkeeping, so the capacity must be at least this + large. (Otherwise 0 is returned.) When this initial space is + exhausted, additional memory will be obtained from the system. + Destroying this space will deallocate all additionally allocated + space (if possible) but not the initial base. +*/ +DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked); + +/* + mspace_track_large_chunks controls whether requests for large chunks + are allocated in their own untracked mmapped regions, separate from + others in this mspace. By default large chunks are not tracked, + which reduces fragmentation. However, such chunks are not + necessarily released to the system upon destroy_mspace. Enabling + tracking by setting to true may increase fragmentation, but avoids + leakage when relying on destroy_mspace to release all memory + allocated using this space. The function returns the previous + setting. +*/ +DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable); + + +/* + mspace_malloc behaves as malloc, but operates within + the given space. +*/ +DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); + +/* + mspace_free behaves as free, but operates within + the given space. + + If compiled with FOOTERS==1, mspace_free is not actually needed. + free may be called instead of mspace_free because freed chunks from + any space are handled by their originating spaces. +*/ +DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); + +/* + mspace_realloc behaves as realloc, but operates within + the given space. + + If compiled with FOOTERS==1, mspace_realloc is not actually + needed. realloc may be called instead of mspace_realloc because + realloced chunks from any space are handled by their originating + spaces. +*/ +DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize); + +/* + mspace_calloc behaves as calloc, but operates within + the given space. +*/ +DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); + +/* + mspace_memalign behaves as memalign, but operates within + the given space. +*/ +DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); + +/* + mspace_independent_calloc behaves as independent_calloc, but + operates within the given space. +*/ +DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void* chunks[]); + +/* + mspace_independent_comalloc behaves as independent_comalloc, but + operates within the given space. +*/ +DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void* chunks[]); + +/* + mspace_footprint() returns the number of bytes obtained from the + system for this space. +*/ +DLMALLOC_EXPORT size_t mspace_footprint(mspace msp); + +/* + mspace_max_footprint() returns the peak number of bytes obtained from the + system for this space. +*/ +DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp); + + +#if !NO_MALLINFO +/* + mspace_mallinfo behaves as mallinfo, but reports properties of + the given space. +*/ +DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp); +#endif /* NO_MALLINFO */ + +/* + malloc_usable_size(void* p) behaves the same as malloc_usable_size; +*/ +DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem); + +/* + mspace_malloc_stats behaves as malloc_stats, but reports + properties of the given space. +*/ +DLMALLOC_EXPORT void mspace_malloc_stats(mspace msp); + +/* + mspace_trim behaves as malloc_trim, but + operates within the given space. +*/ +DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad); + +/* + An alias for mallopt. +*/ +DLMALLOC_EXPORT int mspace_mallopt(int, int); + +#endif /* MSPACES */ + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif /* __cplusplus */ + +/* + ======================================================================== + To make a fully customizable malloc.h header file, cut everything + above this line, put into file malloc.h, edit to suit, and #include it + on the next line, as well as in programs that use this malloc. + ======================================================================== +*/ + +/* #include "malloc.h" */ + +/*------------------------------ internal #includes ---------------------- */ + +#ifdef _MSC_VER +#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ +#endif /* _MSC_VER */ +#if !NO_MALLOC_STATS +#include /* for printing in malloc_stats */ +#endif /* NO_MALLOC_STATS */ +#ifndef LACKS_ERRNO_H +#include /* for MALLOC_FAILURE_ACTION */ +#endif /* LACKS_ERRNO_H */ +#ifdef DEBUG +#if ABORT_ON_ASSERT_FAILURE +#undef assert +#define assert(x) if(!(x)) ABORT +#else /* ABORT_ON_ASSERT_FAILURE */ +#include +#endif /* ABORT_ON_ASSERT_FAILURE */ +#else /* DEBUG */ +#ifndef assert +#define assert(x) +#endif +#define DEBUG 0 +#endif /* DEBUG */ +#if !defined(WIN32) && !defined(LACKS_TIME_H) +#include /* for magic initialization */ +#endif /* WIN32 */ +#ifndef LACKS_STDLIB_H +#include /* for abort() */ +#endif /* LACKS_STDLIB_H */ +#ifndef LACKS_STRING_H +#include /* for memset etc */ +#endif /* LACKS_STRING_H */ +#if USE_BUILTIN_FFS +#ifndef LACKS_STRINGS_H +#include /* for ffs */ +#endif /* LACKS_STRINGS_H */ +#endif /* USE_BUILTIN_FFS */ +#if HAVE_MMAP +#ifndef LACKS_SYS_MMAN_H +/* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ +#if (defined(linux) && !defined(__USE_GNU)) +#define __USE_GNU 1 +#include /* for mmap */ +#undef __USE_GNU +#else +#include /* for mmap */ +#endif /* linux */ +#endif /* LACKS_SYS_MMAN_H */ +#ifndef LACKS_FCNTL_H +#include +#endif /* LACKS_FCNTL_H */ +#endif /* HAVE_MMAP */ +#ifndef LACKS_UNISTD_H +#include /* for sbrk, sysconf */ +#else /* LACKS_UNISTD_H */ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) +extern void* sbrk(ptrdiff_t); +#endif /* FreeBSD etc */ +#endif /* LACKS_UNISTD_H */ + +/* Declarations for locking */ +#if USE_LOCKS +#ifndef WIN32 +#if defined (__SVR4) && defined (__sun) /* solaris */ +#include +#elif !defined(LACKS_SCHED_H) +#include +#endif /* solaris or LACKS_SCHED_H */ +#if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS +#include +#endif /* USE_RECURSIVE_LOCKS ... */ +#elif defined(_MSC_VER) +#ifndef _M_AMD64 +/* These are already defined on AMD64 builds */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp); +LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value); +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _M_AMD64 */ +#pragma intrinsic (_InterlockedCompareExchange) +#pragma intrinsic (_InterlockedExchange) +#define interlockedcompareexchange _InterlockedCompareExchange +#define interlockedexchange _InterlockedExchange +#elif defined(WIN32) && defined(__GNUC__) +#define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b) +#define interlockedexchange __sync_lock_test_and_set +#endif /* Win32 */ +#else /* USE_LOCKS */ +#endif /* USE_LOCKS */ + +#ifndef LOCK_AT_FORK +#define LOCK_AT_FORK 0 +#endif + +/* Declarations for bit scanning on win32 */ +#if defined(_MSC_VER) && _MSC_VER>=1300 +#ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +unsigned char _BitScanForward(unsigned long *index, unsigned long mask); +unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#define BitScanForward _BitScanForward +#define BitScanReverse _BitScanReverse +#pragma intrinsic(_BitScanForward) +#pragma intrinsic(_BitScanReverse) +#endif /* BitScanForward */ +#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ + +#ifndef WIN32 +#ifndef malloc_getpagesize +# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ +# ifndef _SC_PAGE_SIZE +# define _SC_PAGE_SIZE _SC_PAGESIZE +# endif +# endif +# ifdef _SC_PAGE_SIZE +# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) +# else +# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) + extern size_t getpagesize(); +# define malloc_getpagesize getpagesize() +# else +# ifdef WIN32 /* use supplied emulation of getpagesize */ +# define malloc_getpagesize getpagesize() +# else +# ifndef LACKS_SYS_PARAM_H +# include +# endif +# ifdef EXEC_PAGESIZE +# define malloc_getpagesize EXEC_PAGESIZE +# else +# ifdef NBPG +# ifndef CLSIZE +# define malloc_getpagesize NBPG +# else +# define malloc_getpagesize (NBPG * CLSIZE) +# endif +# else +# ifdef NBPC +# define malloc_getpagesize NBPC +# else +# ifdef PAGESIZE +# define malloc_getpagesize PAGESIZE +# else /* just guess */ +# define malloc_getpagesize ((size_t)4096U) +# endif +# endif +# endif +# endif +# endif +# endif +# endif +#endif +#endif + +/* ------------------- size_t and alignment properties -------------------- */ + +/* The byte and bit size of a size_t */ +#define SIZE_T_SIZE (sizeof(size_t)) +#define SIZE_T_BITSIZE (sizeof(size_t) << 3) + +/* Some constants coerced to size_t */ +/* Annoying but necessary to avoid errors on some platforms */ +#define SIZE_T_ZERO ((size_t)0) +#define SIZE_T_ONE ((size_t)1) +#define SIZE_T_TWO ((size_t)2) +#define SIZE_T_FOUR ((size_t)4) +#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) +#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) +#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) +#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) + +/* The bit mask value corresponding to MALLOC_ALIGNMENT */ +#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) + +/* True if address a has acceptable alignment */ +#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) + +/* the number of bytes to offset an address to align it */ +#define align_offset(A)\ + ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ + ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) + +/* -------------------------- MMAP preliminaries ------------------------- */ + +/* + If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and + checks to fail so compiler optimizer can delete code rather than + using so many "#if"s. +*/ + + +/* MORECORE and MMAP must return MFAIL on failure */ +#define MFAIL ((void*)(MAX_SIZE_T)) +#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ + +#if HAVE_MMAP + +#ifndef WIN32 +#define MMAP_PROT (PROT_READ|PROT_WRITE) +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +#define MAP_ANONYMOUS MAP_ANON +#endif /* MAP_ANON */ +#ifdef MAP_ANONYMOUS + +#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) + +static FORCEINLINE void* unixmmap(size_t size) { + void* result; + + result = mmap(0, size, MMAP_PROT, MMAP_FLAGS, -1, 0); + if (result == MFAIL) + return MFAIL; + + return result; +} + +static FORCEINLINE int unixmunmap(void* ptr, size_t size) { + int result; + + result = munmap(ptr, size); + if (result != 0) + return result; + + return result; +} + +#define MMAP_DEFAULT(s) unixmmap(s) +#define MUNMAP_DEFAULT(a, s) unixmunmap((a), (s)) + +#else /* MAP_ANONYMOUS */ +/* + Nearly all versions of mmap support MAP_ANONYMOUS, so the following + is unlikely to be needed, but is supplied just in case. +*/ +#define MMAP_FLAGS (MAP_PRIVATE) +static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ +#define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \ + (dev_zero_fd = open("/dev/zero", O_RDWR), \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) +#define MUNMAP_DEFAULT(a, s) munmap((a), (s)) +#endif /* MAP_ANONYMOUS */ + +#define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) + +#else /* WIN32 */ + +/* Win32 MMAP via VirtualAlloc */ +static FORCEINLINE void* win32mmap(size_t size) { + void* ptr; + + ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + if (ptr == 0) + return MFAIL; + + return ptr; +} + +/* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ +static FORCEINLINE void* win32direct_mmap(size_t size) { + void* ptr; + + ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, + PAGE_READWRITE); + if (ptr == 0) + return MFAIL; + + return ptr; +} + +/* This function supports releasing coalesed segments */ +static FORCEINLINE int win32munmap(void* ptr, size_t size) { + MEMORY_BASIC_INFORMATION minfo; + char* cptr = (char*)ptr; + + while (size) { + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) + return -1; + if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || + minfo.State != MEM_COMMIT || minfo.RegionSize > size) + return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) + return -1; + cptr += minfo.RegionSize; + size -= minfo.RegionSize; + } + + return 0; +} + +#define MMAP_DEFAULT(s) win32mmap(s) +#define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) +#define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) +#endif /* WIN32 */ +#endif /* HAVE_MMAP */ + +#if HAVE_MREMAP +#ifndef WIN32 + +static FORCEINLINE void* dlmremap(void* old_address, size_t old_size, size_t new_size, int flags) { + void* result; + + result = mremap(old_address, old_size, new_size, flags); + if (result == MFAIL) + return MFAIL; + + return result; +} + +#define MREMAP_DEFAULT(addr, osz, nsz, mv) dlmremap((addr), (osz), (nsz), (mv)) +#endif /* WIN32 */ +#endif /* HAVE_MREMAP */ + +/** + * Define CALL_MORECORE + */ +#if HAVE_MORECORE + #ifdef MORECORE + #define CALL_MORECORE(S) MORECORE(S) + #else /* MORECORE */ + #define CALL_MORECORE(S) MORECORE_DEFAULT(S) + #endif /* MORECORE */ +#else /* HAVE_MORECORE */ + #define CALL_MORECORE(S) MFAIL +#endif /* HAVE_MORECORE */ + +/** + * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP + */ +#if HAVE_MMAP + #define USE_MMAP_BIT (SIZE_T_ONE) + + #ifdef MMAP + #define CALL_MMAP(s) MMAP(s) + #else /* MMAP */ + #define CALL_MMAP(s) MMAP_DEFAULT(s) + #endif /* MMAP */ + #ifdef MUNMAP + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) + #else /* MUNMAP */ + #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) + #endif /* MUNMAP */ + #ifdef DIRECT_MMAP + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #else /* DIRECT_MMAP */ + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) + #endif /* DIRECT_MMAP */ +#else /* HAVE_MMAP */ + #define USE_MMAP_BIT (SIZE_T_ZERO) + + #define MMAP(s) MFAIL + #define MUNMAP(a, s) (-1) + #define DIRECT_MMAP(s) MFAIL + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #define CALL_MMAP(s) MMAP(s) + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) +#endif /* HAVE_MMAP */ + +/** + * Define CALL_MREMAP + */ +#if HAVE_MMAP && HAVE_MREMAP + #ifdef MREMAP + #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) + #else /* MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) + #endif /* MREMAP */ +#else /* HAVE_MMAP && HAVE_MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL +#endif /* HAVE_MMAP && HAVE_MREMAP */ + +/* mstate bit set if continguous morecore disabled or failed */ +#define USE_NONCONTIGUOUS_BIT (4U) + +/* segment bit set in create_mspace_with_base */ +#define EXTERN_BIT (8U) + + +/* --------------------------- Lock preliminaries ------------------------ */ + +/* + When locks are defined, there is one global lock, plus + one per-mspace lock. + + The global lock_ensures that mparams.magic and other unique + mparams values are initialized only once. It also protects + sequences of calls to MORECORE. In many cases sys_alloc requires + two calls, that should not be interleaved with calls by other + threads. This does not protect against direct calls to MORECORE + by other threads not using this lock, so there is still code to + cope the best we can on interference. + + Per-mspace locks surround calls to malloc, free, etc. + By default, locks are simple non-reentrant mutexes. + + Because lock-protected regions generally have bounded times, it is + OK to use the supplied simple spinlocks. Spinlocks are likely to + improve performance for lightly contended applications, but worsen + performance under heavy contention. + + If USE_LOCKS is > 1, the definitions of lock routines here are + bypassed, in which case you will need to define the type MLOCK_T, + and at least INITIAL_LOCK, DESTROY_LOCK, ACQUIRE_LOCK, RELEASE_LOCK + and TRY_LOCK. You must also declare a + static MLOCK_T malloc_global_mutex = { initialization values };. + +*/ + +#if !USE_LOCKS +#define USE_LOCK_BIT (0U) +#define INITIAL_LOCK(l) (0) +#define DESTROY_LOCK(l) (0) +#define ACQUIRE_MALLOC_GLOBAL_LOCK() +#define RELEASE_MALLOC_GLOBAL_LOCK() + +#else +#if USE_LOCKS > 1 +/* ----------------------- User-defined locks ------------------------ */ +/* Define your own lock implementation here */ +/* #define INITIAL_LOCK(lk) ... */ +/* #define DESTROY_LOCK(lk) ... */ +/* #define ACQUIRE_LOCK(lk) ... */ +/* #define RELEASE_LOCK(lk) ... */ +/* #define TRY_LOCK(lk) ... */ +/* static MLOCK_T malloc_global_mutex = ... */ + +#elif USE_SPIN_LOCKS + +/* First, define CAS_LOCK and CLEAR_LOCK on ints */ +/* Note CAS_LOCK defined to return 0 on success */ + +#if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) +#define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) +#define CLEAR_LOCK(sl) __sync_lock_release(sl) + +#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) +/* Custom spin locks for older gcc on x86 */ +static FORCEINLINE int x86_cas_lock(int *sl) { + int ret; + int val = 1; + int cmp = 0; + __asm__ __volatile__ ("lock; cmpxchgl %1, %2" + : "=a" (ret) + : "r" (val), "m" (*(sl)), "0"(cmp) + : "memory", "cc"); + return ret; +} + +static FORCEINLINE void x86_clear_lock(int* sl) { + assert(*sl != 0); + int prev = 0; + int ret; + __asm__ __volatile__ ("lock; xchgl %0, %1" + : "=r" (ret) + : "m" (*(sl)), "0"(prev) + : "memory"); +} + +#define CAS_LOCK(sl) x86_cas_lock(sl) +#define CLEAR_LOCK(sl) x86_clear_lock(sl) + +#else /* Win32 MSC */ +#define CAS_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)1) +#define CLEAR_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)0) + +#endif /* ... gcc spins locks ... */ + +/* How to yield for a spin lock */ +#define SPINS_PER_YIELD 63 +#if defined(_MSC_VER) +#define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ +#define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) +#elif defined (__SVR4) && defined (__sun) /* solaris */ +#define SPIN_LOCK_YIELD thr_yield(); +#elif !defined(LACKS_SCHED_H) +#define SPIN_LOCK_YIELD sched_yield(); +#else +#define SPIN_LOCK_YIELD +#endif /* ... yield ... */ + +#if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 +/* Plain spin locks use single word (embedded in malloc_states) */ +static int spin_acquire_lock(int *sl) { + int spins = 0; + while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) { + if ((++spins & SPINS_PER_YIELD) == 0) { + SPIN_LOCK_YIELD; + } + } + return 0; +} + +#define MLOCK_T int +#define TRY_LOCK(sl) !CAS_LOCK(sl) +#define RELEASE_LOCK(sl) CLEAR_LOCK(sl) +#define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0) +#define INITIAL_LOCK(sl) (*sl = 0) +#define DESTROY_LOCK(sl) (0) +static MLOCK_T malloc_global_mutex = 0; + +#else /* USE_RECURSIVE_LOCKS */ +/* types for lock owners */ +#ifdef WIN32 +#define THREAD_ID_T DWORD +#define CURRENT_THREAD GetCurrentThreadId() +#define EQ_OWNER(X,Y) ((X) == (Y)) +#else +/* + Note: the following assume that pthread_t is a type that can be + initialized to (casted) zero. If this is not the case, you will need to + somehow redefine these or not use spin locks. +*/ +#define THREAD_ID_T pthread_t +#define CURRENT_THREAD pthread_self() +#define EQ_OWNER(X,Y) pthread_equal(X, Y) +#endif + +struct malloc_recursive_lock { + int sl; + unsigned int c; + THREAD_ID_T threadid; +}; + +#define MLOCK_T struct malloc_recursive_lock +static MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0}; + +static FORCEINLINE void recursive_release_lock(MLOCK_T *lk) { + assert(lk->sl != 0); + if (--lk->c == 0) { + CLEAR_LOCK(&lk->sl); + } +} + +static FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) { + THREAD_ID_T mythreadid = CURRENT_THREAD; + int spins = 0; + for (;;) { + if (*((volatile int *)(&lk->sl)) == 0) { + if (!CAS_LOCK(&lk->sl)) { + lk->threadid = mythreadid; + lk->c = 1; + return 0; + } + } + else if (EQ_OWNER(lk->threadid, mythreadid)) { + ++lk->c; + return 0; + } + if ((++spins & SPINS_PER_YIELD) == 0) { + SPIN_LOCK_YIELD; + } + } +} + +static FORCEINLINE int recursive_try_lock(MLOCK_T *lk) { + THREAD_ID_T mythreadid = CURRENT_THREAD; + if (*((volatile int *)(&lk->sl)) == 0) { + if (!CAS_LOCK(&lk->sl)) { + lk->threadid = mythreadid; + lk->c = 1; + return 1; + } + } + else if (EQ_OWNER(lk->threadid, mythreadid)) { + ++lk->c; + return 1; + } + return 0; +} + +#define RELEASE_LOCK(lk) recursive_release_lock(lk) +#define TRY_LOCK(lk) recursive_try_lock(lk) +#define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) +#define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) +#define DESTROY_LOCK(lk) (0) +#endif /* USE_RECURSIVE_LOCKS */ + +#elif defined(WIN32) /* Win32 critical sections */ +#define MLOCK_T CRITICAL_SECTION +#define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) +#define RELEASE_LOCK(lk) LeaveCriticalSection(lk) +#define TRY_LOCK(lk) TryEnterCriticalSection(lk) +#define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000)) +#define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) +#define NEED_GLOBAL_LOCK_INIT + +static MLOCK_T malloc_global_mutex; +static volatile LONG malloc_global_mutex_status; + +/* Use spin loop to initialize global lock */ +static void init_malloc_global_mutex() { + for (;;) { + long stat = malloc_global_mutex_status; + if (stat > 0) + return; + /* transition to < 0 while initializing, then to > 0) */ + if (stat == 0 && + interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) { + InitializeCriticalSection(&malloc_global_mutex); + interlockedexchange(&malloc_global_mutex_status, (LONG)1); + return; + } + SleepEx(0, FALSE); + } +} + +#else /* pthreads-based locks */ +#define MLOCK_T pthread_mutex_t +#define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) +#define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) +#define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) +#define INITIAL_LOCK(lk) pthread_init_lock(lk) +#define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) + +#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) +/* Cope with old-style linux recursive lock initialization by adding */ +/* skipped internal declaration from pthread.h */ +extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, + int __kind)); +#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP +#define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) +#endif /* USE_RECURSIVE_LOCKS ... */ + +static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER; + +static int pthread_init_lock (MLOCK_T *lk) { + pthread_mutexattr_t attr; + if (pthread_mutexattr_init(&attr)) return 1; +#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 + if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; +#endif + if (pthread_mutex_init(lk, &attr)) return 1; + if (pthread_mutexattr_destroy(&attr)) return 1; + return 0; +} + +#endif /* ... lock types ... */ + +/* Common code for all lock types */ +#define USE_LOCK_BIT (2U) + +#ifndef ACQUIRE_MALLOC_GLOBAL_LOCK +#define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); +#endif + +#ifndef RELEASE_MALLOC_GLOBAL_LOCK +#define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); +#endif + +#endif /* USE_LOCKS */ + +/* ----------------------- Chunk representations ------------------------ */ + +/* + (The following includes lightly edited explanations by Colin Plumb.) + + The malloc_chunk declaration below is misleading (but accurate and + necessary). It declares a "view" into memory allowing access to + necessary fields at known offsets from a given base. + + Chunks of memory are maintained using a `boundary tag' method as + originally described by Knuth. (See the paper by Paul Wilson + ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such + techniques.) Sizes of free chunks are stored both in the front of + each chunk and at the end. This makes consolidating fragmented + chunks into bigger chunks fast. The head fields also hold bits + representing whether chunks are free or in use. + + Here are some pictures to make it clearer. They are "exploded" to + show that the state of a chunk can be thought of as extending from + the high 31 bits of the head field of its header through the + prev_foot and PINUSE_BIT bit of the following chunk header. + + A chunk that's in use looks like: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk (if P = 0) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| + | Size of this chunk 1| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | | + +- -+ + | | + +- -+ + | : + +- size - sizeof(size_t) available payload bytes -+ + : | + chunk-> +- -+ + | | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| + | Size of next chunk (may or may not be in use) | +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + And if it's free, it looks like this: + + chunk-> +- -+ + | User payload (must be in use, or we would have merged!) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| + | Size of this chunk 0| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Next pointer | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Prev pointer | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | : + +- size - sizeof(struct chunk) unused bytes -+ + : | + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of this chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| + | Size of next chunk (must be in use, or we would have merged)| +-+ + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | : + +- User payload -+ + : | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + |0| + +-+ + Note that since we always merge adjacent free chunks, the chunks + adjacent to a free chunk must be in use. + + Given a pointer to a chunk (which can be derived trivially from the + payload pointer) we can, in O(1) time, find out whether the adjacent + chunks are free, and if so, unlink them from the lists that they + are on and merge them with the current chunk. + + Chunks always begin on even word boundaries, so the mem portion + (which is returned to the user) is also on an even word boundary, and + thus at least double-word aligned. + + The P (PINUSE_BIT) bit, stored in the unused low-order bit of the + chunk size (which is always a multiple of two words), is an in-use + bit for the *previous* chunk. If that bit is *clear*, then the + word before the current chunk size contains the previous chunk + size, and can be used to find the front of the previous chunk. + The very first chunk allocated always has this bit set, preventing + access to non-existent (or non-owned) memory. If pinuse is set for + any given chunk, then you CANNOT determine the size of the + previous chunk, and might even get a memory addressing fault when + trying to do so. + + The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of + the chunk size redundantly records whether the current chunk is + inuse (unless the chunk is mmapped). This redundancy enables usage + checks within free and realloc, and reduces indirection when freeing + and consolidating chunks. + + Each freshly allocated chunk must have both cinuse and pinuse set. + That is, each allocated chunk borders either a previously allocated + and still in-use chunk, or the base of its memory arena. This is + ensured by making all allocations from the `lowest' part of any + found chunk. Further, no free chunk physically borders another one, + so each free chunk is known to be preceded and followed by either + inuse chunks or the ends of memory. + + Note that the `foot' of the current chunk is actually represented + as the prev_foot of the NEXT chunk. This makes it easier to + deal with alignments etc but can be very confusing when trying + to extend or adapt this code. + + The exceptions to all this are + + 1. The special chunk `top' is the top-most available chunk (i.e., + the one bordering the end of available memory). It is treated + specially. Top is never included in any bin, is used only if + no other chunk is available, and is released back to the + system if it is very large (see M_TRIM_THRESHOLD). In effect, + the top chunk is treated as larger (and thus less well + fitting) than any other available chunk. The top chunk + doesn't update its trailing size field since there is no next + contiguous chunk that would have to index off it. However, + space is still allocated for it (TOP_FOOT_SIZE) to enable + separation or merging when space is extended. + + 3. Chunks allocated via mmap, have both cinuse and pinuse bits + cleared in their head fields. Because they are allocated + one-by-one, each must carry its own prev_foot field, which is + also used to hold the offset this chunk has within its mmapped + region, which is needed to preserve alignment. Each mmapped + chunk is trailed by the first two fields of a fake next-chunk + for sake of usage checks. + +*/ + +struct malloc_chunk { + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk* fd; /* double links -- used only if free. */ + struct malloc_chunk* bk; +}; + +typedef struct malloc_chunk mchunk; +typedef struct malloc_chunk* mchunkptr; +typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ +typedef unsigned int bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ + +/* ------------------- Chunks sizes and alignments ----------------------- */ + +#define MCHUNK_SIZE (sizeof(mchunk)) + +#if FOOTERS +#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +#else /* FOOTERS */ +#define CHUNK_OVERHEAD (SIZE_T_SIZE) +#endif /* FOOTERS */ + +/* MMapped chunks need a second word of overhead ... */ +#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +/* ... and additional padding for fake next-chunk at foot */ +#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) + +/* The smallest size we can malloc is an aligned minimal chunk */ +#define MIN_CHUNK_SIZE\ + ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* conversion from malloc headers to user pointers, and back */ +#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) +#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) +/* chunk associated with aligned address A */ +#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) + +/* Bounds on request (not chunk) sizes. */ +#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) +#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) + +/* pad request bytes into a usable size */ +#define pad_request(req) \ + (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + +/* pad request, checking for minimum (but not maximum) */ +#define request2size(req) \ + (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) + + +/* ------------------ Operations on head and foot fields ----------------- */ + +/* + The head field of a chunk is or'ed with PINUSE_BIT when previous + adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in + use, unless mmapped, in which case both bits are cleared. + + FLAG4_BIT is not used by this malloc, but might be useful in extensions. +*/ + +#define PINUSE_BIT (SIZE_T_ONE) +#define CINUSE_BIT (SIZE_T_TWO) +#define FLAG4_BIT (SIZE_T_FOUR) +#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) +#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) + +/* Head value for fenceposts */ +#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) + +/* extraction of fields from head words */ +#define cinuse(p) ((p)->head & CINUSE_BIT) +#define pinuse(p) ((p)->head & PINUSE_BIT) +#define flag4inuse(p) ((p)->head & FLAG4_BIT) +#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) +#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) + +#define chunksize(p) ((p)->head & ~(FLAG_BITS)) + +#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) +#define set_flag4(p) ((p)->head |= FLAG4_BIT) +#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) + +/* Treat space at ptr +/- offset as a chunk */ +#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) +#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) + +/* Ptr to next or previous physical malloc_chunk. */ +#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) +#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) + +/* extract next chunk's pinuse bit */ +#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) + +/* Get/set size at footer */ +#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) +#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) + +/* Set size, pinuse bit, and foot */ +#define set_size_and_pinuse_of_free_chunk(p, s)\ + ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) + +/* Set size, pinuse bit, foot, and clear next pinuse */ +#define set_free_with_pinuse(p, s, n)\ + (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) + +/* Get the internal overhead associated with chunk p */ +#define overhead_for(p)\ + (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) + +/* Return true if malloced space is not necessarily cleared */ +#if MMAP_CLEARS +#define calloc_must_clear(p) (!is_mmapped(p)) +#else /* MMAP_CLEARS */ +#define calloc_must_clear(p) (1) +#endif /* MMAP_CLEARS */ + +/* ---------------------- Overlaid data structures ----------------------- */ + +/* + When chunks are not in use, they are treated as nodes of either + lists or trees. + + "Small" chunks are stored in circular doubly-linked lists, and look + like this: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `head:' | Size of chunk, in bytes |P| + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Forward pointer to next chunk in list | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Back pointer to previous chunk in list | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Unused space (may be 0 bytes long) . + . . + . | +nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `foot:' | Size of chunk, in bytes | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Larger chunks are kept in a form of bitwise digital trees (aka + tries) keyed on chunksizes. Because malloc_tree_chunks are only for + free chunks greater than 256 bytes, their size doesn't impose any + constraints on user chunk sizes. Each node looks like: + + chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Size of previous chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `head:' | Size of chunk, in bytes |P| + mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Forward pointer to next chunk of same size | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Back pointer to previous chunk of same size | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to left child (child[0]) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to right child (child[1]) | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Pointer to parent | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | bin index of this chunk | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + | Unused space . + . | +nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + `foot:' | Size of chunk, in bytes | + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + + Each tree holding treenodes is a tree of unique chunk sizes. Chunks + of the same size are arranged in a circularly-linked list, with only + the oldest chunk (the next to be used, in our FIFO ordering) + actually in the tree. (Tree members are distinguished by a non-null + parent pointer.) If a chunk with the same size an an existing node + is inserted, it is linked off the existing node using pointers that + work in the same way as fd/bk pointers of small chunks. + + Each tree contains a power of 2 sized range of chunk sizes (the + smallest is 0x100 <= x < 0x180), which is is divided in half at each + tree level, with the chunks in the smaller half of the range (0x100 + <= x < 0x140 for the top nose) in the left subtree and the larger + half (0x140 <= x < 0x180) in the right subtree. This is, of course, + done by inspecting individual bits. + + Using these rules, each node's left subtree contains all smaller + sizes than its right subtree. However, the node at the root of each + subtree has no particular ordering relationship to either. (The + dividing line between the subtree sizes is based on trie relation.) + If we remove the last chunk of a given size from the interior of the + tree, we need to replace it with a leaf node. The tree ordering + rules permit a node to be replaced by any leaf below it. + + The smallest chunk in a tree (a common operation in a best-fit + allocator) can be found by walking a path to the leftmost leaf in + the tree. Unlike a usual binary tree, where we follow left child + pointers until we reach a null, here we follow the right child + pointer any time the left one is null, until we reach a leaf with + both child pointers null. The smallest chunk in the tree will be + somewhere along that path. + + The worst case number of steps to add, find, or remove a node is + bounded by the number of bits differentiating chunks within + bins. Under current bin calculations, this ranges from 6 up to 21 + (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case + is of course much better. +*/ + +struct malloc_tree_chunk { + /* The first four fields must be compatible with malloc_chunk */ + size_t prev_foot; + size_t head; + struct malloc_tree_chunk* fd; + struct malloc_tree_chunk* bk; + + struct malloc_tree_chunk* child[2]; + struct malloc_tree_chunk* parent; + bindex_t index; +}; + +typedef struct malloc_tree_chunk tchunk; +typedef struct malloc_tree_chunk* tchunkptr; +typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ + +/* A little helper macro for trees */ +#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) + +/* ----------------------------- Segments -------------------------------- */ + +/* + Each malloc space may include non-contiguous segments, held in a + list headed by an embedded malloc_segment record representing the + top-most space. Segments also include flags holding properties of + the space. Large chunks that are directly allocated by mmap are not + included in this list. They are instead independently created and + destroyed without otherwise keeping track of them. + + Segment management mainly comes into play for spaces allocated by + MMAP. Any call to MMAP might or might not return memory that is + adjacent to an existing segment. MORECORE normally contiguously + extends the current space, so this space is almost always adjacent, + which is simpler and faster to deal with. (This is why MORECORE is + used preferentially to MMAP when both are available -- see + sys_alloc.) When allocating using MMAP, we don't use any of the + hinting mechanisms (inconsistently) supported in various + implementations of unix mmap, or distinguish reserving from + committing memory. Instead, we just ask for space, and exploit + contiguity when we get it. It is probably possible to do + better than this on some systems, but no general scheme seems + to be significantly better. + + Management entails a simpler variant of the consolidation scheme + used for chunks to reduce fragmentation -- new adjacent memory is + normally prepended or appended to an existing segment. However, + there are limitations compared to chunk consolidation that mostly + reflect the fact that segment processing is relatively infrequent + (occurring only when getting memory from system) and that we + don't expect to have huge numbers of segments: + + * Segments are not indexed, so traversal requires linear scans. (It + would be possible to index these, but is not worth the extra + overhead and complexity for most programs on most platforms.) + * New segments are only appended to old ones when holding top-most + memory; if they cannot be prepended to others, they are held in + different segments. + + Except for the top-most segment of an mstate, each segment record + is kept at the tail of its segment. Segments are added by pushing + segment records onto the list headed by &mstate.seg for the + containing mstate. + + Segment flags control allocation/merge/deallocation policies: + * If EXTERN_BIT set, then we did not allocate this segment, + and so should not try to deallocate or merge with others. + (This currently holds only for the initial segment passed + into create_mspace_with_base.) + * If USE_MMAP_BIT set, the segment may be merged with + other surrounding mmapped segments and trimmed/de-allocated + using munmap. + * If neither bit is set, then the segment was obtained using + MORECORE so can be merged with surrounding MORECORE'd segments + and deallocated/trimmed using MORECORE with negative arguments. +*/ + +struct malloc_segment { + char* base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment* next; /* ptr to next segment */ + flag_t sflags; /* mmap and extern flag */ +}; + +#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) +#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) + +typedef struct malloc_segment msegment; +typedef struct malloc_segment* msegmentptr; + +/* ---------------------------- malloc_state ----------------------------- */ + +/* + A malloc_state holds all of the bookkeeping for a space. + The main fields are: + + Top + The topmost chunk of the currently active segment. Its size is + cached in topsize. The actual size of topmost space is + topsize+TOP_FOOT_SIZE, which includes space reserved for adding + fenceposts and segment records if necessary when getting more + space from the system. The size at which to autotrim top is + cached from mparams in trim_check, except that it is disabled if + an autotrim fails. + + Designated victim (dv) + This is the preferred chunk for servicing small requests that + don't have exact fits. It is normally the chunk split off most + recently to service another small request. Its size is cached in + dvsize. The link fields of this chunk are not maintained since it + is not kept in a bin. + + SmallBins + An array of bin headers for free chunks. These bins hold chunks + with sizes less than MIN_LARGE_SIZE bytes. Each bin contains + chunks of all the same size, spaced 8 bytes apart. To simplify + use in double-linked lists, each bin header acts as a malloc_chunk + pointing to the real first node, if it exists (else pointing to + itself). This avoids special-casing for headers. But to avoid + waste, we allocate only the fd/bk pointers of bins, and then use + repositioning tricks to treat these as the fields of a chunk. + + TreeBins + Treebins are pointers to the roots of trees holding a range of + sizes. There are 2 equally spaced treebins for each power of two + from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything + larger. + + Bin maps + There is one bit map for small bins ("smallmap") and one for + treebins ("treemap). Each bin sets its bit when non-empty, and + clears the bit when empty. Bit operations are then used to avoid + bin-by-bin searching -- nearly all "search" is done without ever + looking at bins that won't be selected. The bit maps + conservatively use 32 bits per map word, even if on 64bit system. + For a good description of some of the bit-based techniques used + here, see Henry S. Warren Jr's book "Hacker's Delight" (and + supplement at http://hackersdelight.org/). Many of these are + intended to reduce the branchiness of paths through malloc etc, as + well as to reduce the number of memory locations read or written. + + Segments + A list of segments headed by an embedded malloc_segment record + representing the initial space. + + Address check support + The least_addr field is the least address ever obtained from + MORECORE or MMAP. Attempted frees and reallocs of any address less + than this are trapped (unless INSECURE is defined). + + Magic tag + A cross-check field that should always hold same value as mparams.magic. + + Max allowed footprint + The maximum allowed bytes to allocate from system (zero means no limit) + + Flags + Bits recording whether to use MMAP, locks, or contiguous MORECORE + + Statistics + Each space keeps track of current and maximum system memory + obtained via MORECORE or MMAP. + + Trim support + Fields holding the amount of unused topmost memory that should trigger + trimming, and a counter to force periodic scanning to release unused + non-topmost segments. + + Locking + If USE_LOCKS is defined, the "mutex" lock is acquired and released + around every public call using this mspace. + + Extension support + A void* pointer and a size_t field that can be used to help implement + extensions to this malloc. +*/ + +/* Bin types, widths and sizes */ +#define NSMALLBINS (32U) +#define NTREEBINS (32U) +#define SMALLBIN_SHIFT (3U) +#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) +#define TREEBIN_SHIFT (8U) +#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) +#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) +#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) + +struct malloc_state { + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + char* least_addr; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t release_checks; + size_t magic; + mchunkptr smallbins[(NSMALLBINS+1)*2]; + tbinptr treebins[NTREEBINS]; + size_t footprint; + size_t max_footprint; + size_t footprint_limit; /* zero means no limit */ + flag_t mflags; +#if USE_LOCKS + MLOCK_T mutex; /* locate lock among fields that rarely change */ +#endif /* USE_LOCKS */ + msegment seg; + void* extp; /* Unused but available for extensions */ + size_t exts; +}; + +typedef struct malloc_state* mstate; + +/* ------------- Global malloc_state and malloc_params ------------------- */ + +/* + malloc_params holds global properties, including those that can be + dynamically set using mallopt. There is a single instance, mparams, + initialized in init_mparams. Note that the non-zeroness of "magic" + also serves as an initialization flag. +*/ + +struct malloc_params { + size_t magic; + size_t page_size; + size_t granularity; + size_t mmap_threshold; + size_t trim_threshold; + flag_t default_mflags; +}; + +static struct malloc_params mparams; + +/* Ensure mparams initialized */ +#define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) + +#if !ONLY_MSPACES + +/* The global malloc_state used for all non-"mspace" calls */ +static struct malloc_state _gm_; +#define gm (&_gm_) +#define is_global(M) ((M) == &_gm_) + +#endif /* !ONLY_MSPACES */ + +#define is_initialized(M) ((M)->top != 0) + +/* -------------------------- system alloc setup ------------------------- */ + +/* Operations on mflags */ + +#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) +#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) +#if USE_LOCKS +#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) +#else +#define disable_lock(M) +#endif + +#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) +#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) +#if HAVE_MMAP +#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) +#else +#define disable_mmap(M) +#endif + +#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) +#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) + +#define set_lock(M,L)\ + ((M)->mflags = (L)?\ + ((M)->mflags | USE_LOCK_BIT) :\ + ((M)->mflags & ~USE_LOCK_BIT)) + +/* page-align a size */ +#define page_align(S)\ + (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) + +/* granularity-align a size */ +#define granularity_align(S)\ + (((S) + (mparams.granularity - SIZE_T_ONE))\ + & ~(mparams.granularity - SIZE_T_ONE)) + + +/* For mmap, use granularity alignment on windows, else page-align */ +#ifdef WIN32 +#define mmap_align(S) granularity_align(S) +#else +#define mmap_align(S) page_align(S) +#endif + +/* For sys_alloc, enough padding to ensure can malloc request on success */ +#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) + +#define is_page_aligned(S)\ + (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) +#define is_granularity_aligned(S)\ + (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) + +/* True if segment S holds address A */ +#define segment_holds(S, A)\ + ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) + +/* Return segment holding given address */ +static msegmentptr segment_holding(mstate m, char* addr) { + msegmentptr sp = &m->seg; + for (;;) { + if (addr >= sp->base && addr < sp->base + sp->size) + return sp; + if ((sp = sp->next) == 0) + return 0; + } +} + +/* Return true if segment contains a segment link */ +static int has_segment_link(mstate m, msegmentptr ss) { + msegmentptr sp = &m->seg; + for (;;) { + if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) + return 1; + if ((sp = sp->next) == 0) + return 0; + } +} + +#ifndef MORECORE_CANNOT_TRIM +#define should_trim(M,s) ((s) > (M)->trim_check) +#else /* MORECORE_CANNOT_TRIM */ +#define should_trim(M,s) (0) +#endif /* MORECORE_CANNOT_TRIM */ + +/* + TOP_FOOT_SIZE is padding at the end of a segment, including space + that may be needed to place segment records and fenceposts when new + noncontiguous segments are added. +*/ +#define TOP_FOOT_SIZE\ + (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) + + +/* ------------------------------- Hooks -------------------------------- */ + +/* + PREACTION should be defined to return 0 on success, and nonzero on + failure. If you are not using locking, you can redefine these to do + anything you like. +*/ + +#if USE_LOCKS +#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) +#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } +#else /* USE_LOCKS */ + +#ifndef PREACTION +#define PREACTION(M) (0) +#endif /* PREACTION */ + +#ifndef POSTACTION +#define POSTACTION(M) +#endif /* POSTACTION */ + +#endif /* USE_LOCKS */ + +/* + CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. + USAGE_ERROR_ACTION is triggered on detected bad frees and + reallocs. The argument p is an address that might have triggered the + fault. It is ignored by the two predefined actions, but might be + useful in custom actions that try to help diagnose errors. +*/ + +#if PROCEED_ON_ERROR + +/* A count of the number of corruption errors causing resets */ +int malloc_corruption_error_count; + +/* default corruption action */ +static void reset_on_error(mstate m); + +#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) +#define USAGE_ERROR_ACTION(m, p) + +#else /* PROCEED_ON_ERROR */ + +#ifndef CORRUPTION_ERROR_ACTION +#define CORRUPTION_ERROR_ACTION(m) ABORT +#endif /* CORRUPTION_ERROR_ACTION */ + +#ifndef USAGE_ERROR_ACTION +#define USAGE_ERROR_ACTION(m,p) ABORT +#endif /* USAGE_ERROR_ACTION */ + +#endif /* PROCEED_ON_ERROR */ + + +/* -------------------------- Debugging setup ---------------------------- */ + +#if ! DEBUG + +#define check_free_chunk(M,P) +#define check_inuse_chunk(M,P) +#define check_malloced_chunk(M,P,N) +#define check_mmapped_chunk(M,P) +#define check_malloc_state(M) +#define check_top_chunk(M,P) + +#else /* DEBUG */ +#define check_free_chunk(M,P) do_check_free_chunk(M,P) +#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) +#define check_top_chunk(M,P) do_check_top_chunk(M,P) +#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) +#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) +#define check_malloc_state(M) do_check_malloc_state(M) + +static void do_check_any_chunk(mstate m, mchunkptr p); +static void do_check_top_chunk(mstate m, mchunkptr p); +static void do_check_mmapped_chunk(mstate m, mchunkptr p); +static void do_check_inuse_chunk(mstate m, mchunkptr p); +static void do_check_free_chunk(mstate m, mchunkptr p); +static void do_check_malloced_chunk(mstate m, void* mem, size_t s); +static void do_check_tree(mstate m, tchunkptr t); +static void do_check_treebin(mstate m, bindex_t i); +static void do_check_smallbin(mstate m, bindex_t i); +static void do_check_malloc_state(mstate m); +static int bin_find(mstate m, mchunkptr x); +static size_t traverse_and_check(mstate m); +#endif /* DEBUG */ + +/* ---------------------------- Indexing Bins ---------------------------- */ + +#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) +#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) +#define small_index2size(i) ((i) << SMALLBIN_SHIFT) +#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) + +/* addressing by index. See above about smallbin repositioning */ +#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) +#define treebin_at(M,i) (&((M)->treebins[i])) + +/* assign tree index for size S to variable I. Use x86 asm if possible */ +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +#define compute_tree_index(S, I)\ +{\ + unsigned int X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} + +#elif defined (__INTEL_COMPILER) +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K = _bit_scan_reverse (X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} + +#elif defined(_MSC_VER) && _MSC_VER>=1300 +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K;\ + _BitScanReverse((DWORD *) &K, (DWORD) X);\ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} + +#else /* GNUC */ +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int Y = (unsigned int)X;\ + unsigned int N = ((Y - 0x100) >> 16) & 8;\ + unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ + N += K;\ + N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ + K = 14 - N + ((Y <<= K) >> 15);\ + I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ + }\ +} +#endif /* GNUC */ + +/* Bit representing maximum resolved size in a treebin at i */ +#define bit_for_tree_index(i) \ + (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) + +/* Shift placing maximum resolved bit in a treebin at i as sign bit */ +#define leftshift_for_tree_index(i) \ + ((i == NTREEBINS-1)? 0 : \ + ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + +/* The size of the smallest chunk held in bin with index i */ +#define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ + (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) + + +/* ------------------------ Operations on bin maps ----------------------- */ + +/* bit corresponding to given index */ +#define idx2bit(i) ((binmap_t)(1) << (i)) + +/* Mark/Clear bits with given index */ +#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) +#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) +#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) + +#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) +#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) +#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) + +/* isolate the least set bit of a bitmap */ +#define least_bit(x) ((x) & -(x)) + +/* mask with all bits to left of least bit of x on */ +#define left_bits(x) ((x<<1) | -(x<<1)) + +/* mask with all bits to left of or equal to least bit of x on */ +#define same_or_left_bits(x) ((x) | -(x)) + +/* index corresponding to given bit. Use x86 asm if possible */ + +#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + J = __builtin_ctz(X); \ + I = (bindex_t)J;\ +} + +#elif defined (__INTEL_COMPILER) +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + J = _bit_scan_forward (X); \ + I = (bindex_t)J;\ +} + +#elif defined(_MSC_VER) && _MSC_VER>=1300 +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + _BitScanForward((DWORD *) &J, X);\ + I = (bindex_t)J;\ +} + +#elif USE_BUILTIN_FFS +#define compute_bit2idx(X, I) I = ffs(X)-1 + +#else +#define compute_bit2idx(X, I)\ +{\ + unsigned int Y = X - 1;\ + unsigned int K = Y >> (16-4) & 16;\ + unsigned int N = K; Y >>= K;\ + N += K = Y >> (8-3) & 8; Y >>= K;\ + N += K = Y >> (4-2) & 4; Y >>= K;\ + N += K = Y >> (2-1) & 2; Y >>= K;\ + N += K = Y >> (1-0) & 1; Y >>= K;\ + I = (bindex_t)(N + Y);\ +} +#endif /* GNUC */ + + +/* ----------------------- Runtime Check Support ------------------------- */ + +/* + For security, the main invariant is that malloc/free/etc never + writes to a static address other than malloc_state, unless static + malloc_state itself has been corrupted, which cannot occur via + malloc (because of these checks). In essence this means that we + believe all pointers, sizes, maps etc held in malloc_state, but + check all of those linked or offsetted from other embedded data + structures. These checks are interspersed with main code in a way + that tends to minimize their run-time cost. + + When FOOTERS is defined, in addition to range checking, we also + verify footer fields of inuse chunks, which can be used guarantee + that the mstate controlling malloc/free is intact. This is a + streamlined version of the approach described by William Robertson + et al in "Run-time Detection of Heap-based Overflows" LISA'03 + http://www.usenix.org/events/lisa03/tech/robertson.html The footer + of an inuse chunk holds the xor of its mstate and a random seed, + that is checked upon calls to free() and realloc(). This is + (probabalistically) unguessable from outside the program, but can be + computed by any code successfully malloc'ing any chunk, so does not + itself provide protection against code that has already broken + security through some other means. Unlike Robertson et al, we + always dynamically check addresses of all offset chunks (previous, + next, etc). This turns out to be cheaper than relying on hashes. +*/ + +#if !INSECURE +/* Check if address a is at least as high as any from MORECORE or MMAP */ +#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) +/* Check if address of next chunk n is higher than base chunk p */ +#define ok_next(p, n) ((char*)(p) < (char*)(n)) +/* Check if p has inuse status */ +#define ok_inuse(p) is_inuse(p) +/* Check if p has its pinuse bit on */ +#define ok_pinuse(p) pinuse(p) + +#else /* !INSECURE */ +#define ok_address(M, a) (1) +#define ok_next(b, n) (1) +#define ok_inuse(p) (1) +#define ok_pinuse(p) (1) +#endif /* !INSECURE */ + +#if (FOOTERS && !INSECURE) +/* Check if (alleged) mstate m has expected magic field */ +#define ok_magic(M) ((M)->magic == mparams.magic) +#else /* (FOOTERS && !INSECURE) */ +#define ok_magic(M) (1) +#endif /* (FOOTERS && !INSECURE) */ + +/* In gcc, use __builtin_expect to minimize impact of checks */ +#if !INSECURE +#if defined(__GNUC__) && __GNUC__ >= 3 +#define RTCHECK(e) __builtin_expect(e, 1) +#else /* GNUC */ +#define RTCHECK(e) (e) +#endif /* GNUC */ +#else /* !INSECURE */ +#define RTCHECK(e) (1) +#endif /* !INSECURE */ + +/* macros to set up inuse chunks with or without footers */ + +#if !FOOTERS + +#define mark_inuse_foot(M,p,s) + +/* Macros for setting head/foot of non-mmapped chunks */ + +/* Set cinuse bit and pinuse bit of next chunk */ +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + +/* Set size, cinuse and pinuse bit of this chunk */ +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) + +#else /* FOOTERS */ + +/* Set foot of inuse chunk to be xor of mstate and seed */ +#define mark_inuse_foot(M,p,s)\ + (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) + +#define get_mstate_for(p)\ + ((mstate)(((mchunkptr)((char*)(p) +\ + (chunksize(p))))->prev_foot ^ mparams.magic)) + +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M,p,s)) + +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ + mark_inuse_foot(M,p,s)) + +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + mark_inuse_foot(M, p, s)) + +#endif /* !FOOTERS */ + +/* ---------------------------- setting mparams -------------------------- */ + +#if LOCK_AT_FORK +static void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); } +static void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); } +static void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); } +#endif /* LOCK_AT_FORK */ + +/* Initialize mparams */ +static int init_mparams(void) { +#ifdef NEED_GLOBAL_LOCK_INIT + if (malloc_global_mutex_status <= 0) + init_malloc_global_mutex(); +#endif + + ACQUIRE_MALLOC_GLOBAL_LOCK(); + if (mparams.magic == 0) { + size_t magic; + size_t psize; + size_t gsize; + +#ifndef WIN32 + psize = malloc_getpagesize; + gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); +#else /* WIN32 */ + { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + psize = system_info.dwPageSize; + gsize = ((DEFAULT_GRANULARITY != 0)? + DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); + } +#endif /* WIN32 */ + + /* Sanity-check configuration: + size_t must be unsigned and as wide as pointer type. + ints must be at least 4 bytes. + alignment must be at least 8. + Alignment, min chunk size, and page size must all be powers of 2. + */ + if ((sizeof(size_t) != sizeof(char*)) || + (MAX_SIZE_T < MIN_CHUNK_SIZE) || + (sizeof(int) < 4) || + (MALLOC_ALIGNMENT < (size_t)8U) || + ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || + ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || + ((gsize & (gsize-SIZE_T_ONE)) != 0) || + ((psize & (psize-SIZE_T_ONE)) != 0)) + ABORT; + mparams.granularity = gsize; + mparams.page_size = psize; + mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; + mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; +#if MORECORE_CONTIGUOUS + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; +#else /* MORECORE_CONTIGUOUS */ + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; +#endif /* MORECORE_CONTIGUOUS */ + +#if !ONLY_MSPACES + /* Set up lock for main malloc area */ + gm->mflags = mparams.default_mflags; + (void)INITIAL_LOCK(&gm->mutex); +#endif +#if LOCK_AT_FORK + pthread_atfork(&pre_fork, &post_fork_parent, &post_fork_child); +#endif + + { +#if USE_DEV_RANDOM + int fd; + unsigned char buf[sizeof(size_t)]; + /* Try to use /dev/urandom, else fall back on using time */ + if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && + read(fd, buf, sizeof(buf)) == sizeof(buf)) { + magic = *((size_t *) buf); + close(fd); + } + else +#endif /* USE_DEV_RANDOM */ +#ifdef WIN32 + magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); +#elif defined(LACKS_TIME_H) + magic = (size_t)&magic ^ (size_t)0x55555555U; +#else + magic = (size_t)(time(0) ^ (size_t)0x55555555U); +#endif + magic |= (size_t)8U; /* ensure nonzero */ + magic &= ~(size_t)7U; /* improve chances of fault for bad values */ + /* Until memory modes commonly available, use volatile-write */ + (*(volatile size_t *)(&(mparams.magic))) = magic; + } + } + + RELEASE_MALLOC_GLOBAL_LOCK(); + return 1; +} + +/* support for mallopt */ +static int change_mparam(int param_number, int value) { + size_t val; + ensure_initialization(); + val = (value == -1)? MAX_SIZE_T : (size_t)value; + switch(param_number) { + case M_TRIM_THRESHOLD: + mparams.trim_threshold = val; + return 1; + case M_GRANULARITY: + if (val >= mparams.page_size && ((val & (val-1)) == 0)) { + mparams.granularity = val; + return 1; + } + else + return 0; + case M_MMAP_THRESHOLD: + mparams.mmap_threshold = val; + return 1; + default: + return 0; + } +} + +#if DEBUG +/* ------------------------- Debugging Support --------------------------- */ + +/* Check properties of any chunk, whether free, inuse, mmapped etc */ +static void do_check_any_chunk(mstate m, mchunkptr p) { + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); +} + +/* Check properties of top chunk */ +static void do_check_top_chunk(mstate m, mchunkptr p) { + msegmentptr sp = segment_holding(m, (char*)p); + size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ + assert(sp != 0); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(sz == m->topsize); + assert(sz > 0); + assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); + assert(pinuse(p)); + assert(!pinuse(chunk_plus_offset(p, sz))); +} + +/* Check properties of (inuse) mmapped chunks */ +static void do_check_mmapped_chunk(mstate m, mchunkptr p) { + size_t sz = chunksize(p); + size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); + assert(is_mmapped(p)); + assert(use_mmap(m)); + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); + assert(ok_address(m, p)); + assert(!is_small(sz)); + assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); + assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); + assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); +} + +/* Check properties of inuse chunks */ +static void do_check_inuse_chunk(mstate m, mchunkptr p) { + do_check_any_chunk(m, p); + assert(is_inuse(p)); + assert(next_pinuse(p)); + /* If not pinuse and not mmapped, previous chunk has OK offset */ + assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); + if (is_mmapped(p)) + do_check_mmapped_chunk(m, p); +} + +/* Check properties of free chunks */ +static void do_check_free_chunk(mstate m, mchunkptr p) { + size_t sz = chunksize(p); + mchunkptr next = chunk_plus_offset(p, sz); + do_check_any_chunk(m, p); + assert(!is_inuse(p)); + assert(!next_pinuse(p)); + assert (!is_mmapped(p)); + if (p != m->dv && p != m->top) { + if (sz >= MIN_CHUNK_SIZE) { + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(is_aligned(chunk2mem(p))); + assert(next->prev_foot == sz); + assert(pinuse(p)); + assert (next == m->top || is_inuse(next)); + assert(p->fd->bk == p); + assert(p->bk->fd == p); + } + else /* markers are always of size SIZE_T_SIZE */ + assert(sz == SIZE_T_SIZE); + } +} + +/* Check properties of malloced chunks at the point they are malloced */ +static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + size_t sz = p->head & ~INUSE_BITS; + do_check_inuse_chunk(m, p); + assert((sz & CHUNK_ALIGN_MASK) == 0); + assert(sz >= MIN_CHUNK_SIZE); + assert(sz >= s); + /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ + assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); + } +} + +/* Check a tree and its subtrees. */ +static void do_check_tree(mstate m, tchunkptr t) { + tchunkptr head = 0; + tchunkptr u = t; + bindex_t tindex = t->index; + size_t tsize = chunksize(t); + bindex_t idx; + compute_tree_index(tsize, idx); + assert(tindex == idx); + assert(tsize >= MIN_LARGE_SIZE); + assert(tsize >= minsize_for_tree_index(idx)); + assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); + + do { /* traverse through chain of same-sized nodes */ + do_check_any_chunk(m, ((mchunkptr)u)); + assert(u->index == tindex); + assert(chunksize(u) == tsize); + assert(!is_inuse(u)); + assert(!next_pinuse(u)); + assert(u->fd->bk == u); + assert(u->bk->fd == u); + if (u->parent == 0) { + assert(u->child[0] == 0); + assert(u->child[1] == 0); + } + else { + assert(head == 0); /* only one node on chain has parent */ + head = u; + assert(u->parent != u); + assert (u->parent->child[0] == u || + u->parent->child[1] == u || + *((tbinptr*)(u->parent)) == u); + if (u->child[0] != 0) { + assert(u->child[0]->parent == u); + assert(u->child[0] != u); + do_check_tree(m, u->child[0]); + } + if (u->child[1] != 0) { + assert(u->child[1]->parent == u); + assert(u->child[1] != u); + do_check_tree(m, u->child[1]); + } + if (u->child[0] != 0 && u->child[1] != 0) { + assert(chunksize(u->child[0]) < chunksize(u->child[1])); + } + } + u = u->fd; + } while (u != t); + assert(head != 0); +} + +/* Check all the chunks in a treebin. */ +static void do_check_treebin(mstate m, bindex_t i) { + tbinptr* tb = treebin_at(m, i); + tchunkptr t = *tb; + int empty = (m->treemap & (1U << i)) == 0; + if (t == 0) + assert(empty); + if (!empty) + do_check_tree(m, t); +} + +/* Check all the chunks in a smallbin. */ +static void do_check_smallbin(mstate m, bindex_t i) { + sbinptr b = smallbin_at(m, i); + mchunkptr p = b->bk; + unsigned int empty = (m->smallmap & (1U << i)) == 0; + if (p == b) + assert(empty); + if (!empty) { + for (; p != b; p = p->bk) { + size_t size = chunksize(p); + mchunkptr q; + /* each chunk claims to be free */ + do_check_free_chunk(m, p); + /* chunk belongs in bin */ + assert(small_index(size) == i); + assert(p->bk == b || chunksize(p->bk) == chunksize(p)); + /* chunk is followed by an inuse chunk */ + q = next_chunk(p); + if (q->head != FENCEPOST_HEAD) + do_check_inuse_chunk(m, q); + } + } +} + +/* Find x in a bin. Used in other check functions. */ +static int bin_find(mstate m, mchunkptr x) { + size_t size = chunksize(x); + if (is_small(size)) { + bindex_t sidx = small_index(size); + sbinptr b = smallbin_at(m, sidx); + if (smallmap_is_marked(m, sidx)) { + mchunkptr p = b; + do { + if (p == x) + return 1; + } while ((p = p->fd) != b); + } + } + else { + bindex_t tidx; + compute_tree_index(size, tidx); + if (treemap_is_marked(m, tidx)) { + tchunkptr t = *treebin_at(m, tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); + while (t != 0 && chunksize(t) != size) { + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + sizebits <<= 1; + } + if (t != 0) { + tchunkptr u = t; + do { + if (u == (tchunkptr)x) + return 1; + } while ((u = u->fd) != t); + } + } + } + return 0; +} + +/* Traverse each chunk and check it; return total */ +static size_t traverse_and_check(mstate m) { + size_t sum = 0; + if (is_initialized(m)) { + msegmentptr s = &m->seg; + sum += m->topsize + TOP_FOOT_SIZE; + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + mchunkptr lastq = 0; + assert(pinuse(q)); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + sum += chunksize(q); + if (is_inuse(q)) { + assert(!bin_find(m, q)); + do_check_inuse_chunk(m, q); + } + else { + assert(q == m->dv || bin_find(m, q)); + assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ + do_check_free_chunk(m, q); + } + lastq = q; + q = next_chunk(q); + } + s = s->next; + } + } + return sum; +} + + +/* Check all properties of malloc_state. */ +static void do_check_malloc_state(mstate m) { + bindex_t i; + size_t total; + /* check bins */ + for (i = 0; i < NSMALLBINS; ++i) + do_check_smallbin(m, i); + for (i = 0; i < NTREEBINS; ++i) + do_check_treebin(m, i); + + if (m->dvsize != 0) { /* check dv chunk */ + do_check_any_chunk(m, m->dv); + assert(m->dvsize == chunksize(m->dv)); + assert(m->dvsize >= MIN_CHUNK_SIZE); + assert(bin_find(m, m->dv) == 0); + } + + if (m->top != 0) { /* check top chunk */ + do_check_top_chunk(m, m->top); + /*assert(m->topsize == chunksize(m->top)); redundant */ + assert(m->topsize > 0); + assert(bin_find(m, m->top) == 0); + } + + total = traverse_and_check(m); + assert(total <= m->footprint); + assert(m->footprint <= m->max_footprint); +} +#endif /* DEBUG */ + +/* ----------------------------- statistics ------------------------------ */ + +#if !NO_MALLINFO +static struct mallinfo internal_mallinfo(mstate m) { + struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + ensure_initialization(); + if (!PREACTION(m)) { + check_malloc_state(m); + if (is_initialized(m)) { + size_t nfree = SIZE_T_ONE; /* top always free */ + size_t mfree = m->topsize + TOP_FOOT_SIZE; + size_t sum = mfree; + msegmentptr s = &m->seg; + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + size_t sz = chunksize(q); + sum += sz; + if (!is_inuse(q)) { + mfree += sz; + ++nfree; + } + q = next_chunk(q); + } + s = s->next; + } + + nm.arena = sum; + nm.ordblks = nfree; + nm.hblkhd = m->footprint - sum; + nm.usmblks = m->max_footprint; + nm.uordblks = m->footprint - mfree; + nm.fordblks = mfree; + nm.keepcost = m->topsize; + } + + POSTACTION(m); + } + return nm; +} +#endif /* !NO_MALLINFO */ + +#if !NO_MALLOC_STATS +static void internal_malloc_stats(mstate m) { + ensure_initialization(); + if (!PREACTION(m)) { + size_t maxfp = 0; + size_t fp = 0; + size_t used = 0; + check_malloc_state(m); + if (is_initialized(m)) { + msegmentptr s = &m->seg; + maxfp = m->max_footprint; + fp = m->footprint; + used = fp - (m->topsize + TOP_FOOT_SIZE); + + while (s != 0) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + if (!is_inuse(q)) + used -= chunksize(q); + q = next_chunk(q); + } + s = s->next; + } + } + POSTACTION(m); /* drop lock */ + fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); + fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); + fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); + } +} +#endif /* NO_MALLOC_STATS */ + +/* ----------------------- Operations on smallbins ----------------------- */ + +/* + Various forms of linking and unlinking are defined as macros. Even + the ones for trees, which are very long but have very short typical + paths. This is ugly but reduces reliance on inlining support of + compilers. +*/ + +/* Link a free chunk into a smallbin */ +#define insert_small_chunk(M, P, S) {\ + bindex_t I = small_index(S);\ + mchunkptr B = smallbin_at(M, I);\ + mchunkptr F = B;\ + assert(S >= MIN_CHUNK_SIZE);\ + if (!smallmap_is_marked(M, I))\ + mark_smallmap(M, I);\ + else if (RTCHECK(ok_address(M, B->fd)))\ + F = B->fd;\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + B->fd = P;\ + F->bk = P;\ + P->fd = F;\ + P->bk = B;\ +} + +/* Unlink a chunk from a smallbin */ +#define unlink_small_chunk(M, P, S) {\ + mchunkptr F = P->fd;\ + mchunkptr B = P->bk;\ + bindex_t I = small_index(S);\ + assert(P != B);\ + assert(P != F);\ + assert(chunksize(P) == small_index2size(I));\ + if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \ + if (B == F) {\ + clear_smallmap(M, I);\ + }\ + else if (RTCHECK(B == smallbin_at(M,I) ||\ + (ok_address(M, B) && B->fd == P))) {\ + F->bk = B;\ + B->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ +} + +/* Unlink the first chunk from a smallbin */ +#define unlink_first_small_chunk(M, B, P, I) {\ + mchunkptr F = P->fd;\ + assert(P != B);\ + assert(P != F);\ + assert(chunksize(P) == small_index2size(I));\ + if (B == F) {\ + clear_smallmap(M, I);\ + }\ + else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\ + F->bk = B;\ + B->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ +} + +/* Replace dv node, binning the old one */ +/* Used only when dvsize known to be small */ +#define replace_dv(M, P, S) {\ + size_t DVS = M->dvsize;\ + assert(is_small(DVS));\ + if (DVS != 0) {\ + mchunkptr DV = M->dv;\ + insert_small_chunk(M, DV, DVS);\ + }\ + M->dvsize = S;\ + M->dv = P;\ +} + +/* ------------------------- Operations on trees ------------------------- */ + +/* Insert chunk into tree */ +#define insert_large_chunk(M, X, S) {\ + tbinptr* H;\ + bindex_t I;\ + compute_tree_index(S, I);\ + H = treebin_at(M, I);\ + X->index = I;\ + X->child[0] = X->child[1] = 0;\ + if (!treemap_is_marked(M, I)) {\ + mark_treemap(M, I);\ + *H = X;\ + X->parent = (tchunkptr)H;\ + X->fd = X->bk = X;\ + }\ + else {\ + tchunkptr T = *H;\ + size_t K = S << leftshift_for_tree_index(I);\ + for (;;) {\ + if (chunksize(T) != S) {\ + tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ + K <<= 1;\ + if (*C != 0)\ + T = *C;\ + else if (RTCHECK(ok_address(M, C))) {\ + *C = X;\ + X->parent = T;\ + X->fd = X->bk = X;\ + break;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + break;\ + }\ + }\ + else {\ + tchunkptr F = T->fd;\ + if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ + T->fd = F->bk = X;\ + X->fd = F;\ + X->bk = T;\ + X->parent = 0;\ + break;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + break;\ + }\ + }\ + }\ + }\ +} + +/* + Unlink steps: + + 1. If x is a chained node, unlink it from its same-sized fd/bk links + and choose its bk node as its replacement. + 2. If x was the last node of its size, but not a leaf node, it must + be replaced with a leaf node (not merely one with an open left or + right), to make sure that lefts and rights of descendents + correspond properly to bit masks. We use the rightmost descendent + of x. We could use any other leaf, but this is easy to locate and + tends to counteract removal of leftmosts elsewhere, and so keeps + paths shorter than minimally guaranteed. This doesn't loop much + because on average a node in a tree is near the bottom. + 3. If x is the base of a chain (i.e., has parent links) relink + x's parent and children to x's replacement (or null if none). +*/ + +#define unlink_large_chunk(M, X) {\ + tchunkptr XP = X->parent;\ + tchunkptr R;\ + if (X->bk != X) {\ + tchunkptr F = X->fd;\ + R = X->bk;\ + if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) {\ + F->bk = R;\ + R->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else {\ + tchunkptr* RP;\ + if (((R = *(RP = &(X->child[1]))) != 0) ||\ + ((R = *(RP = &(X->child[0]))) != 0)) {\ + tchunkptr* CP;\ + while ((*(CP = &(R->child[1])) != 0) ||\ + (*(CP = &(R->child[0])) != 0)) {\ + R = *(RP = CP);\ + }\ + if (RTCHECK(ok_address(M, RP)))\ + *RP = 0;\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + }\ + if (XP != 0) {\ + tbinptr* H = treebin_at(M, X->index);\ + if (X == *H) {\ + if ((*H = R) == 0) \ + clear_treemap(M, X->index);\ + }\ + else if (RTCHECK(ok_address(M, XP))) {\ + if (XP->child[0] == X) \ + XP->child[0] = R;\ + else \ + XP->child[1] = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + if (R != 0) {\ + if (RTCHECK(ok_address(M, R))) {\ + tchunkptr C0, C1;\ + R->parent = XP;\ + if ((C0 = X->child[0]) != 0) {\ + if (RTCHECK(ok_address(M, C0))) {\ + R->child[0] = C0;\ + C0->parent = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + if ((C1 = X->child[1]) != 0) {\ + if (RTCHECK(ok_address(M, C1))) {\ + R->child[1] = C1;\ + C1->parent = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ +} + +/* Relays to large vs small bin operations */ + +#define insert_chunk(M, P, S)\ + if (is_small(S)) insert_small_chunk(M, P, S)\ + else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } + +#define unlink_chunk(M, P, S)\ + if (is_small(S)) unlink_small_chunk(M, P, S)\ + else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } + + +/* Relays to internal calls to malloc/free from realloc, memalign etc */ + +#if ONLY_MSPACES +#define internal_malloc(m, b) mspace_malloc(m, b) +#define internal_free(m, mem) mspace_free(m,mem); +#else /* ONLY_MSPACES */ +#if MSPACES +#define internal_malloc(m, b)\ + ((m == gm)? dlmalloc(b) : mspace_malloc(m, b)) +#define internal_free(m, mem)\ + if (m == gm) dlfree(mem); else mspace_free(m,mem); +#else /* MSPACES */ +#define internal_malloc(m, b) dlmalloc(b) +#define internal_free(m, mem) dlfree(mem) +#endif /* MSPACES */ +#endif /* ONLY_MSPACES */ + +/* ----------------------- Direct-mmapping chunks ----------------------- */ + +/* + Directly mmapped chunks are set up with an offset to the start of + the mmapped region stored in the prev_foot field of the chunk. This + allows reconstruction of the required argument to MUNMAP when freed, + and also allows adjustment of the returned chunk to meet alignment + requirements (especially in memalign). +*/ + +/* Malloc using mmap */ +static void* mmap_alloc(mstate m, size_t nb) { + size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + if (m->footprint_limit != 0) { + size_t fp = m->footprint + mmsize; + if (fp <= m->footprint || fp > m->footprint_limit) + return 0; + } + if (mmsize > nb) { /* Check for wrap around 0 */ + char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); + if (mm != CMFAIL) { + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - MMAP_FOOT_PAD; + mchunkptr p = (mchunkptr)(mm + offset); + p->prev_foot = offset; + p->head = psize; + mark_inuse_foot(m, p, psize); + chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; + + if (m->least_addr == 0 || mm < m->least_addr) + m->least_addr = mm; + if ((m->footprint += mmsize) > m->max_footprint) + m->max_footprint = m->footprint; + assert(is_aligned(chunk2mem(p))); + check_mmapped_chunk(m, p); + return chunk2mem(p); + } + } + return 0; +} + +/* Realloc using mmap */ +static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) { + size_t oldsize = chunksize(oldp); + (void)flags; /* placate people compiling -Wunused */ + if (is_small(nb)) /* Can't shrink mmap regions below small size */ + return 0; + /* Keep old chunk if big enough but not too big */ + if (oldsize >= nb + SIZE_T_SIZE && + (oldsize - nb) <= (mparams.granularity << 1)) + return oldp; + else { + size_t offset = oldp->prev_foot; + size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; + size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + char* cp = (char*)CALL_MREMAP((char*)oldp - offset, + oldmmsize, newmmsize, flags); + if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); + size_t psize = newmmsize - offset - MMAP_FOOT_PAD; + newp->head = psize; + mark_inuse_foot(m, newp, psize); + chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; + chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; + + if (cp < m->least_addr) + m->least_addr = cp; + if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) + m->max_footprint = m->footprint; + check_mmapped_chunk(m, newp); + return newp; + } + } + return 0; +} + + +/* -------------------------- mspace management -------------------------- */ + +/* Initialize top chunk and its size */ +static void init_top(mstate m, mchunkptr p, size_t psize) { + /* Ensure alignment */ + size_t offset = align_offset(chunk2mem(p)); + p = (mchunkptr)((char*)p + offset); + psize -= offset; + + m->top = p; + m->topsize = psize; + p->head = psize | PINUSE_BIT; + /* set size of fake trailing chunk holding overhead space only once */ + chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; + m->trim_check = mparams.trim_threshold; /* reset on each update */ +} + +/* Initialize bins for a new mstate that is otherwise zeroed out */ +static void init_bins(mstate m) { + /* Establish circular links for smallbins */ + bindex_t i; + for (i = 0; i < NSMALLBINS; ++i) { + sbinptr bin = smallbin_at(m,i); + bin->fd = bin->bk = bin; + } +} + +#if PROCEED_ON_ERROR + +/* default corruption action */ +static void reset_on_error(mstate m) { + int i; + ++malloc_corruption_error_count; + /* Reinitialize fields to forget about all memory */ + m->smallmap = m->treemap = 0; + m->dvsize = m->topsize = 0; + m->seg.base = 0; + m->seg.size = 0; + m->seg.next = 0; + m->top = m->dv = 0; + for (i = 0; i < NTREEBINS; ++i) + *treebin_at(m, i) = 0; + init_bins(m); +} +#endif /* PROCEED_ON_ERROR */ + +/* Allocate chunk and prepend remainder with chunk in successor base. */ +static void* prepend_alloc(mstate m, char* newbase, char* oldbase, + size_t nb) { + mchunkptr p = align_as_chunk(newbase); + mchunkptr oldfirst = align_as_chunk(oldbase); + size_t psize = (char*)oldfirst - (char*)p; + mchunkptr q = chunk_plus_offset(p, nb); + size_t qsize = psize - nb; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + + assert((char*)oldfirst > (char*)q); + assert(pinuse(oldfirst)); + assert(qsize >= MIN_CHUNK_SIZE); + + /* consolidate remainder with first chunk of old base */ + if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; + m->top = q; + q->head = tsize | PINUSE_BIT; + check_top_chunk(m, q); + } + else if (oldfirst == m->dv) { + size_t dsize = m->dvsize += qsize; + m->dv = q; + set_size_and_pinuse_of_free_chunk(q, dsize); + } + else { + if (!is_inuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); + unlink_chunk(m, oldfirst, nsize); + oldfirst = chunk_plus_offset(oldfirst, nsize); + qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); + insert_chunk(m, q, qsize); + check_free_chunk(m, q); + } + + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); +} + +/* Add a segment to hold a new noncontiguous region */ +static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { + /* Determine locations and sizes of segment, fenceposts, old top */ + char* old_top = (char*)m->top; + msegmentptr oldsp = segment_holding(m, old_top); + char* old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char* asp = rawsp + offset; + char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; + mchunkptr sp = (mchunkptr)csp; + msegmentptr ss = (msegmentptr)(chunk2mem(sp)); + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + int nfences = 0; + + /* reset top to new space */ + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + + /* Set up segment record */ + assert(is_aligned(ss)); + set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); + *ss = m->seg; /* Push current record */ + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.sflags = mmapped; + m->seg.next = ss; + + /* Insert trailing fenceposts */ + for (;;) { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); + p->head = FENCEPOST_HEAD; + ++nfences; + if ((char*)(&(nextp->head)) < old_end) + p = nextp; + else + break; + } + assert(nfences >= 2); + + /* Insert the rest of old top into a bin as an ordinary free chunk */ + if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; + size_t psize = csp - old_top; + mchunkptr tn = chunk_plus_offset(q, psize); + set_free_with_pinuse(q, psize, tn); + insert_chunk(m, q, psize); + } + + check_top_chunk(m, m->top); +} + +/* -------------------------- System allocation -------------------------- */ + +/* Get memory from system using MORECORE or MMAP */ +static void* sys_alloc(mstate m, size_t nb) { + char* tbase = CMFAIL; + size_t tsize = 0; + flag_t mmap_flag = 0; + size_t asize; /* allocation size */ + + ensure_initialization(); + + /* Directly map large chunks, but only if already initialized */ + if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { + void* mem = mmap_alloc(m, nb); + if (mem != 0) + return mem; + } + + asize = granularity_align(nb + SYS_ALLOC_PADDING); + if (asize <= nb) + return 0; /* wraparound */ + if (m->footprint_limit != 0) { + size_t fp = m->footprint + asize; + if (fp <= m->footprint || fp > m->footprint_limit) + return 0; + } + + /* + Try getting memory in any of three ways (in most-preferred to + least-preferred order): + 1. A call to MORECORE that can normally contiguously extend memory. + (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or + or main space is mmapped or a previous contiguous call failed) + 2. A call to MMAP new space (disabled if not HAVE_MMAP). + Note that under the default settings, if MORECORE is unable to + fulfill a request, and HAVE_MMAP is true, then mmap is + used as a noncontiguous system allocator. This is a useful backup + strategy for systems with holes in address spaces -- in this case + sbrk cannot contiguously expand the heap, but mmap may be able to + find space. + 3. A call to MORECORE that cannot usually contiguously extend memory. + (disabled if not HAVE_MORECORE) + + In all cases, we need to request enough bytes from system to ensure + we can malloc nb bytes upon success, so pad with enough space for + top_foot, plus alignment-pad to make sure we don't lose bytes if + not on boundary, and round this up to a granularity unit. + */ + + if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { + char* br = CMFAIL; + size_t ssize = asize; /* sbrk call size */ + msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); + ACQUIRE_MALLOC_GLOBAL_LOCK(); + + if (ss == 0) { /* First time through or recovery */ + char* base = (char*)CALL_MORECORE(0); + if (base != CMFAIL) { + size_t fp; + /* Adjust to end on a page boundary */ + if (!is_page_aligned(base)) + ssize += (page_align((size_t)base) - (size_t)base); + fp = m->footprint + ssize; /* recheck limits */ + if (ssize > nb && ssize < HALF_MAX_SIZE_T && + (m->footprint_limit == 0 || + (fp > m->footprint && fp <= m->footprint_limit)) && + (br = (char*)(CALL_MORECORE(ssize))) == base) { + tbase = base; + tsize = ssize; + } + } + } + else { + /* Subtract out existing available top space from MORECORE request. */ + ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); + /* Use mem here only if it did continuously extend old space */ + if (ssize < HALF_MAX_SIZE_T && + (br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) { + tbase = br; + tsize = ssize; + } + } + + if (tbase == CMFAIL) { /* Cope with partial failure */ + if (br != CMFAIL) { /* Try to use/extend the space we did get */ + if (ssize < HALF_MAX_SIZE_T && + ssize < nb + SYS_ALLOC_PADDING) { + size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize); + if (esize < HALF_MAX_SIZE_T) { + char* end = (char*)CALL_MORECORE(esize); + if (end != CMFAIL) + ssize += esize; + else { /* Can't use; try to release */ + (void) CALL_MORECORE(-ssize); + br = CMFAIL; + } + } + } + } + if (br != CMFAIL) { /* Use the space we did get */ + tbase = br; + tsize = ssize; + } + else + disable_contiguous(m); /* Don't try contiguous path in the future */ + } + + RELEASE_MALLOC_GLOBAL_LOCK(); + } + + if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ + char* mp = (char*)(CALL_MMAP(asize)); + if (mp != CMFAIL) { + tbase = mp; + tsize = asize; + mmap_flag = USE_MMAP_BIT; + } + } + + if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ + if (asize < HALF_MAX_SIZE_T) { + char* br = CMFAIL; + char* end = CMFAIL; + ACQUIRE_MALLOC_GLOBAL_LOCK(); + br = (char*)(CALL_MORECORE(asize)); + end = (char*)(CALL_MORECORE(0)); + RELEASE_MALLOC_GLOBAL_LOCK(); + if (br != CMFAIL && end != CMFAIL && br < end) { + size_t ssize = end - br; + if (ssize > nb + TOP_FOOT_SIZE) { + tbase = br; + tsize = ssize; + } + } + } + } + + if (tbase != CMFAIL) { + + if ((m->footprint += tsize) > m->max_footprint) + m->max_footprint = m->footprint; + + if (!is_initialized(m)) { /* first-time initialization */ + if (m->least_addr == 0 || tbase < m->least_addr) + m->least_addr = tbase; + m->seg.base = tbase; + m->seg.size = tsize; + m->seg.sflags = mmap_flag; + m->magic = mparams.magic; + m->release_checks = MAX_RELEASE_CHECK_RATE; + init_bins(m); +#if !ONLY_MSPACES + if (is_global(m)) + init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); + else +#endif + { + /* Offset top by embedded malloc_state */ + mchunkptr mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); + } + } + + else { + /* Try to merge with an existing segment */ + msegmentptr sp = &m->seg; + /* Only consider most recent segment if traversal suppressed */ + while (sp != 0 && tbase != sp->base + sp->size) + sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; + if (sp != 0 && + !is_extern_segment(sp) && + (sp->sflags & USE_MMAP_BIT) == mmap_flag && + segment_holds(sp, m->top)) { /* append */ + sp->size += tsize; + init_top(m, m->top, m->topsize + tsize); + } + else { + if (tbase < m->least_addr) + m->least_addr = tbase; + sp = &m->seg; + while (sp != 0 && sp->base != tbase + tsize) + sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; + if (sp != 0 && + !is_extern_segment(sp) && + (sp->sflags & USE_MMAP_BIT) == mmap_flag) { + char* oldbase = sp->base; + sp->base = tbase; + sp->size += tsize; + return prepend_alloc(m, tbase, oldbase, nb); + } + else + add_segment(m, tbase, tsize, mmap_flag); + } + } + + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; + mchunkptr p = m->top; + mchunkptr r = m->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(m, p, nb); + check_top_chunk(m, m->top); + check_malloced_chunk(m, chunk2mem(p), nb); + return chunk2mem(p); + } + } + + MALLOC_FAILURE_ACTION; + return 0; +} + +/* ----------------------- system deallocation -------------------------- */ + +/* Unmap and unlink any mmapped segments that don't contain used chunks */ +static size_t release_unused_segments(mstate m) { + size_t released = 0; + int nsegs = 0; + msegmentptr pred = &m->seg; + msegmentptr sp = pred->next; + while (sp != 0) { + char* base = sp->base; + size_t size = sp->size; + msegmentptr next = sp->next; + ++nsegs; + if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { + mchunkptr p = align_as_chunk(base); + size_t psize = chunksize(p); + /* Can unmap if first chunk holds entire segment and not pinned */ + if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; + assert(segment_holds(sp, (char*)sp)); + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } + else { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; + m->footprint -= size; + /* unlink obsoleted record */ + sp = pred; + sp->next = next; + } + else { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } + } + if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ + break; + pred = sp; + sp = next; + } + /* Reset check counter */ + m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)? + (size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE); + return released; +} + +static int sys_trim(mstate m, size_t pad) { + size_t released = 0; + ensure_initialization(); + if (pad < MAX_REQUEST && is_initialized(m)) { + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ + size_t unit = mparams.granularity; + size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - + SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char*)m->top); + + if (!is_extern_segment(sp)) { + if (is_mmapped_segment(sp)) { + if (HAVE_MMAP && + sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ + size_t newsize = sp->size - extra; + (void)newsize; /* placate people compiling -Wunused-variable */ + /* Prefer mremap, fall back to munmap */ + if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || + (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { + released = extra; + } + } + } + else if (HAVE_MORECORE) { + if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ + extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; + ACQUIRE_MALLOC_GLOBAL_LOCK(); + { + /* Make sure end of memory is where we last set it. */ + char* old_br = (char*)(CALL_MORECORE(0)); + if (old_br == sp->base + sp->size) { + char* rel_br = (char*)(CALL_MORECORE(-extra)); + char* new_br = (char*)(CALL_MORECORE(0)); + if (rel_br != CMFAIL && new_br < old_br) + released = old_br - new_br; + } + } + RELEASE_MALLOC_GLOBAL_LOCK(); + } + } + + if (released != 0) { + sp->size -= released; + m->footprint -= released; + init_top(m, m->top, m->topsize - released); + check_top_chunk(m, m->top); + } + } + + /* Unmap any unused mmapped segments */ + if (HAVE_MMAP) + released += release_unused_segments(m); + + /* On failure, disable autotrim to avoid repeated failed future calls */ + if (released == 0 && m->topsize > m->trim_check) + m->trim_check = MAX_SIZE_T; + } + + return (released != 0)? 1 : 0; +} + +/* Consolidate and bin a chunk. Differs from exported versions + of free mainly in that the chunk need not be marked as inuse. +*/ +static void dispose_chunk(mstate m, mchunkptr p, size_t psize) { + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + mchunkptr prev; + size_t prevsize = p->prev_foot; + if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + m->footprint -= psize; + return; + } + prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ + if (p != m->dv) { + unlink_chunk(m, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + m->dvsize = psize; + set_free_with_pinuse(p, psize, next); + return; + } + } + else { + CORRUPTION_ERROR_ACTION(m); + return; + } + } + if (RTCHECK(ok_address(m, next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == m->top) { + size_t tsize = m->topsize += psize; + m->top = p; + p->head = tsize | PINUSE_BIT; + if (p == m->dv) { + m->dv = 0; + m->dvsize = 0; + } + return; + } + else if (next == m->dv) { + size_t dsize = m->dvsize += psize; + m->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + return; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(m, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == m->dv) { + m->dvsize = psize; + return; + } + } + } + else { + set_free_with_pinuse(p, psize, next); + } + insert_chunk(m, p, psize); + } + else { + CORRUPTION_ERROR_ACTION(m); + } +} + +/* ---------------------------- malloc --------------------------- */ + +/* allocate a large request from the best fitting chunk in a treebin */ +static void* tmalloc_large(mstate m, size_t nb) { + tchunkptr v = 0; + size_t rsize = -nb; /* Unsigned negation */ + tchunkptr t; + bindex_t idx; + compute_tree_index(nb, idx); + if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ + for (;;) { + tchunkptr rt; + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + v = t; + if ((rsize = trem) == 0) + break; + } + rt = t->child[1]; + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) + rst = rt; + if (t == 0) { + t = rst; /* set t to least subtree holding sizes > nb */ + break; + } + sizebits <<= 1; + } + } + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; + if (leftbits != 0) { + bindex_t i; + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + t = *treebin_at(m, i); + } + } + + while (t != 0) { /* find smallest of tree or subtree */ + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + t = leftmost_child(t); + } + + /* If dv is a better fit, return 0 so malloc will use it */ + if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { + if (RTCHECK(ok_address(m, v))) { /* split */ + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } + } + CORRUPTION_ERROR_ACTION(m); + } + return 0; +} + +/* allocate a small request from the best fitting chunk in a treebin */ +static void* tmalloc_small(mstate m, size_t nb) { + tchunkptr t, v; + size_t rsize; + bindex_t i; + binmap_t leastbit = least_bit(m->treemap); + compute_bit2idx(leastbit, i); + v = t = *treebin_at(m, i); + rsize = chunksize(t) - nb; + + while ((t = leftmost_child(t)) != 0) { + size_t trem = chunksize(t) - nb; + if (trem < rsize) { + rsize = trem; + v = t; + } + } + + if (RTCHECK(ok_address(m, v))) { + mchunkptr r = chunk_plus_offset(v, nb); + assert(chunksize(v) == rsize + nb); + if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); + if (rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(m, v, (rsize + nb)); + else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(m, r, rsize); + } + return chunk2mem(v); + } + } + + CORRUPTION_ERROR_ACTION(m); + return 0; +} + +#if !ONLY_MSPACES + +void* dlmalloc(size_t bytes) { + /* + Basic algorithm: + If a small request (< 256 bytes minus per-chunk overhead): + 1. If one exists, use a remainderless chunk in associated smallbin. + (Remainderless means that there are too few excess bytes to + represent as a chunk.) + 2. If it is big enough, use the dv chunk, which is normally the + chunk adjacent to the one used for the most recent small request. + 3. If one exists, split the smallest available chunk in a bin, + saving remainder in dv. + 4. If it is big enough, use the top chunk. + 5. If available, get memory from system and use it + Otherwise, for a large request: + 1. Find the smallest available binned chunk that fits, and use it + if it is better fitting than dv chunk, splitting if necessary. + 2. If better fitting than any binned chunk, use the dv chunk. + 3. If it is big enough, use the top chunk. + 4. If request size >= mmap threshold, try to directly mmap this chunk. + 5. If available, get memory from system and use it + + The ugly goto's here ensure that postaction occurs along all paths. + */ + +#if USE_LOCKS + ensure_initialization(); /* initialize in sys_alloc if not using locks */ +#endif + + if (!PREACTION(gm)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = gm->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(gm, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(gm, b, p, idx); + set_inuse_and_pinuse(gm, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (nb > gm->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(gm, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(gm, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(gm, p, small_index2size(i)); + else { + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(gm, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else { + nb = pad_request(bytes); + if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + } + + if (nb <= gm->dvsize) { + size_t rsize = gm->dvsize - nb; + mchunkptr p = gm->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = gm->dv = chunk_plus_offset(p, nb); + gm->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + } + else { /* exhaust dv */ + size_t dvs = gm->dvsize; + gm->dvsize = 0; + gm->dv = 0; + set_inuse_and_pinuse(gm, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + else if (nb < gm->topsize) { /* Split top */ + size_t rsize = gm->topsize -= nb; + mchunkptr p = gm->top; + mchunkptr r = gm->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); + mem = chunk2mem(p); + check_top_chunk(gm, gm->top); + check_malloced_chunk(gm, mem, nb); + goto postaction; + } + + mem = sys_alloc(gm, nb); + + postaction: + POSTACTION(gm); + return mem; + } + + return 0; +} + +/* ---------------------------- free --------------------------- */ + +void dlfree(void* mem) { + /* + Consolidate freed chunks with preceeding or succeeding bordering + free chunks, if they exist, and then place in a bin. Intermixed + with special cases for top, dv, mmapped chunks, and usage errors. + */ + + if (mem != 0) { + mchunkptr p = mem2chunk(mem); +#if FOOTERS + mstate fm = get_mstate_for(p); + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } +#else /* FOOTERS */ +#define fm gm +#endif /* FOOTERS */ + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + fm->footprint -= psize; + goto postaction; + } + else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) + sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + + if (is_small(psize)) { + insert_small_chunk(fm, p, psize); + check_free_chunk(fm, p); + } + else { + tchunkptr tp = (tchunkptr)p; + insert_large_chunk(fm, tp, psize); + check_free_chunk(fm, p); + if (--fm->release_checks == 0) + release_unused_segments(fm); + } + goto postaction; + } + } + erroraction: + USAGE_ERROR_ACTION(fm, p); + postaction: + POSTACTION(fm); + } + } +#if !FOOTERS +#undef fm +#endif /* FOOTERS */ +} + +void* dlcalloc(size_t n_elements, size_t elem_size) { + void* mem; + size_t req = 0; + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && + (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = dlmalloc(req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + __builtin_memset(mem, 0, req); + return mem; +} + +#endif /* !ONLY_MSPACES */ + +/* ------------ Internal support for realloc, memalign, etc -------------- */ + +/* Try to realloc; only in-place unless can_move true */ +static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, + int can_move) { + mchunkptr newp = 0; + size_t oldsize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, oldsize); + if (RTCHECK(ok_address(m, p) && ok_inuse(p) && + ok_next(p, next) && ok_pinuse(next))) { + if (is_mmapped(p)) { + newp = mmap_resize(m, p, nb, can_move); + } + else if (oldsize >= nb) { /* already big enough */ + size_t rsize = oldsize - nb; + if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ + mchunkptr r = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, r, rsize); + dispose_chunk(m, r, rsize); + } + newp = p; + } + else if (next == m->top) { /* extend into top */ + if (oldsize + m->topsize > nb) { + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; + mchunkptr newtop = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + newtop->head = newtopsize |PINUSE_BIT; + m->top = newtop; + m->topsize = newtopsize; + newp = p; + } + } + else if (next == m->dv) { /* extend into dv */ + size_t dvs = m->dvsize; + if (oldsize + dvs >= nb) { + size_t dsize = oldsize + dvs - nb; + if (dsize >= MIN_CHUNK_SIZE) { + mchunkptr r = chunk_plus_offset(p, nb); + mchunkptr n = chunk_plus_offset(r, dsize); + set_inuse(m, p, nb); + set_size_and_pinuse_of_free_chunk(r, dsize); + clear_pinuse(n); + m->dvsize = dsize; + m->dv = r; + } + else { /* exhaust dv */ + size_t newsize = oldsize + dvs; + set_inuse(m, p, newsize); + m->dvsize = 0; + m->dv = 0; + } + newp = p; + } + } + else if (!cinuse(next)) { /* extend into next free chunk */ + size_t nextsize = chunksize(next); + if (oldsize + nextsize >= nb) { + size_t rsize = oldsize + nextsize - nb; + unlink_chunk(m, next, nextsize); + if (rsize < MIN_CHUNK_SIZE) { + size_t newsize = oldsize + nextsize; + set_inuse(m, p, newsize); + } + else { + mchunkptr r = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, r, rsize); + dispose_chunk(m, r, rsize); + } + newp = p; + } + } + } + else { + USAGE_ERROR_ACTION(m, chunk2mem(p)); + } + return newp; +} + +static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { + void* mem = 0; + if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ + alignment = MIN_CHUNK_SIZE; + if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ + size_t a = MALLOC_ALIGNMENT << 1; + while (a < alignment) a <<= 1; + alignment = a; + } + if (bytes >= MAX_REQUEST - alignment) { + if (m != 0) { /* Test isn't needed but avoids compiler warning */ + MALLOC_FAILURE_ACTION; + } + } + else { + size_t nb = request2size(bytes); + size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; + mem = internal_malloc(m, req); + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (PREACTION(m)) + return 0; + if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ + /* + Find an aligned spot inside chunk. Since we need to give + back leading space in a chunk of at least MIN_CHUNK_SIZE, if + the first calculation places us at a spot with less than + MIN_CHUNK_SIZE leader, we can move to the next aligned spot. + We've allocated enough total room so that this is always + possible. + */ + char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment - + SIZE_T_ONE)) & + -alignment)); + char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? + br : br+alignment; + mchunkptr newp = (mchunkptr)pos; + size_t leadsize = pos - (char*)(p); + size_t newsize = chunksize(p) - leadsize; + + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ + newp->prev_foot = p->prev_foot + leadsize; + newp->head = newsize; + } + else { /* Otherwise, give back leader, use the rest */ + set_inuse(m, newp, newsize); + set_inuse(m, p, leadsize); + dispose_chunk(m, p, leadsize); + } + p = newp; + } + + /* Give back spare room at the end */ + if (!is_mmapped(p)) { + size_t size = chunksize(p); + if (size > nb + MIN_CHUNK_SIZE) { + size_t remainder_size = size - nb; + mchunkptr remainder = chunk_plus_offset(p, nb); + set_inuse(m, p, nb); + set_inuse(m, remainder, remainder_size); + dispose_chunk(m, remainder, remainder_size); + } + } + + mem = chunk2mem(p); + assert (chunksize(p) >= nb); + assert(((size_t)mem & (alignment - 1)) == 0); + check_inuse_chunk(m, p); + POSTACTION(m); + } + } + return mem; +} + +/* + Common support for independent_X routines, handling + all of the combinations that can result. + The opts arg has: + bit 0 set if all elements are same size (using sizes[0]) + bit 1 set if elements should be zeroed +*/ +static void** ialloc(mstate m, + size_t n_elements, + size_t* sizes, + int opts, + void* chunks[]) { + + size_t element_size; /* chunksize of each element, if all same */ + size_t contents_size; /* total size of elements */ + size_t array_size; /* request size of pointer array */ + void* mem; /* malloced aggregate space */ + mchunkptr p; /* corresponding chunk */ + size_t remainder_size; /* remaining bytes while splitting */ + void** marray; /* either "chunks" or malloced ptr array */ + mchunkptr array_chunk; /* chunk for malloced ptr array */ + flag_t was_enabled; /* to disable mmap */ + size_t size; + size_t i; + + ensure_initialization(); + /* compute array length, if needed */ + if (chunks != 0) { + if (n_elements == 0) + return chunks; /* nothing to do */ + marray = chunks; + array_size = 0; + } + else { + /* if empty req, must still return chunk representing empty array */ + if (n_elements == 0) + return (void**)internal_malloc(m, 0); + marray = 0; + array_size = request2size(n_elements * (sizeof(void*))); + } + + /* compute total element size */ + if (opts & 0x1) { /* all-same-size */ + element_size = request2size(*sizes); + contents_size = n_elements * element_size; + } + else { /* add up all the sizes */ + element_size = 0; + contents_size = 0; + for (i = 0; i != n_elements; ++i) + contents_size += request2size(sizes[i]); + } + + size = contents_size + array_size; + + /* + Allocate the aggregate chunk. First disable direct-mmapping so + malloc won't use it, since we would not be able to later + free/realloc space internal to a segregated mmap region. + */ + was_enabled = use_mmap(m); + disable_mmap(m); + mem = internal_malloc(m, size - CHUNK_OVERHEAD); + if (was_enabled) + enable_mmap(m); + if (mem == 0) + return 0; + + if (PREACTION(m)) return 0; + p = mem2chunk(mem); + remainder_size = chunksize(p); + + assert(!is_mmapped(p)); + + if (opts & 0x2) { /* optionally clear the elements */ + __builtin_memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); + } + + /* If not provided, allocate the pointer array as final part of chunk */ + if (marray == 0) { + size_t array_chunk_size; + array_chunk = chunk_plus_offset(p, contents_size); + array_chunk_size = remainder_size - contents_size; + marray = (void**) (chunk2mem(array_chunk)); + set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); + remainder_size = contents_size; + } + + /* split out elements */ + for (i = 0; ; ++i) { + marray[i] = chunk2mem(p); + if (i != n_elements-1) { + if (element_size != 0) + size = element_size; + else + size = request2size(sizes[i]); + remainder_size -= size; + set_size_and_pinuse_of_inuse_chunk(m, p, size); + p = chunk_plus_offset(p, size); + } + else { /* the final element absorbs any overallocation slop */ + set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); + break; + } + } + +#if DEBUG + if (marray != chunks) { + /* final element must have exactly exhausted chunk */ + if (element_size != 0) { + assert(remainder_size == element_size); + } + else { + assert(remainder_size == request2size(sizes[i])); + } + check_inuse_chunk(m, mem2chunk(marray)); + } + for (i = 0; i != n_elements; ++i) + check_inuse_chunk(m, mem2chunk(marray[i])); + +#endif /* DEBUG */ + + POSTACTION(m); + return marray; +} + +/* Try to free all pointers in the given array. + Note: this could be made faster, by delaying consolidation, + at the price of disabling some user integrity checks, We + still optimize some consolidations by combining adjacent + chunks before freeing, which will occur often if allocated + with ialloc or the array is sorted. +*/ +static size_t internal_bulk_free(mstate m, void* array[], size_t nelem) { + size_t unfreed = 0; + if (!PREACTION(m)) { + void** a; + void** fence = &(array[nelem]); + for (a = array; a != fence; ++a) { + void* mem = *a; + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + size_t psize = chunksize(p); +#if FOOTERS + if (get_mstate_for(p) != m) { + ++unfreed; + continue; + } +#endif + check_inuse_chunk(m, p); + *a = 0; + if (RTCHECK(ok_address(m, p) && ok_inuse(p))) { + void ** b = a + 1; /* try to merge with next chunk */ + mchunkptr next = next_chunk(p); + if (b != fence && *b == chunk2mem(next)) { + size_t newsize = chunksize(next) + psize; + set_inuse(m, p, newsize); + *b = chunk2mem(p); + } + else + dispose_chunk(m, p, psize); + } + else { + CORRUPTION_ERROR_ACTION(m); + break; + } + } + } + if (should_trim(m, m->topsize)) + sys_trim(m, 0); + POSTACTION(m); + } + return unfreed; +} + +/* Traversal */ +#if MALLOC_INSPECT_ALL +static void internal_inspect_all(mstate m, + void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { + if (is_initialized(m)) { + mchunkptr top = m->top; + msegmentptr s; + for (s = &m->seg; s != 0; s = s->next) { + mchunkptr q = align_as_chunk(s->base); + while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) { + mchunkptr next = next_chunk(q); + size_t sz = chunksize(q); + size_t used; + void* start; + if (is_inuse(q)) { + used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ + start = chunk2mem(q); + } + else { + used = 0; + if (is_small(sz)) { /* offset by possible bookkeeping */ + start = (void*)((char*)q + sizeof(struct malloc_chunk)); + } + else { + start = (void*)((char*)q + sizeof(struct malloc_tree_chunk)); + } + } + if (start < (void*)next) /* skip if all space is bookkeeping */ + handler(start, next, used, arg); + if (q == top) + break; + q = next; + } + } + } +} +#endif /* MALLOC_INSPECT_ALL */ + +/* ------------------ Exported realloc, memalign, etc -------------------- */ + +#if !ONLY_MSPACES + +void* dlrealloc(void* oldmem, size_t bytes) { + void* mem = 0; + if (oldmem == 0) { + mem = dlmalloc(bytes); + } + else if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } +#ifdef REALLOC_ZERO_BYTES_FREES + else if (bytes == 0) { + dlfree(oldmem); + } +#endif /* REALLOC_ZERO_BYTES_FREES */ + else { + size_t nb = request2size(bytes); + mchunkptr oldp = mem2chunk(oldmem); +#if ! FOOTERS + mstate m = gm; +#else /* FOOTERS */ + mstate m = get_mstate_for(oldp); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); + POSTACTION(m); + if (newp != 0) { + check_inuse_chunk(m, newp); + mem = chunk2mem(newp); + } + else { + mem = internal_malloc(m, bytes); + if (mem != 0) { + size_t oc = chunksize(oldp) - overhead_for(oldp); + __builtin_memcpy(mem, oldmem, (oc < bytes)? oc : bytes); + internal_free(m, oldmem); + } + } + } + } + return mem; +} + +void* dlrealloc_in_place(void* oldmem, size_t bytes) { + void* mem = 0; + if (oldmem != 0) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } + else { + size_t nb = request2size(bytes); + mchunkptr oldp = mem2chunk(oldmem); +#if ! FOOTERS + mstate m = gm; +#else /* FOOTERS */ + mstate m = get_mstate_for(oldp); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); + POSTACTION(m); + if (newp == oldp) { + check_inuse_chunk(m, newp); + mem = oldmem; + } + } + } + } + return mem; +} + +void* dlmemalign(size_t alignment, size_t bytes) { + if (alignment <= MALLOC_ALIGNMENT) { + return dlmalloc(bytes); + } + return internal_memalign(gm, alignment, bytes); +} + +int dlposix_memalign(void** pp, size_t alignment, size_t bytes) { + void* mem = 0; + if (alignment == MALLOC_ALIGNMENT) + mem = dlmalloc(bytes); + else { + size_t d = alignment / sizeof(void*); + size_t r = alignment % sizeof(void*); + if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0) + return EINVAL; + else if (bytes <= MAX_REQUEST - alignment) { + if (alignment < MIN_CHUNK_SIZE) + alignment = MIN_CHUNK_SIZE; + mem = internal_memalign(gm, alignment, bytes); + } + } + if (mem == 0) + return ENOMEM; + else { + *pp = mem; + return 0; + } +} + +void* dlvalloc(size_t bytes) { + size_t pagesz; + ensure_initialization(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, bytes); +} + +void* dlpvalloc(size_t bytes) { + size_t pagesz; + ensure_initialization(); + pagesz = mparams.page_size; + return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); +} + +void** dlindependent_calloc(size_t n_elements, size_t elem_size, + void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ + return ialloc(gm, n_elements, &sz, 3, chunks); +} + +void** dlindependent_comalloc(size_t n_elements, size_t sizes[], + void* chunks[]) { + return ialloc(gm, n_elements, sizes, 0, chunks); +} + +size_t dlbulk_free(void* array[], size_t nelem) { + return internal_bulk_free(gm, array, nelem); +} + +#if MALLOC_INSPECT_ALL +void dlmalloc_inspect_all(void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { + ensure_initialization(); + if (!PREACTION(gm)) { + internal_inspect_all(gm, handler, arg); + POSTACTION(gm); + } +} +#endif /* MALLOC_INSPECT_ALL */ + +int dlmalloc_trim(size_t pad) { + int result = 0; + ensure_initialization(); + if (!PREACTION(gm)) { + result = sys_trim(gm, pad); + POSTACTION(gm); + } + return result; +} + +size_t dlmalloc_footprint(void) { + return gm->footprint; +} + +size_t dlmalloc_max_footprint(void) { + return gm->max_footprint; +} + +size_t dlmalloc_footprint_limit(void) { + size_t maf = gm->footprint_limit; + return maf == 0 ? MAX_SIZE_T : maf; +} + +size_t dlmalloc_set_footprint_limit(size_t bytes) { + size_t result; /* invert sense of 0 */ + if (bytes == 0) + result = granularity_align(1); /* Use minimal size */ + if (bytes == MAX_SIZE_T) + result = 0; /* disable */ + else + result = granularity_align(bytes); + return gm->footprint_limit = result; +} + +#if !NO_MALLINFO +struct mallinfo dlmallinfo(void) { + return internal_mallinfo(gm); +} +#endif /* NO_MALLINFO */ + +#if !NO_MALLOC_STATS +void dlmalloc_stats() { + internal_malloc_stats(gm); +} +#endif /* NO_MALLOC_STATS */ + +int dlmallopt(int param_number, int value) { + return change_mparam(param_number, value); +} + +size_t dlmalloc_usable_size(void* mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (is_inuse(p)) + return chunksize(p) - overhead_for(p); + } + return 0; +} + +#endif /* !ONLY_MSPACES */ + +/* ----------------------------- user mspaces ---------------------------- */ + +#if MSPACES + +static mstate init_user_mstate(char* tbase, size_t tsize) { + size_t msize = pad_request(sizeof(struct malloc_state)); + mchunkptr mn; + mchunkptr msp = align_as_chunk(tbase); + mstate m = (mstate)(chunk2mem(msp)); + __builtin_memset(m, 0, msize); + (void)INITIAL_LOCK(&m->mutex); + msp->head = (msize|INUSE_BITS); + m->seg.base = m->least_addr = tbase; + m->seg.size = m->footprint = m->max_footprint = tsize; + m->magic = mparams.magic; + m->release_checks = MAX_RELEASE_CHECK_RATE; + m->mflags = mparams.default_mflags; + m->extp = 0; + m->exts = 0; + disable_contiguous(m); + init_bins(m); + mn = next_chunk(mem2chunk(m)); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); + check_top_chunk(m, m->top); + return m; +} + +mspace create_mspace(size_t capacity, int locked) { + mstate m = 0; + size_t msize; + ensure_initialization(); + msize = pad_request(sizeof(struct malloc_state)); + if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + size_t rs = ((capacity == 0)? mparams.granularity : + (capacity + TOP_FOOT_SIZE + msize)); + size_t tsize = granularity_align(rs); + char* tbase = (char*)(CALL_MMAP(tsize)); + if (tbase != CMFAIL) { + m = init_user_mstate(tbase, tsize); + m->seg.sflags = USE_MMAP_BIT; + set_lock(m, locked); + } + } + return (mspace)m; +} + +mspace create_mspace_with_base(void* base, size_t capacity, int locked) { + mstate m = 0; + size_t msize; + ensure_initialization(); + msize = pad_request(sizeof(struct malloc_state)); + if (capacity > msize + TOP_FOOT_SIZE && + capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + m = init_user_mstate((char*)base, capacity); + m->seg.sflags = EXTERN_BIT; + set_lock(m, locked); + } + return (mspace)m; +} + +int mspace_track_large_chunks(mspace msp, int enable) { + int ret = 0; + mstate ms = (mstate)msp; + if (!PREACTION(ms)) { + if (!use_mmap(ms)) { + ret = 1; + } + if (!enable) { + enable_mmap(ms); + } else { + disable_mmap(ms); + } + POSTACTION(ms); + } + return ret; +} + +size_t destroy_mspace(mspace msp) { + size_t freed = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + msegmentptr sp = &ms->seg; + (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ + while (sp != 0) { + char* base = sp->base; + size_t size = sp->size; + flag_t flag = sp->sflags; + (void)base; /* placate people compiling -Wunused-variable */ + sp = sp->next; + if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && + CALL_MUNMAP(base, size) == 0) + freed += size; + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return freed; +} + +/* + mspace versions of routines are near-clones of the global + versions. This is not so nice but better than the alternatives. +*/ + +void* mspace_malloc(mspace msp, size_t bytes) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (!PREACTION(ms)) { + void* mem; + size_t nb; + if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; + binmap_t smallbits; + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + idx = small_index(nb); + smallbits = ms->smallmap >> idx; + + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + mchunkptr b, p; + idx += ~smallbits & 1; /* Uses next bin if idx empty */ + b = smallbin_at(ms, idx); + p = b->fd; + assert(chunksize(p) == small_index2size(idx)); + unlink_first_small_chunk(ms, b, p, idx); + set_inuse_and_pinuse(ms, p, small_index2size(idx)); + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (nb > ms->dvsize) { + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + mchunkptr b, p, r; + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); + compute_bit2idx(leastbit, i); + b = smallbin_at(ms, i); + p = b->fd; + assert(chunksize(p) == small_index2size(i)); + unlink_first_small_chunk(ms, b, p, i); + rsize = small_index2size(i) - nb; + /* Fit here cannot be remainderless if 4byte sizes */ + if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) + set_inuse_and_pinuse(ms, p, small_index2size(i)); + else { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + r = chunk_plus_offset(p, nb); + set_size_and_pinuse_of_free_chunk(r, rsize); + replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + } + else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ + else { + nb = pad_request(bytes); + if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + } + + if (nb <= ms->dvsize) { + size_t rsize = ms->dvsize - nb; + mchunkptr p = ms->dv; + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + mchunkptr r = ms->dv = chunk_plus_offset(p, nb); + ms->dvsize = rsize; + set_size_and_pinuse_of_free_chunk(r, rsize); + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + } + else { /* exhaust dv */ + size_t dvs = ms->dvsize; + ms->dvsize = 0; + ms->dv = 0; + set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; + mchunkptr p = ms->top; + mchunkptr r = ms->top = chunk_plus_offset(p, nb); + r->head = rsize | PINUSE_BIT; + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); + mem = chunk2mem(p); + check_top_chunk(ms, ms->top); + check_malloced_chunk(ms, mem, nb); + goto postaction; + } + + mem = sys_alloc(ms, nb); + + postaction: + POSTACTION(ms); + return mem; + } + + return 0; +} + +void mspace_free(mspace msp, void* mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); +#if FOOTERS + mstate fm = get_mstate_for(p); + (void)msp; /* placate people compiling -Wunused */ +#else /* FOOTERS */ + mstate fm = (mstate)msp; +#endif /* FOOTERS */ + if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); + return; + } + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); + if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { + size_t psize = chunksize(p); + mchunkptr next = chunk_plus_offset(p, psize); + if (!pinuse(p)) { + size_t prevsize = p->prev_foot; + if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + fm->footprint -= psize; + goto postaction; + } + else { + mchunkptr prev = chunk_minus_offset(p, prevsize); + psize += prevsize; + p = prev; + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; + set_free_with_pinuse(p, psize, next); + goto postaction; + } + } + else + goto erroraction; + } + } + + if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { + if (!cinuse(next)) { /* consolidate forward */ + if (next == fm->top) { + size_t tsize = fm->topsize += psize; + fm->top = p; + p->head = tsize | PINUSE_BIT; + if (p == fm->dv) { + fm->dv = 0; + fm->dvsize = 0; + } + if (should_trim(fm, tsize)) + sys_trim(fm, 0); + goto postaction; + } + else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; + fm->dv = p; + set_size_and_pinuse_of_free_chunk(p, dsize); + goto postaction; + } + else { + size_t nsize = chunksize(next); + psize += nsize; + unlink_chunk(fm, next, nsize); + set_size_and_pinuse_of_free_chunk(p, psize); + if (p == fm->dv) { + fm->dvsize = psize; + goto postaction; + } + } + } + else + set_free_with_pinuse(p, psize, next); + + if (is_small(psize)) { + insert_small_chunk(fm, p, psize); + check_free_chunk(fm, p); + } + else { + tchunkptr tp = (tchunkptr)p; + insert_large_chunk(fm, tp, psize); + check_free_chunk(fm, p); + if (--fm->release_checks == 0) + release_unused_segments(fm); + } + goto postaction; + } + } + erroraction: + USAGE_ERROR_ACTION(fm, p); + postaction: + POSTACTION(fm); + } + } +} + +void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { + void* mem; + size_t req = 0; + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (n_elements != 0) { + req = n_elements * elem_size; + if (((n_elements | elem_size) & ~(size_t)0xffff) && + (req / n_elements != elem_size)) + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = internal_malloc(ms, req); + if (mem != 0 && calloc_must_clear(mem2chunk(mem))) + __builtin_memset(mem, 0, req); + return mem; +} + +void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { + void* mem = 0; + if (oldmem == 0) { + mem = mspace_malloc(msp, bytes); + } + else if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } +#ifdef REALLOC_ZERO_BYTES_FREES + else if (bytes == 0) { + mspace_free(msp, oldmem); + } +#endif /* REALLOC_ZERO_BYTES_FREES */ + else { + size_t nb = request2size(bytes); + mchunkptr oldp = mem2chunk(oldmem); +#if ! FOOTERS + mstate m = (mstate)msp; +#else /* FOOTERS */ + mstate m = get_mstate_for(oldp); + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); + POSTACTION(m); + if (newp != 0) { + check_inuse_chunk(m, newp); + mem = chunk2mem(newp); + } + else { + mem = mspace_malloc(m, bytes); + if (mem != 0) { + size_t oc = chunksize(oldp) - overhead_for(oldp); + __builtin_memcpy(mem, oldmem, (oc < bytes)? oc : bytes); + mspace_free(m, oldmem); + } + } + } + } + return mem; +} + +void* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) { + void* mem = 0; + if (oldmem != 0) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } + else { + size_t nb = request2size(bytes); + mchunkptr oldp = mem2chunk(oldmem); +#if ! FOOTERS + mstate m = (mstate)msp; +#else /* FOOTERS */ + mstate m = get_mstate_for(oldp); + (void)msp; /* placate people compiling -Wunused */ + if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); + return 0; + } +#endif /* FOOTERS */ + if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); + POSTACTION(m); + if (newp == oldp) { + check_inuse_chunk(m, newp); + mem = oldmem; + } + } + } + } + return mem; +} + +void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + if (alignment <= MALLOC_ALIGNMENT) + return mspace_malloc(msp, bytes); + return internal_memalign(ms, alignment, bytes); +} + +void** mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return ialloc(ms, n_elements, &sz, 3, chunks); +} + +void** mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void* chunks[]) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + return 0; + } + return ialloc(ms, n_elements, sizes, 0, chunks); +} + +size_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) { + return internal_bulk_free((mstate)msp, array, nelem); +} + +#if MALLOC_INSPECT_ALL +void mspace_inspect_all(mspace msp, + void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (!PREACTION(ms)) { + internal_inspect_all(ms, handler, arg); + POSTACTION(ms); + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } +} +#endif /* MALLOC_INSPECT_ALL */ + +int mspace_trim(mspace msp, size_t pad) { + int result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (!PREACTION(ms)) { + result = sys_trim(ms, pad); + POSTACTION(ms); + } + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +#if !NO_MALLOC_STATS +void mspace_malloc_stats(mspace msp) { + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + internal_malloc_stats(ms); + } + else { + USAGE_ERROR_ACTION(ms,ms); + } +} +#endif /* NO_MALLOC_STATS */ + +size_t mspace_footprint(mspace msp) { + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->footprint; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +size_t mspace_max_footprint(mspace msp) { + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + result = ms->max_footprint; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +size_t mspace_footprint_limit(mspace msp) { + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + size_t maf = ms->footprint_limit; + result = (maf == 0) ? MAX_SIZE_T : maf; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +size_t mspace_set_footprint_limit(mspace msp, size_t bytes) { + size_t result = 0; + mstate ms = (mstate)msp; + if (ok_magic(ms)) { + if (bytes == 0) + result = granularity_align(1); /* Use minimal size */ + if (bytes == MAX_SIZE_T) + result = 0; /* disable */ + else + result = granularity_align(bytes); + ms->footprint_limit = result; + } + else { + USAGE_ERROR_ACTION(ms,ms); + } + return result; +} + +#if !NO_MALLINFO +struct mallinfo mspace_mallinfo(mspace msp) { + mstate ms = (mstate)msp; + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + } + return internal_mallinfo(ms); +} +#endif /* NO_MALLINFO */ + +size_t mspace_usable_size(const void* mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); + if (is_inuse(p)) + return chunksize(p) - overhead_for(p); + } + return 0; +} + +int mspace_mallopt(int param_number, int value) { + return change_mparam(param_number, value); +} + +#endif /* MSPACES */ + + +/* -------------------- Alternative MORECORE functions ------------------- */ + +/* + Guidelines for creating a custom version of MORECORE: + + * For best performance, MORECORE should allocate in multiples of pagesize. + * MORECORE may allocate more memory than requested. (Or even less, + but this will usually result in a malloc failure.) + * MORECORE must not allocate memory when given argument zero, but + instead return one past the end address of memory from previous + nonzero call. + * For best performance, consecutive calls to MORECORE with positive + arguments should return increasing addresses, indicating that + space has been contiguously extended. + * Even though consecutive calls to MORECORE need not return contiguous + addresses, it must be OK for malloc'ed chunks to span multiple + regions in those cases where they do happen to be contiguous. + * MORECORE need not handle negative arguments -- it may instead + just return MFAIL when given negative arguments. + Negative arguments are always multiples of pagesize. MORECORE + must not misinterpret negative args as large positive unsigned + args. You can suppress all such calls from even occurring by defining + MORECORE_CANNOT_TRIM, + + As an example alternative MORECORE, here is a custom allocator + kindly contributed for pre-OSX macOS. It uses virtually but not + necessarily physically contiguous non-paged memory (locked in, + present and won't get swapped out). You can use it by uncommenting + this section, adding some #includes, and setting up the appropriate + defines above: + + #define MORECORE osMoreCore + + There is also a shutdown routine that should somehow be called for + cleanup upon program exit. + + #define MAX_POOL_ENTRIES 100 + #define MINIMUM_MORECORE_SIZE (64 * 1024U) + static int next_os_pool; + void *our_os_pools[MAX_POOL_ENTRIES]; + + void *osMoreCore(int size) + { + void *ptr = 0; + static void *sbrk_top = 0; + + if (size > 0) + { + if (size < MINIMUM_MORECORE_SIZE) + size = MINIMUM_MORECORE_SIZE; + if (CurrentExecutionLevel() == kTaskLevel) + ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); + if (ptr == 0) + { + return (void *) MFAIL; + } + // save ptrs so they can be freed during cleanup + our_os_pools[next_os_pool] = ptr; + next_os_pool++; + ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); + sbrk_top = (char *) ptr + size; + return ptr; + } + else if (size < 0) + { + // we don't currently support shrink behavior + return (void *) MFAIL; + } + else + { + return sbrk_top; + } + } + + // cleanup any allocated memory pools + // called as last thing before shutting down driver + + void osCleanupMem(void) + { + void **ptr; + + for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) + if (*ptr) + { + PoolDeallocate(*ptr); + *ptr = 0; + } + } + +*/ + + +/* ----------------------------------------------------------------------- +History: + v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea + * fix bad comparison in dlposix_memalign + * don't reuse adjusted asize in sys_alloc + * add LOCK_AT_FORK -- thanks to Kirill Artamonov for the suggestion + * reduce compiler warnings -- thanks to all who reported/suggested these + + v2.8.5 Sun May 22 10:26:02 2011 Doug Lea (dl at gee) + * Always perform unlink checks unless INSECURE + * Add posix_memalign. + * Improve realloc to expand in more cases; expose realloc_in_place. + Thanks to Peter Buhr for the suggestion. + * Add footprint_limit, inspect_all, bulk_free. Thanks + to Barry Hayes and others for the suggestions. + * Internal refactorings to avoid calls while holding locks + * Use non-reentrant locks by default. Thanks to Roland McGrath + for the suggestion. + * Small fixes to mspace_destroy, reset_on_error. + * Various configuration extensions/changes. Thanks + to all who contributed these. + + V2.8.4a Thu Apr 28 14:39:43 2011 (dl at gee.cs.oswego.edu) + * Update Creative Commons URL + + V2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) + * Use zeros instead of prev foot for is_mmapped + * Add mspace_track_large_chunks; thanks to Jean Brouwers + * Fix set_inuse in internal_realloc; thanks to Jean Brouwers + * Fix insufficient sys_alloc padding when using 16byte alignment + * Fix bad error check in mspace_footprint + * Adaptations for ptmalloc; thanks to Wolfram Gloger. + * Reentrant spin locks; thanks to Earl Chew and others + * Win32 improvements; thanks to Niall Douglas and Earl Chew + * Add NO_SEGMENT_TRAVERSAL and MAX_RELEASE_CHECK_RATE options + * Extension hook in malloc_state + * Various small adjustments to reduce warnings on some compilers + * Various configuration extensions/changes for more platforms. Thanks + to all who contributed these. + + V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) + * Add max_footprint functions + * Ensure all appropriate literals are size_t + * Fix conditional compilation problem for some #define settings + * Avoid concatenating segments with the one provided + in create_mspace_with_base + * Rename some variables to avoid compiler shadowing warnings + * Use explicit lock initialization. + * Better handling of sbrk interference. + * Simplify and fix segment insertion, trimming and mspace_destroy + * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x + * Thanks especially to Dennis Flanagan for help on these. + + V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) + * Fix memalign brace error. + + V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) + * Fix improper #endif nesting in C++ + * Add explicit casts needed for C++ + + V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) + * Use trees for large bins + * Support mspaces + * Use segments to unify sbrk-based and mmap-based system allocation, + removing need for emulation on most platforms without sbrk. + * Default safety checks + * Optional footer checks. Thanks to William Robertson for the idea. + * Internal code refactoring + * Incorporate suggestions and platform-specific changes. + Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, + Aaron Bachmann, Emery Berger, and others. + * Speed up non-fastbin processing enough to remove fastbins. + * Remove useless cfree() to avoid conflicts with other apps. + * Remove internal memcpy, memset. Compilers handle builtins better. + * Remove some options that no one ever used and rename others. + + V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) + * Fix malloc_state bitmap array misdeclaration + + V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) + * Allow tuning of FIRST_SORTED_BIN_SIZE + * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. + * Better detection and support for non-contiguousness of MORECORE. + Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger + * Bypass most of malloc if no frees. Thanks To Emery Berger. + * Fix freeing of old top non-contiguous chunk im sysmalloc. + * Raised default trim and map thresholds to 256K. + * Fix mmap-related #defines. Thanks to Lubos Lunak. + * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. + * Branch-free bin calculation + * Default trim and mmap thresholds now 256K. + + V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) + * Introduce independent_comalloc and independent_calloc. + Thanks to Michael Pachos for motivation and help. + * Make optional .h file available + * Allow > 2GB requests on 32bit systems. + * new WIN32 sbrk, mmap, munmap, lock code from . + Thanks also to Andreas Mueller , + and Anonymous. + * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for + helping test this.) + * memalign: check alignment arg + * realloc: don't try to shift chunks backwards, since this + leads to more fragmentation in some programs and doesn't + seem to help in any others. + * Collect all cases in malloc requiring system memory into sysmalloc + * Use mmap as backup to sbrk + * Place all internal state in malloc_state + * Introduce fastbins (although similar to 2.5.1) + * Many minor tunings and cosmetic improvements + * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK + * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS + Thanks to Tony E. Bennett and others. + * Include errno.h to support default failure action. + + V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) + * return null for negative arguments + * Added Several WIN32 cleanups from Martin C. Fong + * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' + (e.g. WIN32 platforms) + * Cleanup header file inclusion for WIN32 platforms + * Cleanup code to avoid Microsoft Visual C++ compiler complaints + * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing + memory allocation routines + * Set 'malloc_getpagesize' for WIN32 platforms (needs more work) + * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to + usage of 'assert' in non-WIN32 code + * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to + avoid infinite loop + * Always call 'fREe()' rather than 'free()' + + V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) + * Fixed ordering problem with boundary-stamping + + V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) + * Added pvalloc, as recommended by H.J. Liu + * Added 64bit pointer support mainly from Wolfram Gloger + * Added anonymously donated WIN32 sbrk emulation + * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen + * malloc_extend_top: fix mask error that caused wastage after + foreign sbrks + * Add linux mremap support code from HJ Liu + + V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) + * Integrated most documentation with the code. + * Add support for mmap, with help from + Wolfram Gloger (Gloger@lrz.uni-muenchen.de). + * Use last_remainder in more cases. + * Pack bins using idea from colin@nyx10.cs.du.edu + * Use ordered bins instead of best-fit threshhold + * Eliminate block-local decls to simplify tracing and debugging. + * Support another case of realloc via move into top + * Fix error occuring when initial sbrk_base not word-aligned. + * Rely on page size for units instead of SBRK_UNIT to + avoid surprises about sbrk alignment conventions. + * Add mallinfo, mallopt. Thanks to Raymond Nijssen + (raymond@es.ele.tue.nl) for the suggestion. + * Add `pad' argument to malloc_trim and top_pad mallopt parameter. + * More precautions for cases where other routines call sbrk, + courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de). + * Added macros etc., allowing use in linux libc from + H.J. Lu (hjl@gnu.ai.mit.edu) + * Inverted this history list + + V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) + * Re-tuned and fixed to behave more nicely with V2.6.0 changes. + * Removed all preallocation code since under current scheme + the work required to undo bad preallocations exceeds + the work saved in good cases for most test programs. + * No longer use return list or unconsolidated bins since + no scheme using them consistently outperforms those that don't + given above changes. + * Use best fit for very large chunks to prevent some worst-cases. + * Added some support for debugging + + V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) + * Removed footers when chunks are in use. Thanks to + Paul Wilson (wilson@cs.texas.edu) for the suggestion. + + V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) + * Added malloc_trim, with help from Wolfram Gloger + (wmglo@Dent.MED.Uni-Muenchen.DE). + + V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) + + V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) + * realloc: try to expand in both directions + * malloc: swap order of clean-bin strategy; + * realloc: only conditionally expand backwards + * Try not to scavenge used bins + * Use bin counts as a guide to preallocation + * Occasionally bin return list chunks in first scan + * Add a few optimizations from colin@nyx10.cs.du.edu + + V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) + * faster bin computation & slightly different binning + * merged all consolidations to one part of malloc proper + (eliminating old malloc_find_space & malloc_clean_bin) + * Scan 2 returns chunks (not just 1) + * Propagate failure in realloc if malloc returns 0 + * Add stuff to allow compilation on non-ANSI compilers + from kpv@research.att.com + + V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) + * removed potential for odd address access in prev_chunk + * removed dependency on getpagesize.h + * misc cosmetics and a bit more internal documentation + * anticosmetics: mangled names in macros to evade debugger strangeness + * tested on sparc, hp-700, dec-mips, rs6000 + with gcc & native cc (hp, dec only) allowing + Detlefs & Zorn comparison study (in SIGPLAN Notices.) + + Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) + * Based loosely on libg++-1.2X malloc. (It retains some of the overall + structure of old version, but most details differ.) + +*/ diff --git a/qemu_mode/libqasan/hooks.c b/qemu_mode/libqasan/hooks.c new file mode 100644 index 00000000..b1ee2e0e --- /dev/null +++ b/qemu_mode/libqasan/hooks.c @@ -0,0 +1,659 @@ +/******************************************************************************* +Copyright (c) 2019-2020, Andrea Fioraldi + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "libqasan.h" +#include "map_macro.h" + +char *(*__lq_libc_fgets)(char *, int, FILE *); +int (*__lq_libc_atoi)(const char *); +long (*__lq_libc_atol)(const char *); +long long (*__lq_libc_atoll)(const char *); + +void __libqasan_init_hooks(void) { + + __libqasan_init_malloc(); + + __lq_libc_fgets = ASSERT_DLSYM(fgets); + __lq_libc_atoi = ASSERT_DLSYM(atoi); + __lq_libc_atol = ASSERT_DLSYM(atol); + __lq_libc_atoll = ASSERT_DLSYM(atoll); + +} + +#ifdef __ANDROID__ +size_t malloc_usable_size(const void *ptr) { + +#else +size_t malloc_usable_size(void *ptr) { + +#endif + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: malloc_usable_size(%p)\n", rtv, ptr); + size_t r = __libqasan_malloc_usable_size((void *)ptr); + QASAN_DEBUG("\t\t = %ld\n", r); + + return r; + +} + +void *malloc(size_t size) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: malloc(%ld)\n", rtv, size); + void *r = __libqasan_malloc(size); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *calloc(size_t nmemb, size_t size) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: calloc(%ld, %ld)\n", rtv, nmemb, size); + void *r = __libqasan_calloc(nmemb, size); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *realloc(void *ptr, size_t size) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: realloc(%p, %ld)\n", rtv, ptr, size); + void *r = __libqasan_realloc(ptr, size); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +int posix_memalign(void **memptr, size_t alignment, size_t size) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: posix_memalign(%p, %ld, %ld)\n", rtv, memptr, alignment, + size); + int r = __libqasan_posix_memalign(memptr, alignment, size); + QASAN_DEBUG("\t\t = %d [*memptr = %p]\n", r, *memptr); + + return r; + +} + +void *memalign(size_t alignment, size_t size) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: memalign(%ld, %ld)\n", rtv, alignment, size); + void *r = __libqasan_memalign(alignment, size); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *aligned_alloc(size_t alignment, size_t size) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: aligned_alloc(%ld, %ld)\n", rtv, alignment, size); + void *r = __libqasan_aligned_alloc(alignment, size); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *valloc(size_t size) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: valloc(%ld)\n", rtv, size); + void *r = __libqasan_memalign(sysconf(_SC_PAGESIZE), size); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *pvalloc(size_t size) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: pvalloc(%ld)\n", rtv, size); + size_t page_size = sysconf(_SC_PAGESIZE); + size = (size & (page_size - 1)) + page_size; + void *r = __libqasan_memalign(page_size, size); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void free(void *ptr) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: free(%p)\n", rtv, ptr); + __libqasan_free(ptr); + +} + +char *fgets(char *s, int size, FILE *stream) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: fgets(%p, %d, %p)\n", rtv, s, size, stream); + QASAN_STORE(s, size); + QASAN_LOAD(stream, sizeof(FILE)); + char *r = __lq_libc_fgets(s, size, stream); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +int memcmp(const void *s1, const void *s2, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: memcmp(%p, %p, %ld)\n", rtv, s1, s2, n); + QASAN_LOAD(s1, n); + QASAN_LOAD(s2, n); + int r = __libqasan_memcmp(s1, s2, n); + QASAN_DEBUG("\t\t = %d\n", r); + + return r; + +} + +void *memcpy(void *dest, const void *src, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: memcpy(%p, %p, %ld)\n", rtv, dest, src, n); + QASAN_LOAD(src, n); + QASAN_STORE(dest, n); + void *r = __libqasan_memcpy(dest, src, n); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *mempcpy(void *dest, const void *src, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: mempcpy(%p, %p, %ld)\n", rtv, dest, src, n); + QASAN_LOAD(src, n); + QASAN_STORE(dest, n); + void *r = (uint8_t *)__libqasan_memcpy(dest, src, n) + n; + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *memmove(void *dest, const void *src, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: memmove(%p, %p, %ld)\n", rtv, dest, src, n); + QASAN_LOAD(src, n); + QASAN_STORE(dest, n); + void *r = __libqasan_memmove(dest, src, n); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *memset(void *s, int c, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: memset(%p, %d, %ld)\n", rtv, s, c, n); + QASAN_STORE(s, n); + void *r = __libqasan_memset(s, c, n); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *memchr(const void *s, int c, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: memchr(%p, %d, %ld)\n", rtv, s, c, n); + void *r = __libqasan_memchr(s, c, n); + if (r == NULL) + QASAN_LOAD(s, n); + else + QASAN_LOAD(s, r - s); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *memrchr(const void *s, int c, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: memrchr(%p, %d, %ld)\n", rtv, s, c, n); + QASAN_LOAD(s, n); + void *r = __libqasan_memrchr(s, c, n); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +void *memmem(const void *haystack, size_t haystacklen, const void *needle, + size_t needlelen) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: memmem(%p, %ld, %p, %ld)\n", rtv, haystack, haystacklen, + needle, needlelen); + QASAN_LOAD(haystack, haystacklen); + QASAN_LOAD(needle, needlelen); + void *r = __libqasan_memmem(haystack, haystacklen, needle, needlelen); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +#ifndef __BIONIC__ +void bzero(void *s, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: bzero(%p, %ld)\n", rtv, s, n); + QASAN_STORE(s, n); + __libqasan_memset(s, 0, n); + +} +#endif + +void explicit_bzero(void *s, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: bzero(%p, %ld)\n", rtv, s, n); + QASAN_STORE(s, n); + __libqasan_memset(s, 0, n); + +} + +int bcmp(const void *s1, const void *s2, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: bcmp(%p, %p, %ld)\n", rtv, s1, s2, n); + QASAN_LOAD(s1, n); + QASAN_LOAD(s2, n); + int r = __libqasan_bcmp(s1, s2, n); + QASAN_DEBUG("\t\t = %d\n", r); + + return r; + +} + +char *strchr(const char *s, int c) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strchr(%p, %d)\n", rtv, s, c); + size_t l = __libqasan_strlen(s); + QASAN_LOAD(s, l + 1); + void *r = __libqasan_strchr(s, c); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +char *strrchr(const char *s, int c) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strrchr(%p, %d)\n", rtv, s, c); + size_t l = __libqasan_strlen(s); + QASAN_LOAD(s, l + 1); + void *r = __libqasan_strrchr(s, c); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +int strcasecmp(const char *s1, const char *s2) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strcasecmp(%p, %p)\n", rtv, s1, s2); + size_t l1 = __libqasan_strlen(s1); + QASAN_LOAD(s1, l1 + 1); + size_t l2 = __libqasan_strlen(s2); + QASAN_LOAD(s2, l2 + 1); + int r = __libqasan_strcasecmp(s1, s2); + QASAN_DEBUG("\t\t = %d\n", r); + + return r; + +} + +int strncasecmp(const char *s1, const char *s2, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strncasecmp(%p, %p, %ld)\n", rtv, s1, s2, n); + size_t l1 = __libqasan_strnlen(s1, n); + QASAN_LOAD(s1, l1); + size_t l2 = __libqasan_strnlen(s2, n); + QASAN_LOAD(s2, l2); + int r = __libqasan_strncasecmp(s1, s2, n); + QASAN_DEBUG("\t\t = %d\n", r); + + return r; + +} + +char *strcat(char *dest, const char *src) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strcat(%p, %p)\n", rtv, dest, src); + size_t l2 = __libqasan_strlen(src); + QASAN_LOAD(src, l2 + 1); + size_t l1 = __libqasan_strlen(dest); + QASAN_STORE(dest, l1 + l2 + 1); + __libqasan_memcpy(dest + l1, src, l2); + dest[l1 + l2] = 0; + void *r = dest; + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +int strcmp(const char *s1, const char *s2) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strcmp(%p, %p)\n", rtv, s1, s2); + size_t l1 = __libqasan_strlen(s1); + QASAN_LOAD(s1, l1 + 1); + size_t l2 = __libqasan_strlen(s2); + QASAN_LOAD(s2, l2 + 1); + int r = __libqasan_strcmp(s1, s2); + QASAN_DEBUG("\t\t = %d\n", r); + + return r; + +} + +int strncmp(const char *s1, const char *s2, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strncmp(%p, %p, %ld)\n", rtv, s1, s2, n); + size_t l1 = __libqasan_strnlen(s1, n); + QASAN_LOAD(s1, l1); + size_t l2 = __libqasan_strnlen(s2, n); + QASAN_LOAD(s2, l2); + int r = __libqasan_strncmp(s1, s2, n); + QASAN_DEBUG("\t\t = %d\n", r); + + return r; + +} + +char *strcpy(char *dest, const char *src) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strcpy(%p, %p)\n", rtv, dest, src); + size_t l = __libqasan_strlen(src) + 1; + QASAN_LOAD(src, l); + QASAN_STORE(dest, l); + void *r = __libqasan_memcpy(dest, src, l); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +char *strncpy(char *dest, const char *src, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strncpy(%p, %p, %ld)\n", rtv, dest, src, n); + size_t l = __libqasan_strnlen(src, n); + QASAN_STORE(dest, n); + void *r; + if (l < n) { + + QASAN_LOAD(src, l + 1); + r = __libqasan_memcpy(dest, src, l + 1); + + } else { + + QASAN_LOAD(src, n); + r = __libqasan_memcpy(dest, src, n); + + } + + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +char *stpcpy(char *dest, const char *src) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: stpcpy(%p, %p)\n", rtv, dest, src); + size_t l = __libqasan_strlen(src) + 1; + QASAN_LOAD(src, l); + QASAN_STORE(dest, l); + char *r = __libqasan_memcpy(dest, src, l) + (l - 1); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +char *strdup(const char *s) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strdup(%p)\n", rtv, s); + size_t l = __libqasan_strlen(s); + QASAN_LOAD(s, l + 1); + void *r = __libqasan_malloc(l + 1); + __libqasan_memcpy(r, s, l + 1); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +size_t strlen(const char *s) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strlen(%p)\n", rtv, s); + size_t r = __libqasan_strlen(s); + QASAN_LOAD(s, r + 1); + QASAN_DEBUG("\t\t = %ld\n", r); + + return r; + +} + +size_t strnlen(const char *s, size_t n) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strnlen(%p, %ld)\n", rtv, s, n); + size_t r = __libqasan_strnlen(s, n); + QASAN_LOAD(s, r); + QASAN_DEBUG("\t\t = %ld\n", r); + + return r; + +} + +char *strstr(const char *haystack, const char *needle) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strstr(%p, %p)\n", rtv, haystack, needle); + size_t l = __libqasan_strlen(haystack) + 1; + QASAN_LOAD(haystack, l); + l = __libqasan_strlen(needle) + 1; + QASAN_LOAD(needle, l); + void *r = __libqasan_strstr(haystack, needle); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +char *strcasestr(const char *haystack, const char *needle) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: strcasestr(%p, %p)\n", rtv, haystack, needle); + size_t l = __libqasan_strlen(haystack) + 1; + QASAN_LOAD(haystack, l); + l = __libqasan_strlen(needle) + 1; + QASAN_LOAD(needle, l); + void *r = __libqasan_strcasestr(haystack, needle); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +int atoi(const char *nptr) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: atoi(%p)\n", rtv, nptr); + size_t l = __libqasan_strlen(nptr) + 1; + QASAN_LOAD(nptr, l); + int r = __lq_libc_atoi(nptr); + QASAN_DEBUG("\t\t = %d\n", r); + + return r; + +} + +long atol(const char *nptr) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: atol(%p)\n", rtv, nptr); + size_t l = __libqasan_strlen(nptr) + 1; + QASAN_LOAD(nptr, l); + long r = __lq_libc_atol(nptr); + QASAN_DEBUG("\t\t = %ld\n", r); + + return r; + +} + +long long atoll(const char *nptr) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: atoll(%p)\n", rtv, nptr); + size_t l = __libqasan_strlen(nptr) + 1; + QASAN_LOAD(nptr, l); + long long r = __lq_libc_atoll(nptr); + QASAN_DEBUG("\t\t = %lld\n", r); + + return r; + +} + +size_t wcslen(const wchar_t *s) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: wcslen(%p)\n", rtv, s); + size_t r = __libqasan_wcslen(s); + QASAN_LOAD(s, sizeof(wchar_t) * (r + 1)); + QASAN_DEBUG("\t\t = %ld\n", r); + + return r; + +} + +wchar_t *wcscpy(wchar_t *dest, const wchar_t *src) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: wcscpy(%p, %p)\n", rtv, dest, src); + size_t l = __libqasan_wcslen(src) + 1; + QASAN_LOAD(src, l * sizeof(wchar_t)); + QASAN_STORE(dest, l * sizeof(wchar_t)); + void *r = __libqasan_wcscpy(dest, src); + QASAN_DEBUG("\t\t = %p\n", r); + + return r; + +} + +int wcscmp(const wchar_t *s1, const wchar_t *s2) { + + void *rtv = __builtin_return_address(0); + + QASAN_DEBUG("%14p: wcscmp(%p, %p)\n", rtv, s1, s2); + size_t l1 = __libqasan_wcslen(s1); + QASAN_LOAD(s1, sizeof(wchar_t) * (l1 + 1)); + size_t l2 = __libqasan_wcslen(s2); + QASAN_LOAD(s2, sizeof(wchar_t) * (l2 + 1)); + int r = __libqasan_wcscmp(s1, s2); + QASAN_DEBUG("\t\t = %d\n", r); + + return r; + +} + diff --git a/qemu_mode/libqasan/libqasan.c b/qemu_mode/libqasan/libqasan.c new file mode 100644 index 00000000..11b50270 --- /dev/null +++ b/qemu_mode/libqasan/libqasan.c @@ -0,0 +1,94 @@ +/******************************************************************************* +Copyright (c) 2019-2020, Andrea Fioraldi + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "libqasan.h" + +#ifdef DEBUG +int __qasan_debug; +#endif +int __qasan_log; + +void __libqasan_print_maps(void) { + + int fd = open("/proc/self/maps", O_RDONLY); + char buf[4096] = {0}; + + read(fd, buf, 4095); + close(fd); + + size_t len = strlen(buf); + + QASAN_LOG("Guest process maps:\n"); + int i; + char *line = NULL; + for (i = 0; i < len; i++) { + + if (!line) line = &buf[i]; + if (buf[i] == '\n') { + + buf[i] = 0; + QASAN_LOG("%s\n", line); + line = NULL; + + } + + } + + if (line) QASAN_LOG("%s\n", line); + QASAN_LOG("\n"); + +} + +/*__attribute__((constructor))*/ void __libqasan_init() { + + __libqasan_init_hooks(); + +#ifdef DEBUG + __qasan_debug = getenv("QASAN_DEBUG") != NULL; +#endif + __qasan_log = getenv("QASAN_LOG") != NULL; + + QASAN_LOG("QEMU-AddressSanitizer (v%s)\n", QASAN_VERSTR); + QASAN_LOG( + "Copyright (C) 2019-2020 Andrea Fioraldi \n"); + QASAN_LOG("\n"); + + if (__qasan_log) __libqasan_print_maps(); + +} + +int __libc_start_main(int (*main)(int, char **, char **), int argc, char **argv, + int (*init)(int, char **, char **), void (*fini)(void), + void (*rtld_fini)(void), void *stack_end) { + + typeof(&__libc_start_main) orig = dlsym(RTLD_NEXT, "__libc_start_main"); + + __libqasan_init(); + if (getenv("AFL_INST_LIBS")) __libqasan_hotpatch(); + + return orig(main, argc, argv, init, fini, rtld_fini, stack_end); + +} + diff --git a/qemu_mode/libqasan/libqasan.h b/qemu_mode/libqasan/libqasan.h new file mode 100644 index 00000000..0761e157 --- /dev/null +++ b/qemu_mode/libqasan/libqasan.h @@ -0,0 +1,131 @@ +/******************************************************************************* +Copyright (c) 2019-2020, Andrea Fioraldi + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#ifndef __LIBQASAN_H__ +#define __LIBQASAN_H__ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qasan.h" + +#define QASAN_LOG(msg...) \ + do { \ + \ + if (__qasan_log) { \ + \ + fprintf(stderr, "==%d== ", getpid()); \ + fprintf(stderr, msg); \ + \ + } \ + \ + } while (0) + +#ifdef DEBUG +#define QASAN_DEBUG(msg...) \ + do { \ + \ + if (__qasan_debug) { \ + \ + fprintf(stderr, "==%d== ", getpid()); \ + fprintf(stderr, msg); \ + \ + } \ + \ + } while (0) +#else +#define QASAN_DEBUG(msg...) \ + do { \ + \ + } while (0) +#endif + +#define ASSERT_DLSYM(name) \ + ({ \ + \ + void* a = (void*)dlsym(RTLD_NEXT, #name); \ + if (!a) { \ + \ + fprintf(stderr, \ + "FATAL ERROR: failed dlsym of " #name " in libqasan!\n"); \ + abort(); \ + \ + } \ + a; \ + \ + }) + +extern int __qasan_debug; +extern int __qasan_log; + +void __libqasan_init_hooks(void); +void __libqasan_init_malloc(void); + +void __libqasan_hotpatch(void); + +size_t __libqasan_malloc_usable_size(void* ptr); +void* __libqasan_malloc(size_t size); +void __libqasan_free(void* ptr); +void* __libqasan_calloc(size_t nmemb, size_t size); +void* __libqasan_realloc(void* ptr, size_t size); +int __libqasan_posix_memalign(void** ptr, size_t align, size_t len); +void* __libqasan_memalign(size_t align, size_t len); +void* __libqasan_aligned_alloc(size_t align, size_t len); + +void* __libqasan_memcpy(void* dest, const void* src, size_t n); +void* __libqasan_memmove(void* dest, const void* src, size_t n); +void* __libqasan_memset(void* s, int c, size_t n); +void* __libqasan_memchr(const void* s, int c, size_t n); +void* __libqasan_memrchr(const void* s, int c, size_t n); +size_t __libqasan_strlen(const char* s); +size_t __libqasan_strnlen(const char* s, size_t len); +int __libqasan_strcmp(const char* str1, const char* str2); +int __libqasan_strncmp(const char* str1, const char* str2, size_t len); +int __libqasan_strcasecmp(const char* str1, const char* str2); +int __libqasan_strncasecmp(const char* str1, const char* str2, size_t len); +int __libqasan_memcmp(const void* mem1, const void* mem2, size_t len); +int __libqasan_bcmp(const void* mem1, const void* mem2, size_t len); +char* __libqasan_strstr(const char* haystack, const char* needle); +char* __libqasan_strcasestr(const char* haystack, const char* needle); +void* __libqasan_memmem(const void* haystack, size_t haystack_len, + const void* needle, size_t needle_len); +char* __libqasan_strchr(const char* s, int c); +char* __libqasan_strrchr(const char* s, int c); +size_t __libqasan_wcslen(const wchar_t* s); +wchar_t* __libqasan_wcscpy(wchar_t* d, const wchar_t* s); +int __libqasan_wcscmp(const wchar_t* s1, const wchar_t* s2); + +#endif + diff --git a/qemu_mode/libqasan/malloc.c b/qemu_mode/libqasan/malloc.c new file mode 100644 index 00000000..a53dbb4b --- /dev/null +++ b/qemu_mode/libqasan/malloc.c @@ -0,0 +1,315 @@ +/******************************************************************************* +Copyright (c) 2019-2020, Andrea Fioraldi + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "libqasan.h" +#include +#include +#include +#include + +#define REDZONE_SIZE 128 +// 50 mb quarantine +#define QUARANTINE_MAX_BYTES 52428800 + +#if __STDC_VERSION__ < 201112L || \ + (defined(__FreeBSD__) && __FreeBSD_version < 1200000) +// use this hack if not C11 +typedef struct { + + long long __ll; + long double __ld; + +} max_align_t; + +#endif + +#define ALLOC_ALIGN_SIZE (_Alignof(max_align_t)) + +struct chunk_begin { + + size_t requested_size; + void* aligned_orig; // NULL if not aligned + struct chunk_begin* next; + struct chunk_begin* prev; + char redzone[REDZONE_SIZE]; + +}; + +struct chunk_struct { + + struct chunk_begin begin; + char redzone[REDZONE_SIZE]; + size_t prev_size_padding; + +}; + +// From dlmalloc.c +void* dlmalloc(size_t); +void dlfree(void*); + +int __libqasan_malloc_initialized; + +static struct chunk_begin* quarantine_top; +static struct chunk_begin* quarantine_end; +static size_t quarantine_bytes; + +#ifdef __BIONIC__ +static pthread_mutex_t quarantine_lock; +#define LOCK_TRY pthread_mutex_trylock +#define LOCK_INIT pthread_mutex_init +#define LOCK_UNLOCK pthread_mutex_unlock +#else +static pthread_spinlock_t quarantine_lock; +#define LOCK_TRY pthread_spin_trylock +#define LOCK_INIT pthread_spin_init +#define LOCK_UNLOCK pthread_spin_unlock +#endif + +// need qasan disabled +static int quanratine_push(struct chunk_begin* ck) { + + if (ck->requested_size >= QUARANTINE_MAX_BYTES) return 0; + + if (LOCK_TRY(&quarantine_lock)) return 0; + + while (ck->requested_size + quarantine_bytes >= QUARANTINE_MAX_BYTES) { + + struct chunk_begin* tmp = quarantine_end; + quarantine_end = tmp->prev; + + quarantine_bytes -= tmp->requested_size; + + if (tmp->aligned_orig) + dlfree(tmp->aligned_orig); + else + dlfree(tmp); + + } + + ck->next = quarantine_top; + if (quarantine_top) quarantine_top->prev = ck; + quarantine_top = ck; + + LOCK_UNLOCK(&quarantine_lock); + + return 1; + +} + +void __libqasan_init_malloc(void) { + + if (__libqasan_malloc_initialized) return; + + LOCK_INIT(&quarantine_lock, PTHREAD_PROCESS_PRIVATE); + + __libqasan_malloc_initialized = 1; + QASAN_LOG("\n"); + QASAN_LOG("Allocator initialization done.\n"); + QASAN_LOG("\n"); + +} + +size_t __libqasan_malloc_usable_size(void* ptr) { + + char* p = ptr; + p -= sizeof(struct chunk_begin); + + return ((struct chunk_begin*)p)->requested_size; + +} + +void* __libqasan_malloc(size_t size) { + + if (!__libqasan_malloc_initialized) { + + __libqasan_init_malloc(); + + } + + if (!__libqasan_malloc_initialized) + __libqasan_init_malloc(); + + int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread + + struct chunk_begin* p = dlmalloc(sizeof(struct chunk_struct) + size); + + QASAN_SWAP(state); + + if (!p) return NULL; + + QASAN_UNPOISON(p, sizeof(struct chunk_struct) + size); + + p->requested_size = size; + p->aligned_orig = NULL; + p->next = p->prev = NULL; + + QASAN_ALLOC(&p[1], (char*)&p[1] + size); + QASAN_POISON(p->redzone, REDZONE_SIZE, ASAN_HEAP_LEFT_RZ); + if (size & (ALLOC_ALIGN_SIZE - 1)) + QASAN_POISON((char*)&p[1] + size, + (size & ~(ALLOC_ALIGN_SIZE - 1)) + 8 - size + REDZONE_SIZE, + ASAN_HEAP_RIGHT_RZ); + else + QASAN_POISON((char*)&p[1] + size, REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); + + __builtin_memset(&p[1], 0xff, size); + + return &p[1]; + +} + +void __libqasan_free(void* ptr) { + + if (!ptr) return; + + struct chunk_begin* p = ptr; + p -= 1; + + size_t n = p->requested_size; + + QASAN_STORE(ptr, n); + int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread + + if (!quanratine_push(p)) { + + if (p->aligned_orig) + dlfree(p->aligned_orig); + else + dlfree(p); + + } + + QASAN_SWAP(state); + + if (n & (ALLOC_ALIGN_SIZE - 1)) + n = (n & ~(ALLOC_ALIGN_SIZE - 1)) + ALLOC_ALIGN_SIZE; + + QASAN_POISON(ptr, n, ASAN_HEAP_FREED); + QASAN_DEALLOC(ptr); + +} + +void* __libqasan_calloc(size_t nmemb, size_t size) { + + size *= nmemb; + + char* p = __libqasan_malloc(size); + if (!p) return NULL; + + __builtin_memset(p, 0, size); + + return p; + +} + +void* __libqasan_realloc(void* ptr, size_t size) { + + char* p = __libqasan_malloc(size); + if (!p) return NULL; + + if (!ptr) return p; + + size_t n = ((struct chunk_begin*)ptr)[-1].requested_size; + if (size < n) n = size; + + __builtin_memcpy(p, ptr, n); + + __libqasan_free(ptr); + return p; + +} + +int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { + + if ((align % 2) || (align % sizeof(void*))) return EINVAL; + if (len == 0) { + + *ptr = NULL; + return 0; + + } + + size_t rem = len % align; + size_t size = len; + if (rem) size += rem; + + int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread + + char* orig = dlmalloc(sizeof(struct chunk_struct) + size); + + QASAN_SWAP(state); + + if (!orig) return ENOMEM; + + QASAN_UNPOISON(orig, sizeof(struct chunk_struct) + size); + + char* data = orig + sizeof(struct chunk_begin); + data += align - ((uintptr_t)data % align); + + struct chunk_begin* p = (struct chunk_begin*)data - 1; + + p->requested_size = len; + p->aligned_orig = orig; + + QASAN_ALLOC(data, data + len); + QASAN_POISON(p->redzone, REDZONE_SIZE, ASAN_HEAP_LEFT_RZ); + if (len & (ALLOC_ALIGN_SIZE - 1)) + QASAN_POISON( + data + len, + (len & ~(ALLOC_ALIGN_SIZE - 1)) + ALLOC_ALIGN_SIZE - len + REDZONE_SIZE, + ASAN_HEAP_RIGHT_RZ); + else + QASAN_POISON(data + len, REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); + + __builtin_memset(data, 0xff, len); + + *ptr = data; + + return 0; + +} + +void* __libqasan_memalign(size_t align, size_t len) { + + void* ret = NULL; + + __libqasan_posix_memalign(&ret, align, len); + + return ret; + +} + +void* __libqasan_aligned_alloc(size_t align, size_t len) { + + void* ret = NULL; + + if ((len % align)) return NULL; + + __libqasan_posix_memalign(&ret, align, len); + + return ret; + +} + diff --git a/qemu_mode/libqasan/map_macro.h b/qemu_mode/libqasan/map_macro.h new file mode 100644 index 00000000..e9438dc5 --- /dev/null +++ b/qemu_mode/libqasan/map_macro.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2012 William Swanson + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the names of the authors or + * their institutions shall not be used in advertising or otherwise to + * promote the sale, use or other dealings in this Software without + * prior written authorization from the authors. + */ + +#ifndef MAP_H_INCLUDED +#define MAP_H_INCLUDED + +#define EVAL0(...) __VA_ARGS__ +#define EVAL1(...) EVAL0(EVAL0(EVAL0(__VA_ARGS__))) +#define EVAL2(...) EVAL1(EVAL1(EVAL1(__VA_ARGS__))) +#define EVAL3(...) EVAL2(EVAL2(EVAL2(__VA_ARGS__))) +#define EVAL4(...) EVAL3(EVAL3(EVAL3(__VA_ARGS__))) +#define EVAL(...) EVAL4(EVAL4(EVAL4(__VA_ARGS__))) + +#define MAP_END(...) +#define MAP_OUT +#define MAP_COMMA , + +#define MAP_GET_END2() 0, MAP_END +#define MAP_GET_END1(...) MAP_GET_END2 +#define MAP_GET_END(...) MAP_GET_END1 +#define MAP_NEXT0(test, next, ...) next MAP_OUT +#define MAP_NEXT1(test, next) MAP_NEXT0(test, next, 0) +#define MAP_NEXT(test, next) MAP_NEXT1(MAP_GET_END test, next) + +#define MAP0(f, x, peek, ...) f(x) MAP_NEXT(peek, MAP1)(f, peek, __VA_ARGS__) +#define MAP1(f, x, peek, ...) f(x) MAP_NEXT(peek, MAP0)(f, peek, __VA_ARGS__) + +#define MAP_LIST_NEXT1(test, next) MAP_NEXT0(test, MAP_COMMA next, 0) +#define MAP_LIST_NEXT(test, next) MAP_LIST_NEXT1(MAP_GET_END test, next) + +#define MAP_LIST0(f, x, peek, ...) \ + f(x) MAP_LIST_NEXT(peek, MAP_LIST1)(f, peek, __VA_ARGS__) +#define MAP_LIST1(f, x, peek, ...) \ + f(x) MAP_LIST_NEXT(peek, MAP_LIST0)(f, peek, __VA_ARGS__) + +/** + * Applies the function macro `f` to each of the remaining parameters. + */ +#define MAP(f, ...) EVAL(MAP1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +/** + * Applies the function macro `f` to each of the remaining parameters and + * inserts commas between the results. + */ +#define MAP_LIST(f, ...) \ + EVAL(MAP_LIST1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) + +#endif + diff --git a/qemu_mode/libqasan/patch.c b/qemu_mode/libqasan/patch.c new file mode 100644 index 00000000..ed783292 --- /dev/null +++ b/qemu_mode/libqasan/patch.c @@ -0,0 +1,243 @@ +/******************************************************************************* +Copyright (c) 2019-2020, Andrea Fioraldi + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "libqasan.h" +#include + +#ifdef __x86_64__ + +uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { + + // mov rax, dest + addr[0] = 0x48; + addr[1] = 0xb8; + *(uint8_t**)&addr[2] = dest; + + // jmp rax + addr[10] = 0xff; + addr[11] = 0xe0; + + return &addr[12]; + +} + +#elif __i386__ + +uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { + + // mov eax, dest + addr[0] = 0xb8; + *(uint8_t**)&addr[1] = dest; + + // jmp eax + addr[5] = 0xff; + addr[6] = 0xe0; + + return &addr[7]; + +} + +#elif __arm__ + +// in ARM, r12 is a scratch register used by the linker to jump, +// so let's use it in our stub + +uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { + + // ldr r12, OFF + addr[0] = 0x0; + addr[1] = 0xc0; + addr[2] = 0x9f; + addr[3] = 0xe5; + + // add pc, pc, r12 + addr[4] = 0xc; + addr[5] = 0xf0; + addr[6] = 0x8f; + addr[7] = 0xe0; + + // OFF: .word dest + *(uint32_t*)&addr[8] = (uint32_t)dest; + + return &addr[12]; + +} + +#elif __aarch64__ + +// in ARM64, x16 is a scratch register used by the linker to jump, +// so let's use it in our stub + +uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { + + // ldr x16, OFF + addr[0] = 0x50; + addr[1] = 0x0; + addr[2] = 0x0; + addr[3] = 0x58; + + // br x16 + addr[4] = 0x0; + addr[5] = 0x2; + addr[6] = 0x1f; + addr[7] = 0xd6; + + // OFF: .dword dest + *(uint64_t*)&addr[8] = (uint64_t)dest; + + return &addr[16]; + +} + +#else + +#define CANNOT_HOTPATCH + +#endif + +#ifdef CANNOT_HOTPATCH + +void __libqasan_hotpatch(void) { + +} + +#else + +static void *libc_start, *libc_end; +int libc_perms; + +static void find_libc(void) { + + FILE* fp; + char* line = NULL; + size_t len = 0; + ssize_t read; + + fp = fopen("/proc/self/maps", "r"); + if (fp == NULL) return; + + while ((read = getline(&line, &len, fp)) != -1) { + + int fields, dev_maj, dev_min, inode; + uint64_t min, max, offset; + char flag_r, flag_w, flag_x, flag_p; + char path[512] = ""; + fields = sscanf(line, + "%" PRIx64 "-%" PRIx64 " %c%c%c%c %" PRIx64 + " %x:%x %d" + " %512s", + &min, &max, &flag_r, &flag_w, &flag_x, &flag_p, &offset, + &dev_maj, &dev_min, &inode, path); + + if ((fields < 10) || (fields > 11)) continue; + + if (flag_x == 'x' && (__libqasan_strstr(path, "/libc.so") || + __libqasan_strstr(path, "/libc-"))) { + + libc_start = (void*)min; + libc_end = (void*)max; + + libc_perms = PROT_EXEC; + if (flag_w == 'w') libc_perms |= PROT_WRITE; + if (flag_r == 'r') libc_perms |= PROT_READ; + + break; + + } + + } + + free(line); + fclose(fp); + +} + +/* Why this shit? https://twitter.com/andreafioraldi/status/1227635146452541441 + Unfortunatly, symbol override with LD_PRELOAD is not enough to prevent libc + code to call this optimized XMM-based routines. + We patch them at runtime to call our unoptimized version of the same routine. +*/ + +void __libqasan_hotpatch(void) { + + find_libc(); + + if (!libc_start) return; + + if (mprotect(libc_start, libc_end - libc_start, + PROT_READ | PROT_WRITE | PROT_EXEC) < 0) + return; + + void* libc = dlopen("libc.so.6", RTLD_LAZY); + +#define HOTPATCH(fn) \ + uint8_t* p_##fn = (uint8_t*)dlsym(libc, #fn); \ + if (p_##fn) __libqasan_patch_jump(p_##fn, (uint8_t*)&(fn)); + + HOTPATCH(memcmp) + HOTPATCH(memmove) + + uint8_t* p_memcpy = (uint8_t*)dlsym(libc, "memcpy"); + // fuck you libc + if (p_memcpy && p_memmove != p_memcpy) + __libqasan_patch_jump(p_memcpy, (uint8_t*)&memcpy); + + HOTPATCH(memchr) + HOTPATCH(memrchr) + HOTPATCH(memmem) +#ifndef __BIONIC__ + HOTPATCH(bzero) + HOTPATCH(explicit_bzero) + HOTPATCH(mempcpy) + HOTPATCH(bcmp) +#endif + + HOTPATCH(strchr) + HOTPATCH(strrchr) + HOTPATCH(strcasecmp) + HOTPATCH(strncasecmp) + HOTPATCH(strcat) + HOTPATCH(strcmp) + HOTPATCH(strncmp) + HOTPATCH(strcpy) + HOTPATCH(strncpy) + HOTPATCH(stpcpy) + HOTPATCH(strdup) + HOTPATCH(strlen) + HOTPATCH(strnlen) + HOTPATCH(strstr) + HOTPATCH(strcasestr) + HOTPATCH(wcslen) + HOTPATCH(wcscpy) + HOTPATCH(wcscmp) + +#undef HOTPATCH + + mprotect(libc_start, libc_end - libc_start, libc_perms); + +} + +#endif + diff --git a/qemu_mode/libqasan/string.c b/qemu_mode/libqasan/string.c new file mode 100644 index 00000000..520f0342 --- /dev/null +++ b/qemu_mode/libqasan/string.c @@ -0,0 +1,339 @@ +/******************************************************************************* +Copyright (c) 2019-2020, Andrea Fioraldi + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "libqasan.h" +#include + +void* __libqasan_memcpy(void* dest, const void* src, size_t n) { + + unsigned char* d = dest; + const unsigned char* s = src; + + if (!n) return dest; + + while (n--) { + + *d = *s; + ++d; + ++s; + + } + + return dest; + +} + +void* __libqasan_memmove(void* dest, const void* src, size_t n) { + + unsigned char* d = dest; + const unsigned char* s = src; + + if (!n) return dest; + + if (!((d + n) >= s && d <= (s + n))) // do not overlap + return __libqasan_memcpy(dest, src, n); + + d = __libqasan_malloc(n); + __libqasan_memcpy(d, src, n); + __libqasan_memcpy(dest, d, n); + + __libqasan_free(d); + + return dest; + +} + +void* __libqasan_memset(void* s, int c, size_t n) { + + unsigned char* b = s; + while (n--) + *(b++) = (unsigned char)c; + return s; + +} + +void* __libqasan_memchr(const void* s, int c, size_t n) { + + unsigned char* m = (unsigned char*)s; + size_t i; + for (i = 0; i < n; ++i) + if (m[i] == (unsigned char)c) return &m[i]; + return NULL; + +} + +void* __libqasan_memrchr(const void* s, int c, size_t n) { + + unsigned char* m = (unsigned char*)s; + long i; + for (i = n; i >= 0; --i) + if (m[i] == (unsigned char)c) return &m[i]; + return NULL; + +} + +size_t __libqasan_strlen(const char* s) { + + const char* i = s; + while (*(i++)) + ; + return i - s - 1; + +} + +size_t __libqasan_strnlen(const char* s, size_t len) { + + size_t r = 0; + while (len-- && *(s++)) + ++r; + return r; + +} + +int __libqasan_strcmp(const char* str1, const char* str2) { + + while (1) { + + const unsigned char c1 = *str1, c2 = *str2; + + if (c1 != c2) return c1 - c2; + if (!c1) return 0; + str1++; + str2++; + + } + + return 0; + +} + +int __libqasan_strncmp(const char* str1, const char* str2, size_t len) { + + while (len--) { + + unsigned char c1 = *str1, c2 = *str2; + + if (c1 != c2) return c1 - c2; + if (!c1) return 0; + str1++; + str2++; + + } + + return 0; + +} + +int __libqasan_strcasecmp(const char* str1, const char* str2) { + + while (1) { + + const unsigned char c1 = tolower(*str1), c2 = tolower(*str2); + + if (c1 != c2) return c1 - c2; + if (!c1) return 0; + str1++; + str2++; + + } + + return 0; + +} + +int __libqasan_strncasecmp(const char* str1, const char* str2, size_t len) { + + while (len--) { + + const unsigned char c1 = tolower(*str1), c2 = tolower(*str2); + + if (c1 != c2) return c1 - c2; + if (!c1) return 0; + str1++; + str2++; + + } + + return 0; + +} + +int __libqasan_memcmp(const void* mem1, const void* mem2, size_t len) { + + const char* strmem1 = (const char*)mem1; + const char* strmem2 = (const char*)mem2; + + while (len--) { + + const unsigned char c1 = *strmem1, c2 = *strmem2; + if (c1 != c2) return (c1 > c2) ? 1 : -1; + strmem1++; + strmem2++; + + } + + return 0; + +} + +int __libqasan_bcmp(const void* mem1, const void* mem2, size_t len) { + + const char* strmem1 = (const char*)mem1; + const char* strmem2 = (const char*)mem2; + + while (len--) { + + int diff = *strmem1 ^ *strmem2; + if (diff != 0) return 1; + strmem1++; + strmem2++; + + } + + return 0; + +} + +char* __libqasan_strstr(const char* haystack, const char* needle) { + + do { + + const char* n = needle; + const char* h = haystack; + + while (*n && *h && *n == *h) + n++, h++; + + if (!*n) return (char*)haystack; + + } while (*(haystack++)); + + return 0; + +} + +char* __libqasan_strcasestr(const char* haystack, const char* needle) { + + do { + + const char* n = needle; + const char* h = haystack; + + while (*n && *h && tolower(*n) == tolower(*h)) + n++, h++; + + if (!*n) return (char*)haystack; + + } while (*(haystack++)); + + return 0; + +} + +void* __libqasan_memmem(const void* haystack, size_t haystack_len, + const void* needle, size_t needle_len) { + + const char* n = (const char*)needle; + const char* h = (const char*)haystack; + if (haystack_len < needle_len) return 0; + if (needle_len == 0) return (void*)haystack; + if (needle_len == 1) return memchr(haystack, *n, haystack_len); + + const char* end = h + (haystack_len - needle_len); + + do { + + if (*h == *n) { + + if (memcmp(h, n, needle_len) == 0) return (void*)h; + + } + + } while (h++ <= end); + + return 0; + +} + +char* __libqasan_strchr(const char* s, int c) { + + while (*s != (char)c) + if (!*s++) return 0; + return (char*)s; + +} + +char* __libqasan_strrchr(const char* s, int c) { + + char* r = NULL; + do + if (*s == (char)c) r = (char*)s; + while (*s++); + + return r; + +} + +size_t __libqasan_wcslen(const wchar_t* s) { + + size_t len = 0; + + while (s[len] != L'\0') { + + if (s[++len] == L'\0') return len; + if (s[++len] == L'\0') return len; + if (s[++len] == L'\0') return len; + ++len; + + } + + return len; + +} + +wchar_t* __libqasan_wcscpy(wchar_t* d, const wchar_t* s) { + + wchar_t* a = d; + while ((*d++ = *s++)) + ; + return a; + +} + +int __libqasan_wcscmp(const wchar_t* s1, const wchar_t* s2) { + + wchar_t c1, c2; + do { + + c1 = *s1++; + c2 = *s2++; + if (c2 == L'\0') return c1 - c2; + + } while (c1 == c2); + + return c1 < c2 ? -1 : 1; + +} + diff --git a/qemu_mode/libqasan/uninstrument.c b/qemu_mode/libqasan/uninstrument.c new file mode 100644 index 00000000..e75a09eb --- /dev/null +++ b/qemu_mode/libqasan/uninstrument.c @@ -0,0 +1,83 @@ +/* + +This code is DEPRECATED! +I'm keeping it here cause maybe the unistrumentation of a function is needed +for some strange reason. + +*/ + +/******************************************************************************* +Copyright (c) 2019-2020, Andrea Fioraldi + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#include "libqasan.h" +#include "map_macro.h" +#include +#include + +#define X_GET_FNPAR(type, name) name +#define GET_FNPAR(x) X_GET_FNPAR x +#define X_GET_FNTYPE(type, name) type +#define GET_FNTYPE(x) X_GET_FNTYPE x +#define X_GET_FNDECL(type, name) type name +#define GET_FNDECL(x) X_GET_FNDECL x + +#define HOOK_UNINSTRUMENT(rettype, name, ...) \ + rettype (*__lq_libc_##name)(MAP_LIST(GET_FNTYPE, __VA_ARGS__)); \ + rettype name(MAP_LIST(GET_FNDECL, __VA_ARGS__)) { \ + \ + if (!(__lq_libc_##name)) __lq_libc_##name = ASSERT_DLSYM(name); \ + int state = QASAN_SWAP(QASAN_DISABLED); \ + rettype r = __lq_libc_##name(MAP_LIST(GET_FNPAR, __VA_ARGS__)); \ + QASAN_SWAP(state); \ + \ + return r; \ + \ + } + +HOOK_UNINSTRUMENT(char *, getenv, (const char *, name)) + +/* +HOOK_UNINSTRUMENT(char*, setlocale, (int, category), (const char *, locale)) +HOOK_UNINSTRUMENT(int, setenv, (const char *, name), (const char *, value), +(int, overwrite)) HOOK_UNINSTRUMENT(char*, getenv, (const char *, name)) +HOOK_UNINSTRUMENT(char*, bindtextdomain, (const char *, domainname), (const char +*, dirname)) HOOK_UNINSTRUMENT(char*, bind_textdomain_codeset, (const char *, +domainname), (const char *, codeset)) HOOK_UNINSTRUMENT(char*, gettext, (const +char *, msgid)) HOOK_UNINSTRUMENT(char*, dgettext, (const char *, domainname), +(const char *, msgid)) HOOK_UNINSTRUMENT(char*, dcgettext, (const char *, +domainname), (const char *, msgid), (int, category)) HOOK_UNINSTRUMENT(int, +__gen_tempname, (char, *tmpl), (int, suffixlen), (int, flags), (int, kind)) +HOOK_UNINSTRUMENT(int, mkstemp, (char *, template)) +HOOK_UNINSTRUMENT(int, mkostemp, (char *, template), (int, flags)) +HOOK_UNINSTRUMENT(int, mkstemps, (char *, template), (int, suffixlen)) +HOOK_UNINSTRUMENT(int, mkostemps, (char *, template), (int, suffixlen), (int, +flags)) HOOK_UNINSTRUMENT(struct passwd *, getpwnam, (const char *, name)) +HOOK_UNINSTRUMENT(struct passwd *, getpwuid, (uid_t, uid)) +HOOK_UNINSTRUMENT(int, getpwnam_r, (const char *, name), (struct passwd *, pwd), +(char *, buf), (size_t, buflen), (struct passwd **, result)) +HOOK_UNINSTRUMENT(int, getpwuid_r, (uid_t, uid), (struct passwd *, pwd), (char +*, buf), (size_t, buflen), (struct passwd **, result)) +*/ + diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index 1d494849..a8a45d93 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit 1d494849ff353d35951954e6d8f78a220300f79d +Subproject commit a8a45d93f5248ba96c0bc24e4bae31698e793704 diff --git a/qemu_mode/unsigaction/Makefile b/qemu_mode/unsigaction/Makefile index 206a8f07..c5d2de31 100644 --- a/qemu_mode/unsigaction/Makefile +++ b/qemu_mode/unsigaction/Makefile @@ -16,19 +16,15 @@ _UNIQ=_QINU_ -TARGETCANDIDATES=unsigaction32.so unsigaction64.so +TARGETCANDIDATES=unsigaction.so _TARGETS=$(_UNIQ)$(AFL_NO_X86)$(_UNIQ) __TARGETS=$(_TARGETS:$(_UNIQ)1$(_UNIQ)=) TARGETS=$(__TARGETS:$(_UNIQ)$(_UNIQ)=$(TARGETCANDIDATES)) all: $(TARGETS) - @if [ "$(AFL_NO_X86)" != "" ]; then echo "[!] Note: skipping compilation of unsigaction (AFL_NO_X86 set)."; fi -unsigaction32.so: - @if $(CC) -m32 -fPIC -shared unsigaction.c -o unsigaction32.so 2>/dev/null ; then echo "unsigaction32 build success"; else echo "unsigaction32 build failure (that's fine)"; fi - -unsigaction64.so: - @if $(CC) -m64 -fPIC -shared unsigaction.c -o unsigaction64.so 2>/dev/null ; then echo "unsigaction64 build success"; else echo "unsigaction64 build failure (that's fine)"; fi +unsigaction.so: unsigaction.c + @if $(CC) -fPIC -shared unsigaction.c -o unsigaction.so 2>/dev/null ; then echo "unsigaction build success"; else echo "unsigaction build failure (that's fine)"; fi clean: - rm -f unsigaction32.so unsigaction64.so + rm -f unsigaction.so -- cgit 1.4.1 From 4488e8e10a6ea801fd32e88eddb142ecc3024908 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 15:16:35 +0100 Subject: fix qemu build script --- qemu_mode/build_qemu_support.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu_mode/build_qemu_support.sh b/qemu_mode/build_qemu_support.sh index cef6ca07..a435f6f6 100755 --- a/qemu_mode/build_qemu_support.sh +++ b/qemu_mode/build_qemu_support.sh @@ -366,7 +366,7 @@ if [ "$ORIG_CROSS" = "" ]; then CROSS=$CPU_TARGET-linux-gnu-gcc fi -if ! command -v "$CROSS" &> /dev/null +if ! command -v "$CROSS" > /dev/null then echo "[!] Cross compiler $CROSS could not be found, cannot compile libcompcov libqasan and unsigaction" else -- cgit 1.4.1 From 6f5746d42878207b5d17af71317220932a42ebd7 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 15:38:49 +0100 Subject: AFL_USE_QASAN --- include/common.h | 1 + src/afl-analyze.c | 25 ++++++++++++++++++++ src/afl-common.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/afl-forkserver.c | 4 ++++ src/afl-fuzz.c | 30 +++++++++++++++++++++--- src/afl-showmap.c | 25 ++++++++++++++++++++ src/afl-tmin.c | 25 ++++++++++++++++++++ 7 files changed, 171 insertions(+), 3 deletions(-) diff --git a/include/common.h b/include/common.h index 9490ec5f..bdaa1735 100644 --- a/include/common.h +++ b/include/common.h @@ -47,6 +47,7 @@ void argv_cpy_free(char **argv); char **get_qemu_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv); char **get_wine_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv); char * get_afl_env(char *env); +u8 *get_libqasan_path(u8 *own_loc); extern u8 be_quiet; extern u8 *doc_path; /* path to documentation dir */ diff --git a/src/afl-analyze.c b/src/afl-analyze.c index 0af489fe..28598ba0 100644 --- a/src/afl-analyze.c +++ b/src/afl-analyze.c @@ -1078,6 +1078,31 @@ int main(int argc, char **argv_orig, char **envp) { if (optind == argc || !in_file) { usage(argv[0]); } + if (qemu_mode && getenv("AFL_USE_QASAN")) { + + u8* preload = getenv("AFL_PRELOAD"); + u8* libqasan = get_libqasan_path(argv_orig[0]); + + if (!preload) { + + setenv("AFL_PRELOAD", libqasan, 0); + + } else { + + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); + strcpy(result, libqasan); + strcat(result, " "); + strcat(result, preload); + + setenv("AFL_PRELOAD", result, 1); + ck_free(result); + + } + + ck_free(libqasan); + + } + map_size = get_map_size(); use_hex_offsets = !!get_afl_env("AFL_ANALYZE_HEX"); diff --git a/src/afl-common.c b/src/afl-common.c index cf996548..a69f2e97 100644 --- a/src/afl-common.c +++ b/src/afl-common.c @@ -334,6 +334,70 @@ char **get_wine_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv) { } +/* Get libqasan path. */ + +u8 *get_libqasan_path(u8 *own_loc) { + + if (!unlikely(own_loc)) { FATAL("BUG: param own_loc is NULL"); } + + u8 *tmp, *cp = NULL, *rsl, *own_copy; + + tmp = getenv("AFL_PATH"); + + if (tmp) { + + cp = alloc_printf("%s/libqasan.so", tmp); + + if (access(cp, X_OK)) { FATAL("Unable to find '%s'", tmp); } + + return cp; + + } + + own_copy = ck_strdup(own_loc); + rsl = strrchr(own_copy, '/'); + + if (rsl) { + + *rsl = 0; + + cp = alloc_printf("%s/libqasan.so", own_copy); + ck_free(own_copy); + + if (!access(cp, X_OK)) { + + return cp; + + } + + } else { + + ck_free(own_copy); + + } + + if (!access(BIN_PATH "/libqasan.so", X_OK)) { + + if (cp) { ck_free(cp); } + + return ck_strdup(BIN_PATH "/libqasan.so"); + + } + + SAYF("\n" cLRD "[-] " cRST + "Oops, unable to find the 'libqasan.so' binary. The binary must be " + "built\n" + " separately by following the instructions in " + "qemu_mode/libqasan/README.md. " + "If you\n" + " already have the binary installed, you may need to specify " + "AFL_PATH in the\n" + " environment.\n"); + + FATAL("Failed to locate 'libqasan.so'."); + +} + /* Find binary, used by analyze, showmap, tmin @returns the path, allocating the string */ diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c index 1f5685b0..e59f0d11 100644 --- a/src/afl-forkserver.c +++ b/src/afl-forkserver.c @@ -515,6 +515,10 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, "handle_sigill=0", 0); + /* Envs for QASan */ + setenv("QASAN_MAX_CALL_STACK", "0", 0); + setenv("QASAN_SYMBOLIZE", "0", 0); + /* MSAN is tricky, because it doesn't support abort_on_error=1 at this point. So, we do this in a very hacky way. */ diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index e856730e..54850173 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -326,8 +326,32 @@ int main(int argc, char **argv_orig, char **envp) { "compile time)"); } - #endif + + if (getenv("AFL_USE_QASAN")) { + + u8* preload = getenv("AFL_PRELOAD"); + u8* libqasan = get_libqasan_path(argv_orig[0]); + + if (!preload) { + + setenv("AFL_PRELOAD", libqasan, 0); + + } else { + + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); + strcpy(result, libqasan); + strcat(result, " "); + strcat(result, preload); + + setenv("AFL_PRELOAD", result, 1); + ck_free(result); + + } + + ck_free(libqasan); + + } char **argv = argv_cpy_dup(argc, argv_orig); @@ -1245,7 +1269,7 @@ int main(int argc, char **argv_orig, char **envp) { "instead of using AFL_PRELOAD?"); } - + if (afl->afl_env.afl_preload) { if (afl->fsrv.qemu_mode) { @@ -1297,7 +1321,7 @@ int main(int argc, char **argv_orig, char **envp) { FATAL("Use AFL_PRELOAD instead of AFL_LD_PRELOAD"); } - + save_cmdline(afl, argc, argv); fix_up_banner(afl, argv[optind]); diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 5a0b6ecf..f3cd5a90 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -942,6 +942,31 @@ int main(int argc, char **argv_orig, char **envp) { } if (optind == argc || !out_file) { usage(argv[0]); } + + if (fsrv->qemu_mode && getenv("AFL_USE_QASAN")) { + + u8* preload = getenv("AFL_PRELOAD"); + u8* libqasan = get_libqasan_path(argv_orig[0]); + + if (!preload) { + + setenv("AFL_PRELOAD", libqasan, 0); + + } else { + + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); + strcpy(result, libqasan); + strcat(result, " "); + strcat(result, preload); + + setenv("AFL_PRELOAD", result, 1); + ck_free(result); + + } + + ck_free(libqasan); + + } if (in_dir) { diff --git a/src/afl-tmin.c b/src/afl-tmin.c index 5fd60cd2..9e9e2d63 100644 --- a/src/afl-tmin.c +++ b/src/afl-tmin.c @@ -1074,6 +1074,31 @@ int main(int argc, char **argv_orig, char **envp) { if (optind == argc || !in_file || !output_file) { usage(argv[0]); } check_environment_vars(envp); + + if (fsrv->qemu_mode && getenv("AFL_USE_QASAN")) { + + u8* preload = getenv("AFL_PRELOAD"); + u8* libqasan = get_libqasan_path(argv_orig[0]); + + if (!preload) { + + setenv("AFL_PRELOAD", libqasan, 0); + + } else { + + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); + strcpy(result, libqasan); + strcat(result, " "); + strcat(result, preload); + + setenv("AFL_PRELOAD", result, 1); + ck_free(result); + + } + + ck_free(libqasan); + + } /* initialize cmplog_mode */ shm.cmplog_mode = 0; -- cgit 1.4.1 From 28e1aaa0f113d45c527a9fdf1436752723182ee2 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 15:47:25 +0100 Subject: qasan support in aflpp --- include/envs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/envs.h b/include/envs.h index 931cff15..926c9e27 100644 --- a/include/envs.h +++ b/include/envs.h @@ -164,6 +164,7 @@ static char *afl_environment_variables[] = { "AFL_WINE_PATH", "AFL_NO_SNAPSHOT", "AFL_EXPAND_HAVOC_NOW", + "AFL_USE_QASAN", NULL }; -- cgit 1.4.1 From 40f609c7354ffa75dea16401d6c22a4eac510910 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 29 Jan 2021 15:57:47 +0100 Subject: better cmplog arithmetic --- src/afl-fuzz-redqueen.c | 194 ++++++++++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 80 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 34db7231..5570520a 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -1118,128 +1118,159 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, #ifdef ARITHMETIC_LESSER_GREATER if (lvl < LVL3 || attr == IS_TRANSFORM) { return 0; } + if ((attr & (IS_GREATER | IS_LESSER)) SHAPE_BYTES(h->shape) < 4) { return 0; } + + // transform >= to < and <= to > + if ((attr & IS_EQUAL) && (attr & (IS_GREATER | IS_LESSER))) { + + if (attr & 2) { + + attr += 2; + + } else { + + attr -= 2; + + } + + } + // lesser/greater FP comparison - if ((attr & (IS_LESSER + IS_GREATER)) && - (attr >= IS_FP && attr < IS_FP_MOD)) { + if (attr >= IS_FP && attr < IS_FP_MOD) { - u64 repl_new; - if (SHAPE_BYTES(h->shape) == 4 && its_len >= 4) { + u64 repl_new; - float *f = (float *)&repl; - float g = *f; - g += 1.0; - u32 *r = (u32 *)&g; - repl_new = (u32)*r; + if (attr & IS_GREATER) { - } else if (SHAPE_BYTES(h->shape) == 8 && its_len >= 8) { + if (SHAPE_BYTES(h->shape) == 4 && its_len >= 4) { - double *f = (double *)&repl; - double g = *f; - g += 1.0; + float *f = (float *)&repl; + float g = *f; + g += 1.0; + u32 *r = (u32 *)&g; + repl_new = (u32)*r; - u64 *r = (u64 *)&g; - repl_new = *r; + } else if (SHAPE_BYTES(h->shape) == 8 && its_len >= 8) { - } else { + double *f = (double *)&repl; + double g = *f; + g += 1.0; - return 0; + u64 *r = (u64 *)&g; + repl_new = *r; - } + } else { - changed_val = repl_new; + return 0; - if (unlikely(cmp_extend_encoding(afl, h, pattern, repl_new, o_pattern, - changed_val, 16, idx, taint_len, orig_buf, - buf, cbuf, len, 1, lvl, status))) { + } - return 1; + changed_val = repl_new; - } + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { - if (SHAPE_BYTES(h->shape) == 4) { + return 1; - float *f = (float *)&repl; - float g = *f; - g -= 1.0; - u32 *r = (u32 *)&g; - repl_new = (u32)*r; + } - } else if (SHAPE_BYTES(h->shape) == 8) { + } else { - double *f = (double *)&repl; - double g = *f; - g -= 1.0; - u64 *r = (u64 *)&g; - repl_new = *r; + if (SHAPE_BYTES(h->shape) == 4) { - } else { + float *f = (float *)&repl; + float g = *f; + g -= 1.0; + u32 *r = (u32 *)&g; + repl_new = (u32)*r; - return 0; + } else if (SHAPE_BYTES(h->shape) == 8) { - } + double *f = (double *)&repl; + double g = *f; + g -= 1.0; + u64 *r = (u64 *)&g; + repl_new = *r; - changed_val = repl_new; + } else { - if (unlikely(cmp_extend_encoding(afl, h, pattern, repl_new, o_pattern, - changed_val, 16, idx, taint_len, orig_buf, - buf, cbuf, len, 1, lvl, status))) { + return 0; - return 1; + } - } + changed_val = repl_new; + + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + + return 1; - // transform double to float, llvm likes to do that internally ... - if (SHAPE_BYTES(h->shape) == 8 && its_len >= 4) { + } - double *f = (double *)&repl; - float g = (float)*f; - repl_new = 0; + } + + // transform double to float, llvm likes to do that internally ... + if (SHAPE_BYTES(h->shape) == 8 && its_len >= 4) { + + double *f = (double *)&repl; + float g = (float)*f; + repl_new = 0; #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - memcpy((char *)&repl_new, (char *)&g, 4); + memcpy((char *)&repl_new, (char *)&g, 4); #else - memcpy(((char *)&repl_new) + 4, (char *)&g, 4); + memcpy(((char *)&repl_new) + 4, (char *)&g, 4); #endif - changed_val = repl_new; - h->shape = 3; // modify shape + changed_val = repl_new; + h->shape = 3; // modify shape - // fprintf(stderr, "DOUBLE2FLOAT %llx\n", repl_new); + // fprintf(stderr, "DOUBLE2FLOAT %llx\n", repl_new); - if (unlikely(cmp_extend_encoding( - afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, - taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + + h->shape = 7; // recover shape + return 1; + + } h->shape = 7; // recover shape - return 1; } - h->shape = 7; // recover shape - } - } else if ((attr & (IS_LESSER + IS_GREATER)) && attr < IS_FP) { + else if (attr < IS_FP) { // lesser/greater integer comparison u64 repl_new; - repl_new = repl + 1; - changed_val = repl_new; - if (unlikely(cmp_extend_encoding(afl, h, pattern, repl_new, o_pattern, - changed_val, 32, idx, taint_len, orig_buf, - buf, cbuf, len, 1, lvl, status))) { + if (attr & IS_GREATER) { + + repl_new = repl + 1; + changed_val = repl_new; + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 32, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + + return 1; - return 1; + } - } + } else { - repl_new = repl - 1; - changed_val = repl_new; - if (unlikely(cmp_extend_encoding(afl, h, pattern, repl_new, o_pattern, - changed_val, 32, idx, taint_len, orig_buf, - buf, cbuf, len, 1, lvl, status))) { + repl_new = repl - 1; + changed_val = repl_new; + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 32, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { - return 1; + return 1; + + } } @@ -1432,6 +1463,8 @@ static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) { #endif +#define SWAPA(_x) ((_x & 0xf8) + ((_x & 7) ^ 0x07)) + static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, u32 lvl, struct tainted *taint) { @@ -1588,8 +1621,8 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, if (unlikely(cmp_extend_encodingN( afl, h, s128_v1, s128_v0, orig_s128_v1, orig_s128_v0, - h->attribute, idx, taint_len, orig_buf, buf, cbuf, len, 1, - lvl, &status))) { + SWAPA(h->attribute), idx, taint_len, orig_buf, buf, cbuf, len, + 1, lvl, &status))) { return 1; @@ -1634,9 +1667,10 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, status = 0; if ((o->v1 != orig_o->v1 || lvl >= LVL3) && orig_o->v0 != orig_o->v1) { - if (unlikely(cmp_extend_encoding( - afl, h, o->v1, o->v0, orig_o->v1, orig_o->v0, h->attribute, idx, - taint_len, orig_buf, buf, cbuf, len, 1, lvl, &status))) { + if (unlikely(cmp_extend_encoding(afl, h, o->v1, o->v0, orig_o->v1, + orig_o->v0, SWAPA(h->attribute), idx, + taint_len, orig_buf, buf, cbuf, len, 1, + lvl, &status))) { return 1; -- cgit 1.4.1 From 66c290f804636de19017ecc3c9ece4a7af9eed28 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 29 Jan 2021 17:23:19 +0100 Subject: fix compile --- src/afl-fuzz-redqueen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 5570520a..1ef84046 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -31,7 +31,7 @@ //#define _DEBUG #define COMBINE //#define CMPLOG_INTROSPECTION -//#define ARITHMETIC_LESSER_GREATER +#define ARITHMETIC_LESSER_GREATER //#define TRANSFORM //#define TRANSFORM_BASE64 @@ -1118,7 +1118,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, #ifdef ARITHMETIC_LESSER_GREATER if (lvl < LVL3 || attr == IS_TRANSFORM) { return 0; } - if ((attr & (IS_GREATER | IS_LESSER)) SHAPE_BYTES(h->shape) < 4) { return 0; } + if (!(attr & (IS_GREATER | IS_LESSER)) || SHAPE_BYTES(h->shape) < 4) { return 0; } // transform >= to < and <= to > if ((attr & IS_EQUAL) && (attr & (IS_GREATER | IS_LESSER))) { -- cgit 1.4.1 From 8a8ecef6f5a11f3b8b7e43ad7232751aeecc6635 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 29 Jan 2021 18:13:45 +0100 Subject: cmplog lower fail --- src/afl-fuzz-redqueen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 1ef84046..67d505fc 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -2440,8 +2440,8 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { if (!afl->shm.cmp_map->headers[k].hits) { continue; } - if (afl->pass_stats[k].faileds == 0xff || - afl->pass_stats[k].total == 0xff) { + if (afl->pass_stats[k].faileds >= 0x69 || + afl->pass_stats[k].total >= 0x69) { #ifdef _DEBUG fprintf(stderr, "DISABLED %u\n", k); -- cgit 1.4.1 From debd832f36b142e1b0b1bab8a6966848a51878f8 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Fri, 29 Jan 2021 18:25:25 +0100 Subject: 32bit fix --- src/afl-fuzz-redqueen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 1ef84046..fc620781 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -1700,12 +1700,15 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, if (afl->pass_stats[key].total == 0) { +#ifdef WORD_SIZE_64 if (unlikely(is_n)) { try_to_add_to_dictN(afl, s128_v0, SHAPE_BYTES(h->shape)); try_to_add_to_dictN(afl, s128_v1, SHAPE_BYTES(h->shape)); - } else { + } else +#endif + { try_to_add_to_dict(afl, o->v0, SHAPE_BYTES(h->shape)); try_to_add_to_dict(afl, o->v1, SHAPE_BYTES(h->shape)); -- cgit 1.4.1 From 29c1131fe0851d518d06c9ec8c808098dacb12fb Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 18:32:28 +0100 Subject: working AFL_USE_QASAN --- qemu_mode/libqasan/README.md | 5 ++++- src/afl-fuzz.c | 51 ++++++++++++++++++++++---------------------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/qemu_mode/libqasan/README.md b/qemu_mode/libqasan/README.md index 1333ed77..399ebeee 100644 --- a/qemu_mode/libqasan/README.md +++ b/qemu_mode/libqasan/README.md @@ -1 +1,4 @@ -TODO +# QEMU AddressSanitizer Runtime + +This library is the injected runtime used by QEMU AddressSanitizer (QASan). + diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 54850173..312d9424 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -328,31 +328,6 @@ int main(int argc, char **argv_orig, char **envp) { } #endif - if (getenv("AFL_USE_QASAN")) { - - u8* preload = getenv("AFL_PRELOAD"); - u8* libqasan = get_libqasan_path(argv_orig[0]); - - if (!preload) { - - setenv("AFL_PRELOAD", libqasan, 0); - - } else { - - u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); - strcpy(result, libqasan); - strcat(result, " "); - strcat(result, preload); - - setenv("AFL_PRELOAD", result, 1); - ck_free(result); - - } - - ck_free(libqasan); - - } - char **argv = argv_cpy_dup(argc, argv_orig); afl_state_t *afl = calloc(1, sizeof(afl_state_t)); @@ -1009,6 +984,32 @@ int main(int argc, char **argv_orig, char **envp) { usage(argv[0], show_help); } + + if (afl->fsrv.qemu_mode && getenv("AFL_USE_QASAN")) { + + u8* preload = getenv("AFL_PRELOAD"); + u8* libqasan = get_libqasan_path(argv_orig[0]); + + if (!preload) { + + setenv("AFL_PRELOAD", libqasan, 0); + + } else { + + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); + strcpy(result, libqasan); + strcat(result, " "); + strcat(result, preload); + + setenv("AFL_PRELOAD", result, 1); + ck_free(result); + + } + + afl->afl_env.afl_preload = (u8 *)getenv("AFL_PRELOAD"); + ck_free(libqasan); + + } if (afl->fsrv.mem_limit && afl->shm.cmplog_mode) afl->fsrv.mem_limit += 260; -- cgit 1.4.1 From 2e3bc3b61319cd5c153ca66af7d475de7ac962e0 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 18:42:21 +0100 Subject: update qemuafl --- qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/qemuafl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index 1bdaf108..7405c388 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -a8a45d93f5 +246c1777f4 diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index a8a45d93..246c1777 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit a8a45d93f5248ba96c0bc24e4bae31698e793704 +Subproject commit 246c1777f453a280cbafc57f92742147ffc72818 -- cgit 1.4.1 From af24d872206d50c41469321db3c7f77f265ff357 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 18:48:46 +0100 Subject: qasan readme --- qemu_mode/libqasan/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qemu_mode/libqasan/README.md b/qemu_mode/libqasan/README.md index 399ebeee..b5c77044 100644 --- a/qemu_mode/libqasan/README.md +++ b/qemu_mode/libqasan/README.md @@ -2,3 +2,18 @@ This library is the injected runtime used by QEMU AddressSanitizer (QASan). +The original repository is [here](https://github.com/andreafioraldi/qasan). + +The version embedded in qemuafl is an updated version of just the usermode part and this runtime in injected via LD_PRELOAD (so works just for dynamically linked binaries). + +The usage is super simple, just set the env var `AFL_USE_QASAN=1` when fuzzing in qemu mode (-Q). afl-fuzz will automatically set AFL_PRELOAD to load this library and enable the QASan instrumentation in afl-qemu-trace. + +For debugging purposes, we still suggest to run the original QASan as the stacktrace support for ARM (just a debug feature, it does not affect the bug finding capabilities during fuzzing) is WIP. + +### When I should use QASan? + +If your target binary is PIC x86_64, you should before give a try to [retrowrite](https://github.com/HexHive/retrowrite) for static rewriting. + +If it fails, or if your binary is for another architecture, or you want to use persistent and snapshot mdoe, AFL++ QASan mode is what you want/have to use. + +Note that the overhead of libdislocator when combined with QEMU mode is much lower but it can catch less bugs. This is a short blanket, take your choice. -- cgit 1.4.1 From aaec45b6528e41a217de95ca3db1173fb2539672 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 29 Jan 2021 18:51:44 +0100 Subject: changelog --- docs/Changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/Changelog.md b/docs/Changelog.md index 5c6b0663..dd160b14 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -37,6 +37,11 @@ sending a mail to . - added AFL_LLVM_INSTRUMENT option NATIVE for native clang pc-guard support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang + - qemuafl + - solved some persistent mode bugs (thanks Dil4rd) + - solved an issue when dumping the memory maps (thanks wizche) + - ported QASan to qemuafl + - ported the QASan runtime adding support for Android - unicornafl - Substential speed gains in python bindings for certain use cases - Improved rust bindings -- cgit 1.4.1 From 1b557d1a7098519b5024179a65c5bea7adc24e92 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sat, 30 Jan 2021 09:01:06 +0100 Subject: remove warnings --- utils/afl_frida/afl-frida.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utils/afl_frida/afl-frida.c b/utils/afl_frida/afl-frida.c index bf39be1c..85cf2e9d 100644 --- a/utils/afl_frida/afl-frida.c +++ b/utils/afl_frida/afl-frida.c @@ -78,11 +78,11 @@ extern unsigned int * __afl_fuzz_len; extern unsigned char *__afl_fuzz_ptr; // Notify AFL about persistent mode. -static volatile char AFL_PERSISTENT[] = "##SIG_AFL_PERSISTENT##"; +static volatile char AFL_PERSISTENT[] = "##SIG_AFL_PERSISTENT##\0"; int __afl_persistent_loop(unsigned int); // Notify AFL about deferred forkserver. -static volatile char AFL_DEFER_FORKSVR[] = "##SIG_AFL_DEFER_FORKSRV##"; +static volatile char AFL_DEFER_FORKSVR[] = "##SIG_AFL_DEFER_FORKSRV##\0"; void __afl_manual_init(); // Because we do our own logging. @@ -249,9 +249,9 @@ int main(int argc, char **argv) { &instr_range, NULL); // to ensure that the signatures are not optimized out - memcpy(__afl_area_ptr, (void *)AFL_PERSISTENT, sizeof(AFL_PERSISTENT) + 1); + memcpy(__afl_area_ptr, (void *)AFL_PERSISTENT, sizeof(AFL_PERSISTENT)); memcpy(__afl_area_ptr + 32, (void *)AFL_DEFER_FORKSVR, - sizeof(AFL_DEFER_FORKSVR) + 1); + sizeof(AFL_DEFER_FORKSVR)); __afl_manual_init(); // -- cgit 1.4.1 From 2f96f1e9204f60d0a1b91a01f5da34b64b29cf9b Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sat, 30 Jan 2021 10:28:34 +0100 Subject: afl-frida faster for x86_x64 --- docs/Changelog.md | 6 ++-- utils/afl_frida/afl-frida.c | 87 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 4 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index dd160b14..329b7520 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -38,10 +38,10 @@ sending a mail to . support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang - qemuafl + - ported QASan to qemuafl! see qemu_mode/libqasan/README.md - solved some persistent mode bugs (thanks Dil4rd) - solved an issue when dumping the memory maps (thanks wizche) - - ported QASan to qemuafl - - ported the QASan runtime adding support for Android + - Android support for QASan - unicornafl - Substential speed gains in python bindings for certain use cases - Improved rust bindings @@ -51,7 +51,7 @@ sending a mail to . - LLVM mode is now compiled with -j4, unicorn with all cores. qemu was already building with all cores, the gcc plugin needs only one. - added dummy Makefile to instrumentation/ - - Updated utils/afl_frida to be 5% faster + - Updated utils/afl_frida to be 5% faster, 7% on x86_x64 - Added AFL_KILL_SIGNAL env variable (thanks @v-p-b) - @Edznux added a nice documentation on how to use rpc.statsd with afl++ in docs/rpc_statsd.md, thanks! diff --git a/utils/afl_frida/afl-frida.c b/utils/afl_frida/afl-frida.c index 85cf2e9d..711d8f33 100644 --- a/utils/afl_frida/afl-frida.c +++ b/utils/afl_frida/afl-frida.c @@ -94,6 +94,8 @@ typedef struct { GumAddress base_address; guint64 code_start, code_end; + GumAddress current_log_impl; + uint64_t afl_prev_loc; } range_t; @@ -109,12 +111,58 @@ inline static void afl_maybe_log(guint64 current_pc) { } +#if GUM_NATIVE_CPU == GUM_CPU_AMD64 + +static const guint8 afl_maybe_log_code[] = { + + 0x9c, // pushfq + 0x50, // push rax + 0x51, // push rcx + 0x52, // push rdx + 0x56, // push rsi + + 0x89, 0xf8, // mov eax, edi + 0xc1, 0xe0, 0x08, // shl eax, 8 + 0xc1, 0xef, 0x04, // shr edi, 4 + 0x31, 0xc7, // xor edi, eax + 0x0f, 0xb7, 0xc7, // movzx eax, di + 0x48, 0x8d, 0x0d, 0x30, 0x00, 0x00, 0x00, // lea rcx, sym._afl_area_ptr_ptr + 0x48, 0x8b, 0x09, // mov rcx, qword [rcx] + 0x48, 0x8b, 0x09, // mov rcx, qword [rcx] + 0x48, 0x8d, 0x15, 0x1b, 0x00, 0x00, 0x00, // lea rdx, sym._afl_prev_loc_ptr + 0x48, 0x8b, 0x32, // mov rsi, qword [rdx] + 0x48, 0x8b, 0x36, // mov rsi, qword [rsi] + 0x48, 0x31, 0xc6, // xor rsi, rax + 0xfe, 0x04, 0x31, // inc byte [rcx + rsi] + + 0x48, 0xd1, 0xe8, // shr rax, 1 + 0x48, 0x8b, 0x0a, // mov rcx, qword [rdx] + 0x48, 0x89, 0x01, // mov qword [rcx], rax + + 0x5e, // pop rsi + 0x5a, // pop rdx + 0x59, // pop rcx + 0x58, // pop rax + 0x9d, // popfq + + 0xc3, // ret + // Read-only data goes here: + // uint64_t* afl_prev_loc_ptr + // uint8_t** afl_area_ptr_ptr + // unsigned int afl_instr_rms + +}; + +#else + static void on_basic_block(GumCpuContext *context, gpointer user_data) { afl_maybe_log((guint64)user_data); } +#endif + void instr_basic_block(GumStalkerIterator *iterator, GumStalkerOutput *output, gpointer user_data) { @@ -129,8 +177,45 @@ void instr_basic_block(GumStalkerIterator *iterator, GumStalkerOutput *output, if (instr->address >= range->code_start && instr->address <= range->code_end) { +#if GUM_NATIVE_CPU == GUM_CPU_AMD64 + GumX86Writer *cw = output->writer.x86; + if (range->current_log_impl == 0 || + !gum_x86_writer_can_branch_directly_between( + cw->pc, range->current_log_impl) || + !gum_x86_writer_can_branch_directly_between( + cw->pc + 128, range->current_log_impl)) { + + gconstpointer after_log_impl = cw->code + 1; + + gum_x86_writer_put_jmp_near_label(cw, after_log_impl); + + range->current_log_impl = cw->pc; + gum_x86_writer_put_bytes(cw, afl_maybe_log_code, + sizeof(afl_maybe_log_code)); + + uint64_t *afl_prev_loc_ptr = &range->afl_prev_loc; + uint8_t **afl_area_ptr_ptr = &__afl_area_ptr; + gum_x86_writer_put_bytes(cw, (const guint8 *)&afl_prev_loc_ptr, + sizeof(afl_prev_loc_ptr)); + gum_x86_writer_put_bytes(cw, (const guint8 *)&afl_area_ptr_ptr, + sizeof(afl_area_ptr_ptr)); + gum_x86_writer_put_label(cw, after_log_impl); + + } + + gum_x86_writer_put_lea_reg_reg_offset(cw, GUM_REG_RSP, GUM_REG_RSP, + -GUM_RED_ZONE_SIZE); + gum_x86_writer_put_push_reg(cw, GUM_REG_RDI); + gum_x86_writer_put_mov_reg_address(cw, GUM_REG_RDI, + GUM_ADDRESS(instr->address)); + gum_x86_writer_put_call_address(cw, range->current_log_impl); + gum_x86_writer_put_pop_reg(cw, GUM_REG_RDI); + gum_x86_writer_put_lea_reg_reg_offset(cw, GUM_REG_RSP, GUM_REG_RSP, + GUM_RED_ZONE_SIZE); +#else gum_stalker_iterator_put_callout(iterator, on_basic_block, (gpointer)instr->address, NULL); +#endif begin = FALSE; } @@ -228,7 +313,7 @@ int main(int argc, char **argv) { guint64 code_start = code_range.base_address; guint64 code_end = code_range.base_address + code_range.size; - range_t instr_range = {0, code_start, code_end}; + range_t instr_range = {0, code_start, code_end, 0, 0}; printf("Frida instrumentation: base=0x%lx instrumenting=0x%lx-%lx\n", base_address, code_start, code_end); -- cgit 1.4.1 From 3b3565269d0453c9f4b5b2847f809cd5d315fff2 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sat, 30 Jan 2021 14:57:17 +0100 Subject: foreign sync from ctime to mtime (libfuzzer) --- include/afl-fuzz.h | 2 +- src/afl-fuzz-init.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index f46d7707..12db9e4d 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -404,7 +404,7 @@ struct afl_pass_stat { struct foreign_sync { u8 * dir; - time_t ctime; + time_t mtime; }; diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 84f81112..1808f0a1 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -468,7 +468,7 @@ void read_foreign_testcases(afl_state_t *afl, int first) { afl->foreign_syncs[iter].dir[0] != 0) { if (first) ACTF("Scanning '%s'...", afl->foreign_syncs[iter].dir); - time_t ctime_max = 0; + time_t mtime_max = 0; u8 * name = strrchr(afl->foreign_syncs[iter].dir, '/'); if (!name) { name = afl->foreign_syncs[iter].dir; } if (!strcmp(name, "queue") || !strcmp(name, "out") || @@ -482,8 +482,8 @@ void read_foreign_testcases(afl_state_t *afl, int first) { } - /* We do not use sorting yet and do a more expensive ctime check instead. - a ctimesort() implementation would be better though. */ + /* We do not use sorting yet and do a more expensive mtime check instead. + a mtimesort() implementation would be better though. */ nl_cnt = scandir(afl->foreign_syncs[iter].dir, &nl, NULL, NULL); @@ -537,8 +537,8 @@ void read_foreign_testcases(afl_state_t *afl, int first) { } - /* we detect new files by their ctime */ - if (likely(st.st_ctime <= afl->foreign_syncs[iter].ctime)) { + /* we detect new files by their mtime */ + if (likely(st.st_mtime <= afl->foreign_syncs[iter].mtime)) { ck_free(fn2); continue; @@ -600,11 +600,11 @@ void read_foreign_testcases(afl_state_t *afl, int first) { munmap(mem, st.st_size); close(fd); - if (st.st_ctime > ctime_max) ctime_max = st.st_ctime; + if (st.st_mtime > mtime_max) mtime_max = st.st_mtime; } - afl->foreign_syncs[iter].ctime = ctime_max; + afl->foreign_syncs[iter].mtime = mtime_max; free(nl); /* not tracked */ } -- cgit 1.4.1 From 9d08f0d098c91e69b5fe41674e4c5d05363af604 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sat, 30 Jan 2021 15:39:47 +0100 Subject: added AFL_CMPLOG_ONLY_NEW feature --- docs/Changelog.md | 2 + docs/env_variables.md | 5 ++ include/afl-fuzz.h | 2 +- include/common.h | 2 +- include/envs.h | 1 + src/afl-analyze.c | 22 ++++---- src/afl-common.c | 6 +-- src/afl-fuzz-init.c | 3 ++ src/afl-fuzz-one.c | 5 +- src/afl-fuzz-redqueen.c | 135 +++++++++++++++++++++++++----------------------- src/afl-fuzz-state.c | 7 +++ src/afl-fuzz.c | 35 +++++++------ src/afl-showmap.c | 24 ++++----- src/afl-tmin.c | 24 ++++----- 14 files changed, 147 insertions(+), 126 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 329b7520..6e59961b 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -20,6 +20,8 @@ sending a mail to . transformations (e.g. toupper, tolower, to/from hex, xor, arithmetics, etc.). this is costly hence new command line option -l that sets the intensity (values 1 to 3). recommended is 1 or 2. + - added `AFL_CMPLOG_ONLY_NEW` to not use cmplog on initial testcases from + `-i` or resumes (as these have most likely already been done) - fix crash for very, very fast targets+systems (thanks to mhlakhani for reporting) - if determinstic mode is active (-D, or -M without -d) then we sync diff --git a/docs/env_variables.md b/docs/env_variables.md index 66d85749..4c3b1cfb 100644 --- a/docs/env_variables.md +++ b/docs/env_variables.md @@ -287,6 +287,11 @@ checks or alter some of the more exotic semantics of the tool: the target. This must be equal or larger than the size the target was compiled with. + - `AFL_CMPLOG_ONLY_NEW` will only perform the expensive cmplog feature for + newly found testcases and not for testcases that are loaded on startup + (`-i in`). This is an important feature to set when resuming a fuzzing + session. + - `AFL_TESTCACHE_SIZE` allows you to override the size of `#define TESTCASE_CACHE` in config.h. Recommended values are 50-250MB - or more if your fuzzing finds a huge amount of paths for large inputs. diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 12db9e4d..e8a21cb5 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -384,7 +384,7 @@ typedef struct afl_env_vars { afl_dumb_forksrv, afl_import_first, afl_custom_mutator_only, afl_no_ui, afl_force_ui, afl_i_dont_care_about_missing_crashes, afl_bench_just_one, afl_bench_until_crash, afl_debug_child, afl_autoresume, afl_cal_fast, - afl_cycle_schedules, afl_expand_havoc, afl_statsd; + afl_cycle_schedules, afl_expand_havoc, afl_statsd, afl_cmplog_only_new; u8 *afl_tmpdir, *afl_custom_mutator_library, *afl_python_module, *afl_path, *afl_hang_tmout, *afl_forksrv_init_tmout, *afl_skip_crashes, *afl_preload, diff --git a/include/common.h b/include/common.h index bdaa1735..bb8831f2 100644 --- a/include/common.h +++ b/include/common.h @@ -47,7 +47,7 @@ void argv_cpy_free(char **argv); char **get_qemu_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv); char **get_wine_argv(u8 *own_loc, u8 **target_path_p, int argc, char **argv); char * get_afl_env(char *env); -u8 *get_libqasan_path(u8 *own_loc); +u8 * get_libqasan_path(u8 *own_loc); extern u8 be_quiet; extern u8 *doc_path; /* path to documentation dir */ diff --git a/include/envs.h b/include/envs.h index 926c9e27..210b34a6 100644 --- a/include/envs.h +++ b/include/envs.h @@ -28,6 +28,7 @@ static char *afl_environment_variables[] = { "AFL_CC", "AFL_CMIN_ALLOW_ANY", "AFL_CMIN_CRASHES_ONLY", + "AFL_CMPLOG_ONLY_NEW", "AFL_CODE_END", "AFL_CODE_START", "AFL_COMPCOV_BINNAME", diff --git a/src/afl-analyze.c b/src/afl-analyze.c index 28598ba0..20aef2da 100644 --- a/src/afl-analyze.c +++ b/src/afl-analyze.c @@ -1079,28 +1079,28 @@ int main(int argc, char **argv_orig, char **envp) { if (optind == argc || !in_file) { usage(argv[0]); } if (qemu_mode && getenv("AFL_USE_QASAN")) { - - u8* preload = getenv("AFL_PRELOAD"); - u8* libqasan = get_libqasan_path(argv_orig[0]); - + + u8 *preload = getenv("AFL_PRELOAD"); + u8 *libqasan = get_libqasan_path(argv_orig[0]); + if (!preload) { - + setenv("AFL_PRELOAD", libqasan, 0); - + } else { - + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); strcpy(result, libqasan); strcat(result, " "); strcat(result, preload); - + setenv("AFL_PRELOAD", result, 1); ck_free(result); - + } - + ck_free(libqasan); - + } map_size = get_map_size(); diff --git a/src/afl-common.c b/src/afl-common.c index a69f2e97..235c4c05 100644 --- a/src/afl-common.c +++ b/src/afl-common.c @@ -364,11 +364,7 @@ u8 *get_libqasan_path(u8 *own_loc) { cp = alloc_printf("%s/libqasan.so", own_copy); ck_free(own_copy); - if (!access(cp, X_OK)) { - - return cp; - - } + if (!access(cp, X_OK)) { return cp; } } else { diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 1808f0a1..2a7864f9 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -25,6 +25,7 @@ #include "afl-fuzz.h" #include +#include "cmplog.h" #ifdef HAVE_AFFINITY @@ -833,6 +834,8 @@ void perform_dry_run(afl_state_t *afl) { } + if (afl->afl_env.afl_cmplog_only_new) { q->colorized = CMPLOG_LVL_MAX; } + u8 *fn = strrchr(q->fname, '/') + 1; ACTF("Attempting dry run with '%s'...", fn); diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c index ff766158..0cf889a8 100644 --- a/src/afl-fuzz-one.c +++ b/src/afl-fuzz-one.c @@ -26,6 +26,7 @@ #include "afl-fuzz.h" #include #include +#include "cmplog.h" /* MOpt */ @@ -553,7 +554,7 @@ u8 fuzz_one_original(afl_state_t *afl) { if (unlikely(len < 4)) { - afl->queue_cur->colorized = 0xff; + afl->queue_cur->colorized = CMPLOG_LVL_MAX; } else { @@ -2981,7 +2982,7 @@ static u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) { if (unlikely(len < 4)) { - afl->queue_cur->colorized = 0xff; + afl->queue_cur->colorized = CMPLOG_LVL_MAX; } else { diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index fc620781..d7657c1d 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -1118,7 +1118,11 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, #ifdef ARITHMETIC_LESSER_GREATER if (lvl < LVL3 || attr == IS_TRANSFORM) { return 0; } - if (!(attr & (IS_GREATER | IS_LESSER)) || SHAPE_BYTES(h->shape) < 4) { return 0; } + if (!(attr & (IS_GREATER | IS_LESSER)) || SHAPE_BYTES(h->shape) < 4) { + + return 0; + + } // transform >= to < and <= to > if ((attr & IS_EQUAL) && (attr & (IS_GREATER | IS_LESSER))) { @@ -1138,110 +1142,110 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // lesser/greater FP comparison if (attr >= IS_FP && attr < IS_FP_MOD) { - u64 repl_new; - - if (attr & IS_GREATER) { + u64 repl_new; - if (SHAPE_BYTES(h->shape) == 4 && its_len >= 4) { + if (attr & IS_GREATER) { - float *f = (float *)&repl; - float g = *f; - g += 1.0; - u32 *r = (u32 *)&g; - repl_new = (u32)*r; + if (SHAPE_BYTES(h->shape) == 4 && its_len >= 4) { - } else if (SHAPE_BYTES(h->shape) == 8 && its_len >= 8) { + float *f = (float *)&repl; + float g = *f; + g += 1.0; + u32 *r = (u32 *)&g; + repl_new = (u32)*r; - double *f = (double *)&repl; - double g = *f; - g += 1.0; + } else if (SHAPE_BYTES(h->shape) == 8 && its_len >= 8) { - u64 *r = (u64 *)&g; - repl_new = *r; + double *f = (double *)&repl; + double g = *f; + g += 1.0; - } else { + u64 *r = (u64 *)&g; + repl_new = *r; - return 0; + } else { - } + return 0; - changed_val = repl_new; + } - if (unlikely(cmp_extend_encoding( - afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, - taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + changed_val = repl_new; - return 1; + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { - } + return 1; - } else { + } - if (SHAPE_BYTES(h->shape) == 4) { + } else { - float *f = (float *)&repl; - float g = *f; - g -= 1.0; - u32 *r = (u32 *)&g; - repl_new = (u32)*r; + if (SHAPE_BYTES(h->shape) == 4) { - } else if (SHAPE_BYTES(h->shape) == 8) { + float *f = (float *)&repl; + float g = *f; + g -= 1.0; + u32 *r = (u32 *)&g; + repl_new = (u32)*r; - double *f = (double *)&repl; - double g = *f; - g -= 1.0; - u64 *r = (u64 *)&g; - repl_new = *r; + } else if (SHAPE_BYTES(h->shape) == 8) { - } else { + double *f = (double *)&repl; + double g = *f; + g -= 1.0; + u64 *r = (u64 *)&g; + repl_new = *r; - return 0; + } else { - } + return 0; - changed_val = repl_new; + } - if (unlikely(cmp_extend_encoding( - afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, - taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + changed_val = repl_new; - return 1; + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { - } + return 1; } - // transform double to float, llvm likes to do that internally ... - if (SHAPE_BYTES(h->shape) == 8 && its_len >= 4) { + } - double *f = (double *)&repl; - float g = (float)*f; - repl_new = 0; + // transform double to float, llvm likes to do that internally ... + if (SHAPE_BYTES(h->shape) == 8 && its_len >= 4) { + + double *f = (double *)&repl; + float g = (float)*f; + repl_new = 0; #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - memcpy((char *)&repl_new, (char *)&g, 4); + memcpy((char *)&repl_new, (char *)&g, 4); #else - memcpy(((char *)&repl_new) + 4, (char *)&g, 4); + memcpy(((char *)&repl_new) + 4, (char *)&g, 4); #endif - changed_val = repl_new; - h->shape = 3; // modify shape - - // fprintf(stderr, "DOUBLE2FLOAT %llx\n", repl_new); + changed_val = repl_new; + h->shape = 3; // modify shape - if (unlikely(cmp_extend_encoding( - afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, - taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { + // fprintf(stderr, "DOUBLE2FLOAT %llx\n", repl_new); - h->shape = 7; // recover shape - return 1; - - } + if (unlikely(cmp_extend_encoding( + afl, h, pattern, repl_new, o_pattern, changed_val, 16, idx, + taint_len, orig_buf, buf, cbuf, len, 1, lvl, status))) { h->shape = 7; // recover shape + return 1; } + h->shape = 7; // recover shape + } + } + else if (attr < IS_FP) { // lesser/greater integer comparison @@ -1707,6 +1711,7 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, try_to_add_to_dictN(afl, s128_v1, SHAPE_BYTES(h->shape)); } else + #endif { diff --git a/src/afl-fuzz-state.c b/src/afl-fuzz-state.c index 8423a3d1..5040e3ef 100644 --- a/src/afl-fuzz-state.c +++ b/src/afl-fuzz-state.c @@ -236,6 +236,13 @@ void read_afl_environment(afl_state_t *afl, char **envp) { afl->afl_env.afl_custom_mutator_only = get_afl_env(afl_environment_variables[i]) ? 1 : 0; + } else if (!strncmp(env, "AFL_CMPLOG_ONLY_NEW", + + afl_environment_variable_len)) { + + afl->afl_env.afl_cmplog_only_new = + get_afl_env(afl_environment_variables[i]) ? 1 : 0; + } else if (!strncmp(env, "AFL_NO_UI", afl_environment_variable_len)) { afl->afl_env.afl_no_ui = diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 312d9424..9d9b0434 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -181,6 +181,7 @@ static void usage(u8 *argv0, int more_help) { "AFL_AUTORESUME: resume fuzzing if directory specified by -o already exists\n" "AFL_BENCH_JUST_ONE: run the target just once\n" "AFL_BENCH_UNTIL_CRASH: exit soon when the first crashing input has been found\n" + "AFL_CMPLOG_ONLY_NEW: do not run cmplog on initial testcases (good for resumes!)\n" "AFL_CRASH_EXITCODE: optional child exit code to be interpreted as crash\n" "AFL_CUSTOM_MUTATOR_LIBRARY: lib with afl_custom_fuzz() to mutate inputs\n" "AFL_CUSTOM_MUTATOR_ONLY: avoid AFL++'s internal mutators\n" @@ -326,8 +327,9 @@ int main(int argc, char **argv_orig, char **envp) { "compile time)"); } + #endif - + char **argv = argv_cpy_dup(argc, argv_orig); afl_state_t *afl = calloc(1, sizeof(afl_state_t)); @@ -356,8 +358,7 @@ int main(int argc, char **argv_orig, char **envp) { while ((opt = getopt( argc, argv, - "+b:B:c:CdDe:E:hi:I:f:F:l:L:m:M:nNo:p:RQs:S:t:T:UV:Wx:Z")) > - 0) { + "+b:B:c:CdDe:E:hi:I:f:F:l:L:m:M:nNo:p:RQs:S:t:T:UV:Wx:Z")) > 0) { switch (opt) { @@ -984,31 +985,31 @@ int main(int argc, char **argv_orig, char **envp) { usage(argv[0], show_help); } - + if (afl->fsrv.qemu_mode && getenv("AFL_USE_QASAN")) { - - u8* preload = getenv("AFL_PRELOAD"); - u8* libqasan = get_libqasan_path(argv_orig[0]); - + + u8 *preload = getenv("AFL_PRELOAD"); + u8 *libqasan = get_libqasan_path(argv_orig[0]); + if (!preload) { - + setenv("AFL_PRELOAD", libqasan, 0); - + } else { - + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); strcpy(result, libqasan); strcat(result, " "); strcat(result, preload); - + setenv("AFL_PRELOAD", result, 1); ck_free(result); - + } - + afl->afl_env.afl_preload = (u8 *)getenv("AFL_PRELOAD"); ck_free(libqasan); - + } if (afl->fsrv.mem_limit && afl->shm.cmplog_mode) afl->fsrv.mem_limit += 260; @@ -1270,7 +1271,7 @@ int main(int argc, char **argv_orig, char **envp) { "instead of using AFL_PRELOAD?"); } - + if (afl->afl_env.afl_preload) { if (afl->fsrv.qemu_mode) { @@ -1322,7 +1323,7 @@ int main(int argc, char **argv_orig, char **envp) { FATAL("Use AFL_PRELOAD instead of AFL_LD_PRELOAD"); } - + save_cmdline(afl, argc, argv); fix_up_banner(afl, argv[optind]); diff --git a/src/afl-showmap.c b/src/afl-showmap.c index f3cd5a90..62bf1021 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -942,30 +942,30 @@ int main(int argc, char **argv_orig, char **envp) { } if (optind == argc || !out_file) { usage(argv[0]); } - + if (fsrv->qemu_mode && getenv("AFL_USE_QASAN")) { - - u8* preload = getenv("AFL_PRELOAD"); - u8* libqasan = get_libqasan_path(argv_orig[0]); - + + u8 *preload = getenv("AFL_PRELOAD"); + u8 *libqasan = get_libqasan_path(argv_orig[0]); + if (!preload) { - + setenv("AFL_PRELOAD", libqasan, 0); - + } else { - + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); strcpy(result, libqasan); strcat(result, " "); strcat(result, preload); - + setenv("AFL_PRELOAD", result, 1); ck_free(result); - + } - + ck_free(libqasan); - + } if (in_dir) { diff --git a/src/afl-tmin.c b/src/afl-tmin.c index 9e9e2d63..09b5211d 100644 --- a/src/afl-tmin.c +++ b/src/afl-tmin.c @@ -1074,30 +1074,30 @@ int main(int argc, char **argv_orig, char **envp) { if (optind == argc || !in_file || !output_file) { usage(argv[0]); } check_environment_vars(envp); - + if (fsrv->qemu_mode && getenv("AFL_USE_QASAN")) { - - u8* preload = getenv("AFL_PRELOAD"); - u8* libqasan = get_libqasan_path(argv_orig[0]); - + + u8 *preload = getenv("AFL_PRELOAD"); + u8 *libqasan = get_libqasan_path(argv_orig[0]); + if (!preload) { - + setenv("AFL_PRELOAD", libqasan, 0); - + } else { - + u8 *result = ck_alloc(strlen(libqasan) + strlen(preload) + 2); strcpy(result, libqasan); strcat(result, " "); strcat(result, preload); - + setenv("AFL_PRELOAD", result, 1); ck_free(result); - + } - + ck_free(libqasan); - + } /* initialize cmplog_mode */ -- cgit 1.4.1 From 893cd47d9cdbfa44e43d03e7d40a56a0c2ad7936 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 31 Jan 2021 13:03:00 +0100 Subject: disable trimming for -M --- README.md | 1 + docs/ideas.md | 15 ++------------- src/afl-fuzz.c | 3 ++- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 2806b734..8c4aab93 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ behaviours and defaults: * a caching of testcases can now be performed and can be modified by editing config.h for TESTCASE_CACHE or by specifying the env variable `AFL_TESTCACHE_SIZE` (in MB). Good values are between 50-500 (default: 50). + * -M mains do not perform trimming * examples/ got renamed to utils/ * libtokencap/ libdislocator/ and qdbi_mode/ were moved to utils/ * afl-cmin/afl-cmin.bash now search first in PATH and last in AFL_PATH diff --git a/docs/ideas.md b/docs/ideas.md index aaa3eed1..7cbe60a5 100644 --- a/docs/ideas.md +++ b/docs/ideas.md @@ -16,6 +16,8 @@ test cases executed. It should be clickable which value is X and Y axis, zoom factor, log scaling on-off, etc. +Mentor: vanhauser-thc + ## WASM Instrumentation Currently, AFL++ can be used for source code fuzzing and traditional binaries. @@ -36,19 +38,6 @@ Either improve a single mutator thorugh learning of many different bugs Mentor: domenukk -## Collision-free Binary-Only Maps - -AFL++ supports collison-free maps using an LTO (link-time-optimization) pass. -This should be possible to implement for QEMU and Unicorn instrumentations. -As the forkserver parent caches just in time translated translation blocks, -adding a simple counter between jumps should be doable. - -Note: this is already in development for qemu by Andrea, so for people who -want to contribute it might make more sense to port his solution to unicorn. - -Mentor: andreafioraldi or domenukk -Issue/idea tracker: [https://github.com/AFLplusplus/AFLplusplus/issues/237](https://github.com/AFLplusplus/AFLplusplus/issues/237) - ## Your idea! Finally, we are open to proposals! diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 9d9b0434..647a665e 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -145,7 +145,7 @@ static void usage(u8 *argv0, int more_help) { "Other stuff:\n" " -M/-S id - distributed mode (see docs/parallel_fuzzing.md)\n" - " -M auto-sets -D and -Z (use -d to disable -D)\n" + " -M auto-sets -D, -Z (use -d to disable -D) and no trimming\n" " -F path - sync to a foreign fuzzer queue directory (requires " "-M, can\n" " be specified up to %u times)\n" @@ -502,6 +502,7 @@ int main(int argc, char **argv_orig, char **envp) { afl->sync_id = ck_strdup(optarg); afl->skip_deterministic = 0; // force deterministic fuzzing afl->old_seed_selection = 1; // force old queue walking seed selection + afl->disable_trim = 1; // disable trimming if ((c = strchr(afl->sync_id, ':'))) { -- cgit 1.4.1 From 7a861498c27997cd7be01a5650d54cff3b87a02e Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 31 Jan 2021 15:04:40 +0100 Subject: added support for __afl_coverage_interesting --- docs/Changelog.md | 3 ++ instrumentation/README.instrument_list.md | 7 +++++ instrumentation/SanitizerCoverageLTO.so.cc | 20 ++++++++++++++ instrumentation/SanitizerCoveragePCGUARD.so.cc | 38 +++++++++++++++++++++++--- src/afl-cc.c | 16 ++++++----- src/afl-fuzz.c | 5 ++-- 6 files changed, 76 insertions(+), 13 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 6e59961b..99bc8b47 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -36,6 +36,9 @@ sending a mail to . - cmplog/redqueen now also tracks floating point, _ExtInt() + 128bit - cmplog/redqueen can now process basic libc++ and libstdc++ std::string comparisons (though no position or length type variants) + - added support for __afl_coverage_interesting() for LTO and + and our own PCGUARD (llvm 10.0.1+), read more about this function + and selective coverage in instrumentation/README.instrument_list.md - added AFL_LLVM_INSTRUMENT option NATIVE for native clang pc-guard support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang diff --git a/instrumentation/README.instrument_list.md b/instrumentation/README.instrument_list.md index b47b50f6..b7dfb40c 100644 --- a/instrumentation/README.instrument_list.md +++ b/instrumentation/README.instrument_list.md @@ -43,6 +43,13 @@ in any function where you want: * `__AFL_COVERAGE_DISCARD();` - reset all coverage gathered until this point * `__AFL_COVERAGE_SKIP();` - mark this test case as unimportant. Whatever happens, afl-fuzz will ignore it. +A special function is `__afl_coverage_interesting`. +To use this, you must define `void __afl_coverage_interesting(u8 val, u32 id);`. +Then you can use this function globally, where the `val` parameter can be set +by you, the `id` parameter is for afl-fuzz and will be overwritten. +Note that useful parameters are for `val` are: 1, 2, 3, 4, 8, 16, 32, 64, 128. +A value of e.g. 33 will be seen as 32 for coverage purposes. + ## 3) Selective instrumenation with AFL_LLVM_ALLOWLIST/AFL_LLVM_DENYLIST This feature is equivalent to llvm 12 sancov feature and allows to specify diff --git a/instrumentation/SanitizerCoverageLTO.so.cc b/instrumentation/SanitizerCoverageLTO.so.cc index 016ac71f..e3490847 100644 --- a/instrumentation/SanitizerCoverageLTO.so.cc +++ b/instrumentation/SanitizerCoverageLTO.so.cc @@ -1237,6 +1237,25 @@ void ModuleSanitizerCoverage::instrumentFunction( for (auto &BB : F) { + for (auto &IN : BB) { + + CallInst *callInst = nullptr; + + if ((callInst = dyn_cast(&IN))) { + + Function *Callee = callInst->getCalledFunction(); + if (!Callee) continue; + if (callInst->getCallingConv() != llvm::CallingConv::C) continue; + StringRef FuncName = Callee->getName(); + if (FuncName.compare(StringRef("__afl_coverage_interesting"))) continue; + + Value *val = ConstantInt::get(Int32Ty, ++afl_global_id); + callInst->setOperand(1, val); + + } + + } + if (shouldInstrumentBlock(F, &BB, DT, PDT, Options)) BlocksToInstrument.push_back(&BB); for (auto &Inst : BB) { @@ -1338,6 +1357,7 @@ bool ModuleSanitizerCoverage::InjectCoverage(Function & F, if (AllBlocks.empty()) return false; CreateFunctionLocalArrays(F, AllBlocks); + for (size_t i = 0, N = AllBlocks.size(); i < N; i++) { // afl++ START diff --git a/instrumentation/SanitizerCoveragePCGUARD.so.cc b/instrumentation/SanitizerCoveragePCGUARD.so.cc index ecd6bc9b..5b274770 100644 --- a/instrumentation/SanitizerCoveragePCGUARD.so.cc +++ b/instrumentation/SanitizerCoveragePCGUARD.so.cc @@ -311,7 +311,8 @@ class ModuleSanitizerCoverage { Function &F, Type *Ty, const char *Section); GlobalVariable *CreatePCArray(Function &F, ArrayRef AllBlocks); - void CreateFunctionLocalArrays(Function &F, ArrayRef AllBlocks); + void CreateFunctionLocalArrays(Function &F, ArrayRef AllBlocks, + uint32_t special); void InjectCoverageAtBlock(Function &F, BasicBlock &BB, size_t Idx, bool IsLeafFunc = true); Function *CreateInitCallsForSections(Module &M, const char *CtorName, @@ -970,11 +971,11 @@ GlobalVariable *ModuleSanitizerCoverage::CreatePCArray( } void ModuleSanitizerCoverage::CreateFunctionLocalArrays( - Function &F, ArrayRef AllBlocks) { + Function &F, ArrayRef AllBlocks, uint32_t special) { if (Options.TracePCGuard) FunctionGuardArray = CreateFunctionLocalArrayInSection( - AllBlocks.size(), F, Int32Ty, SanCovGuardsSectionName); + AllBlocks.size() + special, F, Int32Ty, SanCovGuardsSectionName); if (Options.Inline8bitCounters) Function8bitCounterArray = CreateFunctionLocalArrayInSection( @@ -993,9 +994,38 @@ bool ModuleSanitizerCoverage::InjectCoverage(Function & F, bool IsLeafFunc) { if (AllBlocks.empty()) return false; - CreateFunctionLocalArrays(F, AllBlocks); + + uint32_t special = 0; + for (auto &BB : F) { + + for (auto &IN : BB) { + + CallInst *callInst = nullptr; + + if ((callInst = dyn_cast(&IN))) { + + Function *Callee = callInst->getCalledFunction(); + StringRef FuncName = Callee->getName(); + if (!Callee) continue; + if (callInst->getCallingConv() != llvm::CallingConv::C) continue; + if (FuncName.compare(StringRef("__afl_coverage_interesting"))) continue; + + uint32_t id = 1 + instr + (uint32_t)AllBlocks.size() + special++; + Value * val = ConstantInt::get(Int32Ty, id); + callInst->setOperand(1, val); + + } + + } + + } + + CreateFunctionLocalArrays(F, AllBlocks, special); for (size_t i = 0, N = AllBlocks.size(); i < N; i++) InjectCoverageAtBlock(F, *AllBlocks[i], i, IsLeafFunc); + + instr += special; + return true; } diff --git a/src/afl-cc.c b/src/afl-cc.c index b5dcb632..f513764a 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -572,7 +572,8 @@ static void edit_params(u32 argc, char **argv, char **envp) { cc_params[cc_par_cnt++] = "-Wl,--allow-multiple-definition"; - if (instrument_mode == INSTRUMENT_CFG) + if (instrument_mode == INSTRUMENT_CFG || + instrument_mode == INSTRUMENT_PCGUARD) cc_params[cc_par_cnt++] = alloc_printf( "-Wl,-mllvm=-load=%s/SanitizerCoverageLTO.so", obj_path); else @@ -1670,15 +1671,16 @@ int main(int argc, char **argv, char **envp) { if (compiler_mode == LTO) { if (instrument_mode == 0 || instrument_mode == INSTRUMENT_LTO || - instrument_mode == INSTRUMENT_CFG) { + instrument_mode == INSTRUMENT_CFG || + instrument_mode == INSTRUMENT_PCGUARD) { lto_mode = 1; - if (!instrument_mode) { + // force CFG + // if (!instrument_mode) { - instrument_mode = INSTRUMENT_CFG; - // ptr = instrument_mode_string[instrument_mode]; - - } + instrument_mode = INSTRUMENT_PCGUARD; + // ptr = instrument_mode_string[instrument_mode]; + // } } else if (instrument_mode == INSTRUMENT_LTO || diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 647a665e..82eff61f 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -145,7 +145,8 @@ static void usage(u8 *argv0, int more_help) { "Other stuff:\n" " -M/-S id - distributed mode (see docs/parallel_fuzzing.md)\n" - " -M auto-sets -D, -Z (use -d to disable -D) and no trimming\n" + " -M auto-sets -D, -Z (use -d to disable -D) and no " + "trimming\n" " -F path - sync to a foreign fuzzer queue directory (requires " "-M, can\n" " be specified up to %u times)\n" @@ -502,7 +503,7 @@ int main(int argc, char **argv_orig, char **envp) { afl->sync_id = ck_strdup(optarg); afl->skip_deterministic = 0; // force deterministic fuzzing afl->old_seed_selection = 1; // force old queue walking seed selection - afl->disable_trim = 1; // disable trimming + afl->disable_trim = 1; // disable trimming if ((c = strchr(afl->sync_id, ':'))) { -- cgit 1.4.1 From e5116c6d55185177413104cad1232ca64e04b844 Mon Sep 17 00:00:00 2001 From: aflpp Date: Sun, 31 Jan 2021 17:29:37 +0100 Subject: fix -Z, remove q->next --- include/afl-fuzz.h | 4 +- include/xxhash.h | 2 +- instrumentation/compare-transform-pass.so.cc | 2 +- src/afl-fuzz-init.c | 102 +++++++++++---------------- src/afl-fuzz-one.c | 3 +- src/afl-fuzz-queue.c | 39 +++++----- src/afl-fuzz-stats.c | 10 +-- src/afl-fuzz.c | 65 +++++------------ utils/afl_untracer/afl-untracer.c | 2 +- utils/libtokencap/libtokencap.so.c | 10 +-- utils/persistent_mode/persistent_demo_new.c | 2 +- utils/persistent_mode/test-instr.c | 2 +- 12 files changed, 100 insertions(+), 143 deletions(-) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index e8a21cb5..9b27606c 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -154,6 +154,7 @@ struct queue_entry { u8 *fname; /* File name for the test case */ u32 len; /* Input length */ + u32 id; /* entry number in queue_buf */ u8 colorized, /* Do not run redqueen stage again */ cal_failed; /* Calibration failed? */ @@ -191,8 +192,7 @@ struct queue_entry { u8 * cmplog_colorinput; /* the result buf of colorization */ struct tainted *taint; /* Taint information from CmpLog */ - struct queue_entry *mother, /* queue entry this based on */ - *next; /* Next element, if any */ + struct queue_entry *mother; /* queue entry this based on */ }; diff --git a/include/xxhash.h b/include/xxhash.h index 006d3f3d..3bd56d13 100644 --- a/include/xxhash.h +++ b/include/xxhash.h @@ -287,7 +287,7 @@ typedef uint32_t XXH32_hash_t; #else #include #if UINT_MAX == 0xFFFFFFFFUL -typedef unsigned int XXH32_hash_t; +typedef unsigned int XXH32_hash_t; #else #if ULONG_MAX == 0xFFFFFFFFUL typedef unsigned long XXH32_hash_t; diff --git a/instrumentation/compare-transform-pass.so.cc b/instrumentation/compare-transform-pass.so.cc index da5cf7e9..932540a7 100644 --- a/instrumentation/compare-transform-pass.so.cc +++ b/instrumentation/compare-transform-pass.so.cc @@ -68,7 +68,7 @@ class CompareTransform : public ModulePass { const char *getPassName() const override { #else - StringRef getPassName() const override { + StringRef getPassName() const override { #endif return "transforms compare functions"; diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 2a7864f9..56dae48c 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -817,12 +817,15 @@ void read_testcases(afl_state_t *afl, u8 *directory) { void perform_dry_run(afl_state_t *afl) { - struct queue_entry *q = afl->queue; - u32 cal_failures = 0; + struct queue_entry *q; + u32 cal_failures = 0, idx; u8 * skip_crashes = afl->afl_env.afl_skip_crashes; u8 * use_mem; - while (q) { + for (idx = 0; idx < afl->queued_paths; idx++) { + + q = afl->queue_buf[idx]; + if (unlikely(q->disabled)) { continue; } u8 res; s32 fd; @@ -1052,20 +1055,22 @@ void perform_dry_run(afl_state_t *afl) { p->disabled = 1; p->perf_score = 0; - while (p && p->next != q) - p = p->next; - if (p) - p->next = q->next; - else - afl->queue = q->next; + u32 i = 0; + while (unlikely(afl->queue_buf[i]->disabled)) { + + ++i; + + } + + afl->queue = afl->queue_buf[i]; afl->max_depth = 0; - p = afl->queue; - while (p) { + for (i = 0; i < afl->queued_paths; i++) { - if (p->depth > afl->max_depth) afl->max_depth = p->depth; - p = p->next; + if (!afl->queue_buf[i]->disabled && + afl->queue_buf[i]->depth > afl->max_depth) + afl->max_depth = afl->queue_buf[i]->depth; } @@ -1098,8 +1103,6 @@ void perform_dry_run(afl_state_t *afl) { } - q = q->next; - } if (cal_failures) { @@ -1125,31 +1128,23 @@ void perform_dry_run(afl_state_t *afl) { /* Now we remove all entries from the queue that have a duplicate trace map */ - q = afl->queue; - struct queue_entry *p, *prev = NULL; - int duplicates = 0; - -restart_outer_cull_loop: + u32 duplicates = 0, i; - while (q) { + for (idx = 0; idx < afl->queued_paths; idx++) { - if (q->cal_failed || !q->exec_cksum) { goto next_entry; } + q = afl->queue_buf[idx]; + if (q->disabled || q->cal_failed || !q->exec_cksum) { continue; } - restart_inner_cull_loop: + u32 done = 0; + for (i = idx + 1; i < afl->queued_paths && !done; i++) { - p = q->next; + struct queue_entry *p = afl->queue_buf[i]; + if (p->disabled || p->cal_failed || !p->exec_cksum) { continue; } - while (p) { - - if (!p->cal_failed && p->exec_cksum == q->exec_cksum) { + if (p->exec_cksum == q->exec_cksum) { duplicates = 1; - // We do not remove any of the memory allocated because for - // splicing the data might still be interesting. - // We only decouple them from the linked list. - // This will result in some leaks at exit, but who cares. - // we keep the shorter file if (p->len >= q->len) { @@ -1163,8 +1158,6 @@ restart_outer_cull_loop: p->disabled = 1; p->perf_score = 0; - q->next = p->next; - goto restart_inner_cull_loop; } else { @@ -1178,35 +1171,26 @@ restart_outer_cull_loop: q->disabled = 1; q->perf_score = 0; - if (prev) - prev->next = q = p; - else - afl->queue = q = p; - goto restart_outer_cull_loop; + + done = 1; } } - p = p->next; - } - next_entry: - - prev = q; - q = q->next; - } if (duplicates) { afl->max_depth = 0; - q = afl->queue; - while (q) { - if (q->depth > afl->max_depth) afl->max_depth = q->depth; - q = q->next; + for (idx = 0; idx < afl->queued_paths; idx++) { + + if (!afl->queue_buf[idx]->disabled && + afl->queue_buf[idx]->depth > afl->max_depth) + afl->max_depth = afl->queue_buf[idx]->depth; } @@ -1256,11 +1240,15 @@ static void link_or_copy(u8 *old_path, u8 *new_path) { void pivot_inputs(afl_state_t *afl) { struct queue_entry *q = afl->queue; - u32 id = 0; + u32 id = 0, i; ACTF("Creating hard links for all input files..."); - while (q) { + for (i = 0; i < afl->queued_paths; i++) { + + q = afl->queue_buf[i]; + + if (unlikely(q->disabled)) { continue; } u8 *nfn, *rsl = strrchr(q->fname, '/'); u32 orig_id; @@ -1288,19 +1276,14 @@ void pivot_inputs(afl_state_t *afl) { afl->resuming_fuzz = 1; nfn = alloc_printf("%s/queue/%s", afl->out_dir, rsl); - /* Since we're at it, let's also try to find parent and figure out the + /* Since we're at it, let's also get the parent and figure out the appropriate depth for this entry. */ src_str = strchr(rsl + 3, ':'); if (src_str && sscanf(src_str + 1, "%06u", &src_id) == 1) { - struct queue_entry *s = afl->queue; - while (src_id-- && s) { - - s = s->next; - - } + struct queue_entry *s = afl->queue_buf[src_id]; if (s) { q->depth = s->depth + 1; } @@ -1348,7 +1331,6 @@ void pivot_inputs(afl_state_t *afl) { if (q->passed_det) { mark_as_det_done(afl, q); } - q = q->next; ++id; } diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c index 0cf889a8..18291fb7 100644 --- a/src/afl-fuzz-one.c +++ b/src/afl-fuzz-one.c @@ -544,7 +544,8 @@ u8 fuzz_one_original(afl_state_t *afl) { if (likely(!afl->old_seed_selection)) orig_perf = perf_score = afl->queue_cur->perf_score; else - orig_perf = perf_score = calculate_score(afl, afl->queue_cur); + afl->queue_cur->perf_score = orig_perf = perf_score = + calculate_score(afl, afl->queue_cur); if (unlikely(perf_score <= 0)) { goto abandon_entry; } diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c index 4442b400..ad3e3b8e 100644 --- a/src/afl-fuzz-queue.c +++ b/src/afl-fuzz-queue.c @@ -143,7 +143,7 @@ void create_alias_table(afl_state_t *afl) { struct queue_entry *q = afl->queue_buf[i]; - if (!q->disabled) { q->perf_score = calculate_score(afl, q); } + if (likely(!q->disabled)) { q->perf_score = calculate_score(afl, q); } sum += q->perf_score; @@ -444,7 +444,6 @@ void add_to_queue(afl_state_t *afl, u8 *fname, u32 len, u8 passed_det) { if (afl->queue_top) { - afl->queue_top->next = q; afl->queue_top = q; } else { @@ -465,6 +464,7 @@ void add_to_queue(afl_state_t *afl, u8 *fname, u32 len, u8 passed_det) { AFL_BUF_PARAM(queue), afl->queued_paths * sizeof(struct queue_entry *)); if (unlikely(!queue_buf)) { PFATAL("alloc"); } queue_buf[afl->queued_paths - 1] = q; + q->id = afl->queued_paths - 1; afl->last_path_time = get_cur_time(); @@ -641,10 +641,9 @@ void cull_queue(afl_state_t *afl) { if (likely(!afl->score_changed || afl->non_instrumented_mode)) { return; } - struct queue_entry *q; - u32 len = (afl->fsrv.map_size >> 3); - u32 i; - u8 * temp_v = afl->map_tmp_buf; + u32 len = (afl->fsrv.map_size >> 3); + u32 i; + u8 *temp_v = afl->map_tmp_buf; afl->score_changed = 0; @@ -653,12 +652,9 @@ void cull_queue(afl_state_t *afl) { afl->queued_favored = 0; afl->pending_favored = 0; - q = afl->queue; - - while (q) { + for (i = 0; i < afl->queued_paths; i++) { - q->favored = 0; - q = q->next; + afl->queue_buf[i]->favored = 0; } @@ -697,12 +693,13 @@ void cull_queue(afl_state_t *afl) { } - q = afl->queue; + for (i = 0; i < afl->queued_paths; i++) { + + if (likely(!afl->queue_buf[i]->disabled)) { - while (q) { + mark_as_redundant(afl, afl->queue_buf[i], !afl->queue_buf[i]->favored); - mark_as_redundant(afl, q, !q->favored); - q = q->next; + } } @@ -852,13 +849,15 @@ u32 calculate_score(afl_state_t *afl, struct queue_entry *q) { // Don't modify perf_score for unfuzzed seeds if (q->fuzz_level == 0) break; - struct queue_entry *queue_it = afl->queue; - while (queue_it) { + u32 i; + for (i = 0; i < afl->queued_paths; i++) { - fuzz_mu += log2(afl->n_fuzz[q->n_fuzz_entry]); - n_paths++; + if (likely(!afl->queue_buf[i]->disabled)) { - queue_it = queue_it->next; + fuzz_mu += log2(afl->n_fuzz[afl->queue_buf[i]->n_fuzz_entry]); + n_paths++; + + } } diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index 82da8176..7e99bf8f 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -1014,8 +1014,8 @@ void show_stats(afl_state_t *afl) { void show_init_stats(afl_state_t *afl) { - struct queue_entry *q = afl->queue; - u32 min_bits = 0, max_bits = 0, max_len = 0, count = 0; + struct queue_entry *q; + u32 min_bits = 0, max_bits = 0, max_len = 0, count = 0, i; u64 min_us = 0, max_us = 0; u64 avg_us = 0; @@ -1028,7 +1028,10 @@ void show_init_stats(afl_state_t *afl) { } - while (q) { + for (i = 0; i < afl->queued_paths; i++) { + + q = afl->queue_buf[i]; + if (unlikely(q->disabled)) { continue; } if (!min_us || q->exec_us < min_us) { min_us = q->exec_us; } if (q->exec_us > max_us) { max_us = q->exec_us; } @@ -1039,7 +1042,6 @@ void show_init_stats(afl_state_t *afl) { if (q->len > max_len) { max_len = q->len; } ++count; - q = q->next; } diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 9d9b0434..40d42c11 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1558,45 +1558,6 @@ int main(int argc, char **argv_orig, char **envp) { perform_dry_run(afl); - /* - if (!user_set_cache && afl->q_testcase_max_cache_size) { - - / * The user defined not a fixed number of entries for the cache. - Hence we autodetect a good value. After the dry run inputs are - trimmed and we know the average and max size of the input seeds. - We use this information to set a fitting size to max entries - based on the cache size. * / - - struct queue_entry *q = afl->queue; - u64 size = 0, count = 0, avg = 0, max = 0; - - while (q) { - - ++count; - size += q->len; - if (max < q->len) { max = q->len; } - q = q->next; - - } - - if (count) { - - avg = size / count; - avg = ((avg + max) / 2) + 1; - - } - - if (avg < 10240) { avg = 10240; } - - afl->q_testcase_max_cache_entries = afl->q_testcase_max_cache_size / avg; - - if (afl->q_testcase_max_cache_entries > 32768) - afl->q_testcase_max_cache_entries = 32768; - - } - - */ - if (afl->q_testcase_max_cache_entries) { afl->q_testcase_cache = @@ -1668,7 +1629,10 @@ int main(int argc, char **argv_orig, char **envp) { if (unlikely(afl->old_seed_selection)) { afl->current_entry = 0; - afl->queue_cur = afl->queue; + while (unlikely(afl->queue_buf[afl->current_entry]->disabled)) { + ++afl->current_entry; + } + afl->queue_cur = afl->queue_buf[afl->current_entry]; if (unlikely(seek_to)) { @@ -1800,12 +1764,14 @@ int main(int argc, char **argv_orig, char **envp) { } - struct queue_entry *q = afl->queue; // we must recalculate the scores of all queue entries - while (q) { + for (i = 0; i < (s32)afl->queued_paths; i++) { + + if (likely(!afl->queue_buf[i]->disabled)) { - update_bitmap_score(afl, q); - q = q->next; + update_bitmap_score(afl, afl->queue_buf[i]); + + } } @@ -1847,8 +1813,15 @@ int main(int argc, char **argv_orig, char **envp) { if (unlikely(afl->old_seed_selection)) { - afl->queue_cur = afl->queue_cur->next; - ++afl->current_entry; + while (++afl->current_entry < afl->queued_paths && + afl->queue_buf[afl->current_entry]->disabled) + ; + if (unlikely(afl->current_entry >= afl->queued_paths || + afl->queue_buf[afl->current_entry] == NULL || + afl->queue_buf[afl->current_entry]->disabled)) + afl->queue_cur = NULL; + else + afl->queue_cur = afl->queue_buf[afl->current_entry]; } diff --git a/utils/afl_untracer/afl-untracer.c b/utils/afl_untracer/afl-untracer.c index f3894a06..d2bad0b9 100644 --- a/utils/afl_untracer/afl-untracer.c +++ b/utils/afl_untracer/afl-untracer.c @@ -284,7 +284,7 @@ library_list_t *find_library(char *name) { // this seems to work for clang too. nice :) requires gcc 4.4+ #pragma GCC push_options #pragma GCC optimize("O0") -void breakpoint(void) { +void breakpoint(void) { if (debug) fprintf(stderr, "Breakpoint function \"breakpoint\" reached.\n"); diff --git a/utils/libtokencap/libtokencap.so.c b/utils/libtokencap/libtokencap.so.c index 3629e804..26033b46 100644 --- a/utils/libtokencap/libtokencap.so.c +++ b/utils/libtokencap/libtokencap.so.c @@ -161,8 +161,8 @@ static void __tokencap_load_mappings(void) { #elif defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ - #if defined __FreeBSD__ - int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, __tokencap_pid}; + #if defined __FreeBSD__ + int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, __tokencap_pid}; #elif defined __OpenBSD__ int mib[] = {CTL_KERN, KERN_PROC_VMMAP, __tokencap_pid}; #elif defined __NetBSD__ @@ -177,7 +177,7 @@ static void __tokencap_load_mappings(void) { #if defined __FreeBSD__ || defined __NetBSD__ len = len * 4 / 3; - #elif defined __OpenBSD__ + #elif defined __OpenBSD__ len -= len % sizeof(struct kinfo_vmentry); #endif @@ -202,8 +202,8 @@ static void __tokencap_load_mappings(void) { #if defined __FreeBSD__ || defined __NetBSD__ - #if defined __FreeBSD__ - size_t size = region->kve_structsize; + #if defined __FreeBSD__ + size_t size = region->kve_structsize; if (size == 0) break; #elif defined __NetBSD__ diff --git a/utils/persistent_mode/persistent_demo_new.c b/utils/persistent_mode/persistent_demo_new.c index 7e694696..ca616236 100644 --- a/utils/persistent_mode/persistent_demo_new.c +++ b/utils/persistent_mode/persistent_demo_new.c @@ -51,7 +51,7 @@ __AFL_FUZZ_INIT(); /* To ensure checks are not optimized out it is recommended to disable code optimization for the fuzzer harness main() */ #pragma clang optimize off -#pragma GCC optimize("O0") +#pragma GCC optimize("O0") int main(int argc, char **argv) { diff --git a/utils/persistent_mode/test-instr.c b/utils/persistent_mode/test-instr.c index 6da511de..2c6b6d77 100644 --- a/utils/persistent_mode/test-instr.c +++ b/utils/persistent_mode/test-instr.c @@ -24,7 +24,7 @@ __AFL_FUZZ_INIT(); /* To ensure checks are not optimized out it is recommended to disable code optimization for the fuzzer harness main() */ #pragma clang optimize off -#pragma GCC optimize("O0") +#pragma GCC optimize("O0") int main(int argc, char **argv) { -- cgit 1.4.1 From cc0210426a5a31d56d8a0e850dcc00d90833afcd Mon Sep 17 00:00:00 2001 From: van Hauser Date: Sun, 31 Jan 2021 17:32:24 +0100 Subject: code-format --- docs/Changelog.md | 1 + include/xxhash.h | 2 +- instrumentation/compare-transform-pass.so.cc | 2 +- src/afl-fuzz.c | 3 +++ utils/afl_untracer/afl-untracer.c | 2 +- utils/libtokencap/libtokencap.so.c | 10 +++++----- utils/persistent_mode/persistent_demo_new.c | 2 +- utils/persistent_mode/test-instr.c | 2 +- 8 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 99bc8b47..ff69c949 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -27,6 +27,7 @@ sending a mail to . - if determinstic mode is active (-D, or -M without -d) then we sync after every queue entry as this can take very long time otherwise - better detection if a target needs a large shared map + - fix for -Z - switched to an even faster RNG - added hghwng's patch for faster trace map analysis - afl-cc diff --git a/include/xxhash.h b/include/xxhash.h index 3bd56d13..006d3f3d 100644 --- a/include/xxhash.h +++ b/include/xxhash.h @@ -287,7 +287,7 @@ typedef uint32_t XXH32_hash_t; #else #include #if UINT_MAX == 0xFFFFFFFFUL -typedef unsigned int XXH32_hash_t; +typedef unsigned int XXH32_hash_t; #else #if ULONG_MAX == 0xFFFFFFFFUL typedef unsigned long XXH32_hash_t; diff --git a/instrumentation/compare-transform-pass.so.cc b/instrumentation/compare-transform-pass.so.cc index 932540a7..da5cf7e9 100644 --- a/instrumentation/compare-transform-pass.so.cc +++ b/instrumentation/compare-transform-pass.so.cc @@ -68,7 +68,7 @@ class CompareTransform : public ModulePass { const char *getPassName() const override { #else - StringRef getPassName() const override { + StringRef getPassName() const override { #endif return "transforms compare functions"; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 276074a4..f1f92717 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1632,8 +1632,11 @@ int main(int argc, char **argv_orig, char **envp) { afl->current_entry = 0; while (unlikely(afl->queue_buf[afl->current_entry]->disabled)) { + ++afl->current_entry; + } + afl->queue_cur = afl->queue_buf[afl->current_entry]; if (unlikely(seek_to)) { diff --git a/utils/afl_untracer/afl-untracer.c b/utils/afl_untracer/afl-untracer.c index d2bad0b9..f3894a06 100644 --- a/utils/afl_untracer/afl-untracer.c +++ b/utils/afl_untracer/afl-untracer.c @@ -284,7 +284,7 @@ library_list_t *find_library(char *name) { // this seems to work for clang too. nice :) requires gcc 4.4+ #pragma GCC push_options #pragma GCC optimize("O0") -void breakpoint(void) { +void breakpoint(void) { if (debug) fprintf(stderr, "Breakpoint function \"breakpoint\" reached.\n"); diff --git a/utils/libtokencap/libtokencap.so.c b/utils/libtokencap/libtokencap.so.c index 26033b46..3629e804 100644 --- a/utils/libtokencap/libtokencap.so.c +++ b/utils/libtokencap/libtokencap.so.c @@ -161,8 +161,8 @@ static void __tokencap_load_mappings(void) { #elif defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ - #if defined __FreeBSD__ - int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, __tokencap_pid}; + #if defined __FreeBSD__ + int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, __tokencap_pid}; #elif defined __OpenBSD__ int mib[] = {CTL_KERN, KERN_PROC_VMMAP, __tokencap_pid}; #elif defined __NetBSD__ @@ -177,7 +177,7 @@ static void __tokencap_load_mappings(void) { #if defined __FreeBSD__ || defined __NetBSD__ len = len * 4 / 3; - #elif defined __OpenBSD__ + #elif defined __OpenBSD__ len -= len % sizeof(struct kinfo_vmentry); #endif @@ -202,8 +202,8 @@ static void __tokencap_load_mappings(void) { #if defined __FreeBSD__ || defined __NetBSD__ - #if defined __FreeBSD__ - size_t size = region->kve_structsize; + #if defined __FreeBSD__ + size_t size = region->kve_structsize; if (size == 0) break; #elif defined __NetBSD__ diff --git a/utils/persistent_mode/persistent_demo_new.c b/utils/persistent_mode/persistent_demo_new.c index ca616236..7e694696 100644 --- a/utils/persistent_mode/persistent_demo_new.c +++ b/utils/persistent_mode/persistent_demo_new.c @@ -51,7 +51,7 @@ __AFL_FUZZ_INIT(); /* To ensure checks are not optimized out it is recommended to disable code optimization for the fuzzer harness main() */ #pragma clang optimize off -#pragma GCC optimize("O0") +#pragma GCC optimize("O0") int main(int argc, char **argv) { diff --git a/utils/persistent_mode/test-instr.c b/utils/persistent_mode/test-instr.c index 2c6b6d77..6da511de 100644 --- a/utils/persistent_mode/test-instr.c +++ b/utils/persistent_mode/test-instr.c @@ -24,7 +24,7 @@ __AFL_FUZZ_INIT(); /* To ensure checks are not optimized out it is recommended to disable code optimization for the fuzzer harness main() */ #pragma clang optimize off -#pragma GCC optimize("O0") +#pragma GCC optimize("O0") int main(int argc, char **argv) { -- cgit 1.4.1 From 19d02d7bf6fd08765cb5a4c1657b549feb68e35f Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Sun, 31 Jan 2021 17:45:55 +0100 Subject: update qemu and main makefile for qasan --- GNUmakefile | 4 ++++ qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/qemuafl | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index c71a7d47..b0ab1ab0 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -509,6 +509,8 @@ code-format: ./.custom-format.py -i qemu_mode/libcompcov/*.c ./.custom-format.py -i qemu_mode/libcompcov/*.cc ./.custom-format.py -i qemu_mode/libcompcov/*.h + ./.custom-format.py -i qemu_mode/libqasan/*.c + ./.custom-format.py -i qemu_mode/libqasan/*.h ./.custom-format.py -i *.h ./.custom-format.py -i *.c @@ -563,6 +565,7 @@ clean: $(MAKE) -C utils/argv_fuzzing clean $(MAKE) -C qemu_mode/unsigaction clean $(MAKE) -C qemu_mode/libcompcov clean + $(MAKE) -C qemu_mode/libqasan clean ifeq "$(IN_REPO)" "1" test -e qemu_mode/qemuafl/Makefile && $(MAKE) -C qemu_mode/qemuafl clean || true test -e unicorn_mode/unicornafl/Makefile && $(MAKE) -C unicorn_mode/unicornafl clean || true @@ -638,6 +641,7 @@ install: all $(MANPAGES) @if [ -f libdislocator.so ]; then set -e; install -m 755 libdislocator.so $${DESTDIR}$(HELPER_PATH); fi @if [ -f libtokencap.so ]; then set -e; install -m 755 libtokencap.so $${DESTDIR}$(HELPER_PATH); fi @if [ -f libcompcov.so ]; then set -e; install -m 755 libcompcov.so $${DESTDIR}$(HELPER_PATH); fi + @if [ -f libqasan.so ]; then set -e; install -m 755 libqasan.so $${DESTDIR}$(HELPER_PATH); fi @if [ -f afl-fuzz-document ]; then set -e; install -m 755 afl-fuzz-document $${DESTDIR}$(BIN_PATH); fi @if [ -f socketfuzz32.so -o -f socketfuzz64.so ]; then $(MAKE) -C utils/socket_fuzzing install; fi @if [ -f argvfuzz32.so -o -f argvfuzz64.so ]; then $(MAKE) -C utils/argv_fuzzing install; fi diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index 7405c388..f70fc4ce 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -246c1777f4 +dce1ea3514 diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index 246c1777..dce1ea35 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit 246c1777f453a280cbafc57f92742147ffc72818 +Subproject commit dce1ea35142087d76c79dfe9e95880ac1b54a1d5 -- cgit 1.4.1 From 522eacce71a91f0495834215b08ac38750a4f5d8 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Sun, 31 Jan 2021 21:48:30 +0100 Subject: qemuafl --- qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/qemuafl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index f70fc4ce..97184973 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -dce1ea3514 +6ab6bf28de diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index dce1ea35..6ab6bf28 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit dce1ea35142087d76c79dfe9e95880ac1b54a1d5 +Subproject commit 6ab6bf28decb3e36eee43ffbd4a3bfd052dbbb50 -- cgit 1.4.1 From 981ffb27a8a166b51a06d57fce044ed1eaf1aa62 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 12:01:23 +0100 Subject: making AFL_MAP_SIZE obsolete --- afl-cmin | 4 +-- docs/Changelog.md | 2 ++ include/forkserver.h | 3 ++ include/sharedmem.h | 1 + src/afl-forkserver.c | 28 ++++++++++++++----- src/afl-fuzz-init.c | 14 ++++++---- src/afl-fuzz.c | 73 +++++++++++++++++++++++++++++++++++++++++++------ src/afl-sharedmem.c | 14 ++++++++-- src/afl-showmap.c | 41 +++++++++++++++++++++++++-- src/afl-tmin.c | 37 +++++++++++++++++++++++-- test-instr.c | 5 +++- test/test-basic.sh | 12 ++++---- test/test-gcc-plugin.sh | 10 +++---- test/test-llvm-lto.sh | 8 +++--- test/test-llvm.sh | 10 +++---- 15 files changed, 211 insertions(+), 51 deletions(-) diff --git a/afl-cmin b/afl-cmin index ffefaead..31d7ddad 100755 --- a/afl-cmin +++ b/afl-cmin @@ -343,7 +343,7 @@ BEGIN { stat_format = "-f '%z %N'" # *BSD, MacOS } cmdline = "cd "in_dir" && find . \\( ! -name . -a -type d -prune \\) -o -type f -exec stat "stat_format" \\{\\} \\; | sort -k1n -k2r" - cmdline = "ls "in_dir" | (cd "in_dir" && xargs stat "stat_format") | sort -k1n -k2r" + cmdline = "ls "in_dir" | (cd "in_dir" && xargs stat "stat_format" 2>/dev/null) | sort -k1n -k2r" while (cmdline | getline) { sub(/^[0-9]+ (\.\/)?/,"",$0) infilesSmallToBig[i++] = $0 @@ -355,7 +355,7 @@ BEGIN { # Make sure that we're not dealing with a directory. if (0 == system("test -d "in_dir"/"first_file)) { - print "[-] Error: The input directory contains subdirectories - please fix." > "/dev/stderr" + print "[-] Error: The input directory is empty or contains subdirectories - please fix." > "/dev/stderr" exit 1 } diff --git a/docs/Changelog.md b/docs/Changelog.md index ff69c949..e9efdf38 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -16,6 +16,8 @@ sending a mail to . to be placed in the source code. Check out instrumentation/README.instrument_list.md - afl-fuzz + - Making AFL_MAP_SIZE obsolete - afl-fuzz now learns on start the + target map size - upgraded cmplog/redqueen: solving for floating point, solving transformations (e.g. toupper, tolower, to/from hex, xor, arithmetics, etc.). this is costly hence new command line option diff --git a/include/forkserver.h b/include/forkserver.h index d2fcaa20..ac027f81 100644 --- a/include/forkserver.h +++ b/include/forkserver.h @@ -120,11 +120,14 @@ void afl_fsrv_init(afl_forkserver_t *fsrv); void afl_fsrv_init_dup(afl_forkserver_t *fsrv_to, afl_forkserver_t *from); void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, volatile u8 *stop_soon_p, u8 debug_child_output); +u32 afl_fsrv_get_mapsize(afl_forkserver_t *fsrv, char **argv, + volatile u8 *stop_soon_p, u8 debug_child_output); void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len); fsrv_run_result_t afl_fsrv_run_target(afl_forkserver_t *fsrv, u32 timeout, volatile u8 *stop_soon_p); void afl_fsrv_killall(void); void afl_fsrv_deinit(afl_forkserver_t *fsrv); +void afl_fsrv_kill(afl_forkserver_t *fsrv); #ifdef __APPLE__ #define MSG_FORK_ON_APPLE \ diff --git a/include/sharedmem.h b/include/sharedmem.h index b15d0535..fdc947f9 100644 --- a/include/sharedmem.h +++ b/include/sharedmem.h @@ -51,6 +51,7 @@ typedef struct sharedmem { size_t map_size; /* actual allocated size */ int cmplog_mode; + int shmemfuzz_mode; struct cmp_map *cmp_map; } sharedmem_t; diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c index e59f0d11..9ee59822 100644 --- a/src/afl-forkserver.c +++ b/src/afl-forkserver.c @@ -682,11 +682,7 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, if ((status & FS_OPT_AUTODICT) == FS_OPT_AUTODICT) { - if (ignore_autodict) { - - if (!be_quiet) { WARNF("Ignoring offered AUTODICT feature."); } - - } else { + if (!ignore_autodict) { if (fsrv->add_extra_func == NULL || fsrv->afl_ptr == NULL) { @@ -969,7 +965,9 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv, } -static void afl_fsrv_kill(afl_forkserver_t *fsrv) { +/* Stop the forkserver and child */ + +void afl_fsrv_kill(afl_forkserver_t *fsrv) { if (fsrv->child_pid > 0) { kill(fsrv->child_pid, fsrv->kill_signal); } if (fsrv->fsrv_pid > 0) { @@ -979,13 +977,28 @@ static void afl_fsrv_kill(afl_forkserver_t *fsrv) { } + close(fsrv->fsrv_ctl_fd); + close(fsrv->fsrv_st_fd); + fsrv->fsrv_pid = -1; + fsrv->child_pid = -1; + +} + +/* Get the map size from the target forkserver */ + +u32 afl_fsrv_get_mapsize(afl_forkserver_t *fsrv, char **argv, + volatile u8 *stop_soon_p, u8 debug_child_output) { + + afl_fsrv_start(fsrv, argv, stop_soon_p, debug_child_output); + return fsrv->map_size; + } /* Delete the current testcase and write the buf to the testcase file */ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) { - if (fsrv->shmem_fuzz) { + if (likely(fsrv->use_shmem_fuzz && fsrv->shmem_fuzz)) { if (unlikely(len > MAX_FILE)) len = MAX_FILE; @@ -1042,6 +1055,7 @@ void afl_fsrv_write_to_testcase(afl_forkserver_t *fsrv, u8 *buf, size_t len) { } + // fprintf(stderr, "WRITE %d %u\n", fd, len); ck_write(fd, buf, len, fsrv->out_file); if (fsrv->use_stdin) { diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 56dae48c..40ba20c7 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -766,13 +766,16 @@ void read_testcases(afl_state_t *afl, u8 *directory) { } - if (unlikely(afl->schedule >= FAST && afl->schedule <= RARE)) { + /* + if (unlikely(afl->schedule >= FAST && afl->schedule <= RARE)) { - u64 cksum = hash64(afl->fsrv.trace_bits, afl->fsrv.map_size, HASH_CONST); - afl->queue_top->n_fuzz_entry = cksum % N_FUZZ_SIZE; - afl->n_fuzz[afl->queue_top->n_fuzz_entry] = 1; + u64 cksum = hash64(afl->fsrv.trace_bits, afl->fsrv.map_size, + HASH_CONST); afl->queue_top->n_fuzz_entry = cksum % N_FUZZ_SIZE; + afl->n_fuzz[afl->queue_top->n_fuzz_entry] = 1; - } + } + + */ } @@ -2490,6 +2493,7 @@ void setup_testcase_shmem(afl_state_t *afl) { // we need to set the non-instrumented mode to not overwrite the SHM_ENV_VAR u8 *map = afl_shm_init(afl->shm_fuzz, MAX_FILE + sizeof(u32), 1); + afl->shm_fuzz->shmemfuzz_mode = 1; if (!map) { FATAL("BUG: Zero return from afl_shm_init."); } diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index f1f92717..49733594 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -342,7 +342,6 @@ int main(int argc, char **argv_orig, char **envp) { afl->debug = debug; afl_fsrv_init(&afl->fsrv); if (debug) { afl->fsrv.debug = true; } - read_afl_environment(afl, envp); if (afl->shm.map_size) { afl->fsrv.map_size = afl->shm.map_size; } exit_1 = !!afl->afl_env.afl_bench_just_one; @@ -702,7 +701,6 @@ int main(int argc, char **argv_orig, char **envp) { if (afl->in_bitmap) { FATAL("Multiple -B options not supported"); } afl->in_bitmap = optarg; - read_bitmap(afl->in_bitmap, afl->virgin_bits, afl->fsrv.map_size); break; case 'C': /* crash mode */ @@ -1369,13 +1367,6 @@ int main(int argc, char **argv_orig, char **envp) { set_scheduler_mode(SCHEDULER_MODE_LOW_LATENCY); #endif - afl->fsrv.trace_bits = - afl_shm_init(&afl->shm, afl->fsrv.map_size, afl->non_instrumented_mode); - - if (!afl->in_bitmap) { memset(afl->virgin_bits, 255, afl->fsrv.map_size); } - memset(afl->virgin_tmout, 255, afl->fsrv.map_size); - memset(afl->virgin_crash, 255, afl->fsrv.map_size); - init_count_class16(); if (afl->is_main_node && check_main_node_exists(afl) == 1) { @@ -1542,6 +1533,70 @@ int main(int argc, char **argv_orig, char **envp) { } afl->argv = use_argv; + afl->fsrv.trace_bits = + afl_shm_init(&afl->shm, afl->fsrv.map_size, afl->non_instrumented_mode); + + if (!afl->non_instrumented_mode) { + + afl->fsrv.map_size = 4194304; // dummy temporary value + + u32 new_map_size = afl_fsrv_get_mapsize( + &afl->fsrv, afl->argv, &afl->stop_soon, afl->afl_env.afl_debug_child); + + if (new_map_size && new_map_size != 4194304) { + + // only reinitialize when it makes sense + if (map_size != new_map_size) { + + // if (map_size < new_map_size || + // (new_map_size > map_size && new_map_size - map_size > + // MAP_SIZE)) { + + OKF("Re-initializing maps to %u bytes", new_map_size); + + afl->virgin_bits = ck_realloc(afl->virgin_bits, map_size); + afl->virgin_tmout = ck_realloc(afl->virgin_tmout, map_size); + afl->virgin_crash = ck_realloc(afl->virgin_crash, map_size); + afl->var_bytes = ck_realloc(afl->var_bytes, map_size); + afl->top_rated = ck_realloc(afl->top_rated, map_size * sizeof(void *)); + afl->clean_trace = ck_realloc(afl->clean_trace, map_size); + afl->clean_trace_custom = ck_realloc(afl->clean_trace_custom, map_size); + afl->first_trace = ck_realloc(afl->first_trace, map_size); + afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, map_size); + + afl_shm_deinit(&afl->shm); + afl_fsrv_kill(&afl->fsrv); + afl->fsrv.map_size = new_map_size; + afl->fsrv.trace_bits = afl_shm_init(&afl->shm, afl->fsrv.map_size, + afl->non_instrumented_mode); + setenv("AFL_NO_AUTODICT", "1", 1); // loaded already + afl_fsrv_start(&afl->fsrv, afl->argv, &afl->stop_soon, + afl->afl_env.afl_debug_child); + + } + + map_size = new_map_size; + + } + + afl->fsrv.map_size = map_size; + + } + + // after we have the correct bitmap size we can read the bitmap -B option + // and set the virgin maps + if (!afl->in_bitmap) { + + memset(afl->virgin_bits, 255, afl->fsrv.map_size); + + } else { + + read_bitmap(afl->in_bitmap, afl->virgin_bits, afl->fsrv.map_size); + + } + + memset(afl->virgin_tmout, 255, afl->fsrv.map_size); + memset(afl->virgin_crash, 255, afl->fsrv.map_size); if (afl->cmplog_binary) { diff --git a/src/afl-sharedmem.c b/src/afl-sharedmem.c index fe641d0d..3241a130 100644 --- a/src/afl-sharedmem.c +++ b/src/afl-sharedmem.c @@ -66,9 +66,17 @@ static list_t shm_list = {.element_prealloc_count = 0}; void afl_shm_deinit(sharedmem_t *shm) { - if (shm == NULL) return; - + if (shm == NULL) { return; } list_remove(&shm_list, shm); + if (shm->shmemfuzz_mode) { + + unsetenv(SHM_FUZZ_ENV_VAR); + + } else { + + unsetenv(SHM_ENV_VAR); + + } #ifdef USEMMAP if (shm->map != NULL) { @@ -94,6 +102,8 @@ void afl_shm_deinit(sharedmem_t *shm) { if (shm->cmplog_mode) { + unsetenv(CMPLOG_SHM_ENV_VAR); + if (shm->cmp_map != NULL) { munmap(shm->cmp_map, shm->map_size); diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 62bf1021..56abe4f1 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -86,7 +86,8 @@ static u8 quiet_mode, /* Hide non-essential messages? */ remove_shm = 1, /* remove shmem? */ collect_coverage, /* collect coverage */ have_coverage, /* have coverage? */ - no_classify; /* do not classify counts */ + no_classify, /* do not classify counts */ + debug; /* debug mode */ static volatile u8 stop_soon, /* Ctrl-C pressed? */ child_crashed; /* Child crashed? */ @@ -743,6 +744,7 @@ int main(int argc, char **argv_orig, char **envp) { char **argv = argv_cpy_dup(argc, argv_orig); afl_forkserver_t fsrv_var = {0}; + if (getenv("AFL_DEBUG")) { debug = 1; } fsrv = &fsrv_var; afl_fsrv_init(fsrv); map_size = get_map_size(); @@ -991,14 +993,16 @@ int main(int argc, char **argv_orig, char **envp) { // if (afl->shmem_testcase_mode) { setup_testcase_shmem(afl); } + setenv("AFL_NO_AUTODICT", "1", 1); + /* initialize cmplog_mode */ shm.cmplog_mode = 0; - fsrv->trace_bits = afl_shm_init(&shm, map_size, 0); setup_signal_handlers(); set_up_environment(fsrv); fsrv->target_path = find_binary(argv[optind]); + fsrv->trace_bits = afl_shm_init(&shm, map_size, 0); if (!quiet_mode) { @@ -1051,6 +1055,7 @@ int main(int argc, char **argv_orig, char **envp) { /* initialize cmplog_mode */ shm_fuzz->cmplog_mode = 0; u8 *map = afl_shm_init(shm_fuzz, MAX_FILE + sizeof(u32), 1); + shm_fuzz->shmemfuzz_mode = 1; if (!map) { FATAL("BUG: Zero return from afl_shm_init."); } #ifdef USEMMAP setenv(SHM_FUZZ_ENV_VAR, shm_fuzz->g_shm_file_path, 1); @@ -1063,6 +1068,38 @@ int main(int argc, char **argv_orig, char **envp) { fsrv->shmem_fuzz_len = (u32 *)map; fsrv->shmem_fuzz = map + sizeof(u32); + u32 save_be_quiet = be_quiet; + be_quiet = debug; + fsrv->map_size = 4194304; // dummy temporary value + u32 new_map_size = afl_fsrv_get_mapsize( + fsrv, use_argv, &stop_soon, + (get_afl_env("AFL_DEBUG_CHILD") || get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) + ? 1 + : 0); + be_quiet = save_be_quiet; + + if (new_map_size) { + + // only reinitialize when it makes sense + if (map_size < new_map_size || + (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { + + if (!be_quiet) + ACTF("Aquired new map size for target: %u bytes\n", new_map_size); + + afl_shm_deinit(&shm); + afl_fsrv_kill(fsrv); + fsrv->map_size = new_map_size; + fsrv->trace_bits = afl_shm_init(&shm, new_map_size, 0); + + } + + map_size = new_map_size; + + } + + fsrv->map_size = map_size; + if (in_dir) { DIR * dir_in, *dir_out = NULL; diff --git a/src/afl-tmin.c b/src/afl-tmin.c index 09b5211d..799a4b87 100644 --- a/src/afl-tmin.c +++ b/src/afl-tmin.c @@ -79,7 +79,8 @@ static u8 crash_mode, /* Crash-centric mode? */ edges_only, /* Ignore hit counts? */ exact_mode, /* Require path match for crashes? */ remove_out_file, /* remove out_file on exit? */ - remove_shm = 1; /* remove shmem on exit? */ + remove_shm = 1, /* remove shmem on exit? */ + debug; /* debug mode */ static volatile u8 stop_soon; /* Ctrl-C pressed? */ @@ -878,6 +879,7 @@ int main(int argc, char **argv_orig, char **envp) { char **argv = argv_cpy_dup(argc, argv_orig); afl_forkserver_t fsrv_var = {0}; + if (getenv("AFL_DEBUG")) { debug = 1; } fsrv = &fsrv_var; afl_fsrv_init(fsrv); map_size = get_map_size(); @@ -1074,6 +1076,7 @@ int main(int argc, char **argv_orig, char **envp) { if (optind == argc || !in_file || !output_file) { usage(argv[0]); } check_environment_vars(envp); + setenv("AFL_NO_AUTODICT", "1", 1); if (fsrv->qemu_mode && getenv("AFL_USE_QASAN")) { @@ -1102,7 +1105,6 @@ int main(int argc, char **argv_orig, char **envp) { /* initialize cmplog_mode */ shm.cmplog_mode = 0; - fsrv->trace_bits = afl_shm_init(&shm, map_size, 0); atexit(at_exit_handler); setup_signal_handlers(); @@ -1110,6 +1112,7 @@ int main(int argc, char **argv_orig, char **envp) { set_up_environment(fsrv); fsrv->target_path = find_binary(argv[optind]); + fsrv->trace_bits = afl_shm_init(&shm, map_size, 0); detect_file_args(argv + optind, out_file, &fsrv->use_stdin); if (fsrv->qemu_mode) { @@ -1181,6 +1184,7 @@ int main(int argc, char **argv_orig, char **envp) { /* initialize cmplog_mode */ shm_fuzz->cmplog_mode = 0; u8 *map = afl_shm_init(shm_fuzz, MAX_FILE + sizeof(u32), 1); + shm_fuzz->shmemfuzz_mode = 1; if (!map) { FATAL("BUG: Zero return from afl_shm_init."); } #ifdef USEMMAP setenv(SHM_FUZZ_ENV_VAR, shm_fuzz->g_shm_file_path, 1); @@ -1195,12 +1199,39 @@ int main(int argc, char **argv_orig, char **envp) { read_initial_file(); - afl_fsrv_start( + fsrv->map_size = 4194304; // dummy temporary value + u32 new_map_size = afl_fsrv_get_mapsize( fsrv, use_argv, &stop_soon, (get_afl_env("AFL_DEBUG_CHILD") || get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) ? 1 : 0); + if (new_map_size) { + + if (map_size < new_map_size || + (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { + + if (!be_quiet) + ACTF("Aquired new map size for target: %u bytes\n", new_map_size); + + afl_shm_deinit(&shm); + afl_fsrv_kill(fsrv); + fsrv->map_size = new_map_size; + fsrv->trace_bits = afl_shm_init(&shm, new_map_size, 0); + afl_fsrv_start(fsrv, use_argv, &stop_soon, + (get_afl_env("AFL_DEBUG_CHILD") || + get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) + ? 1 + : 0); + + } + + map_size = new_map_size; + + } + + fsrv->map_size = map_size; + if (fsrv->support_shmem_fuzz && !fsrv->use_shmem_fuzz) shm_fuzz = deinit_shmem(fsrv, shm_fuzz); diff --git a/test-instr.c b/test-instr.c index 84ac0036..00799103 100644 --- a/test-instr.c +++ b/test-instr.c @@ -32,7 +32,8 @@ int main(int argc, char **argv) { } else { - if (argc >= 3 && strcmp(argv[1], "-f") == 0) + if (argc >= 3 && strcmp(argv[1], "-f") == 0) { + if ((fd = open(argv[2], O_RDONLY)) < 0) { fprintf(stderr, "Error: unable to open %s\n", argv[2]); @@ -40,6 +41,8 @@ int main(int argc, char **argv) { } + } + if (read(fd, buf, sizeof(buf)) < 1) { printf("Hum?\n"); diff --git a/test/test-basic.sh b/test/test-basic.sh index fcac8ca3..132610c0 100755 --- a/test/test-basic.sh +++ b/test/test-basic.sh @@ -11,8 +11,8 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc AFL_HARDEN=1 ../${AFL_GCC} -o test-compcov.harden test-compcov.c > /dev/null 2>&1 test -e test-instr.plain && { $ECHO "$GREEN[+] ${AFL_GCC} compilation succeeded" - echo 0 | ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain > /dev/null 2>&1 - ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain < /dev/null > /dev/null 2>&1 + echo 0 | AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain > /dev/null 2>&1 + AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain < /dev/null > /dev/null 2>&1 test -e test-instr.plain.0 -a -e test-instr.plain.1 && { diff test-instr.plain.0 test-instr.plain.1 > /dev/null 2>&1 && { $ECHO "$RED[!] ${AFL_GCC} instrumentation should be different on different input but is not" @@ -26,7 +26,7 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc } rm -f test-instr.plain.0 test-instr.plain.1 SKIP= - TUPLES=`echo 1|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` + TUPLES=`echo 1|AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` test "$TUPLES" -gt 1 -a "$TUPLES" -lt 12 && { $ECHO "$GREEN[+] ${AFL_GCC} run reported $TUPLES instrumented locations which is fine" } || { @@ -132,8 +132,8 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc AFL_HARDEN=1 ../${AFL_GCC} -o test-compcov.harden test-compcov.c > /dev/null 2>&1 test -e test-instr.plain && { $ECHO "$GREEN[+] ${AFL_GCC} compilation succeeded" - echo 0 | ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain > /dev/null 2>&1 - ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain < /dev/null > /dev/null 2>&1 + echo 0 | AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain > /dev/null 2>&1 + AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain < /dev/null > /dev/null 2>&1 test -e test-instr.plain.0 -a -e test-instr.plain.1 && { diff test-instr.plain.0 test-instr.plain.1 > /dev/null 2>&1 && { $ECHO "$RED[!] ${AFL_GCC} instrumentation should be different on different input but is not" @@ -146,7 +146,7 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc CODE=1 } rm -f test-instr.plain.0 test-instr.plain.1 - TUPLES=`echo 1|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` + TUPLES=`echo 1|AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` test "$TUPLES" -gt 1 -a "$TUPLES" -lt 12 && { $ECHO "$GREEN[+] ${AFL_GCC} run reported $TUPLES instrumented locations which is fine" } || { diff --git a/test/test-gcc-plugin.sh b/test/test-gcc-plugin.sh index cce6336b..4c36b6c9 100755 --- a/test/test-gcc-plugin.sh +++ b/test/test-gcc-plugin.sh @@ -10,15 +10,15 @@ test -e ../afl-gcc-fast -a -e ../afl-compiler-rt.o && { AFL_HARDEN=1 ../afl-gcc-fast -o test-compcov.harden.gccpi test-compcov.c > /dev/null 2>&1 test -e test-instr.plain.gccpi && { $ECHO "$GREEN[+] gcc_plugin compilation succeeded" - echo 0 | ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain.gccpi > /dev/null 2>&1 - ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain.gccpi < /dev/null > /dev/null 2>&1 + echo 0 | AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain.gccpi > /dev/null 2>&1 + AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain.gccpi < /dev/null > /dev/null 2>&1 test -e test-instr.plain.0 -a -e test-instr.plain.1 && { diff test-instr.plain.0 test-instr.plain.1 > /dev/null 2>&1 && { $ECHO "$RED[!] gcc_plugin instrumentation should be different on different input but is not" CODE=1 } || { $ECHO "$GREEN[+] gcc_plugin instrumentation present and working correctly" - TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain.gccpi 2>&1 | grep Captur | awk '{print$3}'` + TUPLES=`echo 0|AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain.gccpi 2>&1 | grep Captur | awk '{print$3}'` test "$TUPLES" -gt 1 -a "$TUPLES" -lt 9 && { $ECHO "$GREEN[+] gcc_plugin run reported $TUPLES instrumented locations which is fine" } || { @@ -87,7 +87,7 @@ test -e ../afl-gcc-fast -a -e ../afl-compiler-rt.o && { echo foobar.c > instrumentlist.txt AFL_GCC_INSTRUMENT_FILE=instrumentlist.txt ../afl-gcc-fast -o test-compcov test-compcov.c > /dev/null 2>&1 test -x test-compcov && test_compcov_binary_functionality ./test-compcov && { - echo 1 | ../afl-showmap -m ${MEM_LIMIT} -o - -r -- ./test-compcov 2>&1 | grep -q "Captured 0 tuples" && { + echo 1 | AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o - -r -- ./test-compcov 2>&1 | grep -q "Captured 0 tuples" && { $ECHO "$GREEN[+] gcc_plugin instrumentlist feature works correctly" } || { $ECHO "$RED[!] gcc_plugin instrumentlist feature failed" @@ -100,7 +100,7 @@ test -e ../afl-gcc-fast -a -e ../afl-compiler-rt.o && { rm -f test-compcov test.out instrumentlist.txt ../afl-gcc-fast -o test-persistent ../utils/persistent_mode/persistent_demo.c > /dev/null 2>&1 test -e test-persistent && { - echo foo | ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -q -r ./test-persistent && { + echo foo | AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -q -r ./test-persistent && { $ECHO "$GREEN[+] gcc_plugin persistent mode feature works correctly" } || { $ECHO "$RED[!] gcc_plugin persistent mode feature failed to work" diff --git a/test/test-llvm-lto.sh b/test/test-llvm-lto.sh index a931afb7..3e762acf 100755 --- a/test/test-llvm-lto.sh +++ b/test/test-llvm-lto.sh @@ -16,15 +16,15 @@ test -e ../afl-clang-lto -a -e ../afl-llvm-lto-instrumentation.so && { ../afl-clang-lto -o test-instr.plain ../test-instr.c > /dev/null 2>&1 test -e test-instr.plain && { $ECHO "$GREEN[+] llvm_mode LTO compilation succeeded" - echo 0 | ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain > /dev/null 2>&1 - ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain < /dev/null > /dev/null 2>&1 + echo 0 | AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain > /dev/null 2>&1 + AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain < /dev/null > /dev/null 2>&1 test -e test-instr.plain.0 -a -e test-instr.plain.1 && { diff -q test-instr.plain.0 test-instr.plain.1 > /dev/null 2>&1 && { $ECHO "$RED[!] llvm_mode LTO instrumentation should be different on different input but is not" CODE=1 } || { $ECHO "$GREEN[+] llvm_mode LTO instrumentation present and working correctly" - TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` + TUPLES=`echo 0|AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` test "$TUPLES" -gt 2 -a "$TUPLES" -lt 7 && { $ECHO "$GREEN[+] llvm_mode LTO run reported $TUPLES instrumented locations which is fine" } || { @@ -59,7 +59,7 @@ test -e ../afl-clang-lto -a -e ../afl-llvm-lto-instrumentation.so && { rm -f test-compcov test.out instrumentlist.txt ../afl-clang-lto -o test-persistent ../utils/persistent_mode/persistent_demo.c > /dev/null 2>&1 test -e test-persistent && { - echo foo | ../afl-showmap -m none -o /dev/null -q -r ./test-persistent && { + echo foo | AFL_QUIET=1 ../afl-showmap -m none -o /dev/null -q -r ./test-persistent && { $ECHO "$GREEN[+] llvm_mode LTO persistent mode feature works correctly" } || { $ECHO "$RED[!] llvm_mode LTO persistent mode feature failed to work" diff --git a/test/test-llvm.sh b/test/test-llvm.sh index c968d5a9..156b8920 100755 --- a/test/test-llvm.sh +++ b/test/test-llvm.sh @@ -16,15 +16,15 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && { AFL_HARDEN=1 ../afl-clang-fast -o test-compcov.harden test-compcov.c > /dev/null 2>&1 test -e test-instr.plain && { $ECHO "$GREEN[+] llvm_mode compilation succeeded" - echo 0 | ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain > /dev/null 2>&1 - ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain < /dev/null > /dev/null 2>&1 + echo 0 | AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.0 -r -- ./test-instr.plain > /dev/null 2>&1 + AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o test-instr.plain.1 -r -- ./test-instr.plain < /dev/null > /dev/null 2>&1 test -e test-instr.plain.0 -a -e test-instr.plain.1 && { diff test-instr.plain.0 test-instr.plain.1 > /dev/null 2>&1 && { $ECHO "$RED[!] llvm_mode instrumentation should be different on different input but is not" CODE=1 } || { $ECHO "$GREEN[+] llvm_mode instrumentation present and working correctly" - TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` + TUPLES=`echo 0|AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.plain 2>&1 | grep Captur | awk '{print$3}'` test "$TUPLES" -gt 2 -a "$TUPLES" -lt 8 && { $ECHO "$GREEN[+] llvm_mode run reported $TUPLES instrumented locations which is fine" } || { @@ -128,7 +128,7 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && { test -e ../libLLVMInsTrim.so && { AFL_LLVM_INSTRUMENT=CFG AFL_LLVM_INSTRIM_LOOPHEAD=1 ../afl-clang-fast -o test-instr.instrim ../test-instr.c > /dev/null 2>test.out test -e test-instr.instrim && { - TUPLES=`echo 0|../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.instrim 2>&1 | grep Captur | awk '{print$3}'` + TUPLES=`echo 0|AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -- ./test-instr.instrim 2>&1 | grep Captur | awk '{print$3}'` test "$TUPLES" -gt 1 -a "$TUPLES" -lt 5 && { $ECHO "$GREEN[+] llvm_mode InsTrim reported $TUPLES instrumented locations which is fine" } || { @@ -216,7 +216,7 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && { rm -rf errors test-cmplog in core.* ../afl-clang-fast -o test-persistent ../utils/persistent_mode/persistent_demo.c > /dev/null 2>&1 test -e test-persistent && { - echo foo | ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -q -r ./test-persistent && { + echo foo | AFL_QUIET=1 ../afl-showmap -m ${MEM_LIMIT} -o /dev/null -q -r ./test-persistent && { $ECHO "$GREEN[+] llvm_mode persistent mode feature works correctly" } || { $ECHO "$RED[!] llvm_mode persistent mode feature failed to work" -- cgit 1.4.1 From 965b854803b67f952406d31353d4cb8ed26eeee6 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 12:05:54 +0100 Subject: correct afl-showmap be_quiet state --- src/afl-showmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 56abe4f1..56091357 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -1069,7 +1069,7 @@ int main(int argc, char **argv_orig, char **envp) { fsrv->shmem_fuzz = map + sizeof(u32); u32 save_be_quiet = be_quiet; - be_quiet = debug; + be_quiet = !debug; fsrv->map_size = 4194304; // dummy temporary value u32 new_map_size = afl_fsrv_get_mapsize( fsrv, use_argv, &stop_soon, -- cgit 1.4.1 From d808a8401e1acbcde3352d86e9e2da3f7bac97e8 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 12:16:55 +0100 Subject: import cmplog opts --- include/afl-fuzz.h | 1 + src/afl-fuzz-one.c | 4 ++-- src/afl-fuzz-redqueen.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 9b27606c..c3a8c2ee 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -647,6 +647,7 @@ typedef struct afl_state { u32 cmplog_prev_timed_out; u32 cmplog_max_filesize; u32 cmplog_lvl; + u32 colorize_success; struct afl_pass_stat *pass_stats; struct cmp_map * orig_cmp_map; diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c index 18291fb7..c73e394a 100644 --- a/src/afl-fuzz-one.c +++ b/src/afl-fuzz-one.c @@ -562,7 +562,7 @@ u8 fuzz_one_original(afl_state_t *afl) { if (afl->cmplog_lvl == 3 || (afl->cmplog_lvl == 2 && afl->queue_cur->tc_ref) || !(afl->fsrv.total_execs % afl->queued_paths) || - get_cur_time() - afl->last_path_time > 15000) { + get_cur_time() - afl->last_path_time > 300000) { if (input_to_state_stage(afl, in_buf, out_buf, len)) { @@ -2990,7 +2990,7 @@ static u8 mopt_common_fuzzing(afl_state_t *afl, MOpt_globals_t MOpt_globals) { if (afl->cmplog_lvl == 3 || (afl->cmplog_lvl == 2 && afl->queue_cur->tc_ref) || !(afl->fsrv.total_execs % afl->queued_paths) || - get_cur_time() - afl->last_path_time > 15000) { + get_cur_time() - afl->last_path_time > 300000) { if (input_to_state_stage(afl, in_buf, out_buf, len)) { diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 74c9db38..997b7528 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -379,8 +379,6 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, } - *taints = taint; - /* temporary: clean ranges */ while (ranges) { @@ -423,6 +421,35 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, #endif + if (taint) { + + if (len / positions == 1 && positions > 16384 && + afl->active_paths / afl->colorize_success > 20) { + +#ifdef _DEBUG + fprintf(stderr, "Colorization unsatisfactory\n"); +#endif + + *taints = NULL; + + struct tainted *t; + while (taint) { + + t = taint->next; + ck_free(taint); + taint = t; + + } + + } else { + + *taints = taint; + ++afl->colorize_success; + + } + + } + afl->stage_finds[STAGE_COLORIZATION] += new_hit_cnt - orig_hit_cnt; afl->stage_cycles[STAGE_COLORIZATION] += afl->stage_cur; ck_free(backup); -- cgit 1.4.1 From 88155d2c3b86aa2b042e57481939cf2a7d3b02f4 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 13:04:39 +0100 Subject: make dominik more happy - no auto map size for qemu+unicorn --- instrumentation/afl-compiler-rt.o.c | 4 +-- src/afl-fuzz.c | 3 +- src/afl-showmap.c | 57 +++++++++++++++++-------------- src/afl-tmin.c | 67 ++++++++++++++++++++++--------------- 4 files changed, 75 insertions(+), 56 deletions(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 433a1d89..060be044 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1169,8 +1169,8 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) { if (getenv("AFL_DEBUG")) { - fprintf(stderr, "Running __sanitizer_cov_trace_pc_guard_init: %p-%p\n", - start, stop); + fprintf(stderr, "Running __sanitizer_cov_trace_pc_guard_init: %p-%p (%lu edges)\n", + start, stop, stop - start); } diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 49733594..edcc14d6 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1536,7 +1536,8 @@ int main(int argc, char **argv_orig, char **envp) { afl->fsrv.trace_bits = afl_shm_init(&afl->shm, afl->fsrv.map_size, afl->non_instrumented_mode); - if (!afl->non_instrumented_mode) { + if (!afl->non_instrumented_mode && !afl->fsrv.qemu_mode && + !afl->unicorn_mode) { afl->fsrv.map_size = 4194304; // dummy temporary value diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 56091357..c424cdf3 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -1068,38 +1068,43 @@ int main(int argc, char **argv_orig, char **envp) { fsrv->shmem_fuzz_len = (u32 *)map; fsrv->shmem_fuzz = map + sizeof(u32); - u32 save_be_quiet = be_quiet; - be_quiet = !debug; - fsrv->map_size = 4194304; // dummy temporary value - u32 new_map_size = afl_fsrv_get_mapsize( - fsrv, use_argv, &stop_soon, - (get_afl_env("AFL_DEBUG_CHILD") || get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) - ? 1 - : 0); - be_quiet = save_be_quiet; - - if (new_map_size) { - - // only reinitialize when it makes sense - if (map_size < new_map_size || - (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { - - if (!be_quiet) - ACTF("Aquired new map size for target: %u bytes\n", new_map_size); - - afl_shm_deinit(&shm); - afl_fsrv_kill(fsrv); - fsrv->map_size = new_map_size; - fsrv->trace_bits = afl_shm_init(&shm, new_map_size, 0); + if (!fsrv->qemu_mode && !unicorn_mode) { + + u32 save_be_quiet = be_quiet; + be_quiet = !debug; + fsrv->map_size = 4194304; // dummy temporary value + u32 new_map_size = + afl_fsrv_get_mapsize(fsrv, use_argv, &stop_soon, + (get_afl_env("AFL_DEBUG_CHILD") || + get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) + ? 1 + : 0); + be_quiet = save_be_quiet; + + if (new_map_size) { + + // only reinitialize when it makes sense + if (map_size < new_map_size || + (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { + + if (!be_quiet) + ACTF("Aquired new map size for target: %u bytes\n", new_map_size); + + afl_shm_deinit(&shm); + afl_fsrv_kill(fsrv); + fsrv->map_size = new_map_size; + fsrv->trace_bits = afl_shm_init(&shm, new_map_size, 0); + + } + + map_size = new_map_size; } - map_size = new_map_size; + fsrv->map_size = map_size; } - fsrv->map_size = map_size; - if (in_dir) { DIR * dir_in, *dir_out = NULL; diff --git a/src/afl-tmin.c b/src/afl-tmin.c index 799a4b87..15336959 100644 --- a/src/afl-tmin.c +++ b/src/afl-tmin.c @@ -1199,38 +1199,51 @@ int main(int argc, char **argv_orig, char **envp) { read_initial_file(); - fsrv->map_size = 4194304; // dummy temporary value - u32 new_map_size = afl_fsrv_get_mapsize( - fsrv, use_argv, &stop_soon, - (get_afl_env("AFL_DEBUG_CHILD") || get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) - ? 1 - : 0); - - if (new_map_size) { - - if (map_size < new_map_size || - (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { - - if (!be_quiet) - ACTF("Aquired new map size for target: %u bytes\n", new_map_size); - - afl_shm_deinit(&shm); - afl_fsrv_kill(fsrv); - fsrv->map_size = new_map_size; - fsrv->trace_bits = afl_shm_init(&shm, new_map_size, 0); - afl_fsrv_start(fsrv, use_argv, &stop_soon, - (get_afl_env("AFL_DEBUG_CHILD") || - get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) - ? 1 - : 0); + if (!fsrv->qemu_mode && !unicorn_mode) { + + fsrv->map_size = 4194304; // dummy temporary value + u32 new_map_size = + afl_fsrv_get_mapsize(fsrv, use_argv, &stop_soon, + (get_afl_env("AFL_DEBUG_CHILD") || + get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) + ? 1 + : 0); + + if (new_map_size) { + + if (map_size < new_map_size || + (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { + + if (!be_quiet) + ACTF("Aquired new map size for target: %u bytes\n", new_map_size); + + afl_shm_deinit(&shm); + afl_fsrv_kill(fsrv); + fsrv->map_size = new_map_size; + fsrv->trace_bits = afl_shm_init(&shm, new_map_size, 0); + afl_fsrv_start(fsrv, use_argv, &stop_soon, + (get_afl_env("AFL_DEBUG_CHILD") || + get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) + ? 1 + : 0); + + } + + map_size = new_map_size; } - map_size = new_map_size; + fsrv->map_size = map_size; - } + } else { - fsrv->map_size = map_size; + afl_fsrv_start(fsrv, use_argv, &stop_soon, + (get_afl_env("AFL_DEBUG_CHILD") || + get_afl_env("AFL_DEBUG_CHILD_OUTPUT")) + ? 1 + : 0); + + } if (fsrv->support_shmem_fuzz && !fsrv->use_shmem_fuzz) shm_fuzz = deinit_shmem(fsrv, shm_fuzz); -- cgit 1.4.1 From fc5f8657967bef708dd423b8f9c3ca48a98724ec Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 14:02:31 +0100 Subject: reorder check --- instrumentation/SanitizerCoveragePCGUARD.so.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/SanitizerCoveragePCGUARD.so.cc b/instrumentation/SanitizerCoveragePCGUARD.so.cc index 5b274770..5d6d6703 100644 --- a/instrumentation/SanitizerCoveragePCGUARD.so.cc +++ b/instrumentation/SanitizerCoveragePCGUARD.so.cc @@ -1005,9 +1005,9 @@ bool ModuleSanitizerCoverage::InjectCoverage(Function & F, if ((callInst = dyn_cast(&IN))) { Function *Callee = callInst->getCalledFunction(); - StringRef FuncName = Callee->getName(); if (!Callee) continue; if (callInst->getCallingConv() != llvm::CallingConv::C) continue; + StringRef FuncName = Callee->getName(); if (FuncName.compare(StringRef("__afl_coverage_interesting"))) continue; uint32_t id = 1 + instr + (uint32_t)AllBlocks.size() + special++; -- cgit 1.4.1 From 374fa8af4788960ef4a0f5462370b68be6e4fc90 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 14:56:22 +0100 Subject: add case when cmplog map neds to be larger --- src/afl-fuzz.c | 85 +++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 22 deletions(-) diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index edcc14d6..b3a27fc6 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1547,11 +1547,8 @@ int main(int argc, char **argv_orig, char **envp) { if (new_map_size && new_map_size != 4194304) { // only reinitialize when it makes sense - if (map_size != new_map_size) { - - // if (map_size < new_map_size || - // (new_map_size > map_size && new_map_size - map_size > - // MAP_SIZE)) { + if (map_size < new_map_size || + (new_map_size > map_size && new_map_size - map_size > MAP_SIZE)) { OKF("Re-initializing maps to %u bytes", new_map_size); @@ -1584,21 +1581,6 @@ int main(int argc, char **argv_orig, char **envp) { } - // after we have the correct bitmap size we can read the bitmap -B option - // and set the virgin maps - if (!afl->in_bitmap) { - - memset(afl->virgin_bits, 255, afl->fsrv.map_size); - - } else { - - read_bitmap(afl->in_bitmap, afl->virgin_bits, afl->fsrv.map_size); - - } - - memset(afl->virgin_tmout, 255, afl->fsrv.map_size); - memset(afl->virgin_crash, 255, afl->fsrv.map_size); - if (afl->cmplog_binary) { ACTF("Spawning cmplog forkserver"); @@ -1608,12 +1590,71 @@ int main(int argc, char **argv_orig, char **envp) { afl->cmplog_fsrv.qemu_mode = afl->fsrv.qemu_mode; afl->cmplog_fsrv.cmplog_binary = afl->cmplog_binary; afl->cmplog_fsrv.init_child_func = cmplog_exec_child; - afl_fsrv_start(&afl->cmplog_fsrv, afl->argv, &afl->stop_soon, - afl->afl_env.afl_debug_child); + + afl->cmplog_fsrv.map_size = 4194304; + + u32 new_map_size = + afl_fsrv_get_mapsize(&afl->cmplog_fsrv, afl->argv, &afl->stop_soon, + afl->afl_env.afl_debug_child); + + if (new_map_size && new_map_size != 4194304) { + + // only reinitialize when it needs to be larger + if (map_size < new_map_size) { + + OKF("Re-initializing maps to %u bytes", new_map_size); + + afl->virgin_bits = ck_realloc(afl->virgin_bits, map_size); + afl->virgin_tmout = ck_realloc(afl->virgin_tmout, map_size); + afl->virgin_crash = ck_realloc(afl->virgin_crash, map_size); + afl->var_bytes = ck_realloc(afl->var_bytes, map_size); + afl->top_rated = ck_realloc(afl->top_rated, map_size * sizeof(void *)); + afl->clean_trace = ck_realloc(afl->clean_trace, map_size); + afl->clean_trace_custom = ck_realloc(afl->clean_trace_custom, map_size); + afl->first_trace = ck_realloc(afl->first_trace, map_size); + afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, map_size); + + afl_shm_deinit(&afl->shm); + afl_fsrv_kill(&afl->fsrv); + afl_fsrv_kill(&afl->cmplog_fsrv); + afl->cmplog_fsrv.map_size = new_map_size; // non-cmplog stays the same + + afl->fsrv.trace_bits = afl_shm_init(&afl->shm, new_map_size, + afl->non_instrumented_mode); + setenv("AFL_NO_AUTODICT", "1", 1); // loaded already + afl_fsrv_start(&afl->fsrv, afl->argv, &afl->stop_soon, + afl->afl_env.afl_debug_child); + + afl_fsrv_start(&afl->cmplog_fsrv, afl->argv, &afl->stop_soon, + afl->afl_env.afl_debug_child); + + map_size = new_map_size; + + } + + } + + afl->cmplog_fsrv.map_size = map_size; + OKF("Cmplog forkserver successfully started"); } + // after we have the correct bitmap size we can read the bitmap -B option + // and set the virgin maps + if (afl->in_bitmap) { + + read_bitmap(afl->in_bitmap, afl->virgin_bits, afl->fsrv.map_size); + + } else { + + memset(afl->virgin_bits, 255, map_size); + + } + + memset(afl->virgin_tmout, 255, map_size); + memset(afl->virgin_crash, 255, map_size); + perform_dry_run(afl); if (afl->q_testcase_max_cache_entries) { -- cgit 1.4.1 From 812cf4c9e0f8eff80b8f46907fc8dfcd9458919f Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 15:21:39 +0100 Subject: reorder --- src/afl-fuzz.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index b3a27fc6..d8ebe097 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1562,10 +1562,10 @@ int main(int argc, char **argv_orig, char **envp) { afl->first_trace = ck_realloc(afl->first_trace, map_size); afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, map_size); - afl_shm_deinit(&afl->shm); afl_fsrv_kill(&afl->fsrv); + afl_shm_deinit(&afl->shm); afl->fsrv.map_size = new_map_size; - afl->fsrv.trace_bits = afl_shm_init(&afl->shm, afl->fsrv.map_size, + afl->fsrv.trace_bits = afl_shm_init(&afl->shm, new_map_size, afl->non_instrumented_mode); setenv("AFL_NO_AUTODICT", "1", 1); // loaded already afl_fsrv_start(&afl->fsrv, afl->argv, &afl->stop_soon, @@ -1602,7 +1602,7 @@ int main(int argc, char **argv_orig, char **envp) { // only reinitialize when it needs to be larger if (map_size < new_map_size) { - OKF("Re-initializing maps to %u bytes", new_map_size); + OKF("Re-initializing maps to %u bytes due cmplog", new_map_size); afl->virgin_bits = ck_realloc(afl->virgin_bits, map_size); afl->virgin_tmout = ck_realloc(afl->virgin_tmout, map_size); @@ -1614,9 +1614,9 @@ int main(int argc, char **argv_orig, char **envp) { afl->first_trace = ck_realloc(afl->first_trace, map_size); afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, map_size); - afl_shm_deinit(&afl->shm); afl_fsrv_kill(&afl->fsrv); afl_fsrv_kill(&afl->cmplog_fsrv); + afl_shm_deinit(&afl->shm); afl->cmplog_fsrv.map_size = new_map_size; // non-cmplog stays the same afl->fsrv.trace_bits = afl_shm_init(&afl->shm, new_map_size, -- cgit 1.4.1 From 32110a04c0101a77a43088b85f1465ba321b2bc4 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 15:51:04 +0100 Subject: fixes --- src/afl-common.c | 2 +- src/afl-fuzz.c | 38 ++++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/afl-common.c b/src/afl-common.c index 235c4c05..1cc7f462 100644 --- a/src/afl-common.c +++ b/src/afl-common.c @@ -981,7 +981,7 @@ u8 *u_stringify_time_diff(u8 *buf, u64 cur_ms, u64 event_ms) { /* Reads the map size from ENV */ u32 get_map_size(void) { - uint32_t map_size = MAP_SIZE; + uint32_t map_size = (MAP_SIZE << 2); // needed for target ctors :( char * ptr; if ((ptr = getenv("AFL_MAP_SIZE")) || (ptr = getenv("AFL_MAPSIZE"))) { diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index d8ebe097..008ba7d1 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1540,6 +1540,7 @@ int main(int argc, char **argv_orig, char **envp) { !afl->unicorn_mode) { afl->fsrv.map_size = 4194304; // dummy temporary value + setenv("AFL_MAP_SIZE", "4194304", 1); u32 new_map_size = afl_fsrv_get_mapsize( &afl->fsrv, afl->argv, &afl->stop_soon, afl->afl_env.afl_debug_child); @@ -1552,15 +1553,15 @@ int main(int argc, char **argv_orig, char **envp) { OKF("Re-initializing maps to %u bytes", new_map_size); - afl->virgin_bits = ck_realloc(afl->virgin_bits, map_size); - afl->virgin_tmout = ck_realloc(afl->virgin_tmout, map_size); - afl->virgin_crash = ck_realloc(afl->virgin_crash, map_size); - afl->var_bytes = ck_realloc(afl->var_bytes, map_size); - afl->top_rated = ck_realloc(afl->top_rated, map_size * sizeof(void *)); - afl->clean_trace = ck_realloc(afl->clean_trace, map_size); - afl->clean_trace_custom = ck_realloc(afl->clean_trace_custom, map_size); - afl->first_trace = ck_realloc(afl->first_trace, map_size); - afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, map_size); + afl->virgin_bits = ck_realloc(afl->virgin_bits, new_map_size); + afl->virgin_tmout = ck_realloc(afl->virgin_tmout, new_map_size); + afl->virgin_crash = ck_realloc(afl->virgin_crash, new_map_size); + afl->var_bytes = ck_realloc(afl->var_bytes, new_map_size); + afl->top_rated = ck_realloc(afl->top_rated, new_map_size * sizeof(void *)); + afl->clean_trace = ck_realloc(afl->clean_trace, new_map_size); + afl->clean_trace_custom = ck_realloc(afl->clean_trace_custom, new_map_size); + afl->first_trace = ck_realloc(afl->first_trace, new_map_size); + afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, new_map_size); afl_fsrv_kill(&afl->fsrv); afl_shm_deinit(&afl->shm); @@ -1596,6 +1597,7 @@ int main(int argc, char **argv_orig, char **envp) { u32 new_map_size = afl_fsrv_get_mapsize(&afl->cmplog_fsrv, afl->argv, &afl->stop_soon, afl->afl_env.afl_debug_child); +printf("NEW MAP SIZE2 %u (is %u)\n", new_map_size, map_size); if (new_map_size && new_map_size != 4194304) { @@ -1604,15 +1606,15 @@ int main(int argc, char **argv_orig, char **envp) { OKF("Re-initializing maps to %u bytes due cmplog", new_map_size); - afl->virgin_bits = ck_realloc(afl->virgin_bits, map_size); - afl->virgin_tmout = ck_realloc(afl->virgin_tmout, map_size); - afl->virgin_crash = ck_realloc(afl->virgin_crash, map_size); - afl->var_bytes = ck_realloc(afl->var_bytes, map_size); - afl->top_rated = ck_realloc(afl->top_rated, map_size * sizeof(void *)); - afl->clean_trace = ck_realloc(afl->clean_trace, map_size); - afl->clean_trace_custom = ck_realloc(afl->clean_trace_custom, map_size); - afl->first_trace = ck_realloc(afl->first_trace, map_size); - afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, map_size); + afl->virgin_bits = ck_realloc(afl->virgin_bits, new_map_size); + afl->virgin_tmout = ck_realloc(afl->virgin_tmout, new_map_size); + afl->virgin_crash = ck_realloc(afl->virgin_crash, new_map_size); + afl->var_bytes = ck_realloc(afl->var_bytes, new_map_size); + afl->top_rated = ck_realloc(afl->top_rated, new_map_size * sizeof(void *)); + afl->clean_trace = ck_realloc(afl->clean_trace, new_map_size); + afl->clean_trace_custom = ck_realloc(afl->clean_trace_custom, new_map_size); + afl->first_trace = ck_realloc(afl->first_trace, new_map_size); + afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, new_map_size); afl_fsrv_kill(&afl->fsrv); afl_fsrv_kill(&afl->cmplog_fsrv); -- cgit 1.4.1 From 05472a0fc5767c90811bd55b927d26b1784c403d Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 16:04:34 +0100 Subject: move cmplog compile options to config.h --- src/afl-fuzz-redqueen.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 997b7528..14a9b65d 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -29,11 +29,9 @@ #include "cmplog.h" //#define _DEBUG -#define COMBINE //#define CMPLOG_INTROSPECTION +#define COMBINE #define ARITHMETIC_LESSER_GREATER -//#define TRANSFORM -//#define TRANSFORM_BASE64 // CMP attribute enum enum { @@ -423,8 +421,8 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, if (taint) { - if (len / positions == 1 && positions > 16384 && - afl->active_paths / afl->colorize_success > 20) { + if (len / positions == 1 && positions > CMPLOG_POSITIONS_MAX && + afl->active_paths / afl->colorize_success > CMPLOG_CORPUS_PERCENT) { #ifdef _DEBUG fprintf(stderr, "Colorization unsatisfactory\n"); @@ -498,7 +496,7 @@ static u8 its_fuzz(afl_state_t *afl, u8 *buf, u32 len, u8 *status) { } -#ifdef TRANSFORM +#ifdef CMPLOG_TRANSFORM static int strntoll(const char *str, size_t sz, char **end, int base, long long *out) { @@ -579,7 +577,7 @@ static int is_hex(const char *str) { } - #ifdef TRANSFORM_BASE64 + #ifdef CMPLOG_TRANSFORM_BASE64 // tests 4 bytes at location static int is_base64(const char *str) { @@ -719,7 +717,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // o_pattern, pattern, repl, changed_val, idx, taint_len, // h->shape + 1, attr); -#ifdef TRANSFORM +#ifdef CMPLOG_TRANSFORM // reverse atoi()/strnu?toll() is expensive, so we only to it in lvl 3 if (lvl & LVL3) { @@ -1783,7 +1781,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, #ifndef COMBINE (void)(cbuf); #endif -#ifndef TRANSFORM +#ifndef CMPLOG_TRANSFORM (void)(changed_val); #endif @@ -1865,14 +1863,14 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } -#ifdef TRANSFORM +#ifdef CMPLOG_TRANSFORM if (*status == 1) return 0; if (lvl & LVL3) { u32 toupper = 0, tolower = 0, xor = 0, arith = 0, tohex = 0, fromhex = 0; - #ifdef TRANSFORM_BASE64 + #ifdef CMPLOG_TRANSFORM_BASE64 u32 tob64 = 0, fromb64 = 0; #endif u32 from_0 = 0, from_x = 0, from_X = 0, from_slash = 0, from_up = 0; @@ -1970,7 +1968,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - #ifdef TRANSFORM_BASE64 + #ifdef CMPLOG_TRANSFORM_BASE64 if (i % 3 == 2 && i < 24) { if (is_base64(repl + ((i / 3) << 2))) tob64 += 3; @@ -2018,13 +2016,13 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, "from_0=%u from_slash=%u from_x=%u\n", idx, i, xor, arith, tolower, toupper, tohex, fromhex, to_0, to_slash, to_x, from_0, from_slash, from_x); - #ifdef TRANSFORM_BASE64 + #ifdef CMPLOG_TRANSFORM_BASE64 fprintf(stderr, "RTN idx=%u loop=%u tob64=%u from64=%u\n", tob64, fromb64); #endif #endif - #ifdef TRANSFORM_BASE64 + #ifdef CMPLOG_TRANSFORM_BASE64 // input is base64 and converted to binary? convert repl to base64! if ((i % 4) == 3 && i < 24 && fromb64 > i) { @@ -2183,7 +2181,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if ((i >= 7 && (i >= xor&&i >= arith &&i >= tolower &&i >= toupper &&i > tohex &&i > (fromhex + from_0 + from_x + from_slash + 1) - #ifdef TRANSFORM_BASE64 + #ifdef CMPLOG_TRANSFORM_BASE64 && i > tob64 + 3 && i > fromb64 + 4 #endif )) || @@ -2518,7 +2516,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } else if ((lvl & LVL1) -#ifdef TRANSFORM +#ifdef CMPLOG_TRANSFORM || (lvl & LVL3) #endif ) { -- cgit 1.4.1 From 4018e7f8e5e45ccef83d740d7bc2514dc4f602f0 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 16:23:40 +0100 Subject: mv cmplog options to config.h --- include/config.h | 28 +++++++++++++++++++++++++++- src/afl-fuzz-redqueen.c | 35 ++++++++++------------------------- src/afl-fuzz.c | 3 +-- 3 files changed, 38 insertions(+), 28 deletions(-) diff --git a/include/config.h b/include/config.h index b5137553..60872785 100644 --- a/include/config.h +++ b/include/config.h @@ -34,6 +34,32 @@ * * ******************************************************/ +/* CMPLOG/REDQUEEN TUNING + * + * Here you can tuning and solving options for cmplog. + * Note that these are run-time options for afl-fuzz, no target + * recompilation required. + * + */ + +/* Enable transform following (XOR/ADD/SUB manipulations, hex en/decoding) */ +// #define CMPLOG_TRANSFORM + +/* if TRANSFORM is enabled, this additionally enables base64 en/decoding */ +// #define CMPLOG_TRANSFORM_BASE64 + +/* Minimum % of the corpus to perform cmplog on. Default: 20% */ +#define CMPLOG_CORPUS_PERCENT 20U + +/* Number of potential posititions from which we decide the cmplog becomes + useless, default 16384 */ +#define CMPLOG_POSITIONS_MAX 16384U + +/* Maximum allowed fails per CMP value. Default: 32 * 3 */ +#define CMPLOG_FAIL_MAX 96 + +/* Now non-cmplog configuration options */ + /* console output colors: There are three ways to configure its behavior * 1. default: colored outputs fixed on: defined USE_COLOR && defined * ALWAYS_COLORED The env var. AFL_NO_COLOR will have no effect @@ -67,7 +93,7 @@ /* If you want to have the original afl internal memory corruption checks. Disabled by default for speed. it is better to use "make ASAN_BUILD=1". */ -//#define _WANT_ORIGINAL_AFL_ALLOC +// #define _WANT_ORIGINAL_AFL_ALLOC /* Comment out to disable fancy ANSI boxes and use poor man's 7-bit UI: */ diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 14a9b65d..8979be98 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -51,7 +51,7 @@ enum { enum { LVL1 = 1, // Integer solving - LVL2 = 2, // FP solving + LVL2 = 2, // unused except for setting the queue entry LVL3 = 4 // expensive tranformations }; @@ -986,11 +986,10 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, #endif - // we only allow this for ascii2integer (above) + // we only allow this for ascii2integer (above) so leave if this is the case if (unlikely(pattern == o_pattern)) { return 0; } - if ((lvl & LVL1) || ((lvl & LVL2) && (attr >= IS_FP && attr < IS_FP_MOD)) || - attr >= IS_FP_MOD) { + if ((lvl & LVL1) || attr >= IS_FP_MOD) { if (SHAPE_BYTES(h->shape) >= 8 && *status != 1) { @@ -1498,9 +1497,6 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, u32 lvl, struct tainted *taint) { struct cmp_header *h = &afl->shm.cmp_map->headers[key]; - // FP handling only from lvl 2 onwards - if ((h->attribute & IS_FP) && lvl < LVL2) { return 0; } - struct tainted *t; u32 i, j, idx, taint_len, loggeds; u32 have_taint = 1, is_n = 0; @@ -2443,21 +2439,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { afl->stage_max = 0; afl->stage_cur = 0; - u32 lvl; - u32 cmplog_done = afl->queue_cur->colorized; - u32 cmplog_lvl = afl->cmplog_lvl; - if (!cmplog_done) { - - lvl = LVL1; - - } else { - - lvl = 0; - - } - - if (cmplog_lvl >= 2 && cmplog_done < 2) { lvl += LVL2; } - if (cmplog_lvl >= 3 && cmplog_done < 3) { lvl += LVL3; } + u32 lvl = (afl->queue_cur->colorized ? 0 : LVL1) + (afl->cmplog_lvl == CMPLOG_LVL_MAX ? LVL3 : 0); #ifdef COMBINE u8 *cbuf = afl_realloc((void **)&afl->in_scratch_buf, len + 128); @@ -2473,8 +2455,8 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { if (!afl->shm.cmp_map->headers[k].hits) { continue; } - if (afl->pass_stats[k].faileds >= 0x69 || - afl->pass_stats[k].total >= 0x69) { + if (afl->pass_stats[k].faileds >= CMPLOG_FAIL_MAX || + afl->pass_stats[k].total >= CMPLOG_FAIL_MAX) { #ifdef _DEBUG fprintf(stderr, "DISABLED %u\n", k); @@ -2542,9 +2524,10 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { exit_its: - afl->queue_cur->colorized = afl->cmplog_lvl; if (afl->cmplog_lvl == CMPLOG_LVL_MAX) { + afl->queue_cur->colorized = CMPLOG_LVL_MAX; + ck_free(afl->queue_cur->cmplog_colorinput); t = taint; while (taint) { @@ -2559,6 +2542,8 @@ exit_its: } else { + afl->queue_cur->colorized = LVL2; + if (!afl->queue_cur->taint) { afl->queue_cur->taint = taint; } if (!afl->queue_cur->cmplog_colorinput) { diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 008ba7d1..62560724 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -123,8 +123,7 @@ static void usage(u8 *argv0, int more_help) { "it.\n" " if using QEMU, just use -c 0.\n" " -l cmplog_level - set the complexity/intensivity of CmpLog.\n" - " Values: 1 (integer+string), 2 (+FP) and 3 " - "(+transform)\n\n" + " Values: 1 (basic), 2 (larger files) and 3 (transform)\n\n" "Fuzzing behavior settings:\n" " -Z - sequential queue selection instead of weighted " -- cgit 1.4.1 From 80fc6166d0aeaf6332a00c369f7bdb872066e1b9 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 16:28:52 +0100 Subject: adjust expand havoc --- src/afl-fuzz.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 62560724..4a23d99d 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1779,6 +1779,7 @@ printf("NEW MAP SIZE2 %u (is %u)\n", new_map_size, map_size); break; case 1: // add MOpt mutator + /* if (afl->limit_time_sig == 0 && !afl->custom_only && !afl->python_only) { @@ -1786,12 +1787,11 @@ printf("NEW MAP SIZE2 %u (is %u)\n", new_map_size, map_size); afl->limit_time_puppet = 0; } - + */ afl->expand_havoc = 2; - if (afl->cmplog_lvl < 2) afl->cmplog_lvl = 2; + if (afl->cmplog_lvl && afl->cmplog_lvl < 2) afl->cmplog_lvl = 2; break; case 2: - // if (!have_p) afl->schedule = EXPLOIT; // increase havoc mutations per fuzz attempt afl->havoc_stack_pow2++; afl->expand_havoc = 3; @@ -1803,11 +1803,11 @@ printf("NEW MAP SIZE2 %u (is %u)\n", new_map_size, map_size); break; case 4: afl->expand_havoc = 5; - if (afl->cmplog_lvl < 3) afl->cmplog_lvl = 3; + if (afl->cmplog_lvl && afl->cmplog_lvl < 3) afl->cmplog_lvl = 3; break; case 5: // if not in sync mode, enable deterministic mode? - if (!afl->sync_id) afl->skip_deterministic = 0; + //if (!afl->sync_id) afl->skip_deterministic = 0; afl->expand_havoc = 6; case 6: // nothing else currently -- cgit 1.4.1 From e954c891a00eac190275417bf40f2eefb56399bb Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Mon, 1 Feb 2021 17:32:45 +0100 Subject: Clarify usage of LD_LIBRARY_PATH in afl_frida This will help not *accidentally* trying to set the variable to the library's binary. --- utils/afl_frida/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/afl_frida/README.md b/utils/afl_frida/README.md index 7743479b..68b62009 100644 --- a/utils/afl_frida/README.md +++ b/utils/afl_frida/README.md @@ -20,7 +20,7 @@ search and edit the `STEP 1`, `STEP 2` and `STEP 3` locations. Example (after modifying afl-frida.c to your needs and compile it): ``` -LD_LIBRARY_PATH=/path/to/the/target/library afl-fuzz -i in -o out -- ./afl-frida +LD_LIBRARY_PATH=/path/to/the/target/library/ afl-fuzz -i in -o out -- ./afl-frida ``` (or even remote via afl-network-proxy). -- cgit 1.4.1 From b9f469e12fde797e301845caa4b0fd44315318bd Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 20:00:29 +0100 Subject: make some really weird targets compile --- src/afl-cc.c | 1 + src/afl-fuzz.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index f513764a..7db3c9a0 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -689,6 +689,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (lto_mode && !strncmp(cur, "-fuse-ld=", 9)) continue; if (lto_mode && !strncmp(cur, "--ld-path=", 10)) continue; if (!strncmp(cur, "-fno-unroll", 11)) continue; + if (strstr(cur, "afl-compiler-rt") || strstr(cur, "afl-llvm-rt")) continue; if (!strcmp(cur, "-Wl,-z,defs") || !strcmp(cur, "-Wl,--no-undefined")) continue; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 4a23d99d..3a7343ae 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1596,7 +1596,6 @@ int main(int argc, char **argv_orig, char **envp) { u32 new_map_size = afl_fsrv_get_mapsize(&afl->cmplog_fsrv, afl->argv, &afl->stop_soon, afl->afl_env.afl_debug_child); -printf("NEW MAP SIZE2 %u (is %u)\n", new_map_size, map_size); if (new_map_size && new_map_size != 4194304) { -- cgit 1.4.1 From 90fdafa1ad167f43fb42cdec2335fa7416cc633c Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 22:59:41 +0100 Subject: fix warnings and an llvm cmplog+lto panic --- instrumentation/afl-compiler-rt.o.c | 72 +++++++++++++---------------- instrumentation/cmplog-instructions-pass.cc | 8 +++- src/afl-fuzz-redqueen.c | 13 +++--- src/afl-fuzz.c | 26 +++++++---- src/afl-ld-lto.c | 14 +++--- 5 files changed, 70 insertions(+), 63 deletions(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 060be044..c24173af 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1169,7 +1169,8 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) { if (getenv("AFL_DEBUG")) { - fprintf(stderr, "Running __sanitizer_cov_trace_pc_guard_init: %p-%p (%lu edges)\n", + fprintf(stderr, + "Running __sanitizer_cov_trace_pc_guard_init: %p-%p (%lu edges)\n", start, stop, stop - start); } @@ -1448,45 +1449,38 @@ void __cmplog_ins_hook16(uint128_t arg1, uint128_t arg2, uint8_t attr) { #endif -#if defined(__APPLE__) - #pragma weak __sanitizer_cov_trace_const_cmp1 = __cmplog_ins_hook1 - #pragma weak __sanitizer_cov_trace_const_cmp2 = __cmplog_ins_hook2 - #pragma weak __sanitizer_cov_trace_const_cmp4 = __cmplog_ins_hook4 - #pragma weak __sanitizer_cov_trace_const_cmp8 = __cmplog_ins_hook8 - #pragma weak __sanitizer_cov_trace_const_cmp16 = __cmplog_ins_hook16 - - #pragma weak __sanitizer_cov_trace_cmp1 = __cmplog_ins_hook1 - #pragma weak __sanitizer_cov_trace_cmp2 = __cmplog_ins_hook2 - #pragma weak __sanitizer_cov_trace_cmp4 = __cmplog_ins_hook4 - #pragma weak __sanitizer_cov_trace_cmp8 = __cmplog_ins_hook8 - #pragma weak __sanitizer_cov_trace_cmp16 = __cmplog_ins_hook16 -#else -void __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2) - __attribute__((alias("__cmplog_ins_hook1"))); -void __sanitizer_cov_trace_const_cmp2(uint16_t arg1, uint16_t arg2) - __attribute__((alias("__cmplog_ins_hook2"))); -void __sanitizer_cov_trace_const_cmp4(uint32_t arg1, uint32_t arg2) - __attribute__((alias("__cmplog_ins_hook4"))); -void __sanitizer_cov_trace_const_cmp8(uint64_t arg1, uint64_t arg2) - __attribute__((alias("__cmplog_ins_hook8"))); - #ifdef WORD_SIZE_64 -void __sanitizer_cov_trace_const_cmp16(uint128_t arg1, uint128_t arg2) - __attribute__((alias("__cmplog_ins_hook16"))); - #endif +void __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) { -void __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) - __attribute__((alias("__cmplog_ins_hook1"))); -void __sanitizer_cov_trace_cmp2(uint16_t arg1, uint16_t arg2) - __attribute__((alias("__cmplog_ins_hook2"))); -void __sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2) - __attribute__((alias("__cmplog_ins_hook4"))); -void __sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2) - __attribute__((alias("__cmplog_ins_hook8"))); - #ifdef WORD_SIZE_64 -void __sanitizer_cov_trace_cmp16(uint128_t arg1, uint128_t arg2) - __attribute__((alias("__cmplog_ins_hook16"))); - #endif -#endif /* defined(__APPLE__) */ + __cmplog_ins_hook1(arg1, arg2, 0); + +} + +void __sanitizer_cov_trace_cmp2(uint16_t arg1, uint16_t arg2) { + + __cmplog_ins_hook2(arg1, arg2, 0); + +} + +void __sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2) { + + __cmplog_ins_hook4(arg1, arg2, 0); + +} + +void __sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2) { + + __cmplog_ins_hook8(arg1, arg2, 0); + +} + +#ifdef WORD_SIZE_64 +void __sanitizer_cov_trace_cmp16(uint128_t arg1, uint128_t arg2) { + + __cmplog_ins_hook16(arg1, arg2, 0); + +} + +#endif void __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) { diff --git a/instrumentation/cmplog-instructions-pass.cc b/instrumentation/cmplog-instructions-pass.cc index 6ce1832f..d4bc0b38 100644 --- a/instrumentation/cmplog-instructions-pass.cc +++ b/instrumentation/cmplog-instructions-pass.cc @@ -277,8 +277,12 @@ bool CmpLogInstructions::hookInstrs(Module &M) { if (max_size % 8) { - max_size = (((max_size / 8) + 1) * 8); - do_cast = 1; + // bitcast from i6 to i8 panics llvm, so ... + continue; + /* + max_size = (((max_size / 8) + 1) * 8); + do_cast = 1; + */ } diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 8979be98..f619a6d3 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -1497,10 +1497,10 @@ static u8 cmp_fuzz(afl_state_t *afl, u32 key, u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, u32 lvl, struct tainted *taint) { struct cmp_header *h = &afl->shm.cmp_map->headers[key]; - struct tainted *t; - u32 i, j, idx, taint_len, loggeds; - u32 have_taint = 1, is_n = 0; - u8 status = 0, found_one = 0; + struct tainted * t; + u32 i, j, idx, taint_len, loggeds; + u32 have_taint = 1, is_n = 0; + u8 status = 0, found_one = 0; /* loop cmps are useless, detect and ignore them */ #ifdef WORD_SIZE_64 @@ -2439,7 +2439,8 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { afl->stage_max = 0; afl->stage_cur = 0; - u32 lvl = (afl->queue_cur->colorized ? 0 : LVL1) + (afl->cmplog_lvl == CMPLOG_LVL_MAX ? LVL3 : 0); + u32 lvl = (afl->queue_cur->colorized ? 0 : LVL1) + + (afl->cmplog_lvl == CMPLOG_LVL_MAX ? LVL3 : 0); #ifdef COMBINE u8 *cbuf = afl_realloc((void **)&afl->in_scratch_buf, len + 128); @@ -2527,7 +2528,7 @@ exit_its: if (afl->cmplog_lvl == CMPLOG_LVL_MAX) { afl->queue_cur->colorized = CMPLOG_LVL_MAX; - + ck_free(afl->queue_cur->cmplog_colorinput); t = taint; while (taint) { diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 3a7343ae..a579a8f5 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -123,7 +123,8 @@ static void usage(u8 *argv0, int more_help) { "it.\n" " if using QEMU, just use -c 0.\n" " -l cmplog_level - set the complexity/intensivity of CmpLog.\n" - " Values: 1 (basic), 2 (larger files) and 3 (transform)\n\n" + " Values: 1 (basic), 2 (larger files) and 3 " + "(transform)\n\n" "Fuzzing behavior settings:\n" " -Z - sequential queue selection instead of weighted " @@ -1556,17 +1557,19 @@ int main(int argc, char **argv_orig, char **envp) { afl->virgin_tmout = ck_realloc(afl->virgin_tmout, new_map_size); afl->virgin_crash = ck_realloc(afl->virgin_crash, new_map_size); afl->var_bytes = ck_realloc(afl->var_bytes, new_map_size); - afl->top_rated = ck_realloc(afl->top_rated, new_map_size * sizeof(void *)); + afl->top_rated = + ck_realloc(afl->top_rated, new_map_size * sizeof(void *)); afl->clean_trace = ck_realloc(afl->clean_trace, new_map_size); - afl->clean_trace_custom = ck_realloc(afl->clean_trace_custom, new_map_size); + afl->clean_trace_custom = + ck_realloc(afl->clean_trace_custom, new_map_size); afl->first_trace = ck_realloc(afl->first_trace, new_map_size); afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, new_map_size); afl_fsrv_kill(&afl->fsrv); afl_shm_deinit(&afl->shm); afl->fsrv.map_size = new_map_size; - afl->fsrv.trace_bits = afl_shm_init(&afl->shm, new_map_size, - afl->non_instrumented_mode); + afl->fsrv.trace_bits = + afl_shm_init(&afl->shm, new_map_size, afl->non_instrumented_mode); setenv("AFL_NO_AUTODICT", "1", 1); // loaded already afl_fsrv_start(&afl->fsrv, afl->argv, &afl->stop_soon, afl->afl_env.afl_debug_child); @@ -1608,9 +1611,11 @@ int main(int argc, char **argv_orig, char **envp) { afl->virgin_tmout = ck_realloc(afl->virgin_tmout, new_map_size); afl->virgin_crash = ck_realloc(afl->virgin_crash, new_map_size); afl->var_bytes = ck_realloc(afl->var_bytes, new_map_size); - afl->top_rated = ck_realloc(afl->top_rated, new_map_size * sizeof(void *)); + afl->top_rated = + ck_realloc(afl->top_rated, new_map_size * sizeof(void *)); afl->clean_trace = ck_realloc(afl->clean_trace, new_map_size); - afl->clean_trace_custom = ck_realloc(afl->clean_trace_custom, new_map_size); + afl->clean_trace_custom = + ck_realloc(afl->clean_trace_custom, new_map_size); afl->first_trace = ck_realloc(afl->first_trace, new_map_size); afl->map_tmp_buf = ck_realloc(afl->map_tmp_buf, new_map_size); @@ -1619,8 +1624,8 @@ int main(int argc, char **argv_orig, char **envp) { afl_shm_deinit(&afl->shm); afl->cmplog_fsrv.map_size = new_map_size; // non-cmplog stays the same - afl->fsrv.trace_bits = afl_shm_init(&afl->shm, new_map_size, - afl->non_instrumented_mode); + afl->fsrv.trace_bits = + afl_shm_init(&afl->shm, new_map_size, afl->non_instrumented_mode); setenv("AFL_NO_AUTODICT", "1", 1); // loaded already afl_fsrv_start(&afl->fsrv, afl->argv, &afl->stop_soon, afl->afl_env.afl_debug_child); @@ -1786,6 +1791,7 @@ int main(int argc, char **argv_orig, char **envp) { afl->limit_time_puppet = 0; } + */ afl->expand_havoc = 2; if (afl->cmplog_lvl && afl->cmplog_lvl < 2) afl->cmplog_lvl = 2; @@ -1806,7 +1812,7 @@ int main(int argc, char **argv_orig, char **envp) { break; case 5: // if not in sync mode, enable deterministic mode? - //if (!afl->sync_id) afl->skip_deterministic = 0; + // if (!afl->sync_id) afl->skip_deterministic = 0; afl->expand_havoc = 6; case 6: // nothing else currently diff --git a/src/afl-ld-lto.c b/src/afl-ld-lto.c index 1fb01600..0a978653 100644 --- a/src/afl-ld-lto.c +++ b/src/afl-ld-lto.c @@ -83,7 +83,7 @@ static void edit_params(int argc, char **argv) { if (!passthrough) { - for (i = 1; i < argc; i++) { + for (i = 1; i < (u32)argc; i++) { if (strstr(argv[i], "/afl-llvm-rt-lto.o") != NULL) rt_lto_present = 1; if (strstr(argv[i], "/afl-llvm-rt.o") != NULL) rt_present = 1; @@ -91,7 +91,7 @@ static void edit_params(int argc, char **argv) { } - for (i = 1; i < argc && !gold_pos; i++) { + for (i = 1; i < (u32)argc && !gold_pos; i++) { if (strcmp(argv[i], "-plugin") == 0) { @@ -100,7 +100,9 @@ static void edit_params(int argc, char **argv) { if (strcasestr(argv[i], "LLVMgold.so") != NULL) gold_present = gold_pos = i + 1; - } else if (i < argc && strcasestr(argv[i + 1], "LLVMgold.so") != NULL) { + } else if (i < (u32)argc && + + strcasestr(argv[i + 1], "LLVMgold.so") != NULL) { gold_present = gold_pos = i + 2; @@ -112,7 +114,7 @@ static void edit_params(int argc, char **argv) { if (!gold_pos) { - for (i = 1; i + 1 < argc && !gold_pos; i++) { + for (i = 1; i + 1 < (u32)argc && !gold_pos; i++) { if (argv[i][0] != '-') { @@ -198,7 +200,7 @@ static void edit_params(int argc, char **argv) { gold_present ? "true" : "false", inst_present ? "true" : "false", rt_present ? "true" : "false", rt_lto_present ? "true" : "false"); - for (i = 1; i < argc; i++) { + for (i = 1; i < (u32)argc; i++) { if (ld_param_cnt >= MAX_PARAM_COUNT) FATAL( @@ -324,7 +326,7 @@ int main(int argc, char **argv) { if (debug) { DEBUGF("cd \"%s\";", thecwd); - for (i = 0; i < ld_param_cnt; i++) + for (i = 0; i < (s32)ld_param_cnt; i++) SAYF(" \"%s\"", ld_params[i]); SAYF("\n"); -- cgit 1.4.1 From cd95ee67bc38c0f4cc955bbaaa63a246b3a5c2d8 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 23:00:45 +0100 Subject: code format qasan --- qemu_mode/libqasan/dlmalloc.c | 4761 +++++++++++++++++++++++++---------------- qemu_mode/libqasan/hooks.c | 1 + qemu_mode/libqasan/libqasan.h | 95 +- qemu_mode/libqasan/malloc.c | 91 +- qemu_mode/libqasan/patch.c | 46 +- qemu_mode/libqasan/string.c | 98 +- 6 files changed, 3032 insertions(+), 2060 deletions(-) diff --git a/qemu_mode/libqasan/dlmalloc.c b/qemu_mode/libqasan/dlmalloc.c index 0cdd4a90..39ca4301 100644 --- a/qemu_mode/libqasan/dlmalloc.c +++ b/qemu_mode/libqasan/dlmalloc.c @@ -203,9 +203,12 @@ mspaces as thread-locals. For example: static __thread mspace tlms = 0; void* tlmalloc(size_t bytes) { + if (tlms == 0) tlms = create_mspace(0, 0); return mspace_malloc(tlms, bytes); + } + void tlfree(void* mem) { mspace_free(tlms, mem); } Unless FOOTERS is defined, each mspace is completely independent. @@ -525,197 +528,198 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP /* Version identifier to allow people to support multiple versions */ #ifndef DLMALLOC_VERSION -#define DLMALLOC_VERSION 20806 -#endif /* DLMALLOC_VERSION */ + #define DLMALLOC_VERSION 20806 +#endif /* DLMALLOC_VERSION */ #ifndef DLMALLOC_EXPORT -#define DLMALLOC_EXPORT extern + #define DLMALLOC_EXPORT extern #endif #ifndef WIN32 -#ifdef _WIN32 -#define WIN32 1 -#endif /* _WIN32 */ -#ifdef _WIN32_WCE -#define LACKS_FCNTL_H -#define WIN32 1 -#endif /* _WIN32_WCE */ -#endif /* WIN32 */ + #ifdef _WIN32 + #define WIN32 1 + #endif /* _WIN32 */ + #ifdef _WIN32_WCE + #define LACKS_FCNTL_H + #define WIN32 1 + #endif /* _WIN32_WCE */ +#endif /* WIN32 */ #ifdef WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#include -#define HAVE_MMAP 1 -#define HAVE_MORECORE 0 -#define LACKS_UNISTD_H -#define LACKS_SYS_PARAM_H -#define LACKS_SYS_MMAN_H -#define LACKS_STRING_H -#define LACKS_STRINGS_H -#define LACKS_SYS_TYPES_H -#define LACKS_ERRNO_H -#define LACKS_SCHED_H -#ifndef MALLOC_FAILURE_ACTION -#define MALLOC_FAILURE_ACTION -#endif /* MALLOC_FAILURE_ACTION */ -#ifndef MMAP_CLEARS -#ifdef _WIN32_WCE /* WINCE reportedly does not clear */ -#define MMAP_CLEARS 0 -#else -#define MMAP_CLEARS 1 -#endif /* _WIN32_WCE */ -#endif /*MMAP_CLEARS */ -#endif /* WIN32 */ + #define WIN32_LEAN_AND_MEAN + #include + #include + #define HAVE_MMAP 1 + #define HAVE_MORECORE 0 + #define LACKS_UNISTD_H + #define LACKS_SYS_PARAM_H + #define LACKS_SYS_MMAN_H + #define LACKS_STRING_H + #define LACKS_STRINGS_H + #define LACKS_SYS_TYPES_H + #define LACKS_ERRNO_H + #define LACKS_SCHED_H + #ifndef MALLOC_FAILURE_ACTION + #define MALLOC_FAILURE_ACTION + #endif /* MALLOC_FAILURE_ACTION */ + #ifndef MMAP_CLEARS + #ifdef _WIN32_WCE /* WINCE reportedly does not clear */ + #define MMAP_CLEARS 0 + #else + #define MMAP_CLEARS 1 + #endif /* _WIN32_WCE */ + #endif /*MMAP_CLEARS */ +#endif /* WIN32 */ #if defined(DARWIN) || defined(_DARWIN) -/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ -#ifndef HAVE_MORECORE -#define HAVE_MORECORE 0 -#define HAVE_MMAP 1 -/* OSX allocators provide 16 byte alignment */ -#ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT ((size_t)16U) -#endif -#endif /* HAVE_MORECORE */ -#endif /* DARWIN */ + /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ + #ifndef HAVE_MORECORE + #define HAVE_MORECORE 0 + #define HAVE_MMAP 1 + /* OSX allocators provide 16 byte alignment */ + #ifndef MALLOC_ALIGNMENT + #define MALLOC_ALIGNMENT ((size_t)16U) + #endif + #endif /* HAVE_MORECORE */ +#endif /* DARWIN */ #ifndef LACKS_SYS_TYPES_H -#include /* For size_t */ -#endif /* LACKS_SYS_TYPES_H */ + #include /* For size_t */ +#endif /* LACKS_SYS_TYPES_H */ /* The maximum possible size_t value has all bits set */ -#define MAX_SIZE_T (~(size_t)0) - -#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ -#define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ - (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) -#endif /* USE_LOCKS */ - -#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ -#if ((defined(__GNUC__) && \ - ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ - defined(__i386__) || defined(__x86_64__))) || \ - (defined(_MSC_VER) && _MSC_VER>=1310)) -#ifndef USE_SPIN_LOCKS -#define USE_SPIN_LOCKS 1 -#endif /* USE_SPIN_LOCKS */ -#elif USE_SPIN_LOCKS -#error "USE_SPIN_LOCKS defined without implementation" -#endif /* ... locks available... */ +#define MAX_SIZE_T (~(size_t)0) + +#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ + #define USE_LOCKS \ + ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ + (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) +#endif /* USE_LOCKS */ + +#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ + #if ((defined(__GNUC__) && \ + ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ + defined(__i386__) || defined(__x86_64__))) || \ + (defined(_MSC_VER) && _MSC_VER >= 1310)) + #ifndef USE_SPIN_LOCKS + #define USE_SPIN_LOCKS 1 + #endif /* USE_SPIN_LOCKS */ + #elif USE_SPIN_LOCKS + #error "USE_SPIN_LOCKS defined without implementation" + #endif /* ... locks available... */ #elif !defined(USE_SPIN_LOCKS) -#define USE_SPIN_LOCKS 0 -#endif /* USE_LOCKS */ + #define USE_SPIN_LOCKS 0 +#endif /* USE_LOCKS */ #ifndef ONLY_MSPACES -#define ONLY_MSPACES 0 -#endif /* ONLY_MSPACES */ + #define ONLY_MSPACES 0 +#endif /* ONLY_MSPACES */ #ifndef MSPACES -#if ONLY_MSPACES -#define MSPACES 1 -#else /* ONLY_MSPACES */ -#define MSPACES 0 -#endif /* ONLY_MSPACES */ -#endif /* MSPACES */ + #if ONLY_MSPACES + #define MSPACES 1 + #else /* ONLY_MSPACES */ + #define MSPACES 0 + #endif /* ONLY_MSPACES */ +#endif /* MSPACES */ #ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) -#endif /* MALLOC_ALIGNMENT */ + #define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) +#endif /* MALLOC_ALIGNMENT */ #ifndef FOOTERS -#define FOOTERS 0 -#endif /* FOOTERS */ + #define FOOTERS 0 +#endif /* FOOTERS */ #ifndef ABORT -#define ABORT abort() -#endif /* ABORT */ + #define ABORT abort() +#endif /* ABORT */ #ifndef ABORT_ON_ASSERT_FAILURE -#define ABORT_ON_ASSERT_FAILURE 1 -#endif /* ABORT_ON_ASSERT_FAILURE */ + #define ABORT_ON_ASSERT_FAILURE 1 +#endif /* ABORT_ON_ASSERT_FAILURE */ #ifndef PROCEED_ON_ERROR -#define PROCEED_ON_ERROR 0 -#endif /* PROCEED_ON_ERROR */ + #define PROCEED_ON_ERROR 0 +#endif /* PROCEED_ON_ERROR */ #ifndef INSECURE -#define INSECURE 0 -#endif /* INSECURE */ + #define INSECURE 0 +#endif /* INSECURE */ #ifndef MALLOC_INSPECT_ALL -#define MALLOC_INSPECT_ALL 0 -#endif /* MALLOC_INSPECT_ALL */ + #define MALLOC_INSPECT_ALL 0 +#endif /* MALLOC_INSPECT_ALL */ #ifndef HAVE_MMAP -#define HAVE_MMAP 1 -#endif /* HAVE_MMAP */ + #define HAVE_MMAP 1 +#endif /* HAVE_MMAP */ #ifndef MMAP_CLEARS -#define MMAP_CLEARS 1 -#endif /* MMAP_CLEARS */ + #define MMAP_CLEARS 1 +#endif /* MMAP_CLEARS */ #ifndef HAVE_MREMAP -#ifdef linux -#define HAVE_MREMAP 1 -#define _GNU_SOURCE /* Turns on mremap() definition */ -#else /* linux */ -#define HAVE_MREMAP 0 -#endif /* linux */ -#endif /* HAVE_MREMAP */ + #ifdef linux + #define HAVE_MREMAP 1 + #define _GNU_SOURCE /* Turns on mremap() definition */ + #else /* linux */ + #define HAVE_MREMAP 0 + #endif /* linux */ +#endif /* HAVE_MREMAP */ #ifndef MALLOC_FAILURE_ACTION -#define MALLOC_FAILURE_ACTION errno = ENOMEM; -#endif /* MALLOC_FAILURE_ACTION */ + #define MALLOC_FAILURE_ACTION errno = ENOMEM; +#endif /* MALLOC_FAILURE_ACTION */ #ifndef HAVE_MORECORE -#if ONLY_MSPACES -#define HAVE_MORECORE 0 -#else /* ONLY_MSPACES */ -#define HAVE_MORECORE 1 -#endif /* ONLY_MSPACES */ -#endif /* HAVE_MORECORE */ + #if ONLY_MSPACES + #define HAVE_MORECORE 0 + #else /* ONLY_MSPACES */ + #define HAVE_MORECORE 1 + #endif /* ONLY_MSPACES */ +#endif /* HAVE_MORECORE */ #if !HAVE_MORECORE -#define MORECORE_CONTIGUOUS 0 -#else /* !HAVE_MORECORE */ -#define MORECORE_DEFAULT sbrk -#ifndef MORECORE_CONTIGUOUS -#define MORECORE_CONTIGUOUS 1 -#endif /* MORECORE_CONTIGUOUS */ -#endif /* HAVE_MORECORE */ + #define MORECORE_CONTIGUOUS 0 +#else /* !HAVE_MORECORE */ + #define MORECORE_DEFAULT sbrk + #ifndef MORECORE_CONTIGUOUS + #define MORECORE_CONTIGUOUS 1 + #endif /* MORECORE_CONTIGUOUS */ +#endif /* HAVE_MORECORE */ #ifndef DEFAULT_GRANULARITY -#if (MORECORE_CONTIGUOUS || defined(WIN32)) -#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ -#else /* MORECORE_CONTIGUOUS */ -#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) -#endif /* MORECORE_CONTIGUOUS */ -#endif /* DEFAULT_GRANULARITY */ + #if (MORECORE_CONTIGUOUS || defined(WIN32)) + #define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ + #else /* MORECORE_CONTIGUOUS */ + #define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) + #endif /* MORECORE_CONTIGUOUS */ +#endif /* DEFAULT_GRANULARITY */ #ifndef DEFAULT_TRIM_THRESHOLD -#ifndef MORECORE_CANNOT_TRIM -#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) -#else /* MORECORE_CANNOT_TRIM */ -#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T -#endif /* MORECORE_CANNOT_TRIM */ -#endif /* DEFAULT_TRIM_THRESHOLD */ + #ifndef MORECORE_CANNOT_TRIM + #define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) + #else /* MORECORE_CANNOT_TRIM */ + #define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T + #endif /* MORECORE_CANNOT_TRIM */ +#endif /* DEFAULT_TRIM_THRESHOLD */ #ifndef DEFAULT_MMAP_THRESHOLD -#if HAVE_MMAP -#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) -#else /* HAVE_MMAP */ -#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T -#endif /* HAVE_MMAP */ -#endif /* DEFAULT_MMAP_THRESHOLD */ + #if HAVE_MMAP + #define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) + #else /* HAVE_MMAP */ + #define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T + #endif /* HAVE_MMAP */ +#endif /* DEFAULT_MMAP_THRESHOLD */ #ifndef MAX_RELEASE_CHECK_RATE -#if HAVE_MMAP -#define MAX_RELEASE_CHECK_RATE 4095 -#else -#define MAX_RELEASE_CHECK_RATE MAX_SIZE_T -#endif /* HAVE_MMAP */ -#endif /* MAX_RELEASE_CHECK_RATE */ + #if HAVE_MMAP + #define MAX_RELEASE_CHECK_RATE 4095 + #else + #define MAX_RELEASE_CHECK_RATE MAX_SIZE_T + #endif /* HAVE_MMAP */ +#endif /* MAX_RELEASE_CHECK_RATE */ #ifndef USE_BUILTIN_FFS -#define USE_BUILTIN_FFS 0 -#endif /* USE_BUILTIN_FFS */ + #define USE_BUILTIN_FFS 0 +#endif /* USE_BUILTIN_FFS */ #ifndef USE_DEV_RANDOM -#define USE_DEV_RANDOM 0 -#endif /* USE_DEV_RANDOM */ + #define USE_DEV_RANDOM 0 +#endif /* USE_DEV_RANDOM */ #ifndef NO_MALLINFO -#define NO_MALLINFO 0 -#endif /* NO_MALLINFO */ + #define NO_MALLINFO 0 +#endif /* NO_MALLINFO */ #ifndef MALLINFO_FIELD_TYPE -#define MALLINFO_FIELD_TYPE size_t -#endif /* MALLINFO_FIELD_TYPE */ + #define MALLINFO_FIELD_TYPE size_t +#endif /* MALLINFO_FIELD_TYPE */ #ifndef NO_MALLOC_STATS -#define NO_MALLOC_STATS 0 -#endif /* NO_MALLOC_STATS */ + #define NO_MALLOC_STATS 0 +#endif /* NO_MALLOC_STATS */ #ifndef NO_SEGMENT_TRAVERSAL -#define NO_SEGMENT_TRAVERSAL 0 -#endif /* NO_SEGMENT_TRAVERSAL */ + #define NO_SEGMENT_TRAVERSAL 0 +#endif /* NO_SEGMENT_TRAVERSAL */ /* mallopt tuning options. SVID/XPG defines four standard parameter @@ -727,9 +731,9 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP #undef M_TRIM_THRESHOLD #undef M_GRANULARITY #undef M_MMAP_THRESHOLD -#define M_TRIM_THRESHOLD (-1) -#define M_GRANULARITY (-2) -#define M_MMAP_THRESHOLD (-3) +#define M_TRIM_THRESHOLD (-1) +#define M_GRANULARITY (-2) +#define M_MMAP_THRESHOLD (-3) /* ------------------------ Mallinfo declarations ------------------------ */ @@ -758,28 +762,32 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP /* #define HAVE_USR_INCLUDE_MALLOC_H */ -#ifdef HAVE_USR_INCLUDE_MALLOC_H -#include "/usr/include/malloc.h" -#else /* HAVE_USR_INCLUDE_MALLOC_H */ -#ifndef STRUCT_MALLINFO_DECLARED -/* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */ -#define _STRUCT_MALLINFO -#define STRUCT_MALLINFO_DECLARED 1 + #ifdef HAVE_USR_INCLUDE_MALLOC_H + #include "/usr/include/malloc.h" + #else /* HAVE_USR_INCLUDE_MALLOC_H */ + #ifndef STRUCT_MALLINFO_DECLARED + /* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is + * defined */ + #define _STRUCT_MALLINFO + #define STRUCT_MALLINFO_DECLARED 1 struct mallinfo { - MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ - MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ - MALLINFO_FIELD_TYPE smblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ - MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ - MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ - MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ - MALLINFO_FIELD_TYPE fordblks; /* total free space */ - MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ + + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ + }; -#endif /* STRUCT_MALLINFO_DECLARED */ -#endif /* HAVE_USR_INCLUDE_MALLOC_H */ -#endif /* NO_MALLINFO */ + + #endif /* STRUCT_MALLINFO_DECLARED */ + #endif /* HAVE_USR_INCLUDE_MALLOC_H */ +#endif /* NO_MALLINFO */ /* Try to persuade compilers to inline. The most critical functions for @@ -788,14 +796,14 @@ struct mallinfo { #ifndef FORCEINLINE #if defined(__GNUC__) -#define FORCEINLINE __inline __attribute__ ((always_inline)) + #define FORCEINLINE __inline __attribute__((always_inline)) #elif defined(_MSC_VER) #define FORCEINLINE __forceinline #endif #endif #ifndef NOINLINE #if defined(__GNUC__) - #define NOINLINE __attribute__ ((noinline)) + #define NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) #define NOINLINE __declspec(noinline) #else @@ -805,42 +813,43 @@ struct mallinfo { #ifdef __cplusplus extern "C" { + + #ifndef FORCEINLINE + #define FORCEINLINE inline + #endif +#endif /* __cplusplus */ #ifndef FORCEINLINE - #define FORCEINLINE inline -#endif -#endif /* __cplusplus */ -#ifndef FORCEINLINE - #define FORCEINLINE + #define FORCEINLINE #endif #if !ONLY_MSPACES /* ------------------- Declarations of public routines ------------------- */ -#ifndef USE_DL_PREFIX -#define dlcalloc calloc -#define dlfree free -#define dlmalloc malloc -#define dlmemalign memalign -#define dlposix_memalign posix_memalign -#define dlrealloc realloc -#define dlrealloc_in_place realloc_in_place -#define dlvalloc valloc -#define dlpvalloc pvalloc -#define dlmallinfo mallinfo -#define dlmallopt mallopt -#define dlmalloc_trim malloc_trim -#define dlmalloc_stats malloc_stats -#define dlmalloc_usable_size malloc_usable_size -#define dlmalloc_footprint malloc_footprint -#define dlmalloc_max_footprint malloc_max_footprint -#define dlmalloc_footprint_limit malloc_footprint_limit -#define dlmalloc_set_footprint_limit malloc_set_footprint_limit -#define dlmalloc_inspect_all malloc_inspect_all -#define dlindependent_calloc independent_calloc -#define dlindependent_comalloc independent_comalloc -#define dlbulk_free bulk_free -#endif /* USE_DL_PREFIX */ + #ifndef USE_DL_PREFIX + #define dlcalloc calloc + #define dlfree free + #define dlmalloc malloc + #define dlmemalign memalign + #define dlposix_memalign posix_memalign + #define dlrealloc realloc + #define dlrealloc_in_place realloc_in_place + #define dlvalloc valloc + #define dlpvalloc pvalloc + #define dlmallinfo mallinfo + #define dlmallopt mallopt + #define dlmalloc_trim malloc_trim + #define dlmalloc_stats malloc_stats + #define dlmalloc_usable_size malloc_usable_size + #define dlmalloc_footprint malloc_footprint + #define dlmalloc_max_footprint malloc_max_footprint + #define dlmalloc_footprint_limit malloc_footprint_limit + #define dlmalloc_set_footprint_limit malloc_set_footprint_limit + #define dlmalloc_inspect_all malloc_inspect_all + #define dlindependent_calloc independent_calloc + #define dlindependent_comalloc independent_comalloc + #define dlbulk_free bulk_free + #endif /* USE_DL_PREFIX */ /* malloc(size_t n) @@ -856,7 +865,7 @@ extern "C" { maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t. */ -DLMALLOC_EXPORT void* dlmalloc(size_t); +DLMALLOC_EXPORT void *dlmalloc(size_t); /* free(void* p) @@ -865,14 +874,14 @@ DLMALLOC_EXPORT void* dlmalloc(size_t); It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort. */ -DLMALLOC_EXPORT void dlfree(void*); +DLMALLOC_EXPORT void dlfree(void *); /* calloc(size_t n_elements, size_t element_size); Returns a pointer to n_elements * element_size bytes, with all locations set to zero. */ -DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); +DLMALLOC_EXPORT void *dlcalloc(size_t, size_t); /* realloc(void* p, size_t n) @@ -896,7 +905,7 @@ DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); The old unix realloc convention of allowing the last-free'd chunk to be used as an argument to realloc is not supported. */ -DLMALLOC_EXPORT void* dlrealloc(void*, size_t); +DLMALLOC_EXPORT void *dlrealloc(void *, size_t); /* realloc_in_place(void* p, size_t n) @@ -911,7 +920,7 @@ DLMALLOC_EXPORT void* dlrealloc(void*, size_t); Returns p if successful; otherwise null. */ -DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); +DLMALLOC_EXPORT void *dlrealloc_in_place(void *, size_t); /* memalign(size_t alignment, size_t n); @@ -925,7 +934,7 @@ DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); Overreliance on memalign is a sure way to fragment space. */ -DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); +DLMALLOC_EXPORT void *dlmemalign(size_t, size_t); /* int posix_memalign(void** pp, size_t alignment, size_t n); @@ -935,14 +944,14 @@ DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); returns EINVAL if the alignment is not a power of two (3) fails and returns ENOMEM if memory cannot be allocated. */ -DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t); +DLMALLOC_EXPORT int dlposix_memalign(void **, size_t, size_t); /* valloc(size_t n); Equivalent to memalign(pagesize, n), where pagesize is the page size of the system. If the pagesize is unknown, 4096 is used. */ -DLMALLOC_EXPORT void* dlvalloc(size_t); +DLMALLOC_EXPORT void *dlvalloc(size_t); /* mallopt(int parameter_number, int parameter_value) @@ -1017,7 +1026,7 @@ DLMALLOC_EXPORT size_t dlmalloc_footprint_limit(); */ DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); -#if MALLOC_INSPECT_ALL + #if MALLOC_INSPECT_ALL /* malloc_inspect_all(void(*handler)(void *start, void *end, @@ -1039,19 +1048,23 @@ DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); than 1000, you could write: static int count = 0; void count_chunks(void* start, void* end, size_t used, void* arg) { + if (used >= 1000) ++count; + } + then: malloc_inspect_all(count_chunks, NULL); malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined. */ -DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), - void* arg); +DLMALLOC_EXPORT void dlmalloc_inspect_all(void (*handler)(void *, void *, + size_t, void *), + void *arg); -#endif /* MALLOC_INSPECT_ALL */ + #endif /* MALLOC_INSPECT_ALL */ -#if !NO_MALLINFO + #if !NO_MALLINFO /* mallinfo() Returns (by copy) a struct containing various summary statistics: @@ -1075,7 +1088,7 @@ DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, thus be inaccurate. */ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); -#endif /* NO_MALLINFO */ + #endif /* NO_MALLINFO */ /* independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); @@ -1113,6 +1126,7 @@ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); struct Node { int item; struct Node* next; }; struct Node* build_list() { + struct Node** pool; int n = read_number_of_nodes_needed(); if (n <= 0) return 0; @@ -1124,9 +1138,11 @@ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); pool[i]->next = pool[i+1]; free(pool); // Can now free the array (or not, if it is needed later) return first; + } + */ -DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); +DLMALLOC_EXPORT void **dlindependent_calloc(size_t, size_t, void **); /* independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); @@ -1165,6 +1181,7 @@ DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); struct Foot { ... } void send_message(char* msg) { + int msglen = strlen(msg); size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; void* chunks[3]; @@ -1174,6 +1191,7 @@ DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); char* body = (char*)(chunks[1]); struct Foot* foot = (struct Foot*)(chunks[2]); // ... + } In general though, independent_comalloc is worth using only for @@ -1184,7 +1202,7 @@ DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); since it cannot reuse existing noncontiguous small chunks that might be available for some of the elements. */ -DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); +DLMALLOC_EXPORT void **dlindependent_comalloc(size_t, size_t *, void **); /* bulk_free(void* array[], size_t n_elements) @@ -1195,14 +1213,14 @@ DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); is returned. For large arrays of pointers with poor locality, it may be worthwhile to sort this array before calling bulk_free. */ -DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements); +DLMALLOC_EXPORT size_t dlbulk_free(void **, size_t n_elements); /* pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize. */ -DLMALLOC_EXPORT void* dlpvalloc(size_t); +DLMALLOC_EXPORT void *dlpvalloc(size_t); /* malloc_trim(size_t pad); @@ -1225,7 +1243,7 @@ DLMALLOC_EXPORT void* dlpvalloc(size_t); Malloc_trim returns 1 if it actually released any memory, else 0. */ -DLMALLOC_EXPORT int dlmalloc_trim(size_t); +DLMALLOC_EXPORT int dlmalloc_trim(size_t); /* malloc_stats(); @@ -1246,7 +1264,7 @@ DLMALLOC_EXPORT int dlmalloc_trim(size_t); malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo. */ -DLMALLOC_EXPORT void dlmalloc_stats(void); +DLMALLOC_EXPORT void dlmalloc_stats(void); /* malloc_usable_size(void* p); @@ -1262,9 +1280,9 @@ DLMALLOC_EXPORT void dlmalloc_stats(void); p = malloc(n); assert(malloc_usable_size(p) >= 256); */ -size_t dlmalloc_usable_size(void*); +size_t dlmalloc_usable_size(void *); -#endif /* ONLY_MSPACES */ +#endif /* ONLY_MSPACES */ #if MSPACES @@ -1272,7 +1290,7 @@ size_t dlmalloc_usable_size(void*); mspace is an opaque type representing an independent region of space that supports mspace_malloc, etc. */ -typedef void* mspace; +typedef void *mspace; /* create_mspace creates and returns a new independent space with the @@ -1304,7 +1322,8 @@ DLMALLOC_EXPORT size_t destroy_mspace(mspace msp); Destroying this space will deallocate all additionally allocated space (if possible) but not the initial base. */ -DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked); +DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, + int locked); /* mspace_track_large_chunks controls whether requests for large chunks @@ -1319,12 +1338,11 @@ DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int */ DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable); - /* mspace_malloc behaves as malloc, but operates within the given space. */ -DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); +DLMALLOC_EXPORT void *mspace_malloc(mspace msp, size_t bytes); /* mspace_free behaves as free, but operates within @@ -1334,7 +1352,7 @@ DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); free may be called instead of mspace_free because freed chunks from any space are handled by their originating spaces. */ -DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); +DLMALLOC_EXPORT void mspace_free(mspace msp, void *mem); /* mspace_realloc behaves as realloc, but operates within @@ -1345,33 +1363,38 @@ DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); realloced chunks from any space are handled by their originating spaces. */ -DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize); +DLMALLOC_EXPORT void *mspace_realloc(mspace msp, void *mem, size_t newsize); /* mspace_calloc behaves as calloc, but operates within the given space. */ -DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); +DLMALLOC_EXPORT void *mspace_calloc(mspace msp, size_t n_elements, + size_t elem_size); /* mspace_memalign behaves as memalign, but operates within the given space. */ -DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); +DLMALLOC_EXPORT void *mspace_memalign(mspace msp, size_t alignment, + size_t bytes); /* mspace_independent_calloc behaves as independent_calloc, but operates within the given space. */ -DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]); +DLMALLOC_EXPORT void **mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, + void * chunks[]); /* mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space. */ -DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]); +DLMALLOC_EXPORT void **mspace_independent_comalloc(mspace msp, + size_t n_elements, + size_t sizes[], + void * chunks[]); /* mspace_footprint() returns the number of bytes obtained from the @@ -1385,19 +1408,18 @@ DLMALLOC_EXPORT size_t mspace_footprint(mspace msp); */ DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp); - -#if !NO_MALLINFO + #if !NO_MALLINFO /* mspace_mallinfo behaves as mallinfo, but reports properties of the given space. */ DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp); -#endif /* NO_MALLINFO */ + #endif /* NO_MALLINFO */ /* malloc_usable_size(void* p) behaves the same as malloc_usable_size; */ -DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem); +DLMALLOC_EXPORT size_t mspace_usable_size(const void *mem); /* mspace_malloc_stats behaves as malloc_stats, but reports @@ -1416,11 +1438,13 @@ DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad); */ DLMALLOC_EXPORT int mspace_mallopt(int, int); -#endif /* MSPACES */ +#endif /* MSPACES */ #ifdef __cplusplus -} /* end of extern "C" */ -#endif /* __cplusplus */ + +} /* end of extern "C" */ + +#endif /* __cplusplus */ /* ======================================================================== @@ -1435,195 +1459,207 @@ DLMALLOC_EXPORT int mspace_mallopt(int, int); /*------------------------------ internal #includes ---------------------- */ #ifdef _MSC_VER -#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ -#endif /* _MSC_VER */ + #pragma warning(disable : 4146) /* no "unsigned" warnings */ +#endif /* _MSC_VER */ #if !NO_MALLOC_STATS -#include /* for printing in malloc_stats */ -#endif /* NO_MALLOC_STATS */ + #include /* for printing in malloc_stats */ +#endif /* NO_MALLOC_STATS */ #ifndef LACKS_ERRNO_H -#include /* for MALLOC_FAILURE_ACTION */ -#endif /* LACKS_ERRNO_H */ + #include /* for MALLOC_FAILURE_ACTION */ +#endif /* LACKS_ERRNO_H */ #ifdef DEBUG -#if ABORT_ON_ASSERT_FAILURE -#undef assert -#define assert(x) if(!(x)) ABORT -#else /* ABORT_ON_ASSERT_FAILURE */ -#include -#endif /* ABORT_ON_ASSERT_FAILURE */ -#else /* DEBUG */ -#ifndef assert -#define assert(x) -#endif -#define DEBUG 0 -#endif /* DEBUG */ + #if ABORT_ON_ASSERT_FAILURE + #undef assert + #define assert(x) \ + if (!(x)) ABORT + #else /* ABORT_ON_ASSERT_FAILURE */ + #include + #endif /* ABORT_ON_ASSERT_FAILURE */ +#else /* DEBUG */ + #ifndef assert + #define assert(x) + #endif + #define DEBUG 0 +#endif /* DEBUG */ #if !defined(WIN32) && !defined(LACKS_TIME_H) -#include /* for magic initialization */ -#endif /* WIN32 */ + #include /* for magic initialization */ +#endif /* WIN32 */ #ifndef LACKS_STDLIB_H -#include /* for abort() */ -#endif /* LACKS_STDLIB_H */ + #include /* for abort() */ +#endif /* LACKS_STDLIB_H */ #ifndef LACKS_STRING_H -#include /* for memset etc */ -#endif /* LACKS_STRING_H */ + #include /* for memset etc */ +#endif /* LACKS_STRING_H */ #if USE_BUILTIN_FFS -#ifndef LACKS_STRINGS_H -#include /* for ffs */ -#endif /* LACKS_STRINGS_H */ -#endif /* USE_BUILTIN_FFS */ + #ifndef LACKS_STRINGS_H + #include /* for ffs */ + #endif /* LACKS_STRINGS_H */ +#endif /* USE_BUILTIN_FFS */ #if HAVE_MMAP -#ifndef LACKS_SYS_MMAN_H -/* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ -#if (defined(linux) && !defined(__USE_GNU)) -#define __USE_GNU 1 -#include /* for mmap */ -#undef __USE_GNU -#else -#include /* for mmap */ -#endif /* linux */ -#endif /* LACKS_SYS_MMAN_H */ -#ifndef LACKS_FCNTL_H -#include -#endif /* LACKS_FCNTL_H */ -#endif /* HAVE_MMAP */ + #ifndef LACKS_SYS_MMAN_H + /* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ + #if (defined(linux) && !defined(__USE_GNU)) + #define __USE_GNU 1 + #include /* for mmap */ + #undef __USE_GNU + #else + #include /* for mmap */ + #endif /* linux */ + #endif /* LACKS_SYS_MMAN_H */ + #ifndef LACKS_FCNTL_H + #include + #endif /* LACKS_FCNTL_H */ +#endif /* HAVE_MMAP */ #ifndef LACKS_UNISTD_H -#include /* for sbrk, sysconf */ -#else /* LACKS_UNISTD_H */ -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void* sbrk(ptrdiff_t); -#endif /* FreeBSD etc */ -#endif /* LACKS_UNISTD_H */ + #include /* for sbrk, sysconf */ +#else /* LACKS_UNISTD_H */ + #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) +extern void *sbrk(ptrdiff_t); + #endif /* FreeBSD etc */ +#endif /* LACKS_UNISTD_H */ /* Declarations for locking */ #if USE_LOCKS -#ifndef WIN32 -#if defined (__SVR4) && defined (__sun) /* solaris */ -#include -#elif !defined(LACKS_SCHED_H) -#include -#endif /* solaris or LACKS_SCHED_H */ -#if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS -#include -#endif /* USE_RECURSIVE_LOCKS ... */ -#elif defined(_MSC_VER) -#ifndef _M_AMD64 -/* These are already defined on AMD64 builds */ -#ifdef __cplusplus + #ifndef WIN32 + #if defined(__SVR4) && defined(__sun) /* solaris */ + #include + #elif !defined(LACKS_SCHED_H) + #include + #endif /* solaris or LACKS_SCHED_H */ + #if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || \ + !USE_SPIN_LOCKS + #include + #endif /* USE_RECURSIVE_LOCKS ... */ + #elif defined(_MSC_VER) + #ifndef _M_AMD64 + /* These are already defined on AMD64 builds */ + #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ -LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp); + + #endif /* __cplusplus */ +LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, + LONG Comp); LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value); -#ifdef __cplusplus + #ifdef __cplusplus + } -#endif /* __cplusplus */ -#endif /* _M_AMD64 */ -#pragma intrinsic (_InterlockedCompareExchange) -#pragma intrinsic (_InterlockedExchange) -#define interlockedcompareexchange _InterlockedCompareExchange -#define interlockedexchange _InterlockedExchange -#elif defined(WIN32) && defined(__GNUC__) -#define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b) -#define interlockedexchange __sync_lock_test_and_set -#endif /* Win32 */ -#else /* USE_LOCKS */ -#endif /* USE_LOCKS */ + + #endif /* __cplusplus */ + #endif /* _M_AMD64 */ + #pragma intrinsic(_InterlockedCompareExchange) + #pragma intrinsic(_InterlockedExchange) + #define interlockedcompareexchange _InterlockedCompareExchange + #define interlockedexchange _InterlockedExchange + #elif defined(WIN32) && defined(__GNUC__) + #define interlockedcompareexchange(a, b, c) \ + __sync_val_compare_and_swap(a, c, b) + #define interlockedexchange __sync_lock_test_and_set + #endif /* Win32 */ +#else /* USE_LOCKS */ +#endif /* USE_LOCKS */ #ifndef LOCK_AT_FORK -#define LOCK_AT_FORK 0 + #define LOCK_AT_FORK 0 #endif /* Declarations for bit scanning on win32 */ -#if defined(_MSC_VER) && _MSC_VER>=1300 -#ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ -#ifdef __cplusplus +#if defined(_MSC_VER) && _MSC_VER >= 1300 + #ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ + #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ + + #endif /* __cplusplus */ unsigned char _BitScanForward(unsigned long *index, unsigned long mask); unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); -#ifdef __cplusplus + #ifdef __cplusplus + } -#endif /* __cplusplus */ -#define BitScanForward _BitScanForward -#define BitScanReverse _BitScanReverse -#pragma intrinsic(_BitScanForward) -#pragma intrinsic(_BitScanReverse) -#endif /* BitScanForward */ -#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ + #endif /* __cplusplus */ + + #define BitScanForward _BitScanForward + #define BitScanReverse _BitScanReverse + #pragma intrinsic(_BitScanForward) + #pragma intrinsic(_BitScanReverse) + #endif /* BitScanForward */ +#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ #ifndef WIN32 -#ifndef malloc_getpagesize -# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ -# ifndef _SC_PAGE_SIZE -# define _SC_PAGE_SIZE _SC_PAGESIZE -# endif -# endif -# ifdef _SC_PAGE_SIZE -# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) -# else -# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) - extern size_t getpagesize(); -# define malloc_getpagesize getpagesize() -# else -# ifdef WIN32 /* use supplied emulation of getpagesize */ -# define malloc_getpagesize getpagesize() -# else -# ifndef LACKS_SYS_PARAM_H -# include -# endif -# ifdef EXEC_PAGESIZE -# define malloc_getpagesize EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define malloc_getpagesize NBPG -# else -# define malloc_getpagesize (NBPG * CLSIZE) -# endif -# else -# ifdef NBPC -# define malloc_getpagesize NBPC -# else -# ifdef PAGESIZE -# define malloc_getpagesize PAGESIZE -# else /* just guess */ -# define malloc_getpagesize ((size_t)4096U) -# endif -# endif -# endif -# endif -# endif -# endif -# endif -#endif + #ifndef malloc_getpagesize + #ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ + #ifndef _SC_PAGE_SIZE + #define _SC_PAGE_SIZE _SC_PAGESIZE + #endif + #endif + #ifdef _SC_PAGE_SIZE + #define malloc_getpagesize sysconf(_SC_PAGE_SIZE) + #else + #if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) +extern size_t getpagesize(); + #define malloc_getpagesize getpagesize() + #else + #ifdef WIN32 /* use supplied emulation of getpagesize */ + #define malloc_getpagesize getpagesize() + #else + #ifndef LACKS_SYS_PARAM_H + #include + #endif + #ifdef EXEC_PAGESIZE + #define malloc_getpagesize EXEC_PAGESIZE + #else + #ifdef NBPG + #ifndef CLSIZE + #define malloc_getpagesize NBPG + #else + #define malloc_getpagesize (NBPG * CLSIZE) + #endif + #else + #ifdef NBPC + #define malloc_getpagesize NBPC + #else + #ifdef PAGESIZE + #define malloc_getpagesize PAGESIZE + #else /* just guess */ + #define malloc_getpagesize ((size_t)4096U) + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif #endif /* ------------------- size_t and alignment properties -------------------- */ /* The byte and bit size of a size_t */ -#define SIZE_T_SIZE (sizeof(size_t)) -#define SIZE_T_BITSIZE (sizeof(size_t) << 3) +#define SIZE_T_SIZE (sizeof(size_t)) +#define SIZE_T_BITSIZE (sizeof(size_t) << 3) /* Some constants coerced to size_t */ /* Annoying but necessary to avoid errors on some platforms */ -#define SIZE_T_ZERO ((size_t)0) -#define SIZE_T_ONE ((size_t)1) -#define SIZE_T_TWO ((size_t)2) -#define SIZE_T_FOUR ((size_t)4) -#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) -#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) -#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) -#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) +#define SIZE_T_ZERO ((size_t)0) +#define SIZE_T_ONE ((size_t)1) +#define SIZE_T_TWO ((size_t)2) +#define SIZE_T_FOUR ((size_t)4) +#define TWO_SIZE_T_SIZES (SIZE_T_SIZE << 1) +#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE << 2) +#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES + TWO_SIZE_T_SIZES) +#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) /* The bit mask value corresponding to MALLOC_ALIGNMENT */ -#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) +#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) /* True if address a has acceptable alignment */ -#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) +#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) /* the number of bytes to offset an address to align it */ -#define align_offset(A)\ - ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ - ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) +#define align_offset(A) \ + ((((size_t)(A)&CHUNK_ALIGN_MASK) == 0) \ + ? 0 \ + : ((MALLOC_ALIGNMENT - ((size_t)(A)&CHUNK_ALIGN_MASK)) & \ + CHUNK_ALIGN_MASK)) /* -------------------------- MMAP preliminaries ------------------------- */ @@ -1633,193 +1669,202 @@ unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); using so many "#if"s. */ - /* MORECORE and MMAP must return MFAIL on failure */ -#define MFAIL ((void*)(MAX_SIZE_T)) -#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ +#define MFAIL ((void *)(MAX_SIZE_T)) +#define CMFAIL ((char *)(MFAIL)) /* defined for convenience */ #if HAVE_MMAP -#ifndef WIN32 -#define MMAP_PROT (PROT_READ|PROT_WRITE) -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -#define MAP_ANONYMOUS MAP_ANON -#endif /* MAP_ANON */ -#ifdef MAP_ANONYMOUS + #ifndef WIN32 + #define MMAP_PROT (PROT_READ | PROT_WRITE) + #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) + #define MAP_ANONYMOUS MAP_ANON + #endif /* MAP_ANON */ + #ifdef MAP_ANONYMOUS + + #define MMAP_FLAGS (MAP_PRIVATE | MAP_ANONYMOUS) -#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) +static FORCEINLINE void *unixmmap(size_t size) { -static FORCEINLINE void* unixmmap(size_t size) { - void* result; + void *result; result = mmap(0, size, MMAP_PROT, MMAP_FLAGS, -1, 0); - if (result == MFAIL) - return MFAIL; + if (result == MFAIL) return MFAIL; return result; + } -static FORCEINLINE int unixmunmap(void* ptr, size_t size) { +static FORCEINLINE int unixmunmap(void *ptr, size_t size) { + int result; result = munmap(ptr, size); - if (result != 0) - return result; + if (result != 0) return result; return result; + } -#define MMAP_DEFAULT(s) unixmmap(s) -#define MUNMAP_DEFAULT(a, s) unixmunmap((a), (s)) + #define MMAP_DEFAULT(s) unixmmap(s) + #define MUNMAP_DEFAULT(a, s) unixmunmap((a), (s)) -#else /* MAP_ANONYMOUS */ -/* - Nearly all versions of mmap support MAP_ANONYMOUS, so the following - is unlikely to be needed, but is supplied just in case. -*/ -#define MMAP_FLAGS (MAP_PRIVATE) -static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ -#define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \ - (dev_zero_fd = open("/dev/zero", O_RDWR), \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) -#define MUNMAP_DEFAULT(a, s) munmap((a), (s)) -#endif /* MAP_ANONYMOUS */ + #else /* MAP_ANONYMOUS */ + /* + Nearly all versions of mmap support MAP_ANONYMOUS, so the following + is unlikely to be needed, but is supplied just in case. + */ + #define MMAP_FLAGS (MAP_PRIVATE) +static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ + #define MMAP_DEFAULT(s) \ + ((dev_zero_fd < 0) \ + ? (dev_zero_fd = open("/dev/zero", O_RDWR), \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) \ + : mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) + #define MUNMAP_DEFAULT(a, s) munmap((a), (s)) + #endif /* MAP_ANONYMOUS */ -#define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) + #define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) -#else /* WIN32 */ + #else /* WIN32 */ /* Win32 MMAP via VirtualAlloc */ -static FORCEINLINE void* win32mmap(size_t size) { - void* ptr; +static FORCEINLINE void *win32mmap(size_t size) { + + void *ptr; - ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - if (ptr == 0) - return MFAIL; + ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + if (ptr == 0) return MFAIL; return ptr; + } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ -static FORCEINLINE void* win32direct_mmap(size_t size) { - void* ptr; +static FORCEINLINE void *win32direct_mmap(size_t size) { + + void *ptr; - ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, - PAGE_READWRITE); - if (ptr == 0) - return MFAIL; + ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE); + if (ptr == 0) return MFAIL; return ptr; + } /* This function supports releasing coalesed segments */ -static FORCEINLINE int win32munmap(void* ptr, size_t size) { +static FORCEINLINE int win32munmap(void *ptr, size_t size) { + MEMORY_BASIC_INFORMATION minfo; - char* cptr = (char*)ptr; + char *cptr = (char *)ptr; while (size) { - if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) - return -1; + + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) return -1; if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || minfo.State != MEM_COMMIT || minfo.RegionSize > size) return -1; - if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) - return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) return -1; cptr += minfo.RegionSize; size -= minfo.RegionSize; + } return 0; + } -#define MMAP_DEFAULT(s) win32mmap(s) -#define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) -#define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) -#endif /* WIN32 */ -#endif /* HAVE_MMAP */ + #define MMAP_DEFAULT(s) win32mmap(s) + #define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) + #define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) + #endif /* WIN32 */ +#endif /* HAVE_MMAP */ #if HAVE_MREMAP -#ifndef WIN32 + #ifndef WIN32 -static FORCEINLINE void* dlmremap(void* old_address, size_t old_size, size_t new_size, int flags) { - void* result; +static FORCEINLINE void *dlmremap(void *old_address, size_t old_size, + size_t new_size, int flags) { + + void *result; result = mremap(old_address, old_size, new_size, flags); - if (result == MFAIL) - return MFAIL; + if (result == MFAIL) return MFAIL; return result; + } -#define MREMAP_DEFAULT(addr, osz, nsz, mv) dlmremap((addr), (osz), (nsz), (mv)) -#endif /* WIN32 */ -#endif /* HAVE_MREMAP */ + #define MREMAP_DEFAULT(addr, osz, nsz, mv) \ + dlmremap((addr), (osz), (nsz), (mv)) + #endif /* WIN32 */ +#endif /* HAVE_MREMAP */ /** * Define CALL_MORECORE */ #if HAVE_MORECORE - #ifdef MORECORE - #define CALL_MORECORE(S) MORECORE(S) - #else /* MORECORE */ - #define CALL_MORECORE(S) MORECORE_DEFAULT(S) - #endif /* MORECORE */ -#else /* HAVE_MORECORE */ - #define CALL_MORECORE(S) MFAIL -#endif /* HAVE_MORECORE */ + #ifdef MORECORE + #define CALL_MORECORE(S) MORECORE(S) + #else /* MORECORE */ + #define CALL_MORECORE(S) MORECORE_DEFAULT(S) + #endif /* MORECORE */ +#else /* HAVE_MORECORE */ + #define CALL_MORECORE(S) MFAIL +#endif /* HAVE_MORECORE */ /** * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP */ #if HAVE_MMAP - #define USE_MMAP_BIT (SIZE_T_ONE) - - #ifdef MMAP - #define CALL_MMAP(s) MMAP(s) - #else /* MMAP */ - #define CALL_MMAP(s) MMAP_DEFAULT(s) - #endif /* MMAP */ - #ifdef MUNMAP - #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) - #else /* MUNMAP */ - #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) - #endif /* MUNMAP */ - #ifdef DIRECT_MMAP - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) - #else /* DIRECT_MMAP */ - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) - #endif /* DIRECT_MMAP */ -#else /* HAVE_MMAP */ - #define USE_MMAP_BIT (SIZE_T_ZERO) - - #define MMAP(s) MFAIL - #define MUNMAP(a, s) (-1) - #define DIRECT_MMAP(s) MFAIL - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) - #define CALL_MMAP(s) MMAP(s) - #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) -#endif /* HAVE_MMAP */ + #define USE_MMAP_BIT (SIZE_T_ONE) + + #ifdef MMAP + #define CALL_MMAP(s) MMAP(s) + #else /* MMAP */ + #define CALL_MMAP(s) MMAP_DEFAULT(s) + #endif /* MMAP */ + #ifdef MUNMAP + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) + #else /* MUNMAP */ + #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) + #endif /* MUNMAP */ + #ifdef DIRECT_MMAP + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #else /* DIRECT_MMAP */ + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) + #endif /* DIRECT_MMAP */ +#else /* HAVE_MMAP */ + #define USE_MMAP_BIT (SIZE_T_ZERO) + + #define MMAP(s) MFAIL + #define MUNMAP(a, s) (-1) + #define DIRECT_MMAP(s) MFAIL + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #define CALL_MMAP(s) MMAP(s) + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) +#endif /* HAVE_MMAP */ /** * Define CALL_MREMAP */ #if HAVE_MMAP && HAVE_MREMAP - #ifdef MREMAP - #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) - #else /* MREMAP */ - #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) - #endif /* MREMAP */ -#else /* HAVE_MMAP && HAVE_MREMAP */ - #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL -#endif /* HAVE_MMAP && HAVE_MREMAP */ + #ifdef MREMAP + #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) + #else /* MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) \ + MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) + #endif /* MREMAP */ +#else /* HAVE_MMAP && HAVE_MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL +#endif /* HAVE_MMAP && HAVE_MREMAP */ /* mstate bit set if continguous morecore disabled or failed */ #define USE_NONCONTIGUOUS_BIT (4U) /* segment bit set in create_mspace_with_base */ -#define EXTERN_BIT (8U) - +#define EXTERN_BIT (8U) /* --------------------------- Lock preliminaries ------------------------ */ @@ -1852,247 +1897,284 @@ static FORCEINLINE void* dlmremap(void* old_address, size_t old_size, size_t new */ #if !USE_LOCKS -#define USE_LOCK_BIT (0U) -#define INITIAL_LOCK(l) (0) -#define DESTROY_LOCK(l) (0) -#define ACQUIRE_MALLOC_GLOBAL_LOCK() -#define RELEASE_MALLOC_GLOBAL_LOCK() + #define USE_LOCK_BIT (0U) + #define INITIAL_LOCK(l) (0) + #define DESTROY_LOCK(l) (0) + #define ACQUIRE_MALLOC_GLOBAL_LOCK() + #define RELEASE_MALLOC_GLOBAL_LOCK() #else -#if USE_LOCKS > 1 -/* ----------------------- User-defined locks ------------------------ */ -/* Define your own lock implementation here */ -/* #define INITIAL_LOCK(lk) ... */ -/* #define DESTROY_LOCK(lk) ... */ -/* #define ACQUIRE_LOCK(lk) ... */ -/* #define RELEASE_LOCK(lk) ... */ -/* #define TRY_LOCK(lk) ... */ -/* static MLOCK_T malloc_global_mutex = ... */ - -#elif USE_SPIN_LOCKS - -/* First, define CAS_LOCK and CLEAR_LOCK on ints */ -/* Note CAS_LOCK defined to return 0 on success */ - -#if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) -#define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) -#define CLEAR_LOCK(sl) __sync_lock_release(sl) - -#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) + #if USE_LOCKS > 1 + /* ----------------------- User-defined locks ------------------------ */ + /* Define your own lock implementation here */ + /* #define INITIAL_LOCK(lk) ... */ + /* #define DESTROY_LOCK(lk) ... */ + /* #define ACQUIRE_LOCK(lk) ... */ + /* #define RELEASE_LOCK(lk) ... */ + /* #define TRY_LOCK(lk) ... */ + /* static MLOCK_T malloc_global_mutex = ... */ + + #elif USE_SPIN_LOCKS + + /* First, define CAS_LOCK and CLEAR_LOCK on ints */ + /* Note CAS_LOCK defined to return 0 on success */ + + #if defined(__GNUC__) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) + #define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) + #define CLEAR_LOCK(sl) __sync_lock_release(sl) + + #elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) /* Custom spin locks for older gcc on x86 */ static FORCEINLINE int x86_cas_lock(int *sl) { + int ret; int val = 1; int cmp = 0; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (ret) - : "r" (val), "m" (*(sl)), "0"(cmp) - : "memory", "cc"); + __asm__ __volatile__("lock; cmpxchgl %1, %2" + : "=a"(ret) + : "r"(val), "m"(*(sl)), "0"(cmp) + : "memory", "cc"); return ret; + } -static FORCEINLINE void x86_clear_lock(int* sl) { +static FORCEINLINE void x86_clear_lock(int *sl) { + assert(*sl != 0); int prev = 0; int ret; - __asm__ __volatile__ ("lock; xchgl %0, %1" - : "=r" (ret) - : "m" (*(sl)), "0"(prev) - : "memory"); -} - -#define CAS_LOCK(sl) x86_cas_lock(sl) -#define CLEAR_LOCK(sl) x86_clear_lock(sl) - -#else /* Win32 MSC */ -#define CAS_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)1) -#define CLEAR_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)0) - -#endif /* ... gcc spins locks ... */ + __asm__ __volatile__("lock; xchgl %0, %1" + : "=r"(ret) + : "m"(*(sl)), "0"(prev) + : "memory"); -/* How to yield for a spin lock */ -#define SPINS_PER_YIELD 63 -#if defined(_MSC_VER) -#define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ -#define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) -#elif defined (__SVR4) && defined (__sun) /* solaris */ -#define SPIN_LOCK_YIELD thr_yield(); -#elif !defined(LACKS_SCHED_H) -#define SPIN_LOCK_YIELD sched_yield(); -#else -#define SPIN_LOCK_YIELD -#endif /* ... yield ... */ +} -#if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 + #define CAS_LOCK(sl) x86_cas_lock(sl) + #define CLEAR_LOCK(sl) x86_clear_lock(sl) + + #else /* Win32 MSC */ + #define CAS_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)1) + #define CLEAR_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)0) + + #endif /* ... gcc spins locks ... */ + + /* How to yield for a spin lock */ + #define SPINS_PER_YIELD 63 + #if defined(_MSC_VER) + #define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ + #define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) + #elif defined(__SVR4) && defined(__sun) /* solaris */ + #define SPIN_LOCK_YIELD thr_yield(); + #elif !defined(LACKS_SCHED_H) + #define SPIN_LOCK_YIELD sched_yield(); + #else + #define SPIN_LOCK_YIELD + #endif /* ... yield ... */ + + #if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 /* Plain spin locks use single word (embedded in malloc_states) */ static int spin_acquire_lock(int *sl) { + int spins = 0; while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) { - if ((++spins & SPINS_PER_YIELD) == 0) { - SPIN_LOCK_YIELD; - } + + if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } + } + return 0; + } -#define MLOCK_T int -#define TRY_LOCK(sl) !CAS_LOCK(sl) -#define RELEASE_LOCK(sl) CLEAR_LOCK(sl) -#define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0) -#define INITIAL_LOCK(sl) (*sl = 0) -#define DESTROY_LOCK(sl) (0) + #define MLOCK_T int + #define TRY_LOCK(sl) !CAS_LOCK(sl) + #define RELEASE_LOCK(sl) CLEAR_LOCK(sl) + #define ACQUIRE_LOCK(sl) (CAS_LOCK(sl) ? spin_acquire_lock(sl) : 0) + #define INITIAL_LOCK(sl) (*sl = 0) + #define DESTROY_LOCK(sl) (0) static MLOCK_T malloc_global_mutex = 0; -#else /* USE_RECURSIVE_LOCKS */ -/* types for lock owners */ -#ifdef WIN32 -#define THREAD_ID_T DWORD -#define CURRENT_THREAD GetCurrentThreadId() -#define EQ_OWNER(X,Y) ((X) == (Y)) -#else -/* - Note: the following assume that pthread_t is a type that can be - initialized to (casted) zero. If this is not the case, you will need to - somehow redefine these or not use spin locks. -*/ -#define THREAD_ID_T pthread_t -#define CURRENT_THREAD pthread_self() -#define EQ_OWNER(X,Y) pthread_equal(X, Y) -#endif + #else /* USE_RECURSIVE_LOCKS */ + /* types for lock owners */ + #ifdef WIN32 + #define THREAD_ID_T DWORD + #define CURRENT_THREAD GetCurrentThreadId() + #define EQ_OWNER(X, Y) ((X) == (Y)) + #else + /* + Note: the following assume that pthread_t is a type that can be + initialized to (casted) zero. If this is not the case, you will need + to somehow redefine these or not use spin locks. + */ + #define THREAD_ID_T pthread_t + #define CURRENT_THREAD pthread_self() + #define EQ_OWNER(X, Y) pthread_equal(X, Y) + #endif struct malloc_recursive_lock { - int sl; + + int sl; unsigned int c; - THREAD_ID_T threadid; + THREAD_ID_T threadid; + }; -#define MLOCK_T struct malloc_recursive_lock -static MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0}; + #define MLOCK_T struct malloc_recursive_lock +static MLOCK_T malloc_global_mutex = {0, 0, (THREAD_ID_T)0}; static FORCEINLINE void recursive_release_lock(MLOCK_T *lk) { + assert(lk->sl != 0); - if (--lk->c == 0) { - CLEAR_LOCK(&lk->sl); - } + if (--lk->c == 0) { CLEAR_LOCK(&lk->sl); } + } static FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) { + THREAD_ID_T mythreadid = CURRENT_THREAD; - int spins = 0; + int spins = 0; for (;;) { + if (*((volatile int *)(&lk->sl)) == 0) { + if (!CAS_LOCK(&lk->sl)) { + lk->threadid = mythreadid; lk->c = 1; return 0; + } - } - else if (EQ_OWNER(lk->threadid, mythreadid)) { + + } else if (EQ_OWNER(lk->threadid, mythreadid)) { + ++lk->c; return 0; + } - if ((++spins & SPINS_PER_YIELD) == 0) { - SPIN_LOCK_YIELD; - } + + if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } + } + } static FORCEINLINE int recursive_try_lock(MLOCK_T *lk) { + THREAD_ID_T mythreadid = CURRENT_THREAD; if (*((volatile int *)(&lk->sl)) == 0) { + if (!CAS_LOCK(&lk->sl)) { + lk->threadid = mythreadid; lk->c = 1; return 1; + } - } - else if (EQ_OWNER(lk->threadid, mythreadid)) { + + } else if (EQ_OWNER(lk->threadid, mythreadid)) { + ++lk->c; return 1; + } + return 0; + } -#define RELEASE_LOCK(lk) recursive_release_lock(lk) -#define TRY_LOCK(lk) recursive_try_lock(lk) -#define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) -#define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) -#define DESTROY_LOCK(lk) (0) -#endif /* USE_RECURSIVE_LOCKS */ - -#elif defined(WIN32) /* Win32 critical sections */ -#define MLOCK_T CRITICAL_SECTION -#define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) -#define RELEASE_LOCK(lk) LeaveCriticalSection(lk) -#define TRY_LOCK(lk) TryEnterCriticalSection(lk) -#define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000)) -#define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) -#define NEED_GLOBAL_LOCK_INIT - -static MLOCK_T malloc_global_mutex; + #define RELEASE_LOCK(lk) recursive_release_lock(lk) + #define TRY_LOCK(lk) recursive_try_lock(lk) + #define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) + #define INITIAL_LOCK(lk) \ + ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) + #define DESTROY_LOCK(lk) (0) + #endif /* USE_RECURSIVE_LOCKS */ + + #elif defined(WIN32) /* Win32 critical sections */ + #define MLOCK_T CRITICAL_SECTION + #define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) + #define RELEASE_LOCK(lk) LeaveCriticalSection(lk) + #define TRY_LOCK(lk) TryEnterCriticalSection(lk) + #define INITIAL_LOCK(lk) \ + (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000 | 4000)) + #define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) + #define NEED_GLOBAL_LOCK_INIT + +static MLOCK_T malloc_global_mutex; static volatile LONG malloc_global_mutex_status; /* Use spin loop to initialize global lock */ static void init_malloc_global_mutex() { + for (;;) { + long stat = malloc_global_mutex_status; - if (stat > 0) - return; + if (stat > 0) return; /* transition to < 0 while initializing, then to > 0) */ - if (stat == 0 && - interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) { + if (stat == 0 && interlockedcompareexchange(&malloc_global_mutex_status, + (LONG)-1, (LONG)0) == 0) { + InitializeCriticalSection(&malloc_global_mutex); interlockedexchange(&malloc_global_mutex_status, (LONG)1); return; + } + SleepEx(0, FALSE); + } + } -#else /* pthreads-based locks */ -#define MLOCK_T pthread_mutex_t -#define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) -#define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) -#define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) -#define INITIAL_LOCK(lk) pthread_init_lock(lk) -#define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) + #else /* pthreads-based locks */ + #define MLOCK_T pthread_mutex_t + #define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) + #define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) + #define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) + #define INITIAL_LOCK(lk) pthread_init_lock(lk) + #define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) -#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) + #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && \ + defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) /* Cope with old-style linux recursive lock initialization by adding */ /* skipped internal declaration from pthread.h */ -extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, - int __kind)); -#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP -#define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) -#endif /* USE_RECURSIVE_LOCKS ... */ +extern int pthread_mutexattr_setkind_np __P((pthread_mutexattr_t * __attr, + int __kind)); + #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP + #define pthread_mutexattr_settype(x, y) pthread_mutexattr_setkind_np(x, y) + #endif /* USE_RECURSIVE_LOCKS ... */ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER; -static int pthread_init_lock (MLOCK_T *lk) { +static int pthread_init_lock(MLOCK_T *lk) { + pthread_mutexattr_t attr; if (pthread_mutexattr_init(&attr)) return 1; -#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 + #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; -#endif + #endif if (pthread_mutex_init(lk, &attr)) return 1; if (pthread_mutexattr_destroy(&attr)) return 1; return 0; + } -#endif /* ... lock types ... */ + #endif /* ... lock types ... */ -/* Common code for all lock types */ -#define USE_LOCK_BIT (2U) + /* Common code for all lock types */ + #define USE_LOCK_BIT (2U) -#ifndef ACQUIRE_MALLOC_GLOBAL_LOCK -#define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); -#endif + #ifndef ACQUIRE_MALLOC_GLOBAL_LOCK + #define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); + #endif -#ifndef RELEASE_MALLOC_GLOBAL_LOCK -#define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); -#endif + #ifndef RELEASE_MALLOC_GLOBAL_LOCK + #define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); + #endif -#endif /* USE_LOCKS */ +#endif /* USE_LOCKS */ /* ----------------------- Chunk representations ------------------------ */ @@ -2232,56 +2314,56 @@ static int pthread_init_lock (MLOCK_T *lk) { */ struct malloc_chunk { - size_t prev_foot; /* Size of previous chunk (if free). */ - size_t head; /* Size and inuse bits. */ - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; + + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk *fd; /* double links -- used only if free. */ + struct malloc_chunk *bk; + }; typedef struct malloc_chunk mchunk; -typedef struct malloc_chunk* mchunkptr; -typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ -typedef unsigned int bindex_t; /* Described below */ -typedef unsigned int binmap_t; /* Described below */ -typedef unsigned int flag_t; /* The type of various bit flag sets */ +typedef struct malloc_chunk *mchunkptr; +typedef struct malloc_chunk *sbinptr; /* The type of bins of chunks */ +typedef unsigned int bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ /* ------------------- Chunks sizes and alignments ----------------------- */ -#define MCHUNK_SIZE (sizeof(mchunk)) +#define MCHUNK_SIZE (sizeof(mchunk)) #if FOOTERS -#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -#else /* FOOTERS */ -#define CHUNK_OVERHEAD (SIZE_T_SIZE) -#endif /* FOOTERS */ + #define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +#else /* FOOTERS */ + #define CHUNK_OVERHEAD (SIZE_T_SIZE) +#endif /* FOOTERS */ /* MMapped chunks need a second word of overhead ... */ #define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) /* ... and additional padding for fake next-chunk at foot */ -#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) +#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) /* The smallest size we can malloc is an aligned minimal chunk */ -#define MIN_CHUNK_SIZE\ - ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) +#define MIN_CHUNK_SIZE ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* conversion from malloc headers to user pointers, and back */ -#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) -#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) +#define chunk2mem(p) ((void *)((char *)(p) + TWO_SIZE_T_SIZES)) +#define mem2chunk(mem) ((mchunkptr)((char *)(mem)-TWO_SIZE_T_SIZES)) /* chunk associated with aligned address A */ -#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) +#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) /* Bounds on request (not chunk) sizes. */ -#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) -#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) +#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) +#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) /* pad request bytes into a usable size */ #define pad_request(req) \ - (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* pad request, checking for minimum (but not maximum) */ #define request2size(req) \ - (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) - + (((req) < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(req)) /* ------------------ Operations on head and foot fields ----------------- */ @@ -2293,61 +2375,60 @@ typedef unsigned int flag_t; /* The type of various bit flag sets */ FLAG4_BIT is not used by this malloc, but might be useful in extensions. */ -#define PINUSE_BIT (SIZE_T_ONE) -#define CINUSE_BIT (SIZE_T_TWO) -#define FLAG4_BIT (SIZE_T_FOUR) -#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) -#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) +#define PINUSE_BIT (SIZE_T_ONE) +#define CINUSE_BIT (SIZE_T_TWO) +#define FLAG4_BIT (SIZE_T_FOUR) +#define INUSE_BITS (PINUSE_BIT | CINUSE_BIT) +#define FLAG_BITS (PINUSE_BIT | CINUSE_BIT | FLAG4_BIT) /* Head value for fenceposts */ -#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) +#define FENCEPOST_HEAD (INUSE_BITS | SIZE_T_SIZE) /* extraction of fields from head words */ -#define cinuse(p) ((p)->head & CINUSE_BIT) -#define pinuse(p) ((p)->head & PINUSE_BIT) -#define flag4inuse(p) ((p)->head & FLAG4_BIT) -#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) -#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) +#define cinuse(p) ((p)->head & CINUSE_BIT) +#define pinuse(p) ((p)->head & PINUSE_BIT) +#define flag4inuse(p) ((p)->head & FLAG4_BIT) +#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) +#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) -#define chunksize(p) ((p)->head & ~(FLAG_BITS)) +#define chunksize(p) ((p)->head & ~(FLAG_BITS)) -#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) -#define set_flag4(p) ((p)->head |= FLAG4_BIT) -#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) +#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) +#define set_flag4(p) ((p)->head |= FLAG4_BIT) +#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) /* Treat space at ptr +/- offset as a chunk */ -#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) -#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) +#define chunk_plus_offset(p, s) ((mchunkptr)(((char *)(p)) + (s))) +#define chunk_minus_offset(p, s) ((mchunkptr)(((char *)(p)) - (s))) /* Ptr to next or previous physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) -#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) +#define next_chunk(p) ((mchunkptr)(((char *)(p)) + ((p)->head & ~FLAG_BITS))) +#define prev_chunk(p) ((mchunkptr)(((char *)(p)) - ((p)->prev_foot))) /* extract next chunk's pinuse bit */ -#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) +#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) /* Get/set size at footer */ -#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) -#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) +#define get_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot) +#define set_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot = (s)) /* Set size, pinuse bit, and foot */ -#define set_size_and_pinuse_of_free_chunk(p, s)\ - ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) +#define set_size_and_pinuse_of_free_chunk(p, s) \ + ((p)->head = (s | PINUSE_BIT), set_foot(p, s)) /* Set size, pinuse bit, foot, and clear next pinuse */ -#define set_free_with_pinuse(p, s, n)\ +#define set_free_with_pinuse(p, s, n) \ (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) /* Get the internal overhead associated with chunk p */ -#define overhead_for(p)\ - (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) +#define overhead_for(p) (is_mmapped(p) ? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) /* Return true if malloced space is not necessarily cleared */ #if MMAP_CLEARS -#define calloc_must_clear(p) (!is_mmapped(p)) -#else /* MMAP_CLEARS */ -#define calloc_must_clear(p) (1) -#endif /* MMAP_CLEARS */ + #define calloc_must_clear(p) (!is_mmapped(p)) +#else /* MMAP_CLEARS */ + #define calloc_must_clear(p) (1) +#endif /* MMAP_CLEARS */ /* ---------------------- Overlaid data structures ----------------------- */ @@ -2441,23 +2522,25 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct malloc_tree_chunk { + /* The first four fields must be compatible with malloc_chunk */ size_t prev_foot; size_t head; - struct malloc_tree_chunk* fd; - struct malloc_tree_chunk* bk; + struct malloc_tree_chunk *fd; + struct malloc_tree_chunk *bk; - struct malloc_tree_chunk* child[2]; - struct malloc_tree_chunk* parent; + struct malloc_tree_chunk *child[2]; + struct malloc_tree_chunk *parent; bindex_t index; + }; typedef struct malloc_tree_chunk tchunk; -typedef struct malloc_tree_chunk* tchunkptr; -typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ +typedef struct malloc_tree_chunk *tchunkptr; +typedef struct malloc_tree_chunk *tbinptr; /* The type of bins of trees */ /* A little helper macro for trees */ -#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) +#define leftmost_child(t) ((t)->child[0] != 0 ? (t)->child[0] : (t)->child[1]) /* ----------------------------- Segments -------------------------------- */ @@ -2517,17 +2600,19 @@ typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ */ struct malloc_segment { - char* base; /* base address */ - size_t size; /* allocated size */ - struct malloc_segment* next; /* ptr to next segment */ - flag_t sflags; /* mmap and extern flag */ + + char * base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment *next; /* ptr to next segment */ + flag_t sflags; /* mmap and extern flag */ + }; -#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) -#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) +#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) +#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) typedef struct malloc_segment msegment; -typedef struct malloc_segment* msegmentptr; +typedef struct malloc_segment *msegmentptr; /* ---------------------------- malloc_state ----------------------------- */ @@ -2617,41 +2702,43 @@ typedef struct malloc_segment* msegmentptr; */ /* Bin types, widths and sizes */ -#define NSMALLBINS (32U) -#define NTREEBINS (32U) -#define SMALLBIN_SHIFT (3U) -#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) -#define TREEBIN_SHIFT (8U) -#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) -#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) +#define NSMALLBINS (32U) +#define NTREEBINS (32U) +#define SMALLBIN_SHIFT (3U) +#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) +#define TREEBIN_SHIFT (8U) +#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) +#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) struct malloc_state { - binmap_t smallmap; - binmap_t treemap; - size_t dvsize; - size_t topsize; - char* least_addr; - mchunkptr dv; - mchunkptr top; - size_t trim_check; - size_t release_checks; - size_t magic; - mchunkptr smallbins[(NSMALLBINS+1)*2]; - tbinptr treebins[NTREEBINS]; - size_t footprint; - size_t max_footprint; - size_t footprint_limit; /* zero means no limit */ - flag_t mflags; + + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + char * least_addr; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t release_checks; + size_t magic; + mchunkptr smallbins[(NSMALLBINS + 1) * 2]; + tbinptr treebins[NTREEBINS]; + size_t footprint; + size_t max_footprint; + size_t footprint_limit; /* zero means no limit */ + flag_t mflags; #if USE_LOCKS - MLOCK_T mutex; /* locate lock among fields that rarely change */ -#endif /* USE_LOCKS */ - msegment seg; - void* extp; /* Unused but available for extensions */ - size_t exts; + MLOCK_T mutex; /* locate lock among fields that rarely change */ +#endif /* USE_LOCKS */ + msegment seg; + void * extp; /* Unused but available for extensions */ + size_t exts; + }; -typedef struct malloc_state* mstate; +typedef struct malloc_state *mstate; /* ------------- Global malloc_state and malloc_params ------------------- */ @@ -2663,12 +2750,14 @@ typedef struct malloc_state* mstate; */ struct malloc_params { + size_t magic; size_t page_size; size_t granularity; size_t mmap_threshold; size_t trim_threshold; flag_t default_mflags; + }; static struct malloc_params mparams; @@ -2680,106 +2769,108 @@ static struct malloc_params mparams; /* The global malloc_state used for all non-"mspace" calls */ static struct malloc_state _gm_; -#define gm (&_gm_) -#define is_global(M) ((M) == &_gm_) + #define gm (&_gm_) + #define is_global(M) ((M) == &_gm_) -#endif /* !ONLY_MSPACES */ +#endif /* !ONLY_MSPACES */ -#define is_initialized(M) ((M)->top != 0) +#define is_initialized(M) ((M)->top != 0) /* -------------------------- system alloc setup ------------------------- */ /* Operations on mflags */ -#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) -#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) +#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) +#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) #if USE_LOCKS -#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) + #define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) #else -#define disable_lock(M) + #define disable_lock(M) #endif -#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) -#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) +#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) +#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) #if HAVE_MMAP -#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) + #define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) #else -#define disable_mmap(M) + #define disable_mmap(M) #endif -#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) -#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) +#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) +#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) -#define set_lock(M,L)\ - ((M)->mflags = (L)?\ - ((M)->mflags | USE_LOCK_BIT) :\ - ((M)->mflags & ~USE_LOCK_BIT)) +#define set_lock(M, L) \ + ((M)->mflags = \ + (L) ? ((M)->mflags | USE_LOCK_BIT) : ((M)->mflags & ~USE_LOCK_BIT)) /* page-align a size */ -#define page_align(S)\ - (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) +#define page_align(S) \ + (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) /* granularity-align a size */ -#define granularity_align(S)\ - (((S) + (mparams.granularity - SIZE_T_ONE))\ - & ~(mparams.granularity - SIZE_T_ONE)) - +#define granularity_align(S) \ + (((S) + (mparams.granularity - SIZE_T_ONE)) & \ + ~(mparams.granularity - SIZE_T_ONE)) /* For mmap, use granularity alignment on windows, else page-align */ #ifdef WIN32 -#define mmap_align(S) granularity_align(S) + #define mmap_align(S) granularity_align(S) #else -#define mmap_align(S) page_align(S) + #define mmap_align(S) page_align(S) #endif /* For sys_alloc, enough padding to ensure can malloc request on success */ #define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) -#define is_page_aligned(S)\ - (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) -#define is_granularity_aligned(S)\ - (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) +#define is_page_aligned(S) \ + (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) +#define is_granularity_aligned(S) \ + (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) /* True if segment S holds address A */ -#define segment_holds(S, A)\ - ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) +#define segment_holds(S, A) \ + ((char *)(A) >= S->base && (char *)(A) < S->base + S->size) /* Return segment holding given address */ -static msegmentptr segment_holding(mstate m, char* addr) { +static msegmentptr segment_holding(mstate m, char *addr) { + msegmentptr sp = &m->seg; for (;;) { - if (addr >= sp->base && addr < sp->base + sp->size) - return sp; - if ((sp = sp->next) == 0) - return 0; + + if (addr >= sp->base && addr < sp->base + sp->size) return sp; + if ((sp = sp->next) == 0) return 0; + } + } /* Return true if segment contains a segment link */ static int has_segment_link(mstate m, msegmentptr ss) { + msegmentptr sp = &m->seg; for (;;) { - if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) - return 1; - if ((sp = sp->next) == 0) - return 0; + + if ((char *)sp >= ss->base && (char *)sp < ss->base + ss->size) return 1; + if ((sp = sp->next) == 0) return 0; + } + } #ifndef MORECORE_CANNOT_TRIM -#define should_trim(M,s) ((s) > (M)->trim_check) -#else /* MORECORE_CANNOT_TRIM */ -#define should_trim(M,s) (0) -#endif /* MORECORE_CANNOT_TRIM */ + #define should_trim(M, s) ((s) > (M)->trim_check) +#else /* MORECORE_CANNOT_TRIM */ + #define should_trim(M, s) (0) +#endif /* MORECORE_CANNOT_TRIM */ /* TOP_FOOT_SIZE is padding at the end of a segment, including space that may be needed to place segment records and fenceposts when new noncontiguous segments are added. */ -#define TOP_FOOT_SIZE\ - (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) - +#define TOP_FOOT_SIZE \ + (align_offset(chunk2mem(0)) + pad_request(sizeof(struct malloc_segment)) + \ + MIN_CHUNK_SIZE) /* ------------------------------- Hooks -------------------------------- */ @@ -2790,19 +2881,24 @@ static int has_segment_link(mstate m, msegmentptr ss) { */ #if USE_LOCKS -#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) -#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } -#else /* USE_LOCKS */ + #define PREACTION(M) ((use_lock(M)) ? ACQUIRE_LOCK(&(M)->mutex) : 0) + #define POSTACTION(M) \ + { \ + \ + if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); \ + \ + } +#else /* USE_LOCKS */ -#ifndef PREACTION -#define PREACTION(M) (0) -#endif /* PREACTION */ + #ifndef PREACTION + #define PREACTION(M) (0) + #endif /* PREACTION */ -#ifndef POSTACTION -#define POSTACTION(M) -#endif /* POSTACTION */ + #ifndef POSTACTION + #define POSTACTION(M) + #endif /* POSTACTION */ -#endif /* USE_LOCKS */ +#endif /* USE_LOCKS */ /* CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. @@ -2820,164 +2916,180 @@ int malloc_corruption_error_count; /* default corruption action */ static void reset_on_error(mstate m); -#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) -#define USAGE_ERROR_ACTION(m, p) + #define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) + #define USAGE_ERROR_ACTION(m, p) -#else /* PROCEED_ON_ERROR */ +#else /* PROCEED_ON_ERROR */ -#ifndef CORRUPTION_ERROR_ACTION -#define CORRUPTION_ERROR_ACTION(m) ABORT -#endif /* CORRUPTION_ERROR_ACTION */ + #ifndef CORRUPTION_ERROR_ACTION + #define CORRUPTION_ERROR_ACTION(m) ABORT + #endif /* CORRUPTION_ERROR_ACTION */ -#ifndef USAGE_ERROR_ACTION -#define USAGE_ERROR_ACTION(m,p) ABORT -#endif /* USAGE_ERROR_ACTION */ - -#endif /* PROCEED_ON_ERROR */ + #ifndef USAGE_ERROR_ACTION + #define USAGE_ERROR_ACTION(m, p) ABORT + #endif /* USAGE_ERROR_ACTION */ +#endif /* PROCEED_ON_ERROR */ /* -------------------------- Debugging setup ---------------------------- */ -#if ! DEBUG +#if !DEBUG -#define check_free_chunk(M,P) -#define check_inuse_chunk(M,P) -#define check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) -#define check_malloc_state(M) -#define check_top_chunk(M,P) + #define check_free_chunk(M, P) + #define check_inuse_chunk(M, P) + #define check_malloced_chunk(M, P, N) + #define check_mmapped_chunk(M, P) + #define check_malloc_state(M) + #define check_top_chunk(M, P) -#else /* DEBUG */ -#define check_free_chunk(M,P) do_check_free_chunk(M,P) -#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) -#define check_top_chunk(M,P) do_check_top_chunk(M,P) -#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) -#define check_malloc_state(M) do_check_malloc_state(M) +#else /* DEBUG */ + #define check_free_chunk(M, P) do_check_free_chunk(M, P) + #define check_inuse_chunk(M, P) do_check_inuse_chunk(M, P) + #define check_top_chunk(M, P) do_check_top_chunk(M, P) + #define check_malloced_chunk(M, P, N) do_check_malloced_chunk(M, P, N) + #define check_mmapped_chunk(M, P) do_check_mmapped_chunk(M, P) + #define check_malloc_state(M) do_check_malloc_state(M) static void do_check_any_chunk(mstate m, mchunkptr p); static void do_check_top_chunk(mstate m, mchunkptr p); static void do_check_mmapped_chunk(mstate m, mchunkptr p); static void do_check_inuse_chunk(mstate m, mchunkptr p); static void do_check_free_chunk(mstate m, mchunkptr p); -static void do_check_malloced_chunk(mstate m, void* mem, size_t s); +static void do_check_malloced_chunk(mstate m, void *mem, size_t s); static void do_check_tree(mstate m, tchunkptr t); static void do_check_treebin(mstate m, bindex_t i); static void do_check_smallbin(mstate m, bindex_t i); static void do_check_malloc_state(mstate m); static int bin_find(mstate m, mchunkptr x); static size_t traverse_and_check(mstate m); -#endif /* DEBUG */ +#endif /* DEBUG */ /* ---------------------------- Indexing Bins ---------------------------- */ -#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) -#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) -#define small_index2size(i) ((i) << SMALLBIN_SHIFT) -#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) +#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) +#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) +#define small_index2size(i) ((i) << SMALLBIN_SHIFT) +#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) /* addressing by index. See above about smallbin repositioning */ -#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) -#define treebin_at(M,i) (&((M)->treebins[i])) +#define smallbin_at(M, i) ((sbinptr)((char *)&((M)->smallbins[(i) << 1]))) +#define treebin_at(M, i) (&((M)->treebins[i])) /* assign tree index for size S to variable I. Use x86 asm if possible */ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -#define compute_tree_index(S, I)\ -{\ - unsigned int X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} + #define compute_tree_index(S, I) \ + { \ + \ + unsigned int X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else { \ + \ + unsigned int K = (unsigned)sizeof(X) * __CHAR_BIT__ - 1 - \ + (unsigned)__builtin_clz(X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ + \ + } \ + \ + } -#elif defined (__INTEL_COMPILER) -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K = _bit_scan_reverse (X); \ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} +#elif defined(__INTEL_COMPILER) + #define compute_tree_index(S, I) \ + { \ + \ + size_t X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else { \ + \ + unsigned int K = _bit_scan_reverse(X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ + \ + } \ + \ + } -#elif defined(_MSC_VER) && _MSC_VER>=1300 -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K;\ - _BitScanReverse((DWORD *) &K, (DWORD) X);\ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} +#elif defined(_MSC_VER) && _MSC_VER >= 1300 + #define compute_tree_index(S, I) \ + { \ + \ + size_t X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else { \ + \ + unsigned int K; \ + _BitScanReverse((DWORD *)&K, (DWORD)X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ + \ + } \ + \ + } -#else /* GNUC */ -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int Y = (unsigned int)X;\ - unsigned int N = ((Y - 0x100) >> 16) & 8;\ - unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ - N += K;\ - N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ - K = 14 - N + ((Y <<= K) >> 15);\ - I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ - }\ -} -#endif /* GNUC */ +#else /* GNUC */ + #define compute_tree_index(S, I) \ + { \ + \ + size_t X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else { \ + \ + unsigned int Y = (unsigned int)X; \ + unsigned int N = ((Y - 0x100) >> 16) & 8; \ + unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4; \ + N += K; \ + N += K = (((Y <<= K) - 0x4000) >> 16) & 2; \ + K = 14 - N + ((Y <<= K) >> 15); \ + I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1)); \ + \ + } \ + \ + } +#endif /* GNUC */ /* Bit representing maximum resolved size in a treebin at i */ #define bit_for_tree_index(i) \ - (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) + (i == NTREEBINS - 1) ? (SIZE_T_BITSIZE - 1) : (((i) >> 1) + TREEBIN_SHIFT - 2) /* Shift placing maximum resolved bit in a treebin at i as sign bit */ #define leftshift_for_tree_index(i) \ - ((i == NTREEBINS-1)? 0 : \ - ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + ((i == NTREEBINS - 1) \ + ? 0 \ + : ((SIZE_T_BITSIZE - SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) /* The size of the smallest chunk held in bin with index i */ -#define minsize_for_tree_index(i) \ - ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ - (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) - +#define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ + (((size_t)((i)&SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) /* ------------------------ Operations on bin maps ----------------------- */ /* bit corresponding to given index */ -#define idx2bit(i) ((binmap_t)(1) << (i)) +#define idx2bit(i) ((binmap_t)(1) << (i)) /* Mark/Clear bits with given index */ -#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) -#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) -#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) +#define mark_smallmap(M, i) ((M)->smallmap |= idx2bit(i)) +#define clear_smallmap(M, i) ((M)->smallmap &= ~idx2bit(i)) +#define smallmap_is_marked(M, i) ((M)->smallmap & idx2bit(i)) -#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) -#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) -#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) +#define mark_treemap(M, i) ((M)->treemap |= idx2bit(i)) +#define clear_treemap(M, i) ((M)->treemap &= ~idx2bit(i)) +#define treemap_is_marked(M, i) ((M)->treemap & idx2bit(i)) /* isolate the least set bit of a bitmap */ -#define least_bit(x) ((x) & -(x)) +#define least_bit(x) ((x) & -(x)) /* mask with all bits to left of least bit of x on */ -#define left_bits(x) ((x<<1) | -(x<<1)) +#define left_bits(x) ((x << 1) | -(x << 1)) /* mask with all bits to left of or equal to least bit of x on */ #define same_or_left_bits(x) ((x) | -(x)) @@ -2985,46 +3097,58 @@ static size_t traverse_and_check(mstate m); /* index corresponding to given bit. Use x86 asm if possible */ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - J = __builtin_ctz(X); \ - I = (bindex_t)J;\ -} + #define compute_bit2idx(X, I) \ + { \ + \ + unsigned int J; \ + J = __builtin_ctz(X); \ + I = (bindex_t)J; \ + \ + } -#elif defined (__INTEL_COMPILER) -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - J = _bit_scan_forward (X); \ - I = (bindex_t)J;\ -} +#elif defined(__INTEL_COMPILER) + #define compute_bit2idx(X, I) \ + { \ + \ + unsigned int J; \ + J = _bit_scan_forward(X); \ + I = (bindex_t)J; \ + \ + } -#elif defined(_MSC_VER) && _MSC_VER>=1300 -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - _BitScanForward((DWORD *) &J, X);\ - I = (bindex_t)J;\ -} +#elif defined(_MSC_VER) && _MSC_VER >= 1300 + #define compute_bit2idx(X, I) \ + { \ + \ + unsigned int J; \ + _BitScanForward((DWORD *)&J, X); \ + I = (bindex_t)J; \ + \ + } #elif USE_BUILTIN_FFS -#define compute_bit2idx(X, I) I = ffs(X)-1 + #define compute_bit2idx(X, I) I = ffs(X) - 1 #else -#define compute_bit2idx(X, I)\ -{\ - unsigned int Y = X - 1;\ - unsigned int K = Y >> (16-4) & 16;\ - unsigned int N = K; Y >>= K;\ - N += K = Y >> (8-3) & 8; Y >>= K;\ - N += K = Y >> (4-2) & 4; Y >>= K;\ - N += K = Y >> (2-1) & 2; Y >>= K;\ - N += K = Y >> (1-0) & 1; Y >>= K;\ - I = (bindex_t)(N + Y);\ -} -#endif /* GNUC */ - + #define compute_bit2idx(X, I) \ + { \ + \ + unsigned int Y = X - 1; \ + unsigned int K = Y >> (16 - 4) & 16; \ + unsigned int N = K; \ + Y >>= K; \ + N += K = Y >> (8 - 3) & 8; \ + Y >>= K; \ + N += K = Y >> (4 - 2) & 4; \ + Y >>= K; \ + N += K = Y >> (2 - 1) & 2; \ + Y >>= K; \ + N += K = Y >> (1 - 0) & 1; \ + Y >>= K; \ + I = (bindex_t)(N + Y); \ + \ + } +#endif /* GNUC */ /* ----------------------- Runtime Check Support ------------------------- */ @@ -3055,121 +3179,141 @@ static size_t traverse_and_check(mstate m); */ #if !INSECURE -/* Check if address a is at least as high as any from MORECORE or MMAP */ -#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) -/* Check if address of next chunk n is higher than base chunk p */ -#define ok_next(p, n) ((char*)(p) < (char*)(n)) -/* Check if p has inuse status */ -#define ok_inuse(p) is_inuse(p) -/* Check if p has its pinuse bit on */ -#define ok_pinuse(p) pinuse(p) - -#else /* !INSECURE */ -#define ok_address(M, a) (1) -#define ok_next(b, n) (1) -#define ok_inuse(p) (1) -#define ok_pinuse(p) (1) -#endif /* !INSECURE */ + /* Check if address a is at least as high as any from MORECORE or MMAP */ + #define ok_address(M, a) ((char *)(a) >= (M)->least_addr) + /* Check if address of next chunk n is higher than base chunk p */ + #define ok_next(p, n) ((char *)(p) < (char *)(n)) + /* Check if p has inuse status */ + #define ok_inuse(p) is_inuse(p) + /* Check if p has its pinuse bit on */ + #define ok_pinuse(p) pinuse(p) + +#else /* !INSECURE */ + #define ok_address(M, a) (1) + #define ok_next(b, n) (1) + #define ok_inuse(p) (1) + #define ok_pinuse(p) (1) +#endif /* !INSECURE */ #if (FOOTERS && !INSECURE) -/* Check if (alleged) mstate m has expected magic field */ -#define ok_magic(M) ((M)->magic == mparams.magic) -#else /* (FOOTERS && !INSECURE) */ -#define ok_magic(M) (1) -#endif /* (FOOTERS && !INSECURE) */ + /* Check if (alleged) mstate m has expected magic field */ + #define ok_magic(M) ((M)->magic == mparams.magic) +#else /* (FOOTERS && !INSECURE) */ + #define ok_magic(M) (1) +#endif /* (FOOTERS && !INSECURE) */ /* In gcc, use __builtin_expect to minimize impact of checks */ #if !INSECURE -#if defined(__GNUC__) && __GNUC__ >= 3 -#define RTCHECK(e) __builtin_expect(e, 1) -#else /* GNUC */ -#define RTCHECK(e) (e) -#endif /* GNUC */ -#else /* !INSECURE */ -#define RTCHECK(e) (1) -#endif /* !INSECURE */ + #if defined(__GNUC__) && __GNUC__ >= 3 + #define RTCHECK(e) __builtin_expect(e, 1) + #else /* GNUC */ + #define RTCHECK(e) (e) + #endif /* GNUC */ +#else /* !INSECURE */ + #define RTCHECK(e) (1) +#endif /* !INSECURE */ /* macros to set up inuse chunks with or without footers */ #if !FOOTERS -#define mark_inuse_foot(M,p,s) + #define mark_inuse_foot(M, p, s) -/* Macros for setting head/foot of non-mmapped chunks */ + /* Macros for setting head/foot of non-mmapped chunks */ -/* Set cinuse bit and pinuse bit of next chunk */ -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + /* Set cinuse bit and pinuse bit of next chunk */ + #define set_inuse(M, p, s) \ + ((p)->head = (((p)->head & PINUSE_BIT) | s | CINUSE_BIT), \ + ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) -/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + /* Set cinuse and pinuse of this chunk and pinuse of next chunk */ + #define set_inuse_and_pinuse(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), \ + ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) -/* Set size, cinuse and pinuse bit of this chunk */ -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) + /* Set size, cinuse and pinuse bit of this chunk */ + #define set_size_and_pinuse_of_inuse_chunk(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT)) -#else /* FOOTERS */ +#else /* FOOTERS */ -/* Set foot of inuse chunk to be xor of mstate and seed */ -#define mark_inuse_foot(M,p,s)\ - (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) + /* Set foot of inuse chunk to be xor of mstate and seed */ + #define mark_inuse_foot(M, p, s) \ + (((mchunkptr)((char *)(p) + (s)))->prev_foot = \ + ((size_t)(M) ^ mparams.magic)) -#define get_mstate_for(p)\ - ((mstate)(((mchunkptr)((char*)(p) +\ - (chunksize(p))))->prev_foot ^ mparams.magic)) + #define get_mstate_for(p) \ + ((mstate)(((mchunkptr)((char *)(p) + (chunksize(p))))->prev_foot ^ \ + mparams.magic)) -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ - mark_inuse_foot(M,p,s)) + #define set_inuse(M, p, s) \ + ((p)->head = (((p)->head & PINUSE_BIT) | s | CINUSE_BIT), \ + (((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M, p, s)) -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ - mark_inuse_foot(M,p,s)) + #define set_inuse_and_pinuse(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), \ + (((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M, p, s)) -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - mark_inuse_foot(M, p, s)) + #define set_size_and_pinuse_of_inuse_chunk(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), mark_inuse_foot(M, p, s)) -#endif /* !FOOTERS */ +#endif /* !FOOTERS */ /* ---------------------------- setting mparams -------------------------- */ #if LOCK_AT_FORK -static void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); } -static void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); } -static void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); } -#endif /* LOCK_AT_FORK */ +static void pre_fork(void) { + + ACQUIRE_LOCK(&(gm)->mutex); + +} + +static void post_fork_parent(void) { + + RELEASE_LOCK(&(gm)->mutex); + +} + +static void post_fork_child(void) { + + INITIAL_LOCK(&(gm)->mutex); + +} + +#endif /* LOCK_AT_FORK */ /* Initialize mparams */ static int init_mparams(void) { + #ifdef NEED_GLOBAL_LOCK_INIT - if (malloc_global_mutex_status <= 0) - init_malloc_global_mutex(); + if (malloc_global_mutex_status <= 0) init_malloc_global_mutex(); #endif ACQUIRE_MALLOC_GLOBAL_LOCK(); if (mparams.magic == 0) { + size_t magic; size_t psize; size_t gsize; #ifndef WIN32 psize = malloc_getpagesize; - gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); -#else /* WIN32 */ + gsize = ((DEFAULT_GRANULARITY != 0) ? DEFAULT_GRANULARITY : psize); +#else /* WIN32 */ { + SYSTEM_INFO system_info; GetSystemInfo(&system_info); psize = system_info.dwPageSize; - gsize = ((DEFAULT_GRANULARITY != 0)? - DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); + gsize = + ((DEFAULT_GRANULARITY != 0) ? DEFAULT_GRANULARITY + : system_info.dwAllocationGranularity); + } -#endif /* WIN32 */ + +#endif /* WIN32 */ /* Sanity-check configuration: size_t must be unsigned and as wide as pointer type. @@ -3177,24 +3321,23 @@ static int init_mparams(void) { alignment must be at least 8. Alignment, min chunk size, and page size must all be powers of 2. */ - if ((sizeof(size_t) != sizeof(char*)) || - (MAX_SIZE_T < MIN_CHUNK_SIZE) || - (sizeof(int) < 4) || - (MALLOC_ALIGNMENT < (size_t)8U) || - ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || - ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || - ((gsize & (gsize-SIZE_T_ONE)) != 0) || - ((psize & (psize-SIZE_T_ONE)) != 0)) + if ((sizeof(size_t) != sizeof(char *)) || (MAX_SIZE_T < MIN_CHUNK_SIZE) || + (sizeof(int) < 4) || (MALLOC_ALIGNMENT < (size_t)8U) || + ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT - SIZE_T_ONE)) != 0) || + ((MCHUNK_SIZE & (MCHUNK_SIZE - SIZE_T_ONE)) != 0) || + ((gsize & (gsize - SIZE_T_ONE)) != 0) || + ((psize & (psize - SIZE_T_ONE)) != 0)) ABORT; mparams.granularity = gsize; mparams.page_size = psize; mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; #if MORECORE_CONTIGUOUS - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; -#else /* MORECORE_CONTIGUOUS */ - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; -#endif /* MORECORE_CONTIGUOUS */ + mparams.default_mflags = USE_LOCK_BIT | USE_MMAP_BIT; +#else /* MORECORE_CONTIGUOUS */ + mparams.default_mflags = + USE_LOCK_BIT | USE_MMAP_BIT | USE_NONCONTIGUOUS_BIT; +#endif /* MORECORE_CONTIGUOUS */ #if !ONLY_MSPACES /* Set up lock for main malloc area */ @@ -3206,57 +3349,69 @@ static int init_mparams(void) { #endif { + #if USE_DEV_RANDOM - int fd; + int fd; unsigned char buf[sizeof(size_t)]; /* Try to use /dev/urandom, else fall back on using time */ if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && read(fd, buf, sizeof(buf)) == sizeof(buf)) { - magic = *((size_t *) buf); + + magic = *((size_t *)buf); close(fd); - } - else -#endif /* USE_DEV_RANDOM */ + + } else + +#endif /* USE_DEV_RANDOM */ #ifdef WIN32 - magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); + magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); #elif defined(LACKS_TIME_H) magic = (size_t)&magic ^ (size_t)0x55555555U; #else magic = (size_t)(time(0) ^ (size_t)0x55555555U); #endif - magic |= (size_t)8U; /* ensure nonzero */ - magic &= ~(size_t)7U; /* improve chances of fault for bad values */ + magic |= (size_t)8U; /* ensure nonzero */ + magic &= ~(size_t)7U; /* improve chances of fault for bad values */ /* Until memory modes commonly available, use volatile-write */ (*(volatile size_t *)(&(mparams.magic))) = magic; + } + } RELEASE_MALLOC_GLOBAL_LOCK(); return 1; + } /* support for mallopt */ static int change_mparam(int param_number, int value) { + size_t val; ensure_initialization(); - val = (value == -1)? MAX_SIZE_T : (size_t)value; - switch(param_number) { - case M_TRIM_THRESHOLD: - mparams.trim_threshold = val; - return 1; - case M_GRANULARITY: - if (val >= mparams.page_size && ((val & (val-1)) == 0)) { - mparams.granularity = val; + val = (value == -1) ? MAX_SIZE_T : (size_t)value; + switch (param_number) { + + case M_TRIM_THRESHOLD: + mparams.trim_threshold = val; return 1; - } - else + case M_GRANULARITY: + if (val >= mparams.page_size && ((val & (val - 1)) == 0)) { + + mparams.granularity = val; + return 1; + + } else + + return 0; + case M_MMAP_THRESHOLD: + mparams.mmap_threshold = val; + return 1; + default: return 0; - case M_MMAP_THRESHOLD: - mparams.mmap_threshold = val; - return 1; - default: - return 0; + } + } #if DEBUG @@ -3264,100 +3419,118 @@ static int change_mparam(int param_number, int value) { /* Check properties of any chunk, whether free, inuse, mmapped etc */ static void do_check_any_chunk(mstate m, mchunkptr p) { + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); + } /* Check properties of top chunk */ static void do_check_top_chunk(mstate m, mchunkptr p) { - msegmentptr sp = segment_holding(m, (char*)p); - size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ + + msegmentptr sp = segment_holding(m, (char *)p); + size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ assert(sp != 0); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(sz == m->topsize); assert(sz > 0); - assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); + assert(sz == ((sp->base + sp->size) - (char *)p) - TOP_FOOT_SIZE); assert(pinuse(p)); assert(!pinuse(chunk_plus_offset(p, sz))); + } /* Check properties of (inuse) mmapped chunks */ static void do_check_mmapped_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); + + size_t sz = chunksize(p); size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); assert(is_mmapped(p)); assert(use_mmap(m)); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(!is_small(sz)); - assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); + assert((len & (mparams.page_size - SIZE_T_ONE)) == 0); assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); - assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); + assert(chunk_plus_offset(p, sz + SIZE_T_SIZE)->head == 0); + } /* Check properties of inuse chunks */ static void do_check_inuse_chunk(mstate m, mchunkptr p) { + do_check_any_chunk(m, p); assert(is_inuse(p)); assert(next_pinuse(p)); /* If not pinuse and not mmapped, previous chunk has OK offset */ assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); - if (is_mmapped(p)) - do_check_mmapped_chunk(m, p); + if (is_mmapped(p)) do_check_mmapped_chunk(m, p); + } /* Check properties of free chunks */ static void do_check_free_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); + + size_t sz = chunksize(p); mchunkptr next = chunk_plus_offset(p, sz); do_check_any_chunk(m, p); assert(!is_inuse(p)); assert(!next_pinuse(p)); - assert (!is_mmapped(p)); + assert(!is_mmapped(p)); if (p != m->dv && p != m->top) { + if (sz >= MIN_CHUNK_SIZE) { + assert((sz & CHUNK_ALIGN_MASK) == 0); assert(is_aligned(chunk2mem(p))); assert(next->prev_foot == sz); assert(pinuse(p)); - assert (next == m->top || is_inuse(next)); + assert(next == m->top || is_inuse(next)); assert(p->fd->bk == p); assert(p->bk->fd == p); - } - else /* markers are always of size SIZE_T_SIZE */ + + } else /* markers are always of size SIZE_T_SIZE */ + assert(sz == SIZE_T_SIZE); + } + } /* Check properties of malloced chunks at the point they are malloced */ -static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { +static void do_check_malloced_chunk(mstate m, void *mem, size_t s) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); - size_t sz = p->head & ~INUSE_BITS; + size_t sz = p->head & ~INUSE_BITS; do_check_inuse_chunk(m, p); assert((sz & CHUNK_ALIGN_MASK) == 0); assert(sz >= MIN_CHUNK_SIZE); assert(sz >= s); /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); + } + } /* Check a tree and its subtrees. */ static void do_check_tree(mstate m, tchunkptr t) { + tchunkptr head = 0; tchunkptr u = t; - bindex_t tindex = t->index; - size_t tsize = chunksize(t); - bindex_t idx; + bindex_t tindex = t->index; + size_t tsize = chunksize(t); + bindex_t idx; compute_tree_index(tsize, idx); assert(tindex == idx); assert(tsize >= MIN_LARGE_SIZE); assert(tsize >= minsize_for_tree_index(idx)); - assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); + assert((idx == NTREEBINS - 1) || (tsize < minsize_for_tree_index((idx + 1)))); - do { /* traverse through chain of same-sized nodes */ + do { /* traverse through chain of same-sized nodes */ do_check_any_chunk(m, ((mchunkptr)u)); assert(u->index == tindex); assert(chunksize(u) == tsize); @@ -3366,56 +3539,72 @@ static void do_check_tree(mstate m, tchunkptr t) { assert(u->fd->bk == u); assert(u->bk->fd == u); if (u->parent == 0) { + assert(u->child[0] == 0); assert(u->child[1] == 0); - } - else { - assert(head == 0); /* only one node on chain has parent */ - head = u; - assert(u->parent != u); - assert (u->parent->child[0] == u || - u->parent->child[1] == u || - *((tbinptr*)(u->parent)) == u); + + } else { + + assert(head == 0); /* only one node on chain has parent */ + head = u; + assert(u->parent != u); + assert(u->parent->child[0] == u || u->parent->child[1] == u || + *((tbinptr *)(u->parent)) == u); if (u->child[0] != 0) { + assert(u->child[0]->parent == u); assert(u->child[0] != u); do_check_tree(m, u->child[0]); + } + if (u->child[1] != 0) { + assert(u->child[1]->parent == u); assert(u->child[1] != u); do_check_tree(m, u->child[1]); + } + if (u->child[0] != 0 && u->child[1] != 0) { + assert(chunksize(u->child[0]) < chunksize(u->child[1])); + } + } + u = u->fd; + } while (u != t); + assert(head != 0); + } /* Check all the chunks in a treebin. */ static void do_check_treebin(mstate m, bindex_t i) { - tbinptr* tb = treebin_at(m, i); + + tbinptr * tb = treebin_at(m, i); tchunkptr t = *tb; - int empty = (m->treemap & (1U << i)) == 0; - if (t == 0) - assert(empty); - if (!empty) - do_check_tree(m, t); + int empty = (m->treemap & (1U << i)) == 0; + if (t == 0) assert(empty); + if (!empty) do_check_tree(m, t); + } /* Check all the chunks in a smallbin. */ static void do_check_smallbin(mstate m, bindex_t i) { - sbinptr b = smallbin_at(m, i); - mchunkptr p = b->bk; + + sbinptr b = smallbin_at(m, i); + mchunkptr p = b->bk; unsigned int empty = (m->smallmap & (1U << i)) == 0; - if (p == b) - assert(empty); + if (p == b) assert(empty); if (!empty) { + for (; p != b; p = p->bk) { - size_t size = chunksize(p); + + size_t size = chunksize(p); mchunkptr q; /* each chunk claims to be free */ do_check_free_chunk(m, p); @@ -3424,185 +3613,249 @@ static void do_check_smallbin(mstate m, bindex_t i) { assert(p->bk == b || chunksize(p->bk) == chunksize(p)); /* chunk is followed by an inuse chunk */ q = next_chunk(p); - if (q->head != FENCEPOST_HEAD) - do_check_inuse_chunk(m, q); + if (q->head != FENCEPOST_HEAD) do_check_inuse_chunk(m, q); + } + } + } /* Find x in a bin. Used in other check functions. */ static int bin_find(mstate m, mchunkptr x) { + size_t size = chunksize(x); if (is_small(size)) { + bindex_t sidx = small_index(size); - sbinptr b = smallbin_at(m, sidx); + sbinptr b = smallbin_at(m, sidx); if (smallmap_is_marked(m, sidx)) { + mchunkptr p = b; do { - if (p == x) - return 1; + + if (p == x) return 1; + } while ((p = p->fd) != b); + } - } - else { + + } else { + bindex_t tidx; compute_tree_index(size, tidx); if (treemap_is_marked(m, tidx)) { + tchunkptr t = *treebin_at(m, tidx); - size_t sizebits = size << leftshift_for_tree_index(tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); while (t != 0 && chunksize(t) != size) { - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + + t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; sizebits <<= 1; + } + if (t != 0) { + tchunkptr u = t; do { - if (u == (tchunkptr)x) - return 1; + + if (u == (tchunkptr)x) return 1; + } while ((u = u->fd) != t); + } + } + } + return 0; + } /* Traverse each chunk and check it; return total */ static size_t traverse_and_check(mstate m) { + size_t sum = 0; if (is_initialized(m)) { + msegmentptr s = &m->seg; sum += m->topsize + TOP_FOOT_SIZE; while (s != 0) { + mchunkptr q = align_as_chunk(s->base); mchunkptr lastq = 0; assert(pinuse(q)); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { + while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { + sum += chunksize(q); if (is_inuse(q)) { + assert(!bin_find(m, q)); do_check_inuse_chunk(m, q); - } - else { + + } else { + assert(q == m->dv || bin_find(m, q)); - assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ + assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ do_check_free_chunk(m, q); + } + lastq = q; q = next_chunk(q); + } + s = s->next; + } + } + return sum; -} +} /* Check all properties of malloc_state. */ static void do_check_malloc_state(mstate m) { + bindex_t i; - size_t total; + size_t total; /* check bins */ for (i = 0; i < NSMALLBINS; ++i) do_check_smallbin(m, i); for (i = 0; i < NTREEBINS; ++i) do_check_treebin(m, i); - if (m->dvsize != 0) { /* check dv chunk */ + if (m->dvsize != 0) { /* check dv chunk */ do_check_any_chunk(m, m->dv); assert(m->dvsize == chunksize(m->dv)); assert(m->dvsize >= MIN_CHUNK_SIZE); assert(bin_find(m, m->dv) == 0); + } - if (m->top != 0) { /* check top chunk */ + if (m->top != 0) { /* check top chunk */ do_check_top_chunk(m, m->top); /*assert(m->topsize == chunksize(m->top)); redundant */ assert(m->topsize > 0); assert(bin_find(m, m->top) == 0); + } total = traverse_and_check(m); assert(total <= m->footprint); assert(m->footprint <= m->max_footprint); + } -#endif /* DEBUG */ + +#endif /* DEBUG */ /* ----------------------------- statistics ------------------------------ */ #if !NO_MALLINFO static struct mallinfo internal_mallinfo(mstate m) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + struct mallinfo nm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; ensure_initialization(); if (!PREACTION(m)) { + check_malloc_state(m); if (is_initialized(m)) { - size_t nfree = SIZE_T_ONE; /* top always free */ - size_t mfree = m->topsize + TOP_FOOT_SIZE; - size_t sum = mfree; + + size_t nfree = SIZE_T_ONE; /* top always free */ + size_t mfree = m->topsize + TOP_FOOT_SIZE; + size_t sum = mfree; msegmentptr s = &m->seg; while (s != 0) { + mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { + while (segment_holds(s, q) && q != m->top && + q->head != FENCEPOST_HEAD) { + size_t sz = chunksize(q); sum += sz; if (!is_inuse(q)) { + mfree += sz; ++nfree; + } + q = next_chunk(q); + } + s = s->next; + } - nm.arena = sum; - nm.ordblks = nfree; - nm.hblkhd = m->footprint - sum; - nm.usmblks = m->max_footprint; + nm.arena = sum; + nm.ordblks = nfree; + nm.hblkhd = m->footprint - sum; + nm.usmblks = m->max_footprint; nm.uordblks = m->footprint - mfree; nm.fordblks = mfree; nm.keepcost = m->topsize; + } POSTACTION(m); + } + return nm; + } -#endif /* !NO_MALLINFO */ + +#endif /* !NO_MALLINFO */ #if !NO_MALLOC_STATS static void internal_malloc_stats(mstate m) { + ensure_initialization(); if (!PREACTION(m)) { + size_t maxfp = 0; size_t fp = 0; size_t used = 0; check_malloc_state(m); if (is_initialized(m)) { + msegmentptr s = &m->seg; maxfp = m->max_footprint; fp = m->footprint; used = fp - (m->topsize + TOP_FOOT_SIZE); while (s != 0) { + mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - if (!is_inuse(q)) - used -= chunksize(q); + while (segment_holds(s, q) && q != m->top && + q->head != FENCEPOST_HEAD) { + + if (!is_inuse(q)) used -= chunksize(q); q = next_chunk(q); + } + s = s->next; + } + } - POSTACTION(m); /* drop lock */ + + POSTACTION(m); /* drop lock */ fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); + } + } -#endif /* NO_MALLOC_STATS */ + +#endif /* NO_MALLOC_STATS */ /* ----------------------- Operations on smallbins ----------------------- */ @@ -3614,134 +3867,179 @@ static void internal_malloc_stats(mstate m) { */ /* Link a free chunk into a smallbin */ -#define insert_small_chunk(M, P, S) {\ - bindex_t I = small_index(S);\ - mchunkptr B = smallbin_at(M, I);\ - mchunkptr F = B;\ - assert(S >= MIN_CHUNK_SIZE);\ - if (!smallmap_is_marked(M, I))\ - mark_smallmap(M, I);\ - else if (RTCHECK(ok_address(M, B->fd)))\ - F = B->fd;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - B->fd = P;\ - F->bk = P;\ - P->fd = F;\ - P->bk = B;\ -} +#define insert_small_chunk(M, P, S) \ + { \ + \ + bindex_t I = small_index(S); \ + mchunkptr B = smallbin_at(M, I); \ + mchunkptr F = B; \ + assert(S >= MIN_CHUNK_SIZE); \ + if (!smallmap_is_marked(M, I)) \ + mark_smallmap(M, I); \ + else if (RTCHECK(ok_address(M, B->fd))) \ + F = B->fd; \ + else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + B->fd = P; \ + F->bk = P; \ + P->fd = F; \ + P->bk = B; \ + \ + } /* Unlink a chunk from a smallbin */ -#define unlink_small_chunk(M, P, S) {\ - mchunkptr F = P->fd;\ - mchunkptr B = P->bk;\ - bindex_t I = small_index(S);\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \ - if (B == F) {\ - clear_smallmap(M, I);\ - }\ - else if (RTCHECK(B == smallbin_at(M,I) ||\ - (ok_address(M, B) && B->fd == P))) {\ - F->bk = B;\ - B->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} +#define unlink_small_chunk(M, P, S) \ + { \ + \ + mchunkptr F = P->fd; \ + mchunkptr B = P->bk; \ + bindex_t I = small_index(S); \ + assert(P != B); \ + assert(P != F); \ + assert(chunksize(P) == small_index2size(I)); \ + if (RTCHECK(F == smallbin_at(M, I) || (ok_address(M, F) && F->bk == P))) { \ + \ + if (B == F) { \ + \ + clear_smallmap(M, I); \ + \ + } else if (RTCHECK(B == smallbin_at(M, I) || \ + (ok_address(M, B) && B->fd == P))) { \ + \ + F->bk = B; \ + B->fd = F; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } /* Unlink the first chunk from a smallbin */ -#define unlink_first_small_chunk(M, B, P, I) {\ - mchunkptr F = P->fd;\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (B == F) {\ - clear_smallmap(M, I);\ - }\ - else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\ - F->bk = B;\ - B->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} +#define unlink_first_small_chunk(M, B, P, I) \ + { \ + \ + mchunkptr F = P->fd; \ + assert(P != B); \ + assert(P != F); \ + assert(chunksize(P) == small_index2size(I)); \ + if (B == F) { \ + \ + clear_smallmap(M, I); \ + \ + } else if (RTCHECK(ok_address(M, F) && F->bk == P)) { \ + \ + F->bk = B; \ + B->fd = F; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } /* Replace dv node, binning the old one */ /* Used only when dvsize known to be small */ -#define replace_dv(M, P, S) {\ - size_t DVS = M->dvsize;\ - assert(is_small(DVS));\ - if (DVS != 0) {\ - mchunkptr DV = M->dv;\ - insert_small_chunk(M, DV, DVS);\ - }\ - M->dvsize = S;\ - M->dv = P;\ -} +#define replace_dv(M, P, S) \ + { \ + \ + size_t DVS = M->dvsize; \ + assert(is_small(DVS)); \ + if (DVS != 0) { \ + \ + mchunkptr DV = M->dv; \ + insert_small_chunk(M, DV, DVS); \ + \ + } \ + M->dvsize = S; \ + M->dv = P; \ + \ + } /* ------------------------- Operations on trees ------------------------- */ /* Insert chunk into tree */ -#define insert_large_chunk(M, X, S) {\ - tbinptr* H;\ - bindex_t I;\ - compute_tree_index(S, I);\ - H = treebin_at(M, I);\ - X->index = I;\ - X->child[0] = X->child[1] = 0;\ - if (!treemap_is_marked(M, I)) {\ - mark_treemap(M, I);\ - *H = X;\ - X->parent = (tchunkptr)H;\ - X->fd = X->bk = X;\ - }\ - else {\ - tchunkptr T = *H;\ - size_t K = S << leftshift_for_tree_index(I);\ - for (;;) {\ - if (chunksize(T) != S) {\ - tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ - K <<= 1;\ - if (*C != 0)\ - T = *C;\ - else if (RTCHECK(ok_address(M, C))) {\ - *C = X;\ - X->parent = T;\ - X->fd = X->bk = X;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - else {\ - tchunkptr F = T->fd;\ - if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ - T->fd = F->bk = X;\ - X->fd = F;\ - X->bk = T;\ - X->parent = 0;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - }\ - }\ -} +#define insert_large_chunk(M, X, S) \ + { \ + \ + tbinptr *H; \ + bindex_t I; \ + compute_tree_index(S, I); \ + H = treebin_at(M, I); \ + X->index = I; \ + X->child[0] = X->child[1] = 0; \ + if (!treemap_is_marked(M, I)) { \ + \ + mark_treemap(M, I); \ + *H = X; \ + X->parent = (tchunkptr)H; \ + X->fd = X->bk = X; \ + \ + } else { \ + \ + tchunkptr T = *H; \ + size_t K = S << leftshift_for_tree_index(I); \ + for (;;) { \ + \ + if (chunksize(T) != S) { \ + \ + tchunkptr *C = \ + &(T->child[(K >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]); \ + K <<= 1; \ + if (*C != 0) \ + T = *C; \ + else if (RTCHECK(ok_address(M, C))) { \ + \ + *C = X; \ + X->parent = T; \ + X->fd = X->bk = X; \ + break; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + break; \ + \ + } \ + \ + } else { \ + \ + tchunkptr F = T->fd; \ + if (RTCHECK(ok_address(M, T) && ok_address(M, F))) { \ + \ + T->fd = F->bk = X; \ + X->fd = F; \ + X->bk = T; \ + X->parent = 0; \ + break; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + break; \ + \ + } \ + \ + } \ + \ + } \ + \ + } \ + \ + } /* Unlink steps: @@ -3760,104 +4058,141 @@ static void internal_malloc_stats(mstate m) { x's parent and children to x's replacement (or null if none). */ -#define unlink_large_chunk(M, X) {\ - tchunkptr XP = X->parent;\ - tchunkptr R;\ - if (X->bk != X) {\ - tchunkptr F = X->fd;\ - R = X->bk;\ - if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) {\ - F->bk = R;\ - R->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else {\ - tchunkptr* RP;\ - if (((R = *(RP = &(X->child[1]))) != 0) ||\ - ((R = *(RP = &(X->child[0]))) != 0)) {\ - tchunkptr* CP;\ - while ((*(CP = &(R->child[1])) != 0) ||\ - (*(CP = &(R->child[0])) != 0)) {\ - R = *(RP = CP);\ - }\ - if (RTCHECK(ok_address(M, RP)))\ - *RP = 0;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - }\ - if (XP != 0) {\ - tbinptr* H = treebin_at(M, X->index);\ - if (X == *H) {\ - if ((*H = R) == 0) \ - clear_treemap(M, X->index);\ - }\ - else if (RTCHECK(ok_address(M, XP))) {\ - if (XP->child[0] == X) \ - XP->child[0] = R;\ - else \ - XP->child[1] = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - if (R != 0) {\ - if (RTCHECK(ok_address(M, R))) {\ - tchunkptr C0, C1;\ - R->parent = XP;\ - if ((C0 = X->child[0]) != 0) {\ - if (RTCHECK(ok_address(M, C0))) {\ - R->child[0] = C0;\ - C0->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - if ((C1 = X->child[1]) != 0) {\ - if (RTCHECK(ok_address(M, C1))) {\ - R->child[1] = C1;\ - C1->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ -} +#define unlink_large_chunk(M, X) \ + { \ + \ + tchunkptr XP = X->parent; \ + tchunkptr R; \ + if (X->bk != X) { \ + \ + tchunkptr F = X->fd; \ + R = X->bk; \ + if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) { \ + \ + F->bk = R; \ + R->fd = F; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } else { \ + \ + tchunkptr *RP; \ + if (((R = *(RP = &(X->child[1]))) != 0) || \ + ((R = *(RP = &(X->child[0]))) != 0)) { \ + \ + tchunkptr *CP; \ + while ((*(CP = &(R->child[1])) != 0) || \ + (*(CP = &(R->child[0])) != 0)) { \ + \ + R = *(RP = CP); \ + \ + } \ + if (RTCHECK(ok_address(M, RP))) \ + *RP = 0; \ + else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } \ + \ + } \ + if (XP != 0) { \ + \ + tbinptr *H = treebin_at(M, X->index); \ + if (X == *H) { \ + \ + if ((*H = R) == 0) clear_treemap(M, X->index); \ + \ + } else if (RTCHECK(ok_address(M, XP))) { \ + \ + if (XP->child[0] == X) \ + XP->child[0] = R; \ + else \ + XP->child[1] = R; \ + \ + } else \ + CORRUPTION_ERROR_ACTION(M); \ + if (R != 0) { \ + \ + if (RTCHECK(ok_address(M, R))) { \ + \ + tchunkptr C0, C1; \ + R->parent = XP; \ + if ((C0 = X->child[0]) != 0) { \ + \ + if (RTCHECK(ok_address(M, C0))) { \ + \ + R->child[0] = C0; \ + C0->parent = R; \ + \ + } else \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + if ((C1 = X->child[1]) != 0) { \ + \ + if (RTCHECK(ok_address(M, C1))) { \ + \ + R->child[1] = C1; \ + C1->parent = R; \ + \ + } else \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } else \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } \ + \ + } /* Relays to large vs small bin operations */ -#define insert_chunk(M, P, S)\ - if (is_small(S)) insert_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } - -#define unlink_chunk(M, P, S)\ - if (is_small(S)) unlink_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } +#define insert_chunk(M, P, S) \ + if (is_small(S)) insert_small_chunk(M, P, S) else { \ + \ + tchunkptr TP = (tchunkptr)(P); \ + insert_large_chunk(M, TP, S); \ + \ + } +#define unlink_chunk(M, P, S) \ + if (is_small(S)) unlink_small_chunk(M, P, S) else { \ + \ + tchunkptr TP = (tchunkptr)(P); \ + unlink_large_chunk(M, TP); \ + \ + } /* Relays to internal calls to malloc/free from realloc, memalign etc */ #if ONLY_MSPACES -#define internal_malloc(m, b) mspace_malloc(m, b) -#define internal_free(m, mem) mspace_free(m,mem); -#else /* ONLY_MSPACES */ -#if MSPACES -#define internal_malloc(m, b)\ - ((m == gm)? dlmalloc(b) : mspace_malloc(m, b)) -#define internal_free(m, mem)\ - if (m == gm) dlfree(mem); else mspace_free(m,mem); -#else /* MSPACES */ -#define internal_malloc(m, b) dlmalloc(b) -#define internal_free(m, mem) dlfree(mem) -#endif /* MSPACES */ -#endif /* ONLY_MSPACES */ + #define internal_malloc(m, b) mspace_malloc(m, b) + #define internal_free(m, mem) mspace_free(m, mem); +#else /* ONLY_MSPACES */ + #if MSPACES + #define internal_malloc(m, b) \ + ((m == gm) ? dlmalloc(b) : mspace_malloc(m, b)) + #define internal_free(m, mem) \ + if (m == gm) \ + dlfree(mem); \ + else \ + mspace_free(m, mem); + #else /* MSPACES */ + #define internal_malloc(m, b) dlmalloc(b) + #define internal_free(m, mem) dlfree(mem) + #endif /* MSPACES */ +#endif /* ONLY_MSPACES */ /* ----------------------- Direct-mmapping chunks ----------------------- */ @@ -3870,80 +4205,93 @@ static void internal_malloc_stats(mstate m) { */ /* Malloc using mmap */ -static void* mmap_alloc(mstate m, size_t nb) { +static void *mmap_alloc(mstate m, size_t nb) { + size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); if (m->footprint_limit != 0) { + size_t fp = m->footprint + mmsize; - if (fp <= m->footprint || fp > m->footprint_limit) - return 0; + if (fp <= m->footprint || fp > m->footprint_limit) return 0; + } - if (mmsize > nb) { /* Check for wrap around 0 */ - char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); + + if (mmsize > nb) { /* Check for wrap around 0 */ + char *mm = (char *)(CALL_DIRECT_MMAP(mmsize)); if (mm != CMFAIL) { - size_t offset = align_offset(chunk2mem(mm)); - size_t psize = mmsize - offset - MMAP_FOOT_PAD; + + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - MMAP_FOOT_PAD; mchunkptr p = (mchunkptr)(mm + offset); p->prev_foot = offset; p->head = psize; mark_inuse_foot(m, p, psize); chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; + chunk_plus_offset(p, psize + SIZE_T_SIZE)->head = 0; - if (m->least_addr == 0 || mm < m->least_addr) - m->least_addr = mm; + if (m->least_addr == 0 || mm < m->least_addr) m->least_addr = mm; if ((m->footprint += mmsize) > m->max_footprint) m->max_footprint = m->footprint; assert(is_aligned(chunk2mem(p))); check_mmapped_chunk(m, p); return chunk2mem(p); + } + } + return 0; + } /* Realloc using mmap */ static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) { + size_t oldsize = chunksize(oldp); - (void)flags; /* placate people compiling -Wunused */ - if (is_small(nb)) /* Can't shrink mmap regions below small size */ + (void)flags; /* placate people compiling -Wunused */ + if (is_small(nb)) /* Can't shrink mmap regions below small size */ return 0; /* Keep old chunk if big enough but not too big */ if (oldsize >= nb + SIZE_T_SIZE && (oldsize - nb) <= (mparams.granularity << 1)) return oldp; else { + size_t offset = oldp->prev_foot; size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - char* cp = (char*)CALL_MREMAP((char*)oldp - offset, - oldmmsize, newmmsize, flags); + char * cp = + (char *)CALL_MREMAP((char *)oldp - offset, oldmmsize, newmmsize, flags); if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); - size_t psize = newmmsize - offset - MMAP_FOOT_PAD; + size_t psize = newmmsize - offset - MMAP_FOOT_PAD; newp->head = psize; mark_inuse_foot(m, newp, psize); chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; + chunk_plus_offset(newp, psize + SIZE_T_SIZE)->head = 0; - if (cp < m->least_addr) - m->least_addr = cp; + if (cp < m->least_addr) m->least_addr = cp; if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) m->max_footprint = m->footprint; check_mmapped_chunk(m, newp); return newp; + } + } + return 0; -} +} /* -------------------------- mspace management -------------------------- */ /* Initialize top chunk and its size */ static void init_top(mstate m, mchunkptr p, size_t psize) { + /* Ensure alignment */ size_t offset = align_offset(chunk2mem(p)); - p = (mchunkptr)((char*)p + offset); + p = (mchunkptr)((char *)p + offset); psize -= offset; m->top = p; @@ -3951,23 +4299,29 @@ static void init_top(mstate m, mchunkptr p, size_t psize) { p->head = psize | PINUSE_BIT; /* set size of fake trailing chunk holding overhead space only once */ chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; - m->trim_check = mparams.trim_threshold; /* reset on each update */ + m->trim_check = mparams.trim_threshold; /* reset on each update */ + } /* Initialize bins for a new mstate that is otherwise zeroed out */ static void init_bins(mstate m) { + /* Establish circular links for smallbins */ bindex_t i; for (i = 0; i < NSMALLBINS; ++i) { - sbinptr bin = smallbin_at(m,i); + + sbinptr bin = smallbin_at(m, i); bin->fd = bin->bk = bin; + } + } #if PROCEED_ON_ERROR /* default corruption action */ static void reset_on_error(mstate m) { + int i; ++malloc_corruption_error_count; /* Reinitialize fields to forget about all memory */ @@ -3980,67 +4334,78 @@ static void reset_on_error(mstate m) { for (i = 0; i < NTREEBINS; ++i) *treebin_at(m, i) = 0; init_bins(m); + } -#endif /* PROCEED_ON_ERROR */ + +#endif /* PROCEED_ON_ERROR */ /* Allocate chunk and prepend remainder with chunk in successor base. */ -static void* prepend_alloc(mstate m, char* newbase, char* oldbase, - size_t nb) { +static void *prepend_alloc(mstate m, char *newbase, char *oldbase, size_t nb) { + mchunkptr p = align_as_chunk(newbase); mchunkptr oldfirst = align_as_chunk(oldbase); - size_t psize = (char*)oldfirst - (char*)p; + size_t psize = (char *)oldfirst - (char *)p; mchunkptr q = chunk_plus_offset(p, nb); - size_t qsize = psize - nb; + size_t qsize = psize - nb; set_size_and_pinuse_of_inuse_chunk(m, p, nb); - assert((char*)oldfirst > (char*)q); + assert((char *)oldfirst > (char *)q); assert(pinuse(oldfirst)); assert(qsize >= MIN_CHUNK_SIZE); /* consolidate remainder with first chunk of old base */ if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; m->top = q; q->head = tsize | PINUSE_BIT; check_top_chunk(m, q); - } - else if (oldfirst == m->dv) { + + } else if (oldfirst == m->dv) { + size_t dsize = m->dvsize += qsize; m->dv = q; set_size_and_pinuse_of_free_chunk(q, dsize); - } - else { + + } else { + if (!is_inuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); unlink_chunk(m, oldfirst, nsize); oldfirst = chunk_plus_offset(oldfirst, nsize); qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); insert_chunk(m, q, qsize); check_free_chunk(m, q); + } check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); + } /* Add a segment to hold a new noncontiguous region */ -static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { +static void add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped) { + /* Determine locations and sizes of segment, fenceposts, old top */ - char* old_top = (char*)m->top; + char * old_top = (char *)m->top; msegmentptr oldsp = segment_holding(m, old_top); - char* old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request(sizeof(struct malloc_segment)); - char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset(chunk2mem(rawsp)); - char* asp = rawsp + offset; - char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; - mchunkptr sp = (mchunkptr)csp; + char * old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char * rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char * asp = rawsp + offset; + char * csp = (asp < (old_top + MIN_CHUNK_SIZE)) ? old_top : asp; + mchunkptr sp = (mchunkptr)csp; msegmentptr ss = (msegmentptr)(chunk2mem(sp)); - mchunkptr tnext = chunk_plus_offset(sp, ssize); - mchunkptr p = tnext; - int nfences = 0; + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + int nfences = 0; /* reset top to new space */ init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); @@ -4048,7 +4413,7 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { /* Set up segment record */ assert(is_aligned(ss)); set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); - *ss = m->seg; /* Push current record */ + *ss = m->seg; /* Push current record */ m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmapped; @@ -4056,53 +4421,61 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { /* Insert trailing fenceposts */ for (;;) { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); p->head = FENCEPOST_HEAD; ++nfences; - if ((char*)(&(nextp->head)) < old_end) + if ((char *)(&(nextp->head)) < old_end) p = nextp; else break; + } + assert(nfences >= 2); /* Insert the rest of old top into a bin as an ordinary free chunk */ if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; - size_t psize = csp - old_top; + size_t psize = csp - old_top; mchunkptr tn = chunk_plus_offset(q, psize); set_free_with_pinuse(q, psize, tn); insert_chunk(m, q, psize); + } check_top_chunk(m, m->top); + } /* -------------------------- System allocation -------------------------- */ /* Get memory from system using MORECORE or MMAP */ -static void* sys_alloc(mstate m, size_t nb) { - char* tbase = CMFAIL; +static void *sys_alloc(mstate m, size_t nb) { + + char * tbase = CMFAIL; size_t tsize = 0; flag_t mmap_flag = 0; - size_t asize; /* allocation size */ + size_t asize; /* allocation size */ ensure_initialization(); /* Directly map large chunks, but only if already initialized */ if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { - void* mem = mmap_alloc(m, nb); - if (mem != 0) - return mem; + + void *mem = mmap_alloc(m, nb); + if (mem != 0) return mem; + } asize = granularity_align(nb + SYS_ALLOC_PADDING); - if (asize <= nb) - return 0; /* wraparound */ + if (asize <= nb) return 0; /* wraparound */ if (m->footprint_limit != 0) { + size_t fp = m->footprint + asize; - if (fp <= m->footprint || fp > m->footprint_limit) - return 0; + if (fp <= m->footprint || fp > m->footprint_limit) return 0; + } /* @@ -4128,91 +4501,119 @@ static void* sys_alloc(mstate m, size_t nb) { */ if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { - char* br = CMFAIL; - size_t ssize = asize; /* sbrk call size */ - msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); + + char * br = CMFAIL; + size_t ssize = asize; /* sbrk call size */ + msegmentptr ss = (m->top == 0) ? 0 : segment_holding(m, (char *)m->top); ACQUIRE_MALLOC_GLOBAL_LOCK(); - if (ss == 0) { /* First time through or recovery */ - char* base = (char*)CALL_MORECORE(0); + if (ss == 0) { /* First time through or recovery */ + char *base = (char *)CALL_MORECORE(0); if (base != CMFAIL) { + size_t fp; /* Adjust to end on a page boundary */ if (!is_page_aligned(base)) ssize += (page_align((size_t)base) - (size_t)base); - fp = m->footprint + ssize; /* recheck limits */ + fp = m->footprint + ssize; /* recheck limits */ if (ssize > nb && ssize < HALF_MAX_SIZE_T && (m->footprint_limit == 0 || (fp > m->footprint && fp <= m->footprint_limit)) && - (br = (char*)(CALL_MORECORE(ssize))) == base) { + (br = (char *)(CALL_MORECORE(ssize))) == base) { + tbase = base; tsize = ssize; + } + } - } - else { + + } else { + /* Subtract out existing available top space from MORECORE request. */ ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); /* Use mem here only if it did continuously extend old space */ if (ssize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) { + (br = (char *)(CALL_MORECORE(ssize))) == ss->base + ss->size) { + tbase = br; tsize = ssize; + } + } - if (tbase == CMFAIL) { /* Cope with partial failure */ - if (br != CMFAIL) { /* Try to use/extend the space we did get */ - if (ssize < HALF_MAX_SIZE_T && - ssize < nb + SYS_ALLOC_PADDING) { + if (tbase == CMFAIL) { /* Cope with partial failure */ + if (br != CMFAIL) { /* Try to use/extend the space we did get */ + if (ssize < HALF_MAX_SIZE_T && ssize < nb + SYS_ALLOC_PADDING) { + size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize); if (esize < HALF_MAX_SIZE_T) { - char* end = (char*)CALL_MORECORE(esize); + + char *end = (char *)CALL_MORECORE(esize); if (end != CMFAIL) ssize += esize; - else { /* Can't use; try to release */ - (void) CALL_MORECORE(-ssize); + else { /* Can't use; try to release */ + (void)CALL_MORECORE(-ssize); br = CMFAIL; + } + } + } + } - if (br != CMFAIL) { /* Use the space we did get */ + + if (br != CMFAIL) { /* Use the space we did get */ tbase = br; tsize = ssize; - } - else - disable_contiguous(m); /* Don't try contiguous path in the future */ + + } else + + disable_contiguous(m); /* Don't try contiguous path in the future */ + } RELEASE_MALLOC_GLOBAL_LOCK(); + } - if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ - char* mp = (char*)(CALL_MMAP(asize)); + if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ + char *mp = (char *)(CALL_MMAP(asize)); if (mp != CMFAIL) { + tbase = mp; tsize = asize; mmap_flag = USE_MMAP_BIT; + } + } - if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ + if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ if (asize < HALF_MAX_SIZE_T) { - char* br = CMFAIL; - char* end = CMFAIL; + + char *br = CMFAIL; + char *end = CMFAIL; ACQUIRE_MALLOC_GLOBAL_LOCK(); - br = (char*)(CALL_MORECORE(asize)); - end = (char*)(CALL_MORECORE(0)); + br = (char *)(CALL_MORECORE(asize)); + end = (char *)(CALL_MORECORE(0)); RELEASE_MALLOC_GLOBAL_LOCK(); if (br != CMFAIL && end != CMFAIL && br < end) { + size_t ssize = end - br; if (ssize > nb + TOP_FOOT_SIZE) { + tbase = br; tsize = ssize; + } + } + } + } if (tbase != CMFAIL) { @@ -4220,9 +4621,8 @@ static void* sys_alloc(mstate m, size_t nb) { if ((m->footprint += tsize) > m->max_footprint) m->max_footprint = m->footprint; - if (!is_initialized(m)) { /* first-time initialization */ - if (m->least_addr == 0 || tbase < m->least_addr) - m->least_addr = tbase; + if (!is_initialized(m)) { /* first-time initialization */ + if (m->least_addr == 0 || tbase < m->least_addr) m->least_addr = tbase; m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmap_flag; @@ -4235,46 +4635,52 @@ static void* sys_alloc(mstate m, size_t nb) { else #endif { + /* Offset top by embedded malloc_state */ mchunkptr mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); + init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); + } + } else { + /* Try to merge with an existing segment */ msegmentptr sp = &m->seg; /* Only consider most recent segment if traversal suppressed */ while (sp != 0 && tbase != sp->base + sp->size) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; - if (sp != 0 && - !is_extern_segment(sp) && + if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag && - segment_holds(sp, m->top)) { /* append */ + segment_holds(sp, m->top)) { /* append */ sp->size += tsize; init_top(m, m->top, m->topsize + tsize); - } - else { - if (tbase < m->least_addr) - m->least_addr = tbase; + + } else { + + if (tbase < m->least_addr) m->least_addr = tbase; sp = &m->seg; while (sp != 0 && sp->base != tbase + tsize) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; - if (sp != 0 && - !is_extern_segment(sp) && + if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag) { - char* oldbase = sp->base; + + char *oldbase = sp->base; sp->base = tbase; sp->size += tsize; return prepend_alloc(m, tbase, oldbase, nb); - } - else + + } else + add_segment(m, tbase, tsize, mmap_flag); + } + } - if (nb < m->topsize) { /* Allocate from new or extended top space */ - size_t rsize = m->topsize -= nb; + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; mchunkptr p = m->top; mchunkptr r = m->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -4282,313 +4688,421 @@ static void* sys_alloc(mstate m, size_t nb) { check_top_chunk(m, m->top); check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); + } + } MALLOC_FAILURE_ACTION; return 0; + } /* ----------------------- system deallocation -------------------------- */ /* Unmap and unlink any mmapped segments that don't contain used chunks */ static size_t release_unused_segments(mstate m) { - size_t released = 0; - int nsegs = 0; + + size_t released = 0; + int nsegs = 0; msegmentptr pred = &m->seg; msegmentptr sp = pred->next; while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; + + char * base = sp->base; + size_t size = sp->size; msegmentptr next = sp->next; ++nsegs; if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { + mchunkptr p = align_as_chunk(base); - size_t psize = chunksize(p); + size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ - if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { + if (!is_inuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; - assert(segment_holds(sp, (char*)sp)); + assert(segment_holds(sp, (char *)sp)); if (p == m->dv) { + m->dv = 0; m->dvsize = 0; - } - else { + + } else { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; m->footprint -= size; /* unlink obsoleted record */ sp = pred; sp->next = next; - } - else { /* back out if cannot unmap */ + + } else { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } + } - if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ + + if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ break; pred = sp; sp = next; + } + /* Reset check counter */ - m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)? - (size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE); + m->release_checks = (((size_t)nsegs > (size_t)MAX_RELEASE_CHECK_RATE) + ? (size_t)nsegs + : (size_t)MAX_RELEASE_CHECK_RATE); return released; + } static int sys_trim(mstate m, size_t pad) { + size_t released = 0; ensure_initialization(); if (pad < MAX_REQUEST && is_initialized(m)) { - pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ size_t unit = mparams.granularity; - size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding(m, (char*)m->top); + size_t extra = + ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char *)m->top); if (!is_extern_segment(sp)) { + if (is_mmapped_segment(sp)) { - if (HAVE_MMAP && - sp->size >= extra && - !has_segment_link(m, sp)) { /* can't shrink if pinned */ + + if (HAVE_MMAP && sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ size_t newsize = sp->size - extra; - (void)newsize; /* placate people compiling -Wunused-variable */ + (void)newsize; /* placate people compiling -Wunused-variable */ /* Prefer mremap, fall back to munmap */ if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { + released = extra; + } + } - } - else if (HAVE_MORECORE) { - if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ - extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; + + } else if (HAVE_MORECORE) { + + if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ + extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; ACQUIRE_MALLOC_GLOBAL_LOCK(); { + /* Make sure end of memory is where we last set it. */ - char* old_br = (char*)(CALL_MORECORE(0)); + char *old_br = (char *)(CALL_MORECORE(0)); if (old_br == sp->base + sp->size) { - char* rel_br = (char*)(CALL_MORECORE(-extra)); - char* new_br = (char*)(CALL_MORECORE(0)); + + char *rel_br = (char *)(CALL_MORECORE(-extra)); + char *new_br = (char *)(CALL_MORECORE(0)); if (rel_br != CMFAIL && new_br < old_br) released = old_br - new_br; + } + } + RELEASE_MALLOC_GLOBAL_LOCK(); + } + } if (released != 0) { + sp->size -= released; m->footprint -= released; init_top(m, m->top, m->topsize - released); check_top_chunk(m, m->top); + } + } /* Unmap any unused mmapped segments */ - if (HAVE_MMAP) - released += release_unused_segments(m); + if (HAVE_MMAP) released += release_unused_segments(m); /* On failure, disable autotrim to avoid repeated failed future calls */ - if (released == 0 && m->topsize > m->trim_check) - m->trim_check = MAX_SIZE_T; + if (released == 0 && m->topsize > m->trim_check) m->trim_check = MAX_SIZE_T; + } - return (released != 0)? 1 : 0; + return (released != 0) ? 1 : 0; + } /* Consolidate and bin a chunk. Differs from exported versions of free mainly in that the chunk need not be marked as inuse. */ static void dispose_chunk(mstate m, mchunkptr p, size_t psize) { + mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { + mchunkptr prev; - size_t prevsize = p->prev_foot; + size_t prevsize = p->prev_foot; if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - m->footprint -= psize; + if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) m->footprint -= psize; return; + } + prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ if (p != m->dv) { + unlink_chunk(m, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { + + } else if ((next->head & INUSE_BITS) == INUSE_BITS) { + m->dvsize = psize; set_free_with_pinuse(p, psize, next); return; + } - } - else { + + } else { + CORRUPTION_ERROR_ACTION(m); return; + } + } + if (RTCHECK(ok_address(m, next))) { - if (!cinuse(next)) { /* consolidate forward */ + + if (!cinuse(next)) { /* consolidate forward */ if (next == m->top) { + size_t tsize = m->topsize += psize; m->top = p; p->head = tsize | PINUSE_BIT; if (p == m->dv) { + m->dv = 0; m->dvsize = 0; + } + return; - } - else if (next == m->dv) { + + } else if (next == m->dv) { + size_t dsize = m->dvsize += psize; m->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); return; - } - else { + + } else { + size_t nsize = chunksize(next); psize += nsize; unlink_chunk(m, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == m->dv) { + m->dvsize = psize; return; + } + } - } - else { + + } else { + set_free_with_pinuse(p, psize, next); + } + insert_chunk(m, p, psize); - } - else { + + } else { + CORRUPTION_ERROR_ACTION(m); + } + } /* ---------------------------- malloc --------------------------- */ /* allocate a large request from the best fitting chunk in a treebin */ -static void* tmalloc_large(mstate m, size_t nb) { +static void *tmalloc_large(mstate m, size_t nb) { + tchunkptr v = 0; - size_t rsize = -nb; /* Unsigned negation */ + size_t rsize = -nb; /* Unsigned negation */ tchunkptr t; - bindex_t idx; + bindex_t idx; compute_tree_index(nb, idx); if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index(idx); - tchunkptr rst = 0; /* The deepest untaken right subtree */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ for (;;) { + tchunkptr rt; - size_t trem = chunksize(t) - nb; + size_t trem = chunksize(t) - nb; if (trem < rsize) { + v = t; - if ((rsize = trem) == 0) - break; + if ((rsize = trem) == 0) break; + } + rt = t->child[1]; - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - if (rt != 0 && rt != t) - rst = rt; + t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) rst = rt; if (t == 0) { - t = rst; /* set t to least subtree holding sizes > nb */ + + t = rst; /* set t to least subtree holding sizes > nb */ break; + } + sizebits <<= 1; + } + } - if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; if (leftbits != 0) { + bindex_t i; binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); t = *treebin_at(m, i); + } + } - while (t != 0) { /* find smallest of tree or subtree */ + while (t != 0) { /* find smallest of tree or subtree */ size_t trem = chunksize(t) - nb; if (trem < rsize) { + rsize = trem; v = t; + } + t = leftmost_child(t); + } /* If dv is a better fit, return 0 so malloc will use it */ if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { - if (RTCHECK(ok_address(m, v))) { /* split */ + + if (RTCHECK(ok_address(m, v))) { /* split */ mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } + } + CORRUPTION_ERROR_ACTION(m); + } + return 0; + } /* allocate a small request from the best fitting chunk in a treebin */ -static void* tmalloc_small(mstate m, size_t nb) { +static void *tmalloc_small(mstate m, size_t nb) { + tchunkptr t, v; - size_t rsize; - bindex_t i; - binmap_t leastbit = least_bit(m->treemap); + size_t rsize; + bindex_t i; + binmap_t leastbit = least_bit(m->treemap); compute_bit2idx(leastbit, i); v = t = *treebin_at(m, i); rsize = chunksize(t) - nb; while ((t = leftmost_child(t)) != 0) { + size_t trem = chunksize(t) - nb; if (trem < rsize) { + rsize = trem; v = t; + } + } if (RTCHECK(ok_address(m, v))) { + mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(m, r, rsize); + } + return chunk2mem(v); + } + } CORRUPTION_ERROR_ACTION(m); return 0; + } #if !ONLY_MSPACES -void* dlmalloc(size_t bytes) { +void *dlmalloc(size_t bytes) { + /* Basic algorithm: If a small request (< 256 bytes minus per-chunk overhead): @@ -4612,23 +5126,25 @@ void* dlmalloc(size_t bytes) { The ugly goto's here ensure that postaction occurs along all paths. */ -#if USE_LOCKS - ensure_initialization(); /* initialize in sys_alloc if not using locks */ -#endif + #if USE_LOCKS + ensure_initialization(); /* initialize in sys_alloc if not using locks */ + #endif if (!PREACTION(gm)) { - void* mem; + + void * mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = gm->smallmap >> idx; - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ + idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(gm, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); @@ -4637,15 +5153,17 @@ void* dlmalloc(size_t bytes) { mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; + } else if (nb > gm->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(gm, i); p = b->fd; @@ -4656,54 +5174,71 @@ void* dlmalloc(size_t bytes) { if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(gm, p, small_index2size(i)); else { + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(gm, r, rsize); + } + mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; + } else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); goto postaction; + } + } - } - else if (bytes >= MAX_REQUEST) + + } else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { + nb = pad_request(bytes); if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); goto postaction; + } + } if (nb <= gm->dvsize) { - size_t rsize = gm->dvsize - nb; + + size_t rsize = gm->dvsize - nb; mchunkptr p = gm->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = gm->dv = chunk_plus_offset(p, nb); gm->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - } - else { /* exhaust dv */ + + } else { /* exhaust dv */ + size_t dvs = gm->dvsize; gm->dvsize = 0; gm->dv = 0; set_inuse_and_pinuse(gm, p, dvs); + } + mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; + } - else if (nb < gm->topsize) { /* Split top */ - size_t rsize = gm->topsize -= nb; + else if (nb < gm->topsize) { /* Split top */ + size_t rsize = gm->topsize -= nb; mchunkptr p = gm->top; mchunkptr r = gm->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -4712,6 +5247,7 @@ void* dlmalloc(size_t bytes) { check_top_chunk(gm, gm->top); check_malloced_chunk(gm, mem, nb); goto postaction; + } mem = sys_alloc(gm, nb); @@ -4719,14 +5255,17 @@ void* dlmalloc(size_t bytes) { postaction: POSTACTION(gm); return mem; + } return 0; + } /* ---------------------------- free --------------------------- */ -void dlfree(void* mem) { +void dlfree(void *mem) { + /* Consolidate freed chunks with preceeding or succeeding bordering free chunks, if they exist, and then place in a bin. Intermixed @@ -4734,164 +5273,216 @@ void dlfree(void* mem) { */ if (mem != 0) { - mchunkptr p = mem2chunk(mem); -#if FOOTERS + + mchunkptr p = mem2chunk(mem); + #if FOOTERS mstate fm = get_mstate_for(p); if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); return; + } -#else /* FOOTERS */ -#define fm gm -#endif /* FOOTERS */ + + #else /* FOOTERS */ + #define fm gm + #endif /* FOOTERS */ if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { - size_t psize = chunksize(p); + + size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { + size_t prevsize = p->prev_foot; if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; - } - else { + + } else { + mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { + + } else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; + } - } - else + + } else + goto erroraction; + } + } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ + + if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { + size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { + fm->dv = 0; fm->dvsize = 0; + } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); + + if (should_trim(fm, tsize)) sys_trim(fm, 0); goto postaction; - } - else if (next == fm->dv) { + + } else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; - } - else { + + } else { + size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { + fm->dvsize = psize; goto postaction; + } + } - } - else + + } else + set_free_with_pinuse(p, psize, next); if (is_small(psize)) { + insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); - } - else { + + } else { + tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); - if (--fm->release_checks == 0) - release_unused_segments(fm); + if (--fm->release_checks == 0) release_unused_segments(fm); + } + goto postaction; + } + } + erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); + } + } -#if !FOOTERS -#undef fm -#endif /* FOOTERS */ + + #if !FOOTERS + #undef fm + #endif /* FOOTERS */ + } -void* dlcalloc(size_t n_elements, size_t elem_size) { - void* mem; +void *dlcalloc(size_t n_elements, size_t elem_size) { + + void * mem; size_t req = 0; if (n_elements != 0) { + req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = dlmalloc(req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) __builtin_memset(mem, 0, req); return mem; + } -#endif /* !ONLY_MSPACES */ +#endif /* !ONLY_MSPACES */ /* ------------ Internal support for realloc, memalign, etc -------------- */ /* Try to realloc; only in-place unless can_move true */ static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, int can_move) { + mchunkptr newp = 0; - size_t oldsize = chunksize(p); + size_t oldsize = chunksize(p); mchunkptr next = chunk_plus_offset(p, oldsize); - if (RTCHECK(ok_address(m, p) && ok_inuse(p) && - ok_next(p, next) && ok_pinuse(next))) { + if (RTCHECK(ok_address(m, p) && ok_inuse(p) && ok_next(p, next) && + ok_pinuse(next))) { + if (is_mmapped(p)) { + newp = mmap_resize(m, p, nb, can_move); - } - else if (oldsize >= nb) { /* already big enough */ + + } else if (oldsize >= nb) { /* already big enough */ + size_t rsize = oldsize - nb; - if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ + if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); + } + newp = p; - } - else if (next == m->top) { /* extend into top */ + + } else if (next == m->top) { /* extend into top */ + if (oldsize + m->topsize > nb) { - size_t newsize = oldsize + m->topsize; - size_t newtopsize = newsize - nb; + + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; mchunkptr newtop = chunk_plus_offset(p, nb); set_inuse(m, p, nb); - newtop->head = newtopsize |PINUSE_BIT; + newtop->head = newtopsize | PINUSE_BIT; m->top = newtop; m->topsize = newtopsize; newp = p; + } - } - else if (next == m->dv) { /* extend into dv */ + + } else if (next == m->dv) { /* extend into dv */ + size_t dvs = m->dvsize; if (oldsize + dvs >= nb) { + size_t dsize = oldsize + dvs - nb; if (dsize >= MIN_CHUNK_SIZE) { + mchunkptr r = chunk_plus_offset(p, nb); mchunkptr n = chunk_plus_offset(r, dsize); set_inuse(m, p, nb); @@ -4899,64 +5490,87 @@ static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, clear_pinuse(n); m->dvsize = dsize; m->dv = r; - } - else { /* exhaust dv */ + + } else { /* exhaust dv */ + size_t newsize = oldsize + dvs; set_inuse(m, p, newsize); m->dvsize = 0; m->dv = 0; + } + newp = p; + } - } - else if (!cinuse(next)) { /* extend into next free chunk */ + + } else if (!cinuse(next)) { /* extend into next free chunk */ + size_t nextsize = chunksize(next); if (oldsize + nextsize >= nb) { + size_t rsize = oldsize + nextsize - nb; unlink_chunk(m, next, nextsize); if (rsize < MIN_CHUNK_SIZE) { + size_t newsize = oldsize + nextsize; set_inuse(m, p, newsize); - } - else { + + } else { + mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); + } + newp = p; + } + } - } - else { + + } else { + USAGE_ERROR_ACTION(m, chunk2mem(p)); + } + return newp; + } -static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { - void* mem = 0; - if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ +static void *internal_memalign(mstate m, size_t alignment, size_t bytes) { + + void *mem = 0; + if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ alignment = MIN_CHUNK_SIZE; - if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ + if ((alignment & (alignment - SIZE_T_ONE)) != 0) { /* Ensure a power of 2 */ size_t a = MALLOC_ALIGNMENT << 1; - while (a < alignment) a <<= 1; + while (a < alignment) + a <<= 1; alignment = a; + } + if (bytes >= MAX_REQUEST - alignment) { - if (m != 0) { /* Test isn't needed but avoids compiler warning */ + + if (m != 0) { /* Test isn't needed but avoids compiler warning */ MALLOC_FAILURE_ACTION; + } - } - else { + + } else { + size_t nb = request2size(bytes); size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; mem = internal_malloc(m, req); if (mem != 0) { + mchunkptr p = mem2chunk(mem); - if (PREACTION(m)) - return 0; - if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ + if (PREACTION(m)) return 0; + if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ /* Find an aligned spot inside chunk. Since we need to give back leading space in a chunk of at least MIN_CHUNK_SIZE, if @@ -4965,47 +5579,59 @@ static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { We've allocated enough total room so that this is always possible. */ - char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment - - SIZE_T_ONE)) & - -alignment)); - char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? - br : br+alignment; + char * br = (char *)mem2chunk((size_t)( + ((size_t)((char *)mem + alignment - SIZE_T_ONE)) & -alignment)); + char * pos = ((size_t)(br - (char *)(p)) >= MIN_CHUNK_SIZE) + ? br + : br + alignment; mchunkptr newp = (mchunkptr)pos; - size_t leadsize = pos - (char*)(p); - size_t newsize = chunksize(p) - leadsize; + size_t leadsize = pos - (char *)(p); + size_t newsize = chunksize(p) - leadsize; - if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ newp->prev_foot = p->prev_foot + leadsize; newp->head = newsize; - } - else { /* Otherwise, give back leader, use the rest */ + + } else { /* Otherwise, give back leader, use the rest */ + set_inuse(m, newp, newsize); set_inuse(m, p, leadsize); dispose_chunk(m, p, leadsize); + } + p = newp; + } /* Give back spare room at the end */ if (!is_mmapped(p)) { + size_t size = chunksize(p); if (size > nb + MIN_CHUNK_SIZE) { - size_t remainder_size = size - nb; + + size_t remainder_size = size - nb; mchunkptr remainder = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, remainder, remainder_size); dispose_chunk(m, remainder, remainder_size); + } + } mem = chunk2mem(p); - assert (chunksize(p) >= nb); + assert(chunksize(p) >= nb); assert(((size_t)mem & (alignment - 1)) == 0); check_inuse_chunk(m, p); POSTACTION(m); + } + } + return mem; + } /* @@ -5015,50 +5641,50 @@ static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { bit 0 set if all elements are same size (using sizes[0]) bit 1 set if elements should be zeroed */ -static void** ialloc(mstate m, - size_t n_elements, - size_t* sizes, - int opts, - void* chunks[]) { - - size_t element_size; /* chunksize of each element, if all same */ - size_t contents_size; /* total size of elements */ - size_t array_size; /* request size of pointer array */ - void* mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - size_t remainder_size; /* remaining bytes while splitting */ - void** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - flag_t was_enabled; /* to disable mmap */ +static void **ialloc(mstate m, size_t n_elements, size_t *sizes, int opts, + void *chunks[]) { + + size_t element_size; /* chunksize of each element, if all same */ + size_t contents_size; /* total size of elements */ + size_t array_size; /* request size of pointer array */ + void * mem; /* malloced aggregate space */ + mchunkptr p; /* corresponding chunk */ + size_t remainder_size; /* remaining bytes while splitting */ + void ** marray; /* either "chunks" or malloced ptr array */ + mchunkptr array_chunk; /* chunk for malloced ptr array */ + flag_t was_enabled; /* to disable mmap */ size_t size; size_t i; ensure_initialization(); /* compute array length, if needed */ if (chunks != 0) { - if (n_elements == 0) - return chunks; /* nothing to do */ + + if (n_elements == 0) return chunks; /* nothing to do */ marray = chunks; array_size = 0; - } - else { + + } else { + /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) - return (void**)internal_malloc(m, 0); + if (n_elements == 0) return (void **)internal_malloc(m, 0); marray = 0; - array_size = request2size(n_elements * (sizeof(void*))); + array_size = request2size(n_elements * (sizeof(void *))); + } /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ + if (opts & 0x1) { /* all-same-size */ element_size = request2size(*sizes); contents_size = n_elements * element_size; - } - else { /* add up all the sizes */ + + } else { /* add up all the sizes */ + element_size = 0; contents_size = 0; for (i = 0; i != n_elements; ++i) contents_size += request2size(sizes[i]); + } size = contents_size + array_size; @@ -5071,10 +5697,8 @@ static void** ialloc(mstate m, was_enabled = use_mmap(m); disable_mmap(m); mem = internal_malloc(m, size - CHUNK_OVERHEAD); - if (was_enabled) - enable_mmap(m); - if (mem == 0) - return 0; + if (was_enabled) enable_mmap(m); + if (mem == 0) return 0; if (PREACTION(m)) return 0; p = mem2chunk(mem); @@ -5082,24 +5706,30 @@ static void** ialloc(mstate m, assert(!is_mmapped(p)); - if (opts & 0x2) { /* optionally clear the elements */ - __builtin_memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); + if (opts & 0x2) { /* optionally clear the elements */ + __builtin_memset((size_t *)mem, 0, + remainder_size - SIZE_T_SIZE - array_size); + } /* If not provided, allocate the pointer array as final part of chunk */ if (marray == 0) { - size_t array_chunk_size; + + size_t array_chunk_size; array_chunk = chunk_plus_offset(p, contents_size); array_chunk_size = remainder_size - contents_size; - marray = (void**) (chunk2mem(array_chunk)); + marray = (void **)(chunk2mem(array_chunk)); set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); remainder_size = contents_size; + } /* split out elements */ - for (i = 0; ; ++i) { + for (i = 0;; ++i) { + marray[i] = chunk2mem(p); - if (i != n_elements-1) { + if (i != n_elements - 1) { + if (element_size != 0) size = element_size; else @@ -5107,31 +5737,42 @@ static void** ialloc(mstate m, remainder_size -= size; set_size_and_pinuse_of_inuse_chunk(m, p, size); p = chunk_plus_offset(p, size); - } - else { /* the final element absorbs any overallocation slop */ + + } else { /* the final element absorbs any overallocation slop */ + set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); break; + } + } #if DEBUG if (marray != chunks) { + /* final element must have exactly exhausted chunk */ if (element_size != 0) { + assert(remainder_size == element_size); - } - else { + + } else { + assert(remainder_size == request2size(sizes[i])); + } + check_inuse_chunk(m, mem2chunk(marray)); + } + for (i = 0; i != n_elements; ++i) check_inuse_chunk(m, mem2chunk(marray[i])); -#endif /* DEBUG */ +#endif /* DEBUG */ POSTACTION(m); return marray; + } /* Try to free all pointers in the given array. @@ -5141,316 +5782,431 @@ static void** ialloc(mstate m, chunks before freeing, which will occur often if allocated with ialloc or the array is sorted. */ -static size_t internal_bulk_free(mstate m, void* array[], size_t nelem) { +static size_t internal_bulk_free(mstate m, void *array[], size_t nelem) { + size_t unfreed = 0; if (!PREACTION(m)) { - void** a; - void** fence = &(array[nelem]); + + void **a; + void **fence = &(array[nelem]); for (a = array; a != fence; ++a) { - void* mem = *a; + + void *mem = *a; if (mem != 0) { + mchunkptr p = mem2chunk(mem); - size_t psize = chunksize(p); + size_t psize = chunksize(p); #if FOOTERS if (get_mstate_for(p) != m) { + ++unfreed; continue; + } + #endif check_inuse_chunk(m, p); *a = 0; if (RTCHECK(ok_address(m, p) && ok_inuse(p))) { - void ** b = a + 1; /* try to merge with next chunk */ + + void ** b = a + 1; /* try to merge with next chunk */ mchunkptr next = next_chunk(p); if (b != fence && *b == chunk2mem(next)) { + size_t newsize = chunksize(next) + psize; set_inuse(m, p, newsize); *b = chunk2mem(p); - } - else + + } else + dispose_chunk(m, p, psize); - } - else { + + } else { + CORRUPTION_ERROR_ACTION(m); break; + } + } + } - if (should_trim(m, m->topsize)) - sys_trim(m, 0); + + if (should_trim(m, m->topsize)) sys_trim(m, 0); POSTACTION(m); + } + return unfreed; + } /* Traversal */ #if MALLOC_INSPECT_ALL static void internal_inspect_all(mstate m, - void(*handler)(void *start, - void *end, - size_t used_bytes, - void* callback_arg), - void* arg) { + void (*handler)(void *start, void *end, + size_t used_bytes, + void * callback_arg), + void *arg) { + if (is_initialized(m)) { - mchunkptr top = m->top; + + mchunkptr top = m->top; msegmentptr s; for (s = &m->seg; s != 0; s = s->next) { + mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) { + mchunkptr next = next_chunk(q); - size_t sz = chunksize(q); - size_t used; - void* start; + size_t sz = chunksize(q); + size_t used; + void * start; if (is_inuse(q)) { - used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ + + used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ start = chunk2mem(q); - } - else { + + } else { + used = 0; - if (is_small(sz)) { /* offset by possible bookkeeping */ - start = (void*)((char*)q + sizeof(struct malloc_chunk)); - } - else { - start = (void*)((char*)q + sizeof(struct malloc_tree_chunk)); + if (is_small(sz)) { /* offset by possible bookkeeping */ + start = (void *)((char *)q + sizeof(struct malloc_chunk)); + + } else { + + start = (void *)((char *)q + sizeof(struct malloc_tree_chunk)); + } + } - if (start < (void*)next) /* skip if all space is bookkeeping */ + + if (start < (void *)next) /* skip if all space is bookkeeping */ handler(start, next, used, arg); - if (q == top) - break; + if (q == top) break; q = next; + } + } + } + } -#endif /* MALLOC_INSPECT_ALL */ + +#endif /* MALLOC_INSPECT_ALL */ /* ------------------ Exported realloc, memalign, etc -------------------- */ #if !ONLY_MSPACES -void* dlrealloc(void* oldmem, size_t bytes) { - void* mem = 0; +void *dlrealloc(void *oldmem, size_t bytes) { + + void *mem = 0; if (oldmem == 0) { + mem = dlmalloc(bytes); - } - else if (bytes >= MAX_REQUEST) { + + } else if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } -#ifdef REALLOC_ZERO_BYTES_FREES + + #ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { + dlfree(oldmem); + } -#endif /* REALLOC_ZERO_BYTES_FREES */ + + #endif /* REALLOC_ZERO_BYTES_FREES */ else { - size_t nb = request2size(bytes); + + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); -#if ! FOOTERS + #if !FOOTERS mstate m = gm; -#else /* FOOTERS */ + #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; + } -#endif /* FOOTERS */ + + #endif /* FOOTERS */ if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { + check_inuse_chunk(m, newp); mem = chunk2mem(newp); - } - else { + + } else { + mem = internal_malloc(m, bytes); if (mem != 0) { + size_t oc = chunksize(oldp) - overhead_for(oldp); - __builtin_memcpy(mem, oldmem, (oc < bytes)? oc : bytes); + __builtin_memcpy(mem, oldmem, (oc < bytes) ? oc : bytes); internal_free(m, oldmem); + } + } + } + } + return mem; + } -void* dlrealloc_in_place(void* oldmem, size_t bytes) { - void* mem = 0; +void *dlrealloc_in_place(void *oldmem, size_t bytes) { + + void *mem = 0; if (oldmem != 0) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; - } - else { - size_t nb = request2size(bytes); + + } else { + + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); -#if ! FOOTERS + #if !FOOTERS mstate m = gm; -#else /* FOOTERS */ + #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; + } -#endif /* FOOTERS */ + + #endif /* FOOTERS */ if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { + check_inuse_chunk(m, newp); mem = oldmem; + } + } + } + } + return mem; + } -void* dlmemalign(size_t alignment, size_t bytes) { - if (alignment <= MALLOC_ALIGNMENT) { - return dlmalloc(bytes); - } +void *dlmemalign(size_t alignment, size_t bytes) { + + if (alignment <= MALLOC_ALIGNMENT) { return dlmalloc(bytes); } return internal_memalign(gm, alignment, bytes); + } -int dlposix_memalign(void** pp, size_t alignment, size_t bytes) { - void* mem = 0; +int dlposix_memalign(void **pp, size_t alignment, size_t bytes) { + + void *mem = 0; if (alignment == MALLOC_ALIGNMENT) mem = dlmalloc(bytes); else { - size_t d = alignment / sizeof(void*); - size_t r = alignment % sizeof(void*); - if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0) + + size_t d = alignment / sizeof(void *); + size_t r = alignment % sizeof(void *); + if (r != 0 || d == 0 || (d & (d - SIZE_T_ONE)) != 0) return EINVAL; else if (bytes <= MAX_REQUEST - alignment) { - if (alignment < MIN_CHUNK_SIZE) - alignment = MIN_CHUNK_SIZE; + + if (alignment < MIN_CHUNK_SIZE) alignment = MIN_CHUNK_SIZE; mem = internal_memalign(gm, alignment, bytes); + } + } + if (mem == 0) return ENOMEM; else { + *pp = mem; return 0; + } + } -void* dlvalloc(size_t bytes) { +void *dlvalloc(size_t bytes) { + size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; return dlmemalign(pagesz, bytes); + } -void* dlpvalloc(size_t bytes) { +void *dlpvalloc(size_t bytes) { + size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; - return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); + return dlmemalign(pagesz, + (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); + } -void** dlindependent_calloc(size_t n_elements, size_t elem_size, - void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ +void **dlindependent_calloc(size_t n_elements, size_t elem_size, + void *chunks[]) { + + size_t sz = elem_size; /* serves as 1-element array */ return ialloc(gm, n_elements, &sz, 3, chunks); + } -void** dlindependent_comalloc(size_t n_elements, size_t sizes[], - void* chunks[]) { +void **dlindependent_comalloc(size_t n_elements, size_t sizes[], + void *chunks[]) { + return ialloc(gm, n_elements, sizes, 0, chunks); + } -size_t dlbulk_free(void* array[], size_t nelem) { +size_t dlbulk_free(void *array[], size_t nelem) { + return internal_bulk_free(gm, array, nelem); + } -#if MALLOC_INSPECT_ALL -void dlmalloc_inspect_all(void(*handler)(void *start, - void *end, - size_t used_bytes, - void* callback_arg), - void* arg) { + #if MALLOC_INSPECT_ALL +void dlmalloc_inspect_all(void (*handler)(void *start, void *end, + size_t used_bytes, + void * callback_arg), + void *arg) { + ensure_initialization(); if (!PREACTION(gm)) { + internal_inspect_all(gm, handler, arg); POSTACTION(gm); + } + } -#endif /* MALLOC_INSPECT_ALL */ + + #endif /* MALLOC_INSPECT_ALL */ int dlmalloc_trim(size_t pad) { + int result = 0; ensure_initialization(); if (!PREACTION(gm)) { + result = sys_trim(gm, pad); POSTACTION(gm); + } + return result; + } size_t dlmalloc_footprint(void) { + return gm->footprint; + } size_t dlmalloc_max_footprint(void) { + return gm->max_footprint; + } size_t dlmalloc_footprint_limit(void) { + size_t maf = gm->footprint_limit; return maf == 0 ? MAX_SIZE_T : maf; + } size_t dlmalloc_set_footprint_limit(size_t bytes) { - size_t result; /* invert sense of 0 */ - if (bytes == 0) - result = granularity_align(1); /* Use minimal size */ + + size_t result; /* invert sense of 0 */ + if (bytes == 0) result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) - result = 0; /* disable */ + result = 0; /* disable */ else result = granularity_align(bytes); return gm->footprint_limit = result; + } -#if !NO_MALLINFO + #if !NO_MALLINFO struct mallinfo dlmallinfo(void) { + return internal_mallinfo(gm); + } -#endif /* NO_MALLINFO */ -#if !NO_MALLOC_STATS + #endif /* NO_MALLINFO */ + + #if !NO_MALLOC_STATS void dlmalloc_stats() { + internal_malloc_stats(gm); + } -#endif /* NO_MALLOC_STATS */ + + #endif /* NO_MALLOC_STATS */ int dlmallopt(int param_number, int value) { + return change_mparam(param_number, value); + } -size_t dlmalloc_usable_size(void* mem) { +size_t dlmalloc_usable_size(void *mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); - if (is_inuse(p)) - return chunksize(p) - overhead_for(p); + if (is_inuse(p)) return chunksize(p) - overhead_for(p); + } + return 0; + } -#endif /* !ONLY_MSPACES */ +#endif /* !ONLY_MSPACES */ /* ----------------------------- user mspaces ---------------------------- */ #if MSPACES -static mstate init_user_mstate(char* tbase, size_t tsize) { - size_t msize = pad_request(sizeof(struct malloc_state)); +static mstate init_user_mstate(char *tbase, size_t tsize) { + + size_t msize = pad_request(sizeof(struct malloc_state)); mchunkptr mn; mchunkptr msp = align_as_chunk(tbase); - mstate m = (mstate)(chunk2mem(msp)); + mstate m = (mstate)(chunk2mem(msp)); __builtin_memset(m, 0, msize); (void)INITIAL_LOCK(&m->mutex); - msp->head = (msize|INUSE_BITS); + msp->head = (msize | INUSE_BITS); m->seg.base = m->least_addr = tbase; m->seg.size = m->footprint = m->max_footprint = tsize; m->magic = mparams.magic; @@ -5461,82 +6217,111 @@ static mstate init_user_mstate(char* tbase, size_t tsize) { disable_contiguous(m); init_bins(m); mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); + init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); check_top_chunk(m, m->top); return m; + } mspace create_mspace(size_t capacity, int locked) { + mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); - if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - size_t rs = ((capacity == 0)? mparams.granularity : - (capacity + TOP_FOOT_SIZE + msize)); + if (capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { + + size_t rs = ((capacity == 0) ? mparams.granularity + : (capacity + TOP_FOOT_SIZE + msize)); size_t tsize = granularity_align(rs); - char* tbase = (char*)(CALL_MMAP(tsize)); + char * tbase = (char *)(CALL_MMAP(tsize)); if (tbase != CMFAIL) { + m = init_user_mstate(tbase, tsize); m->seg.sflags = USE_MMAP_BIT; set_lock(m, locked); + } + } + return (mspace)m; + } -mspace create_mspace_with_base(void* base, size_t capacity, int locked) { +mspace create_mspace_with_base(void *base, size_t capacity, int locked) { + mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); if (capacity > msize + TOP_FOOT_SIZE && - capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - m = init_user_mstate((char*)base, capacity); + capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { + + m = init_user_mstate((char *)base, capacity); m->seg.sflags = EXTERN_BIT; set_lock(m, locked); + } + return (mspace)m; + } int mspace_track_large_chunks(mspace msp, int enable) { - int ret = 0; + + int ret = 0; mstate ms = (mstate)msp; if (!PREACTION(ms)) { - if (!use_mmap(ms)) { - ret = 1; - } + + if (!use_mmap(ms)) { ret = 1; } if (!enable) { + enable_mmap(ms); + } else { + disable_mmap(ms); + } + POSTACTION(ms); + } + return ret; + } size_t destroy_mspace(mspace msp) { + size_t freed = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + msegmentptr sp = &ms->seg; - (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ + (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ while (sp != 0) { - char* base = sp->base; + + char * base = sp->base; size_t size = sp->size; flag_t flag = sp->sflags; - (void)base; /* placate people compiling -Wunused-variable */ + (void)base; /* placate people compiling -Wunused-variable */ sp = sp->next; if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && CALL_MUNMAP(base, size) == 0) freed += size; + } + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return freed; + } /* @@ -5544,25 +6329,31 @@ size_t destroy_mspace(mspace msp) { versions. This is not so nice but better than the alternatives. */ -void* mspace_malloc(mspace msp, size_t bytes) { +void *mspace_malloc(mspace msp, size_t bytes) { + mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } + if (!PREACTION(ms)) { - void* mem; + + void * mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = ms->smallmap >> idx; - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ + idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(ms, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); @@ -5571,15 +6362,17 @@ void* mspace_malloc(mspace msp, size_t bytes) { mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; + } else if (nb > ms->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(ms, i); p = b->fd; @@ -5590,54 +6383,71 @@ void* mspace_malloc(mspace msp, size_t bytes) { if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(ms, p, small_index2size(i)); else { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; + } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); goto postaction; + } + } - } - else if (bytes >= MAX_REQUEST) + + } else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { + nb = pad_request(bytes); if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); goto postaction; + } + } if (nb <= ms->dvsize) { - size_t rsize = ms->dvsize - nb; + + size_t rsize = ms->dvsize - nb; mchunkptr p = ms->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = ms->dv = chunk_plus_offset(p, nb); ms->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - } - else { /* exhaust dv */ + + } else { /* exhaust dv */ + size_t dvs = ms->dvsize; ms->dvsize = 0; ms->dv = 0; set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; + } - else if (nb < ms->topsize) { /* Split top */ - size_t rsize = ms->topsize -= nb; + else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; mchunkptr p = ms->top; mchunkptr r = ms->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -5646,6 +6456,7 @@ void* mspace_malloc(mspace msp, size_t bytes) { check_top_chunk(ms, ms->top); check_malloced_chunk(ms, mem, nb); goto postaction; + } mem = sys_alloc(ms, nb); @@ -5653,372 +6464,519 @@ void* mspace_malloc(mspace msp, size_t bytes) { postaction: POSTACTION(ms); return mem; + } return 0; + } -void mspace_free(mspace msp, void* mem) { +void mspace_free(mspace msp, void *mem) { + if (mem != 0) { - mchunkptr p = mem2chunk(mem); -#if FOOTERS + + mchunkptr p = mem2chunk(mem); + #if FOOTERS mstate fm = get_mstate_for(p); - (void)msp; /* placate people compiling -Wunused */ -#else /* FOOTERS */ + (void)msp; /* placate people compiling -Wunused */ + #else /* FOOTERS */ mstate fm = (mstate)msp; -#endif /* FOOTERS */ + #endif /* FOOTERS */ if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); return; + } + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { - size_t psize = chunksize(p); + + size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { + size_t prevsize = p->prev_foot; if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; - } - else { + + } else { + mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { + + } else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; + } - } - else + + } else + goto erroraction; + } + } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ + + if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { + size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { + fm->dv = 0; fm->dvsize = 0; + } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); + + if (should_trim(fm, tsize)) sys_trim(fm, 0); goto postaction; - } - else if (next == fm->dv) { + + } else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; - } - else { + + } else { + size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { + fm->dvsize = psize; goto postaction; + } + } - } - else + + } else + set_free_with_pinuse(p, psize, next); if (is_small(psize)) { + insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); - } - else { + + } else { + tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); - if (--fm->release_checks == 0) - release_unused_segments(fm); + if (--fm->release_checks == 0) release_unused_segments(fm); + } + goto postaction; + } + } + erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); + } + } + } -void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { - void* mem; +void *mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { + + void * mem; size_t req = 0; mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } + if (n_elements != 0) { + req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = internal_malloc(ms, req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) __builtin_memset(mem, 0, req); return mem; + } -void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { - void* mem = 0; +void *mspace_realloc(mspace msp, void *oldmem, size_t bytes) { + + void *mem = 0; if (oldmem == 0) { + mem = mspace_malloc(msp, bytes); - } - else if (bytes >= MAX_REQUEST) { + + } else if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } -#ifdef REALLOC_ZERO_BYTES_FREES + + #ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { + mspace_free(msp, oldmem); + } -#endif /* REALLOC_ZERO_BYTES_FREES */ + + #endif /* REALLOC_ZERO_BYTES_FREES */ else { - size_t nb = request2size(bytes); + + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); -#if ! FOOTERS + #if !FOOTERS mstate m = (mstate)msp; -#else /* FOOTERS */ + #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; + } -#endif /* FOOTERS */ + + #endif /* FOOTERS */ if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { + check_inuse_chunk(m, newp); mem = chunk2mem(newp); - } - else { + + } else { + mem = mspace_malloc(m, bytes); if (mem != 0) { + size_t oc = chunksize(oldp) - overhead_for(oldp); - __builtin_memcpy(mem, oldmem, (oc < bytes)? oc : bytes); + __builtin_memcpy(mem, oldmem, (oc < bytes) ? oc : bytes); mspace_free(m, oldmem); + } + } + } + } + return mem; + } -void* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) { - void* mem = 0; +void *mspace_realloc_in_place(mspace msp, void *oldmem, size_t bytes) { + + void *mem = 0; if (oldmem != 0) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; - } - else { - size_t nb = request2size(bytes); + + } else { + + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); -#if ! FOOTERS + #if !FOOTERS mstate m = (mstate)msp; -#else /* FOOTERS */ + #else /* FOOTERS */ mstate m = get_mstate_for(oldp); - (void)msp; /* placate people compiling -Wunused */ + (void)msp; /* placate people compiling -Wunused */ if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; + } -#endif /* FOOTERS */ + + #endif /* FOOTERS */ if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { + check_inuse_chunk(m, newp); mem = oldmem; + } + } + } + } + return mem; + } -void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { +void *mspace_memalign(mspace msp, size_t alignment, size_t bytes) { + mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } - if (alignment <= MALLOC_ALIGNMENT) - return mspace_malloc(msp, bytes); + + if (alignment <= MALLOC_ALIGNMENT) return mspace_malloc(msp, bytes); return internal_memalign(ms, alignment, bytes); + } -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ +void **mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void *chunks[]) { + + size_t sz = elem_size; /* serves as 1-element array */ mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } + return ialloc(ms, n_elements, &sz, 3, chunks); + } -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]) { +void **mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void *chunks[]) { + mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } + return ialloc(ms, n_elements, sizes, 0, chunks); + } -size_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) { +size_t mspace_bulk_free(mspace msp, void *array[], size_t nelem) { + return internal_bulk_free((mstate)msp, array, nelem); + } -#if MALLOC_INSPECT_ALL + #if MALLOC_INSPECT_ALL void mspace_inspect_all(mspace msp, - void(*handler)(void *start, - void *end, - size_t used_bytes, - void* callback_arg), - void* arg) { + void (*handler)(void *start, void *end, + size_t used_bytes, void *callback_arg), + void *arg) { + mstate ms = (mstate)msp; if (ok_magic(ms)) { + if (!PREACTION(ms)) { + internal_inspect_all(ms, handler, arg); POSTACTION(ms); + } + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + } -#endif /* MALLOC_INSPECT_ALL */ + + #endif /* MALLOC_INSPECT_ALL */ int mspace_trim(mspace msp, size_t pad) { - int result = 0; + + int result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + if (!PREACTION(ms)) { + result = sys_trim(ms, pad); POSTACTION(ms); + } + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } -#if !NO_MALLOC_STATS + #if !NO_MALLOC_STATS void mspace_malloc_stats(mspace msp) { + mstate ms = (mstate)msp; if (ok_magic(ms)) { + internal_malloc_stats(ms); + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + } -#endif /* NO_MALLOC_STATS */ + + #endif /* NO_MALLOC_STATS */ size_t mspace_footprint(mspace msp) { + size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + result = ms->footprint; + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } size_t mspace_max_footprint(mspace msp) { + size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + result = ms->max_footprint; + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } size_t mspace_footprint_limit(mspace msp) { + size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + size_t maf = ms->footprint_limit; result = (maf == 0) ? MAX_SIZE_T : maf; + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } size_t mspace_set_footprint_limit(mspace msp, size_t bytes) { + size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { - if (bytes == 0) - result = granularity_align(1); /* Use minimal size */ + + if (bytes == 0) result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) - result = 0; /* disable */ + result = 0; /* disable */ else result = granularity_align(bytes); ms->footprint_limit = result; + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } -#if !NO_MALLINFO + #if !NO_MALLINFO struct mallinfo mspace_mallinfo(mspace msp) { + mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - } + if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms, ms); } return internal_mallinfo(ms); + } -#endif /* NO_MALLINFO */ -size_t mspace_usable_size(const void* mem) { + #endif /* NO_MALLINFO */ + +size_t mspace_usable_size(const void *mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); - if (is_inuse(p)) - return chunksize(p) - overhead_for(p); + if (is_inuse(p)) return chunksize(p) - overhead_for(p); + } + return 0; + } int mspace_mallopt(int param_number, int value) { + return change_mparam(param_number, value); -} -#endif /* MSPACES */ +} +#endif /* MSPACES */ /* -------------------- Alternative MORECORE functions ------------------- */ @@ -6063,35 +7021,48 @@ int mspace_mallopt(int param_number, int value) { void *osMoreCore(int size) { + void *ptr = 0; static void *sbrk_top = 0; if (size > 0) { + if (size < MINIMUM_MORECORE_SIZE) size = MINIMUM_MORECORE_SIZE; if (CurrentExecutionLevel() == kTaskLevel) ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); if (ptr == 0) { + return (void *) MFAIL; + } + // save ptrs so they can be freed during cleanup our_os_pools[next_os_pool] = ptr; next_os_pool++; ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); sbrk_top = (char *) ptr + size; return ptr; + } + else if (size < 0) { + // we don't currently support shrink behavior return (void *) MFAIL; + } + else { + return sbrk_top; + } + } // cleanup any allocated memory pools @@ -6099,19 +7070,22 @@ int mspace_mallopt(int param_number, int value) { void osCleanupMem(void) { + void **ptr; for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) if (*ptr) { + PoolDeallocate(*ptr); *ptr = 0; + } + } */ - /* ----------------------------------------------------------------------- History: v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea @@ -6330,3 +7304,4 @@ History: structure of old version, but most details differ.) */ + diff --git a/qemu_mode/libqasan/hooks.c b/qemu_mode/libqasan/hooks.c index b1ee2e0e..3bb4cc42 100644 --- a/qemu_mode/libqasan/hooks.c +++ b/qemu_mode/libqasan/hooks.c @@ -306,6 +306,7 @@ void bzero(void *s, size_t n) { __libqasan_memset(s, 0, n); } + #endif void explicit_bzero(void *s, size_t n) { diff --git a/qemu_mode/libqasan/libqasan.h b/qemu_mode/libqasan/libqasan.h index 0761e157..43b7adb5 100644 --- a/qemu_mode/libqasan/libqasan.h +++ b/qemu_mode/libqasan/libqasan.h @@ -54,28 +54,29 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } while (0) #ifdef DEBUG -#define QASAN_DEBUG(msg...) \ - do { \ - \ - if (__qasan_debug) { \ - \ - fprintf(stderr, "==%d== ", getpid()); \ - fprintf(stderr, msg); \ - \ - } \ - \ - } while (0) + #define QASAN_DEBUG(msg...) \ + do { \ + \ + if (__qasan_debug) { \ + \ + fprintf(stderr, "==%d== ", getpid()); \ + fprintf(stderr, msg); \ + \ + } \ + \ + } while (0) + #else -#define QASAN_DEBUG(msg...) \ - do { \ - \ - } while (0) + #define QASAN_DEBUG(msg...) \ + do { \ + \ + } while (0) #endif #define ASSERT_DLSYM(name) \ ({ \ \ - void* a = (void*)dlsym(RTLD_NEXT, #name); \ + void *a = (void *)dlsym(RTLD_NEXT, #name); \ if (!a) { \ \ fprintf(stderr, \ @@ -95,37 +96,37 @@ void __libqasan_init_malloc(void); void __libqasan_hotpatch(void); -size_t __libqasan_malloc_usable_size(void* ptr); -void* __libqasan_malloc(size_t size); -void __libqasan_free(void* ptr); -void* __libqasan_calloc(size_t nmemb, size_t size); -void* __libqasan_realloc(void* ptr, size_t size); -int __libqasan_posix_memalign(void** ptr, size_t align, size_t len); -void* __libqasan_memalign(size_t align, size_t len); -void* __libqasan_aligned_alloc(size_t align, size_t len); - -void* __libqasan_memcpy(void* dest, const void* src, size_t n); -void* __libqasan_memmove(void* dest, const void* src, size_t n); -void* __libqasan_memset(void* s, int c, size_t n); -void* __libqasan_memchr(const void* s, int c, size_t n); -void* __libqasan_memrchr(const void* s, int c, size_t n); -size_t __libqasan_strlen(const char* s); -size_t __libqasan_strnlen(const char* s, size_t len); -int __libqasan_strcmp(const char* str1, const char* str2); -int __libqasan_strncmp(const char* str1, const char* str2, size_t len); -int __libqasan_strcasecmp(const char* str1, const char* str2); -int __libqasan_strncasecmp(const char* str1, const char* str2, size_t len); -int __libqasan_memcmp(const void* mem1, const void* mem2, size_t len); -int __libqasan_bcmp(const void* mem1, const void* mem2, size_t len); -char* __libqasan_strstr(const char* haystack, const char* needle); -char* __libqasan_strcasestr(const char* haystack, const char* needle); -void* __libqasan_memmem(const void* haystack, size_t haystack_len, - const void* needle, size_t needle_len); -char* __libqasan_strchr(const char* s, int c); -char* __libqasan_strrchr(const char* s, int c); -size_t __libqasan_wcslen(const wchar_t* s); -wchar_t* __libqasan_wcscpy(wchar_t* d, const wchar_t* s); -int __libqasan_wcscmp(const wchar_t* s1, const wchar_t* s2); +size_t __libqasan_malloc_usable_size(void *ptr); +void * __libqasan_malloc(size_t size); +void __libqasan_free(void *ptr); +void * __libqasan_calloc(size_t nmemb, size_t size); +void * __libqasan_realloc(void *ptr, size_t size); +int __libqasan_posix_memalign(void **ptr, size_t align, size_t len); +void * __libqasan_memalign(size_t align, size_t len); +void * __libqasan_aligned_alloc(size_t align, size_t len); + +void * __libqasan_memcpy(void *dest, const void *src, size_t n); +void * __libqasan_memmove(void *dest, const void *src, size_t n); +void * __libqasan_memset(void *s, int c, size_t n); +void * __libqasan_memchr(const void *s, int c, size_t n); +void * __libqasan_memrchr(const void *s, int c, size_t n); +size_t __libqasan_strlen(const char *s); +size_t __libqasan_strnlen(const char *s, size_t len); +int __libqasan_strcmp(const char *str1, const char *str2); +int __libqasan_strncmp(const char *str1, const char *str2, size_t len); +int __libqasan_strcasecmp(const char *str1, const char *str2); +int __libqasan_strncasecmp(const char *str1, const char *str2, size_t len); +int __libqasan_memcmp(const void *mem1, const void *mem2, size_t len); +int __libqasan_bcmp(const void *mem1, const void *mem2, size_t len); +char * __libqasan_strstr(const char *haystack, const char *needle); +char * __libqasan_strcasestr(const char *haystack, const char *needle); +void * __libqasan_memmem(const void *haystack, size_t haystack_len, + const void *needle, size_t needle_len); +char * __libqasan_strchr(const char *s, int c); +char * __libqasan_strrchr(const char *s, int c); +size_t __libqasan_wcslen(const wchar_t *s); +wchar_t *__libqasan_wcscpy(wchar_t *d, const wchar_t *s); +int __libqasan_wcscmp(const wchar_t *s1, const wchar_t *s2); #endif diff --git a/qemu_mode/libqasan/malloc.c b/qemu_mode/libqasan/malloc.c index a53dbb4b..f8237826 100644 --- a/qemu_mode/libqasan/malloc.c +++ b/qemu_mode/libqasan/malloc.c @@ -50,9 +50,9 @@ typedef struct { struct chunk_begin { size_t requested_size; - void* aligned_orig; // NULL if not aligned - struct chunk_begin* next; - struct chunk_begin* prev; + void * aligned_orig; // NULL if not aligned + struct chunk_begin *next; + struct chunk_begin *prev; char redzone[REDZONE_SIZE]; }; @@ -66,29 +66,29 @@ struct chunk_struct { }; // From dlmalloc.c -void* dlmalloc(size_t); -void dlfree(void*); +void *dlmalloc(size_t); +void dlfree(void *); int __libqasan_malloc_initialized; -static struct chunk_begin* quarantine_top; -static struct chunk_begin* quarantine_end; +static struct chunk_begin *quarantine_top; +static struct chunk_begin *quarantine_end; static size_t quarantine_bytes; #ifdef __BIONIC__ -static pthread_mutex_t quarantine_lock; -#define LOCK_TRY pthread_mutex_trylock -#define LOCK_INIT pthread_mutex_init -#define LOCK_UNLOCK pthread_mutex_unlock +static pthread_mutex_t quarantine_lock; + #define LOCK_TRY pthread_mutex_trylock + #define LOCK_INIT pthread_mutex_init + #define LOCK_UNLOCK pthread_mutex_unlock #else -static pthread_spinlock_t quarantine_lock; -#define LOCK_TRY pthread_spin_trylock -#define LOCK_INIT pthread_spin_init -#define LOCK_UNLOCK pthread_spin_unlock +static pthread_spinlock_t quarantine_lock; + #define LOCK_TRY pthread_spin_trylock + #define LOCK_INIT pthread_spin_init + #define LOCK_UNLOCK pthread_spin_unlock #endif // need qasan disabled -static int quanratine_push(struct chunk_begin* ck) { +static int quanratine_push(struct chunk_begin *ck) { if (ck->requested_size >= QUARANTINE_MAX_BYTES) return 0; @@ -96,7 +96,7 @@ static int quanratine_push(struct chunk_begin* ck) { while (ck->requested_size + quarantine_bytes >= QUARANTINE_MAX_BYTES) { - struct chunk_begin* tmp = quarantine_end; + struct chunk_begin *tmp = quarantine_end; quarantine_end = tmp->prev; quarantine_bytes -= tmp->requested_size; @@ -131,29 +131,24 @@ void __libqasan_init_malloc(void) { } -size_t __libqasan_malloc_usable_size(void* ptr) { +size_t __libqasan_malloc_usable_size(void *ptr) { - char* p = ptr; + char *p = ptr; p -= sizeof(struct chunk_begin); - return ((struct chunk_begin*)p)->requested_size; + return ((struct chunk_begin *)p)->requested_size; } -void* __libqasan_malloc(size_t size) { +void *__libqasan_malloc(size_t size) { - if (!__libqasan_malloc_initialized) { - - __libqasan_init_malloc(); + if (!__libqasan_malloc_initialized) { __libqasan_init_malloc(); } - } - - if (!__libqasan_malloc_initialized) - __libqasan_init_malloc(); + if (!__libqasan_malloc_initialized) __libqasan_init_malloc(); int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread - struct chunk_begin* p = dlmalloc(sizeof(struct chunk_struct) + size); + struct chunk_begin *p = dlmalloc(sizeof(struct chunk_struct) + size); QASAN_SWAP(state); @@ -165,14 +160,14 @@ void* __libqasan_malloc(size_t size) { p->aligned_orig = NULL; p->next = p->prev = NULL; - QASAN_ALLOC(&p[1], (char*)&p[1] + size); + QASAN_ALLOC(&p[1], (char *)&p[1] + size); QASAN_POISON(p->redzone, REDZONE_SIZE, ASAN_HEAP_LEFT_RZ); if (size & (ALLOC_ALIGN_SIZE - 1)) - QASAN_POISON((char*)&p[1] + size, + QASAN_POISON((char *)&p[1] + size, (size & ~(ALLOC_ALIGN_SIZE - 1)) + 8 - size + REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); else - QASAN_POISON((char*)&p[1] + size, REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); + QASAN_POISON((char *)&p[1] + size, REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); __builtin_memset(&p[1], 0xff, size); @@ -180,11 +175,11 @@ void* __libqasan_malloc(size_t size) { } -void __libqasan_free(void* ptr) { +void __libqasan_free(void *ptr) { if (!ptr) return; - struct chunk_begin* p = ptr; + struct chunk_begin *p = ptr; p -= 1; size_t n = p->requested_size; @@ -211,11 +206,11 @@ void __libqasan_free(void* ptr) { } -void* __libqasan_calloc(size_t nmemb, size_t size) { +void *__libqasan_calloc(size_t nmemb, size_t size) { size *= nmemb; - char* p = __libqasan_malloc(size); + char *p = __libqasan_malloc(size); if (!p) return NULL; __builtin_memset(p, 0, size); @@ -224,14 +219,14 @@ void* __libqasan_calloc(size_t nmemb, size_t size) { } -void* __libqasan_realloc(void* ptr, size_t size) { +void *__libqasan_realloc(void *ptr, size_t size) { - char* p = __libqasan_malloc(size); + char *p = __libqasan_malloc(size); if (!p) return NULL; if (!ptr) return p; - size_t n = ((struct chunk_begin*)ptr)[-1].requested_size; + size_t n = ((struct chunk_begin *)ptr)[-1].requested_size; if (size < n) n = size; __builtin_memcpy(p, ptr, n); @@ -241,9 +236,9 @@ void* __libqasan_realloc(void* ptr, size_t size) { } -int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { +int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) { - if ((align % 2) || (align % sizeof(void*))) return EINVAL; + if ((align % 2) || (align % sizeof(void *))) return EINVAL; if (len == 0) { *ptr = NULL; @@ -257,7 +252,7 @@ int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread - char* orig = dlmalloc(sizeof(struct chunk_struct) + size); + char *orig = dlmalloc(sizeof(struct chunk_struct) + size); QASAN_SWAP(state); @@ -265,10 +260,10 @@ int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { QASAN_UNPOISON(orig, sizeof(struct chunk_struct) + size); - char* data = orig + sizeof(struct chunk_begin); + char *data = orig + sizeof(struct chunk_begin); data += align - ((uintptr_t)data % align); - struct chunk_begin* p = (struct chunk_begin*)data - 1; + struct chunk_begin *p = (struct chunk_begin *)data - 1; p->requested_size = len; p->aligned_orig = orig; @@ -291,9 +286,9 @@ int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { } -void* __libqasan_memalign(size_t align, size_t len) { +void *__libqasan_memalign(size_t align, size_t len) { - void* ret = NULL; + void *ret = NULL; __libqasan_posix_memalign(&ret, align, len); @@ -301,9 +296,9 @@ void* __libqasan_memalign(size_t align, size_t len) { } -void* __libqasan_aligned_alloc(size_t align, size_t len) { +void *__libqasan_aligned_alloc(size_t align, size_t len) { - void* ret = NULL; + void *ret = NULL; if ((len % align)) return NULL; diff --git a/qemu_mode/libqasan/patch.c b/qemu_mode/libqasan/patch.c index ed783292..fbc09c99 100644 --- a/qemu_mode/libqasan/patch.c +++ b/qemu_mode/libqasan/patch.c @@ -28,12 +28,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef __x86_64__ -uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { +uint8_t *__libqasan_patch_jump(uint8_t *addr, uint8_t *dest) { // mov rax, dest addr[0] = 0x48; addr[1] = 0xb8; - *(uint8_t**)&addr[2] = dest; + *(uint8_t **)&addr[2] = dest; // jmp rax addr[10] = 0xff; @@ -45,11 +45,11 @@ uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { #elif __i386__ -uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { +uint8_t *__libqasan_patch_jump(uint8_t *addr, uint8_t *dest) { // mov eax, dest addr[0] = 0xb8; - *(uint8_t**)&addr[1] = dest; + *(uint8_t **)&addr[1] = dest; // jmp eax addr[5] = 0xff; @@ -64,7 +64,7 @@ uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { // in ARM, r12 is a scratch register used by the linker to jump, // so let's use it in our stub -uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { +uint8_t *__libqasan_patch_jump(uint8_t *addr, uint8_t *dest) { // ldr r12, OFF addr[0] = 0x0; @@ -79,7 +79,7 @@ uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { addr[7] = 0xe0; // OFF: .word dest - *(uint32_t*)&addr[8] = (uint32_t)dest; + *(uint32_t *)&addr[8] = (uint32_t)dest; return &addr[12]; @@ -90,7 +90,7 @@ uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { // in ARM64, x16 is a scratch register used by the linker to jump, // so let's use it in our stub -uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { +uint8_t *__libqasan_patch_jump(uint8_t *addr, uint8_t *dest) { // ldr x16, OFF addr[0] = 0x50; @@ -105,7 +105,7 @@ uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { addr[7] = 0xd6; // OFF: .dword dest - *(uint64_t*)&addr[8] = (uint64_t)dest; + *(uint64_t *)&addr[8] = (uint64_t)dest; return &addr[16]; @@ -113,7 +113,7 @@ uint8_t* __libqasan_patch_jump(uint8_t* addr, uint8_t* dest) { #else -#define CANNOT_HOTPATCH + #define CANNOT_HOTPATCH #endif @@ -130,8 +130,8 @@ int libc_perms; static void find_libc(void) { - FILE* fp; - char* line = NULL; + FILE * fp; + char * line = NULL; size_t len = 0; ssize_t read; @@ -156,8 +156,8 @@ static void find_libc(void) { if (flag_x == 'x' && (__libqasan_strstr(path, "/libc.so") || __libqasan_strstr(path, "/libc-"))) { - libc_start = (void*)min; - libc_end = (void*)max; + libc_start = (void *)min; + libc_end = (void *)max; libc_perms = PROT_EXEC; if (flag_w == 'w') libc_perms |= PROT_WRITE; @@ -190,30 +190,30 @@ void __libqasan_hotpatch(void) { PROT_READ | PROT_WRITE | PROT_EXEC) < 0) return; - void* libc = dlopen("libc.so.6", RTLD_LAZY); + void *libc = dlopen("libc.so.6", RTLD_LAZY); -#define HOTPATCH(fn) \ - uint8_t* p_##fn = (uint8_t*)dlsym(libc, #fn); \ - if (p_##fn) __libqasan_patch_jump(p_##fn, (uint8_t*)&(fn)); + #define HOTPATCH(fn) \ + uint8_t *p_##fn = (uint8_t *)dlsym(libc, #fn); \ + if (p_##fn) __libqasan_patch_jump(p_##fn, (uint8_t *)&(fn)); HOTPATCH(memcmp) HOTPATCH(memmove) - uint8_t* p_memcpy = (uint8_t*)dlsym(libc, "memcpy"); + uint8_t *p_memcpy = (uint8_t *)dlsym(libc, "memcpy"); // fuck you libc if (p_memcpy && p_memmove != p_memcpy) - __libqasan_patch_jump(p_memcpy, (uint8_t*)&memcpy); + __libqasan_patch_jump(p_memcpy, (uint8_t *)&memcpy); HOTPATCH(memchr) HOTPATCH(memrchr) HOTPATCH(memmem) -#ifndef __BIONIC__ + #ifndef __BIONIC__ HOTPATCH(bzero) HOTPATCH(explicit_bzero) HOTPATCH(mempcpy) HOTPATCH(bcmp) -#endif - + #endif + HOTPATCH(strchr) HOTPATCH(strrchr) HOTPATCH(strcasecmp) @@ -233,7 +233,7 @@ void __libqasan_hotpatch(void) { HOTPATCH(wcscpy) HOTPATCH(wcscmp) -#undef HOTPATCH + #undef HOTPATCH mprotect(libc_start, libc_end - libc_start, libc_perms); diff --git a/qemu_mode/libqasan/string.c b/qemu_mode/libqasan/string.c index 520f0342..c850463b 100644 --- a/qemu_mode/libqasan/string.c +++ b/qemu_mode/libqasan/string.c @@ -26,10 +26,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "libqasan.h" #include -void* __libqasan_memcpy(void* dest, const void* src, size_t n) { +void *__libqasan_memcpy(void *dest, const void *src, size_t n) { - unsigned char* d = dest; - const unsigned char* s = src; + unsigned char * d = dest; + const unsigned char *s = src; if (!n) return dest; @@ -45,10 +45,10 @@ void* __libqasan_memcpy(void* dest, const void* src, size_t n) { } -void* __libqasan_memmove(void* dest, const void* src, size_t n) { +void *__libqasan_memmove(void *dest, const void *src, size_t n) { - unsigned char* d = dest; - const unsigned char* s = src; + unsigned char * d = dest; + const unsigned char *s = src; if (!n) return dest; @@ -65,18 +65,18 @@ void* __libqasan_memmove(void* dest, const void* src, size_t n) { } -void* __libqasan_memset(void* s, int c, size_t n) { +void *__libqasan_memset(void *s, int c, size_t n) { - unsigned char* b = s; + unsigned char *b = s; while (n--) *(b++) = (unsigned char)c; return s; } -void* __libqasan_memchr(const void* s, int c, size_t n) { +void *__libqasan_memchr(const void *s, int c, size_t n) { - unsigned char* m = (unsigned char*)s; + unsigned char *m = (unsigned char *)s; size_t i; for (i = 0; i < n; ++i) if (m[i] == (unsigned char)c) return &m[i]; @@ -84,9 +84,9 @@ void* __libqasan_memchr(const void* s, int c, size_t n) { } -void* __libqasan_memrchr(const void* s, int c, size_t n) { +void *__libqasan_memrchr(const void *s, int c, size_t n) { - unsigned char* m = (unsigned char*)s; + unsigned char *m = (unsigned char *)s; long i; for (i = n; i >= 0; --i) if (m[i] == (unsigned char)c) return &m[i]; @@ -94,16 +94,16 @@ void* __libqasan_memrchr(const void* s, int c, size_t n) { } -size_t __libqasan_strlen(const char* s) { +size_t __libqasan_strlen(const char *s) { - const char* i = s; + const char *i = s; while (*(i++)) ; return i - s - 1; } -size_t __libqasan_strnlen(const char* s, size_t len) { +size_t __libqasan_strnlen(const char *s, size_t len) { size_t r = 0; while (len-- && *(s++)) @@ -112,7 +112,7 @@ size_t __libqasan_strnlen(const char* s, size_t len) { } -int __libqasan_strcmp(const char* str1, const char* str2) { +int __libqasan_strcmp(const char *str1, const char *str2) { while (1) { @@ -129,7 +129,7 @@ int __libqasan_strcmp(const char* str1, const char* str2) { } -int __libqasan_strncmp(const char* str1, const char* str2, size_t len) { +int __libqasan_strncmp(const char *str1, const char *str2, size_t len) { while (len--) { @@ -146,7 +146,7 @@ int __libqasan_strncmp(const char* str1, const char* str2, size_t len) { } -int __libqasan_strcasecmp(const char* str1, const char* str2) { +int __libqasan_strcasecmp(const char *str1, const char *str2) { while (1) { @@ -163,7 +163,7 @@ int __libqasan_strcasecmp(const char* str1, const char* str2) { } -int __libqasan_strncasecmp(const char* str1, const char* str2, size_t len) { +int __libqasan_strncasecmp(const char *str1, const char *str2, size_t len) { while (len--) { @@ -180,10 +180,10 @@ int __libqasan_strncasecmp(const char* str1, const char* str2, size_t len) { } -int __libqasan_memcmp(const void* mem1, const void* mem2, size_t len) { +int __libqasan_memcmp(const void *mem1, const void *mem2, size_t len) { - const char* strmem1 = (const char*)mem1; - const char* strmem2 = (const char*)mem2; + const char *strmem1 = (const char *)mem1; + const char *strmem2 = (const char *)mem2; while (len--) { @@ -198,10 +198,10 @@ int __libqasan_memcmp(const void* mem1, const void* mem2, size_t len) { } -int __libqasan_bcmp(const void* mem1, const void* mem2, size_t len) { +int __libqasan_bcmp(const void *mem1, const void *mem2, size_t len) { - const char* strmem1 = (const char*)mem1; - const char* strmem2 = (const char*)mem2; + const char *strmem1 = (const char *)mem1; + const char *strmem2 = (const char *)mem2; while (len--) { @@ -216,17 +216,17 @@ int __libqasan_bcmp(const void* mem1, const void* mem2, size_t len) { } -char* __libqasan_strstr(const char* haystack, const char* needle) { +char *__libqasan_strstr(const char *haystack, const char *needle) { do { - const char* n = needle; - const char* h = haystack; + const char *n = needle; + const char *h = haystack; while (*n && *h && *n == *h) n++, h++; - if (!*n) return (char*)haystack; + if (!*n) return (char *)haystack; } while (*(haystack++)); @@ -234,17 +234,17 @@ char* __libqasan_strstr(const char* haystack, const char* needle) { } -char* __libqasan_strcasestr(const char* haystack, const char* needle) { +char *__libqasan_strcasestr(const char *haystack, const char *needle) { do { - const char* n = needle; - const char* h = haystack; + const char *n = needle; + const char *h = haystack; while (*n && *h && tolower(*n) == tolower(*h)) n++, h++; - if (!*n) return (char*)haystack; + if (!*n) return (char *)haystack; } while (*(haystack++)); @@ -252,22 +252,22 @@ char* __libqasan_strcasestr(const char* haystack, const char* needle) { } -void* __libqasan_memmem(const void* haystack, size_t haystack_len, - const void* needle, size_t needle_len) { +void *__libqasan_memmem(const void *haystack, size_t haystack_len, + const void *needle, size_t needle_len) { - const char* n = (const char*)needle; - const char* h = (const char*)haystack; + const char *n = (const char *)needle; + const char *h = (const char *)haystack; if (haystack_len < needle_len) return 0; - if (needle_len == 0) return (void*)haystack; + if (needle_len == 0) return (void *)haystack; if (needle_len == 1) return memchr(haystack, *n, haystack_len); - const char* end = h + (haystack_len - needle_len); + const char *end = h + (haystack_len - needle_len); do { if (*h == *n) { - if (memcmp(h, n, needle_len) == 0) return (void*)h; + if (memcmp(h, n, needle_len) == 0) return (void *)h; } @@ -277,26 +277,26 @@ void* __libqasan_memmem(const void* haystack, size_t haystack_len, } -char* __libqasan_strchr(const char* s, int c) { +char *__libqasan_strchr(const char *s, int c) { while (*s != (char)c) if (!*s++) return 0; - return (char*)s; + return (char *)s; } -char* __libqasan_strrchr(const char* s, int c) { +char *__libqasan_strrchr(const char *s, int c) { - char* r = NULL; + char *r = NULL; do - if (*s == (char)c) r = (char*)s; + if (*s == (char)c) r = (char *)s; while (*s++); return r; } -size_t __libqasan_wcslen(const wchar_t* s) { +size_t __libqasan_wcslen(const wchar_t *s) { size_t len = 0; @@ -313,16 +313,16 @@ size_t __libqasan_wcslen(const wchar_t* s) { } -wchar_t* __libqasan_wcscpy(wchar_t* d, const wchar_t* s) { +wchar_t *__libqasan_wcscpy(wchar_t *d, const wchar_t *s) { - wchar_t* a = d; + wchar_t *a = d; while ((*d++ = *s++)) ; return a; } -int __libqasan_wcscmp(const wchar_t* s1, const wchar_t* s2) { +int __libqasan_wcscmp(const wchar_t *s1, const wchar_t *s2) { wchar_t c1, c2; do { -- cgit 1.4.1 From 654f389e73c9fd5b7e141b33ea28ab0fdda3178f Mon Sep 17 00:00:00 2001 From: van Hauser Date: Mon, 1 Feb 2021 23:36:27 +0100 Subject: try to remove warnings during compilation --- src/afl-cc.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index 7db3c9a0..f272f0b5 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -313,7 +313,8 @@ static u8 *find_object(u8 *obj, u8 *argv0) { static void edit_params(u32 argc, char **argv, char **envp) { u8 fortify_set = 0, asan_set = 0, x_set = 0, bit_mode = 0, shared_linking = 0, - preprocessor_only = 0, have_unroll = 0, have_o = 0, have_pic = 0; + preprocessor_only = 0, have_unroll = 0, have_o = 0, have_pic = 0, + have_c = 0; u8 *name; cc_params = ck_alloc((argc + 128) * sizeof(u8 *)); @@ -461,7 +462,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { // laf if (getenv("LAF_SPLIT_SWITCHES") || getenv("AFL_LLVM_LAF_SPLIT_SWITCHES")) { - if (lto_mode) { + if (lto_mode && !have_c) { cc_params[cc_par_cnt++] = alloc_printf( "-Wl,-mllvm=-load=%s/split-switches-pass.so", obj_path); @@ -481,7 +482,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (getenv("LAF_TRANSFORM_COMPARES") || getenv("AFL_LLVM_LAF_TRANSFORM_COMPARES")) { - if (lto_mode) { + if (lto_mode && !have_c) { cc_params[cc_par_cnt++] = alloc_printf( "-Wl,-mllvm=-load=%s/compare-transform-pass.so", obj_path); @@ -501,7 +502,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (getenv("LAF_SPLIT_COMPARES") || getenv("AFL_LLVM_LAF_SPLIT_COMPARES") || getenv("AFL_LLVM_LAF_SPLIT_FLOATS")) { - if (lto_mode) { + if (lto_mode && !have_c) { cc_params[cc_par_cnt++] = alloc_printf( "-Wl,-mllvm=-load=%s/split-compares-pass.so", obj_path); @@ -524,7 +525,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { unsetenv("AFL_LD_CALLER"); if (cmplog_mode) { - if (lto_mode) { + if (lto_mode && !have_c) { cc_params[cc_par_cnt++] = alloc_printf( "-Wl,-mllvm=-load=%s/cmplog-routines-pass.so", obj_path); @@ -560,7 +561,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { } - if (lto_mode) { + if (lto_mode && !have_c) { u8 *ld_path = strdup(AFL_REAL_LD); if (!*ld_path) ld_path = "ld.lld"; @@ -708,6 +709,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (!strcmp(cur, "-x")) x_set = 1; if (!strcmp(cur, "-E")) preprocessor_only = 1; if (!strcmp(cur, "-shared")) shared_linking = 1; + if (!strcmp(cur, "-c")) have_c = 1; if (!strncmp(cur, "-O", 2)) have_o = 1; if (!strncmp(cur, "-funroll-loop", 13)) have_unroll = 1; @@ -800,7 +802,8 @@ static void edit_params(u32 argc, char **argv, char **envp) { } #if defined(USEMMAP) && !defined(__HAIKU__) - cc_params[cc_par_cnt++] = "-lrt"; + if (!have_c) + cc_params[cc_par_cnt++] = "-lrt"; #endif cc_params[cc_par_cnt++] = "-D__AFL_HAVE_MANUAL_CONTROL=1"; @@ -967,15 +970,19 @@ static void edit_params(u32 argc, char **argv, char **envp) { } #if !defined(__APPLE__) && !defined(__sun) - if (!shared_linking) + if (!shared_linking && !have_c) cc_params[cc_par_cnt++] = alloc_printf("-Wl,--dynamic-list=%s/dynamic_list.txt", obj_path); #endif #if defined(USEMMAP) && !defined(__HAIKU__) - cc_params[cc_par_cnt++] = "-lrt"; + if (!have_c) + cc_params[cc_par_cnt++] = "-lrt"; #endif + // prevent unnecessary build errors + cc_params[cc_par_cnt++] = "-Wno-unused-command-line-argument"; + } #endif -- cgit 1.4.1 From 1f71b85426f837ebcae8381897d44a3a67c73a4f Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 2 Feb 2021 10:05:10 +0100 Subject: automagically fix sanitize fuzzer+coverage --- src/afl-cc.c | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index f272f0b5..cba435bd 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -693,6 +693,38 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (strstr(cur, "afl-compiler-rt") || strstr(cur, "afl-llvm-rt")) continue; if (!strcmp(cur, "-Wl,-z,defs") || !strcmp(cur, "-Wl,--no-undefined")) continue; + if (!strncmp(cur, "-fsanitize=fuzzer-", strlen("-fsanitize=fuzzer-")) || + !strncmp(cur, "-fsanitize-coverage", strlen("-fsanitize-coverage"))) { + + if (!be_quiet) { WARNF("Found '%s' - stripping!", cur); } + continue; + + } + + if (!strcmp(cur, "-fsanitize=fuzzer")) { + + u8 *afllib = find_object("libAFLDriver.a", argv[0]); + + if (!be_quiet) + WARNF( + "Found errornous '-fsanitize=fuzzer', trying to replace with " + "libAFLDriver.a"); + + if (!afllib) { + + WARNF( + "Cannot find 'libAFLDriver.a' to replace a wrong " + "'-fsanitize=fuzzer' in the flags - this will fail!"); + + } else { + + cc_params[cc_par_cnt++] = afllib; + + } + + continue; + + } if (!strcmp(cur, "-m32")) bit_mode = 32; if (!strcmp(cur, "armv7a-linux-androideabi")) bit_mode = 32; @@ -802,8 +834,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { } #if defined(USEMMAP) && !defined(__HAIKU__) - if (!have_c) - cc_params[cc_par_cnt++] = "-lrt"; + if (!have_c) cc_params[cc_par_cnt++] = "-lrt"; #endif cc_params[cc_par_cnt++] = "-D__AFL_HAVE_MANUAL_CONTROL=1"; @@ -976,12 +1007,11 @@ static void edit_params(u32 argc, char **argv, char **envp) { #endif #if defined(USEMMAP) && !defined(__HAIKU__) - if (!have_c) - cc_params[cc_par_cnt++] = "-lrt"; + if (!have_c) cc_params[cc_par_cnt++] = "-lrt"; #endif - // prevent unnecessary build errors - cc_params[cc_par_cnt++] = "-Wno-unused-command-line-argument"; + // prevent unnecessary build errors + cc_params[cc_par_cnt++] = "-Wno-unused-command-line-argument"; } -- cgit 1.4.1 From 6be3896bfa48baacc17dce764c47a7ff0d4b1b82 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 2 Feb 2021 14:41:31 +0100 Subject: linux performance option --- afl-system-config | 1 + 1 file changed, 1 insertion(+) diff --git a/afl-system-config b/afl-system-config index 456cccac..d5e5ceae 100755 --- a/afl-system-config +++ b/afl-system-config @@ -34,6 +34,7 @@ if [ "$PLATFORM" = "Linux" ] ; then test -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor && echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor test -e /sys/devices/system/cpu/intel_pstate/no_turbo && echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo test -e /sys/devices/system/cpu/cpufreq/boost && echo 1 > /sys/devices/system/cpu/cpufreq/boost + test -e /sys/devices/system/cpu/intel_pstate/max_perf_pct && echo 100 > /sys/devices/system/cpu/intel_pstate/max_perf_pct } > /dev/null echo Settings applied. dmesg | egrep -q 'nospectre_v2|spectre_v2=off' || { -- cgit 1.4.1 From 8bd70a50b1218f6fe8ff260acf766097190d6747 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Tue, 2 Feb 2021 23:03:52 +0000 Subject: afl-untracer: Mac M1 build update proposal. --- utils/afl_untracer/afl-untracer.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/utils/afl_untracer/afl-untracer.c b/utils/afl_untracer/afl-untracer.c index f3894a06..1f1a10ea 100644 --- a/utils/afl_untracer/afl-untracer.c +++ b/utils/afl_untracer/afl-untracer.c @@ -56,9 +56,9 @@ #include #include #include -#include #if defined(__linux__) + #include #include #elif defined(__APPLE__) && defined(__LP64__) #include @@ -480,6 +480,9 @@ void setup_trap_instrumentation(void) { // Index into the coverage bitmap for the current trap instruction. #ifdef __aarch64__ uint64_t bitmap_index = 0; +#ifdef __APPLE__ + pthread_jit_write_protect_np(0); +#endif #else uint32_t bitmap_index = 0; #endif @@ -508,7 +511,6 @@ void setup_trap_instrumentation(void) { lib_size); lib_addr = (u8 *)lib_base->addr_start; - // Make library code writable. if (mprotect((void *)lib_addr, lib_size, PROT_READ | PROT_WRITE | PROT_EXEC) != 0) @@ -625,8 +627,13 @@ static void sigtrap_handler(int signum, siginfo_t *si, void *context) { // Must re-execute the instruction, so decrement PC by one instruction. ucontext_t *ctx = (ucontext_t *)context; #if defined(__APPLE__) && defined(__LP64__) +#if defined(__x86_64__) ctx->uc_mcontext->__ss.__rip -= 1; addr = ctx->uc_mcontext->__ss.__rip; +#else + ctx->uc_mcontext->__ss.__pc -= 4; + addr = ctx->uc_mcontext->__ss.__pc; +#endif #elif defined(__linux__) #if defined(__x86_64__) || defined(__i386__) ctx->uc_mcontext.gregs[REG_RIP] -= 1; @@ -676,7 +683,9 @@ static void sigtrap_handler(int signum, siginfo_t *si, void *context) { /* the MAIN function */ int main(int argc, char *argv[]) { +#if defined(__linux__) (void)personality(ADDR_NO_RANDOMIZE); // disable ASLR +#endif pid = getpid(); if (getenv("AFL_DEBUG")) debug = 1; -- cgit 1.4.1 From 58a5372bf0c55ead2a04ed4a4a5b651d68e69292 Mon Sep 17 00:00:00 2001 From: hexcoder Date: Wed, 3 Feb 2021 14:18:35 +0100 Subject: typo --- src/afl-cc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/afl-cc.c b/src/afl-cc.c index cba435bd..cf10d9a7 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -707,7 +707,7 @@ static void edit_params(u32 argc, char **argv, char **envp) { if (!be_quiet) WARNF( - "Found errornous '-fsanitize=fuzzer', trying to replace with " + "Found erroneous '-fsanitize=fuzzer', trying to replace with " "libAFLDriver.a"); if (!afllib) { -- cgit 1.4.1 From d0ab2ded0010fbb2f07920ebcf16bea818507378 Mon Sep 17 00:00:00 2001 From: b1gr3db <73140724+b1gr3db@users.noreply.github.com> Date: Wed, 3 Feb 2021 15:32:06 -0500 Subject: Create string.c Off by one error resulted in memmem calling memcmp where h + needle_len is one past the end. --- qemu_mode/libqasan/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu_mode/libqasan/string.c b/qemu_mode/libqasan/string.c index c850463b..4be01279 100644 --- a/qemu_mode/libqasan/string.c +++ b/qemu_mode/libqasan/string.c @@ -271,7 +271,7 @@ void *__libqasan_memmem(const void *haystack, size_t haystack_len, } - } while (h++ <= end); + } while (++h <= end); return 0; -- cgit 1.4.1 From ec737f3368e678cbee3a916d4ef6fb683ebfa1f0 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Thu, 4 Feb 2021 18:57:27 +0100 Subject: workaroung for llvm LTO bitcast bug --- instrumentation/cmplog-instructions-pass.cc | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/instrumentation/cmplog-instructions-pass.cc b/instrumentation/cmplog-instructions-pass.cc index d4bc0b38..b5cc1882 100644 --- a/instrumentation/cmplog-instructions-pass.cc +++ b/instrumentation/cmplog-instructions-pass.cc @@ -265,7 +265,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) { unsigned int max_size = Val->getType()->getIntegerBitWidth(), cast_size; unsigned char do_cast = 0; - if (!SI->getNumCases() || max_size <= 8) { + if (!SI->getNumCases() || max_size < 16 || max_size % 8) { // if (!be_quiet) errs() << "skip trivial switch..\n"; continue; @@ -275,17 +275,6 @@ bool CmpLogInstructions::hookInstrs(Module &M) { IRBuilder<> IRB(SI->getParent()); IRB.SetInsertPoint(SI); - if (max_size % 8) { - - // bitcast from i6 to i8 panics llvm, so ... - continue; - /* - max_size = (((max_size / 8) + 1) * 8); - do_cast = 1; - */ - - } - if (max_size > 128) { if (!be_quiet) { @@ -551,15 +540,7 @@ bool CmpLogInstructions::hookInstrs(Module &M) { } - if (!max_size) { continue; } - - // _ExtInt() with non-8th values - if (max_size % 8) { - - max_size = (((max_size / 8) + 1) * 8); - do_cast = 1; - - } + if (!max_size || max_size % 8 || max_size < 16) { continue; } if (max_size > 128) { -- cgit 1.4.1 From bf1198c4dbcfcca81ee912f4926daad02d9e27c1 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Thu, 4 Feb 2021 20:47:51 +0100 Subject: dockerfile: fix qemu built, update llvm to 12 --- Dockerfile | 15 ++++++++------- instrumentation/afl-llvm-lto-instrumentation.so.cc | 12 ++++++------ unicorn_mode/build_unicorn_support.sh | 2 ++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index dec952af..8779fee5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && \ apt-get -y install --no-install-suggests --no-install-recommends \ automake \ + ninja-build \ bison flex \ build-essential \ git \ @@ -26,7 +27,7 @@ RUN apt-get update && \ gnuplot-nox \ && rm -rf /var/lib/apt/lists/* -RUN echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main" >> /etc/apt/sources.list && \ +RUN echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-12 main" >> /etc/apt/sources.list && \ wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - RUN echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal main" >> /etc/apt/sources.list && \ @@ -35,17 +36,17 @@ RUN echo "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu focal main RUN apt-get update && apt-get full-upgrade -y && \ apt-get -y install --no-install-suggests --no-install-recommends \ gcc-10 g++-10 gcc-10-plugin-dev gcc-10-multilib gdb lcov \ - clang-11 clang-tools-11 libc++1-11 libc++-11-dev \ - libc++abi1-11 libc++abi-11-dev libclang1-11 libclang-11-dev \ - libclang-common-11-dev libclang-cpp11 libclang-cpp11-dev liblld-11 \ - liblld-11-dev liblldb-11 liblldb-11-dev libllvm11 libomp-11-dev \ - libomp5-11 lld-11 lldb-11 llvm-11 llvm-11-dev llvm-11-runtime llvm-11-tools \ + clang-12 clang-tools-12 libc++1-12 libc++-12-dev \ + libc++abi1-12 libc++abi-12-dev libclang1-12 libclang-12-dev \ + libclang-common-12-dev libclang-cpp12 libclang-cpp12-dev liblld-12 \ + liblld-12-dev liblldb-12 liblldb-12-dev libllvm12 libomp-12-dev \ + libomp5-12 lld-12 lldb-12 llvm-12 llvm-12-dev llvm-12-runtime llvm-12-tools \ && rm -rf /var/lib/apt/lists/* RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 0 RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 0 -ENV LLVM_CONFIG=llvm-config-11 +ENV LLVM_CONFIG=llvm-config-12 ENV AFL_SKIP_CPUFREQ=1 RUN git clone https://github.com/vanhauser-thc/afl-cov /afl-cov diff --git a/instrumentation/afl-llvm-lto-instrumentation.so.cc b/instrumentation/afl-llvm-lto-instrumentation.so.cc index 13dca8c4..fa494f44 100644 --- a/instrumentation/afl-llvm-lto-instrumentation.so.cc +++ b/instrumentation/afl-llvm-lto-instrumentation.so.cc @@ -69,7 +69,7 @@ class AFLLTOPass : public ModulePass { if (getenv("AFL_DEBUG")) debug = 1; if ((ptr = getenv("AFL_LLVM_LTO_STARTID")) != NULL) - if ((afl_global_id = atoi(ptr)) < 0 || afl_global_id >= MAP_SIZE) + if ((afl_global_id = (uint32_t)atoi(ptr)) < 0 || afl_global_id >= MAP_SIZE) FATAL("AFL_LLVM_LTO_STARTID value of \"%s\" is not between 0 and %u\n", ptr, MAP_SIZE - 1); @@ -88,7 +88,7 @@ class AFLLTOPass : public ModulePass { bool runOnModule(Module &M) override; protected: - int afl_global_id = 1, autodictionary = 1; + uint32_t afl_global_id = 1, autodictionary = 1; uint32_t function_minimum_size = 1; uint32_t inst_blocks = 0, inst_funcs = 0, total_instr = 0; uint64_t map_addr = 0x10000; @@ -800,7 +800,7 @@ bool AFLLTOPass::runOnModule(Module &M) { if (documentFile) { - fprintf(documentFile, "ModuleID=%llu Function=%s edgeID=%d\n", + fprintf(documentFile, "ModuleID=%llu Function=%s edgeID=%u\n", moduleID, F.getName().str().c_str(), afl_global_id); } @@ -872,10 +872,10 @@ bool AFLLTOPass::runOnModule(Module &M) { while ((map = map >> 1)) pow2map++; WARNF( - "We have %d blocks to instrument but the map size is only %u. Either " + "We have %u blocks to instrument but the map size is only %u. Either " "edit config.h and set MAP_SIZE_POW2 from %d to %u, then recompile " "afl-fuzz and llvm_mode and then make this target - or set " - "AFL_MAP_SIZE with at least size %d when running afl-fuzz with this " + "AFL_MAP_SIZE with at least size %u when running afl-fuzz with this " "target.", afl_global_id, MAP_SIZE, MAP_SIZE_POW2, pow2map, afl_global_id); @@ -925,7 +925,7 @@ bool AFLLTOPass::runOnModule(Module &M) { uint32_t write_loc = afl_global_id; - if (afl_global_id % 8) write_loc = (((afl_global_id + 8) >> 3) << 3); + if (afl_global_id % 32) write_loc = (((afl_global_id + 32) >> 4) << 4); GlobalVariable *AFLFinalLoc = new GlobalVariable( M, Int32Ty, true, GlobalValue::ExternalLinkage, 0, "__afl_final_loc"); diff --git a/unicorn_mode/build_unicorn_support.sh b/unicorn_mode/build_unicorn_support.sh index c32eb3e1..f1d028f8 100755 --- a/unicorn_mode/build_unicorn_support.sh +++ b/unicorn_mode/build_unicorn_support.sh @@ -147,6 +147,8 @@ if [ "$PREREQ_NOTFOUND" = "1" ]; then exit 1 fi +unset CFLAGS + echo "[+] All checks passed!" echo "[*] Making sure unicornafl is checked out" -- cgit 1.4.1 From faa9daf260e63482121c9e06e1205efe0a7bcf2d Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Thu, 4 Feb 2021 23:09:49 +0100 Subject: update readme --- README.md | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c4aab93..d1ae05d3 100644 --- a/README.md +++ b/README.md @@ -68,9 +68,10 @@ behaviours and defaults: 3. [How to fuzz a target](#how-to-fuzz-with-afl) 4. [Fuzzing binary-only targets](#fuzzing-binary-only-targets) 5. [Good examples and writeups of afl++ usages](#good-examples-and-writeups) - 6. [Branches](#branches) - 7. [Want to help?](#help-wanted) - 8. [Detailed help and description of afl++](#challenges-of-guided-fuzzing) + 6. [CI Fuzzing](#ci-fuzzing) + 7. [Branches](#branches) + 8. [Want to help?](#help-wanted) + 9. [Detailed help and description of afl++](#challenges-of-guided-fuzzing) ## Important features of afl++ @@ -689,6 +690,9 @@ If you want to know more, the rest of this README and the tons of texts in Note that there are also a lot of tools out there that help fuzzing with afl++ (some might be deprecated or unsupported): +Speeding up fuzzing: + * [libfiowrapper](https://github.com/marekzmyslowski/libfiowrapper) - if you cannot use stdin or in-memory fuzzing, this emulates file reading, recommended. + Minimization of test cases: * [afl-pytmin](https://github.com/ilsani/afl-pytmin) - a wrapper for afl-tmin that tries to speed up the process of minimization of a single test case by using many CPU cores. * [afl-ddmin-mod](https://github.com/MarkusTeufelberger/afl-ddmin-mod) - a variation of afl-tmin based on the ddmin algorithm. @@ -794,6 +798,34 @@ All these methods are extremely promising in experimental settings, but tend to suffer from reliability and performance problems in practical uses - and currently do not offer a viable alternative to "dumb" fuzzing techniques. +## CI Fuzzing + +Some notes on CI Fuzzing - this fuzzing is different to normal fuzzing +campaigns as these are much shorter runnings. + +1. Always: + * LTO has a much longer compile time which is diametrical to short fuzzing - + hence use afl-clang-fast instead + * `AFL_FAST_CAL` - Enable fast calibration, halfs the time the saturated + corpus is loaded + * `AFL_CMPLOG_ONLY_NEW` - only perform cmplog on new found paths, not the + initial corpus as it has been done there already + * Keep the generated corpus, use afl-cmin and reuse it everytime! + +2. Additionally randomize the afl++ compilation options, e.g. + * 40% for `AFL_LLVM_CMPLOG` + * 10% for `AFL_LLVM_LAF_ALL` + +3. Also randomize the afl-fuzz runtime options, e.g. + * 60% for `AFL_DISABLE_TRIM` + * 50% use a dictionary generated by `AFL_LLVM_DICT2FILE` + * 50% use MOpt (`-L 0`) + * 40% for `AFL_EXPAND_HAVOC_NOW` + * 30% for old queue processing (`-Z`) + * for CMPLOG targets, 60% for `-l 2`, 40% for `-l 3` + +4. Do *not* run any `-M` modes, just running `-S` modes are better for CI fuzzing. + ## Background: The afl-fuzz approach American Fuzzy Lop is a brute-force fuzzer coupled with an exceedingly simple -- cgit 1.4.1 From 6f163bb0c50a103dc4565ec5f0b8b9b94b5c16f6 Mon Sep 17 00:00:00 2001 From: vj-27 Date: Fri, 5 Feb 2021 00:26:23 +0000 Subject: load existing stats file when in AFL_AUTORESUME or -i - --- include/afl-fuzz.h | 1 + src/afl-fuzz-stats.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/afl-fuzz.c | 1 + 3 files changed, 103 insertions(+) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index c3a8c2ee..9e2913a2 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -1067,6 +1067,7 @@ void destroy_extras(afl_state_t *); /* Stats */ +void load_stats_file(afl_state_t *); void write_setup_file(afl_state_t *, u32, char **); void write_stats_file(afl_state_t *, double, double, double); void maybe_update_plot_file(afl_state_t *, double, double); diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index 7e99bf8f..d75b8405 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -89,6 +89,107 @@ void write_setup_file(afl_state_t *afl, u32 argc, char **argv) { } +/* load some of the existing stats file when resuming.*/ +void load_stats_file(afl_state_t *afl) { + + FILE *f; + u8 buf[MAX_LINE]; + u8 * lptr; + u8 fn[PATH_MAX]; + u32 lineno = 0; + + snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir); + f = fopen(fn, "r"); + if (!f) { + + WARNF("Unable to load stats file '%s'", fn); + return; + + } + + while ((lptr = fgets(buf, MAX_LINE, f))) { + + lineno++; + u8 *lstartptr = lptr; + u8 *rptr = lptr + strlen(lptr) - 1; + u8 keystring[MAX_LINE]; + while (*lptr != ':' && lptr < rptr) { + + lptr++; + + } + + if (*lptr == '\n' || !*lptr) { + + WARNF("Unable to read line %d of stats file", lineno); + continue; + + } + + if (*lptr == ':') { + + *lptr = 0; + strcpy(keystring, lstartptr); + lptr++; + char *nptr; + switch (lineno) { + + case 5: + if (!strcmp(keystring, "cycles_done ")) + afl->queue_cycle = + strtoull(lptr, &nptr, 10) ? strtoull(lptr, &nptr, 10) + 1 : 0; + break; + case 7: + if (!strcmp(keystring, "execs_done ")) + afl->fsrv.total_execs = strtoull(lptr, &nptr, 10); + break; + case 10: + if (!strcmp(keystring, "paths_total ")) + afl->queued_paths = strtoul(lptr, &nptr, 10); + break; + case 11: + if (!strcmp(keystring, "paths_favored ")) + afl->queued_favored = strtoul(lptr, &nptr, 10); + break; + case 12: + if (!strcmp(keystring, "paths_found ")) + afl->queued_discovered = strtoul(lptr, &nptr, 10); + break; + case 13: + if (!strcmp(keystring, "paths_imported ")) + afl->queued_imported = strtoul(lptr, &nptr, 10); + break; + case 14: + if (!strcmp(keystring, "max_depth ")) + afl->max_depth = strtoul(lptr, &nptr, 10); + break; + case 16: + if (!strcmp(keystring, "pending_favs ")) + afl->pending_favored = strtoul(lptr, &nptr, 10); + break; + case 17: + if (!strcmp(keystring, "pending_total ")) + afl->pending_not_fuzzed = strtoul(lptr, &nptr, 10); + break; + case 21: + if (!strcmp(keystring, "unique_crashes ")) + afl->unique_crashes = strtoull(lptr, &nptr, 10); + break; + case 22: + if (!strcmp(keystring, "unique_hangs ")) + afl->unique_hangs = strtoull(lptr, &nptr, 10); + break; + default: + break; + + } + + } + + } + +} + /* Update stats file for unattended monitoring. */ void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability, diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index a579a8f5..6c617b18 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1682,6 +1682,7 @@ int main(int argc, char **argv_orig, char **envp) { if (unlikely(afl->old_seed_selection)) seek_to = find_start_position(afl); + if (afl->in_place_resume || afl->afl_env.afl_autoresume) load_stats_file(afl); write_stats_file(afl, 0, 0, 0); maybe_update_plot_file(afl, 0, 0); save_auto(afl); -- cgit 1.4.1 From 1677481726a065516b593051a20da0281b28760c Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 5 Feb 2021 10:47:16 +0100 Subject: try if this helps on fuzzbench --- include/coverage-32.h | 2 +- include/coverage-64.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/coverage-32.h b/include/coverage-32.h index a5cc498c..ca36c29f 100644 --- a/include/coverage-32.h +++ b/include/coverage-32.h @@ -97,7 +97,7 @@ inline void discover_word(u8 *ret, u32 *current, u32 *virgin) { #define PACK_SIZE 16 inline u32 skim(const u32 *virgin, const u32 *current, const u32 *current_end) { - for (; current != current_end; virgin += 4, current += 4) { + for (; current < current_end; virgin += 4, current += 4) { if (current[0] && classify_word(current[0]) & virgin[0]) return 1; if (current[1] && classify_word(current[1]) & virgin[1]) return 1; diff --git a/include/coverage-64.h b/include/coverage-64.h index 0ede5fa5..54fe9d33 100644 --- a/include/coverage-64.h +++ b/include/coverage-64.h @@ -145,7 +145,7 @@ inline u32 skim(const u64 *virgin, const u64 *current, const u64 *current_end) { __m256i zeroes = _mm256_setzero_si256(); - for (; current != current_end; virgin += 4, current += 4) { + for (; current < current_end; virgin += 4, current += 4) { __m256i value = *(__m256i *)current; __m256i cmp = _mm256_cmpeq_epi64(value, zeroes); @@ -172,7 +172,7 @@ inline u32 skim(const u64 *virgin, const u64 *current, const u64 *current_end) { #define PACK_SIZE 32 inline u32 skim(const u64 *virgin, const u64 *current, const u64 *current_end) { - for (; current != current_end; virgin += 4, current += 4) { + for (; current < current_end; virgin += 4, current += 4) { if (current[0] && classify_word(current[0]) & virgin[0]) return 1; if (current[1] && classify_word(current[1]) & virgin[1]) return 1; -- cgit 1.4.1 From d8a18a03e326dc8b7cf8c8ab3a10f92501e96a26 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 5 Feb 2021 11:44:48 +0100 Subject: update unicorn ref --- unicorn_mode/UNICORNAFL_VERSION | 2 +- unicorn_mode/unicornafl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unicorn_mode/UNICORNAFL_VERSION b/unicorn_mode/UNICORNAFL_VERSION index 4d8a03b2..d9ae5590 100644 --- a/unicorn_mode/UNICORNAFL_VERSION +++ b/unicorn_mode/UNICORNAFL_VERSION @@ -1 +1 @@ -80d31ef3 +fb2fc9f2 diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 80d31ef3..fb2fc9f2 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 80d31ef367f7a1a75fc48e08e129d10f2ffa0498 +Subproject commit fb2fc9f25df32f17f6b6b859e4dbd70f9a857e0c -- cgit 1.4.1 From f53a2e4b88673b6259dba10583addea1a5138223 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 5 Feb 2021 12:11:18 +0100 Subject: nits --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d1ae05d3..046a9642 100644 --- a/README.md +++ b/README.md @@ -691,7 +691,7 @@ Note that there are also a lot of tools out there that help fuzzing with afl++ (some might be deprecated or unsupported): Speeding up fuzzing: - * [libfiowrapper](https://github.com/marekzmyslowski/libfiowrapper) - if you cannot use stdin or in-memory fuzzing, this emulates file reading, recommended. + * [libfiowrapper](https://github.com/marekzmyslowski/libfiowrapper) - if the function you want to fuzz requires loading a file, this allows using the shared memory testcase feature :-) - recommended. Minimization of test cases: * [afl-pytmin](https://github.com/ilsani/afl-pytmin) - a wrapper for afl-tmin that tries to speed up the process of minimization of a single test case by using many CPU cores. @@ -805,11 +805,11 @@ campaigns as these are much shorter runnings. 1. Always: * LTO has a much longer compile time which is diametrical to short fuzzing - - hence use afl-clang-fast instead - * `AFL_FAST_CAL` - Enable fast calibration, halfs the time the saturated - corpus is loaded + hence use afl-clang-fast instead. + * `AFL_FAST_CAL` - Enable fast calibration, this halfs the time the saturated + corpus needs to be loaded. * `AFL_CMPLOG_ONLY_NEW` - only perform cmplog on new found paths, not the - initial corpus as it has been done there already + initial corpus as this very likely has been done for them already. * Keep the generated corpus, use afl-cmin and reuse it everytime! 2. Additionally randomize the afl++ compilation options, e.g. @@ -824,7 +824,7 @@ campaigns as these are much shorter runnings. * 30% for old queue processing (`-Z`) * for CMPLOG targets, 60% for `-l 2`, 40% for `-l 3` -4. Do *not* run any `-M` modes, just running `-S` modes are better for CI fuzzing. +4. Do *not* run any `-M` modes, just running `-S` modes is better for CI fuzzing. ## Background: The afl-fuzz approach -- cgit 1.4.1 From 7e625c36873c334dbdbc3999bf3a02eb4723948f Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 5 Feb 2021 12:30:21 +0100 Subject: more doc, so good --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 046a9642..894a43e7 100644 --- a/README.md +++ b/README.md @@ -727,6 +727,16 @@ Crash processing When source code is *NOT* available, afl++ offers various support for fast, on-the-fly instrumentation of black-box binaries. +If you do not have to use Unicorn the following setup is recommended: + * run 1 afl-fuzz -Q instance with CMPLOG (`-c 0` + `AFL_COMPCOV_LEVEL=2`) + * run 1 afl-fuzz -Q instance with QASAN (`AFL_USE_QASAN=1`) + * run 1 afl-fuzz -Q instance with LAF (``AFL_PRELOAD=libcmpcov.so` + `AFL_COMPCOV_LEVEL=2`) +Then run as many instances as you have cores left with either -Q mode or - better - +use a binary rewriter like afl-dyninst, retrowrite, zipr, fibre, etc. + +For Qemu mode, check out the persistent mode and snapshot features, they give +a huge speed improvement! + ### QEMU For linux programs and its libraries this is accomplished with a version of @@ -737,7 +747,8 @@ feature by doing: cd qemu_mode ./build_qemu_support.sh ``` -For additional instructions and caveats, see [qemu_mode/README.md](qemu_mode/README.md). +For additional instructions and caveats, see [qemu_mode/README.md](qemu_mode/README.md) - +check out the snapshot feature! :-) If possible you should use the persistent mode, see [qemu_mode/README.persistent.md](qemu_mode/README.persistent.md). The mode is approximately 2-5x slower than compile-time instrumentation, and is less conducive to parallelization. @@ -745,6 +756,9 @@ less conducive to parallelization. If [afl-dyninst](https://github.com/vanhauser-thc/afl-dyninst) works for your binary, then you can use afl-fuzz normally and it will have twice the speed compared to qemu_mode (but slower than persistent mode). +Note that several other binary rewriters exist, all with their advantages and +caveats. As rewriting a binary is much faster than Qemu this is a highly +recommended approach! ### Unicorn -- cgit 1.4.1 From bed789cd5a382c2d025d2082c3e043ebfadb9560 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 5 Feb 2021 13:01:13 +0100 Subject: fix doc --- README.md | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 894a43e7..55aa63c3 100644 --- a/README.md +++ b/README.md @@ -722,6 +722,34 @@ Crash processing * [AFLize](https://github.com/d33tah/aflize) - a tool that automatically generates builds of debian packages suitable for AFL. * [afl-fid](https://github.com/FoRTE-Research/afl-fid) - a set of tools for working with input data. +## CI Fuzzing + +Some notes on CI Fuzzing - this fuzzing is different to normal fuzzing +campaigns as these are much shorter runnings. + +1. Always: + * LTO has a much longer compile time which is diametrical to short fuzzing - + hence use afl-clang-fast instead. + * `AFL_FAST_CAL` - Enable fast calibration, this halfs the time the saturated + corpus needs to be loaded. + * `AFL_CMPLOG_ONLY_NEW` - only perform cmplog on new found paths, not the + initial corpus as this very likely has been done for them already. + * Keep the generated corpus, use afl-cmin and reuse it everytime! + +2. Additionally randomize the afl++ compilation options, e.g. + * 40% for `AFL_LLVM_CMPLOG` + * 10% for `AFL_LLVM_LAF_ALL` + +3. Also randomize the afl-fuzz runtime options, e.g. + * 60% for `AFL_DISABLE_TRIM` + * 50% use a dictionary generated by `AFL_LLVM_DICT2FILE` + * 50% use MOpt (`-L 0`) + * 40% for `AFL_EXPAND_HAVOC_NOW` + * 30% for old queue processing (`-Z`) + * for CMPLOG targets, 60% for `-l 2`, 40% for `-l 3` + +4. Do *not* run any `-M` modes, just running `-S` modes is better for CI fuzzing. + ## Fuzzing binary-only targets When source code is *NOT* available, afl++ offers various support for fast, @@ -812,34 +840,6 @@ All these methods are extremely promising in experimental settings, but tend to suffer from reliability and performance problems in practical uses - and currently do not offer a viable alternative to "dumb" fuzzing techniques. -## CI Fuzzing - -Some notes on CI Fuzzing - this fuzzing is different to normal fuzzing -campaigns as these are much shorter runnings. - -1. Always: - * LTO has a much longer compile time which is diametrical to short fuzzing - - hence use afl-clang-fast instead. - * `AFL_FAST_CAL` - Enable fast calibration, this halfs the time the saturated - corpus needs to be loaded. - * `AFL_CMPLOG_ONLY_NEW` - only perform cmplog on new found paths, not the - initial corpus as this very likely has been done for them already. - * Keep the generated corpus, use afl-cmin and reuse it everytime! - -2. Additionally randomize the afl++ compilation options, e.g. - * 40% for `AFL_LLVM_CMPLOG` - * 10% for `AFL_LLVM_LAF_ALL` - -3. Also randomize the afl-fuzz runtime options, e.g. - * 60% for `AFL_DISABLE_TRIM` - * 50% use a dictionary generated by `AFL_LLVM_DICT2FILE` - * 50% use MOpt (`-L 0`) - * 40% for `AFL_EXPAND_HAVOC_NOW` - * 30% for old queue processing (`-Z`) - * for CMPLOG targets, 60% for `-l 2`, 40% for `-l 3` - -4. Do *not* run any `-M` modes, just running `-S` modes is better for CI fuzzing. - ## Background: The afl-fuzz approach American Fuzzy Lop is a brute-force fuzzer coupled with an exceedingly simple -- cgit 1.4.1 From 19d8f00963a2eb3526fc442c0b1685c166b68410 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 5 Feb 2021 13:01:42 +0100 Subject: doc fix --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 55aa63c3..118a619d 100644 --- a/README.md +++ b/README.md @@ -759,6 +759,7 @@ If you do not have to use Unicorn the following setup is recommended: * run 1 afl-fuzz -Q instance with CMPLOG (`-c 0` + `AFL_COMPCOV_LEVEL=2`) * run 1 afl-fuzz -Q instance with QASAN (`AFL_USE_QASAN=1`) * run 1 afl-fuzz -Q instance with LAF (``AFL_PRELOAD=libcmpcov.so` + `AFL_COMPCOV_LEVEL=2`) + Then run as many instances as you have cores left with either -Q mode or - better - use a binary rewriter like afl-dyninst, retrowrite, zipr, fibre, etc. -- cgit 1.4.1 From 1a8c242d280066b7bfb36897c91215d4f4b5eb01 Mon Sep 17 00:00:00 2001 From: vj-27 Date: Fri, 5 Feb 2021 19:46:24 +0000 Subject: load run time and donot load pending_* or *_favoured --- include/afl-fuzz.h | 2 +- src/afl-fuzz-stats.c | 29 ++++++++++++++--------------- src/afl-fuzz.c | 8 +++++++- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 9e2913a2..1b2b9a8e 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -1067,7 +1067,7 @@ void destroy_extras(afl_state_t *); /* Stats */ -void load_stats_file(afl_state_t *); +u32 load_stats_file(afl_state_t *); void write_setup_file(afl_state_t *, u32, char **); void write_stats_file(afl_state_t *, double, double, double); void maybe_update_plot_file(afl_state_t *, double, double); diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index d75b8405..3edb5bb6 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -90,20 +90,20 @@ void write_setup_file(afl_state_t *afl, u32 argc, char **argv) { } /* load some of the existing stats file when resuming.*/ -void load_stats_file(afl_state_t *afl) { +u32 load_stats_file(afl_state_t *afl) { FILE *f; u8 buf[MAX_LINE]; u8 * lptr; u8 fn[PATH_MAX]; u32 lineno = 0; - + u32 prev_run_time = 0; snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir); f = fopen(fn, "r"); if (!f) { WARNF("Unable to load stats file '%s'", fn); - return; + return prev_run_time; } @@ -134,6 +134,15 @@ void load_stats_file(afl_state_t *afl) { char *nptr; switch (lineno) { + case 3: + if (!strcmp(keystring, "run_time ")) { + + prev_run_time = 1000 * strtoull(lptr, &nptr, 10); + afl->start_time -= prev_run_time; + + } + + break; case 5: if (!strcmp(keystring, "cycles_done ")) afl->queue_cycle = @@ -147,10 +156,6 @@ void load_stats_file(afl_state_t *afl) { if (!strcmp(keystring, "paths_total ")) afl->queued_paths = strtoul(lptr, &nptr, 10); break; - case 11: - if (!strcmp(keystring, "paths_favored ")) - afl->queued_favored = strtoul(lptr, &nptr, 10); - break; case 12: if (!strcmp(keystring, "paths_found ")) afl->queued_discovered = strtoul(lptr, &nptr, 10); @@ -163,14 +168,6 @@ void load_stats_file(afl_state_t *afl) { if (!strcmp(keystring, "max_depth ")) afl->max_depth = strtoul(lptr, &nptr, 10); break; - case 16: - if (!strcmp(keystring, "pending_favs ")) - afl->pending_favored = strtoul(lptr, &nptr, 10); - break; - case 17: - if (!strcmp(keystring, "pending_total ")) - afl->pending_not_fuzzed = strtoul(lptr, &nptr, 10); - break; case 21: if (!strcmp(keystring, "unique_crashes ")) afl->unique_crashes = strtoull(lptr, &nptr, 10); @@ -188,6 +185,8 @@ void load_stats_file(afl_state_t *afl) { } + return prev_run_time; + } /* Update stats file for unattended monitoring. */ diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 6c617b18..b7cd251a 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1682,7 +1682,11 @@ int main(int argc, char **argv_orig, char **envp) { if (unlikely(afl->old_seed_selection)) seek_to = find_start_position(afl); - if (afl->in_place_resume || afl->afl_env.afl_autoresume) load_stats_file(afl); + u32 prev_run_time = 0; // to not call load_stats_file again after line 1705 + afl->start_time = get_cur_time(); // without this, time taken for + // perform_dry_run gets added to run time. + if (afl->in_place_resume || afl->afl_env.afl_autoresume) + prev_run_time = load_stats_file(afl); write_stats_file(afl, 0, 0, 0); maybe_update_plot_file(afl, 0, 0); save_auto(afl); @@ -1701,6 +1705,8 @@ int main(int argc, char **argv_orig, char **envp) { // (void)nice(-20); // does not improve the speed // real start time, we reset, so this works correctly with -V afl->start_time = get_cur_time(); + if (afl->in_place_resume || afl->afl_env.afl_autoresume) + afl->start_time -= prev_run_time; u32 runs_in_current_cycle = (u32)-1; u32 prev_queued_paths = 0; -- cgit 1.4.1 From bf289ce50e60ffe07d916915cdcca99e59479386 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sat, 6 Feb 2021 09:31:41 +0100 Subject: larger dummy map --- instrumentation/afl-compiler-rt.o.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index c24173af..905051c6 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -70,7 +70,7 @@ run. It will end up as .comm, so it shouldn't be too wasteful. */ #if MAP_SIZE <= 65536 - #define MAP_INITIAL_SIZE 256000 + #define MAP_INITIAL_SIZE 1048576 #else #define MAP_INITIAL_SIZE MAP_SIZE #endif @@ -1090,7 +1090,7 @@ __attribute__((constructor(0))) void __afl_auto_first(void) { if (getenv("AFL_DISABLE_LLVM_INSTRUMENTATION")) return; u8 *ptr; - ptr = (u8 *)malloc(1024000); + ptr = (u8 *)malloc(2097152); if (ptr && (ssize_t)ptr != -1) { -- cgit 1.4.1 From f54c4dbfdb17a06798b337a2182d7cf33ec178dd Mon Sep 17 00:00:00 2001 From: vj-27 Date: Sat, 6 Feb 2021 09:41:15 +0000 Subject: set prev_run_time inside afl state --- include/afl-fuzz.h | 3 ++- src/afl-fuzz-stats.c | 12 ++++++------ src/afl-fuzz.c | 6 ++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 1b2b9a8e..4027a88f 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -569,6 +569,7 @@ typedef struct afl_state { blocks_eff_total, /* Blocks subject to effector maps */ blocks_eff_select, /* Blocks selected as fuzzable */ start_time, /* Unix start time (ms) */ + prev_run_time, /* Runtime read from prev stats file*/ last_path_time, /* Time for most recent path (ms) */ last_crash_time, /* Time for most recent crash (ms) */ last_hang_time; /* Time for most recent hang (ms) */ @@ -1067,7 +1068,7 @@ void destroy_extras(afl_state_t *); /* Stats */ -u32 load_stats_file(afl_state_t *); +void load_stats_file(afl_state_t *); void write_setup_file(afl_state_t *, u32, char **); void write_stats_file(afl_state_t *, double, double, double); void maybe_update_plot_file(afl_state_t *, double, double); diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index 3edb5bb6..880551d3 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -90,20 +90,20 @@ void write_setup_file(afl_state_t *afl, u32 argc, char **argv) { } /* load some of the existing stats file when resuming.*/ -u32 load_stats_file(afl_state_t *afl) { +void load_stats_file(afl_state_t *afl) { FILE *f; u8 buf[MAX_LINE]; u8 * lptr; u8 fn[PATH_MAX]; u32 lineno = 0; - u32 prev_run_time = 0; + afl->prev_run_time = 0; snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir); f = fopen(fn, "r"); if (!f) { WARNF("Unable to load stats file '%s'", fn); - return prev_run_time; + return; } @@ -137,8 +137,8 @@ u32 load_stats_file(afl_state_t *afl) { case 3: if (!strcmp(keystring, "run_time ")) { - prev_run_time = 1000 * strtoull(lptr, &nptr, 10); - afl->start_time -= prev_run_time; + afl->prev_run_time = 1000 * strtoull(lptr, &nptr, 10); + afl->start_time -= afl->prev_run_time; } @@ -185,7 +185,7 @@ u32 load_stats_file(afl_state_t *afl) { } - return prev_run_time; + return; } diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index b7cd251a..08724959 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1682,11 +1682,9 @@ int main(int argc, char **argv_orig, char **envp) { if (unlikely(afl->old_seed_selection)) seek_to = find_start_position(afl); - u32 prev_run_time = 0; // to not call load_stats_file again after line 1705 afl->start_time = get_cur_time(); // without this, time taken for // perform_dry_run gets added to run time. - if (afl->in_place_resume || afl->afl_env.afl_autoresume) - prev_run_time = load_stats_file(afl); + if (afl->in_place_resume || afl->afl_env.afl_autoresume) load_stats_file(afl); write_stats_file(afl, 0, 0, 0); maybe_update_plot_file(afl, 0, 0); save_auto(afl); @@ -1706,7 +1704,7 @@ int main(int argc, char **argv_orig, char **envp) { // real start time, we reset, so this works correctly with -V afl->start_time = get_cur_time(); if (afl->in_place_resume || afl->afl_env.afl_autoresume) - afl->start_time -= prev_run_time; + afl->start_time -= afl->prev_run_time; u32 runs_in_current_cycle = (u32)-1; u32 prev_queued_paths = 0; -- cgit 1.4.1 From e81f30828fbe6374b0fd3be03ebc13cfb490f8a3 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Sat, 6 Feb 2021 11:24:04 +0100 Subject: fix test-qemu-mode.sh to run standalone --- test/test-libextensions.sh | 10 ---------- test/test-qemu-mode.sh | 10 ++++++++++ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/test-libextensions.sh b/test/test-libextensions.sh index 905a4cbc..40a898c8 100755 --- a/test/test-libextensions.sh +++ b/test/test-libextensions.sh @@ -38,14 +38,4 @@ test -e ../libdislocator.so && { } rm -f test-compcov -test -z "$AFL_CC" && { - if type gcc >/dev/null; then - export AFL_CC=gcc - else - if type clang >/dev/null; then - export AFL_CC=clang - fi - fi -} - . ./test-post.sh diff --git a/test/test-qemu-mode.sh b/test/test-qemu-mode.sh index 73b39a43..0cd6ef40 100755 --- a/test/test-qemu-mode.sh +++ b/test/test-qemu-mode.sh @@ -3,6 +3,16 @@ . ./test-pre.sh $ECHO "$BLUE[*] Testing: qemu_mode" +test -z "$AFL_CC" && { + if type gcc >/dev/null; then + export AFL_CC=gcc + else + if type clang >/dev/null; then + export AFL_CC=clang + fi + fi +} + test -e ../afl-qemu-trace && { cc -pie -fPIE -o test-instr ../test-instr.c cc -o test-compcov test-compcov.c -- cgit 1.4.1 From 08076f0500fda00ba09a926a25a0300dc21bade0 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Sat, 6 Feb 2021 12:04:29 +0100 Subject: fix qemu build script for Arch Linux ($CROSS) --- qemu_mode/build_qemu_support.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qemu_mode/build_qemu_support.sh b/qemu_mode/build_qemu_support.sh index a435f6f6..a161cc43 100755 --- a/qemu_mode/build_qemu_support.sh +++ b/qemu_mode/build_qemu_support.sh @@ -364,6 +364,10 @@ ORIG_CROSS="$CROSS" if [ "$ORIG_CROSS" = "" ]; then CROSS=$CPU_TARGET-linux-gnu-gcc + if ! command -v "$CROSS" > /dev/null + then # works on Arch Linux + CROSS=$CPU_TARGET-pc-linux-gnu-gcc + fi fi if ! command -v "$CROSS" > /dev/null -- cgit 1.4.1 From d920104248a6c5387267561382636de404938675 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sat, 6 Feb 2021 12:26:35 +0100 Subject: remove compiler warnings --- instrumentation/afl-compiler-rt.o.c | 20 ++++++++++---------- src/afl-cc.c | 4 ++++ utils/aflpp_driver/aflpp_driver.c | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 905051c6..ceae15d1 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -368,8 +368,8 @@ static void __afl_map_shm(void) { if (__afl_map_size && __afl_map_size > MAP_SIZE) { - u8 *map_env = getenv("AFL_MAP_SIZE"); - if (!map_env || atoi(map_env) < MAP_SIZE) { + u8 *map_env = (u8 *)getenv("AFL_MAP_SIZE"); + if (!map_env || atoi((char *)map_env) < MAP_SIZE) { send_forkserver_error(FS_ERROR_MAP_SIZE); _exit(1); @@ -378,7 +378,7 @@ static void __afl_map_shm(void) { } - __afl_area_ptr = shmat(shm_id, (void *)__afl_map_addr, 0); + __afl_area_ptr = (u8 *)shmat(shm_id, (void *)__afl_map_addr, 0); /* Whooooops. */ @@ -405,9 +405,9 @@ static void __afl_map_shm(void) { __afl_map_addr) { - __afl_area_ptr = - mmap((void *)__afl_map_addr, __afl_map_size, PROT_READ | PROT_WRITE, - MAP_FIXED_NOREPLACE | MAP_SHARED | MAP_ANONYMOUS, -1, 0); + __afl_area_ptr = (u8 *)mmap( + (void *)__afl_map_addr, __afl_map_size, PROT_READ | PROT_WRITE, + MAP_FIXED_NOREPLACE | MAP_SHARED | MAP_ANONYMOUS, -1, 0); if (__afl_area_ptr == MAP_FAILED) { @@ -425,7 +425,7 @@ static void __afl_map_shm(void) { if (__afl_final_loc > MAP_INITIAL_SIZE) { - __afl_area_ptr = malloc(__afl_final_loc); + __afl_area_ptr = (u8 *)malloc(__afl_final_loc); } @@ -439,7 +439,7 @@ static void __afl_map_shm(void) { if (__afl_map_size > MAP_INITIAL_SIZE) { - __afl_area_ptr_dummy = malloc(__afl_map_size); + __afl_area_ptr_dummy = (u8 *)malloc(__afl_map_size); if (__afl_area_ptr_dummy) { @@ -505,7 +505,7 @@ static void __afl_map_shm(void) { #else u32 shm_id = atoi(id_str); - __afl_cmp_map = shmat(shm_id, NULL, 0); + __afl_cmp_map = (struct cmp_map *)shmat(shm_id, NULL, 0); #endif __afl_cmp_map_backup = __afl_cmp_map; @@ -1528,7 +1528,7 @@ void __sanitizer_cov_trace_switch(uint64_t val, uint64_t *cases) { // to avoid to call it on .text addresses static int area_is_mapped(void *ptr, size_t len) { - char *p = ptr; + char *p = (char *)ptr; char *page = (char *)((uintptr_t)p & ~(sysconf(_SC_PAGE_SIZE) - 1)); int r = msync(page, (p - page) + len, MS_ASYNC); diff --git a/src/afl-cc.c b/src/afl-cc.c index cf10d9a7..76f4a437 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -1840,6 +1840,8 @@ int main(int argc, char **argv, char **envp) { for (i = 0; i < argc; i++) SAYF(" '%s'", argv[i]); SAYF("\n"); + fflush(stdout); + fflush(stderr); } @@ -1880,6 +1882,8 @@ int main(int argc, char **argv, char **envp) { for (i = 0; i < (s32)cc_par_cnt; i++) SAYF(" '%s'", cc_params[i]); SAYF("\n"); + fflush(stdout); + fflush(stderr); } diff --git a/utils/aflpp_driver/aflpp_driver.c b/utils/aflpp_driver/aflpp_driver.c index 7bb929b2..6af79e14 100644 --- a/utils/aflpp_driver/aflpp_driver.c +++ b/utils/aflpp_driver/aflpp_driver.c @@ -173,7 +173,7 @@ size_t LLVMFuzzerMutate(uint8_t *Data, size_t Size, size_t MaxSize) { // Execute any files provided as parameters. static int ExecuteFilesOnyByOne(int argc, char **argv) { - unsigned char *buf = malloc(MAX_FILE); + unsigned char *buf = (unsigned char *)malloc(MAX_FILE); for (int i = 1; i < argc; i++) { int fd = open(argv[i], O_RDONLY); -- cgit 1.4.1 From a763c61d89f90330bcde7c294c57cfccda1431b8 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sat, 6 Feb 2021 12:43:22 +0100 Subject: add missing sancov cmp functions --- instrumentation/afl-compiler-rt.o.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index ceae15d1..65a5d3d2 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1320,7 +1320,7 @@ void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2, uint8_t attr) { void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2, uint8_t attr) { - // fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); + fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); if (unlikely(!__afl_cmp_map || arg1 == arg2)) return; @@ -1455,24 +1455,48 @@ void __sanitizer_cov_trace_cmp1(uint8_t arg1, uint8_t arg2) { } +void __sanitizer_cov_trace_const_cmp1(uint8_t arg1, uint8_t arg2) { + + __cmplog_ins_hook1(arg1, arg2, 0); + +} + void __sanitizer_cov_trace_cmp2(uint16_t arg1, uint16_t arg2) { __cmplog_ins_hook2(arg1, arg2, 0); } +void __sanitizer_cov_trace_const_cmp2(uint16_t arg1, uint16_t arg2) { + + __cmplog_ins_hook2(arg1, arg2, 0); + +} + void __sanitizer_cov_trace_cmp4(uint32_t arg1, uint32_t arg2) { __cmplog_ins_hook4(arg1, arg2, 0); } +void __sanitizer_cov_trace_cost_cmp4(uint32_t arg1, uint32_t arg2) { + + __cmplog_ins_hook4(arg1, arg2, 0); + +} + void __sanitizer_cov_trace_cmp8(uint64_t arg1, uint64_t arg2) { __cmplog_ins_hook8(arg1, arg2, 0); } +void __sanitizer_cov_trace_const_cmp8(uint64_t arg1, uint64_t arg2) { + + __cmplog_ins_hook8(arg1, arg2, 0); + +} + #ifdef WORD_SIZE_64 void __sanitizer_cov_trace_cmp16(uint128_t arg1, uint128_t arg2) { -- cgit 1.4.1 From 96cdc97c98ee2e2af7df59252f4f0df1689afb7b Mon Sep 17 00:00:00 2001 From: vj-27 Date: Sun, 7 Feb 2021 03:33:47 +0530 Subject: prev_run_time loaded used only for ui and when writing the stats file --- include/afl-fuzz.h | 4 ++-- src/afl-fuzz-stats.c | 25 ++++++++++--------------- src/afl-fuzz.c | 5 +---- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h index 4027a88f..1d5ec1f0 100644 --- a/include/afl-fuzz.h +++ b/include/afl-fuzz.h @@ -425,7 +425,8 @@ typedef struct afl_state { really makes no sense to haul them around as function parameters. */ u64 orig_hit_cnt_puppet, last_limit_time_start, tmp_pilot_time, total_pacemaker_time, total_puppet_find, temp_puppet_find, most_time_key, - most_time, most_execs_key, most_execs, old_hit_count, force_ui_update; + most_time, most_execs_key, most_execs, old_hit_count, force_ui_update, + prev_run_time; MOpt_globals_t mopt_globals_core, mopt_globals_pilot; @@ -569,7 +570,6 @@ typedef struct afl_state { blocks_eff_total, /* Blocks subject to effector maps */ blocks_eff_select, /* Blocks selected as fuzzable */ start_time, /* Unix start time (ms) */ - prev_run_time, /* Runtime read from prev stats file*/ last_path_time, /* Time for most recent path (ms) */ last_crash_time, /* Time for most recent crash (ms) */ last_hang_time; /* Time for most recent hang (ms) */ diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c index 880551d3..66efeb20 100644 --- a/src/afl-fuzz-stats.c +++ b/src/afl-fuzz-stats.c @@ -97,7 +97,6 @@ void load_stats_file(afl_state_t *afl) { u8 * lptr; u8 fn[PATH_MAX]; u32 lineno = 0; - afl->prev_run_time = 0; snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir); f = fopen(fn, "r"); if (!f) { @@ -135,13 +134,8 @@ void load_stats_file(afl_state_t *afl) { switch (lineno) { case 3: - if (!strcmp(keystring, "run_time ")) { - + if (!strcmp(keystring, "run_time ")) afl->prev_run_time = 1000 * strtoull(lptr, &nptr, 10); - afl->start_time -= afl->prev_run_time; - - } - break; case 5: if (!strcmp(keystring, "cycles_done ")) @@ -279,12 +273,13 @@ void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability, "\n" "target_mode : %s%s%s%s%s%s%s%s%s\n" "command_line : %s\n", - afl->start_time / 1000, cur_time / 1000, - (cur_time - afl->start_time) / 1000, (u32)getpid(), - afl->queue_cycle ? (afl->queue_cycle - 1) : 0, afl->cycles_wo_finds, - afl->fsrv.total_execs, + (afl->start_time - afl->prev_run_time) / 1000, cur_time / 1000, + (afl->prev_run_time + cur_time - afl->start_time) / 1000, + (u32)getpid(), afl->queue_cycle ? (afl->queue_cycle - 1) : 0, + afl->cycles_wo_finds, afl->fsrv.total_execs, afl->fsrv.total_execs / - ((double)(get_cur_time() - afl->start_time) / 1000), + ((double)(afl->prev_run_time + get_cur_time() - afl->start_time) / + 1000), afl->last_avg_execs_saved, afl->queued_paths, afl->queued_favored, afl->queued_discovered, afl->queued_imported, afl->max_depth, afl->current_entry, afl->pending_favored, afl->pending_not_fuzzed, @@ -479,8 +474,8 @@ void show_stats(afl_state_t *afl) { if (likely(cur_ms != afl->start_time)) { - afl->stats_avg_exec = - ((double)afl->fsrv.total_execs) * 1000 / (cur_ms - afl->start_time); + afl->stats_avg_exec = ((double)afl->fsrv.total_execs) * 1000 / + (afl->prev_run_time + cur_ms - afl->start_time); } @@ -692,7 +687,7 @@ void show_stats(afl_state_t *afl) { } - u_stringify_time_diff(time_tmp, cur_ms, afl->start_time); + u_stringify_time_diff(time_tmp, afl->prev_run_time + cur_ms, afl->start_time); SAYF(bV bSTOP " run time : " cRST "%-33s " bSTG bV bSTOP " cycles done : %s%-5s " bSTG bV "\n", time_tmp, tmp, u_stringify_int(IB(0), afl->queue_cycle - 1)); diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index 08724959..e4139857 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -1682,8 +1682,7 @@ int main(int argc, char **argv_orig, char **envp) { if (unlikely(afl->old_seed_selection)) seek_to = find_start_position(afl); - afl->start_time = get_cur_time(); // without this, time taken for - // perform_dry_run gets added to run time. + afl->start_time = get_cur_time(); if (afl->in_place_resume || afl->afl_env.afl_autoresume) load_stats_file(afl); write_stats_file(afl, 0, 0, 0); maybe_update_plot_file(afl, 0, 0); @@ -1703,8 +1702,6 @@ int main(int argc, char **argv_orig, char **envp) { // (void)nice(-20); // does not improve the speed // real start time, we reset, so this works correctly with -V afl->start_time = get_cur_time(); - if (afl->in_place_resume || afl->afl_env.afl_autoresume) - afl->start_time -= afl->prev_run_time; u32 runs_in_current_cycle = (u32)-1; u32 prev_queued_paths = 0; -- cgit 1.4.1 From 209c5ba4657b641bf261da7ac9ce7d3f809109c2 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sun, 7 Feb 2021 05:33:02 +0100 Subject: larger map, stats reload fix, code format --- docs/Changelog.md | 2 + instrumentation/afl-compiler-rt.o.c | 2 +- instrumentation/afl-llvm-lto-instrumentation.so.cc | 3 +- qemu_mode/libqasan/dlmalloc.c | 5 ++ src/afl-fuzz-bitmap.c | 3 +- src/afl-fuzz-statsd.c | 63 ++++++++++++---------- utils/afl_untracer/afl-untracer.c | 10 ++-- 7 files changed, 52 insertions(+), 36 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index e9efdf38..f2041917 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -26,6 +26,8 @@ sending a mail to . `-i` or resumes (as these have most likely already been done) - fix crash for very, very fast targets+systems (thanks to mhlakhani for reporting) + - on restarts (-i)/autoresume (AFL_AUTORESUME) the stats are now + reloaded and used, thanks to Vimal Joseph for this PR! - if determinstic mode is active (-D, or -M without -d) then we sync after every queue entry as this can take very long time otherwise - better detection if a target needs a large shared map diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 65a5d3d2..059691ec 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -70,7 +70,7 @@ run. It will end up as .comm, so it shouldn't be too wasteful. */ #if MAP_SIZE <= 65536 - #define MAP_INITIAL_SIZE 1048576 + #define MAP_INITIAL_SIZE 2097152 #else #define MAP_INITIAL_SIZE MAP_SIZE #endif diff --git a/instrumentation/afl-llvm-lto-instrumentation.so.cc b/instrumentation/afl-llvm-lto-instrumentation.so.cc index fa494f44..841d52e5 100644 --- a/instrumentation/afl-llvm-lto-instrumentation.so.cc +++ b/instrumentation/afl-llvm-lto-instrumentation.so.cc @@ -69,7 +69,8 @@ class AFLLTOPass : public ModulePass { if (getenv("AFL_DEBUG")) debug = 1; if ((ptr = getenv("AFL_LLVM_LTO_STARTID")) != NULL) - if ((afl_global_id = (uint32_t)atoi(ptr)) < 0 || afl_global_id >= MAP_SIZE) + if ((afl_global_id = (uint32_t)atoi(ptr)) < 0 || + afl_global_id >= MAP_SIZE) FATAL("AFL_LLVM_LTO_STARTID value of \"%s\" is not between 0 and %u\n", ptr, MAP_SIZE - 1); diff --git a/qemu_mode/libqasan/dlmalloc.c b/qemu_mode/libqasan/dlmalloc.c index 39ca4301..ce94451d 100644 --- a/qemu_mode/libqasan/dlmalloc.c +++ b/qemu_mode/libqasan/dlmalloc.c @@ -3907,6 +3907,7 @@ static void internal_malloc_stats(mstate m) { clear_smallmap(M, I); \ \ } else if (RTCHECK(B == smallbin_at(M, I) || \ + \ (ok_address(M, B) && B->fd == P))) { \ \ F->bk = B; \ @@ -4117,6 +4118,7 @@ static void internal_malloc_stats(mstate m) { XP->child[1] = R; \ \ } else \ + \ CORRUPTION_ERROR_ACTION(M); \ if (R != 0) { \ \ @@ -4132,6 +4134,7 @@ static void internal_malloc_stats(mstate m) { C0->parent = R; \ \ } else \ + \ CORRUPTION_ERROR_ACTION(M); \ \ } \ @@ -4143,11 +4146,13 @@ static void internal_malloc_stats(mstate m) { C1->parent = R; \ \ } else \ + \ CORRUPTION_ERROR_ACTION(M); \ \ } \ \ } else \ + \ CORRUPTION_ERROR_ACTION(M); \ \ } \ diff --git a/src/afl-fuzz-bitmap.c b/src/afl-fuzz-bitmap.c index 0c4a114e..4ed59364 100644 --- a/src/afl-fuzz-bitmap.c +++ b/src/afl-fuzz-bitmap.c @@ -325,7 +325,8 @@ u8 *describe_op(afl_state_t *afl, u8 new_bits, size_t max_description_len) { } - sprintf(ret + strlen(ret), ",time:%llu", get_cur_time() - afl->start_time); + sprintf(ret + strlen(ret), ",time:%llu", + get_cur_time() + afl->prev_run_time - afl->start_time); if (afl->current_custom_fuzz && afl->current_custom_fuzz->afl_custom_describe) { diff --git a/src/afl-fuzz-statsd.c b/src/afl-fuzz-statsd.c index 69cafd90..461bbbf6 100644 --- a/src/afl-fuzz-statsd.c +++ b/src/afl-fuzz-statsd.c @@ -1,3 +1,8 @@ +/* + * This implements rpc.statsd support, see docs/rpc_statsd.md + * + */ + #include #include #include @@ -226,37 +231,39 @@ int statsd_format_metric(afl_state_t *afl, char *buff, size_t bufflen) { */ if (afl->statsd_metric_format_type == STATSD_TAGS_TYPE_SUFFIX) { - snprintf(buff, bufflen, afl->statsd_metric_format, - afl->queue_cycle ? (afl->queue_cycle - 1) : 0, tags, - afl->cycles_wo_finds, tags, afl->fsrv.total_execs, tags, - afl->fsrv.total_execs / - ((double)(get_cur_time() - afl->start_time) / 1000), - tags, afl->queued_paths, tags, afl->queued_favored, tags, - afl->queued_discovered, tags, afl->queued_imported, tags, - afl->max_depth, tags, afl->current_entry, tags, - afl->pending_favored, tags, afl->pending_not_fuzzed, tags, - afl->queued_variable, tags, afl->unique_crashes, tags, - afl->unique_hangs, tags, afl->total_crashes, tags, - afl->slowest_exec_ms, tags, - count_non_255_bytes(afl, afl->virgin_bits), tags, - afl->var_byte_count, tags, afl->expand_havoc, tags); + snprintf( + buff, bufflen, afl->statsd_metric_format, + afl->queue_cycle ? (afl->queue_cycle - 1) : 0, tags, + afl->cycles_wo_finds, tags, afl->fsrv.total_execs, tags, + afl->fsrv.total_execs / + ((double)(get_cur_time() + afl->prev_run_time - afl->start_time) / + 1000), + tags, afl->queued_paths, tags, afl->queued_favored, tags, + afl->queued_discovered, tags, afl->queued_imported, tags, + afl->max_depth, tags, afl->current_entry, tags, afl->pending_favored, + tags, afl->pending_not_fuzzed, tags, afl->queued_variable, tags, + afl->unique_crashes, tags, afl->unique_hangs, tags, afl->total_crashes, + tags, afl->slowest_exec_ms, tags, + count_non_255_bytes(afl, afl->virgin_bits), tags, afl->var_byte_count, + tags, afl->expand_havoc, tags); } else if (afl->statsd_metric_format_type == STATSD_TAGS_TYPE_MID) { - snprintf(buff, bufflen, afl->statsd_metric_format, tags, - afl->queue_cycle ? (afl->queue_cycle - 1) : 0, tags, - afl->cycles_wo_finds, tags, afl->fsrv.total_execs, tags, - afl->fsrv.total_execs / - ((double)(get_cur_time() - afl->start_time) / 1000), - tags, afl->queued_paths, tags, afl->queued_favored, tags, - afl->queued_discovered, tags, afl->queued_imported, tags, - afl->max_depth, tags, afl->current_entry, tags, - afl->pending_favored, tags, afl->pending_not_fuzzed, tags, - afl->queued_variable, tags, afl->unique_crashes, tags, - afl->unique_hangs, tags, afl->total_crashes, tags, - afl->slowest_exec_ms, tags, - count_non_255_bytes(afl, afl->virgin_bits), tags, - afl->var_byte_count, tags, afl->expand_havoc); + snprintf( + buff, bufflen, afl->statsd_metric_format, tags, + afl->queue_cycle ? (afl->queue_cycle - 1) : 0, tags, + afl->cycles_wo_finds, tags, afl->fsrv.total_execs, tags, + afl->fsrv.total_execs / + ((double)(get_cur_time() + afl->prev_run_time - afl->start_time) / + 1000), + tags, afl->queued_paths, tags, afl->queued_favored, tags, + afl->queued_discovered, tags, afl->queued_imported, tags, + afl->max_depth, tags, afl->current_entry, tags, afl->pending_favored, + tags, afl->pending_not_fuzzed, tags, afl->queued_variable, tags, + afl->unique_crashes, tags, afl->unique_hangs, tags, afl->total_crashes, + tags, afl->slowest_exec_ms, tags, + count_non_255_bytes(afl, afl->virgin_bits), tags, afl->var_byte_count, + tags, afl->expand_havoc); } diff --git a/utils/afl_untracer/afl-untracer.c b/utils/afl_untracer/afl-untracer.c index 1f1a10ea..2baeb58d 100644 --- a/utils/afl_untracer/afl-untracer.c +++ b/utils/afl_untracer/afl-untracer.c @@ -480,9 +480,9 @@ void setup_trap_instrumentation(void) { // Index into the coverage bitmap for the current trap instruction. #ifdef __aarch64__ uint64_t bitmap_index = 0; -#ifdef __APPLE__ + #ifdef __APPLE__ pthread_jit_write_protect_np(0); -#endif + #endif #else uint32_t bitmap_index = 0; #endif @@ -627,13 +627,13 @@ static void sigtrap_handler(int signum, siginfo_t *si, void *context) { // Must re-execute the instruction, so decrement PC by one instruction. ucontext_t *ctx = (ucontext_t *)context; #if defined(__APPLE__) && defined(__LP64__) -#if defined(__x86_64__) + #if defined(__x86_64__) ctx->uc_mcontext->__ss.__rip -= 1; addr = ctx->uc_mcontext->__ss.__rip; -#else + #else ctx->uc_mcontext->__ss.__pc -= 4; addr = ctx->uc_mcontext->__ss.__pc; -#endif + #endif #elif defined(__linux__) #if defined(__x86_64__) || defined(__i386__) ctx->uc_mcontext.gregs[REG_RIP] -= 1; -- cgit 1.4.1 From aeb7d7048371cd91ab9280c3958f1c35e5d5e758 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sun, 7 Feb 2021 06:16:53 +0100 Subject: remove debug output --- instrumentation/afl-compiler-rt.o.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c index 059691ec..3a9e3e0e 100644 --- a/instrumentation/afl-compiler-rt.o.c +++ b/instrumentation/afl-compiler-rt.o.c @@ -1320,7 +1320,7 @@ void __cmplog_ins_hook4(uint32_t arg1, uint32_t arg2, uint8_t attr) { void __cmplog_ins_hook8(uint64_t arg1, uint64_t arg2, uint8_t attr) { - fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); + // fprintf(stderr, "hook8 arg0=%lx arg1=%lx attr=%u\n", arg1, arg2, attr); if (unlikely(!__afl_cmp_map || arg1 == arg2)) return; -- cgit 1.4.1 From 0ad56167c53ae660d40ccc6cdedb39f0a52eefcd Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sun, 7 Feb 2021 07:51:29 +0100 Subject: fix scan-build issues --- instrumentation/LLVMInsTrim.so.cc | 2 +- instrumentation/SanitizerCoverageLTO.so.cc | 2 +- instrumentation/afl-llvm-common.cc | 2 +- instrumentation/afl-llvm-dict2file.so.cc | 1 - instrumentation/afl-llvm-lto-instrumentation.so.cc | 2 +- instrumentation/afl-llvm-pass.so.cc | 1 + instrumentation/compare-transform-pass.so.cc | 2 +- instrumentation/split-compares-pass.so.cc | 37 +++++++++------------- src/afl-cc.c | 7 ---- src/afl-fuzz-init.c | 2 +- src/afl-fuzz-redqueen.c | 36 ++++++++++++++++++--- 11 files changed, 53 insertions(+), 41 deletions(-) diff --git a/instrumentation/LLVMInsTrim.so.cc b/instrumentation/LLVMInsTrim.so.cc index 235ee30f..948f8f3a 100644 --- a/instrumentation/LLVMInsTrim.so.cc +++ b/instrumentation/LLVMInsTrim.so.cc @@ -459,7 +459,7 @@ struct InsTrim : public ModulePass { BasicBlock *PBB = *PI; auto It = PredMap.insert({PBB, genLabel()}); unsigned Label = It.first->second; - cur_loc = Label; + // cur_loc = Label; PN->addIncoming(ConstantInt::get(Int32Ty, Label), PBB); } diff --git a/instrumentation/SanitizerCoverageLTO.so.cc b/instrumentation/SanitizerCoverageLTO.so.cc index e3490847..3026abc8 100644 --- a/instrumentation/SanitizerCoverageLTO.so.cc +++ b/instrumentation/SanitizerCoverageLTO.so.cc @@ -760,7 +760,7 @@ bool ModuleSanitizerCoverage::instrumentModule( if (literalLength + 1 == optLength) { Str2.append("\0", 1); // add null byte - addedNull = true; + // addedNull = true; } diff --git a/instrumentation/afl-llvm-common.cc b/instrumentation/afl-llvm-common.cc index a27c4069..aa54f4f7 100644 --- a/instrumentation/afl-llvm-common.cc +++ b/instrumentation/afl-llvm-common.cc @@ -351,7 +351,7 @@ static std::string getSourceName(llvm::Function *F) { if (cDILoc) { instFilename = cDILoc->getFilename(); } - if (instFilename.str().empty()) { + if (instFilename.str().empty() && cDILoc) { /* If the original location is empty, try using the inlined location */ diff --git a/instrumentation/afl-llvm-dict2file.so.cc b/instrumentation/afl-llvm-dict2file.so.cc index a4b33732..6f34ac5a 100644 --- a/instrumentation/afl-llvm-dict2file.so.cc +++ b/instrumentation/afl-llvm-dict2file.so.cc @@ -430,7 +430,6 @@ bool AFLdict2filePass::runOnModule(Module &M) { if (literalLength + 1 == optLength) { Str2.append("\0", 1); // add null byte - addedNull = true; } diff --git a/instrumentation/afl-llvm-lto-instrumentation.so.cc b/instrumentation/afl-llvm-lto-instrumentation.so.cc index 841d52e5..f5c24e41 100644 --- a/instrumentation/afl-llvm-lto-instrumentation.so.cc +++ b/instrumentation/afl-llvm-lto-instrumentation.so.cc @@ -546,7 +546,7 @@ bool AFLLTOPass::runOnModule(Module &M) { if (literalLength + 1 == optLength) { Str2.append("\0", 1); // add null byte - addedNull = true; + // addedNull = true; } diff --git a/instrumentation/afl-llvm-pass.so.cc b/instrumentation/afl-llvm-pass.so.cc index 57ff3b47..16fd9c94 100644 --- a/instrumentation/afl-llvm-pass.so.cc +++ b/instrumentation/afl-llvm-pass.so.cc @@ -538,6 +538,7 @@ bool AFLCoverage::runOnModule(Module &M) { Store = IRB.CreateStore(ConstantInt::get(Int32Ty, cur_loc >> 1), AFLPrevLoc); + Store->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None)); } diff --git a/instrumentation/compare-transform-pass.so.cc b/instrumentation/compare-transform-pass.so.cc index da5cf7e9..8b00d8d1 100644 --- a/instrumentation/compare-transform-pass.so.cc +++ b/instrumentation/compare-transform-pass.so.cc @@ -391,7 +391,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, if (val && !val->empty()) { Str2 = StringRef(*val); - HasStr2 = true; + // HasStr2 = true; } diff --git a/instrumentation/split-compares-pass.so.cc b/instrumentation/split-compares-pass.so.cc index b6d8c466..80cd90ba 100644 --- a/instrumentation/split-compares-pass.so.cc +++ b/instrumentation/split-compares-pass.so.cc @@ -407,6 +407,7 @@ bool SplitComparesTransform::simplifyIntSignedness(Module &M) { auto op1 = IcmpInst->getOperand(1); IntegerType *intTyOp0 = dyn_cast(op0->getType()); + if (!intTyOp0) { continue; } unsigned bitw = intTyOp0->getBitWidth(); IntegerType *IntType = IntegerType::get(C, bitw); @@ -606,10 +607,11 @@ size_t SplitComparesTransform::splitFPCompares(Module &M) { : sizeInBits == 64 ? 53 : sizeInBits == 128 ? 113 : sizeInBits == 16 ? 11 - /* sizeInBits == 80 */ - : 65; + : sizeInBits == 80 ? 65 + : sizeInBits - 8; - const unsigned shiftR_exponent = precision - 1; + const unsigned shiftR_exponent = precision - 1; + // BUG FIXME TODO: u64 does not work for > 64 bit ... e.g. 80 and 128 bit const unsigned long long mask_fraction = (1ULL << (shiftR_exponent - 1)) | ((1ULL << (shiftR_exponent - 1)) - 1); const unsigned long long mask_exponent = @@ -1300,12 +1302,9 @@ bool SplitComparesTransform::runOnModule(Module &M) { case 64: count += splitIntCompares(M, bitw); - /* - if (!be_quiet) - errs() << "Split-integer-compare-pass " << bitw << "bit: " << - count - << " split\n"; - */ + if (debug) + errs() << "Split-integer-compare-pass " << bitw << "bit: " << count + << " split\n"; bitw >>= 1; #if LLVM_VERSION_MAJOR > 3 || \ (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 7) @@ -1313,12 +1312,9 @@ bool SplitComparesTransform::runOnModule(Module &M) { #endif case 32: count += splitIntCompares(M, bitw); - /* - if (!be_quiet) - errs() << "Split-integer-compare-pass " << bitw << "bit: " << - count - << " split\n"; - */ + if (debug) + errs() << "Split-integer-compare-pass " << bitw << "bit: " << count + << " split\n"; bitw >>= 1; #if LLVM_VERSION_MAJOR > 3 || \ (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR > 7) @@ -1326,13 +1322,10 @@ bool SplitComparesTransform::runOnModule(Module &M) { #endif case 16: count += splitIntCompares(M, bitw); - /* - if (!be_quiet) - errs() << "Split-integer-compare-pass " << bitw << "bit: " << - count - << " split\n"; - */ - bitw >>= 1; + if (debug) + errs() << "Split-integer-compare-pass " << bitw << "bit: " << count + << " split\n"; + // bitw >>= 1; break; default: diff --git a/src/afl-cc.c b/src/afl-cc.c index 76f4a437..0ae401e7 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -315,16 +315,9 @@ static void edit_params(u32 argc, char **argv, char **envp) { u8 fortify_set = 0, asan_set = 0, x_set = 0, bit_mode = 0, shared_linking = 0, preprocessor_only = 0, have_unroll = 0, have_o = 0, have_pic = 0, have_c = 0; - u8 *name; cc_params = ck_alloc((argc + 128) * sizeof(u8 *)); - name = strrchr(argv[0], '/'); - if (!name) - name = argv[0]; - else - ++name; - if (lto_mode) { if (lto_flag[0] != '-') diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c index 40ba20c7..702e732d 100644 --- a/src/afl-fuzz-init.c +++ b/src/afl-fuzz-init.c @@ -1242,7 +1242,7 @@ static void link_or_copy(u8 *old_path, u8 *new_path) { void pivot_inputs(afl_state_t *afl) { - struct queue_entry *q = afl->queue; + struct queue_entry *q; u32 id = 0, i; ACTF("Creating hard links for all input files..."); diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index f619a6d3..002929c5 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -1415,7 +1415,7 @@ static void try_to_add_to_dict(afl_state_t *afl, u64 v, u8 shape) { } else if (b[k] == 0xff) { - ++cons_0; + ++cons_ff; } else { @@ -1473,7 +1473,7 @@ static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) { } else if (b[k] == 0xff) { - ++cons_0; + ++cons_ff; } else { @@ -2410,7 +2410,21 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { // manually clear the full cmp_map memset(afl->shm.cmp_map, 0, sizeof(struct cmp_map)); - if (unlikely(common_fuzz_cmplog_stuff(afl, orig_buf, len))) { return 1; } + if (unlikely(common_fuzz_cmplog_stuff(afl, orig_buf, len))) { + + afl->queue_cur->colorized = CMPLOG_LVL_MAX; + while (taint) { + + t = taint->next; + ck_free(taint); + taint = t; + + } + + return 1; + + } + if (unlikely(!afl->orig_cmp_map)) { afl->orig_cmp_map = ck_alloc_nozero(sizeof(struct cmp_map)); @@ -2419,7 +2433,20 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { memcpy(afl->orig_cmp_map, afl->shm.cmp_map, sizeof(struct cmp_map)); memset(afl->shm.cmp_map->headers, 0, sizeof(struct cmp_header) * CMP_MAP_W); - if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) { return 1; } + if (unlikely(common_fuzz_cmplog_stuff(afl, buf, len))) { + + afl->queue_cur->colorized = CMPLOG_LVL_MAX; + while (taint) { + + t = taint->next; + ck_free(taint); + taint = t; + + } + + return 1; + + } #ifdef _DEBUG dump("ORIG", orig_buf, len); @@ -2530,7 +2557,6 @@ exit_its: afl->queue_cur->colorized = CMPLOG_LVL_MAX; ck_free(afl->queue_cur->cmplog_colorinput); - t = taint; while (taint) { t = taint->next; -- cgit 1.4.1 From c2c65fd9c1cc3604200bc6ae62e2a1a7e6950a0e Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sun, 7 Feb 2021 09:42:28 +0100 Subject: mark llvm 13 as unsupported (yet) --- GNUmakefile.llvm | 2 +- README.md | 3 +++ qemu_mode/libqasan/dlmalloc.c | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/GNUmakefile.llvm b/GNUmakefile.llvm index a9092579..d3691658 100644 --- a/GNUmakefile.llvm +++ b/GNUmakefile.llvm @@ -43,7 +43,7 @@ endif LLVMVER = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/git//' | sed 's/svn//' ) LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/\..*//' ) LLVM_MINOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/.*\.//' | sed 's/git//' | sed 's/svn//' | sed 's/ .*//' ) -LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^3\.[0-3]|^19' && echo 1 || echo 0 ) +LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^3\.[0-3]|^1[3-9]' && echo 1 || echo 0 ) LLVM_NEW_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[0-9]' && echo 1 || echo 0 ) LLVM_10_OK = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[1-9]|^10\.[1-9]|^10\.0.[1-9]' && echo 1 || echo 0 ) LLVM_HAVE_LTO = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[1-9]' && echo 1 || echo 0 ) diff --git a/README.md b/README.md index 118a619d..e3886ca7 100644 --- a/README.md +++ b/README.md @@ -730,6 +730,9 @@ campaigns as these are much shorter runnings. 1. Always: * LTO has a much longer compile time which is diametrical to short fuzzing - hence use afl-clang-fast instead. + * If you compile with CMPLOG then you can save fuzzing time and reuse that + compiled target for both the -c option and the main fuzz target. + This will impact the speed by ~15% though. * `AFL_FAST_CAL` - Enable fast calibration, this halfs the time the saturated corpus needs to be loaded. * `AFL_CMPLOG_ONLY_NEW` - only perform cmplog on new found paths, not the diff --git a/qemu_mode/libqasan/dlmalloc.c b/qemu_mode/libqasan/dlmalloc.c index ce94451d..3c7dcea8 100644 --- a/qemu_mode/libqasan/dlmalloc.c +++ b/qemu_mode/libqasan/dlmalloc.c @@ -3908,6 +3908,7 @@ static void internal_malloc_stats(mstate m) { \ } else if (RTCHECK(B == smallbin_at(M, I) || \ \ + \ (ok_address(M, B) && B->fd == P))) { \ \ F->bk = B; \ @@ -4119,6 +4120,7 @@ static void internal_malloc_stats(mstate m) { \ } else \ \ + \ CORRUPTION_ERROR_ACTION(M); \ if (R != 0) { \ \ @@ -4135,6 +4137,7 @@ static void internal_malloc_stats(mstate m) { \ } else \ \ + \ CORRUPTION_ERROR_ACTION(M); \ \ } \ @@ -4147,12 +4150,14 @@ static void internal_malloc_stats(mstate m) { \ } else \ \ + \ CORRUPTION_ERROR_ACTION(M); \ \ } \ \ } else \ \ + \ CORRUPTION_ERROR_ACTION(M); \ \ } \ -- cgit 1.4.1 From c465e48e27bb928704031234366934da6c9a1ab0 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sun, 7 Feb 2021 16:19:27 +0100 Subject: remove AFL_CC from unset list to allow success for unusual environments --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index b0ab1ab0..4ba5d3b3 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -519,7 +519,7 @@ code-format: ifndef AFL_NO_X86 test_build: afl-cc afl-gcc afl-as afl-showmap @echo "[*] Testing the CC wrapper afl-cc and its instrumentation output..." - @unset AFL_MAP_SIZE AFL_USE_UBSAN AFL_USE_CFISAN AFL_USE_ASAN AFL_USE_MSAN AFL_CC; ASAN_OPTIONS=detect_leaks=0 AFL_INST_RATIO=100 AFL_PATH=. ./afl-cc test-instr.c -o test-instr 2>&1 || (echo "Oops, afl-cc failed"; exit 1 ) + @unset AFL_MAP_SIZE AFL_USE_UBSAN AFL_USE_CFISAN AFL_USE_ASAN AFL_USE_MSAN; ASAN_OPTIONS=detect_leaks=0 AFL_INST_RATIO=100 AFL_PATH=. ./afl-cc test-instr.c -o test-instr 2>&1 || (echo "Oops, afl-cc failed"; exit 1 ) ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr0 ./test-instr < /dev/null echo 1 | ASAN_OPTIONS=detect_leaks=0 ./afl-showmap -m none -q -o .test-instr1 ./test-instr @rm -f test-instr -- cgit 1.4.1 From 17cbb03ba7d4fc0eb3b3b47911c58e25b567e89b Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Tue, 9 Feb 2021 09:18:24 +0100 Subject: more cmplog options in config.h --- include/config.h | 12 ++++++++--- src/afl-fuzz-redqueen.c | 56 ++++++++++++++++++++++--------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/config.h b/include/config.h index 60872785..25fa1142 100644 --- a/include/config.h +++ b/include/config.h @@ -36,17 +36,23 @@ /* CMPLOG/REDQUEEN TUNING * - * Here you can tuning and solving options for cmplog. + * Here you can modify tuning and solving options for CMPLOG. * Note that these are run-time options for afl-fuzz, no target * recompilation required. * */ +/* Enable arithmetic compare solving for both path */ +#define CMPLOG_SOLVE_ARITHMETIC + /* Enable transform following (XOR/ADD/SUB manipulations, hex en/decoding) */ -// #define CMPLOG_TRANSFORM +#define CMPLOG_SOLVE_TRANSFORM /* if TRANSFORM is enabled, this additionally enables base64 en/decoding */ -// #define CMPLOG_TRANSFORM_BASE64 +// #define CMPLOG_SOLVE_TRANSFORM_BASE64 + +/* If a redqueen pass finds more than one solve, try to combine them? */ +#define CMPLOG_COMBINE /* Minimum % of the corpus to perform cmplog on. Default: 20% */ #define CMPLOG_CORPUS_PERCENT 20U diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 002929c5..7844eedf 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -30,8 +30,7 @@ //#define _DEBUG //#define CMPLOG_INTROSPECTION -#define COMBINE -#define ARITHMETIC_LESSER_GREATER +#define CMPLOG_COMBINE // CMP attribute enum enum { @@ -496,7 +495,7 @@ static u8 its_fuzz(afl_state_t *afl, u8 *buf, u32 len, u8 *status) { } -#ifdef CMPLOG_TRANSFORM +#ifdef CMPLOG_SOLVE_TRANSFORM static int strntoll(const char *str, size_t sz, char **end, int base, long long *out) { @@ -577,7 +576,7 @@ static int is_hex(const char *str) { } - #ifdef CMPLOG_TRANSFORM_BASE64 + #ifdef CMPLOG_SOLVE_TRANSFORM_BASE64 // tests 4 bytes at location static int is_base64(const char *str) { @@ -717,7 +716,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // o_pattern, pattern, repl, changed_val, idx, taint_len, // h->shape + 1, attr); -#ifdef CMPLOG_TRANSFORM +#ifdef CMPLOG_SOLVE_TRANSFORM // reverse atoi()/strnu?toll() is expensive, so we only to it in lvl 3 if (lvl & LVL3) { @@ -1009,7 +1008,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u64 tmp_64 = *buf_64; *buf_64 = repl; if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } -#ifdef COMBINE +#ifdef CMPLOG_COMBINE if (*status == 1) { memcpy(cbuf + idx, buf_64, 8); } #endif *buf_64 = tmp_64; @@ -1050,7 +1049,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u32 tmp_32 = *buf_32; *buf_32 = (u32)repl; if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } -#ifdef COMBINE +#ifdef CMPLOG_COMBINE if (*status == 1) { memcpy(cbuf + idx, buf_32, 4); } #endif *buf_32 = tmp_32; @@ -1084,7 +1083,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u16 tmp_16 = *buf_16; *buf_16 = (u16)repl; if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } -#ifdef COMBINE +#ifdef CMPLOG_COMBINE if (*status == 1) { memcpy(cbuf + idx, buf_16, 2); } #endif *buf_16 = tmp_16; @@ -1122,7 +1121,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, u8 tmp_8 = *buf_8; *buf_8 = (u8)repl; if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } -#ifdef COMBINE +#ifdef CMPLOG_COMBINE if (*status == 1) { cbuf[idx] = *buf_8; } #endif *buf_8 = tmp_8; @@ -1139,7 +1138,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, // 16 = modified float, 32 = modified integer (modified = wont match // in original buffer) -#ifdef ARITHMETIC_LESSER_GREATER +#ifdef CMPLOG_SOLVE_ARITHMETIC if (lvl < LVL3 || attr == IS_TRANSFORM) { return 0; } if (!(attr & (IS_GREATER | IS_LESSER)) || SHAPE_BYTES(h->shape) < 4) { @@ -1304,7 +1303,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } -#endif /* ARITHMETIC_LESSER_GREATER */ +#endif /* CMPLOG_SOLVE_ARITHMETIC */ return 0; @@ -1366,7 +1365,7 @@ static u8 cmp_extend_encodingN(afl_state_t *afl, struct cmp_header *h, if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } - #ifdef COMBINE + #ifdef CMPLOG_COMBINE if (*status == 1) { memcpy(cbuf + idx, r, shape); } #endif @@ -1774,10 +1773,10 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, u32 taint_len, u8 *orig_buf, u8 *buf, u8 *cbuf, u32 len, u8 lvl, u8 *status) { -#ifndef COMBINE +#ifndef CMPLOG_COMBINE (void)(cbuf); #endif -#ifndef CMPLOG_TRANSFORM +#ifndef CMPLOG_SOLVE_TRANSFORM (void)(changed_val); #endif @@ -1847,7 +1846,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, if (unlikely(its_fuzz(afl, buf, len, status))) { return 1; } -#ifdef COMBINE +#ifdef CMPLOG_COMBINE if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i); } #endif @@ -1859,14 +1858,14 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } -#ifdef CMPLOG_TRANSFORM +#ifdef CMPLOG_SOLVE_TRANSFORM if (*status == 1) return 0; if (lvl & LVL3) { u32 toupper = 0, tolower = 0, xor = 0, arith = 0, tohex = 0, fromhex = 0; - #ifdef CMPLOG_TRANSFORM_BASE64 + #ifdef CMPLOG_SOLVE_TRANSFORM_BASE64 u32 tob64 = 0, fromb64 = 0; #endif u32 from_0 = 0, from_x = 0, from_X = 0, from_slash = 0, from_up = 0; @@ -1964,7 +1963,7 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - #ifdef CMPLOG_TRANSFORM_BASE64 + #ifdef CMPLOG_SOLVE_TRANSFORM_BASE64 if (i % 3 == 2 && i < 24) { if (is_base64(repl + ((i / 3) << 2))) tob64 += 3; @@ -2012,13 +2011,13 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, "from_0=%u from_slash=%u from_x=%u\n", idx, i, xor, arith, tolower, toupper, tohex, fromhex, to_0, to_slash, to_x, from_0, from_slash, from_x); - #ifdef CMPLOG_TRANSFORM_BASE64 + #ifdef CMPLOG_SOLVE_TRANSFORM_BASE64 fprintf(stderr, "RTN idx=%u loop=%u tob64=%u from64=%u\n", tob64, fromb64); #endif #endif - #ifdef CMPLOG_TRANSFORM_BASE64 + #ifdef CMPLOG_SOLVE_TRANSFORM_BASE64 // input is base64 and converted to binary? convert repl to base64! if ((i % 4) == 3 && i < 24 && fromb64 > i) { @@ -2170,14 +2169,14 @@ static u8 rtn_extend_encoding(afl_state_t *afl, u8 *pattern, u8 *repl, } - #ifdef COMBINE + #ifdef CMPLOG_COMBINE if (*status == 1) { memcpy(cbuf + idx, &buf[idx], i + 1); } #endif if ((i >= 7 && (i >= xor&&i >= arith &&i >= tolower &&i >= toupper &&i > tohex &&i > (fromhex + from_0 + from_x + from_slash + 1) - #ifdef CMPLOG_TRANSFORM_BASE64 + #ifdef CMPLOG_SOLVE_TRANSFORM_BASE64 && i > tob64 + 3 && i > fromb64 + 4 #endif )) || @@ -2469,7 +2468,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { u32 lvl = (afl->queue_cur->colorized ? 0 : LVL1) + (afl->cmplog_lvl == CMPLOG_LVL_MAX ? LVL3 : 0); -#ifdef COMBINE +#ifdef CMPLOG_COMBINE u8 *cbuf = afl_realloc((void **)&afl->in_scratch_buf, len + 128); memcpy(cbuf, orig_buf, len); u8 *virgin_backup = afl_realloc((void **)&afl->ex_buf, afl->shm.map_size); @@ -2526,7 +2525,7 @@ u8 input_to_state_stage(afl_state_t *afl, u8 *orig_buf, u8 *buf, u32 len) { } else if ((lvl & LVL1) -#ifdef CMPLOG_TRANSFORM +#ifdef CMPLOG_SOLVE_TRANSFORM || (lvl & LVL3) #endif ) { @@ -2583,7 +2582,7 @@ exit_its: } -#ifdef COMBINE +#ifdef CMPLOG_COMBINE if (afl->queued_paths + afl->unique_crashes > orig_hit_cnt + 1) { // copy the current virgin bits so we can recover the information @@ -2622,7 +2621,7 @@ exit_its: dump("COMB", cbuf, len); if (status == 1) { - fprintf(stderr, "NEW COMBINED\n"); + fprintf(stderr, "NEW CMPLOG_COMBINED\n"); } else { @@ -2671,8 +2670,3 @@ exit_its: return r; } - -#ifdef COMBINE - #undef COMBINE -#endif - -- cgit 1.4.1 From b6643743d6ccba1cc299daf2e9b5272cb4cdd53c Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Wed, 10 Feb 2021 10:13:08 +0100 Subject: fix laf for potential crashes --- instrumentation/compare-transform-pass.so.cc | 34 ++++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/instrumentation/compare-transform-pass.so.cc b/instrumentation/compare-transform-pass.so.cc index 8b00d8d1..bd524a69 100644 --- a/instrumentation/compare-transform-pass.so.cc +++ b/instrumentation/compare-transform-pass.so.cc @@ -362,19 +362,22 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, bool HasStr1 = getConstantStringInfo(Str1P, Str1); bool HasStr2 = getConstantStringInfo(Str2P, Str2); uint64_t constStrLen, unrollLen, constSizedLen = 0; - bool isMemcmp = - !callInst->getCalledFunction()->getName().compare(StringRef("memcmp")); - bool isSizedcmp = isMemcmp || - !callInst->getCalledFunction()->getName().compare( - StringRef("strncmp")) || - !callInst->getCalledFunction()->getName().compare( - StringRef("strncasecmp")); + bool isMemcmp = false; + bool isSizedcmp = false; + bool isCaseInsensitive = false; + Function * Callee = callInst->getCalledFunction(); + if (Callee) { + + isMemcmp = Callee->getName().compare("memcmp") == 0; + isSizedcmp = isMemcmp || Callee->getName().compare("strncmp") == 0 || + Callee->getName().compare("strncasecmp") == 0; + isCaseInsensitive = Callee->getName().compare("strcasecmp") == 0 || + Callee->getName().compare("strncasecmp") == 0; + + } + Value *sizedValue = isSizedcmp ? callInst->getArgOperand(2) : NULL; bool isConstSized = sizedValue && isa(sizedValue); - bool isCaseInsensitive = !callInst->getCalledFunction()->getName().compare( - StringRef("strcasecmp")) || - !callInst->getCalledFunction()->getName().compare( - StringRef("strncasecmp")); if (!(HasStr1 || HasStr2)) { @@ -436,15 +439,6 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, else unrollLen = constStrLen; - /* - if (!be_quiet) - errs() << callInst->getCalledFunction()->getName() << ": unroll len " - << unrollLen - << ((isSizedcmp && !isConstSized) ? ", variable n" : "") << ": - " - << ConstStr << "\n"; - */ - /* split before the call instruction */ BasicBlock *bb = callInst->getParent(); BasicBlock *end_bb = bb->splitBasicBlock(BasicBlock::iterator(callInst)); -- cgit 1.4.1 From 267b085f80074e61bdacf1e85e99014b6b2cdad2 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Wed, 10 Feb 2021 15:15:16 +0100 Subject: dlmalloc only for non glibc qasan and AFL_QEMU_FORCE_DFL --- docs/env_variables.md | 6 + qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/libqasan/dlmalloc.c | 4769 ++++++++++++++++------------------------- qemu_mode/libqasan/malloc.c | 147 +- qemu_mode/qemuafl | 2 +- 5 files changed, 2003 insertions(+), 2923 deletions(-) diff --git a/docs/env_variables.md b/docs/env_variables.md index 4c3b1cfb..ab56c178 100644 --- a/docs/env_variables.md +++ b/docs/env_variables.md @@ -514,6 +514,12 @@ The QEMU wrapper used to instrument binary-only code supports several settings: stack pointer in which QEMU can find the return address when `start addr` is hit. + - With `AFL_USE_QASAN` you can enable QEMU AddressSanitizer for dynamically + linked binaries. + + - With `AFL_QEMU_FORCE_DFL` you force QEMU to ignore the registered singal + handlers of the target. + ## 6) Settings for afl-cmin The corpus minimization script offers very little customization: diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index 97184973..d9f0ec33 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -6ab6bf28de +47722f64e4 diff --git a/qemu_mode/libqasan/dlmalloc.c b/qemu_mode/libqasan/dlmalloc.c index 3c7dcea8..7e3cb159 100644 --- a/qemu_mode/libqasan/dlmalloc.c +++ b/qemu_mode/libqasan/dlmalloc.c @@ -1,3 +1,7 @@ +#include + +#ifndef __GLIBC__ + /* This is a version (aka dlmalloc) of malloc/free/realloc written by Doug Lea and released to the public domain, as explained at @@ -203,12 +207,9 @@ mspaces as thread-locals. For example: static __thread mspace tlms = 0; void* tlmalloc(size_t bytes) { - if (tlms == 0) tlms = create_mspace(0, 0); return mspace_malloc(tlms, bytes); - } - void tlfree(void* mem) { mspace_free(tlms, mem); } Unless FOOTERS is defined, each mspace is completely independent. @@ -528,198 +529,197 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP /* Version identifier to allow people to support multiple versions */ #ifndef DLMALLOC_VERSION - #define DLMALLOC_VERSION 20806 -#endif /* DLMALLOC_VERSION */ +#define DLMALLOC_VERSION 20806 +#endif /* DLMALLOC_VERSION */ #ifndef DLMALLOC_EXPORT - #define DLMALLOC_EXPORT extern +#define DLMALLOC_EXPORT extern #endif #ifndef WIN32 - #ifdef _WIN32 - #define WIN32 1 - #endif /* _WIN32 */ - #ifdef _WIN32_WCE - #define LACKS_FCNTL_H - #define WIN32 1 - #endif /* _WIN32_WCE */ -#endif /* WIN32 */ +#ifdef _WIN32 +#define WIN32 1 +#endif /* _WIN32 */ +#ifdef _WIN32_WCE +#define LACKS_FCNTL_H +#define WIN32 1 +#endif /* _WIN32_WCE */ +#endif /* WIN32 */ #ifdef WIN32 - #define WIN32_LEAN_AND_MEAN - #include - #include - #define HAVE_MMAP 1 - #define HAVE_MORECORE 0 - #define LACKS_UNISTD_H - #define LACKS_SYS_PARAM_H - #define LACKS_SYS_MMAN_H - #define LACKS_STRING_H - #define LACKS_STRINGS_H - #define LACKS_SYS_TYPES_H - #define LACKS_ERRNO_H - #define LACKS_SCHED_H - #ifndef MALLOC_FAILURE_ACTION - #define MALLOC_FAILURE_ACTION - #endif /* MALLOC_FAILURE_ACTION */ - #ifndef MMAP_CLEARS - #ifdef _WIN32_WCE /* WINCE reportedly does not clear */ - #define MMAP_CLEARS 0 - #else - #define MMAP_CLEARS 1 - #endif /* _WIN32_WCE */ - #endif /*MMAP_CLEARS */ -#endif /* WIN32 */ +#define WIN32_LEAN_AND_MEAN +#include +#include +#define HAVE_MMAP 1 +#define HAVE_MORECORE 0 +#define LACKS_UNISTD_H +#define LACKS_SYS_PARAM_H +#define LACKS_SYS_MMAN_H +#define LACKS_STRING_H +#define LACKS_STRINGS_H +#define LACKS_SYS_TYPES_H +#define LACKS_ERRNO_H +#define LACKS_SCHED_H +#ifndef MALLOC_FAILURE_ACTION +#define MALLOC_FAILURE_ACTION +#endif /* MALLOC_FAILURE_ACTION */ +#ifndef MMAP_CLEARS +#ifdef _WIN32_WCE /* WINCE reportedly does not clear */ +#define MMAP_CLEARS 0 +#else +#define MMAP_CLEARS 1 +#endif /* _WIN32_WCE */ +#endif /*MMAP_CLEARS */ +#endif /* WIN32 */ #if defined(DARWIN) || defined(_DARWIN) - /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ - #ifndef HAVE_MORECORE - #define HAVE_MORECORE 0 - #define HAVE_MMAP 1 - /* OSX allocators provide 16 byte alignment */ - #ifndef MALLOC_ALIGNMENT - #define MALLOC_ALIGNMENT ((size_t)16U) - #endif - #endif /* HAVE_MORECORE */ -#endif /* DARWIN */ +/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ +#ifndef HAVE_MORECORE +#define HAVE_MORECORE 0 +#define HAVE_MMAP 1 +/* OSX allocators provide 16 byte alignment */ +#ifndef MALLOC_ALIGNMENT +#define MALLOC_ALIGNMENT ((size_t)16U) +#endif +#endif /* HAVE_MORECORE */ +#endif /* DARWIN */ #ifndef LACKS_SYS_TYPES_H - #include /* For size_t */ -#endif /* LACKS_SYS_TYPES_H */ +#include /* For size_t */ +#endif /* LACKS_SYS_TYPES_H */ /* The maximum possible size_t value has all bits set */ -#define MAX_SIZE_T (~(size_t)0) - -#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ - #define USE_LOCKS \ - ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ - (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) -#endif /* USE_LOCKS */ - -#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ - #if ((defined(__GNUC__) && \ - ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ - defined(__i386__) || defined(__x86_64__))) || \ - (defined(_MSC_VER) && _MSC_VER >= 1310)) - #ifndef USE_SPIN_LOCKS - #define USE_SPIN_LOCKS 1 - #endif /* USE_SPIN_LOCKS */ - #elif USE_SPIN_LOCKS - #error "USE_SPIN_LOCKS defined without implementation" - #endif /* ... locks available... */ +#define MAX_SIZE_T (~(size_t)0) + +#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ +#define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ + (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) +#endif /* USE_LOCKS */ + +#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ +#if ((defined(__GNUC__) && \ + ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ + defined(__i386__) || defined(__x86_64__))) || \ + (defined(_MSC_VER) && _MSC_VER>=1310)) +#ifndef USE_SPIN_LOCKS +#define USE_SPIN_LOCKS 1 +#endif /* USE_SPIN_LOCKS */ +#elif USE_SPIN_LOCKS +#error "USE_SPIN_LOCKS defined without implementation" +#endif /* ... locks available... */ #elif !defined(USE_SPIN_LOCKS) - #define USE_SPIN_LOCKS 0 -#endif /* USE_LOCKS */ +#define USE_SPIN_LOCKS 0 +#endif /* USE_LOCKS */ #ifndef ONLY_MSPACES - #define ONLY_MSPACES 0 -#endif /* ONLY_MSPACES */ +#define ONLY_MSPACES 0 +#endif /* ONLY_MSPACES */ #ifndef MSPACES - #if ONLY_MSPACES - #define MSPACES 1 - #else /* ONLY_MSPACES */ - #define MSPACES 0 - #endif /* ONLY_MSPACES */ -#endif /* MSPACES */ +#if ONLY_MSPACES +#define MSPACES 1 +#else /* ONLY_MSPACES */ +#define MSPACES 0 +#endif /* ONLY_MSPACES */ +#endif /* MSPACES */ #ifndef MALLOC_ALIGNMENT - #define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) -#endif /* MALLOC_ALIGNMENT */ +#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) +#endif /* MALLOC_ALIGNMENT */ #ifndef FOOTERS - #define FOOTERS 0 -#endif /* FOOTERS */ +#define FOOTERS 0 +#endif /* FOOTERS */ #ifndef ABORT - #define ABORT abort() -#endif /* ABORT */ +#define ABORT abort() +#endif /* ABORT */ #ifndef ABORT_ON_ASSERT_FAILURE - #define ABORT_ON_ASSERT_FAILURE 1 -#endif /* ABORT_ON_ASSERT_FAILURE */ +#define ABORT_ON_ASSERT_FAILURE 1 +#endif /* ABORT_ON_ASSERT_FAILURE */ #ifndef PROCEED_ON_ERROR - #define PROCEED_ON_ERROR 0 -#endif /* PROCEED_ON_ERROR */ +#define PROCEED_ON_ERROR 0 +#endif /* PROCEED_ON_ERROR */ #ifndef INSECURE - #define INSECURE 0 -#endif /* INSECURE */ +#define INSECURE 0 +#endif /* INSECURE */ #ifndef MALLOC_INSPECT_ALL - #define MALLOC_INSPECT_ALL 0 -#endif /* MALLOC_INSPECT_ALL */ +#define MALLOC_INSPECT_ALL 0 +#endif /* MALLOC_INSPECT_ALL */ #ifndef HAVE_MMAP - #define HAVE_MMAP 1 -#endif /* HAVE_MMAP */ +#define HAVE_MMAP 1 +#endif /* HAVE_MMAP */ #ifndef MMAP_CLEARS - #define MMAP_CLEARS 1 -#endif /* MMAP_CLEARS */ +#define MMAP_CLEARS 1 +#endif /* MMAP_CLEARS */ #ifndef HAVE_MREMAP - #ifdef linux - #define HAVE_MREMAP 1 - #define _GNU_SOURCE /* Turns on mremap() definition */ - #else /* linux */ - #define HAVE_MREMAP 0 - #endif /* linux */ -#endif /* HAVE_MREMAP */ +#ifdef linux +#define HAVE_MREMAP 1 +#define _GNU_SOURCE /* Turns on mremap() definition */ +#else /* linux */ +#define HAVE_MREMAP 0 +#endif /* linux */ +#endif /* HAVE_MREMAP */ #ifndef MALLOC_FAILURE_ACTION - #define MALLOC_FAILURE_ACTION errno = ENOMEM; -#endif /* MALLOC_FAILURE_ACTION */ +#define MALLOC_FAILURE_ACTION errno = ENOMEM; +#endif /* MALLOC_FAILURE_ACTION */ #ifndef HAVE_MORECORE - #if ONLY_MSPACES - #define HAVE_MORECORE 0 - #else /* ONLY_MSPACES */ - #define HAVE_MORECORE 1 - #endif /* ONLY_MSPACES */ -#endif /* HAVE_MORECORE */ +#if ONLY_MSPACES +#define HAVE_MORECORE 0 +#else /* ONLY_MSPACES */ +#define HAVE_MORECORE 1 +#endif /* ONLY_MSPACES */ +#endif /* HAVE_MORECORE */ #if !HAVE_MORECORE - #define MORECORE_CONTIGUOUS 0 -#else /* !HAVE_MORECORE */ - #define MORECORE_DEFAULT sbrk - #ifndef MORECORE_CONTIGUOUS - #define MORECORE_CONTIGUOUS 1 - #endif /* MORECORE_CONTIGUOUS */ -#endif /* HAVE_MORECORE */ +#define MORECORE_CONTIGUOUS 0 +#else /* !HAVE_MORECORE */ +#define MORECORE_DEFAULT sbrk +#ifndef MORECORE_CONTIGUOUS +#define MORECORE_CONTIGUOUS 1 +#endif /* MORECORE_CONTIGUOUS */ +#endif /* HAVE_MORECORE */ #ifndef DEFAULT_GRANULARITY - #if (MORECORE_CONTIGUOUS || defined(WIN32)) - #define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ - #else /* MORECORE_CONTIGUOUS */ - #define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) - #endif /* MORECORE_CONTIGUOUS */ -#endif /* DEFAULT_GRANULARITY */ +#if (MORECORE_CONTIGUOUS || defined(WIN32)) +#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ +#else /* MORECORE_CONTIGUOUS */ +#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) +#endif /* MORECORE_CONTIGUOUS */ +#endif /* DEFAULT_GRANULARITY */ #ifndef DEFAULT_TRIM_THRESHOLD - #ifndef MORECORE_CANNOT_TRIM - #define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) - #else /* MORECORE_CANNOT_TRIM */ - #define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T - #endif /* MORECORE_CANNOT_TRIM */ -#endif /* DEFAULT_TRIM_THRESHOLD */ +#ifndef MORECORE_CANNOT_TRIM +#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) +#else /* MORECORE_CANNOT_TRIM */ +#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T +#endif /* MORECORE_CANNOT_TRIM */ +#endif /* DEFAULT_TRIM_THRESHOLD */ #ifndef DEFAULT_MMAP_THRESHOLD - #if HAVE_MMAP - #define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) - #else /* HAVE_MMAP */ - #define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T - #endif /* HAVE_MMAP */ -#endif /* DEFAULT_MMAP_THRESHOLD */ +#if HAVE_MMAP +#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) +#else /* HAVE_MMAP */ +#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T +#endif /* HAVE_MMAP */ +#endif /* DEFAULT_MMAP_THRESHOLD */ #ifndef MAX_RELEASE_CHECK_RATE - #if HAVE_MMAP - #define MAX_RELEASE_CHECK_RATE 4095 - #else - #define MAX_RELEASE_CHECK_RATE MAX_SIZE_T - #endif /* HAVE_MMAP */ -#endif /* MAX_RELEASE_CHECK_RATE */ +#if HAVE_MMAP +#define MAX_RELEASE_CHECK_RATE 4095 +#else +#define MAX_RELEASE_CHECK_RATE MAX_SIZE_T +#endif /* HAVE_MMAP */ +#endif /* MAX_RELEASE_CHECK_RATE */ #ifndef USE_BUILTIN_FFS - #define USE_BUILTIN_FFS 0 -#endif /* USE_BUILTIN_FFS */ +#define USE_BUILTIN_FFS 0 +#endif /* USE_BUILTIN_FFS */ #ifndef USE_DEV_RANDOM - #define USE_DEV_RANDOM 0 -#endif /* USE_DEV_RANDOM */ +#define USE_DEV_RANDOM 0 +#endif /* USE_DEV_RANDOM */ #ifndef NO_MALLINFO - #define NO_MALLINFO 0 -#endif /* NO_MALLINFO */ +#define NO_MALLINFO 0 +#endif /* NO_MALLINFO */ #ifndef MALLINFO_FIELD_TYPE - #define MALLINFO_FIELD_TYPE size_t -#endif /* MALLINFO_FIELD_TYPE */ +#define MALLINFO_FIELD_TYPE size_t +#endif /* MALLINFO_FIELD_TYPE */ #ifndef NO_MALLOC_STATS - #define NO_MALLOC_STATS 0 -#endif /* NO_MALLOC_STATS */ +#define NO_MALLOC_STATS 0 +#endif /* NO_MALLOC_STATS */ #ifndef NO_SEGMENT_TRAVERSAL - #define NO_SEGMENT_TRAVERSAL 0 -#endif /* NO_SEGMENT_TRAVERSAL */ +#define NO_SEGMENT_TRAVERSAL 0 +#endif /* NO_SEGMENT_TRAVERSAL */ /* mallopt tuning options. SVID/XPG defines four standard parameter @@ -731,9 +731,9 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP #undef M_TRIM_THRESHOLD #undef M_GRANULARITY #undef M_MMAP_THRESHOLD -#define M_TRIM_THRESHOLD (-1) -#define M_GRANULARITY (-2) -#define M_MMAP_THRESHOLD (-3) +#define M_TRIM_THRESHOLD (-1) +#define M_GRANULARITY (-2) +#define M_MMAP_THRESHOLD (-3) /* ------------------------ Mallinfo declarations ------------------------ */ @@ -762,32 +762,28 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP /* #define HAVE_USR_INCLUDE_MALLOC_H */ - #ifdef HAVE_USR_INCLUDE_MALLOC_H - #include "/usr/include/malloc.h" - #else /* HAVE_USR_INCLUDE_MALLOC_H */ - #ifndef STRUCT_MALLINFO_DECLARED - /* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is - * defined */ - #define _STRUCT_MALLINFO - #define STRUCT_MALLINFO_DECLARED 1 +#ifdef HAVE_USR_INCLUDE_MALLOC_H +#include "/usr/include/malloc.h" +#else /* HAVE_USR_INCLUDE_MALLOC_H */ +#ifndef STRUCT_MALLINFO_DECLARED +/* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */ +#define _STRUCT_MALLINFO +#define STRUCT_MALLINFO_DECLARED 1 struct mallinfo { - - MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ - MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ - MALLINFO_FIELD_TYPE smblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ - MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ - MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ - MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ - MALLINFO_FIELD_TYPE fordblks; /* total free space */ - MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ - + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ }; - - #endif /* STRUCT_MALLINFO_DECLARED */ - #endif /* HAVE_USR_INCLUDE_MALLOC_H */ -#endif /* NO_MALLINFO */ +#endif /* STRUCT_MALLINFO_DECLARED */ +#endif /* HAVE_USR_INCLUDE_MALLOC_H */ +#endif /* NO_MALLINFO */ /* Try to persuade compilers to inline. The most critical functions for @@ -796,14 +792,14 @@ struct mallinfo { #ifndef FORCEINLINE #if defined(__GNUC__) - #define FORCEINLINE __inline __attribute__((always_inline)) +#define FORCEINLINE __inline __attribute__ ((always_inline)) #elif defined(_MSC_VER) #define FORCEINLINE __forceinline #endif #endif #ifndef NOINLINE #if defined(__GNUC__) - #define NOINLINE __attribute__((noinline)) + #define NOINLINE __attribute__ ((noinline)) #elif defined(_MSC_VER) #define NOINLINE __declspec(noinline) #else @@ -813,43 +809,42 @@ struct mallinfo { #ifdef __cplusplus extern "C" { - - #ifndef FORCEINLINE - #define FORCEINLINE inline - #endif -#endif /* __cplusplus */ #ifndef FORCEINLINE - #define FORCEINLINE + #define FORCEINLINE inline +#endif +#endif /* __cplusplus */ +#ifndef FORCEINLINE + #define FORCEINLINE #endif #if !ONLY_MSPACES /* ------------------- Declarations of public routines ------------------- */ - #ifndef USE_DL_PREFIX - #define dlcalloc calloc - #define dlfree free - #define dlmalloc malloc - #define dlmemalign memalign - #define dlposix_memalign posix_memalign - #define dlrealloc realloc - #define dlrealloc_in_place realloc_in_place - #define dlvalloc valloc - #define dlpvalloc pvalloc - #define dlmallinfo mallinfo - #define dlmallopt mallopt - #define dlmalloc_trim malloc_trim - #define dlmalloc_stats malloc_stats - #define dlmalloc_usable_size malloc_usable_size - #define dlmalloc_footprint malloc_footprint - #define dlmalloc_max_footprint malloc_max_footprint - #define dlmalloc_footprint_limit malloc_footprint_limit - #define dlmalloc_set_footprint_limit malloc_set_footprint_limit - #define dlmalloc_inspect_all malloc_inspect_all - #define dlindependent_calloc independent_calloc - #define dlindependent_comalloc independent_comalloc - #define dlbulk_free bulk_free - #endif /* USE_DL_PREFIX */ +#ifndef USE_DL_PREFIX +#define dlcalloc calloc +#define dlfree free +#define dlmalloc malloc +#define dlmemalign memalign +#define dlposix_memalign posix_memalign +#define dlrealloc realloc +#define dlrealloc_in_place realloc_in_place +#define dlvalloc valloc +#define dlpvalloc pvalloc +#define dlmallinfo mallinfo +#define dlmallopt mallopt +#define dlmalloc_trim malloc_trim +#define dlmalloc_stats malloc_stats +#define dlmalloc_usable_size malloc_usable_size +#define dlmalloc_footprint malloc_footprint +#define dlmalloc_max_footprint malloc_max_footprint +#define dlmalloc_footprint_limit malloc_footprint_limit +#define dlmalloc_set_footprint_limit malloc_set_footprint_limit +#define dlmalloc_inspect_all malloc_inspect_all +#define dlindependent_calloc independent_calloc +#define dlindependent_comalloc independent_comalloc +#define dlbulk_free bulk_free +#endif /* USE_DL_PREFIX */ /* malloc(size_t n) @@ -865,7 +860,7 @@ extern "C" { maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t. */ -DLMALLOC_EXPORT void *dlmalloc(size_t); +DLMALLOC_EXPORT void* dlmalloc(size_t); /* free(void* p) @@ -874,14 +869,14 @@ DLMALLOC_EXPORT void *dlmalloc(size_t); It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort. */ -DLMALLOC_EXPORT void dlfree(void *); +DLMALLOC_EXPORT void dlfree(void*); /* calloc(size_t n_elements, size_t element_size); Returns a pointer to n_elements * element_size bytes, with all locations set to zero. */ -DLMALLOC_EXPORT void *dlcalloc(size_t, size_t); +DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); /* realloc(void* p, size_t n) @@ -905,7 +900,7 @@ DLMALLOC_EXPORT void *dlcalloc(size_t, size_t); The old unix realloc convention of allowing the last-free'd chunk to be used as an argument to realloc is not supported. */ -DLMALLOC_EXPORT void *dlrealloc(void *, size_t); +DLMALLOC_EXPORT void* dlrealloc(void*, size_t); /* realloc_in_place(void* p, size_t n) @@ -920,7 +915,7 @@ DLMALLOC_EXPORT void *dlrealloc(void *, size_t); Returns p if successful; otherwise null. */ -DLMALLOC_EXPORT void *dlrealloc_in_place(void *, size_t); +DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); /* memalign(size_t alignment, size_t n); @@ -934,7 +929,7 @@ DLMALLOC_EXPORT void *dlrealloc_in_place(void *, size_t); Overreliance on memalign is a sure way to fragment space. */ -DLMALLOC_EXPORT void *dlmemalign(size_t, size_t); +DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); /* int posix_memalign(void** pp, size_t alignment, size_t n); @@ -944,14 +939,14 @@ DLMALLOC_EXPORT void *dlmemalign(size_t, size_t); returns EINVAL if the alignment is not a power of two (3) fails and returns ENOMEM if memory cannot be allocated. */ -DLMALLOC_EXPORT int dlposix_memalign(void **, size_t, size_t); +DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t); /* valloc(size_t n); Equivalent to memalign(pagesize, n), where pagesize is the page size of the system. If the pagesize is unknown, 4096 is used. */ -DLMALLOC_EXPORT void *dlvalloc(size_t); +DLMALLOC_EXPORT void* dlvalloc(size_t); /* mallopt(int parameter_number, int parameter_value) @@ -1026,7 +1021,7 @@ DLMALLOC_EXPORT size_t dlmalloc_footprint_limit(); */ DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); - #if MALLOC_INSPECT_ALL +#if MALLOC_INSPECT_ALL /* malloc_inspect_all(void(*handler)(void *start, void *end, @@ -1048,23 +1043,19 @@ DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); than 1000, you could write: static int count = 0; void count_chunks(void* start, void* end, size_t used, void* arg) { - if (used >= 1000) ++count; - } - then: malloc_inspect_all(count_chunks, NULL); malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined. */ -DLMALLOC_EXPORT void dlmalloc_inspect_all(void (*handler)(void *, void *, - size_t, void *), - void *arg); +DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), + void* arg); - #endif /* MALLOC_INSPECT_ALL */ +#endif /* MALLOC_INSPECT_ALL */ - #if !NO_MALLINFO +#if !NO_MALLINFO /* mallinfo() Returns (by copy) a struct containing various summary statistics: @@ -1088,7 +1079,7 @@ DLMALLOC_EXPORT void dlmalloc_inspect_all(void (*handler)(void *, void *, thus be inaccurate. */ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); - #endif /* NO_MALLINFO */ +#endif /* NO_MALLINFO */ /* independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); @@ -1126,7 +1117,6 @@ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); struct Node { int item; struct Node* next; }; struct Node* build_list() { - struct Node** pool; int n = read_number_of_nodes_needed(); if (n <= 0) return 0; @@ -1138,11 +1128,9 @@ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); pool[i]->next = pool[i+1]; free(pool); // Can now free the array (or not, if it is needed later) return first; - } - */ -DLMALLOC_EXPORT void **dlindependent_calloc(size_t, size_t, void **); +DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); /* independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); @@ -1181,7 +1169,6 @@ DLMALLOC_EXPORT void **dlindependent_calloc(size_t, size_t, void **); struct Foot { ... } void send_message(char* msg) { - int msglen = strlen(msg); size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; void* chunks[3]; @@ -1191,7 +1178,6 @@ DLMALLOC_EXPORT void **dlindependent_calloc(size_t, size_t, void **); char* body = (char*)(chunks[1]); struct Foot* foot = (struct Foot*)(chunks[2]); // ... - } In general though, independent_comalloc is worth using only for @@ -1202,7 +1188,7 @@ DLMALLOC_EXPORT void **dlindependent_calloc(size_t, size_t, void **); since it cannot reuse existing noncontiguous small chunks that might be available for some of the elements. */ -DLMALLOC_EXPORT void **dlindependent_comalloc(size_t, size_t *, void **); +DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); /* bulk_free(void* array[], size_t n_elements) @@ -1213,14 +1199,14 @@ DLMALLOC_EXPORT void **dlindependent_comalloc(size_t, size_t *, void **); is returned. For large arrays of pointers with poor locality, it may be worthwhile to sort this array before calling bulk_free. */ -DLMALLOC_EXPORT size_t dlbulk_free(void **, size_t n_elements); +DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements); /* pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize. */ -DLMALLOC_EXPORT void *dlpvalloc(size_t); +DLMALLOC_EXPORT void* dlpvalloc(size_t); /* malloc_trim(size_t pad); @@ -1243,7 +1229,7 @@ DLMALLOC_EXPORT void *dlpvalloc(size_t); Malloc_trim returns 1 if it actually released any memory, else 0. */ -DLMALLOC_EXPORT int dlmalloc_trim(size_t); +DLMALLOC_EXPORT int dlmalloc_trim(size_t); /* malloc_stats(); @@ -1264,7 +1250,7 @@ DLMALLOC_EXPORT int dlmalloc_trim(size_t); malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo. */ -DLMALLOC_EXPORT void dlmalloc_stats(void); +DLMALLOC_EXPORT void dlmalloc_stats(void); /* malloc_usable_size(void* p); @@ -1280,9 +1266,9 @@ DLMALLOC_EXPORT void dlmalloc_stats(void); p = malloc(n); assert(malloc_usable_size(p) >= 256); */ -size_t dlmalloc_usable_size(void *); +size_t dlmalloc_usable_size(void*); -#endif /* ONLY_MSPACES */ +#endif /* ONLY_MSPACES */ #if MSPACES @@ -1290,7 +1276,7 @@ size_t dlmalloc_usable_size(void *); mspace is an opaque type representing an independent region of space that supports mspace_malloc, etc. */ -typedef void *mspace; +typedef void* mspace; /* create_mspace creates and returns a new independent space with the @@ -1322,8 +1308,7 @@ DLMALLOC_EXPORT size_t destroy_mspace(mspace msp); Destroying this space will deallocate all additionally allocated space (if possible) but not the initial base. */ -DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, - int locked); +DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked); /* mspace_track_large_chunks controls whether requests for large chunks @@ -1338,11 +1323,12 @@ DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, */ DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable); + /* mspace_malloc behaves as malloc, but operates within the given space. */ -DLMALLOC_EXPORT void *mspace_malloc(mspace msp, size_t bytes); +DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); /* mspace_free behaves as free, but operates within @@ -1352,7 +1338,7 @@ DLMALLOC_EXPORT void *mspace_malloc(mspace msp, size_t bytes); free may be called instead of mspace_free because freed chunks from any space are handled by their originating spaces. */ -DLMALLOC_EXPORT void mspace_free(mspace msp, void *mem); +DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); /* mspace_realloc behaves as realloc, but operates within @@ -1363,38 +1349,33 @@ DLMALLOC_EXPORT void mspace_free(mspace msp, void *mem); realloced chunks from any space are handled by their originating spaces. */ -DLMALLOC_EXPORT void *mspace_realloc(mspace msp, void *mem, size_t newsize); +DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize); /* mspace_calloc behaves as calloc, but operates within the given space. */ -DLMALLOC_EXPORT void *mspace_calloc(mspace msp, size_t n_elements, - size_t elem_size); +DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); /* mspace_memalign behaves as memalign, but operates within the given space. */ -DLMALLOC_EXPORT void *mspace_memalign(mspace msp, size_t alignment, - size_t bytes); +DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); /* mspace_independent_calloc behaves as independent_calloc, but operates within the given space. */ -DLMALLOC_EXPORT void **mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, - void * chunks[]); +DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void* chunks[]); /* mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space. */ -DLMALLOC_EXPORT void **mspace_independent_comalloc(mspace msp, - size_t n_elements, - size_t sizes[], - void * chunks[]); +DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void* chunks[]); /* mspace_footprint() returns the number of bytes obtained from the @@ -1408,18 +1389,19 @@ DLMALLOC_EXPORT size_t mspace_footprint(mspace msp); */ DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp); - #if !NO_MALLINFO + +#if !NO_MALLINFO /* mspace_mallinfo behaves as mallinfo, but reports properties of the given space. */ DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp); - #endif /* NO_MALLINFO */ +#endif /* NO_MALLINFO */ /* malloc_usable_size(void* p) behaves the same as malloc_usable_size; */ -DLMALLOC_EXPORT size_t mspace_usable_size(const void *mem); +DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem); /* mspace_malloc_stats behaves as malloc_stats, but reports @@ -1438,13 +1420,11 @@ DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad); */ DLMALLOC_EXPORT int mspace_mallopt(int, int); -#endif /* MSPACES */ +#endif /* MSPACES */ #ifdef __cplusplus - -} /* end of extern "C" */ - -#endif /* __cplusplus */ +} /* end of extern "C" */ +#endif /* __cplusplus */ /* ======================================================================== @@ -1459,207 +1439,195 @@ DLMALLOC_EXPORT int mspace_mallopt(int, int); /*------------------------------ internal #includes ---------------------- */ #ifdef _MSC_VER - #pragma warning(disable : 4146) /* no "unsigned" warnings */ -#endif /* _MSC_VER */ +#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ +#endif /* _MSC_VER */ #if !NO_MALLOC_STATS - #include /* for printing in malloc_stats */ -#endif /* NO_MALLOC_STATS */ +#include /* for printing in malloc_stats */ +#endif /* NO_MALLOC_STATS */ #ifndef LACKS_ERRNO_H - #include /* for MALLOC_FAILURE_ACTION */ -#endif /* LACKS_ERRNO_H */ +#include /* for MALLOC_FAILURE_ACTION */ +#endif /* LACKS_ERRNO_H */ #ifdef DEBUG - #if ABORT_ON_ASSERT_FAILURE - #undef assert - #define assert(x) \ - if (!(x)) ABORT - #else /* ABORT_ON_ASSERT_FAILURE */ - #include - #endif /* ABORT_ON_ASSERT_FAILURE */ -#else /* DEBUG */ - #ifndef assert - #define assert(x) - #endif - #define DEBUG 0 -#endif /* DEBUG */ +#if ABORT_ON_ASSERT_FAILURE +#undef assert +#define assert(x) if(!(x)) ABORT +#else /* ABORT_ON_ASSERT_FAILURE */ +#include +#endif /* ABORT_ON_ASSERT_FAILURE */ +#else /* DEBUG */ +#ifndef assert +#define assert(x) +#endif +#define DEBUG 0 +#endif /* DEBUG */ #if !defined(WIN32) && !defined(LACKS_TIME_H) - #include /* for magic initialization */ -#endif /* WIN32 */ +#include /* for magic initialization */ +#endif /* WIN32 */ #ifndef LACKS_STDLIB_H - #include /* for abort() */ -#endif /* LACKS_STDLIB_H */ +#include /* for abort() */ +#endif /* LACKS_STDLIB_H */ #ifndef LACKS_STRING_H - #include /* for memset etc */ -#endif /* LACKS_STRING_H */ +#include /* for memset etc */ +#endif /* LACKS_STRING_H */ #if USE_BUILTIN_FFS - #ifndef LACKS_STRINGS_H - #include /* for ffs */ - #endif /* LACKS_STRINGS_H */ -#endif /* USE_BUILTIN_FFS */ +#ifndef LACKS_STRINGS_H +#include /* for ffs */ +#endif /* LACKS_STRINGS_H */ +#endif /* USE_BUILTIN_FFS */ #if HAVE_MMAP - #ifndef LACKS_SYS_MMAN_H - /* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ - #if (defined(linux) && !defined(__USE_GNU)) - #define __USE_GNU 1 - #include /* for mmap */ - #undef __USE_GNU - #else - #include /* for mmap */ - #endif /* linux */ - #endif /* LACKS_SYS_MMAN_H */ - #ifndef LACKS_FCNTL_H - #include - #endif /* LACKS_FCNTL_H */ -#endif /* HAVE_MMAP */ +#ifndef LACKS_SYS_MMAN_H +/* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ +#if (defined(linux) && !defined(__USE_GNU)) +#define __USE_GNU 1 +#include /* for mmap */ +#undef __USE_GNU +#else +#include /* for mmap */ +#endif /* linux */ +#endif /* LACKS_SYS_MMAN_H */ +#ifndef LACKS_FCNTL_H +#include +#endif /* LACKS_FCNTL_H */ +#endif /* HAVE_MMAP */ #ifndef LACKS_UNISTD_H - #include /* for sbrk, sysconf */ -#else /* LACKS_UNISTD_H */ - #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void *sbrk(ptrdiff_t); - #endif /* FreeBSD etc */ -#endif /* LACKS_UNISTD_H */ +#include /* for sbrk, sysconf */ +#else /* LACKS_UNISTD_H */ +#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) +extern void* sbrk(ptrdiff_t); +#endif /* FreeBSD etc */ +#endif /* LACKS_UNISTD_H */ /* Declarations for locking */ #if USE_LOCKS - #ifndef WIN32 - #if defined(__SVR4) && defined(__sun) /* solaris */ - #include - #elif !defined(LACKS_SCHED_H) - #include - #endif /* solaris or LACKS_SCHED_H */ - #if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || \ - !USE_SPIN_LOCKS - #include - #endif /* USE_RECURSIVE_LOCKS ... */ - #elif defined(_MSC_VER) - #ifndef _M_AMD64 - /* These are already defined on AMD64 builds */ - #ifdef __cplusplus +#ifndef WIN32 +#if defined (__SVR4) && defined (__sun) /* solaris */ +#include +#elif !defined(LACKS_SCHED_H) +#include +#endif /* solaris or LACKS_SCHED_H */ +#if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS +#include +#endif /* USE_RECURSIVE_LOCKS ... */ +#elif defined(_MSC_VER) +#ifndef _M_AMD64 +/* These are already defined on AMD64 builds */ +#ifdef __cplusplus extern "C" { - - #endif /* __cplusplus */ -LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, - LONG Comp); +#endif /* __cplusplus */ +LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp); LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value); - #ifdef __cplusplus - +#ifdef __cplusplus } - - #endif /* __cplusplus */ - #endif /* _M_AMD64 */ - #pragma intrinsic(_InterlockedCompareExchange) - #pragma intrinsic(_InterlockedExchange) - #define interlockedcompareexchange _InterlockedCompareExchange - #define interlockedexchange _InterlockedExchange - #elif defined(WIN32) && defined(__GNUC__) - #define interlockedcompareexchange(a, b, c) \ - __sync_val_compare_and_swap(a, c, b) - #define interlockedexchange __sync_lock_test_and_set - #endif /* Win32 */ -#else /* USE_LOCKS */ -#endif /* USE_LOCKS */ +#endif /* __cplusplus */ +#endif /* _M_AMD64 */ +#pragma intrinsic (_InterlockedCompareExchange) +#pragma intrinsic (_InterlockedExchange) +#define interlockedcompareexchange _InterlockedCompareExchange +#define interlockedexchange _InterlockedExchange +#elif defined(WIN32) && defined(__GNUC__) +#define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b) +#define interlockedexchange __sync_lock_test_and_set +#endif /* Win32 */ +#else /* USE_LOCKS */ +#endif /* USE_LOCKS */ #ifndef LOCK_AT_FORK - #define LOCK_AT_FORK 0 +#define LOCK_AT_FORK 0 #endif /* Declarations for bit scanning on win32 */ -#if defined(_MSC_VER) && _MSC_VER >= 1300 - #ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ - #ifdef __cplusplus +#if defined(_MSC_VER) && _MSC_VER>=1300 +#ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ +#ifdef __cplusplus extern "C" { - - #endif /* __cplusplus */ +#endif /* __cplusplus */ unsigned char _BitScanForward(unsigned long *index, unsigned long mask); unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); - #ifdef __cplusplus - +#ifdef __cplusplus } +#endif /* __cplusplus */ - #endif /* __cplusplus */ - - #define BitScanForward _BitScanForward - #define BitScanReverse _BitScanReverse - #pragma intrinsic(_BitScanForward) - #pragma intrinsic(_BitScanReverse) - #endif /* BitScanForward */ -#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ +#define BitScanForward _BitScanForward +#define BitScanReverse _BitScanReverse +#pragma intrinsic(_BitScanForward) +#pragma intrinsic(_BitScanReverse) +#endif /* BitScanForward */ +#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ #ifndef WIN32 - #ifndef malloc_getpagesize - #ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ - #ifndef _SC_PAGE_SIZE - #define _SC_PAGE_SIZE _SC_PAGESIZE - #endif - #endif - #ifdef _SC_PAGE_SIZE - #define malloc_getpagesize sysconf(_SC_PAGE_SIZE) - #else - #if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) -extern size_t getpagesize(); - #define malloc_getpagesize getpagesize() - #else - #ifdef WIN32 /* use supplied emulation of getpagesize */ - #define malloc_getpagesize getpagesize() - #else - #ifndef LACKS_SYS_PARAM_H - #include - #endif - #ifdef EXEC_PAGESIZE - #define malloc_getpagesize EXEC_PAGESIZE - #else - #ifdef NBPG - #ifndef CLSIZE - #define malloc_getpagesize NBPG - #else - #define malloc_getpagesize (NBPG * CLSIZE) - #endif - #else - #ifdef NBPC - #define malloc_getpagesize NBPC - #else - #ifdef PAGESIZE - #define malloc_getpagesize PAGESIZE - #else /* just guess */ - #define malloc_getpagesize ((size_t)4096U) - #endif - #endif - #endif - #endif - #endif - #endif - #endif - #endif +#ifndef malloc_getpagesize +# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ +# ifndef _SC_PAGE_SIZE +# define _SC_PAGE_SIZE _SC_PAGESIZE +# endif +# endif +# ifdef _SC_PAGE_SIZE +# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) +# else +# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) + extern size_t getpagesize(); +# define malloc_getpagesize getpagesize() +# else +# ifdef WIN32 /* use supplied emulation of getpagesize */ +# define malloc_getpagesize getpagesize() +# else +# ifndef LACKS_SYS_PARAM_H +# include +# endif +# ifdef EXEC_PAGESIZE +# define malloc_getpagesize EXEC_PAGESIZE +# else +# ifdef NBPG +# ifndef CLSIZE +# define malloc_getpagesize NBPG +# else +# define malloc_getpagesize (NBPG * CLSIZE) +# endif +# else +# ifdef NBPC +# define malloc_getpagesize NBPC +# else +# ifdef PAGESIZE +# define malloc_getpagesize PAGESIZE +# else /* just guess */ +# define malloc_getpagesize ((size_t)4096U) +# endif +# endif +# endif +# endif +# endif +# endif +# endif +#endif #endif /* ------------------- size_t and alignment properties -------------------- */ /* The byte and bit size of a size_t */ -#define SIZE_T_SIZE (sizeof(size_t)) -#define SIZE_T_BITSIZE (sizeof(size_t) << 3) +#define SIZE_T_SIZE (sizeof(size_t)) +#define SIZE_T_BITSIZE (sizeof(size_t) << 3) /* Some constants coerced to size_t */ /* Annoying but necessary to avoid errors on some platforms */ -#define SIZE_T_ZERO ((size_t)0) -#define SIZE_T_ONE ((size_t)1) -#define SIZE_T_TWO ((size_t)2) -#define SIZE_T_FOUR ((size_t)4) -#define TWO_SIZE_T_SIZES (SIZE_T_SIZE << 1) -#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE << 2) -#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES + TWO_SIZE_T_SIZES) -#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) +#define SIZE_T_ZERO ((size_t)0) +#define SIZE_T_ONE ((size_t)1) +#define SIZE_T_TWO ((size_t)2) +#define SIZE_T_FOUR ((size_t)4) +#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) +#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) +#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) +#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) /* The bit mask value corresponding to MALLOC_ALIGNMENT */ -#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) +#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) /* True if address a has acceptable alignment */ -#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) +#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) /* the number of bytes to offset an address to align it */ -#define align_offset(A) \ - ((((size_t)(A)&CHUNK_ALIGN_MASK) == 0) \ - ? 0 \ - : ((MALLOC_ALIGNMENT - ((size_t)(A)&CHUNK_ALIGN_MASK)) & \ - CHUNK_ALIGN_MASK)) +#define align_offset(A)\ + ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ + ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) /* -------------------------- MMAP preliminaries ------------------------- */ @@ -1669,202 +1637,193 @@ extern size_t getpagesize(); using so many "#if"s. */ + /* MORECORE and MMAP must return MFAIL on failure */ -#define MFAIL ((void *)(MAX_SIZE_T)) -#define CMFAIL ((char *)(MFAIL)) /* defined for convenience */ +#define MFAIL ((void*)(MAX_SIZE_T)) +#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ #if HAVE_MMAP - #ifndef WIN32 - #define MMAP_PROT (PROT_READ | PROT_WRITE) - #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) - #define MAP_ANONYMOUS MAP_ANON - #endif /* MAP_ANON */ - #ifdef MAP_ANONYMOUS - - #define MMAP_FLAGS (MAP_PRIVATE | MAP_ANONYMOUS) +#ifndef WIN32 +#define MMAP_PROT (PROT_READ|PROT_WRITE) +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +#define MAP_ANONYMOUS MAP_ANON +#endif /* MAP_ANON */ +#ifdef MAP_ANONYMOUS -static FORCEINLINE void *unixmmap(size_t size) { +#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) - void *result; +static FORCEINLINE void* unixmmap(size_t size) { + void* result; result = mmap(0, size, MMAP_PROT, MMAP_FLAGS, -1, 0); - if (result == MFAIL) return MFAIL; + if (result == MFAIL) + return MFAIL; return result; - } -static FORCEINLINE int unixmunmap(void *ptr, size_t size) { - +static FORCEINLINE int unixmunmap(void* ptr, size_t size) { int result; result = munmap(ptr, size); - if (result != 0) return result; + if (result != 0) + return result; return result; - } - #define MMAP_DEFAULT(s) unixmmap(s) - #define MUNMAP_DEFAULT(a, s) unixmunmap((a), (s)) +#define MMAP_DEFAULT(s) unixmmap(s) +#define MUNMAP_DEFAULT(a, s) unixmunmap((a), (s)) - #else /* MAP_ANONYMOUS */ - /* - Nearly all versions of mmap support MAP_ANONYMOUS, so the following - is unlikely to be needed, but is supplied just in case. - */ - #define MMAP_FLAGS (MAP_PRIVATE) -static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ - #define MMAP_DEFAULT(s) \ - ((dev_zero_fd < 0) \ - ? (dev_zero_fd = open("/dev/zero", O_RDWR), \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) \ - : mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) - #define MUNMAP_DEFAULT(a, s) munmap((a), (s)) - #endif /* MAP_ANONYMOUS */ +#else /* MAP_ANONYMOUS */ +/* + Nearly all versions of mmap support MAP_ANONYMOUS, so the following + is unlikely to be needed, but is supplied just in case. +*/ +#define MMAP_FLAGS (MAP_PRIVATE) +static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ +#define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \ + (dev_zero_fd = open("/dev/zero", O_RDWR), \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) +#define MUNMAP_DEFAULT(a, s) munmap((a), (s)) +#endif /* MAP_ANONYMOUS */ - #define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) +#define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) - #else /* WIN32 */ +#else /* WIN32 */ /* Win32 MMAP via VirtualAlloc */ -static FORCEINLINE void *win32mmap(size_t size) { - - void *ptr; +static FORCEINLINE void* win32mmap(size_t size) { + void* ptr; - ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); - if (ptr == 0) return MFAIL; + ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); + if (ptr == 0) + return MFAIL; return ptr; - } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ -static FORCEINLINE void *win32direct_mmap(size_t size) { - - void *ptr; +static FORCEINLINE void* win32direct_mmap(size_t size) { + void* ptr; - ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, - PAGE_READWRITE); - if (ptr == 0) return MFAIL; + ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, + PAGE_READWRITE); + if (ptr == 0) + return MFAIL; return ptr; - } /* This function supports releasing coalesed segments */ -static FORCEINLINE int win32munmap(void *ptr, size_t size) { - +static FORCEINLINE int win32munmap(void* ptr, size_t size) { MEMORY_BASIC_INFORMATION minfo; - char *cptr = (char *)ptr; + char* cptr = (char*)ptr; while (size) { - - if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) return -1; + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) + return -1; if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || minfo.State != MEM_COMMIT || minfo.RegionSize > size) return -1; - if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) + return -1; cptr += minfo.RegionSize; size -= minfo.RegionSize; - } return 0; - } - #define MMAP_DEFAULT(s) win32mmap(s) - #define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) - #define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) - #endif /* WIN32 */ -#endif /* HAVE_MMAP */ +#define MMAP_DEFAULT(s) win32mmap(s) +#define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) +#define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) +#endif /* WIN32 */ +#endif /* HAVE_MMAP */ #if HAVE_MREMAP - #ifndef WIN32 - -static FORCEINLINE void *dlmremap(void *old_address, size_t old_size, - size_t new_size, int flags) { +#ifndef WIN32 - void *result; +static FORCEINLINE void* dlmremap(void* old_address, size_t old_size, size_t new_size, int flags) { + void* result; result = mremap(old_address, old_size, new_size, flags); - if (result == MFAIL) return MFAIL; + if (result == MFAIL) + return MFAIL; return result; - } - #define MREMAP_DEFAULT(addr, osz, nsz, mv) \ - dlmremap((addr), (osz), (nsz), (mv)) - #endif /* WIN32 */ -#endif /* HAVE_MREMAP */ +#define MREMAP_DEFAULT(addr, osz, nsz, mv) dlmremap((addr), (osz), (nsz), (mv)) +#endif /* WIN32 */ +#endif /* HAVE_MREMAP */ /** * Define CALL_MORECORE */ #if HAVE_MORECORE - #ifdef MORECORE - #define CALL_MORECORE(S) MORECORE(S) - #else /* MORECORE */ - #define CALL_MORECORE(S) MORECORE_DEFAULT(S) - #endif /* MORECORE */ -#else /* HAVE_MORECORE */ - #define CALL_MORECORE(S) MFAIL -#endif /* HAVE_MORECORE */ + #ifdef MORECORE + #define CALL_MORECORE(S) MORECORE(S) + #else /* MORECORE */ + #define CALL_MORECORE(S) MORECORE_DEFAULT(S) + #endif /* MORECORE */ +#else /* HAVE_MORECORE */ + #define CALL_MORECORE(S) MFAIL +#endif /* HAVE_MORECORE */ /** * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP */ #if HAVE_MMAP - #define USE_MMAP_BIT (SIZE_T_ONE) - - #ifdef MMAP - #define CALL_MMAP(s) MMAP(s) - #else /* MMAP */ - #define CALL_MMAP(s) MMAP_DEFAULT(s) - #endif /* MMAP */ - #ifdef MUNMAP - #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) - #else /* MUNMAP */ - #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) - #endif /* MUNMAP */ - #ifdef DIRECT_MMAP - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) - #else /* DIRECT_MMAP */ - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) - #endif /* DIRECT_MMAP */ -#else /* HAVE_MMAP */ - #define USE_MMAP_BIT (SIZE_T_ZERO) - - #define MMAP(s) MFAIL - #define MUNMAP(a, s) (-1) - #define DIRECT_MMAP(s) MFAIL - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) - #define CALL_MMAP(s) MMAP(s) - #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) -#endif /* HAVE_MMAP */ + #define USE_MMAP_BIT (SIZE_T_ONE) + + #ifdef MMAP + #define CALL_MMAP(s) MMAP(s) + #else /* MMAP */ + #define CALL_MMAP(s) MMAP_DEFAULT(s) + #endif /* MMAP */ + #ifdef MUNMAP + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) + #else /* MUNMAP */ + #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) + #endif /* MUNMAP */ + #ifdef DIRECT_MMAP + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #else /* DIRECT_MMAP */ + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) + #endif /* DIRECT_MMAP */ +#else /* HAVE_MMAP */ + #define USE_MMAP_BIT (SIZE_T_ZERO) + + #define MMAP(s) MFAIL + #define MUNMAP(a, s) (-1) + #define DIRECT_MMAP(s) MFAIL + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #define CALL_MMAP(s) MMAP(s) + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) +#endif /* HAVE_MMAP */ /** * Define CALL_MREMAP */ #if HAVE_MMAP && HAVE_MREMAP - #ifdef MREMAP - #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) - #else /* MREMAP */ - #define CALL_MREMAP(addr, osz, nsz, mv) \ - MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) - #endif /* MREMAP */ -#else /* HAVE_MMAP && HAVE_MREMAP */ - #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL -#endif /* HAVE_MMAP && HAVE_MREMAP */ + #ifdef MREMAP + #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) + #else /* MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) + #endif /* MREMAP */ +#else /* HAVE_MMAP && HAVE_MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL +#endif /* HAVE_MMAP && HAVE_MREMAP */ /* mstate bit set if continguous morecore disabled or failed */ #define USE_NONCONTIGUOUS_BIT (4U) /* segment bit set in create_mspace_with_base */ -#define EXTERN_BIT (8U) +#define EXTERN_BIT (8U) + /* --------------------------- Lock preliminaries ------------------------ */ @@ -1897,284 +1856,247 @@ static FORCEINLINE void *dlmremap(void *old_address, size_t old_size, */ #if !USE_LOCKS - #define USE_LOCK_BIT (0U) - #define INITIAL_LOCK(l) (0) - #define DESTROY_LOCK(l) (0) - #define ACQUIRE_MALLOC_GLOBAL_LOCK() - #define RELEASE_MALLOC_GLOBAL_LOCK() +#define USE_LOCK_BIT (0U) +#define INITIAL_LOCK(l) (0) +#define DESTROY_LOCK(l) (0) +#define ACQUIRE_MALLOC_GLOBAL_LOCK() +#define RELEASE_MALLOC_GLOBAL_LOCK() #else - #if USE_LOCKS > 1 - /* ----------------------- User-defined locks ------------------------ */ - /* Define your own lock implementation here */ - /* #define INITIAL_LOCK(lk) ... */ - /* #define DESTROY_LOCK(lk) ... */ - /* #define ACQUIRE_LOCK(lk) ... */ - /* #define RELEASE_LOCK(lk) ... */ - /* #define TRY_LOCK(lk) ... */ - /* static MLOCK_T malloc_global_mutex = ... */ - - #elif USE_SPIN_LOCKS - - /* First, define CAS_LOCK and CLEAR_LOCK on ints */ - /* Note CAS_LOCK defined to return 0 on success */ - - #if defined(__GNUC__) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) - #define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) - #define CLEAR_LOCK(sl) __sync_lock_release(sl) - - #elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) +#if USE_LOCKS > 1 +/* ----------------------- User-defined locks ------------------------ */ +/* Define your own lock implementation here */ +/* #define INITIAL_LOCK(lk) ... */ +/* #define DESTROY_LOCK(lk) ... */ +/* #define ACQUIRE_LOCK(lk) ... */ +/* #define RELEASE_LOCK(lk) ... */ +/* #define TRY_LOCK(lk) ... */ +/* static MLOCK_T malloc_global_mutex = ... */ + +#elif USE_SPIN_LOCKS + +/* First, define CAS_LOCK and CLEAR_LOCK on ints */ +/* Note CAS_LOCK defined to return 0 on success */ + +#if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) +#define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) +#define CLEAR_LOCK(sl) __sync_lock_release(sl) + +#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) /* Custom spin locks for older gcc on x86 */ static FORCEINLINE int x86_cas_lock(int *sl) { - int ret; int val = 1; int cmp = 0; - __asm__ __volatile__("lock; cmpxchgl %1, %2" - : "=a"(ret) - : "r"(val), "m"(*(sl)), "0"(cmp) - : "memory", "cc"); + __asm__ __volatile__ ("lock; cmpxchgl %1, %2" + : "=a" (ret) + : "r" (val), "m" (*(sl)), "0"(cmp) + : "memory", "cc"); return ret; - } -static FORCEINLINE void x86_clear_lock(int *sl) { - +static FORCEINLINE void x86_clear_lock(int* sl) { assert(*sl != 0); int prev = 0; int ret; - __asm__ __volatile__("lock; xchgl %0, %1" - : "=r"(ret) - : "m"(*(sl)), "0"(prev) - : "memory"); - + __asm__ __volatile__ ("lock; xchgl %0, %1" + : "=r" (ret) + : "m" (*(sl)), "0"(prev) + : "memory"); } - #define CAS_LOCK(sl) x86_cas_lock(sl) - #define CLEAR_LOCK(sl) x86_clear_lock(sl) - - #else /* Win32 MSC */ - #define CAS_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)1) - #define CLEAR_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)0) - - #endif /* ... gcc spins locks ... */ - - /* How to yield for a spin lock */ - #define SPINS_PER_YIELD 63 - #if defined(_MSC_VER) - #define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ - #define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) - #elif defined(__SVR4) && defined(__sun) /* solaris */ - #define SPIN_LOCK_YIELD thr_yield(); - #elif !defined(LACKS_SCHED_H) - #define SPIN_LOCK_YIELD sched_yield(); - #else - #define SPIN_LOCK_YIELD - #endif /* ... yield ... */ - - #if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 +#define CAS_LOCK(sl) x86_cas_lock(sl) +#define CLEAR_LOCK(sl) x86_clear_lock(sl) + +#else /* Win32 MSC */ +#define CAS_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)1) +#define CLEAR_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)0) + +#endif /* ... gcc spins locks ... */ + +/* How to yield for a spin lock */ +#define SPINS_PER_YIELD 63 +#if defined(_MSC_VER) +#define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ +#define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) +#elif defined (__SVR4) && defined (__sun) /* solaris */ +#define SPIN_LOCK_YIELD thr_yield(); +#elif !defined(LACKS_SCHED_H) +#define SPIN_LOCK_YIELD sched_yield(); +#else +#define SPIN_LOCK_YIELD +#endif /* ... yield ... */ + +#if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 /* Plain spin locks use single word (embedded in malloc_states) */ static int spin_acquire_lock(int *sl) { - int spins = 0; while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) { - - if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } - + if ((++spins & SPINS_PER_YIELD) == 0) { + SPIN_LOCK_YIELD; + } } - return 0; - } - #define MLOCK_T int - #define TRY_LOCK(sl) !CAS_LOCK(sl) - #define RELEASE_LOCK(sl) CLEAR_LOCK(sl) - #define ACQUIRE_LOCK(sl) (CAS_LOCK(sl) ? spin_acquire_lock(sl) : 0) - #define INITIAL_LOCK(sl) (*sl = 0) - #define DESTROY_LOCK(sl) (0) +#define MLOCK_T int +#define TRY_LOCK(sl) !CAS_LOCK(sl) +#define RELEASE_LOCK(sl) CLEAR_LOCK(sl) +#define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0) +#define INITIAL_LOCK(sl) (*sl = 0) +#define DESTROY_LOCK(sl) (0) static MLOCK_T malloc_global_mutex = 0; - #else /* USE_RECURSIVE_LOCKS */ - /* types for lock owners */ - #ifdef WIN32 - #define THREAD_ID_T DWORD - #define CURRENT_THREAD GetCurrentThreadId() - #define EQ_OWNER(X, Y) ((X) == (Y)) - #else - /* - Note: the following assume that pthread_t is a type that can be - initialized to (casted) zero. If this is not the case, you will need - to somehow redefine these or not use spin locks. - */ - #define THREAD_ID_T pthread_t - #define CURRENT_THREAD pthread_self() - #define EQ_OWNER(X, Y) pthread_equal(X, Y) - #endif +#else /* USE_RECURSIVE_LOCKS */ +/* types for lock owners */ +#ifdef WIN32 +#define THREAD_ID_T DWORD +#define CURRENT_THREAD GetCurrentThreadId() +#define EQ_OWNER(X,Y) ((X) == (Y)) +#else +/* + Note: the following assume that pthread_t is a type that can be + initialized to (casted) zero. If this is not the case, you will need to + somehow redefine these or not use spin locks. +*/ +#define THREAD_ID_T pthread_t +#define CURRENT_THREAD pthread_self() +#define EQ_OWNER(X,Y) pthread_equal(X, Y) +#endif struct malloc_recursive_lock { - - int sl; + int sl; unsigned int c; - THREAD_ID_T threadid; - + THREAD_ID_T threadid; }; - #define MLOCK_T struct malloc_recursive_lock -static MLOCK_T malloc_global_mutex = {0, 0, (THREAD_ID_T)0}; +#define MLOCK_T struct malloc_recursive_lock +static MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0}; static FORCEINLINE void recursive_release_lock(MLOCK_T *lk) { - assert(lk->sl != 0); - if (--lk->c == 0) { CLEAR_LOCK(&lk->sl); } - + if (--lk->c == 0) { + CLEAR_LOCK(&lk->sl); + } } static FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) { - THREAD_ID_T mythreadid = CURRENT_THREAD; - int spins = 0; + int spins = 0; for (;;) { - if (*((volatile int *)(&lk->sl)) == 0) { - if (!CAS_LOCK(&lk->sl)) { - lk->threadid = mythreadid; lk->c = 1; return 0; - } - - } else if (EQ_OWNER(lk->threadid, mythreadid)) { - + } + else if (EQ_OWNER(lk->threadid, mythreadid)) { ++lk->c; return 0; - } - - if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } - + if ((++spins & SPINS_PER_YIELD) == 0) { + SPIN_LOCK_YIELD; + } } - } static FORCEINLINE int recursive_try_lock(MLOCK_T *lk) { - THREAD_ID_T mythreadid = CURRENT_THREAD; if (*((volatile int *)(&lk->sl)) == 0) { - if (!CAS_LOCK(&lk->sl)) { - lk->threadid = mythreadid; lk->c = 1; return 1; - } - - } else if (EQ_OWNER(lk->threadid, mythreadid)) { - + } + else if (EQ_OWNER(lk->threadid, mythreadid)) { ++lk->c; return 1; - } - return 0; - } - #define RELEASE_LOCK(lk) recursive_release_lock(lk) - #define TRY_LOCK(lk) recursive_try_lock(lk) - #define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) - #define INITIAL_LOCK(lk) \ - ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) - #define DESTROY_LOCK(lk) (0) - #endif /* USE_RECURSIVE_LOCKS */ - - #elif defined(WIN32) /* Win32 critical sections */ - #define MLOCK_T CRITICAL_SECTION - #define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) - #define RELEASE_LOCK(lk) LeaveCriticalSection(lk) - #define TRY_LOCK(lk) TryEnterCriticalSection(lk) - #define INITIAL_LOCK(lk) \ - (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000 | 4000)) - #define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) - #define NEED_GLOBAL_LOCK_INIT - -static MLOCK_T malloc_global_mutex; +#define RELEASE_LOCK(lk) recursive_release_lock(lk) +#define TRY_LOCK(lk) recursive_try_lock(lk) +#define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) +#define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) +#define DESTROY_LOCK(lk) (0) +#endif /* USE_RECURSIVE_LOCKS */ + +#elif defined(WIN32) /* Win32 critical sections */ +#define MLOCK_T CRITICAL_SECTION +#define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) +#define RELEASE_LOCK(lk) LeaveCriticalSection(lk) +#define TRY_LOCK(lk) TryEnterCriticalSection(lk) +#define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000)) +#define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) +#define NEED_GLOBAL_LOCK_INIT + +static MLOCK_T malloc_global_mutex; static volatile LONG malloc_global_mutex_status; /* Use spin loop to initialize global lock */ static void init_malloc_global_mutex() { - for (;;) { - long stat = malloc_global_mutex_status; - if (stat > 0) return; + if (stat > 0) + return; /* transition to < 0 while initializing, then to > 0) */ - if (stat == 0 && interlockedcompareexchange(&malloc_global_mutex_status, - (LONG)-1, (LONG)0) == 0) { - + if (stat == 0 && + interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) { InitializeCriticalSection(&malloc_global_mutex); interlockedexchange(&malloc_global_mutex_status, (LONG)1); return; - } - SleepEx(0, FALSE); - } - } - #else /* pthreads-based locks */ - #define MLOCK_T pthread_mutex_t - #define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) - #define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) - #define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) - #define INITIAL_LOCK(lk) pthread_init_lock(lk) - #define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) +#else /* pthreads-based locks */ +#define MLOCK_T pthread_mutex_t +#define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) +#define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) +#define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) +#define INITIAL_LOCK(lk) pthread_init_lock(lk) +#define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) - #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && \ - defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) +#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) /* Cope with old-style linux recursive lock initialization by adding */ /* skipped internal declaration from pthread.h */ -extern int pthread_mutexattr_setkind_np __P((pthread_mutexattr_t * __attr, - int __kind)); - #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP - #define pthread_mutexattr_settype(x, y) pthread_mutexattr_setkind_np(x, y) - #endif /* USE_RECURSIVE_LOCKS ... */ +extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, + int __kind)); +#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP +#define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) +#endif /* USE_RECURSIVE_LOCKS ... */ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER; -static int pthread_init_lock(MLOCK_T *lk) { - +static int pthread_init_lock (MLOCK_T *lk) { pthread_mutexattr_t attr; if (pthread_mutexattr_init(&attr)) return 1; - #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 +#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; - #endif +#endif if (pthread_mutex_init(lk, &attr)) return 1; if (pthread_mutexattr_destroy(&attr)) return 1; return 0; - } - #endif /* ... lock types ... */ +#endif /* ... lock types ... */ - /* Common code for all lock types */ - #define USE_LOCK_BIT (2U) +/* Common code for all lock types */ +#define USE_LOCK_BIT (2U) - #ifndef ACQUIRE_MALLOC_GLOBAL_LOCK - #define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); - #endif +#ifndef ACQUIRE_MALLOC_GLOBAL_LOCK +#define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); +#endif - #ifndef RELEASE_MALLOC_GLOBAL_LOCK - #define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); - #endif +#ifndef RELEASE_MALLOC_GLOBAL_LOCK +#define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); +#endif -#endif /* USE_LOCKS */ +#endif /* USE_LOCKS */ /* ----------------------- Chunk representations ------------------------ */ @@ -2314,56 +2236,56 @@ static int pthread_init_lock(MLOCK_T *lk) { */ struct malloc_chunk { - - size_t prev_foot; /* Size of previous chunk (if free). */ - size_t head; /* Size and inuse bits. */ - struct malloc_chunk *fd; /* double links -- used only if free. */ - struct malloc_chunk *bk; - + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk* fd; /* double links -- used only if free. */ + struct malloc_chunk* bk; }; typedef struct malloc_chunk mchunk; -typedef struct malloc_chunk *mchunkptr; -typedef struct malloc_chunk *sbinptr; /* The type of bins of chunks */ -typedef unsigned int bindex_t; /* Described below */ -typedef unsigned int binmap_t; /* Described below */ -typedef unsigned int flag_t; /* The type of various bit flag sets */ +typedef struct malloc_chunk* mchunkptr; +typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ +typedef unsigned int bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ /* ------------------- Chunks sizes and alignments ----------------------- */ -#define MCHUNK_SIZE (sizeof(mchunk)) +#define MCHUNK_SIZE (sizeof(mchunk)) #if FOOTERS - #define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -#else /* FOOTERS */ - #define CHUNK_OVERHEAD (SIZE_T_SIZE) -#endif /* FOOTERS */ +#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) +#else /* FOOTERS */ +#define CHUNK_OVERHEAD (SIZE_T_SIZE) +#endif /* FOOTERS */ /* MMapped chunks need a second word of overhead ... */ #define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) /* ... and additional padding for fake next-chunk at foot */ -#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) +#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) /* The smallest size we can malloc is an aligned minimal chunk */ -#define MIN_CHUNK_SIZE ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) +#define MIN_CHUNK_SIZE\ + ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* conversion from malloc headers to user pointers, and back */ -#define chunk2mem(p) ((void *)((char *)(p) + TWO_SIZE_T_SIZES)) -#define mem2chunk(mem) ((mchunkptr)((char *)(mem)-TWO_SIZE_T_SIZES)) +#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) +#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) /* chunk associated with aligned address A */ -#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) +#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) /* Bounds on request (not chunk) sizes. */ -#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) -#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) +#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) +#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) /* pad request bytes into a usable size */ #define pad_request(req) \ - (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* pad request, checking for minimum (but not maximum) */ #define request2size(req) \ - (((req) < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(req)) + (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) + /* ------------------ Operations on head and foot fields ----------------- */ @@ -2375,60 +2297,61 @@ typedef unsigned int flag_t; /* The type of various bit flag sets */ FLAG4_BIT is not used by this malloc, but might be useful in extensions. */ -#define PINUSE_BIT (SIZE_T_ONE) -#define CINUSE_BIT (SIZE_T_TWO) -#define FLAG4_BIT (SIZE_T_FOUR) -#define INUSE_BITS (PINUSE_BIT | CINUSE_BIT) -#define FLAG_BITS (PINUSE_BIT | CINUSE_BIT | FLAG4_BIT) +#define PINUSE_BIT (SIZE_T_ONE) +#define CINUSE_BIT (SIZE_T_TWO) +#define FLAG4_BIT (SIZE_T_FOUR) +#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) +#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) /* Head value for fenceposts */ -#define FENCEPOST_HEAD (INUSE_BITS | SIZE_T_SIZE) +#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) /* extraction of fields from head words */ -#define cinuse(p) ((p)->head & CINUSE_BIT) -#define pinuse(p) ((p)->head & PINUSE_BIT) -#define flag4inuse(p) ((p)->head & FLAG4_BIT) -#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) -#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) +#define cinuse(p) ((p)->head & CINUSE_BIT) +#define pinuse(p) ((p)->head & PINUSE_BIT) +#define flag4inuse(p) ((p)->head & FLAG4_BIT) +#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) +#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) -#define chunksize(p) ((p)->head & ~(FLAG_BITS)) +#define chunksize(p) ((p)->head & ~(FLAG_BITS)) -#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) -#define set_flag4(p) ((p)->head |= FLAG4_BIT) -#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) +#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) +#define set_flag4(p) ((p)->head |= FLAG4_BIT) +#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) /* Treat space at ptr +/- offset as a chunk */ -#define chunk_plus_offset(p, s) ((mchunkptr)(((char *)(p)) + (s))) -#define chunk_minus_offset(p, s) ((mchunkptr)(((char *)(p)) - (s))) +#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) +#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) /* Ptr to next or previous physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)(((char *)(p)) + ((p)->head & ~FLAG_BITS))) -#define prev_chunk(p) ((mchunkptr)(((char *)(p)) - ((p)->prev_foot))) +#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) +#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) /* extract next chunk's pinuse bit */ -#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) +#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) /* Get/set size at footer */ -#define get_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot) -#define set_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot = (s)) +#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) +#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) /* Set size, pinuse bit, and foot */ -#define set_size_and_pinuse_of_free_chunk(p, s) \ - ((p)->head = (s | PINUSE_BIT), set_foot(p, s)) +#define set_size_and_pinuse_of_free_chunk(p, s)\ + ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) /* Set size, pinuse bit, foot, and clear next pinuse */ -#define set_free_with_pinuse(p, s, n) \ +#define set_free_with_pinuse(p, s, n)\ (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) /* Get the internal overhead associated with chunk p */ -#define overhead_for(p) (is_mmapped(p) ? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) +#define overhead_for(p)\ + (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) /* Return true if malloced space is not necessarily cleared */ #if MMAP_CLEARS - #define calloc_must_clear(p) (!is_mmapped(p)) -#else /* MMAP_CLEARS */ - #define calloc_must_clear(p) (1) -#endif /* MMAP_CLEARS */ +#define calloc_must_clear(p) (!is_mmapped(p)) +#else /* MMAP_CLEARS */ +#define calloc_must_clear(p) (1) +#endif /* MMAP_CLEARS */ /* ---------------------- Overlaid data structures ----------------------- */ @@ -2522,25 +2445,23 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct malloc_tree_chunk { - /* The first four fields must be compatible with malloc_chunk */ size_t prev_foot; size_t head; - struct malloc_tree_chunk *fd; - struct malloc_tree_chunk *bk; + struct malloc_tree_chunk* fd; + struct malloc_tree_chunk* bk; - struct malloc_tree_chunk *child[2]; - struct malloc_tree_chunk *parent; + struct malloc_tree_chunk* child[2]; + struct malloc_tree_chunk* parent; bindex_t index; - }; typedef struct malloc_tree_chunk tchunk; -typedef struct malloc_tree_chunk *tchunkptr; -typedef struct malloc_tree_chunk *tbinptr; /* The type of bins of trees */ +typedef struct malloc_tree_chunk* tchunkptr; +typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ /* A little helper macro for trees */ -#define leftmost_child(t) ((t)->child[0] != 0 ? (t)->child[0] : (t)->child[1]) +#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) /* ----------------------------- Segments -------------------------------- */ @@ -2600,19 +2521,17 @@ typedef struct malloc_tree_chunk *tbinptr; /* The type of bins of trees */ */ struct malloc_segment { - - char * base; /* base address */ - size_t size; /* allocated size */ - struct malloc_segment *next; /* ptr to next segment */ - flag_t sflags; /* mmap and extern flag */ - + char* base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment* next; /* ptr to next segment */ + flag_t sflags; /* mmap and extern flag */ }; -#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) -#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) +#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) +#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) typedef struct malloc_segment msegment; -typedef struct malloc_segment *msegmentptr; +typedef struct malloc_segment* msegmentptr; /* ---------------------------- malloc_state ----------------------------- */ @@ -2702,43 +2621,41 @@ typedef struct malloc_segment *msegmentptr; */ /* Bin types, widths and sizes */ -#define NSMALLBINS (32U) -#define NTREEBINS (32U) -#define SMALLBIN_SHIFT (3U) -#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) -#define TREEBIN_SHIFT (8U) -#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) -#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) +#define NSMALLBINS (32U) +#define NTREEBINS (32U) +#define SMALLBIN_SHIFT (3U) +#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) +#define TREEBIN_SHIFT (8U) +#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) +#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) struct malloc_state { - - binmap_t smallmap; - binmap_t treemap; - size_t dvsize; - size_t topsize; - char * least_addr; - mchunkptr dv; - mchunkptr top; - size_t trim_check; - size_t release_checks; - size_t magic; - mchunkptr smallbins[(NSMALLBINS + 1) * 2]; - tbinptr treebins[NTREEBINS]; - size_t footprint; - size_t max_footprint; - size_t footprint_limit; /* zero means no limit */ - flag_t mflags; + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + char* least_addr; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t release_checks; + size_t magic; + mchunkptr smallbins[(NSMALLBINS+1)*2]; + tbinptr treebins[NTREEBINS]; + size_t footprint; + size_t max_footprint; + size_t footprint_limit; /* zero means no limit */ + flag_t mflags; #if USE_LOCKS - MLOCK_T mutex; /* locate lock among fields that rarely change */ -#endif /* USE_LOCKS */ - msegment seg; - void * extp; /* Unused but available for extensions */ - size_t exts; - + MLOCK_T mutex; /* locate lock among fields that rarely change */ +#endif /* USE_LOCKS */ + msegment seg; + void* extp; /* Unused but available for extensions */ + size_t exts; }; -typedef struct malloc_state *mstate; +typedef struct malloc_state* mstate; /* ------------- Global malloc_state and malloc_params ------------------- */ @@ -2750,14 +2667,12 @@ typedef struct malloc_state *mstate; */ struct malloc_params { - size_t magic; size_t page_size; size_t granularity; size_t mmap_threshold; size_t trim_threshold; flag_t default_mflags; - }; static struct malloc_params mparams; @@ -2769,108 +2684,106 @@ static struct malloc_params mparams; /* The global malloc_state used for all non-"mspace" calls */ static struct malloc_state _gm_; - #define gm (&_gm_) - #define is_global(M) ((M) == &_gm_) +#define gm (&_gm_) +#define is_global(M) ((M) == &_gm_) -#endif /* !ONLY_MSPACES */ +#endif /* !ONLY_MSPACES */ -#define is_initialized(M) ((M)->top != 0) +#define is_initialized(M) ((M)->top != 0) /* -------------------------- system alloc setup ------------------------- */ /* Operations on mflags */ -#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) -#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) +#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) +#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) #if USE_LOCKS - #define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) +#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) #else - #define disable_lock(M) +#define disable_lock(M) #endif -#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) -#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) +#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) +#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) #if HAVE_MMAP - #define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) +#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) #else - #define disable_mmap(M) +#define disable_mmap(M) #endif -#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) -#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) +#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) +#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) -#define set_lock(M, L) \ - ((M)->mflags = \ - (L) ? ((M)->mflags | USE_LOCK_BIT) : ((M)->mflags & ~USE_LOCK_BIT)) +#define set_lock(M,L)\ + ((M)->mflags = (L)?\ + ((M)->mflags | USE_LOCK_BIT) :\ + ((M)->mflags & ~USE_LOCK_BIT)) /* page-align a size */ -#define page_align(S) \ - (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) +#define page_align(S)\ + (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) /* granularity-align a size */ -#define granularity_align(S) \ - (((S) + (mparams.granularity - SIZE_T_ONE)) & \ - ~(mparams.granularity - SIZE_T_ONE)) +#define granularity_align(S)\ + (((S) + (mparams.granularity - SIZE_T_ONE))\ + & ~(mparams.granularity - SIZE_T_ONE)) + /* For mmap, use granularity alignment on windows, else page-align */ #ifdef WIN32 - #define mmap_align(S) granularity_align(S) +#define mmap_align(S) granularity_align(S) #else - #define mmap_align(S) page_align(S) +#define mmap_align(S) page_align(S) #endif /* For sys_alloc, enough padding to ensure can malloc request on success */ #define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) -#define is_page_aligned(S) \ - (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) -#define is_granularity_aligned(S) \ - (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) +#define is_page_aligned(S)\ + (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) +#define is_granularity_aligned(S)\ + (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) /* True if segment S holds address A */ -#define segment_holds(S, A) \ - ((char *)(A) >= S->base && (char *)(A) < S->base + S->size) +#define segment_holds(S, A)\ + ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) /* Return segment holding given address */ -static msegmentptr segment_holding(mstate m, char *addr) { - +static msegmentptr segment_holding(mstate m, char* addr) { msegmentptr sp = &m->seg; for (;;) { - - if (addr >= sp->base && addr < sp->base + sp->size) return sp; - if ((sp = sp->next) == 0) return 0; - + if (addr >= sp->base && addr < sp->base + sp->size) + return sp; + if ((sp = sp->next) == 0) + return 0; } - } /* Return true if segment contains a segment link */ static int has_segment_link(mstate m, msegmentptr ss) { - msegmentptr sp = &m->seg; for (;;) { - - if ((char *)sp >= ss->base && (char *)sp < ss->base + ss->size) return 1; - if ((sp = sp->next) == 0) return 0; - + if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) + return 1; + if ((sp = sp->next) == 0) + return 0; } - } #ifndef MORECORE_CANNOT_TRIM - #define should_trim(M, s) ((s) > (M)->trim_check) -#else /* MORECORE_CANNOT_TRIM */ - #define should_trim(M, s) (0) -#endif /* MORECORE_CANNOT_TRIM */ +#define should_trim(M,s) ((s) > (M)->trim_check) +#else /* MORECORE_CANNOT_TRIM */ +#define should_trim(M,s) (0) +#endif /* MORECORE_CANNOT_TRIM */ /* TOP_FOOT_SIZE is padding at the end of a segment, including space that may be needed to place segment records and fenceposts when new noncontiguous segments are added. */ -#define TOP_FOOT_SIZE \ - (align_offset(chunk2mem(0)) + pad_request(sizeof(struct malloc_segment)) + \ - MIN_CHUNK_SIZE) +#define TOP_FOOT_SIZE\ + (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) + /* ------------------------------- Hooks -------------------------------- */ @@ -2881,24 +2794,19 @@ static int has_segment_link(mstate m, msegmentptr ss) { */ #if USE_LOCKS - #define PREACTION(M) ((use_lock(M)) ? ACQUIRE_LOCK(&(M)->mutex) : 0) - #define POSTACTION(M) \ - { \ - \ - if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); \ - \ - } -#else /* USE_LOCKS */ +#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) +#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } +#else /* USE_LOCKS */ - #ifndef PREACTION - #define PREACTION(M) (0) - #endif /* PREACTION */ +#ifndef PREACTION +#define PREACTION(M) (0) +#endif /* PREACTION */ - #ifndef POSTACTION - #define POSTACTION(M) - #endif /* POSTACTION */ +#ifndef POSTACTION +#define POSTACTION(M) +#endif /* POSTACTION */ -#endif /* USE_LOCKS */ +#endif /* USE_LOCKS */ /* CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. @@ -2916,180 +2824,164 @@ int malloc_corruption_error_count; /* default corruption action */ static void reset_on_error(mstate m); - #define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) - #define USAGE_ERROR_ACTION(m, p) +#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) +#define USAGE_ERROR_ACTION(m, p) -#else /* PROCEED_ON_ERROR */ +#else /* PROCEED_ON_ERROR */ - #ifndef CORRUPTION_ERROR_ACTION - #define CORRUPTION_ERROR_ACTION(m) ABORT - #endif /* CORRUPTION_ERROR_ACTION */ +#ifndef CORRUPTION_ERROR_ACTION +#define CORRUPTION_ERROR_ACTION(m) ABORT +#endif /* CORRUPTION_ERROR_ACTION */ - #ifndef USAGE_ERROR_ACTION - #define USAGE_ERROR_ACTION(m, p) ABORT - #endif /* USAGE_ERROR_ACTION */ +#ifndef USAGE_ERROR_ACTION +#define USAGE_ERROR_ACTION(m,p) ABORT +#endif /* USAGE_ERROR_ACTION */ + +#endif /* PROCEED_ON_ERROR */ -#endif /* PROCEED_ON_ERROR */ /* -------------------------- Debugging setup ---------------------------- */ -#if !DEBUG +#if ! DEBUG - #define check_free_chunk(M, P) - #define check_inuse_chunk(M, P) - #define check_malloced_chunk(M, P, N) - #define check_mmapped_chunk(M, P) - #define check_malloc_state(M) - #define check_top_chunk(M, P) +#define check_free_chunk(M,P) +#define check_inuse_chunk(M,P) +#define check_malloced_chunk(M,P,N) +#define check_mmapped_chunk(M,P) +#define check_malloc_state(M) +#define check_top_chunk(M,P) -#else /* DEBUG */ - #define check_free_chunk(M, P) do_check_free_chunk(M, P) - #define check_inuse_chunk(M, P) do_check_inuse_chunk(M, P) - #define check_top_chunk(M, P) do_check_top_chunk(M, P) - #define check_malloced_chunk(M, P, N) do_check_malloced_chunk(M, P, N) - #define check_mmapped_chunk(M, P) do_check_mmapped_chunk(M, P) - #define check_malloc_state(M) do_check_malloc_state(M) +#else /* DEBUG */ +#define check_free_chunk(M,P) do_check_free_chunk(M,P) +#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) +#define check_top_chunk(M,P) do_check_top_chunk(M,P) +#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) +#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) +#define check_malloc_state(M) do_check_malloc_state(M) static void do_check_any_chunk(mstate m, mchunkptr p); static void do_check_top_chunk(mstate m, mchunkptr p); static void do_check_mmapped_chunk(mstate m, mchunkptr p); static void do_check_inuse_chunk(mstate m, mchunkptr p); static void do_check_free_chunk(mstate m, mchunkptr p); -static void do_check_malloced_chunk(mstate m, void *mem, size_t s); +static void do_check_malloced_chunk(mstate m, void* mem, size_t s); static void do_check_tree(mstate m, tchunkptr t); static void do_check_treebin(mstate m, bindex_t i); static void do_check_smallbin(mstate m, bindex_t i); static void do_check_malloc_state(mstate m); static int bin_find(mstate m, mchunkptr x); static size_t traverse_and_check(mstate m); -#endif /* DEBUG */ +#endif /* DEBUG */ /* ---------------------------- Indexing Bins ---------------------------- */ -#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) -#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) -#define small_index2size(i) ((i) << SMALLBIN_SHIFT) -#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) +#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) +#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) +#define small_index2size(i) ((i) << SMALLBIN_SHIFT) +#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) /* addressing by index. See above about smallbin repositioning */ -#define smallbin_at(M, i) ((sbinptr)((char *)&((M)->smallbins[(i) << 1]))) -#define treebin_at(M, i) (&((M)->treebins[i])) +#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) +#define treebin_at(M,i) (&((M)->treebins[i])) /* assign tree index for size S to variable I. Use x86 asm if possible */ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - #define compute_tree_index(S, I) \ - { \ - \ - unsigned int X = S >> TREEBIN_SHIFT; \ - if (X == 0) \ - I = 0; \ - else if (X > 0xFFFF) \ - I = NTREEBINS - 1; \ - else { \ - \ - unsigned int K = (unsigned)sizeof(X) * __CHAR_BIT__ - 1 - \ - (unsigned)__builtin_clz(X); \ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ - \ - } \ - \ - } +#define compute_tree_index(S, I)\ +{\ + unsigned int X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} -#elif defined(__INTEL_COMPILER) - #define compute_tree_index(S, I) \ - { \ - \ - size_t X = S >> TREEBIN_SHIFT; \ - if (X == 0) \ - I = 0; \ - else if (X > 0xFFFF) \ - I = NTREEBINS - 1; \ - else { \ - \ - unsigned int K = _bit_scan_reverse(X); \ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ - \ - } \ - \ - } +#elif defined (__INTEL_COMPILER) +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K = _bit_scan_reverse (X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} -#elif defined(_MSC_VER) && _MSC_VER >= 1300 - #define compute_tree_index(S, I) \ - { \ - \ - size_t X = S >> TREEBIN_SHIFT; \ - if (X == 0) \ - I = 0; \ - else if (X > 0xFFFF) \ - I = NTREEBINS - 1; \ - else { \ - \ - unsigned int K; \ - _BitScanReverse((DWORD *)&K, (DWORD)X); \ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ - \ - } \ - \ - } +#elif defined(_MSC_VER) && _MSC_VER>=1300 +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int K;\ + _BitScanReverse((DWORD *) &K, (DWORD) X);\ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ + }\ +} -#else /* GNUC */ - #define compute_tree_index(S, I) \ - { \ - \ - size_t X = S >> TREEBIN_SHIFT; \ - if (X == 0) \ - I = 0; \ - else if (X > 0xFFFF) \ - I = NTREEBINS - 1; \ - else { \ - \ - unsigned int Y = (unsigned int)X; \ - unsigned int N = ((Y - 0x100) >> 16) & 8; \ - unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4; \ - N += K; \ - N += K = (((Y <<= K) - 0x4000) >> 16) & 2; \ - K = 14 - N + ((Y <<= K) >> 15); \ - I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1)); \ - \ - } \ - \ - } -#endif /* GNUC */ +#else /* GNUC */ +#define compute_tree_index(S, I)\ +{\ + size_t X = S >> TREEBIN_SHIFT;\ + if (X == 0)\ + I = 0;\ + else if (X > 0xFFFF)\ + I = NTREEBINS-1;\ + else {\ + unsigned int Y = (unsigned int)X;\ + unsigned int N = ((Y - 0x100) >> 16) & 8;\ + unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ + N += K;\ + N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ + K = 14 - N + ((Y <<= K) >> 15);\ + I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ + }\ +} +#endif /* GNUC */ /* Bit representing maximum resolved size in a treebin at i */ #define bit_for_tree_index(i) \ - (i == NTREEBINS - 1) ? (SIZE_T_BITSIZE - 1) : (((i) >> 1) + TREEBIN_SHIFT - 2) + (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) /* Shift placing maximum resolved bit in a treebin at i as sign bit */ #define leftshift_for_tree_index(i) \ - ((i == NTREEBINS - 1) \ - ? 0 \ - : ((SIZE_T_BITSIZE - SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + ((i == NTREEBINS-1)? 0 : \ + ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) /* The size of the smallest chunk held in bin with index i */ -#define minsize_for_tree_index(i) \ - ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ - (((size_t)((i)&SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) +#define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ + (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) + /* ------------------------ Operations on bin maps ----------------------- */ /* bit corresponding to given index */ -#define idx2bit(i) ((binmap_t)(1) << (i)) +#define idx2bit(i) ((binmap_t)(1) << (i)) /* Mark/Clear bits with given index */ -#define mark_smallmap(M, i) ((M)->smallmap |= idx2bit(i)) -#define clear_smallmap(M, i) ((M)->smallmap &= ~idx2bit(i)) -#define smallmap_is_marked(M, i) ((M)->smallmap & idx2bit(i)) +#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) +#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) +#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) -#define mark_treemap(M, i) ((M)->treemap |= idx2bit(i)) -#define clear_treemap(M, i) ((M)->treemap &= ~idx2bit(i)) -#define treemap_is_marked(M, i) ((M)->treemap & idx2bit(i)) +#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) +#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) +#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) /* isolate the least set bit of a bitmap */ -#define least_bit(x) ((x) & -(x)) +#define least_bit(x) ((x) & -(x)) /* mask with all bits to left of least bit of x on */ -#define left_bits(x) ((x << 1) | -(x << 1)) +#define left_bits(x) ((x<<1) | -(x<<1)) /* mask with all bits to left of or equal to least bit of x on */ #define same_or_left_bits(x) ((x) | -(x)) @@ -3097,58 +2989,46 @@ static size_t traverse_and_check(mstate m); /* index corresponding to given bit. Use x86 asm if possible */ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - #define compute_bit2idx(X, I) \ - { \ - \ - unsigned int J; \ - J = __builtin_ctz(X); \ - I = (bindex_t)J; \ - \ - } +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + J = __builtin_ctz(X); \ + I = (bindex_t)J;\ +} -#elif defined(__INTEL_COMPILER) - #define compute_bit2idx(X, I) \ - { \ - \ - unsigned int J; \ - J = _bit_scan_forward(X); \ - I = (bindex_t)J; \ - \ - } +#elif defined (__INTEL_COMPILER) +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + J = _bit_scan_forward (X); \ + I = (bindex_t)J;\ +} -#elif defined(_MSC_VER) && _MSC_VER >= 1300 - #define compute_bit2idx(X, I) \ - { \ - \ - unsigned int J; \ - _BitScanForward((DWORD *)&J, X); \ - I = (bindex_t)J; \ - \ - } +#elif defined(_MSC_VER) && _MSC_VER>=1300 +#define compute_bit2idx(X, I)\ +{\ + unsigned int J;\ + _BitScanForward((DWORD *) &J, X);\ + I = (bindex_t)J;\ +} #elif USE_BUILTIN_FFS - #define compute_bit2idx(X, I) I = ffs(X) - 1 +#define compute_bit2idx(X, I) I = ffs(X)-1 #else - #define compute_bit2idx(X, I) \ - { \ - \ - unsigned int Y = X - 1; \ - unsigned int K = Y >> (16 - 4) & 16; \ - unsigned int N = K; \ - Y >>= K; \ - N += K = Y >> (8 - 3) & 8; \ - Y >>= K; \ - N += K = Y >> (4 - 2) & 4; \ - Y >>= K; \ - N += K = Y >> (2 - 1) & 2; \ - Y >>= K; \ - N += K = Y >> (1 - 0) & 1; \ - Y >>= K; \ - I = (bindex_t)(N + Y); \ - \ - } -#endif /* GNUC */ +#define compute_bit2idx(X, I)\ +{\ + unsigned int Y = X - 1;\ + unsigned int K = Y >> (16-4) & 16;\ + unsigned int N = K; Y >>= K;\ + N += K = Y >> (8-3) & 8; Y >>= K;\ + N += K = Y >> (4-2) & 4; Y >>= K;\ + N += K = Y >> (2-1) & 2; Y >>= K;\ + N += K = Y >> (1-0) & 1; Y >>= K;\ + I = (bindex_t)(N + Y);\ +} +#endif /* GNUC */ + /* ----------------------- Runtime Check Support ------------------------- */ @@ -3179,141 +3059,121 @@ static size_t traverse_and_check(mstate m); */ #if !INSECURE - /* Check if address a is at least as high as any from MORECORE or MMAP */ - #define ok_address(M, a) ((char *)(a) >= (M)->least_addr) - /* Check if address of next chunk n is higher than base chunk p */ - #define ok_next(p, n) ((char *)(p) < (char *)(n)) - /* Check if p has inuse status */ - #define ok_inuse(p) is_inuse(p) - /* Check if p has its pinuse bit on */ - #define ok_pinuse(p) pinuse(p) - -#else /* !INSECURE */ - #define ok_address(M, a) (1) - #define ok_next(b, n) (1) - #define ok_inuse(p) (1) - #define ok_pinuse(p) (1) -#endif /* !INSECURE */ +/* Check if address a is at least as high as any from MORECORE or MMAP */ +#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) +/* Check if address of next chunk n is higher than base chunk p */ +#define ok_next(p, n) ((char*)(p) < (char*)(n)) +/* Check if p has inuse status */ +#define ok_inuse(p) is_inuse(p) +/* Check if p has its pinuse bit on */ +#define ok_pinuse(p) pinuse(p) + +#else /* !INSECURE */ +#define ok_address(M, a) (1) +#define ok_next(b, n) (1) +#define ok_inuse(p) (1) +#define ok_pinuse(p) (1) +#endif /* !INSECURE */ #if (FOOTERS && !INSECURE) - /* Check if (alleged) mstate m has expected magic field */ - #define ok_magic(M) ((M)->magic == mparams.magic) -#else /* (FOOTERS && !INSECURE) */ - #define ok_magic(M) (1) -#endif /* (FOOTERS && !INSECURE) */ +/* Check if (alleged) mstate m has expected magic field */ +#define ok_magic(M) ((M)->magic == mparams.magic) +#else /* (FOOTERS && !INSECURE) */ +#define ok_magic(M) (1) +#endif /* (FOOTERS && !INSECURE) */ /* In gcc, use __builtin_expect to minimize impact of checks */ #if !INSECURE - #if defined(__GNUC__) && __GNUC__ >= 3 - #define RTCHECK(e) __builtin_expect(e, 1) - #else /* GNUC */ - #define RTCHECK(e) (e) - #endif /* GNUC */ -#else /* !INSECURE */ - #define RTCHECK(e) (1) -#endif /* !INSECURE */ +#if defined(__GNUC__) && __GNUC__ >= 3 +#define RTCHECK(e) __builtin_expect(e, 1) +#else /* GNUC */ +#define RTCHECK(e) (e) +#endif /* GNUC */ +#else /* !INSECURE */ +#define RTCHECK(e) (1) +#endif /* !INSECURE */ /* macros to set up inuse chunks with or without footers */ #if !FOOTERS - #define mark_inuse_foot(M, p, s) +#define mark_inuse_foot(M,p,s) - /* Macros for setting head/foot of non-mmapped chunks */ +/* Macros for setting head/foot of non-mmapped chunks */ - /* Set cinuse bit and pinuse bit of next chunk */ - #define set_inuse(M, p, s) \ - ((p)->head = (((p)->head & PINUSE_BIT) | s | CINUSE_BIT), \ - ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) +/* Set cinuse bit and pinuse bit of next chunk */ +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) - /* Set cinuse and pinuse of this chunk and pinuse of next chunk */ - #define set_inuse_and_pinuse(M, p, s) \ - ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), \ - ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) +/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) - /* Set size, cinuse and pinuse bit of this chunk */ - #define set_size_and_pinuse_of_inuse_chunk(M, p, s) \ - ((p)->head = (s | PINUSE_BIT | CINUSE_BIT)) +/* Set size, cinuse and pinuse bit of this chunk */ +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) -#else /* FOOTERS */ +#else /* FOOTERS */ - /* Set foot of inuse chunk to be xor of mstate and seed */ - #define mark_inuse_foot(M, p, s) \ - (((mchunkptr)((char *)(p) + (s)))->prev_foot = \ - ((size_t)(M) ^ mparams.magic)) +/* Set foot of inuse chunk to be xor of mstate and seed */ +#define mark_inuse_foot(M,p,s)\ + (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) - #define get_mstate_for(p) \ - ((mstate)(((mchunkptr)((char *)(p) + (chunksize(p))))->prev_foot ^ \ - mparams.magic)) +#define get_mstate_for(p)\ + ((mstate)(((mchunkptr)((char*)(p) +\ + (chunksize(p))))->prev_foot ^ mparams.magic)) - #define set_inuse(M, p, s) \ - ((p)->head = (((p)->head & PINUSE_BIT) | s | CINUSE_BIT), \ - (((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT), \ - mark_inuse_foot(M, p, s)) +#define set_inuse(M,p,s)\ + ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ + (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M,p,s)) - #define set_inuse_and_pinuse(M, p, s) \ - ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), \ - (((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT), \ - mark_inuse_foot(M, p, s)) +#define set_inuse_and_pinuse(M,p,s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ + mark_inuse_foot(M,p,s)) - #define set_size_and_pinuse_of_inuse_chunk(M, p, s) \ - ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), mark_inuse_foot(M, p, s)) +#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ + ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ + mark_inuse_foot(M, p, s)) -#endif /* !FOOTERS */ +#endif /* !FOOTERS */ /* ---------------------------- setting mparams -------------------------- */ #if LOCK_AT_FORK -static void pre_fork(void) { - - ACQUIRE_LOCK(&(gm)->mutex); - -} - -static void post_fork_parent(void) { - - RELEASE_LOCK(&(gm)->mutex); - -} - -static void post_fork_child(void) { - - INITIAL_LOCK(&(gm)->mutex); - -} - -#endif /* LOCK_AT_FORK */ +static void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); } +static void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); } +static void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); } +#endif /* LOCK_AT_FORK */ /* Initialize mparams */ static int init_mparams(void) { - #ifdef NEED_GLOBAL_LOCK_INIT - if (malloc_global_mutex_status <= 0) init_malloc_global_mutex(); + if (malloc_global_mutex_status <= 0) + init_malloc_global_mutex(); #endif ACQUIRE_MALLOC_GLOBAL_LOCK(); if (mparams.magic == 0) { - size_t magic; size_t psize; size_t gsize; #ifndef WIN32 psize = malloc_getpagesize; - gsize = ((DEFAULT_GRANULARITY != 0) ? DEFAULT_GRANULARITY : psize); -#else /* WIN32 */ + gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); +#else /* WIN32 */ { - SYSTEM_INFO system_info; GetSystemInfo(&system_info); psize = system_info.dwPageSize; - gsize = - ((DEFAULT_GRANULARITY != 0) ? DEFAULT_GRANULARITY - : system_info.dwAllocationGranularity); - + gsize = ((DEFAULT_GRANULARITY != 0)? + DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); } - -#endif /* WIN32 */ +#endif /* WIN32 */ /* Sanity-check configuration: size_t must be unsigned and as wide as pointer type. @@ -3321,23 +3181,24 @@ static int init_mparams(void) { alignment must be at least 8. Alignment, min chunk size, and page size must all be powers of 2. */ - if ((sizeof(size_t) != sizeof(char *)) || (MAX_SIZE_T < MIN_CHUNK_SIZE) || - (sizeof(int) < 4) || (MALLOC_ALIGNMENT < (size_t)8U) || - ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT - SIZE_T_ONE)) != 0) || - ((MCHUNK_SIZE & (MCHUNK_SIZE - SIZE_T_ONE)) != 0) || - ((gsize & (gsize - SIZE_T_ONE)) != 0) || - ((psize & (psize - SIZE_T_ONE)) != 0)) + if ((sizeof(size_t) != sizeof(char*)) || + (MAX_SIZE_T < MIN_CHUNK_SIZE) || + (sizeof(int) < 4) || + (MALLOC_ALIGNMENT < (size_t)8U) || + ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || + ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || + ((gsize & (gsize-SIZE_T_ONE)) != 0) || + ((psize & (psize-SIZE_T_ONE)) != 0)) ABORT; mparams.granularity = gsize; mparams.page_size = psize; mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; #if MORECORE_CONTIGUOUS - mparams.default_mflags = USE_LOCK_BIT | USE_MMAP_BIT; -#else /* MORECORE_CONTIGUOUS */ - mparams.default_mflags = - USE_LOCK_BIT | USE_MMAP_BIT | USE_NONCONTIGUOUS_BIT; -#endif /* MORECORE_CONTIGUOUS */ + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; +#else /* MORECORE_CONTIGUOUS */ + mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; +#endif /* MORECORE_CONTIGUOUS */ #if !ONLY_MSPACES /* Set up lock for main malloc area */ @@ -3349,69 +3210,57 @@ static int init_mparams(void) { #endif { - #if USE_DEV_RANDOM - int fd; + int fd; unsigned char buf[sizeof(size_t)]; /* Try to use /dev/urandom, else fall back on using time */ if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && read(fd, buf, sizeof(buf)) == sizeof(buf)) { - - magic = *((size_t *)buf); + magic = *((size_t *) buf); close(fd); - - } else - -#endif /* USE_DEV_RANDOM */ + } + else +#endif /* USE_DEV_RANDOM */ #ifdef WIN32 - magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); + magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); #elif defined(LACKS_TIME_H) magic = (size_t)&magic ^ (size_t)0x55555555U; #else magic = (size_t)(time(0) ^ (size_t)0x55555555U); #endif - magic |= (size_t)8U; /* ensure nonzero */ - magic &= ~(size_t)7U; /* improve chances of fault for bad values */ + magic |= (size_t)8U; /* ensure nonzero */ + magic &= ~(size_t)7U; /* improve chances of fault for bad values */ /* Until memory modes commonly available, use volatile-write */ (*(volatile size_t *)(&(mparams.magic))) = magic; - } - } RELEASE_MALLOC_GLOBAL_LOCK(); return 1; - } /* support for mallopt */ static int change_mparam(int param_number, int value) { - size_t val; ensure_initialization(); - val = (value == -1) ? MAX_SIZE_T : (size_t)value; - switch (param_number) { - - case M_TRIM_THRESHOLD: - mparams.trim_threshold = val; - return 1; - case M_GRANULARITY: - if (val >= mparams.page_size && ((val & (val - 1)) == 0)) { - - mparams.granularity = val; - return 1; - - } else - - return 0; - case M_MMAP_THRESHOLD: - mparams.mmap_threshold = val; + val = (value == -1)? MAX_SIZE_T : (size_t)value; + switch(param_number) { + case M_TRIM_THRESHOLD: + mparams.trim_threshold = val; + return 1; + case M_GRANULARITY: + if (val >= mparams.page_size && ((val & (val-1)) == 0)) { + mparams.granularity = val; return 1; - default: + } + else return 0; - + case M_MMAP_THRESHOLD: + mparams.mmap_threshold = val; + return 1; + default: + return 0; } - } #if DEBUG @@ -3419,118 +3268,100 @@ static int change_mparam(int param_number, int value) { /* Check properties of any chunk, whether free, inuse, mmapped etc */ static void do_check_any_chunk(mstate m, mchunkptr p) { - assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); - } /* Check properties of top chunk */ static void do_check_top_chunk(mstate m, mchunkptr p) { - - msegmentptr sp = segment_holding(m, (char *)p); - size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ + msegmentptr sp = segment_holding(m, (char*)p); + size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ assert(sp != 0); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(sz == m->topsize); assert(sz > 0); - assert(sz == ((sp->base + sp->size) - (char *)p) - TOP_FOOT_SIZE); + assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); assert(pinuse(p)); assert(!pinuse(chunk_plus_offset(p, sz))); - } /* Check properties of (inuse) mmapped chunks */ static void do_check_mmapped_chunk(mstate m, mchunkptr p) { - - size_t sz = chunksize(p); + size_t sz = chunksize(p); size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); assert(is_mmapped(p)); assert(use_mmap(m)); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(!is_small(sz)); - assert((len & (mparams.page_size - SIZE_T_ONE)) == 0); + assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); - assert(chunk_plus_offset(p, sz + SIZE_T_SIZE)->head == 0); - + assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); } /* Check properties of inuse chunks */ static void do_check_inuse_chunk(mstate m, mchunkptr p) { - do_check_any_chunk(m, p); assert(is_inuse(p)); assert(next_pinuse(p)); /* If not pinuse and not mmapped, previous chunk has OK offset */ assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); - if (is_mmapped(p)) do_check_mmapped_chunk(m, p); - + if (is_mmapped(p)) + do_check_mmapped_chunk(m, p); } /* Check properties of free chunks */ static void do_check_free_chunk(mstate m, mchunkptr p) { - - size_t sz = chunksize(p); + size_t sz = chunksize(p); mchunkptr next = chunk_plus_offset(p, sz); do_check_any_chunk(m, p); assert(!is_inuse(p)); assert(!next_pinuse(p)); - assert(!is_mmapped(p)); + assert (!is_mmapped(p)); if (p != m->dv && p != m->top) { - if (sz >= MIN_CHUNK_SIZE) { - assert((sz & CHUNK_ALIGN_MASK) == 0); assert(is_aligned(chunk2mem(p))); assert(next->prev_foot == sz); assert(pinuse(p)); - assert(next == m->top || is_inuse(next)); + assert (next == m->top || is_inuse(next)); assert(p->fd->bk == p); assert(p->bk->fd == p); - - } else /* markers are always of size SIZE_T_SIZE */ - + } + else /* markers are always of size SIZE_T_SIZE */ assert(sz == SIZE_T_SIZE); - } - } /* Check properties of malloced chunks at the point they are malloced */ -static void do_check_malloced_chunk(mstate m, void *mem, size_t s) { - +static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { if (mem != 0) { - mchunkptr p = mem2chunk(mem); - size_t sz = p->head & ~INUSE_BITS; + size_t sz = p->head & ~INUSE_BITS; do_check_inuse_chunk(m, p); assert((sz & CHUNK_ALIGN_MASK) == 0); assert(sz >= MIN_CHUNK_SIZE); assert(sz >= s); /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); - } - } /* Check a tree and its subtrees. */ static void do_check_tree(mstate m, tchunkptr t) { - tchunkptr head = 0; tchunkptr u = t; - bindex_t tindex = t->index; - size_t tsize = chunksize(t); - bindex_t idx; + bindex_t tindex = t->index; + size_t tsize = chunksize(t); + bindex_t idx; compute_tree_index(tsize, idx); assert(tindex == idx); assert(tsize >= MIN_LARGE_SIZE); assert(tsize >= minsize_for_tree_index(idx)); - assert((idx == NTREEBINS - 1) || (tsize < minsize_for_tree_index((idx + 1)))); + assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); - do { /* traverse through chain of same-sized nodes */ + do { /* traverse through chain of same-sized nodes */ do_check_any_chunk(m, ((mchunkptr)u)); assert(u->index == tindex); assert(chunksize(u) == tsize); @@ -3539,72 +3370,56 @@ static void do_check_tree(mstate m, tchunkptr t) { assert(u->fd->bk == u); assert(u->bk->fd == u); if (u->parent == 0) { - assert(u->child[0] == 0); assert(u->child[1] == 0); - - } else { - - assert(head == 0); /* only one node on chain has parent */ + } + else { + assert(head == 0); /* only one node on chain has parent */ head = u; assert(u->parent != u); - assert(u->parent->child[0] == u || u->parent->child[1] == u || - *((tbinptr *)(u->parent)) == u); + assert (u->parent->child[0] == u || + u->parent->child[1] == u || + *((tbinptr*)(u->parent)) == u); if (u->child[0] != 0) { - assert(u->child[0]->parent == u); assert(u->child[0] != u); do_check_tree(m, u->child[0]); - } - if (u->child[1] != 0) { - assert(u->child[1]->parent == u); assert(u->child[1] != u); do_check_tree(m, u->child[1]); - } - if (u->child[0] != 0 && u->child[1] != 0) { - assert(chunksize(u->child[0]) < chunksize(u->child[1])); - } - } - u = u->fd; - } while (u != t); - assert(head != 0); - } /* Check all the chunks in a treebin. */ static void do_check_treebin(mstate m, bindex_t i) { - - tbinptr * tb = treebin_at(m, i); + tbinptr* tb = treebin_at(m, i); tchunkptr t = *tb; - int empty = (m->treemap & (1U << i)) == 0; - if (t == 0) assert(empty); - if (!empty) do_check_tree(m, t); - + int empty = (m->treemap & (1U << i)) == 0; + if (t == 0) + assert(empty); + if (!empty) + do_check_tree(m, t); } /* Check all the chunks in a smallbin. */ static void do_check_smallbin(mstate m, bindex_t i) { - - sbinptr b = smallbin_at(m, i); - mchunkptr p = b->bk; + sbinptr b = smallbin_at(m, i); + mchunkptr p = b->bk; unsigned int empty = (m->smallmap & (1U << i)) == 0; - if (p == b) assert(empty); + if (p == b) + assert(empty); if (!empty) { - for (; p != b; p = p->bk) { - - size_t size = chunksize(p); + size_t size = chunksize(p); mchunkptr q; /* each chunk claims to be free */ do_check_free_chunk(m, p); @@ -3613,249 +3428,185 @@ static void do_check_smallbin(mstate m, bindex_t i) { assert(p->bk == b || chunksize(p->bk) == chunksize(p)); /* chunk is followed by an inuse chunk */ q = next_chunk(p); - if (q->head != FENCEPOST_HEAD) do_check_inuse_chunk(m, q); - + if (q->head != FENCEPOST_HEAD) + do_check_inuse_chunk(m, q); } - } - } /* Find x in a bin. Used in other check functions. */ static int bin_find(mstate m, mchunkptr x) { - size_t size = chunksize(x); if (is_small(size)) { - bindex_t sidx = small_index(size); - sbinptr b = smallbin_at(m, sidx); + sbinptr b = smallbin_at(m, sidx); if (smallmap_is_marked(m, sidx)) { - mchunkptr p = b; do { - - if (p == x) return 1; - + if (p == x) + return 1; } while ((p = p->fd) != b); - } - - } else { - + } + else { bindex_t tidx; compute_tree_index(size, tidx); if (treemap_is_marked(m, tidx)) { - tchunkptr t = *treebin_at(m, tidx); - size_t sizebits = size << leftshift_for_tree_index(tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); while (t != 0 && chunksize(t) != size) { - - t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; sizebits <<= 1; - } - if (t != 0) { - tchunkptr u = t; do { - - if (u == (tchunkptr)x) return 1; - + if (u == (tchunkptr)x) + return 1; } while ((u = u->fd) != t); - } - } - } - return 0; - } /* Traverse each chunk and check it; return total */ static size_t traverse_and_check(mstate m) { - size_t sum = 0; if (is_initialized(m)) { - msegmentptr s = &m->seg; sum += m->topsize + TOP_FOOT_SIZE; while (s != 0) { - mchunkptr q = align_as_chunk(s->base); mchunkptr lastq = 0; assert(pinuse(q)); - while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { - + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { sum += chunksize(q); if (is_inuse(q)) { - assert(!bin_find(m, q)); do_check_inuse_chunk(m, q); - - } else { - + } + else { assert(q == m->dv || bin_find(m, q)); - assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ + assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ do_check_free_chunk(m, q); - } - lastq = q; q = next_chunk(q); - } - s = s->next; - } - } - return sum; - } + /* Check all properties of malloc_state. */ static void do_check_malloc_state(mstate m) { - bindex_t i; - size_t total; + size_t total; /* check bins */ for (i = 0; i < NSMALLBINS; ++i) do_check_smallbin(m, i); for (i = 0; i < NTREEBINS; ++i) do_check_treebin(m, i); - if (m->dvsize != 0) { /* check dv chunk */ + if (m->dvsize != 0) { /* check dv chunk */ do_check_any_chunk(m, m->dv); assert(m->dvsize == chunksize(m->dv)); assert(m->dvsize >= MIN_CHUNK_SIZE); assert(bin_find(m, m->dv) == 0); - } - if (m->top != 0) { /* check top chunk */ + if (m->top != 0) { /* check top chunk */ do_check_top_chunk(m, m->top); /*assert(m->topsize == chunksize(m->top)); redundant */ assert(m->topsize > 0); assert(bin_find(m, m->top) == 0); - } total = traverse_and_check(m); assert(total <= m->footprint); assert(m->footprint <= m->max_footprint); - } - -#endif /* DEBUG */ +#endif /* DEBUG */ /* ----------------------------- statistics ------------------------------ */ #if !NO_MALLINFO static struct mallinfo internal_mallinfo(mstate m) { - - struct mallinfo nm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ensure_initialization(); if (!PREACTION(m)) { - check_malloc_state(m); if (is_initialized(m)) { - - size_t nfree = SIZE_T_ONE; /* top always free */ - size_t mfree = m->topsize + TOP_FOOT_SIZE; - size_t sum = mfree; + size_t nfree = SIZE_T_ONE; /* top always free */ + size_t mfree = m->topsize + TOP_FOOT_SIZE; + size_t sum = mfree; msegmentptr s = &m->seg; while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && q != m->top && - q->head != FENCEPOST_HEAD) { - + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { size_t sz = chunksize(q); sum += sz; if (!is_inuse(q)) { - mfree += sz; ++nfree; - } - q = next_chunk(q); - } - s = s->next; - } - nm.arena = sum; - nm.ordblks = nfree; - nm.hblkhd = m->footprint - sum; - nm.usmblks = m->max_footprint; + nm.arena = sum; + nm.ordblks = nfree; + nm.hblkhd = m->footprint - sum; + nm.usmblks = m->max_footprint; nm.uordblks = m->footprint - mfree; nm.fordblks = mfree; nm.keepcost = m->topsize; - } POSTACTION(m); - } - return nm; - } - -#endif /* !NO_MALLINFO */ +#endif /* !NO_MALLINFO */ #if !NO_MALLOC_STATS static void internal_malloc_stats(mstate m) { - ensure_initialization(); if (!PREACTION(m)) { - size_t maxfp = 0; size_t fp = 0; size_t used = 0; check_malloc_state(m); if (is_initialized(m)) { - msegmentptr s = &m->seg; maxfp = m->max_footprint; fp = m->footprint; used = fp - (m->topsize + TOP_FOOT_SIZE); while (s != 0) { - mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && q != m->top && - q->head != FENCEPOST_HEAD) { - - if (!is_inuse(q)) used -= chunksize(q); + while (segment_holds(s, q) && + q != m->top && q->head != FENCEPOST_HEAD) { + if (!is_inuse(q)) + used -= chunksize(q); q = next_chunk(q); - } - s = s->next; - } - } - - POSTACTION(m); /* drop lock */ + POSTACTION(m); /* drop lock */ fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); - } - } - -#endif /* NO_MALLOC_STATS */ +#endif /* NO_MALLOC_STATS */ /* ----------------------- Operations on smallbins ----------------------- */ @@ -3867,181 +3618,134 @@ static void internal_malloc_stats(mstate m) { */ /* Link a free chunk into a smallbin */ -#define insert_small_chunk(M, P, S) \ - { \ - \ - bindex_t I = small_index(S); \ - mchunkptr B = smallbin_at(M, I); \ - mchunkptr F = B; \ - assert(S >= MIN_CHUNK_SIZE); \ - if (!smallmap_is_marked(M, I)) \ - mark_smallmap(M, I); \ - else if (RTCHECK(ok_address(M, B->fd))) \ - F = B->fd; \ - else { \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - B->fd = P; \ - F->bk = P; \ - P->fd = F; \ - P->bk = B; \ - \ - } +#define insert_small_chunk(M, P, S) {\ + bindex_t I = small_index(S);\ + mchunkptr B = smallbin_at(M, I);\ + mchunkptr F = B;\ + assert(S >= MIN_CHUNK_SIZE);\ + if (!smallmap_is_marked(M, I))\ + mark_smallmap(M, I);\ + else if (RTCHECK(ok_address(M, B->fd)))\ + F = B->fd;\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + B->fd = P;\ + F->bk = P;\ + P->fd = F;\ + P->bk = B;\ +} /* Unlink a chunk from a smallbin */ -#define unlink_small_chunk(M, P, S) \ - { \ - \ - mchunkptr F = P->fd; \ - mchunkptr B = P->bk; \ - bindex_t I = small_index(S); \ - assert(P != B); \ - assert(P != F); \ - assert(chunksize(P) == small_index2size(I)); \ - if (RTCHECK(F == smallbin_at(M, I) || (ok_address(M, F) && F->bk == P))) { \ - \ - if (B == F) { \ - \ - clear_smallmap(M, I); \ - \ - } else if (RTCHECK(B == smallbin_at(M, I) || \ - \ - \ - (ok_address(M, B) && B->fd == P))) { \ - \ - F->bk = B; \ - B->fd = F; \ - \ - } else { \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - \ - } else { \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - \ - } +#define unlink_small_chunk(M, P, S) {\ + mchunkptr F = P->fd;\ + mchunkptr B = P->bk;\ + bindex_t I = small_index(S);\ + assert(P != B);\ + assert(P != F);\ + assert(chunksize(P) == small_index2size(I));\ + if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \ + if (B == F) {\ + clear_smallmap(M, I);\ + }\ + else if (RTCHECK(B == smallbin_at(M,I) ||\ + (ok_address(M, B) && B->fd == P))) {\ + F->bk = B;\ + B->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ +} /* Unlink the first chunk from a smallbin */ -#define unlink_first_small_chunk(M, B, P, I) \ - { \ - \ - mchunkptr F = P->fd; \ - assert(P != B); \ - assert(P != F); \ - assert(chunksize(P) == small_index2size(I)); \ - if (B == F) { \ - \ - clear_smallmap(M, I); \ - \ - } else if (RTCHECK(ok_address(M, F) && F->bk == P)) { \ - \ - F->bk = B; \ - B->fd = F; \ - \ - } else { \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - \ - } +#define unlink_first_small_chunk(M, B, P, I) {\ + mchunkptr F = P->fd;\ + assert(P != B);\ + assert(P != F);\ + assert(chunksize(P) == small_index2size(I));\ + if (B == F) {\ + clear_smallmap(M, I);\ + }\ + else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\ + F->bk = B;\ + B->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ +} /* Replace dv node, binning the old one */ /* Used only when dvsize known to be small */ -#define replace_dv(M, P, S) \ - { \ - \ - size_t DVS = M->dvsize; \ - assert(is_small(DVS)); \ - if (DVS != 0) { \ - \ - mchunkptr DV = M->dv; \ - insert_small_chunk(M, DV, DVS); \ - \ - } \ - M->dvsize = S; \ - M->dv = P; \ - \ - } +#define replace_dv(M, P, S) {\ + size_t DVS = M->dvsize;\ + assert(is_small(DVS));\ + if (DVS != 0) {\ + mchunkptr DV = M->dv;\ + insert_small_chunk(M, DV, DVS);\ + }\ + M->dvsize = S;\ + M->dv = P;\ +} /* ------------------------- Operations on trees ------------------------- */ /* Insert chunk into tree */ -#define insert_large_chunk(M, X, S) \ - { \ - \ - tbinptr *H; \ - bindex_t I; \ - compute_tree_index(S, I); \ - H = treebin_at(M, I); \ - X->index = I; \ - X->child[0] = X->child[1] = 0; \ - if (!treemap_is_marked(M, I)) { \ - \ - mark_treemap(M, I); \ - *H = X; \ - X->parent = (tchunkptr)H; \ - X->fd = X->bk = X; \ - \ - } else { \ - \ - tchunkptr T = *H; \ - size_t K = S << leftshift_for_tree_index(I); \ - for (;;) { \ - \ - if (chunksize(T) != S) { \ - \ - tchunkptr *C = \ - &(T->child[(K >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]); \ - K <<= 1; \ - if (*C != 0) \ - T = *C; \ - else if (RTCHECK(ok_address(M, C))) { \ - \ - *C = X; \ - X->parent = T; \ - X->fd = X->bk = X; \ - break; \ - \ - } else { \ - \ - CORRUPTION_ERROR_ACTION(M); \ - break; \ - \ - } \ - \ - } else { \ - \ - tchunkptr F = T->fd; \ - if (RTCHECK(ok_address(M, T) && ok_address(M, F))) { \ - \ - T->fd = F->bk = X; \ - X->fd = F; \ - X->bk = T; \ - X->parent = 0; \ - break; \ - \ - } else { \ - \ - CORRUPTION_ERROR_ACTION(M); \ - break; \ - \ - } \ - \ - } \ - \ - } \ - \ - } \ - \ - } +#define insert_large_chunk(M, X, S) {\ + tbinptr* H;\ + bindex_t I;\ + compute_tree_index(S, I);\ + H = treebin_at(M, I);\ + X->index = I;\ + X->child[0] = X->child[1] = 0;\ + if (!treemap_is_marked(M, I)) {\ + mark_treemap(M, I);\ + *H = X;\ + X->parent = (tchunkptr)H;\ + X->fd = X->bk = X;\ + }\ + else {\ + tchunkptr T = *H;\ + size_t K = S << leftshift_for_tree_index(I);\ + for (;;) {\ + if (chunksize(T) != S) {\ + tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ + K <<= 1;\ + if (*C != 0)\ + T = *C;\ + else if (RTCHECK(ok_address(M, C))) {\ + *C = X;\ + X->parent = T;\ + X->fd = X->bk = X;\ + break;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + break;\ + }\ + }\ + else {\ + tchunkptr F = T->fd;\ + if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ + T->fd = F->bk = X;\ + X->fd = F;\ + X->bk = T;\ + X->parent = 0;\ + break;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + break;\ + }\ + }\ + }\ + }\ +} /* Unlink steps: @@ -4060,149 +3764,104 @@ static void internal_malloc_stats(mstate m) { x's parent and children to x's replacement (or null if none). */ -#define unlink_large_chunk(M, X) \ - { \ - \ - tchunkptr XP = X->parent; \ - tchunkptr R; \ - if (X->bk != X) { \ - \ - tchunkptr F = X->fd; \ - R = X->bk; \ - if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) { \ - \ - F->bk = R; \ - R->fd = F; \ - \ - } else { \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - \ - } else { \ - \ - tchunkptr *RP; \ - if (((R = *(RP = &(X->child[1]))) != 0) || \ - ((R = *(RP = &(X->child[0]))) != 0)) { \ - \ - tchunkptr *CP; \ - while ((*(CP = &(R->child[1])) != 0) || \ - (*(CP = &(R->child[0])) != 0)) { \ - \ - R = *(RP = CP); \ - \ - } \ - if (RTCHECK(ok_address(M, RP))) \ - *RP = 0; \ - else { \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - \ - } \ - \ - } \ - if (XP != 0) { \ - \ - tbinptr *H = treebin_at(M, X->index); \ - if (X == *H) { \ - \ - if ((*H = R) == 0) clear_treemap(M, X->index); \ - \ - } else if (RTCHECK(ok_address(M, XP))) { \ - \ - if (XP->child[0] == X) \ - XP->child[0] = R; \ - else \ - XP->child[1] = R; \ - \ - } else \ - \ - \ - CORRUPTION_ERROR_ACTION(M); \ - if (R != 0) { \ - \ - if (RTCHECK(ok_address(M, R))) { \ - \ - tchunkptr C0, C1; \ - R->parent = XP; \ - if ((C0 = X->child[0]) != 0) { \ - \ - if (RTCHECK(ok_address(M, C0))) { \ - \ - R->child[0] = C0; \ - C0->parent = R; \ - \ - } else \ - \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - if ((C1 = X->child[1]) != 0) { \ - \ - if (RTCHECK(ok_address(M, C1))) { \ - \ - R->child[1] = C1; \ - C1->parent = R; \ - \ - } else \ - \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - \ - } else \ - \ - \ - CORRUPTION_ERROR_ACTION(M); \ - \ - } \ - \ - } \ - \ - } +#define unlink_large_chunk(M, X) {\ + tchunkptr XP = X->parent;\ + tchunkptr R;\ + if (X->bk != X) {\ + tchunkptr F = X->fd;\ + R = X->bk;\ + if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) {\ + F->bk = R;\ + R->fd = F;\ + }\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else {\ + tchunkptr* RP;\ + if (((R = *(RP = &(X->child[1]))) != 0) ||\ + ((R = *(RP = &(X->child[0]))) != 0)) {\ + tchunkptr* CP;\ + while ((*(CP = &(R->child[1])) != 0) ||\ + (*(CP = &(R->child[0])) != 0)) {\ + R = *(RP = CP);\ + }\ + if (RTCHECK(ok_address(M, RP)))\ + *RP = 0;\ + else {\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + }\ + if (XP != 0) {\ + tbinptr* H = treebin_at(M, X->index);\ + if (X == *H) {\ + if ((*H = R) == 0) \ + clear_treemap(M, X->index);\ + }\ + else if (RTCHECK(ok_address(M, XP))) {\ + if (XP->child[0] == X) \ + XP->child[0] = R;\ + else \ + XP->child[1] = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + if (R != 0) {\ + if (RTCHECK(ok_address(M, R))) {\ + tchunkptr C0, C1;\ + R->parent = XP;\ + if ((C0 = X->child[0]) != 0) {\ + if (RTCHECK(ok_address(M, C0))) {\ + R->child[0] = C0;\ + C0->parent = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + if ((C1 = X->child[1]) != 0) {\ + if (RTCHECK(ok_address(M, C1))) {\ + R->child[1] = C1;\ + C1->parent = R;\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ + else\ + CORRUPTION_ERROR_ACTION(M);\ + }\ + }\ +} /* Relays to large vs small bin operations */ -#define insert_chunk(M, P, S) \ - if (is_small(S)) insert_small_chunk(M, P, S) else { \ - \ - tchunkptr TP = (tchunkptr)(P); \ - insert_large_chunk(M, TP, S); \ - \ - } +#define insert_chunk(M, P, S)\ + if (is_small(S)) insert_small_chunk(M, P, S)\ + else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } + +#define unlink_chunk(M, P, S)\ + if (is_small(S)) unlink_small_chunk(M, P, S)\ + else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } -#define unlink_chunk(M, P, S) \ - if (is_small(S)) unlink_small_chunk(M, P, S) else { \ - \ - tchunkptr TP = (tchunkptr)(P); \ - unlink_large_chunk(M, TP); \ - \ - } /* Relays to internal calls to malloc/free from realloc, memalign etc */ #if ONLY_MSPACES - #define internal_malloc(m, b) mspace_malloc(m, b) - #define internal_free(m, mem) mspace_free(m, mem); -#else /* ONLY_MSPACES */ - #if MSPACES - #define internal_malloc(m, b) \ - ((m == gm) ? dlmalloc(b) : mspace_malloc(m, b)) - #define internal_free(m, mem) \ - if (m == gm) \ - dlfree(mem); \ - else \ - mspace_free(m, mem); - #else /* MSPACES */ - #define internal_malloc(m, b) dlmalloc(b) - #define internal_free(m, mem) dlfree(mem) - #endif /* MSPACES */ -#endif /* ONLY_MSPACES */ +#define internal_malloc(m, b) mspace_malloc(m, b) +#define internal_free(m, mem) mspace_free(m,mem); +#else /* ONLY_MSPACES */ +#if MSPACES +#define internal_malloc(m, b)\ + ((m == gm)? dlmalloc(b) : mspace_malloc(m, b)) +#define internal_free(m, mem)\ + if (m == gm) dlfree(mem); else mspace_free(m,mem); +#else /* MSPACES */ +#define internal_malloc(m, b) dlmalloc(b) +#define internal_free(m, mem) dlfree(mem) +#endif /* MSPACES */ +#endif /* ONLY_MSPACES */ /* ----------------------- Direct-mmapping chunks ----------------------- */ @@ -4215,93 +3874,80 @@ static void internal_malloc_stats(mstate m) { */ /* Malloc using mmap */ -static void *mmap_alloc(mstate m, size_t nb) { - +static void* mmap_alloc(mstate m, size_t nb) { size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); if (m->footprint_limit != 0) { - size_t fp = m->footprint + mmsize; - if (fp <= m->footprint || fp > m->footprint_limit) return 0; - + if (fp <= m->footprint || fp > m->footprint_limit) + return 0; } - - if (mmsize > nb) { /* Check for wrap around 0 */ - char *mm = (char *)(CALL_DIRECT_MMAP(mmsize)); + if (mmsize > nb) { /* Check for wrap around 0 */ + char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); if (mm != CMFAIL) { - - size_t offset = align_offset(chunk2mem(mm)); - size_t psize = mmsize - offset - MMAP_FOOT_PAD; + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - MMAP_FOOT_PAD; mchunkptr p = (mchunkptr)(mm + offset); p->prev_foot = offset; p->head = psize; mark_inuse_foot(m, p, psize); chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(p, psize + SIZE_T_SIZE)->head = 0; + chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; - if (m->least_addr == 0 || mm < m->least_addr) m->least_addr = mm; + if (m->least_addr == 0 || mm < m->least_addr) + m->least_addr = mm; if ((m->footprint += mmsize) > m->max_footprint) m->max_footprint = m->footprint; assert(is_aligned(chunk2mem(p))); check_mmapped_chunk(m, p); return chunk2mem(p); - } - } - return 0; - } /* Realloc using mmap */ static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) { - size_t oldsize = chunksize(oldp); - (void)flags; /* placate people compiling -Wunused */ - if (is_small(nb)) /* Can't shrink mmap regions below small size */ + (void)flags; /* placate people compiling -Wunused */ + if (is_small(nb)) /* Can't shrink mmap regions below small size */ return 0; /* Keep old chunk if big enough but not too big */ if (oldsize >= nb + SIZE_T_SIZE && (oldsize - nb) <= (mparams.granularity << 1)) return oldp; else { - size_t offset = oldp->prev_foot; size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - char * cp = - (char *)CALL_MREMAP((char *)oldp - offset, oldmmsize, newmmsize, flags); + char* cp = (char*)CALL_MREMAP((char*)oldp - offset, + oldmmsize, newmmsize, flags); if (cp != CMFAIL) { - mchunkptr newp = (mchunkptr)(cp + offset); - size_t psize = newmmsize - offset - MMAP_FOOT_PAD; + size_t psize = newmmsize - offset - MMAP_FOOT_PAD; newp->head = psize; mark_inuse_foot(m, newp, psize); chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(newp, psize + SIZE_T_SIZE)->head = 0; + chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; - if (cp < m->least_addr) m->least_addr = cp; + if (cp < m->least_addr) + m->least_addr = cp; if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) m->max_footprint = m->footprint; check_mmapped_chunk(m, newp); return newp; - } - } - return 0; - } + /* -------------------------- mspace management -------------------------- */ /* Initialize top chunk and its size */ static void init_top(mstate m, mchunkptr p, size_t psize) { - /* Ensure alignment */ size_t offset = align_offset(chunk2mem(p)); - p = (mchunkptr)((char *)p + offset); + p = (mchunkptr)((char*)p + offset); psize -= offset; m->top = p; @@ -4309,29 +3955,23 @@ static void init_top(mstate m, mchunkptr p, size_t psize) { p->head = psize | PINUSE_BIT; /* set size of fake trailing chunk holding overhead space only once */ chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; - m->trim_check = mparams.trim_threshold; /* reset on each update */ - + m->trim_check = mparams.trim_threshold; /* reset on each update */ } /* Initialize bins for a new mstate that is otherwise zeroed out */ static void init_bins(mstate m) { - /* Establish circular links for smallbins */ bindex_t i; for (i = 0; i < NSMALLBINS; ++i) { - - sbinptr bin = smallbin_at(m, i); + sbinptr bin = smallbin_at(m,i); bin->fd = bin->bk = bin; - } - } #if PROCEED_ON_ERROR /* default corruption action */ static void reset_on_error(mstate m) { - int i; ++malloc_corruption_error_count; /* Reinitialize fields to forget about all memory */ @@ -4344,78 +3984,67 @@ static void reset_on_error(mstate m) { for (i = 0; i < NTREEBINS; ++i) *treebin_at(m, i) = 0; init_bins(m); - } - -#endif /* PROCEED_ON_ERROR */ +#endif /* PROCEED_ON_ERROR */ /* Allocate chunk and prepend remainder with chunk in successor base. */ -static void *prepend_alloc(mstate m, char *newbase, char *oldbase, size_t nb) { - +static void* prepend_alloc(mstate m, char* newbase, char* oldbase, + size_t nb) { mchunkptr p = align_as_chunk(newbase); mchunkptr oldfirst = align_as_chunk(oldbase); - size_t psize = (char *)oldfirst - (char *)p; + size_t psize = (char*)oldfirst - (char*)p; mchunkptr q = chunk_plus_offset(p, nb); - size_t qsize = psize - nb; + size_t qsize = psize - nb; set_size_and_pinuse_of_inuse_chunk(m, p, nb); - assert((char *)oldfirst > (char *)q); + assert((char*)oldfirst > (char*)q); assert(pinuse(oldfirst)); assert(qsize >= MIN_CHUNK_SIZE); /* consolidate remainder with first chunk of old base */ if (oldfirst == m->top) { - size_t tsize = m->topsize += qsize; m->top = q; q->head = tsize | PINUSE_BIT; check_top_chunk(m, q); - - } else if (oldfirst == m->dv) { - + } + else if (oldfirst == m->dv) { size_t dsize = m->dvsize += qsize; m->dv = q; set_size_and_pinuse_of_free_chunk(q, dsize); - - } else { - + } + else { if (!is_inuse(oldfirst)) { - size_t nsize = chunksize(oldfirst); unlink_chunk(m, oldfirst, nsize); oldfirst = chunk_plus_offset(oldfirst, nsize); qsize += nsize; - } - set_free_with_pinuse(q, qsize, oldfirst); insert_chunk(m, q, qsize); check_free_chunk(m, q); - } check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); - } /* Add a segment to hold a new noncontiguous region */ -static void add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped) { - +static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { /* Determine locations and sizes of segment, fenceposts, old top */ - char * old_top = (char *)m->top; + char* old_top = (char*)m->top; msegmentptr oldsp = segment_holding(m, old_top); - char * old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request(sizeof(struct malloc_segment)); - char * rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset(chunk2mem(rawsp)); - char * asp = rawsp + offset; - char * csp = (asp < (old_top + MIN_CHUNK_SIZE)) ? old_top : asp; - mchunkptr sp = (mchunkptr)csp; + char* old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char* asp = rawsp + offset; + char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; + mchunkptr sp = (mchunkptr)csp; msegmentptr ss = (msegmentptr)(chunk2mem(sp)); - mchunkptr tnext = chunk_plus_offset(sp, ssize); - mchunkptr p = tnext; - int nfences = 0; + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + int nfences = 0; /* reset top to new space */ init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); @@ -4423,7 +4052,7 @@ static void add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped) { /* Set up segment record */ assert(is_aligned(ss)); set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); - *ss = m->seg; /* Push current record */ + *ss = m->seg; /* Push current record */ m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmapped; @@ -4431,61 +4060,53 @@ static void add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped) { /* Insert trailing fenceposts */ for (;;) { - mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); p->head = FENCEPOST_HEAD; ++nfences; - if ((char *)(&(nextp->head)) < old_end) + if ((char*)(&(nextp->head)) < old_end) p = nextp; else break; - } - assert(nfences >= 2); /* Insert the rest of old top into a bin as an ordinary free chunk */ if (csp != old_top) { - mchunkptr q = (mchunkptr)old_top; - size_t psize = csp - old_top; + size_t psize = csp - old_top; mchunkptr tn = chunk_plus_offset(q, psize); set_free_with_pinuse(q, psize, tn); insert_chunk(m, q, psize); - } check_top_chunk(m, m->top); - } /* -------------------------- System allocation -------------------------- */ /* Get memory from system using MORECORE or MMAP */ -static void *sys_alloc(mstate m, size_t nb) { - - char * tbase = CMFAIL; +static void* sys_alloc(mstate m, size_t nb) { + char* tbase = CMFAIL; size_t tsize = 0; flag_t mmap_flag = 0; - size_t asize; /* allocation size */ + size_t asize; /* allocation size */ ensure_initialization(); /* Directly map large chunks, but only if already initialized */ if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { - - void *mem = mmap_alloc(m, nb); - if (mem != 0) return mem; - + void* mem = mmap_alloc(m, nb); + if (mem != 0) + return mem; } asize = granularity_align(nb + SYS_ALLOC_PADDING); - if (asize <= nb) return 0; /* wraparound */ + if (asize <= nb) + return 0; /* wraparound */ if (m->footprint_limit != 0) { - size_t fp = m->footprint + asize; - if (fp <= m->footprint || fp > m->footprint_limit) return 0; - + if (fp <= m->footprint || fp > m->footprint_limit) + return 0; } /* @@ -4511,119 +4132,91 @@ static void *sys_alloc(mstate m, size_t nb) { */ if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { - - char * br = CMFAIL; - size_t ssize = asize; /* sbrk call size */ - msegmentptr ss = (m->top == 0) ? 0 : segment_holding(m, (char *)m->top); + char* br = CMFAIL; + size_t ssize = asize; /* sbrk call size */ + msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); ACQUIRE_MALLOC_GLOBAL_LOCK(); - if (ss == 0) { /* First time through or recovery */ - char *base = (char *)CALL_MORECORE(0); + if (ss == 0) { /* First time through or recovery */ + char* base = (char*)CALL_MORECORE(0); if (base != CMFAIL) { - size_t fp; /* Adjust to end on a page boundary */ if (!is_page_aligned(base)) ssize += (page_align((size_t)base) - (size_t)base); - fp = m->footprint + ssize; /* recheck limits */ + fp = m->footprint + ssize; /* recheck limits */ if (ssize > nb && ssize < HALF_MAX_SIZE_T && (m->footprint_limit == 0 || (fp > m->footprint && fp <= m->footprint_limit)) && - (br = (char *)(CALL_MORECORE(ssize))) == base) { - + (br = (char*)(CALL_MORECORE(ssize))) == base) { tbase = base; tsize = ssize; - } - } - - } else { - + } + else { /* Subtract out existing available top space from MORECORE request. */ ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); /* Use mem here only if it did continuously extend old space */ if (ssize < HALF_MAX_SIZE_T && - (br = (char *)(CALL_MORECORE(ssize))) == ss->base + ss->size) { - + (br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) { tbase = br; tsize = ssize; - } - } - if (tbase == CMFAIL) { /* Cope with partial failure */ - if (br != CMFAIL) { /* Try to use/extend the space we did get */ - if (ssize < HALF_MAX_SIZE_T && ssize < nb + SYS_ALLOC_PADDING) { - + if (tbase == CMFAIL) { /* Cope with partial failure */ + if (br != CMFAIL) { /* Try to use/extend the space we did get */ + if (ssize < HALF_MAX_SIZE_T && + ssize < nb + SYS_ALLOC_PADDING) { size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize); if (esize < HALF_MAX_SIZE_T) { - - char *end = (char *)CALL_MORECORE(esize); + char* end = (char*)CALL_MORECORE(esize); if (end != CMFAIL) ssize += esize; - else { /* Can't use; try to release */ - (void)CALL_MORECORE(-ssize); + else { /* Can't use; try to release */ + (void) CALL_MORECORE(-ssize); br = CMFAIL; - } - } - } - } - - if (br != CMFAIL) { /* Use the space we did get */ + if (br != CMFAIL) { /* Use the space we did get */ tbase = br; tsize = ssize; - - } else - - disable_contiguous(m); /* Don't try contiguous path in the future */ - + } + else + disable_contiguous(m); /* Don't try contiguous path in the future */ } RELEASE_MALLOC_GLOBAL_LOCK(); - } - if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ - char *mp = (char *)(CALL_MMAP(asize)); + if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ + char* mp = (char*)(CALL_MMAP(asize)); if (mp != CMFAIL) { - tbase = mp; tsize = asize; mmap_flag = USE_MMAP_BIT; - } - } - if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ + if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ if (asize < HALF_MAX_SIZE_T) { - - char *br = CMFAIL; - char *end = CMFAIL; + char* br = CMFAIL; + char* end = CMFAIL; ACQUIRE_MALLOC_GLOBAL_LOCK(); - br = (char *)(CALL_MORECORE(asize)); - end = (char *)(CALL_MORECORE(0)); + br = (char*)(CALL_MORECORE(asize)); + end = (char*)(CALL_MORECORE(0)); RELEASE_MALLOC_GLOBAL_LOCK(); if (br != CMFAIL && end != CMFAIL && br < end) { - size_t ssize = end - br; if (ssize > nb + TOP_FOOT_SIZE) { - tbase = br; tsize = ssize; - } - } - } - } if (tbase != CMFAIL) { @@ -4631,8 +4224,9 @@ static void *sys_alloc(mstate m, size_t nb) { if ((m->footprint += tsize) > m->max_footprint) m->max_footprint = m->footprint; - if (!is_initialized(m)) { /* first-time initialization */ - if (m->least_addr == 0 || tbase < m->least_addr) m->least_addr = tbase; + if (!is_initialized(m)) { /* first-time initialization */ + if (m->least_addr == 0 || tbase < m->least_addr) + m->least_addr = tbase; m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmap_flag; @@ -4645,52 +4239,46 @@ static void *sys_alloc(mstate m, size_t nb) { else #endif { - /* Offset top by embedded malloc_state */ mchunkptr mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); - + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); } - } else { - /* Try to merge with an existing segment */ msegmentptr sp = &m->seg; /* Only consider most recent segment if traversal suppressed */ while (sp != 0 && tbase != sp->base + sp->size) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; - if (sp != 0 && !is_extern_segment(sp) && + if (sp != 0 && + !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag && - segment_holds(sp, m->top)) { /* append */ + segment_holds(sp, m->top)) { /* append */ sp->size += tsize; init_top(m, m->top, m->topsize + tsize); - - } else { - - if (tbase < m->least_addr) m->least_addr = tbase; + } + else { + if (tbase < m->least_addr) + m->least_addr = tbase; sp = &m->seg; while (sp != 0 && sp->base != tbase + tsize) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; - if (sp != 0 && !is_extern_segment(sp) && + if (sp != 0 && + !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag) { - - char *oldbase = sp->base; + char* oldbase = sp->base; sp->base = tbase; sp->size += tsize; return prepend_alloc(m, tbase, oldbase, nb); - - } else - + } + else add_segment(m, tbase, tsize, mmap_flag); - } - } - if (nb < m->topsize) { /* Allocate from new or extended top space */ - size_t rsize = m->topsize -= nb; + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; mchunkptr p = m->top; mchunkptr r = m->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -4698,421 +4286,313 @@ static void *sys_alloc(mstate m, size_t nb) { check_top_chunk(m, m->top); check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); - } - } MALLOC_FAILURE_ACTION; return 0; - } /* ----------------------- system deallocation -------------------------- */ /* Unmap and unlink any mmapped segments that don't contain used chunks */ static size_t release_unused_segments(mstate m) { - - size_t released = 0; - int nsegs = 0; + size_t released = 0; + int nsegs = 0; msegmentptr pred = &m->seg; msegmentptr sp = pred->next; while (sp != 0) { - - char * base = sp->base; - size_t size = sp->size; + char* base = sp->base; + size_t size = sp->size; msegmentptr next = sp->next; ++nsegs; if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { - mchunkptr p = align_as_chunk(base); - size_t psize = chunksize(p); + size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ - if (!is_inuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { - + if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { tchunkptr tp = (tchunkptr)p; - assert(segment_holds(sp, (char *)sp)); + assert(segment_holds(sp, (char*)sp)); if (p == m->dv) { - m->dv = 0; m->dvsize = 0; - - } else { - + } + else { unlink_large_chunk(m, tp); - } - if (CALL_MUNMAP(base, size) == 0) { - released += size; m->footprint -= size; /* unlink obsoleted record */ sp = pred; sp->next = next; - - } else { /* back out if cannot unmap */ - + } + else { /* back out if cannot unmap */ insert_large_chunk(m, tp, psize); - } - } - } - - if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ + if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ break; pred = sp; sp = next; - } - /* Reset check counter */ - m->release_checks = (((size_t)nsegs > (size_t)MAX_RELEASE_CHECK_RATE) - ? (size_t)nsegs - : (size_t)MAX_RELEASE_CHECK_RATE); + m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)? + (size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE); return released; - } static int sys_trim(mstate m, size_t pad) { - size_t released = 0; ensure_initialization(); if (pad < MAX_REQUEST && is_initialized(m)) { - - pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ if (m->topsize > pad) { - /* Shrink top space in granularity-size units, keeping at least one */ size_t unit = mparams.granularity; - size_t extra = - ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding(m, (char *)m->top); + size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - + SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char*)m->top); if (!is_extern_segment(sp)) { - if (is_mmapped_segment(sp)) { - - if (HAVE_MMAP && sp->size >= extra && - !has_segment_link(m, sp)) { /* can't shrink if pinned */ + if (HAVE_MMAP && + sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ size_t newsize = sp->size - extra; - (void)newsize; /* placate people compiling -Wunused-variable */ + (void)newsize; /* placate people compiling -Wunused-variable */ /* Prefer mremap, fall back to munmap */ if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { - released = extra; - } - } - - } else if (HAVE_MORECORE) { - - if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ + } + else if (HAVE_MORECORE) { + if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; ACQUIRE_MALLOC_GLOBAL_LOCK(); { - /* Make sure end of memory is where we last set it. */ - char *old_br = (char *)(CALL_MORECORE(0)); + char* old_br = (char*)(CALL_MORECORE(0)); if (old_br == sp->base + sp->size) { - - char *rel_br = (char *)(CALL_MORECORE(-extra)); - char *new_br = (char *)(CALL_MORECORE(0)); + char* rel_br = (char*)(CALL_MORECORE(-extra)); + char* new_br = (char*)(CALL_MORECORE(0)); if (rel_br != CMFAIL && new_br < old_br) released = old_br - new_br; - } - } - RELEASE_MALLOC_GLOBAL_LOCK(); - } - } if (released != 0) { - sp->size -= released; m->footprint -= released; init_top(m, m->top, m->topsize - released); check_top_chunk(m, m->top); - } - } /* Unmap any unused mmapped segments */ - if (HAVE_MMAP) released += release_unused_segments(m); + if (HAVE_MMAP) + released += release_unused_segments(m); /* On failure, disable autotrim to avoid repeated failed future calls */ - if (released == 0 && m->topsize > m->trim_check) m->trim_check = MAX_SIZE_T; - + if (released == 0 && m->topsize > m->trim_check) + m->trim_check = MAX_SIZE_T; } - return (released != 0) ? 1 : 0; - + return (released != 0)? 1 : 0; } /* Consolidate and bin a chunk. Differs from exported versions of free mainly in that the chunk need not be marked as inuse. */ static void dispose_chunk(mstate m, mchunkptr p, size_t psize) { - mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { - mchunkptr prev; - size_t prevsize = p->prev_foot; + size_t prevsize = p->prev_foot; if (is_mmapped(p)) { - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) m->footprint -= psize; + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + m->footprint -= psize; return; - } - prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ if (p != m->dv) { - unlink_chunk(m, p, prevsize); - - } else if ((next->head & INUSE_BITS) == INUSE_BITS) { - + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { m->dvsize = psize; set_free_with_pinuse(p, psize, next); return; - } - - } else { - + } + else { CORRUPTION_ERROR_ACTION(m); return; - } - } - if (RTCHECK(ok_address(m, next))) { - - if (!cinuse(next)) { /* consolidate forward */ + if (!cinuse(next)) { /* consolidate forward */ if (next == m->top) { - size_t tsize = m->topsize += psize; m->top = p; p->head = tsize | PINUSE_BIT; if (p == m->dv) { - m->dv = 0; m->dvsize = 0; - } - return; - - } else if (next == m->dv) { - + } + else if (next == m->dv) { size_t dsize = m->dvsize += psize; m->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); return; - - } else { - + } + else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(m, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == m->dv) { - m->dvsize = psize; return; - } - } - - } else { - + } + else { set_free_with_pinuse(p, psize, next); - } - insert_chunk(m, p, psize); - - } else { - + } + else { CORRUPTION_ERROR_ACTION(m); - } - } /* ---------------------------- malloc --------------------------- */ /* allocate a large request from the best fitting chunk in a treebin */ -static void *tmalloc_large(mstate m, size_t nb) { - +static void* tmalloc_large(mstate m, size_t nb) { tchunkptr v = 0; - size_t rsize = -nb; /* Unsigned negation */ + size_t rsize = -nb; /* Unsigned negation */ tchunkptr t; - bindex_t idx; + bindex_t idx; compute_tree_index(nb, idx); if ((t = *treebin_at(m, idx)) != 0) { - /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index(idx); - tchunkptr rst = 0; /* The deepest untaken right subtree */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ for (;;) { - tchunkptr rt; - size_t trem = chunksize(t) - nb; + size_t trem = chunksize(t) - nb; if (trem < rsize) { - v = t; - if ((rsize = trem) == 0) break; - + if ((rsize = trem) == 0) + break; } - rt = t->child[1]; - t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; - if (rt != 0 && rt != t) rst = rt; + t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) + rst = rt; if (t == 0) { - - t = rst; /* set t to least subtree holding sizes > nb */ + t = rst; /* set t to least subtree holding sizes > nb */ break; - } - sizebits <<= 1; - } - } - - if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; if (leftbits != 0) { - bindex_t i; binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); t = *treebin_at(m, i); - } - } - while (t != 0) { /* find smallest of tree or subtree */ + while (t != 0) { /* find smallest of tree or subtree */ size_t trem = chunksize(t) - nb; if (trem < rsize) { - rsize = trem; v = t; - } - t = leftmost_child(t); - } /* If dv is a better fit, return 0 so malloc will use it */ if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { - - if (RTCHECK(ok_address(m, v))) { /* split */ + if (RTCHECK(ok_address(m, v))) { /* split */ mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); insert_chunk(m, r, rsize); - } - return chunk2mem(v); - } - } - CORRUPTION_ERROR_ACTION(m); - } - return 0; - } /* allocate a small request from the best fitting chunk in a treebin */ -static void *tmalloc_small(mstate m, size_t nb) { - +static void* tmalloc_small(mstate m, size_t nb) { tchunkptr t, v; - size_t rsize; - bindex_t i; - binmap_t leastbit = least_bit(m->treemap); + size_t rsize; + bindex_t i; + binmap_t leastbit = least_bit(m->treemap); compute_bit2idx(leastbit, i); v = t = *treebin_at(m, i); rsize = chunksize(t) - nb; while ((t = leftmost_child(t)) != 0) { - size_t trem = chunksize(t) - nb; if (trem < rsize) { - rsize = trem; v = t; - } - } if (RTCHECK(ok_address(m, v))) { - mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { - unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { - set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(m, r, rsize); - } - return chunk2mem(v); - } - } CORRUPTION_ERROR_ACTION(m); return 0; - } #if !ONLY_MSPACES -void *dlmalloc(size_t bytes) { - +void* dlmalloc(size_t bytes) { /* Basic algorithm: If a small request (< 256 bytes minus per-chunk overhead): @@ -5136,25 +4616,23 @@ void *dlmalloc(size_t bytes) { The ugly goto's here ensure that postaction occurs along all paths. */ - #if USE_LOCKS - ensure_initialization(); /* initialize in sys_alloc if not using locks */ - #endif +#if USE_LOCKS + ensure_initialization(); /* initialize in sys_alloc if not using locks */ +#endif if (!PREACTION(gm)) { - - void * mem; + void* mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; binmap_t smallbits; - nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = gm->smallmap >> idx; - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ + idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(gm, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); @@ -5163,17 +4641,15 @@ void *dlmalloc(size_t bytes) { mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; - } else if (nb > gm->dvsize) { - - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(gm, i); p = b->fd; @@ -5184,71 +4660,54 @@ void *dlmalloc(size_t bytes) { if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(gm, p, small_index2size(i)); else { - set_size_and_pinuse_of_inuse_chunk(gm, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(gm, r, rsize); - } - mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; - } else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); goto postaction; - } - } - - } else if (bytes >= MAX_REQUEST) - + } + else if (bytes >= MAX_REQUEST) nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { - nb = pad_request(bytes); if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { - check_malloced_chunk(gm, mem, nb); goto postaction; - } - } if (nb <= gm->dvsize) { - - size_t rsize = gm->dvsize - nb; + size_t rsize = gm->dvsize - nb; mchunkptr p = gm->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = gm->dv = chunk_plus_offset(p, nb); gm->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - - } else { /* exhaust dv */ - + } + else { /* exhaust dv */ size_t dvs = gm->dvsize; gm->dvsize = 0; gm->dv = 0; set_inuse_and_pinuse(gm, p, dvs); - } - mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; - } - else if (nb < gm->topsize) { /* Split top */ - size_t rsize = gm->topsize -= nb; + else if (nb < gm->topsize) { /* Split top */ + size_t rsize = gm->topsize -= nb; mchunkptr p = gm->top; mchunkptr r = gm->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -5257,7 +4716,6 @@ void *dlmalloc(size_t bytes) { check_top_chunk(gm, gm->top); check_malloced_chunk(gm, mem, nb); goto postaction; - } mem = sys_alloc(gm, nb); @@ -5265,17 +4723,14 @@ void *dlmalloc(size_t bytes) { postaction: POSTACTION(gm); return mem; - } return 0; - } /* ---------------------------- free --------------------------- */ -void dlfree(void *mem) { - +void dlfree(void* mem) { /* Consolidate freed chunks with preceeding or succeeding bordering free chunks, if they exist, and then place in a bin. Intermixed @@ -5283,216 +4738,164 @@ void dlfree(void *mem) { */ if (mem != 0) { - - mchunkptr p = mem2chunk(mem); - #if FOOTERS + mchunkptr p = mem2chunk(mem); +#if FOOTERS mstate fm = get_mstate_for(p); if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); return; - } - - #else /* FOOTERS */ - #define fm gm - #endif /* FOOTERS */ +#else /* FOOTERS */ +#define fm gm +#endif /* FOOTERS */ if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { - - size_t psize = chunksize(p); + size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { - size_t prevsize = p->prev_foot; if (is_mmapped(p)) { - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; - - } else { - + } + else { mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - - } else if ((next->head & INUSE_BITS) == INUSE_BITS) { - + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; - } - - } else - + } + else goto erroraction; - } - } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - - if (!cinuse(next)) { /* consolidate forward */ + if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { - size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { - fm->dv = 0; fm->dvsize = 0; - } - - if (should_trim(fm, tsize)) sys_trim(fm, 0); + if (should_trim(fm, tsize)) + sys_trim(fm, 0); goto postaction; - - } else if (next == fm->dv) { - + } + else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; - - } else { - + } + else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { - fm->dvsize = psize; goto postaction; - } - } - - } else - + } + else set_free_with_pinuse(p, psize, next); if (is_small(psize)) { - insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); - - } else { - + } + else { tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); - if (--fm->release_checks == 0) release_unused_segments(fm); - + if (--fm->release_checks == 0) + release_unused_segments(fm); } - goto postaction; - } - } - erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); - } - } - - #if !FOOTERS - #undef fm - #endif /* FOOTERS */ - +#if !FOOTERS +#undef fm +#endif /* FOOTERS */ } -void *dlcalloc(size_t n_elements, size_t elem_size) { - - void * mem; +void* dlcalloc(size_t n_elements, size_t elem_size) { + void* mem; size_t req = 0; if (n_elements != 0) { - req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - + req = MAX_SIZE_T; /* force downstream failure on overflow */ } - mem = dlmalloc(req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) __builtin_memset(mem, 0, req); return mem; - } -#endif /* !ONLY_MSPACES */ +#endif /* !ONLY_MSPACES */ /* ------------ Internal support for realloc, memalign, etc -------------- */ /* Try to realloc; only in-place unless can_move true */ static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, int can_move) { - mchunkptr newp = 0; - size_t oldsize = chunksize(p); + size_t oldsize = chunksize(p); mchunkptr next = chunk_plus_offset(p, oldsize); - if (RTCHECK(ok_address(m, p) && ok_inuse(p) && ok_next(p, next) && - ok_pinuse(next))) { - + if (RTCHECK(ok_address(m, p) && ok_inuse(p) && + ok_next(p, next) && ok_pinuse(next))) { if (is_mmapped(p)) { - newp = mmap_resize(m, p, nb, can_move); - - } else if (oldsize >= nb) { /* already big enough */ - + } + else if (oldsize >= nb) { /* already big enough */ size_t rsize = oldsize - nb; - if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ + if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); - } - newp = p; - - } else if (next == m->top) { /* extend into top */ - + } + else if (next == m->top) { /* extend into top */ if (oldsize + m->topsize > nb) { - - size_t newsize = oldsize + m->topsize; - size_t newtopsize = newsize - nb; + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; mchunkptr newtop = chunk_plus_offset(p, nb); set_inuse(m, p, nb); - newtop->head = newtopsize | PINUSE_BIT; + newtop->head = newtopsize |PINUSE_BIT; m->top = newtop; m->topsize = newtopsize; newp = p; - } - - } else if (next == m->dv) { /* extend into dv */ - + } + else if (next == m->dv) { /* extend into dv */ size_t dvs = m->dvsize; if (oldsize + dvs >= nb) { - size_t dsize = oldsize + dvs - nb; if (dsize >= MIN_CHUNK_SIZE) { - mchunkptr r = chunk_plus_offset(p, nb); mchunkptr n = chunk_plus_offset(r, dsize); set_inuse(m, p, nb); @@ -5500,87 +4903,64 @@ static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, clear_pinuse(n); m->dvsize = dsize; m->dv = r; - - } else { /* exhaust dv */ - + } + else { /* exhaust dv */ size_t newsize = oldsize + dvs; set_inuse(m, p, newsize); m->dvsize = 0; m->dv = 0; - } - newp = p; - } - - } else if (!cinuse(next)) { /* extend into next free chunk */ - + } + else if (!cinuse(next)) { /* extend into next free chunk */ size_t nextsize = chunksize(next); if (oldsize + nextsize >= nb) { - size_t rsize = oldsize + nextsize - nb; unlink_chunk(m, next, nextsize); if (rsize < MIN_CHUNK_SIZE) { - size_t newsize = oldsize + nextsize; set_inuse(m, p, newsize); - - } else { - + } + else { mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); - } - newp = p; - } - } - - } else { - + } + else { USAGE_ERROR_ACTION(m, chunk2mem(p)); - } - return newp; - } -static void *internal_memalign(mstate m, size_t alignment, size_t bytes) { - - void *mem = 0; - if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ +static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { + void* mem = 0; + if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ alignment = MIN_CHUNK_SIZE; - if ((alignment & (alignment - SIZE_T_ONE)) != 0) { /* Ensure a power of 2 */ + if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ size_t a = MALLOC_ALIGNMENT << 1; - while (a < alignment) - a <<= 1; + while (a < alignment) a <<= 1; alignment = a; - } - if (bytes >= MAX_REQUEST - alignment) { - - if (m != 0) { /* Test isn't needed but avoids compiler warning */ + if (m != 0) { /* Test isn't needed but avoids compiler warning */ MALLOC_FAILURE_ACTION; - } - - } else { - + } + else { size_t nb = request2size(bytes); size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; mem = internal_malloc(m, req); if (mem != 0) { - mchunkptr p = mem2chunk(mem); - if (PREACTION(m)) return 0; - if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ + if (PREACTION(m)) + return 0; + if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ /* Find an aligned spot inside chunk. Since we need to give back leading space in a chunk of at least MIN_CHUNK_SIZE, if @@ -5589,59 +4969,47 @@ static void *internal_memalign(mstate m, size_t alignment, size_t bytes) { We've allocated enough total room so that this is always possible. */ - char * br = (char *)mem2chunk((size_t)( - ((size_t)((char *)mem + alignment - SIZE_T_ONE)) & -alignment)); - char * pos = ((size_t)(br - (char *)(p)) >= MIN_CHUNK_SIZE) - ? br - : br + alignment; + char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment - + SIZE_T_ONE)) & + -alignment)); + char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? + br : br+alignment; mchunkptr newp = (mchunkptr)pos; - size_t leadsize = pos - (char *)(p); - size_t newsize = chunksize(p) - leadsize; + size_t leadsize = pos - (char*)(p); + size_t newsize = chunksize(p) - leadsize; - if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ newp->prev_foot = p->prev_foot + leadsize; newp->head = newsize; - - } else { /* Otherwise, give back leader, use the rest */ - + } + else { /* Otherwise, give back leader, use the rest */ set_inuse(m, newp, newsize); set_inuse(m, p, leadsize); dispose_chunk(m, p, leadsize); - } - p = newp; - } /* Give back spare room at the end */ if (!is_mmapped(p)) { - size_t size = chunksize(p); if (size > nb + MIN_CHUNK_SIZE) { - - size_t remainder_size = size - nb; + size_t remainder_size = size - nb; mchunkptr remainder = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, remainder, remainder_size); dispose_chunk(m, remainder, remainder_size); - } - } mem = chunk2mem(p); - assert(chunksize(p) >= nb); + assert (chunksize(p) >= nb); assert(((size_t)mem & (alignment - 1)) == 0); check_inuse_chunk(m, p); POSTACTION(m); - } - } - return mem; - } /* @@ -5651,50 +5019,50 @@ static void *internal_memalign(mstate m, size_t alignment, size_t bytes) { bit 0 set if all elements are same size (using sizes[0]) bit 1 set if elements should be zeroed */ -static void **ialloc(mstate m, size_t n_elements, size_t *sizes, int opts, - void *chunks[]) { - - size_t element_size; /* chunksize of each element, if all same */ - size_t contents_size; /* total size of elements */ - size_t array_size; /* request size of pointer array */ - void * mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - size_t remainder_size; /* remaining bytes while splitting */ - void ** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - flag_t was_enabled; /* to disable mmap */ +static void** ialloc(mstate m, + size_t n_elements, + size_t* sizes, + int opts, + void* chunks[]) { + + size_t element_size; /* chunksize of each element, if all same */ + size_t contents_size; /* total size of elements */ + size_t array_size; /* request size of pointer array */ + void* mem; /* malloced aggregate space */ + mchunkptr p; /* corresponding chunk */ + size_t remainder_size; /* remaining bytes while splitting */ + void** marray; /* either "chunks" or malloced ptr array */ + mchunkptr array_chunk; /* chunk for malloced ptr array */ + flag_t was_enabled; /* to disable mmap */ size_t size; size_t i; ensure_initialization(); /* compute array length, if needed */ if (chunks != 0) { - - if (n_elements == 0) return chunks; /* nothing to do */ + if (n_elements == 0) + return chunks; /* nothing to do */ marray = chunks; array_size = 0; - - } else { - + } + else { /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) return (void **)internal_malloc(m, 0); + if (n_elements == 0) + return (void**)internal_malloc(m, 0); marray = 0; - array_size = request2size(n_elements * (sizeof(void *))); - + array_size = request2size(n_elements * (sizeof(void*))); } /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ + if (opts & 0x1) { /* all-same-size */ element_size = request2size(*sizes); contents_size = n_elements * element_size; - - } else { /* add up all the sizes */ - + } + else { /* add up all the sizes */ element_size = 0; contents_size = 0; for (i = 0; i != n_elements; ++i) contents_size += request2size(sizes[i]); - } size = contents_size + array_size; @@ -5707,8 +5075,10 @@ static void **ialloc(mstate m, size_t n_elements, size_t *sizes, int opts, was_enabled = use_mmap(m); disable_mmap(m); mem = internal_malloc(m, size - CHUNK_OVERHEAD); - if (was_enabled) enable_mmap(m); - if (mem == 0) return 0; + if (was_enabled) + enable_mmap(m); + if (mem == 0) + return 0; if (PREACTION(m)) return 0; p = mem2chunk(mem); @@ -5716,30 +5086,24 @@ static void **ialloc(mstate m, size_t n_elements, size_t *sizes, int opts, assert(!is_mmapped(p)); - if (opts & 0x2) { /* optionally clear the elements */ - __builtin_memset((size_t *)mem, 0, - remainder_size - SIZE_T_SIZE - array_size); - + if (opts & 0x2) { /* optionally clear the elements */ + __builtin_memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); } /* If not provided, allocate the pointer array as final part of chunk */ if (marray == 0) { - - size_t array_chunk_size; + size_t array_chunk_size; array_chunk = chunk_plus_offset(p, contents_size); array_chunk_size = remainder_size - contents_size; - marray = (void **)(chunk2mem(array_chunk)); + marray = (void**) (chunk2mem(array_chunk)); set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); remainder_size = contents_size; - } /* split out elements */ - for (i = 0;; ++i) { - + for (i = 0; ; ++i) { marray[i] = chunk2mem(p); - if (i != n_elements - 1) { - + if (i != n_elements-1) { if (element_size != 0) size = element_size; else @@ -5747,42 +5111,31 @@ static void **ialloc(mstate m, size_t n_elements, size_t *sizes, int opts, remainder_size -= size; set_size_and_pinuse_of_inuse_chunk(m, p, size); p = chunk_plus_offset(p, size); - - } else { /* the final element absorbs any overallocation slop */ - + } + else { /* the final element absorbs any overallocation slop */ set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); break; - } - } #if DEBUG if (marray != chunks) { - /* final element must have exactly exhausted chunk */ if (element_size != 0) { - assert(remainder_size == element_size); - - } else { - + } + else { assert(remainder_size == request2size(sizes[i])); - } - check_inuse_chunk(m, mem2chunk(marray)); - } - for (i = 0; i != n_elements; ++i) check_inuse_chunk(m, mem2chunk(marray[i])); -#endif /* DEBUG */ +#endif /* DEBUG */ POSTACTION(m); return marray; - } /* Try to free all pointers in the given array. @@ -5792,431 +5145,316 @@ static void **ialloc(mstate m, size_t n_elements, size_t *sizes, int opts, chunks before freeing, which will occur often if allocated with ialloc or the array is sorted. */ -static size_t internal_bulk_free(mstate m, void *array[], size_t nelem) { - +static size_t internal_bulk_free(mstate m, void* array[], size_t nelem) { size_t unfreed = 0; if (!PREACTION(m)) { - - void **a; - void **fence = &(array[nelem]); + void** a; + void** fence = &(array[nelem]); for (a = array; a != fence; ++a) { - - void *mem = *a; + void* mem = *a; if (mem != 0) { - mchunkptr p = mem2chunk(mem); - size_t psize = chunksize(p); + size_t psize = chunksize(p); #if FOOTERS if (get_mstate_for(p) != m) { - ++unfreed; continue; - } - #endif check_inuse_chunk(m, p); *a = 0; if (RTCHECK(ok_address(m, p) && ok_inuse(p))) { - - void ** b = a + 1; /* try to merge with next chunk */ + void ** b = a + 1; /* try to merge with next chunk */ mchunkptr next = next_chunk(p); if (b != fence && *b == chunk2mem(next)) { - size_t newsize = chunksize(next) + psize; set_inuse(m, p, newsize); *b = chunk2mem(p); - - } else - + } + else dispose_chunk(m, p, psize); - - } else { - + } + else { CORRUPTION_ERROR_ACTION(m); break; - } - } - } - - if (should_trim(m, m->topsize)) sys_trim(m, 0); + if (should_trim(m, m->topsize)) + sys_trim(m, 0); POSTACTION(m); - } - return unfreed; - } /* Traversal */ #if MALLOC_INSPECT_ALL static void internal_inspect_all(mstate m, - void (*handler)(void *start, void *end, - size_t used_bytes, - void * callback_arg), - void *arg) { - + void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { if (is_initialized(m)) { - - mchunkptr top = m->top; + mchunkptr top = m->top; msegmentptr s; for (s = &m->seg; s != 0; s = s->next) { - mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) { - mchunkptr next = next_chunk(q); - size_t sz = chunksize(q); - size_t used; - void * start; + size_t sz = chunksize(q); + size_t used; + void* start; if (is_inuse(q)) { - - used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ + used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ start = chunk2mem(q); - - } else { - + } + else { used = 0; - if (is_small(sz)) { /* offset by possible bookkeeping */ - start = (void *)((char *)q + sizeof(struct malloc_chunk)); - - } else { - - start = (void *)((char *)q + sizeof(struct malloc_tree_chunk)); - + if (is_small(sz)) { /* offset by possible bookkeeping */ + start = (void*)((char*)q + sizeof(struct malloc_chunk)); + } + else { + start = (void*)((char*)q + sizeof(struct malloc_tree_chunk)); } - } - - if (start < (void *)next) /* skip if all space is bookkeeping */ + if (start < (void*)next) /* skip if all space is bookkeeping */ handler(start, next, used, arg); - if (q == top) break; + if (q == top) + break; q = next; - } - } - } - } - -#endif /* MALLOC_INSPECT_ALL */ +#endif /* MALLOC_INSPECT_ALL */ /* ------------------ Exported realloc, memalign, etc -------------------- */ #if !ONLY_MSPACES -void *dlrealloc(void *oldmem, size_t bytes) { - - void *mem = 0; +void* dlrealloc(void* oldmem, size_t bytes) { + void* mem = 0; if (oldmem == 0) { - mem = dlmalloc(bytes); - - } else if (bytes >= MAX_REQUEST) { - + } + else if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; - } - - #ifdef REALLOC_ZERO_BYTES_FREES +#ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { - dlfree(oldmem); - } - - #endif /* REALLOC_ZERO_BYTES_FREES */ +#endif /* REALLOC_ZERO_BYTES_FREES */ else { - - size_t nb = request2size(bytes); + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); - #if !FOOTERS +#if ! FOOTERS mstate m = gm; - #else /* FOOTERS */ +#else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { - USAGE_ERROR_ACTION(m, oldmem); return 0; - } - - #endif /* FOOTERS */ +#endif /* FOOTERS */ if (!PREACTION(m)) { - mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { - check_inuse_chunk(m, newp); mem = chunk2mem(newp); - - } else { - + } + else { mem = internal_malloc(m, bytes); if (mem != 0) { - size_t oc = chunksize(oldp) - overhead_for(oldp); - __builtin_memcpy(mem, oldmem, (oc < bytes) ? oc : bytes); + __builtin_memcpy(mem, oldmem, (oc < bytes)? oc : bytes); internal_free(m, oldmem); - } - } - } - } - return mem; - } -void *dlrealloc_in_place(void *oldmem, size_t bytes) { - - void *mem = 0; +void* dlrealloc_in_place(void* oldmem, size_t bytes) { + void* mem = 0; if (oldmem != 0) { - if (bytes >= MAX_REQUEST) { - MALLOC_FAILURE_ACTION; - - } else { - - size_t nb = request2size(bytes); + } + else { + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); - #if !FOOTERS +#if ! FOOTERS mstate m = gm; - #else /* FOOTERS */ +#else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { - USAGE_ERROR_ACTION(m, oldmem); return 0; - } - - #endif /* FOOTERS */ +#endif /* FOOTERS */ if (!PREACTION(m)) { - mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { - check_inuse_chunk(m, newp); mem = oldmem; - } - } - } - } - return mem; - } -void *dlmemalign(size_t alignment, size_t bytes) { - - if (alignment <= MALLOC_ALIGNMENT) { return dlmalloc(bytes); } +void* dlmemalign(size_t alignment, size_t bytes) { + if (alignment <= MALLOC_ALIGNMENT) { + return dlmalloc(bytes); + } return internal_memalign(gm, alignment, bytes); - } -int dlposix_memalign(void **pp, size_t alignment, size_t bytes) { - - void *mem = 0; +int dlposix_memalign(void** pp, size_t alignment, size_t bytes) { + void* mem = 0; if (alignment == MALLOC_ALIGNMENT) mem = dlmalloc(bytes); else { - - size_t d = alignment / sizeof(void *); - size_t r = alignment % sizeof(void *); - if (r != 0 || d == 0 || (d & (d - SIZE_T_ONE)) != 0) + size_t d = alignment / sizeof(void*); + size_t r = alignment % sizeof(void*); + if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0) return EINVAL; else if (bytes <= MAX_REQUEST - alignment) { - - if (alignment < MIN_CHUNK_SIZE) alignment = MIN_CHUNK_SIZE; + if (alignment < MIN_CHUNK_SIZE) + alignment = MIN_CHUNK_SIZE; mem = internal_memalign(gm, alignment, bytes); - } - } - if (mem == 0) return ENOMEM; else { - *pp = mem; return 0; - } - } -void *dlvalloc(size_t bytes) { - +void* dlvalloc(size_t bytes) { size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; return dlmemalign(pagesz, bytes); - } -void *dlpvalloc(size_t bytes) { - +void* dlpvalloc(size_t bytes) { size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; - return dlmemalign(pagesz, - (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); - + return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); } -void **dlindependent_calloc(size_t n_elements, size_t elem_size, - void *chunks[]) { - - size_t sz = elem_size; /* serves as 1-element array */ +void** dlindependent_calloc(size_t n_elements, size_t elem_size, + void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ return ialloc(gm, n_elements, &sz, 3, chunks); - } -void **dlindependent_comalloc(size_t n_elements, size_t sizes[], - void *chunks[]) { - +void** dlindependent_comalloc(size_t n_elements, size_t sizes[], + void* chunks[]) { return ialloc(gm, n_elements, sizes, 0, chunks); - } -size_t dlbulk_free(void *array[], size_t nelem) { - +size_t dlbulk_free(void* array[], size_t nelem) { return internal_bulk_free(gm, array, nelem); - } - #if MALLOC_INSPECT_ALL -void dlmalloc_inspect_all(void (*handler)(void *start, void *end, - size_t used_bytes, - void * callback_arg), - void *arg) { - +#if MALLOC_INSPECT_ALL +void dlmalloc_inspect_all(void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { ensure_initialization(); if (!PREACTION(gm)) { - internal_inspect_all(gm, handler, arg); POSTACTION(gm); - } - } - - #endif /* MALLOC_INSPECT_ALL */ +#endif /* MALLOC_INSPECT_ALL */ int dlmalloc_trim(size_t pad) { - int result = 0; ensure_initialization(); if (!PREACTION(gm)) { - result = sys_trim(gm, pad); POSTACTION(gm); - } - return result; - } size_t dlmalloc_footprint(void) { - return gm->footprint; - } size_t dlmalloc_max_footprint(void) { - return gm->max_footprint; - } size_t dlmalloc_footprint_limit(void) { - size_t maf = gm->footprint_limit; return maf == 0 ? MAX_SIZE_T : maf; - } size_t dlmalloc_set_footprint_limit(size_t bytes) { - - size_t result; /* invert sense of 0 */ - if (bytes == 0) result = granularity_align(1); /* Use minimal size */ + size_t result; /* invert sense of 0 */ + if (bytes == 0) + result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) - result = 0; /* disable */ + result = 0; /* disable */ else result = granularity_align(bytes); return gm->footprint_limit = result; - } - #if !NO_MALLINFO +#if !NO_MALLINFO struct mallinfo dlmallinfo(void) { - return internal_mallinfo(gm); - } +#endif /* NO_MALLINFO */ - #endif /* NO_MALLINFO */ - - #if !NO_MALLOC_STATS +#if !NO_MALLOC_STATS void dlmalloc_stats() { - internal_malloc_stats(gm); - } - - #endif /* NO_MALLOC_STATS */ +#endif /* NO_MALLOC_STATS */ int dlmallopt(int param_number, int value) { - return change_mparam(param_number, value); - } -size_t dlmalloc_usable_size(void *mem) { - +size_t dlmalloc_usable_size(void* mem) { if (mem != 0) { - mchunkptr p = mem2chunk(mem); - if (is_inuse(p)) return chunksize(p) - overhead_for(p); - + if (is_inuse(p)) + return chunksize(p) - overhead_for(p); } - return 0; - } -#endif /* !ONLY_MSPACES */ +#endif /* !ONLY_MSPACES */ /* ----------------------------- user mspaces ---------------------------- */ #if MSPACES -static mstate init_user_mstate(char *tbase, size_t tsize) { - - size_t msize = pad_request(sizeof(struct malloc_state)); +static mstate init_user_mstate(char* tbase, size_t tsize) { + size_t msize = pad_request(sizeof(struct malloc_state)); mchunkptr mn; mchunkptr msp = align_as_chunk(tbase); - mstate m = (mstate)(chunk2mem(msp)); + mstate m = (mstate)(chunk2mem(msp)); __builtin_memset(m, 0, msize); (void)INITIAL_LOCK(&m->mutex); - msp->head = (msize | INUSE_BITS); + msp->head = (msize|INUSE_BITS); m->seg.base = m->least_addr = tbase; m->seg.size = m->footprint = m->max_footprint = tsize; m->magic = mparams.magic; @@ -6227,111 +5465,82 @@ static mstate init_user_mstate(char *tbase, size_t tsize) { disable_contiguous(m); init_bins(m); mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); + init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); check_top_chunk(m, m->top); return m; - } mspace create_mspace(size_t capacity, int locked) { - mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); - if (capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { - - size_t rs = ((capacity == 0) ? mparams.granularity - : (capacity + TOP_FOOT_SIZE + msize)); + if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + size_t rs = ((capacity == 0)? mparams.granularity : + (capacity + TOP_FOOT_SIZE + msize)); size_t tsize = granularity_align(rs); - char * tbase = (char *)(CALL_MMAP(tsize)); + char* tbase = (char*)(CALL_MMAP(tsize)); if (tbase != CMFAIL) { - m = init_user_mstate(tbase, tsize); m->seg.sflags = USE_MMAP_BIT; set_lock(m, locked); - } - } - return (mspace)m; - } -mspace create_mspace_with_base(void *base, size_t capacity, int locked) { - +mspace create_mspace_with_base(void* base, size_t capacity, int locked) { mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); if (capacity > msize + TOP_FOOT_SIZE && - capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { - - m = init_user_mstate((char *)base, capacity); + capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { + m = init_user_mstate((char*)base, capacity); m->seg.sflags = EXTERN_BIT; set_lock(m, locked); - } - return (mspace)m; - } int mspace_track_large_chunks(mspace msp, int enable) { - - int ret = 0; + int ret = 0; mstate ms = (mstate)msp; if (!PREACTION(ms)) { - - if (!use_mmap(ms)) { ret = 1; } + if (!use_mmap(ms)) { + ret = 1; + } if (!enable) { - enable_mmap(ms); - } else { - disable_mmap(ms); - } - POSTACTION(ms); - } - return ret; - } size_t destroy_mspace(mspace msp) { - size_t freed = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { - msegmentptr sp = &ms->seg; - (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ + (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ while (sp != 0) { - - char * base = sp->base; + char* base = sp->base; size_t size = sp->size; flag_t flag = sp->sflags; - (void)base; /* placate people compiling -Wunused-variable */ + (void)base; /* placate people compiling -Wunused-variable */ sp = sp->next; if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && CALL_MUNMAP(base, size) == 0) freed += size; - } - - } else { - - USAGE_ERROR_ACTION(ms, ms); - } - + else { + USAGE_ERROR_ACTION(ms,ms); + } return freed; - } /* @@ -6339,31 +5548,25 @@ size_t destroy_mspace(mspace msp) { versions. This is not so nice but better than the alternatives. */ -void *mspace_malloc(mspace msp, size_t bytes) { - +void* mspace_malloc(mspace msp, size_t bytes) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { - - USAGE_ERROR_ACTION(ms, ms); + USAGE_ERROR_ACTION(ms,ms); return 0; - } - if (!PREACTION(ms)) { - - void * mem; + void* mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { - bindex_t idx; binmap_t smallbits; - nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); + nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = ms->smallmap >> idx; - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ + idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(ms, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); @@ -6372,17 +5575,15 @@ void *mspace_malloc(mspace msp, size_t bytes) { mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; - } else if (nb > ms->dvsize) { - - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(ms, i); p = b->fd; @@ -6393,71 +5594,54 @@ void *mspace_malloc(mspace msp, size_t bytes) { if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(ms, p, small_index2size(i)); else { - set_size_and_pinuse_of_inuse_chunk(ms, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(ms, r, rsize); - } - mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; - } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); goto postaction; - } - } - - } else if (bytes >= MAX_REQUEST) - + } + else if (bytes >= MAX_REQUEST) nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { - nb = pad_request(bytes); if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { - check_malloced_chunk(ms, mem, nb); goto postaction; - } - } if (nb <= ms->dvsize) { - - size_t rsize = ms->dvsize - nb; + size_t rsize = ms->dvsize - nb; mchunkptr p = ms->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = ms->dv = chunk_plus_offset(p, nb); ms->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - - } else { /* exhaust dv */ - + } + else { /* exhaust dv */ size_t dvs = ms->dvsize; ms->dvsize = 0; ms->dv = 0; set_inuse_and_pinuse(ms, p, dvs); - } - mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; - } - else if (nb < ms->topsize) { /* Split top */ - size_t rsize = ms->topsize -= nb; + else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; mchunkptr p = ms->top; mchunkptr r = ms->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -6466,7 +5650,6 @@ void *mspace_malloc(mspace msp, size_t bytes) { check_top_chunk(ms, ms->top); check_malloced_chunk(ms, mem, nb); goto postaction; - } mem = sys_alloc(ms, nb); @@ -6474,519 +5657,372 @@ void *mspace_malloc(mspace msp, size_t bytes) { postaction: POSTACTION(ms); return mem; - } return 0; - } -void mspace_free(mspace msp, void *mem) { - +void mspace_free(mspace msp, void* mem) { if (mem != 0) { - - mchunkptr p = mem2chunk(mem); - #if FOOTERS + mchunkptr p = mem2chunk(mem); +#if FOOTERS mstate fm = get_mstate_for(p); - (void)msp; /* placate people compiling -Wunused */ - #else /* FOOTERS */ + (void)msp; /* placate people compiling -Wunused */ +#else /* FOOTERS */ mstate fm = (mstate)msp; - #endif /* FOOTERS */ +#endif /* FOOTERS */ if (!ok_magic(fm)) { - USAGE_ERROR_ACTION(fm, p); return; - } - if (!PREACTION(fm)) { - check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { - - size_t psize = chunksize(p); + size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { - size_t prevsize = p->prev_foot; if (is_mmapped(p)) { - psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) + if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; - - } else { - + } + else { mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { - unlink_chunk(fm, p, prevsize); - - } else if ((next->head & INUSE_BITS) == INUSE_BITS) { - + } + else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; - } - - } else - + } + else goto erroraction; - } - } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - - if (!cinuse(next)) { /* consolidate forward */ + if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { - size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { - fm->dv = 0; fm->dvsize = 0; - } - - if (should_trim(fm, tsize)) sys_trim(fm, 0); + if (should_trim(fm, tsize)) + sys_trim(fm, 0); goto postaction; - - } else if (next == fm->dv) { - + } + else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; - - } else { - + } + else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { - fm->dvsize = psize; goto postaction; - } - } - - } else - + } + else set_free_with_pinuse(p, psize, next); if (is_small(psize)) { - insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); - - } else { - + } + else { tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); - if (--fm->release_checks == 0) release_unused_segments(fm); - + if (--fm->release_checks == 0) + release_unused_segments(fm); } - goto postaction; - } - } - erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); - } - } - } -void *mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { - - void * mem; +void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { + void* mem; size_t req = 0; mstate ms = (mstate)msp; if (!ok_magic(ms)) { - - USAGE_ERROR_ACTION(ms, ms); + USAGE_ERROR_ACTION(ms,ms); return 0; - } - if (n_elements != 0) { - req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ - + req = MAX_SIZE_T; /* force downstream failure on overflow */ } - mem = internal_malloc(ms, req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) __builtin_memset(mem, 0, req); return mem; - } -void *mspace_realloc(mspace msp, void *oldmem, size_t bytes) { - - void *mem = 0; +void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { + void* mem = 0; if (oldmem == 0) { - mem = mspace_malloc(msp, bytes); - - } else if (bytes >= MAX_REQUEST) { - + } + else if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; - } - - #ifdef REALLOC_ZERO_BYTES_FREES +#ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { - mspace_free(msp, oldmem); - } - - #endif /* REALLOC_ZERO_BYTES_FREES */ +#endif /* REALLOC_ZERO_BYTES_FREES */ else { - - size_t nb = request2size(bytes); + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); - #if !FOOTERS +#if ! FOOTERS mstate m = (mstate)msp; - #else /* FOOTERS */ +#else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { - USAGE_ERROR_ACTION(m, oldmem); return 0; - } - - #endif /* FOOTERS */ +#endif /* FOOTERS */ if (!PREACTION(m)) { - mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { - check_inuse_chunk(m, newp); mem = chunk2mem(newp); - - } else { - + } + else { mem = mspace_malloc(m, bytes); if (mem != 0) { - size_t oc = chunksize(oldp) - overhead_for(oldp); - __builtin_memcpy(mem, oldmem, (oc < bytes) ? oc : bytes); + __builtin_memcpy(mem, oldmem, (oc < bytes)? oc : bytes); mspace_free(m, oldmem); - } - } - } - } - return mem; - } -void *mspace_realloc_in_place(mspace msp, void *oldmem, size_t bytes) { - - void *mem = 0; +void* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) { + void* mem = 0; if (oldmem != 0) { - if (bytes >= MAX_REQUEST) { - MALLOC_FAILURE_ACTION; - - } else { - - size_t nb = request2size(bytes); + } + else { + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); - #if !FOOTERS +#if ! FOOTERS mstate m = (mstate)msp; - #else /* FOOTERS */ +#else /* FOOTERS */ mstate m = get_mstate_for(oldp); - (void)msp; /* placate people compiling -Wunused */ + (void)msp; /* placate people compiling -Wunused */ if (!ok_magic(m)) { - USAGE_ERROR_ACTION(m, oldmem); return 0; - } - - #endif /* FOOTERS */ +#endif /* FOOTERS */ if (!PREACTION(m)) { - mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { - check_inuse_chunk(m, newp); mem = oldmem; - } - } - } - } - return mem; - } -void *mspace_memalign(mspace msp, size_t alignment, size_t bytes) { - +void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { - - USAGE_ERROR_ACTION(ms, ms); + USAGE_ERROR_ACTION(ms,ms); return 0; - } - - if (alignment <= MALLOC_ALIGNMENT) return mspace_malloc(msp, bytes); + if (alignment <= MALLOC_ALIGNMENT) + return mspace_malloc(msp, bytes); return internal_memalign(ms, alignment, bytes); - } -void **mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void *chunks[]) { - - size_t sz = elem_size; /* serves as 1-element array */ +void** mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void* chunks[]) { + size_t sz = elem_size; /* serves as 1-element array */ mstate ms = (mstate)msp; if (!ok_magic(ms)) { - - USAGE_ERROR_ACTION(ms, ms); + USAGE_ERROR_ACTION(ms,ms); return 0; - } - return ialloc(ms, n_elements, &sz, 3, chunks); - } -void **mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void *chunks[]) { - +void** mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void* chunks[]) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { - - USAGE_ERROR_ACTION(ms, ms); + USAGE_ERROR_ACTION(ms,ms); return 0; - } - return ialloc(ms, n_elements, sizes, 0, chunks); - } -size_t mspace_bulk_free(mspace msp, void *array[], size_t nelem) { - +size_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) { return internal_bulk_free((mstate)msp, array, nelem); - } - #if MALLOC_INSPECT_ALL +#if MALLOC_INSPECT_ALL void mspace_inspect_all(mspace msp, - void (*handler)(void *start, void *end, - size_t used_bytes, void *callback_arg), - void *arg) { - + void(*handler)(void *start, + void *end, + size_t used_bytes, + void* callback_arg), + void* arg) { mstate ms = (mstate)msp; if (ok_magic(ms)) { - if (!PREACTION(ms)) { - internal_inspect_all(ms, handler, arg); POSTACTION(ms); - } - - } else { - - USAGE_ERROR_ACTION(ms, ms); - } - + else { + USAGE_ERROR_ACTION(ms,ms); + } } - - #endif /* MALLOC_INSPECT_ALL */ +#endif /* MALLOC_INSPECT_ALL */ int mspace_trim(mspace msp, size_t pad) { - - int result = 0; + int result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { - if (!PREACTION(ms)) { - result = sys_trim(ms, pad); POSTACTION(ms); - } - - } else { - - USAGE_ERROR_ACTION(ms, ms); - } - + else { + USAGE_ERROR_ACTION(ms,ms); + } return result; - } - #if !NO_MALLOC_STATS +#if !NO_MALLOC_STATS void mspace_malloc_stats(mspace msp) { - mstate ms = (mstate)msp; if (ok_magic(ms)) { - internal_malloc_stats(ms); - - } else { - - USAGE_ERROR_ACTION(ms, ms); - } - + else { + USAGE_ERROR_ACTION(ms,ms); + } } - - #endif /* NO_MALLOC_STATS */ +#endif /* NO_MALLOC_STATS */ size_t mspace_footprint(mspace msp) { - size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { - result = ms->footprint; - - } else { - - USAGE_ERROR_ACTION(ms, ms); - } - + else { + USAGE_ERROR_ACTION(ms,ms); + } return result; - } size_t mspace_max_footprint(mspace msp) { - size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { - result = ms->max_footprint; - - } else { - - USAGE_ERROR_ACTION(ms, ms); - } - + else { + USAGE_ERROR_ACTION(ms,ms); + } return result; - } size_t mspace_footprint_limit(mspace msp) { - size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { - size_t maf = ms->footprint_limit; result = (maf == 0) ? MAX_SIZE_T : maf; - - } else { - - USAGE_ERROR_ACTION(ms, ms); - } - + else { + USAGE_ERROR_ACTION(ms,ms); + } return result; - } size_t mspace_set_footprint_limit(mspace msp, size_t bytes) { - size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { - - if (bytes == 0) result = granularity_align(1); /* Use minimal size */ + if (bytes == 0) + result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) - result = 0; /* disable */ + result = 0; /* disable */ else result = granularity_align(bytes); ms->footprint_limit = result; - - } else { - - USAGE_ERROR_ACTION(ms, ms); - } - + else { + USAGE_ERROR_ACTION(ms,ms); + } return result; - } - #if !NO_MALLINFO +#if !NO_MALLINFO struct mallinfo mspace_mallinfo(mspace msp) { - mstate ms = (mstate)msp; - if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms, ms); } + if (!ok_magic(ms)) { + USAGE_ERROR_ACTION(ms,ms); + } return internal_mallinfo(ms); - } +#endif /* NO_MALLINFO */ - #endif /* NO_MALLINFO */ - -size_t mspace_usable_size(const void *mem) { - +size_t mspace_usable_size(const void* mem) { if (mem != 0) { - mchunkptr p = mem2chunk(mem); - if (is_inuse(p)) return chunksize(p) - overhead_for(p); - + if (is_inuse(p)) + return chunksize(p) - overhead_for(p); } - return 0; - } int mspace_mallopt(int param_number, int value) { - return change_mparam(param_number, value); - } -#endif /* MSPACES */ +#endif /* MSPACES */ + /* -------------------- Alternative MORECORE functions ------------------- */ @@ -7031,48 +6067,35 @@ int mspace_mallopt(int param_number, int value) { void *osMoreCore(int size) { - void *ptr = 0; static void *sbrk_top = 0; if (size > 0) { - if (size < MINIMUM_MORECORE_SIZE) size = MINIMUM_MORECORE_SIZE; if (CurrentExecutionLevel() == kTaskLevel) ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); if (ptr == 0) { - return (void *) MFAIL; - } - // save ptrs so they can be freed during cleanup our_os_pools[next_os_pool] = ptr; next_os_pool++; ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); sbrk_top = (char *) ptr + size; return ptr; - } - else if (size < 0) { - // we don't currently support shrink behavior return (void *) MFAIL; - } - else { - return sbrk_top; - } - } // cleanup any allocated memory pools @@ -7080,22 +6103,19 @@ int mspace_mallopt(int param_number, int value) { void osCleanupMem(void) { - void **ptr; for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) if (*ptr) { - PoolDeallocate(*ptr); *ptr = 0; - } - } */ + /* ----------------------------------------------------------------------- History: v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea @@ -7315,3 +6335,4 @@ History: */ +#endif // __GLIBC__ diff --git a/qemu_mode/libqasan/malloc.c b/qemu_mode/libqasan/malloc.c index f8237826..54c1096a 100644 --- a/qemu_mode/libqasan/malloc.c +++ b/qemu_mode/libqasan/malloc.c @@ -24,6 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ #include "libqasan.h" +#include #include #include #include @@ -50,9 +51,9 @@ typedef struct { struct chunk_begin { size_t requested_size; - void * aligned_orig; // NULL if not aligned - struct chunk_begin *next; - struct chunk_begin *prev; + void* aligned_orig; // NULL if not aligned + struct chunk_begin* next; + struct chunk_begin* prev; char redzone[REDZONE_SIZE]; }; @@ -65,30 +66,47 @@ struct chunk_struct { }; +#ifdef __GLIBC__ + +void* (*__lq_libc_malloc)(size_t); +void (*__lq_libc_free)(void*); +#define backend_malloc __lq_libc_malloc +#define backend_free __lq_libc_free + +#define TMP_ZONE_SIZE 4096 +static int __tmp_alloc_zone_idx; +static unsigned char __tmp_alloc_zone[TMP_ZONE_SIZE]; + +#else + // From dlmalloc.c -void *dlmalloc(size_t); -void dlfree(void *); +void* dlmalloc(size_t); +void dlfree(void*); +#define backend_malloc dlmalloc +#define backend_free dlfree + +#endif int __libqasan_malloc_initialized; -static struct chunk_begin *quarantine_top; -static struct chunk_begin *quarantine_end; +static struct chunk_begin* quarantine_top; +static struct chunk_begin* quarantine_end; static size_t quarantine_bytes; #ifdef __BIONIC__ -static pthread_mutex_t quarantine_lock; - #define LOCK_TRY pthread_mutex_trylock - #define LOCK_INIT pthread_mutex_init - #define LOCK_UNLOCK pthread_mutex_unlock +static pthread_mutex_t quarantine_lock; +#define LOCK_TRY pthread_mutex_trylock +#define LOCK_INIT pthread_mutex_init +#define LOCK_UNLOCK pthread_mutex_unlock #else -static pthread_spinlock_t quarantine_lock; - #define LOCK_TRY pthread_spin_trylock - #define LOCK_INIT pthread_spin_init - #define LOCK_UNLOCK pthread_spin_unlock +static pthread_spinlock_t quarantine_lock; +#define LOCK_TRY pthread_spin_trylock +#define LOCK_INIT pthread_spin_init +#define LOCK_UNLOCK pthread_spin_unlock #endif // need qasan disabled -static int quanratine_push(struct chunk_begin *ck) { +static int quanratine_push(struct chunk_begin* ck) { if (ck->requested_size >= QUARANTINE_MAX_BYTES) return 0; @@ -96,15 +114,15 @@ static int quanratine_push(struct chunk_begin *ck) { while (ck->requested_size + quarantine_bytes >= QUARANTINE_MAX_BYTES) { - struct chunk_begin *tmp = quarantine_end; + struct chunk_begin* tmp = quarantine_end; quarantine_end = tmp->prev; quarantine_bytes -= tmp->requested_size; if (tmp->aligned_orig) - dlfree(tmp->aligned_orig); + backend_free(tmp->aligned_orig); else - dlfree(tmp); + backend_free(tmp); } @@ -122,6 +140,11 @@ void __libqasan_init_malloc(void) { if (__libqasan_malloc_initialized) return; +#ifdef __GLIBC__ + __lq_libc_malloc = dlsym(RTLD_NEXT, "malloc"); + __lq_libc_free = dlsym(RTLD_NEXT, "free"); +#endif + LOCK_INIT(&quarantine_lock, PTHREAD_PROCESS_PRIVATE); __libqasan_malloc_initialized = 1; @@ -131,24 +154,38 @@ void __libqasan_init_malloc(void) { } -size_t __libqasan_malloc_usable_size(void *ptr) { +size_t __libqasan_malloc_usable_size(void* ptr) { - char *p = ptr; + char* p = ptr; p -= sizeof(struct chunk_begin); - return ((struct chunk_begin *)p)->requested_size; + return ((struct chunk_begin*)p)->requested_size; } -void *__libqasan_malloc(size_t size) { +void* __libqasan_malloc(size_t size) { - if (!__libqasan_malloc_initialized) { __libqasan_init_malloc(); } + if (!__libqasan_malloc_initialized) { + + __libqasan_init_malloc(); - if (!__libqasan_malloc_initialized) __libqasan_init_malloc(); +#ifdef __GLIBC__ + void* r = &__tmp_alloc_zone[__tmp_alloc_zone_idx]; + + if (size & (ALLOC_ALIGN_SIZE - 1)) + __tmp_alloc_zone_idx += + (size & ~(ALLOC_ALIGN_SIZE - 1)) + ALLOC_ALIGN_SIZE; + else + __tmp_alloc_zone_idx += size; + + return r; +#endif + + } int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread - struct chunk_begin *p = dlmalloc(sizeof(struct chunk_struct) + size); + struct chunk_begin* p = backend_malloc(sizeof(struct chunk_struct) + size); QASAN_SWAP(state); @@ -160,14 +197,14 @@ void *__libqasan_malloc(size_t size) { p->aligned_orig = NULL; p->next = p->prev = NULL; - QASAN_ALLOC(&p[1], (char *)&p[1] + size); + QASAN_ALLOC(&p[1], (char*)&p[1] + size); QASAN_POISON(p->redzone, REDZONE_SIZE, ASAN_HEAP_LEFT_RZ); if (size & (ALLOC_ALIGN_SIZE - 1)) - QASAN_POISON((char *)&p[1] + size, + QASAN_POISON((char*)&p[1] + size, (size & ~(ALLOC_ALIGN_SIZE - 1)) + 8 - size + REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); else - QASAN_POISON((char *)&p[1] + size, REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); + QASAN_POISON((char*)&p[1] + size, REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); __builtin_memset(&p[1], 0xff, size); @@ -175,11 +212,17 @@ void *__libqasan_malloc(size_t size) { } -void __libqasan_free(void *ptr) { +void __libqasan_free(void* ptr) { if (!ptr) return; + +#ifdef __GLIBC__ + if (ptr >= (void*)__tmp_alloc_zone && + ptr < ((void*)__tmp_alloc_zone + TMP_ZONE_SIZE)) + return; +#endif - struct chunk_begin *p = ptr; + struct chunk_begin* p = ptr; p -= 1; size_t n = p->requested_size; @@ -190,9 +233,9 @@ void __libqasan_free(void *ptr) { if (!quanratine_push(p)) { if (p->aligned_orig) - dlfree(p->aligned_orig); + backend_free(p->aligned_orig); else - dlfree(p); + backend_free(p); } @@ -206,11 +249,21 @@ void __libqasan_free(void *ptr) { } -void *__libqasan_calloc(size_t nmemb, size_t size) { +void* __libqasan_calloc(size_t nmemb, size_t size) { size *= nmemb; - char *p = __libqasan_malloc(size); +#ifdef __GLIBC__ + if (!__libqasan_malloc_initialized) { + + void* r = &__tmp_alloc_zone[__tmp_alloc_zone_idx]; + __tmp_alloc_zone_idx += size; + return r; + + } +#endif + + char* p = __libqasan_malloc(size); if (!p) return NULL; __builtin_memset(p, 0, size); @@ -219,14 +272,14 @@ void *__libqasan_calloc(size_t nmemb, size_t size) { } -void *__libqasan_realloc(void *ptr, size_t size) { +void* __libqasan_realloc(void* ptr, size_t size) { - char *p = __libqasan_malloc(size); + char* p = __libqasan_malloc(size); if (!p) return NULL; if (!ptr) return p; - size_t n = ((struct chunk_begin *)ptr)[-1].requested_size; + size_t n = ((struct chunk_begin*)ptr)[-1].requested_size; if (size < n) n = size; __builtin_memcpy(p, ptr, n); @@ -236,9 +289,9 @@ void *__libqasan_realloc(void *ptr, size_t size) { } -int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) { +int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { - if ((align % 2) || (align % sizeof(void *))) return EINVAL; + if ((align % 2) || (align % sizeof(void*))) return EINVAL; if (len == 0) { *ptr = NULL; @@ -252,7 +305,7 @@ int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) { int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread - char *orig = dlmalloc(sizeof(struct chunk_struct) + size); + char* orig = backend_malloc(sizeof(struct chunk_struct) + size); QASAN_SWAP(state); @@ -260,10 +313,10 @@ int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) { QASAN_UNPOISON(orig, sizeof(struct chunk_struct) + size); - char *data = orig + sizeof(struct chunk_begin); + char* data = orig + sizeof(struct chunk_begin); data += align - ((uintptr_t)data % align); - struct chunk_begin *p = (struct chunk_begin *)data - 1; + struct chunk_begin* p = (struct chunk_begin*)data - 1; p->requested_size = len; p->aligned_orig = orig; @@ -286,9 +339,9 @@ int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) { } -void *__libqasan_memalign(size_t align, size_t len) { +void* __libqasan_memalign(size_t align, size_t len) { - void *ret = NULL; + void* ret = NULL; __libqasan_posix_memalign(&ret, align, len); @@ -296,9 +349,9 @@ void *__libqasan_memalign(size_t align, size_t len) { } -void *__libqasan_aligned_alloc(size_t align, size_t len) { +void* __libqasan_aligned_alloc(size_t align, size_t len) { - void *ret = NULL; + void* ret = NULL; if ((len % align)) return NULL; diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index 6ab6bf28..47722f64 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit 6ab6bf28decb3e36eee43ffbd4a3bfd052dbbb50 +Subproject commit 47722f64e4c1662bad97dc25f3e4cc63959ff5f3 -- cgit 1.4.1 From 5b2634f711e95b48b6105d3cac659e51706ff4e9 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Wed, 10 Feb 2021 17:56:27 +0100 Subject: update changelog + ideas --- docs/Changelog.md | 12 ++++++------ docs/ideas.md | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index f2041917..56137eec 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -16,8 +16,8 @@ sending a mail to . to be placed in the source code. Check out instrumentation/README.instrument_list.md - afl-fuzz - - Making AFL_MAP_SIZE obsolete - afl-fuzz now learns on start the - target map size + - Making AFL_MAP_SIZE (mostly) obsolete - afl-fuzz now learns on start + the target map size - upgraded cmplog/redqueen: solving for floating point, solving transformations (e.g. toupper, tolower, to/from hex, xor, arithmetics, etc.). this is costly hence new command line option @@ -27,7 +27,7 @@ sending a mail to . - fix crash for very, very fast targets+systems (thanks to mhlakhani for reporting) - on restarts (-i)/autoresume (AFL_AUTORESUME) the stats are now - reloaded and used, thanks to Vimal Joseph for this PR! + reloaded and used, thanks to Vimal Joseph for this patch! - if determinstic mode is active (-D, or -M without -d) then we sync after every queue entry as this can take very long time otherwise - better detection if a target needs a large shared map @@ -47,8 +47,10 @@ sending a mail to . - added AFL_LLVM_INSTRUMENT option NATIVE for native clang pc-guard support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang + - fixed a potential crash in the LAF feature - qemuafl - - ported QASan to qemuafl! see qemu_mode/libqasan/README.md + - QASan (address sanitizer for Qemu) ported to qemuafl! + See qemu_mode/libqasan/README.md - solved some persistent mode bugs (thanks Dil4rd) - solved an issue when dumping the memory maps (thanks wizche) - Android support for QASan @@ -58,8 +60,6 @@ sending a mail to . - Added a new example harness to compare python, c, and rust bindings - changed default: no memory limit for afl-cmin and afl-cmin.bash - warn on any _AFL and __AFL env vars - - LLVM mode is now compiled with -j4, unicorn with all cores. qemu was - already building with all cores, the gcc plugin needs only one. - added dummy Makefile to instrumentation/ - Updated utils/afl_frida to be 5% faster, 7% on x86_x64 - Added AFL_KILL_SIGNAL env variable (thanks @v-p-b) diff --git a/docs/ideas.md b/docs/ideas.md index 7cbe60a5..08cb16ef 100644 --- a/docs/ideas.md +++ b/docs/ideas.md @@ -3,6 +3,40 @@ In the following, we describe a variety of ideas that could be implemented for future AFL++ versions. +# GSoC 2021 + +All GSoC 2021 projects will be in the Rust development language! + +## UI for libaflrs + +Write a user interface to libaflrs, the upcoming backend of afl++. +This might look like the afl-fuzz UI, but you can improve on it - and should! + +## Schedulers for libaflrs + +Schedulers is a mechanism that selects items from the fuzzing corpus based +on strategy and randomness. One scheduler might focus on long paths, +another on rarity of edges disocvered, still another on a combination on +things. Some of the schedulers in afl++ have to be ported, but you are free +to come up with your own if you want to - and see how it performs. + +## Forkserver support for libaflrs + +The current libaflrs implementation fuzzes in-memory, however obviously we +want to support afl instrumented binaries as well. +Hence a forkserver support needs to be implemented - forking off the target +and talking to the target via a socketpair and the communication protocol +within. + +## More Observers for libaflrs + +An observer is measuring functionality that looks at the target being fuzzed +and documents something about it. In traditional fuzzing this is the coverage +in the target, however we want to add various more observers, e.g. stack depth, +heap usage, etc. - this is a topic for an experienced Rust developer. + +# Generic ideas and wishlist + ## Analysis software Currently analysis is done by using afl-plot, which is rather outdated. -- cgit 1.4.1 From f4cac37b04ce8068a6d426c5e357c164853b159b Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Thu, 11 Feb 2021 10:20:36 +0100 Subject: typos --- instrumentation/README.instrument_list.md | 2 +- qemu_mode/libqasan/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/instrumentation/README.instrument_list.md b/instrumentation/README.instrument_list.md index b7dfb40c..25b99074 100644 --- a/instrumentation/README.instrument_list.md +++ b/instrumentation/README.instrument_list.md @@ -47,7 +47,7 @@ A special function is `__afl_coverage_interesting`. To use this, you must define `void __afl_coverage_interesting(u8 val, u32 id);`. Then you can use this function globally, where the `val` parameter can be set by you, the `id` parameter is for afl-fuzz and will be overwritten. -Note that useful parameters are for `val` are: 1, 2, 3, 4, 8, 16, 32, 64, 128. +Note that useful parameters for `val` are: 1, 2, 3, 4, 8, 16, 32, 64, 128. A value of e.g. 33 will be seen as 32 for coverage purposes. ## 3) Selective instrumenation with AFL_LLVM_ALLOWLIST/AFL_LLVM_DENYLIST diff --git a/qemu_mode/libqasan/README.md b/qemu_mode/libqasan/README.md index b5c77044..3a43cdf1 100644 --- a/qemu_mode/libqasan/README.md +++ b/qemu_mode/libqasan/README.md @@ -12,7 +12,7 @@ For debugging purposes, we still suggest to run the original QASan as the stackt ### When I should use QASan? -If your target binary is PIC x86_64, you should before give a try to [retrowrite](https://github.com/HexHive/retrowrite) for static rewriting. +If your target binary is PIC x86_64, you should also give a try to [retrowrite](https://github.com/HexHive/retrowrite) for static rewriting. If it fails, or if your binary is for another architecture, or you want to use persistent and snapshot mdoe, AFL++ QASan mode is what you want/have to use. -- cgit 1.4.1 From f3e783d343ff07bd43793248508aae8dcee77872 Mon Sep 17 00:00:00 2001 From: hexcoder Date: Thu, 11 Feb 2021 19:55:21 +0100 Subject: typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e3886ca7..4f49bf99 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ behaviours and defaults: * a caching of testcases can now be performed and can be modified by editing config.h for TESTCASE_CACHE or by specifying the env variable `AFL_TESTCACHE_SIZE` (in MB). Good values are between 50-500 (default: 50). - * -M mains do not perform trimming + * -M mains does not perform trimming * examples/ got renamed to utils/ * libtokencap/ libdislocator/ and qdbi_mode/ were moved to utils/ * afl-cmin/afl-cmin.bash now search first in PATH and last in AFL_PATH -- cgit 1.4.1 From dd3f4bb41c47025c490e7687d7bd1f04188f7bc4 Mon Sep 17 00:00:00 2001 From: hexcoder Date: Thu, 11 Feb 2021 20:05:06 +0100 Subject: typos & formatting --- docs/Changelog.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 56137eec..919e2aeb 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -20,18 +20,18 @@ sending a mail to . the target map size - upgraded cmplog/redqueen: solving for floating point, solving transformations (e.g. toupper, tolower, to/from hex, xor, - arithmetics, etc.). this is costly hence new command line option - -l that sets the intensity (values 1 to 3). recommended is 1 or 2. + arithmetics, etc.). This is costly hence new command line option + `-l` that sets the intensity (values 1 to 3). Recommended is 1 or 2. - added `AFL_CMPLOG_ONLY_NEW` to not use cmplog on initial testcases from `-i` or resumes (as these have most likely already been done) - fix crash for very, very fast targets+systems (thanks to mhlakhani for reporting) - - on restarts (-i)/autoresume (AFL_AUTORESUME) the stats are now + - on restarts (`-i`)/autoresume (AFL_AUTORESUME) the stats are now reloaded and used, thanks to Vimal Joseph for this patch! - - if determinstic mode is active (-D, or -M without -d) then we sync + - if deterministic mode is active (`-D`, or `-M` without `-d`) then we sync after every queue entry as this can take very long time otherwise - better detection if a target needs a large shared map - - fix for -Z + - fix for `-Z` - switched to an even faster RNG - added hghwng's patch for faster trace map analysis - afl-cc @@ -55,7 +55,7 @@ sending a mail to . - solved an issue when dumping the memory maps (thanks wizche) - Android support for QASan - unicornafl - - Substential speed gains in python bindings for certain use cases + - Substantial speed gains in python bindings for certain use cases - Improved rust bindings - Added a new example harness to compare python, c, and rust bindings - changed default: no memory limit for afl-cmin and afl-cmin.bash -- cgit 1.4.1 From 223bd70f1f1530a0b8331e3deee0de2b20ae061b Mon Sep 17 00:00:00 2001 From: hexcoder Date: Thu, 11 Feb 2021 20:08:28 +0100 Subject: typo --- docs/env_variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/env_variables.md b/docs/env_variables.md index ab56c178..886669ad 100644 --- a/docs/env_variables.md +++ b/docs/env_variables.md @@ -517,7 +517,7 @@ The QEMU wrapper used to instrument binary-only code supports several settings: - With `AFL_USE_QASAN` you can enable QEMU AddressSanitizer for dynamically linked binaries. - - With `AFL_QEMU_FORCE_DFL` you force QEMU to ignore the registered singal + - With `AFL_QEMU_FORCE_DFL` you force QEMU to ignore the registered signal handlers of the target. ## 6) Settings for afl-cmin -- cgit 1.4.1 From 2ff6e5023f9116c24842e6aee0da644106a61829 Mon Sep 17 00:00:00 2001 From: hexcoder Date: Thu, 11 Feb 2021 20:14:48 +0100 Subject: typos --- docs/rpc_statsd.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/rpc_statsd.md b/docs/rpc_statsd.md index 02f72be6..fb97aa09 100644 --- a/docs/rpc_statsd.md +++ b/docs/rpc_statsd.md @@ -1,6 +1,6 @@ # Remote monitoring with StatsD -StatsD allows you to receive and aggregate metrics from a wide range of application and retransmit them to the backend of your choice. +StatsD allows you to receive and aggregate metrics from a wide range of applications and retransmit them to the backend of your choice. This enables you to create nice and readable dashboards containing all the information you need on your fuzzer instances. No need to write your own statistics parsing system, deploy and maintain it to all your instances, sync with your graph rendering system... @@ -45,7 +45,7 @@ For more information on these env vars, check out `docs/env_variables.md`. The simplest way of using this feature is to use any metric provider and change the host/port of your StatsD daemon, with `AFL_STATSD_HOST` and `AFL_STATSD_PORT`, if required (defaults are `localhost` and port `8125`). -To get started, here are some instruction with free and open source tools. +To get started, here are some instructions with free and open source tools. The following setup is based on Prometheus, statsd_exporter and Grafana. Grafana here is not mandatory, but gives you some nice graphs and features. @@ -131,7 +131,7 @@ mappings: Run `docker-compose up -d`. -Everything should be now setup, you are now able to run your fuzzers with +Everything should now be setup, you are now able to run your fuzzers with ``` AFL_STATSD_TAGS_FLAVOR=dogstatsd AFL_STATSD=1 afl-fuzz -M test-fuzzer-1 -i i -o o ./bin/my-application @@ @@ -139,5 +139,5 @@ AFL_STATSD_TAGS_FLAVOR=dogstatsd AFL_STATSD=1 afl-fuzz -S test-fuzzer-2 -i i -o ... ``` -This setup may be modified before use in production environment. Depending on your needs: addind passwords, creating volumes for storage, +This setup may be modified before use in a production environment. Depending on your needs: adding passwords, creating volumes for storage, tweaking the metrics gathering to get host metrics (CPU, RAM ...). -- cgit 1.4.1 From 756206e4d710b954759eaa97c50940825eff39f7 Mon Sep 17 00:00:00 2001 From: hexcoder Date: Thu, 11 Feb 2021 20:26:02 +0100 Subject: typo --- include/config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/config.h b/include/config.h index 25fa1142..181285cd 100644 --- a/include/config.h +++ b/include/config.h @@ -10,7 +10,7 @@ Dominik Maier Copyright 2016, 2017 Google Inc. All rights reserved. - Copyright 2019-2020 AFLplusplus Project. All rights reserved. + Copyright 2019-2021 AFLplusplus Project. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ /* Minimum % of the corpus to perform cmplog on. Default: 20% */ #define CMPLOG_CORPUS_PERCENT 20U -/* Number of potential posititions from which we decide the cmplog becomes +/* Number of potential positions from which we decide if cmplog becomes useless, default 16384 */ #define CMPLOG_POSITIONS_MAX 16384U -- cgit 1.4.1 From d44cf1344d83508b750de934848d1ca3d9459c54 Mon Sep 17 00:00:00 2001 From: hexcoder Date: Thu, 11 Feb 2021 21:08:10 +0100 Subject: typo --- instrumentation/README.instrument_list.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/instrumentation/README.instrument_list.md b/instrumentation/README.instrument_list.md index 25b99074..2116d24c 100644 --- a/instrumentation/README.instrument_list.md +++ b/instrumentation/README.instrument_list.md @@ -50,7 +50,7 @@ by you, the `id` parameter is for afl-fuzz and will be overwritten. Note that useful parameters for `val` are: 1, 2, 3, 4, 8, 16, 32, 64, 128. A value of e.g. 33 will be seen as 32 for coverage purposes. -## 3) Selective instrumenation with AFL_LLVM_ALLOWLIST/AFL_LLVM_DENYLIST +## 3) Selective instrumentation with AFL_LLVM_ALLOWLIST/AFL_LLVM_DENYLIST This feature is equivalent to llvm 12 sancov feature and allows to specify on a filename and/or function name level to instrument these or skip them. -- cgit 1.4.1 From ea05f3f4cd3c4a618ed25267ae848d262ef83919 Mon Sep 17 00:00:00 2001 From: hexcoder Date: Thu, 11 Feb 2021 21:55:14 +0100 Subject: typos --- qemu_mode/libqasan/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu_mode/libqasan/README.md b/qemu_mode/libqasan/README.md index 3a43cdf1..83fb2442 100644 --- a/qemu_mode/libqasan/README.md +++ b/qemu_mode/libqasan/README.md @@ -4,7 +4,7 @@ This library is the injected runtime used by QEMU AddressSanitizer (QASan). The original repository is [here](https://github.com/andreafioraldi/qasan). -The version embedded in qemuafl is an updated version of just the usermode part and this runtime in injected via LD_PRELOAD (so works just for dynamically linked binaries). +The version embedded in qemuafl is an updated version of just the usermode part and this runtime is injected via LD_PRELOAD (so works just for dynamically linked binaries). The usage is super simple, just set the env var `AFL_USE_QASAN=1` when fuzzing in qemu mode (-Q). afl-fuzz will automatically set AFL_PRELOAD to load this library and enable the QASan instrumentation in afl-qemu-trace. @@ -14,6 +14,6 @@ For debugging purposes, we still suggest to run the original QASan as the stackt If your target binary is PIC x86_64, you should also give a try to [retrowrite](https://github.com/HexHive/retrowrite) for static rewriting. -If it fails, or if your binary is for another architecture, or you want to use persistent and snapshot mdoe, AFL++ QASan mode is what you want/have to use. +If it fails, or if your binary is for another architecture, or you want to use persistent and snapshot mode, AFL++ QASan mode is what you want/have to use. Note that the overhead of libdislocator when combined with QEMU mode is much lower but it can catch less bugs. This is a short blanket, take your choice. -- cgit 1.4.1 From 16ffbb37f5897ca318e747518fdae6b4e56b52ac Mon Sep 17 00:00:00 2001 From: hexcoder Date: Thu, 11 Feb 2021 22:09:19 +0100 Subject: typo --- qemu_mode/libqasan/uninstrument.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu_mode/libqasan/uninstrument.c b/qemu_mode/libqasan/uninstrument.c index e75a09eb..5bf841a3 100644 --- a/qemu_mode/libqasan/uninstrument.c +++ b/qemu_mode/libqasan/uninstrument.c @@ -1,7 +1,7 @@ /* This code is DEPRECATED! -I'm keeping it here cause maybe the unistrumentation of a function is needed +I'm keeping it here cause maybe the uninstrumentation of a function is needed for some strange reason. */ -- cgit 1.4.1 From 22a3c7f7d043d9dbf39c847061d88a4577537031 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 12 Feb 2021 09:42:22 +0100 Subject: fix #736 (ty b1gr3db) --- qemu_mode/QEMUAFL_VERSION | 2 +- qemu_mode/libqasan/dlmalloc.c | 5553 ++++++++++++++++++++++++----------------- qemu_mode/libqasan/hooks.c | 2 + qemu_mode/libqasan/libqasan.c | 2 +- qemu_mode/libqasan/malloc.c | 109 +- qemu_mode/libqasan/string.c | 2 +- qemu_mode/qemuafl | 2 +- src/afl-fuzz-redqueen.c | 3 +- 8 files changed, 3332 insertions(+), 2343 deletions(-) diff --git a/qemu_mode/QEMUAFL_VERSION b/qemu_mode/QEMUAFL_VERSION index d9f0ec33..e73a9588 100644 --- a/qemu_mode/QEMUAFL_VERSION +++ b/qemu_mode/QEMUAFL_VERSION @@ -1 +1 @@ -47722f64e4 +9a258d5b7a diff --git a/qemu_mode/libqasan/dlmalloc.c b/qemu_mode/libqasan/dlmalloc.c index 7e3cb159..bace0ff6 100644 --- a/qemu_mode/libqasan/dlmalloc.c +++ b/qemu_mode/libqasan/dlmalloc.c @@ -207,9 +207,12 @@ mspaces as thread-locals. For example: static __thread mspace tlms = 0; void* tlmalloc(size_t bytes) { + if (tlms == 0) tlms = create_mspace(0, 0); return mspace_malloc(tlms, bytes); + } + void tlfree(void* mem) { mspace_free(tlms, mem); } Unless FOOTERS is defined, each mspace is completely independent. @@ -525,201 +528,203 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP improvement at the expense of carrying around more memory. */ -#define USE_DL_PREFIX - -/* Version identifier to allow people to support multiple versions */ -#ifndef DLMALLOC_VERSION -#define DLMALLOC_VERSION 20806 -#endif /* DLMALLOC_VERSION */ - -#ifndef DLMALLOC_EXPORT -#define DLMALLOC_EXPORT extern -#endif - -#ifndef WIN32 -#ifdef _WIN32 -#define WIN32 1 -#endif /* _WIN32 */ -#ifdef _WIN32_WCE -#define LACKS_FCNTL_H -#define WIN32 1 -#endif /* _WIN32_WCE */ -#endif /* WIN32 */ -#ifdef WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#include -#define HAVE_MMAP 1 -#define HAVE_MORECORE 0 -#define LACKS_UNISTD_H -#define LACKS_SYS_PARAM_H -#define LACKS_SYS_MMAN_H -#define LACKS_STRING_H -#define LACKS_STRINGS_H -#define LACKS_SYS_TYPES_H -#define LACKS_ERRNO_H -#define LACKS_SCHED_H -#ifndef MALLOC_FAILURE_ACTION -#define MALLOC_FAILURE_ACTION -#endif /* MALLOC_FAILURE_ACTION */ -#ifndef MMAP_CLEARS -#ifdef _WIN32_WCE /* WINCE reportedly does not clear */ -#define MMAP_CLEARS 0 -#else -#define MMAP_CLEARS 1 -#endif /* _WIN32_WCE */ -#endif /*MMAP_CLEARS */ -#endif /* WIN32 */ - -#if defined(DARWIN) || defined(_DARWIN) -/* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ -#ifndef HAVE_MORECORE -#define HAVE_MORECORE 0 -#define HAVE_MMAP 1 -/* OSX allocators provide 16 byte alignment */ -#ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT ((size_t)16U) -#endif -#endif /* HAVE_MORECORE */ -#endif /* DARWIN */ - -#ifndef LACKS_SYS_TYPES_H -#include /* For size_t */ -#endif /* LACKS_SYS_TYPES_H */ - -/* The maximum possible size_t value has all bits set */ -#define MAX_SIZE_T (~(size_t)0) - -#ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ -#define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ - (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) -#endif /* USE_LOCKS */ - -#if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ -#if ((defined(__GNUC__) && \ - ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ - defined(__i386__) || defined(__x86_64__))) || \ - (defined(_MSC_VER) && _MSC_VER>=1310)) -#ifndef USE_SPIN_LOCKS -#define USE_SPIN_LOCKS 1 -#endif /* USE_SPIN_LOCKS */ -#elif USE_SPIN_LOCKS -#error "USE_SPIN_LOCKS defined without implementation" -#endif /* ... locks available... */ -#elif !defined(USE_SPIN_LOCKS) -#define USE_SPIN_LOCKS 0 -#endif /* USE_LOCKS */ - -#ifndef ONLY_MSPACES -#define ONLY_MSPACES 0 -#endif /* ONLY_MSPACES */ -#ifndef MSPACES -#if ONLY_MSPACES -#define MSPACES 1 -#else /* ONLY_MSPACES */ -#define MSPACES 0 -#endif /* ONLY_MSPACES */ -#endif /* MSPACES */ -#ifndef MALLOC_ALIGNMENT -#define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) -#endif /* MALLOC_ALIGNMENT */ -#ifndef FOOTERS -#define FOOTERS 0 -#endif /* FOOTERS */ -#ifndef ABORT -#define ABORT abort() -#endif /* ABORT */ -#ifndef ABORT_ON_ASSERT_FAILURE -#define ABORT_ON_ASSERT_FAILURE 1 -#endif /* ABORT_ON_ASSERT_FAILURE */ -#ifndef PROCEED_ON_ERROR -#define PROCEED_ON_ERROR 0 -#endif /* PROCEED_ON_ERROR */ - -#ifndef INSECURE -#define INSECURE 0 -#endif /* INSECURE */ -#ifndef MALLOC_INSPECT_ALL -#define MALLOC_INSPECT_ALL 0 -#endif /* MALLOC_INSPECT_ALL */ -#ifndef HAVE_MMAP -#define HAVE_MMAP 1 -#endif /* HAVE_MMAP */ -#ifndef MMAP_CLEARS -#define MMAP_CLEARS 1 -#endif /* MMAP_CLEARS */ -#ifndef HAVE_MREMAP -#ifdef linux -#define HAVE_MREMAP 1 -#define _GNU_SOURCE /* Turns on mremap() definition */ -#else /* linux */ -#define HAVE_MREMAP 0 -#endif /* linux */ -#endif /* HAVE_MREMAP */ -#ifndef MALLOC_FAILURE_ACTION -#define MALLOC_FAILURE_ACTION errno = ENOMEM; -#endif /* MALLOC_FAILURE_ACTION */ -#ifndef HAVE_MORECORE -#if ONLY_MSPACES -#define HAVE_MORECORE 0 -#else /* ONLY_MSPACES */ -#define HAVE_MORECORE 1 -#endif /* ONLY_MSPACES */ -#endif /* HAVE_MORECORE */ -#if !HAVE_MORECORE -#define MORECORE_CONTIGUOUS 0 -#else /* !HAVE_MORECORE */ -#define MORECORE_DEFAULT sbrk -#ifndef MORECORE_CONTIGUOUS -#define MORECORE_CONTIGUOUS 1 -#endif /* MORECORE_CONTIGUOUS */ -#endif /* HAVE_MORECORE */ -#ifndef DEFAULT_GRANULARITY -#if (MORECORE_CONTIGUOUS || defined(WIN32)) -#define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ -#else /* MORECORE_CONTIGUOUS */ -#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) -#endif /* MORECORE_CONTIGUOUS */ -#endif /* DEFAULT_GRANULARITY */ -#ifndef DEFAULT_TRIM_THRESHOLD -#ifndef MORECORE_CANNOT_TRIM -#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) -#else /* MORECORE_CANNOT_TRIM */ -#define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T -#endif /* MORECORE_CANNOT_TRIM */ -#endif /* DEFAULT_TRIM_THRESHOLD */ -#ifndef DEFAULT_MMAP_THRESHOLD -#if HAVE_MMAP -#define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) -#else /* HAVE_MMAP */ -#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T -#endif /* HAVE_MMAP */ -#endif /* DEFAULT_MMAP_THRESHOLD */ -#ifndef MAX_RELEASE_CHECK_RATE -#if HAVE_MMAP -#define MAX_RELEASE_CHECK_RATE 4095 -#else -#define MAX_RELEASE_CHECK_RATE MAX_SIZE_T -#endif /* HAVE_MMAP */ -#endif /* MAX_RELEASE_CHECK_RATE */ -#ifndef USE_BUILTIN_FFS -#define USE_BUILTIN_FFS 0 -#endif /* USE_BUILTIN_FFS */ -#ifndef USE_DEV_RANDOM -#define USE_DEV_RANDOM 0 -#endif /* USE_DEV_RANDOM */ -#ifndef NO_MALLINFO -#define NO_MALLINFO 0 -#endif /* NO_MALLINFO */ -#ifndef MALLINFO_FIELD_TYPE -#define MALLINFO_FIELD_TYPE size_t -#endif /* MALLINFO_FIELD_TYPE */ -#ifndef NO_MALLOC_STATS -#define NO_MALLOC_STATS 0 -#endif /* NO_MALLOC_STATS */ -#ifndef NO_SEGMENT_TRAVERSAL -#define NO_SEGMENT_TRAVERSAL 0 -#endif /* NO_SEGMENT_TRAVERSAL */ + #define USE_DL_PREFIX + + /* Version identifier to allow people to support multiple versions */ + #ifndef DLMALLOC_VERSION + #define DLMALLOC_VERSION 20806 + #endif /* DLMALLOC_VERSION */ + + #ifndef DLMALLOC_EXPORT + #define DLMALLOC_EXPORT extern + #endif + + #ifndef WIN32 + #ifdef _WIN32 + #define WIN32 1 + #endif /* _WIN32 */ + #ifdef _WIN32_WCE + #define LACKS_FCNTL_H + #define WIN32 1 + #endif /* _WIN32_WCE */ + #endif /* WIN32 */ + #ifdef WIN32 + #define WIN32_LEAN_AND_MEAN + #include + #include + #define HAVE_MMAP 1 + #define HAVE_MORECORE 0 + #define LACKS_UNISTD_H + #define LACKS_SYS_PARAM_H + #define LACKS_SYS_MMAN_H + #define LACKS_STRING_H + #define LACKS_STRINGS_H + #define LACKS_SYS_TYPES_H + #define LACKS_ERRNO_H + #define LACKS_SCHED_H + #ifndef MALLOC_FAILURE_ACTION + #define MALLOC_FAILURE_ACTION + #endif /* MALLOC_FAILURE_ACTION */ + #ifndef MMAP_CLEARS + #ifdef _WIN32_WCE /* WINCE reportedly does not clear */ + #define MMAP_CLEARS 0 + #else + #define MMAP_CLEARS 1 + #endif /* _WIN32_WCE */ + #endif /*MMAP_CLEARS */ + #endif /* WIN32 */ + + #if defined(DARWIN) || defined(_DARWIN) + /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ + #ifndef HAVE_MORECORE + #define HAVE_MORECORE 0 + #define HAVE_MMAP 1 + /* OSX allocators provide 16 byte alignment */ + #ifndef MALLOC_ALIGNMENT + #define MALLOC_ALIGNMENT ((size_t)16U) + #endif + #endif /* HAVE_MORECORE */ + #endif /* DARWIN */ + + #ifndef LACKS_SYS_TYPES_H + #include /* For size_t */ + #endif /* LACKS_SYS_TYPES_H */ + + /* The maximum possible size_t value has all bits set */ + #define MAX_SIZE_T (~(size_t)0) + + #ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ + #define USE_LOCKS \ + ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ + (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) + #endif /* USE_LOCKS */ + + #if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ + #if ((defined(__GNUC__) && \ + ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ + defined(__i386__) || defined(__x86_64__))) || \ + (defined(_MSC_VER) && _MSC_VER >= 1310)) + #ifndef USE_SPIN_LOCKS + #define USE_SPIN_LOCKS 1 + #endif /* USE_SPIN_LOCKS */ + #elif USE_SPIN_LOCKS + #error "USE_SPIN_LOCKS defined without implementation" + #endif /* ... locks available... */ + #elif !defined(USE_SPIN_LOCKS) + #define USE_SPIN_LOCKS 0 + #endif /* USE_LOCKS */ + + #ifndef ONLY_MSPACES + #define ONLY_MSPACES 0 + #endif /* ONLY_MSPACES */ + #ifndef MSPACES + #if ONLY_MSPACES + #define MSPACES 1 + #else /* ONLY_MSPACES */ + #define MSPACES 0 + #endif /* ONLY_MSPACES */ + #endif /* MSPACES */ + #ifndef MALLOC_ALIGNMENT + #define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) + #endif /* MALLOC_ALIGNMENT */ + #ifndef FOOTERS + #define FOOTERS 0 + #endif /* FOOTERS */ + #ifndef ABORT + #define ABORT abort() + #endif /* ABORT */ + #ifndef ABORT_ON_ASSERT_FAILURE + #define ABORT_ON_ASSERT_FAILURE 1 + #endif /* ABORT_ON_ASSERT_FAILURE */ + #ifndef PROCEED_ON_ERROR + #define PROCEED_ON_ERROR 0 + #endif /* PROCEED_ON_ERROR */ + + #ifndef INSECURE + #define INSECURE 0 + #endif /* INSECURE */ + #ifndef MALLOC_INSPECT_ALL + #define MALLOC_INSPECT_ALL 0 + #endif /* MALLOC_INSPECT_ALL */ + #ifndef HAVE_MMAP + #define HAVE_MMAP 1 + #endif /* HAVE_MMAP */ + #ifndef MMAP_CLEARS + #define MMAP_CLEARS 1 + #endif /* MMAP_CLEARS */ + #ifndef HAVE_MREMAP + #ifdef linux + #define HAVE_MREMAP 1 + #define _GNU_SOURCE /* Turns on mremap() definition */ + #else /* linux */ + #define HAVE_MREMAP 0 + #endif /* linux */ + #endif /* HAVE_MREMAP */ + #ifndef MALLOC_FAILURE_ACTION + #define MALLOC_FAILURE_ACTION errno = ENOMEM; + #endif /* MALLOC_FAILURE_ACTION */ + #ifndef HAVE_MORECORE + #if ONLY_MSPACES + #define HAVE_MORECORE 0 + #else /* ONLY_MSPACES */ + #define HAVE_MORECORE 1 + #endif /* ONLY_MSPACES */ + #endif /* HAVE_MORECORE */ + #if !HAVE_MORECORE + #define MORECORE_CONTIGUOUS 0 + #else /* !HAVE_MORECORE */ + #define MORECORE_DEFAULT sbrk + #ifndef MORECORE_CONTIGUOUS + #define MORECORE_CONTIGUOUS 1 + #endif /* MORECORE_CONTIGUOUS */ + #endif /* HAVE_MORECORE */ + #ifndef DEFAULT_GRANULARITY + #if (MORECORE_CONTIGUOUS || defined(WIN32)) + #define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ + #else /* MORECORE_CONTIGUOUS */ + #define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) + #endif /* MORECORE_CONTIGUOUS */ + #endif /* DEFAULT_GRANULARITY */ + #ifndef DEFAULT_TRIM_THRESHOLD + #ifndef MORECORE_CANNOT_TRIM + #define DEFAULT_TRIM_THRESHOLD \ + ((size_t)2U * (size_t)1024U * (size_t)1024U) + #else /* MORECORE_CANNOT_TRIM */ + #define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T + #endif /* MORECORE_CANNOT_TRIM */ + #endif /* DEFAULT_TRIM_THRESHOLD */ + #ifndef DEFAULT_MMAP_THRESHOLD + #if HAVE_MMAP + #define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) + #else /* HAVE_MMAP */ + #define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T + #endif /* HAVE_MMAP */ + #endif /* DEFAULT_MMAP_THRESHOLD */ + #ifndef MAX_RELEASE_CHECK_RATE + #if HAVE_MMAP + #define MAX_RELEASE_CHECK_RATE 4095 + #else + #define MAX_RELEASE_CHECK_RATE MAX_SIZE_T + #endif /* HAVE_MMAP */ + #endif /* MAX_RELEASE_CHECK_RATE */ + #ifndef USE_BUILTIN_FFS + #define USE_BUILTIN_FFS 0 + #endif /* USE_BUILTIN_FFS */ + #ifndef USE_DEV_RANDOM + #define USE_DEV_RANDOM 0 + #endif /* USE_DEV_RANDOM */ + #ifndef NO_MALLINFO + #define NO_MALLINFO 0 + #endif /* NO_MALLINFO */ + #ifndef MALLINFO_FIELD_TYPE + #define MALLINFO_FIELD_TYPE size_t + #endif /* MALLINFO_FIELD_TYPE */ + #ifndef NO_MALLOC_STATS + #define NO_MALLOC_STATS 0 + #endif /* NO_MALLOC_STATS */ + #ifndef NO_SEGMENT_TRAVERSAL + #define NO_SEGMENT_TRAVERSAL 0 + #endif /* NO_SEGMENT_TRAVERSAL */ /* mallopt tuning options. SVID/XPG defines four standard parameter @@ -728,123 +733,128 @@ MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP malloc does support the following options. */ -#undef M_TRIM_THRESHOLD -#undef M_GRANULARITY -#undef M_MMAP_THRESHOLD -#define M_TRIM_THRESHOLD (-1) -#define M_GRANULARITY (-2) -#define M_MMAP_THRESHOLD (-3) + #undef M_TRIM_THRESHOLD + #undef M_GRANULARITY + #undef M_MMAP_THRESHOLD + #define M_TRIM_THRESHOLD (-1) + #define M_GRANULARITY (-2) + #define M_MMAP_THRESHOLD (-3) /* ------------------------ Mallinfo declarations ------------------------ */ -#if !NO_MALLINFO -/* - This version of malloc supports the standard SVID/XPG mallinfo - routine that returns a struct containing usage properties and - statistics. It should work on any system that has a - /usr/include/malloc.h defining struct mallinfo. The main - declaration needed is the mallinfo struct that is returned (by-copy) - by mallinfo(). The malloinfo struct contains a bunch of fields that - are not even meaningful in this version of malloc. These fields are - are instead filled by mallinfo() with other numbers that might be of - interest. - - HAVE_USR_INCLUDE_MALLOC_H should be set if you have a - /usr/include/malloc.h file that includes a declaration of struct - mallinfo. If so, it is included; else a compliant version is - declared below. These must be precisely the same for mallinfo() to - work. The original SVID version of this struct, defined on most - systems with mallinfo, declares all fields as ints. But some others - define as unsigned long. If your system defines the fields using a - type of different width than listed here, you MUST #include your - system version and #define HAVE_USR_INCLUDE_MALLOC_H. -*/ + #if !NO_MALLINFO + /* + This version of malloc supports the standard SVID/XPG mallinfo + routine that returns a struct containing usage properties and + statistics. It should work on any system that has a + /usr/include/malloc.h defining struct mallinfo. The main + declaration needed is the mallinfo struct that is returned (by-copy) + by mallinfo(). The malloinfo struct contains a bunch of fields that + are not even meaningful in this version of malloc. These fields are + are instead filled by mallinfo() with other numbers that might be of + interest. + + HAVE_USR_INCLUDE_MALLOC_H should be set if you have a + /usr/include/malloc.h file that includes a declaration of struct + mallinfo. If so, it is included; else a compliant version is + declared below. These must be precisely the same for mallinfo() to + work. The original SVID version of this struct, defined on most + systems with mallinfo, declares all fields as ints. But some others + define as unsigned long. If your system defines the fields using a + type of different width than listed here, you MUST #include your + system version and #define HAVE_USR_INCLUDE_MALLOC_H. + */ -/* #define HAVE_USR_INCLUDE_MALLOC_H */ + /* #define HAVE_USR_INCLUDE_MALLOC_H */ -#ifdef HAVE_USR_INCLUDE_MALLOC_H -#include "/usr/include/malloc.h" -#else /* HAVE_USR_INCLUDE_MALLOC_H */ -#ifndef STRUCT_MALLINFO_DECLARED -/* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */ -#define _STRUCT_MALLINFO -#define STRUCT_MALLINFO_DECLARED 1 + #ifdef HAVE_USR_INCLUDE_MALLOC_H + #include "/usr/include/malloc.h" + #else /* HAVE_USR_INCLUDE_MALLOC_H */ + #ifndef STRUCT_MALLINFO_DECLARED + /* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is + * defined */ + #define _STRUCT_MALLINFO + #define STRUCT_MALLINFO_DECLARED 1 struct mallinfo { - MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ - MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ - MALLINFO_FIELD_TYPE smblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblks; /* always 0 */ - MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ - MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ - MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ - MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ - MALLINFO_FIELD_TYPE fordblks; /* total free space */ - MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ + + MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ + MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ + MALLINFO_FIELD_TYPE smblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblks; /* always 0 */ + MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ + MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ + MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ + MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ + MALLINFO_FIELD_TYPE fordblks; /* total free space */ + MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ + }; -#endif /* STRUCT_MALLINFO_DECLARED */ -#endif /* HAVE_USR_INCLUDE_MALLOC_H */ -#endif /* NO_MALLINFO */ + + #endif /* STRUCT_MALLINFO_DECLARED */ + #endif /* HAVE_USR_INCLUDE_MALLOC_H */ + #endif /* NO_MALLINFO */ /* Try to persuade compilers to inline. The most critical functions for inlining are defined as macros, so these aren't used for them. */ -#ifndef FORCEINLINE - #if defined(__GNUC__) -#define FORCEINLINE __inline __attribute__ ((always_inline)) - #elif defined(_MSC_VER) - #define FORCEINLINE __forceinline + #ifndef FORCEINLINE + #if defined(__GNUC__) + #define FORCEINLINE __inline __attribute__((always_inline)) + #elif defined(_MSC_VER) + #define FORCEINLINE __forceinline + #endif #endif -#endif -#ifndef NOINLINE - #if defined(__GNUC__) - #define NOINLINE __attribute__ ((noinline)) - #elif defined(_MSC_VER) - #define NOINLINE __declspec(noinline) - #else - #define NOINLINE + #ifndef NOINLINE + #if defined(__GNUC__) + #define NOINLINE __attribute__((noinline)) + #elif defined(_MSC_VER) + #define NOINLINE __declspec(noinline) + #else + #define NOINLINE + #endif #endif -#endif -#ifdef __cplusplus + #ifdef __cplusplus extern "C" { -#ifndef FORCEINLINE - #define FORCEINLINE inline -#endif -#endif /* __cplusplus */ -#ifndef FORCEINLINE - #define FORCEINLINE -#endif - -#if !ONLY_MSPACES - -/* ------------------- Declarations of public routines ------------------- */ - -#ifndef USE_DL_PREFIX -#define dlcalloc calloc -#define dlfree free -#define dlmalloc malloc -#define dlmemalign memalign -#define dlposix_memalign posix_memalign -#define dlrealloc realloc -#define dlrealloc_in_place realloc_in_place -#define dlvalloc valloc -#define dlpvalloc pvalloc -#define dlmallinfo mallinfo -#define dlmallopt mallopt -#define dlmalloc_trim malloc_trim -#define dlmalloc_stats malloc_stats -#define dlmalloc_usable_size malloc_usable_size -#define dlmalloc_footprint malloc_footprint -#define dlmalloc_max_footprint malloc_max_footprint -#define dlmalloc_footprint_limit malloc_footprint_limit -#define dlmalloc_set_footprint_limit malloc_set_footprint_limit -#define dlmalloc_inspect_all malloc_inspect_all -#define dlindependent_calloc independent_calloc -#define dlindependent_comalloc independent_comalloc -#define dlbulk_free bulk_free -#endif /* USE_DL_PREFIX */ + + #ifndef FORCEINLINE + #define FORCEINLINE inline + #endif + #endif /* __cplusplus */ + #ifndef FORCEINLINE + #define FORCEINLINE + #endif + + #if !ONLY_MSPACES + + /* ------------------- Declarations of public routines ------------------- */ + + #ifndef USE_DL_PREFIX + #define dlcalloc calloc + #define dlfree free + #define dlmalloc malloc + #define dlmemalign memalign + #define dlposix_memalign posix_memalign + #define dlrealloc realloc + #define dlrealloc_in_place realloc_in_place + #define dlvalloc valloc + #define dlpvalloc pvalloc + #define dlmallinfo mallinfo + #define dlmallopt mallopt + #define dlmalloc_trim malloc_trim + #define dlmalloc_stats malloc_stats + #define dlmalloc_usable_size malloc_usable_size + #define dlmalloc_footprint malloc_footprint + #define dlmalloc_max_footprint malloc_max_footprint + #define dlmalloc_footprint_limit malloc_footprint_limit + #define dlmalloc_set_footprint_limit malloc_set_footprint_limit + #define dlmalloc_inspect_all malloc_inspect_all + #define dlindependent_calloc independent_calloc + #define dlindependent_comalloc independent_comalloc + #define dlbulk_free bulk_free + #endif /* USE_DL_PREFIX */ /* malloc(size_t n) @@ -860,7 +870,7 @@ extern "C" { maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t. */ -DLMALLOC_EXPORT void* dlmalloc(size_t); +DLMALLOC_EXPORT void *dlmalloc(size_t); /* free(void* p) @@ -869,14 +879,14 @@ DLMALLOC_EXPORT void* dlmalloc(size_t); It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort. */ -DLMALLOC_EXPORT void dlfree(void*); +DLMALLOC_EXPORT void dlfree(void *); /* calloc(size_t n_elements, size_t element_size); Returns a pointer to n_elements * element_size bytes, with all locations set to zero. */ -DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); +DLMALLOC_EXPORT void *dlcalloc(size_t, size_t); /* realloc(void* p, size_t n) @@ -900,7 +910,7 @@ DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); The old unix realloc convention of allowing the last-free'd chunk to be used as an argument to realloc is not supported. */ -DLMALLOC_EXPORT void* dlrealloc(void*, size_t); +DLMALLOC_EXPORT void *dlrealloc(void *, size_t); /* realloc_in_place(void* p, size_t n) @@ -915,7 +925,7 @@ DLMALLOC_EXPORT void* dlrealloc(void*, size_t); Returns p if successful; otherwise null. */ -DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); +DLMALLOC_EXPORT void *dlrealloc_in_place(void *, size_t); /* memalign(size_t alignment, size_t n); @@ -929,7 +939,7 @@ DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); Overreliance on memalign is a sure way to fragment space. */ -DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); +DLMALLOC_EXPORT void *dlmemalign(size_t, size_t); /* int posix_memalign(void** pp, size_t alignment, size_t n); @@ -939,14 +949,14 @@ DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); returns EINVAL if the alignment is not a power of two (3) fails and returns ENOMEM if memory cannot be allocated. */ -DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t); +DLMALLOC_EXPORT int dlposix_memalign(void **, size_t, size_t); /* valloc(size_t n); Equivalent to memalign(pagesize, n), where pagesize is the page size of the system. If the pagesize is unknown, 4096 is used. */ -DLMALLOC_EXPORT void* dlvalloc(size_t); +DLMALLOC_EXPORT void *dlvalloc(size_t); /* mallopt(int parameter_number, int parameter_value) @@ -1021,7 +1031,7 @@ DLMALLOC_EXPORT size_t dlmalloc_footprint_limit(); */ DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); -#if MALLOC_INSPECT_ALL + #if MALLOC_INSPECT_ALL /* malloc_inspect_all(void(*handler)(void *start, void *end, @@ -1043,19 +1053,23 @@ DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); than 1000, you could write: static int count = 0; void count_chunks(void* start, void* end, size_t used, void* arg) { + if (used >= 1000) ++count; + } + then: malloc_inspect_all(count_chunks, NULL); malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined. */ -DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), - void* arg); +DLMALLOC_EXPORT void dlmalloc_inspect_all(void (*handler)(void *, void *, + size_t, void *), + void *arg); -#endif /* MALLOC_INSPECT_ALL */ + #endif /* MALLOC_INSPECT_ALL */ -#if !NO_MALLINFO + #if !NO_MALLINFO /* mallinfo() Returns (by copy) a struct containing various summary statistics: @@ -1079,7 +1093,7 @@ DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, thus be inaccurate. */ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); -#endif /* NO_MALLINFO */ + #endif /* NO_MALLINFO */ /* independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); @@ -1117,6 +1131,7 @@ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); struct Node { int item; struct Node* next; }; struct Node* build_list() { + struct Node** pool; int n = read_number_of_nodes_needed(); if (n <= 0) return 0; @@ -1128,9 +1143,11 @@ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); pool[i]->next = pool[i+1]; free(pool); // Can now free the array (or not, if it is needed later) return first; + } + */ -DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); +DLMALLOC_EXPORT void **dlindependent_calloc(size_t, size_t, void **); /* independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); @@ -1169,6 +1186,7 @@ DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); struct Foot { ... } void send_message(char* msg) { + int msglen = strlen(msg); size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; void* chunks[3]; @@ -1178,6 +1196,7 @@ DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); char* body = (char*)(chunks[1]); struct Foot* foot = (struct Foot*)(chunks[2]); // ... + } In general though, independent_comalloc is worth using only for @@ -1188,7 +1207,7 @@ DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); since it cannot reuse existing noncontiguous small chunks that might be available for some of the elements. */ -DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); +DLMALLOC_EXPORT void **dlindependent_comalloc(size_t, size_t *, void **); /* bulk_free(void* array[], size_t n_elements) @@ -1199,14 +1218,14 @@ DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); is returned. For large arrays of pointers with poor locality, it may be worthwhile to sort this array before calling bulk_free. */ -DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements); +DLMALLOC_EXPORT size_t dlbulk_free(void **, size_t n_elements); /* pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize. */ -DLMALLOC_EXPORT void* dlpvalloc(size_t); +DLMALLOC_EXPORT void *dlpvalloc(size_t); /* malloc_trim(size_t pad); @@ -1229,7 +1248,7 @@ DLMALLOC_EXPORT void* dlpvalloc(size_t); Malloc_trim returns 1 if it actually released any memory, else 0. */ -DLMALLOC_EXPORT int dlmalloc_trim(size_t); +DLMALLOC_EXPORT int dlmalloc_trim(size_t); /* malloc_stats(); @@ -1250,7 +1269,7 @@ DLMALLOC_EXPORT int dlmalloc_trim(size_t); malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo. */ -DLMALLOC_EXPORT void dlmalloc_stats(void); +DLMALLOC_EXPORT void dlmalloc_stats(void); /* malloc_usable_size(void* p); @@ -1266,17 +1285,17 @@ DLMALLOC_EXPORT void dlmalloc_stats(void); p = malloc(n); assert(malloc_usable_size(p) >= 256); */ -size_t dlmalloc_usable_size(void*); +size_t dlmalloc_usable_size(void *); -#endif /* ONLY_MSPACES */ + #endif /* ONLY_MSPACES */ -#if MSPACES + #if MSPACES /* mspace is an opaque type representing an independent region of space that supports mspace_malloc, etc. */ -typedef void* mspace; +typedef void *mspace; /* create_mspace creates and returns a new independent space with the @@ -1308,7 +1327,8 @@ DLMALLOC_EXPORT size_t destroy_mspace(mspace msp); Destroying this space will deallocate all additionally allocated space (if possible) but not the initial base. */ -DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked); +DLMALLOC_EXPORT mspace create_mspace_with_base(void *base, size_t capacity, + int locked); /* mspace_track_large_chunks controls whether requests for large chunks @@ -1323,12 +1343,11 @@ DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int */ DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable); - /* mspace_malloc behaves as malloc, but operates within the given space. */ -DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); +DLMALLOC_EXPORT void *mspace_malloc(mspace msp, size_t bytes); /* mspace_free behaves as free, but operates within @@ -1338,7 +1357,7 @@ DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); free may be called instead of mspace_free because freed chunks from any space are handled by their originating spaces. */ -DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); +DLMALLOC_EXPORT void mspace_free(mspace msp, void *mem); /* mspace_realloc behaves as realloc, but operates within @@ -1349,33 +1368,38 @@ DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); realloced chunks from any space are handled by their originating spaces. */ -DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize); +DLMALLOC_EXPORT void *mspace_realloc(mspace msp, void *mem, size_t newsize); /* mspace_calloc behaves as calloc, but operates within the given space. */ -DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); +DLMALLOC_EXPORT void *mspace_calloc(mspace msp, size_t n_elements, + size_t elem_size); /* mspace_memalign behaves as memalign, but operates within the given space. */ -DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); +DLMALLOC_EXPORT void *mspace_memalign(mspace msp, size_t alignment, + size_t bytes); /* mspace_independent_calloc behaves as independent_calloc, but operates within the given space. */ -DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]); +DLMALLOC_EXPORT void **mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, + void * chunks[]); /* mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space. */ -DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]); +DLMALLOC_EXPORT void **mspace_independent_comalloc(mspace msp, + size_t n_elements, + size_t sizes[], + void * chunks[]); /* mspace_footprint() returns the number of bytes obtained from the @@ -1389,19 +1413,18 @@ DLMALLOC_EXPORT size_t mspace_footprint(mspace msp); */ DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp); - -#if !NO_MALLINFO + #if !NO_MALLINFO /* mspace_mallinfo behaves as mallinfo, but reports properties of the given space. */ DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp); -#endif /* NO_MALLINFO */ + #endif /* NO_MALLINFO */ /* malloc_usable_size(void* p) behaves the same as malloc_usable_size; */ -DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem); +DLMALLOC_EXPORT size_t mspace_usable_size(const void *mem); /* mspace_malloc_stats behaves as malloc_stats, but reports @@ -1420,11 +1443,13 @@ DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad); */ DLMALLOC_EXPORT int mspace_mallopt(int, int); -#endif /* MSPACES */ + #endif /* MSPACES */ -#ifdef __cplusplus -} /* end of extern "C" */ -#endif /* __cplusplus */ + #ifdef __cplusplus + +} /* end of extern "C" */ + + #endif /* __cplusplus */ /* ======================================================================== @@ -1438,392 +1463,413 @@ DLMALLOC_EXPORT int mspace_mallopt(int, int); /*------------------------------ internal #includes ---------------------- */ -#ifdef _MSC_VER -#pragma warning( disable : 4146 ) /* no "unsigned" warnings */ -#endif /* _MSC_VER */ -#if !NO_MALLOC_STATS -#include /* for printing in malloc_stats */ -#endif /* NO_MALLOC_STATS */ -#ifndef LACKS_ERRNO_H -#include /* for MALLOC_FAILURE_ACTION */ -#endif /* LACKS_ERRNO_H */ -#ifdef DEBUG -#if ABORT_ON_ASSERT_FAILURE -#undef assert -#define assert(x) if(!(x)) ABORT -#else /* ABORT_ON_ASSERT_FAILURE */ -#include -#endif /* ABORT_ON_ASSERT_FAILURE */ -#else /* DEBUG */ -#ifndef assert -#define assert(x) -#endif -#define DEBUG 0 -#endif /* DEBUG */ -#if !defined(WIN32) && !defined(LACKS_TIME_H) -#include /* for magic initialization */ -#endif /* WIN32 */ -#ifndef LACKS_STDLIB_H -#include /* for abort() */ -#endif /* LACKS_STDLIB_H */ -#ifndef LACKS_STRING_H -#include /* for memset etc */ -#endif /* LACKS_STRING_H */ -#if USE_BUILTIN_FFS -#ifndef LACKS_STRINGS_H -#include /* for ffs */ -#endif /* LACKS_STRINGS_H */ -#endif /* USE_BUILTIN_FFS */ -#if HAVE_MMAP -#ifndef LACKS_SYS_MMAN_H -/* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ -#if (defined(linux) && !defined(__USE_GNU)) -#define __USE_GNU 1 -#include /* for mmap */ -#undef __USE_GNU -#else -#include /* for mmap */ -#endif /* linux */ -#endif /* LACKS_SYS_MMAN_H */ -#ifndef LACKS_FCNTL_H -#include -#endif /* LACKS_FCNTL_H */ -#endif /* HAVE_MMAP */ -#ifndef LACKS_UNISTD_H -#include /* for sbrk, sysconf */ -#else /* LACKS_UNISTD_H */ -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) -extern void* sbrk(ptrdiff_t); -#endif /* FreeBSD etc */ -#endif /* LACKS_UNISTD_H */ - -/* Declarations for locking */ -#if USE_LOCKS -#ifndef WIN32 -#if defined (__SVR4) && defined (__sun) /* solaris */ -#include -#elif !defined(LACKS_SCHED_H) -#include -#endif /* solaris or LACKS_SCHED_H */ -#if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS -#include -#endif /* USE_RECURSIVE_LOCKS ... */ -#elif defined(_MSC_VER) -#ifndef _M_AMD64 -/* These are already defined on AMD64 builds */ -#ifdef __cplusplus + #ifdef _MSC_VER + #pragma warning(disable : 4146) /* no "unsigned" warnings */ + #endif /* _MSC_VER */ + #if !NO_MALLOC_STATS + #include /* for printing in malloc_stats */ + #endif /* NO_MALLOC_STATS */ + #ifndef LACKS_ERRNO_H + #include /* for MALLOC_FAILURE_ACTION */ + #endif /* LACKS_ERRNO_H */ + #ifdef DEBUG + #if ABORT_ON_ASSERT_FAILURE + #undef assert + #define assert(x) \ + if (!(x)) ABORT + #else /* ABORT_ON_ASSERT_FAILURE */ + #include + #endif /* ABORT_ON_ASSERT_FAILURE */ + #else /* DEBUG */ + #ifndef assert + #define assert(x) + #endif + #define DEBUG 0 + #endif /* DEBUG */ + #if !defined(WIN32) && !defined(LACKS_TIME_H) + #include /* for magic initialization */ + #endif /* WIN32 */ + #ifndef LACKS_STDLIB_H + #include /* for abort() */ + #endif /* LACKS_STDLIB_H */ + #ifndef LACKS_STRING_H + #include /* for memset etc */ + #endif /* LACKS_STRING_H */ + #if USE_BUILTIN_FFS + #ifndef LACKS_STRINGS_H + #include /* for ffs */ + #endif /* LACKS_STRINGS_H */ + #endif /* USE_BUILTIN_FFS */ + #if HAVE_MMAP + #ifndef LACKS_SYS_MMAN_H + /* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ + #if (defined(linux) && !defined(__USE_GNU)) + #define __USE_GNU 1 + #include /* for mmap */ + #undef __USE_GNU + #else + #include /* for mmap */ + #endif /* linux */ + #endif /* LACKS_SYS_MMAN_H */ + #ifndef LACKS_FCNTL_H + #include + #endif /* LACKS_FCNTL_H */ + #endif /* HAVE_MMAP */ + #ifndef LACKS_UNISTD_H + #include /* for sbrk, sysconf */ + #else /* LACKS_UNISTD_H */ + #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) +extern void *sbrk(ptrdiff_t); + #endif /* FreeBSD etc */ + #endif /* LACKS_UNISTD_H */ + + /* Declarations for locking */ + #if USE_LOCKS + #ifndef WIN32 + #if defined(__SVR4) && defined(__sun) /* solaris */ + #include + #elif !defined(LACKS_SCHED_H) + #include + #endif /* solaris or LACKS_SCHED_H */ + #if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || \ + !USE_SPIN_LOCKS + #include + #endif /* USE_RECURSIVE_LOCKS ... */ + #elif defined(_MSC_VER) + #ifndef _M_AMD64 + /* These are already defined on AMD64 builds */ + #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ -LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp); + + #endif /* __cplusplus */ +LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, + LONG Comp); LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value); -#ifdef __cplusplus + #ifdef __cplusplus + } -#endif /* __cplusplus */ -#endif /* _M_AMD64 */ -#pragma intrinsic (_InterlockedCompareExchange) -#pragma intrinsic (_InterlockedExchange) -#define interlockedcompareexchange _InterlockedCompareExchange -#define interlockedexchange _InterlockedExchange -#elif defined(WIN32) && defined(__GNUC__) -#define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b) -#define interlockedexchange __sync_lock_test_and_set -#endif /* Win32 */ -#else /* USE_LOCKS */ -#endif /* USE_LOCKS */ - -#ifndef LOCK_AT_FORK -#define LOCK_AT_FORK 0 -#endif - -/* Declarations for bit scanning on win32 */ -#if defined(_MSC_VER) && _MSC_VER>=1300 -#ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ -#ifdef __cplusplus + + #endif /* __cplusplus */ + #endif /* _M_AMD64 */ + #pragma intrinsic(_InterlockedCompareExchange) + #pragma intrinsic(_InterlockedExchange) + #define interlockedcompareexchange _InterlockedCompareExchange + #define interlockedexchange _InterlockedExchange + #elif defined(WIN32) && defined(__GNUC__) + #define interlockedcompareexchange(a, b, c) \ + __sync_val_compare_and_swap(a, c, b) + #define interlockedexchange __sync_lock_test_and_set + #endif /* Win32 */ + #else /* USE_LOCKS */ + #endif /* USE_LOCKS */ + + #ifndef LOCK_AT_FORK + #define LOCK_AT_FORK 0 + #endif + + /* Declarations for bit scanning on win32 */ + #if defined(_MSC_VER) && _MSC_VER >= 1300 + #ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ + #ifdef __cplusplus extern "C" { -#endif /* __cplusplus */ + + #endif /* __cplusplus */ unsigned char _BitScanForward(unsigned long *index, unsigned long mask); unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); -#ifdef __cplusplus + #ifdef __cplusplus + } -#endif /* __cplusplus */ - -#define BitScanForward _BitScanForward -#define BitScanReverse _BitScanReverse -#pragma intrinsic(_BitScanForward) -#pragma intrinsic(_BitScanReverse) -#endif /* BitScanForward */ -#endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ - -#ifndef WIN32 -#ifndef malloc_getpagesize -# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ -# ifndef _SC_PAGE_SIZE -# define _SC_PAGE_SIZE _SC_PAGESIZE -# endif -# endif -# ifdef _SC_PAGE_SIZE -# define malloc_getpagesize sysconf(_SC_PAGE_SIZE) -# else -# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) - extern size_t getpagesize(); -# define malloc_getpagesize getpagesize() -# else -# ifdef WIN32 /* use supplied emulation of getpagesize */ -# define malloc_getpagesize getpagesize() -# else -# ifndef LACKS_SYS_PARAM_H -# include -# endif -# ifdef EXEC_PAGESIZE -# define malloc_getpagesize EXEC_PAGESIZE -# else -# ifdef NBPG -# ifndef CLSIZE -# define malloc_getpagesize NBPG -# else -# define malloc_getpagesize (NBPG * CLSIZE) -# endif -# else -# ifdef NBPC -# define malloc_getpagesize NBPC -# else -# ifdef PAGESIZE -# define malloc_getpagesize PAGESIZE -# else /* just guess */ -# define malloc_getpagesize ((size_t)4096U) -# endif -# endif -# endif -# endif -# endif -# endif -# endif -#endif -#endif - -/* ------------------- size_t and alignment properties -------------------- */ - -/* The byte and bit size of a size_t */ -#define SIZE_T_SIZE (sizeof(size_t)) -#define SIZE_T_BITSIZE (sizeof(size_t) << 3) - -/* Some constants coerced to size_t */ -/* Annoying but necessary to avoid errors on some platforms */ -#define SIZE_T_ZERO ((size_t)0) -#define SIZE_T_ONE ((size_t)1) -#define SIZE_T_TWO ((size_t)2) -#define SIZE_T_FOUR ((size_t)4) -#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) -#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) -#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) -#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) - -/* The bit mask value corresponding to MALLOC_ALIGNMENT */ -#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) - -/* True if address a has acceptable alignment */ -#define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) - -/* the number of bytes to offset an address to align it */ -#define align_offset(A)\ - ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ - ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) - -/* -------------------------- MMAP preliminaries ------------------------- */ -/* - If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and - checks to fail so compiler optimizer can delete code rather than - using so many "#if"s. -*/ + #endif /* __cplusplus */ + + #define BitScanForward _BitScanForward + #define BitScanReverse _BitScanReverse + #pragma intrinsic(_BitScanForward) + #pragma intrinsic(_BitScanReverse) + #endif /* BitScanForward */ + #endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ + + #ifndef WIN32 + #ifndef malloc_getpagesize + #ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ + #ifndef _SC_PAGE_SIZE + #define _SC_PAGE_SIZE _SC_PAGESIZE + #endif + #endif + #ifdef _SC_PAGE_SIZE + #define malloc_getpagesize sysconf(_SC_PAGE_SIZE) + #else + #if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) +extern size_t getpagesize(); + #define malloc_getpagesize getpagesize() + #else + #ifdef WIN32 /* use supplied emulation of getpagesize */ + #define malloc_getpagesize getpagesize() + #else + #ifndef LACKS_SYS_PARAM_H + #include + #endif + #ifdef EXEC_PAGESIZE + #define malloc_getpagesize EXEC_PAGESIZE + #else + #ifdef NBPG + #ifndef CLSIZE + #define malloc_getpagesize NBPG + #else + #define malloc_getpagesize (NBPG * CLSIZE) + #endif + #else + #ifdef NBPC + #define malloc_getpagesize NBPC + #else + #ifdef PAGESIZE + #define malloc_getpagesize PAGESIZE + #else /* just guess */ + #define malloc_getpagesize ((size_t)4096U) + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif + #endif + + /* ------------------- size_t and alignment properties -------------------- */ + + /* The byte and bit size of a size_t */ + #define SIZE_T_SIZE (sizeof(size_t)) + #define SIZE_T_BITSIZE (sizeof(size_t) << 3) + + /* Some constants coerced to size_t */ + /* Annoying but necessary to avoid errors on some platforms */ + #define SIZE_T_ZERO ((size_t)0) + #define SIZE_T_ONE ((size_t)1) + #define SIZE_T_TWO ((size_t)2) + #define SIZE_T_FOUR ((size_t)4) + #define TWO_SIZE_T_SIZES (SIZE_T_SIZE << 1) + #define FOUR_SIZE_T_SIZES (SIZE_T_SIZE << 2) + #define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES + TWO_SIZE_T_SIZES) + #define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) + + /* The bit mask value corresponding to MALLOC_ALIGNMENT */ + #define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) + + /* True if address a has acceptable alignment */ + #define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) + + /* the number of bytes to offset an address to align it */ + #define align_offset(A) \ + ((((size_t)(A)&CHUNK_ALIGN_MASK) == 0) \ + ? 0 \ + : ((MALLOC_ALIGNMENT - ((size_t)(A)&CHUNK_ALIGN_MASK)) & \ + CHUNK_ALIGN_MASK)) + + /* -------------------------- MMAP preliminaries ------------------------- */ + + /* + If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and + checks to fail so compiler optimizer can delete code rather than + using so many "#if"s. + */ + /* MORECORE and MMAP must return MFAIL on failure */ + #define MFAIL ((void *)(MAX_SIZE_T)) + #define CMFAIL ((char *)(MFAIL)) /* defined for convenience */ -/* MORECORE and MMAP must return MFAIL on failure */ -#define MFAIL ((void*)(MAX_SIZE_T)) -#define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ + #if HAVE_MMAP -#if HAVE_MMAP + #ifndef WIN32 + #define MMAP_PROT (PROT_READ | PROT_WRITE) + #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) + #define MAP_ANONYMOUS MAP_ANON + #endif /* MAP_ANON */ + #ifdef MAP_ANONYMOUS -#ifndef WIN32 -#define MMAP_PROT (PROT_READ|PROT_WRITE) -#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -#define MAP_ANONYMOUS MAP_ANON -#endif /* MAP_ANON */ -#ifdef MAP_ANONYMOUS + #define MMAP_FLAGS (MAP_PRIVATE | MAP_ANONYMOUS) -#define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) +static FORCEINLINE void *unixmmap(size_t size) { -static FORCEINLINE void* unixmmap(size_t size) { - void* result; + void *result; result = mmap(0, size, MMAP_PROT, MMAP_FLAGS, -1, 0); - if (result == MFAIL) - return MFAIL; + if (result == MFAIL) return MFAIL; return result; + } -static FORCEINLINE int unixmunmap(void* ptr, size_t size) { +static FORCEINLINE int unixmunmap(void *ptr, size_t size) { + int result; result = munmap(ptr, size); - if (result != 0) - return result; + if (result != 0) return result; return result; + } -#define MMAP_DEFAULT(s) unixmmap(s) -#define MUNMAP_DEFAULT(a, s) unixmunmap((a), (s)) + #define MMAP_DEFAULT(s) unixmmap(s) + #define MUNMAP_DEFAULT(a, s) unixmunmap((a), (s)) -#else /* MAP_ANONYMOUS */ -/* - Nearly all versions of mmap support MAP_ANONYMOUS, so the following - is unlikely to be needed, but is supplied just in case. -*/ -#define MMAP_FLAGS (MAP_PRIVATE) -static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ -#define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \ - (dev_zero_fd = open("/dev/zero", O_RDWR), \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ - mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) -#define MUNMAP_DEFAULT(a, s) munmap((a), (s)) -#endif /* MAP_ANONYMOUS */ + #else /* MAP_ANONYMOUS */ + /* + Nearly all versions of mmap support MAP_ANONYMOUS, so the following + is unlikely to be needed, but is supplied just in case. + */ + #define MMAP_FLAGS (MAP_PRIVATE) +static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ + #define MMAP_DEFAULT(s) \ + ((dev_zero_fd < 0) \ + ? (dev_zero_fd = open("/dev/zero", O_RDWR), \ + mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) \ + : mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) + #define MUNMAP_DEFAULT(a, s) munmap((a), (s)) + #endif /* MAP_ANONYMOUS */ -#define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) + #define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) -#else /* WIN32 */ + #else /* WIN32 */ /* Win32 MMAP via VirtualAlloc */ -static FORCEINLINE void* win32mmap(size_t size) { - void* ptr; +static FORCEINLINE void *win32mmap(size_t size) { + + void *ptr; - ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); - if (ptr == 0) - return MFAIL; + ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); + if (ptr == 0) return MFAIL; return ptr; + } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ -static FORCEINLINE void* win32direct_mmap(size_t size) { - void* ptr; +static FORCEINLINE void *win32direct_mmap(size_t size) { + + void *ptr; - ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, - PAGE_READWRITE); - if (ptr == 0) - return MFAIL; + ptr = VirtualAlloc(0, size, MEM_RESERVE | MEM_COMMIT | MEM_TOP_DOWN, + PAGE_READWRITE); + if (ptr == 0) return MFAIL; return ptr; + } /* This function supports releasing coalesed segments */ -static FORCEINLINE int win32munmap(void* ptr, size_t size) { +static FORCEINLINE int win32munmap(void *ptr, size_t size) { + MEMORY_BASIC_INFORMATION minfo; - char* cptr = (char*)ptr; + char *cptr = (char *)ptr; while (size) { - if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) - return -1; + + if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) return -1; if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || minfo.State != MEM_COMMIT || minfo.RegionSize > size) return -1; - if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) - return -1; + if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) return -1; cptr += minfo.RegionSize; size -= minfo.RegionSize; + } return 0; + } -#define MMAP_DEFAULT(s) win32mmap(s) -#define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) -#define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) -#endif /* WIN32 */ -#endif /* HAVE_MMAP */ + #define MMAP_DEFAULT(s) win32mmap(s) + #define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) + #define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) + #endif /* WIN32 */ + #endif /* HAVE_MMAP */ + + #if HAVE_MREMAP + #ifndef WIN32 -#if HAVE_MREMAP -#ifndef WIN32 +static FORCEINLINE void *dlmremap(void *old_address, size_t old_size, + size_t new_size, int flags) { -static FORCEINLINE void* dlmremap(void* old_address, size_t old_size, size_t new_size, int flags) { - void* result; + void *result; result = mremap(old_address, old_size, new_size, flags); - if (result == MFAIL) - return MFAIL; + if (result == MFAIL) return MFAIL; return result; + } -#define MREMAP_DEFAULT(addr, osz, nsz, mv) dlmremap((addr), (osz), (nsz), (mv)) -#endif /* WIN32 */ -#endif /* HAVE_MREMAP */ + #define MREMAP_DEFAULT(addr, osz, nsz, mv) \ + dlmremap((addr), (osz), (nsz), (mv)) + #endif /* WIN32 */ + #endif /* HAVE_MREMAP */ -/** - * Define CALL_MORECORE - */ -#if HAVE_MORECORE + /** + * Define CALL_MORECORE + */ + #if HAVE_MORECORE #ifdef MORECORE - #define CALL_MORECORE(S) MORECORE(S) - #else /* MORECORE */ - #define CALL_MORECORE(S) MORECORE_DEFAULT(S) - #endif /* MORECORE */ -#else /* HAVE_MORECORE */ - #define CALL_MORECORE(S) MFAIL -#endif /* HAVE_MORECORE */ - -/** - * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP - */ -#if HAVE_MMAP - #define USE_MMAP_BIT (SIZE_T_ONE) + #define CALL_MORECORE(S) MORECORE(S) + #else /* MORECORE */ + #define CALL_MORECORE(S) MORECORE_DEFAULT(S) + #endif /* MORECORE */ + #else /* HAVE_MORECORE */ + #define CALL_MORECORE(S) MFAIL + #endif /* HAVE_MORECORE */ + + /** + * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP + */ + #if HAVE_MMAP + #define USE_MMAP_BIT (SIZE_T_ONE) #ifdef MMAP - #define CALL_MMAP(s) MMAP(s) - #else /* MMAP */ - #define CALL_MMAP(s) MMAP_DEFAULT(s) - #endif /* MMAP */ + #define CALL_MMAP(s) MMAP(s) + #else /* MMAP */ + #define CALL_MMAP(s) MMAP_DEFAULT(s) + #endif /* MMAP */ #ifdef MUNMAP - #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) - #else /* MUNMAP */ - #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) - #endif /* MUNMAP */ + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) + #else /* MUNMAP */ + #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) + #endif /* MUNMAP */ #ifdef DIRECT_MMAP - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) - #else /* DIRECT_MMAP */ - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) - #endif /* DIRECT_MMAP */ -#else /* HAVE_MMAP */ - #define USE_MMAP_BIT (SIZE_T_ZERO) - - #define MMAP(s) MFAIL - #define MUNMAP(a, s) (-1) - #define DIRECT_MMAP(s) MFAIL - #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) - #define CALL_MMAP(s) MMAP(s) - #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) -#endif /* HAVE_MMAP */ - -/** - * Define CALL_MREMAP - */ -#if HAVE_MMAP && HAVE_MREMAP + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #else /* DIRECT_MMAP */ + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) + #endif /* DIRECT_MMAP */ + #else /* HAVE_MMAP */ + #define USE_MMAP_BIT (SIZE_T_ZERO) + + #define MMAP(s) MFAIL + #define MUNMAP(a, s) (-1) + #define DIRECT_MMAP(s) MFAIL + #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) + #define CALL_MMAP(s) MMAP(s) + #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) + #endif /* HAVE_MMAP */ + + /** + * Define CALL_MREMAP + */ + #if HAVE_MMAP && HAVE_MREMAP #ifdef MREMAP - #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) - #else /* MREMAP */ - #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) - #endif /* MREMAP */ -#else /* HAVE_MMAP && HAVE_MREMAP */ - #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL -#endif /* HAVE_MMAP && HAVE_MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) + #else /* MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) \ + MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) + #endif /* MREMAP */ + #else /* HAVE_MMAP && HAVE_MREMAP */ + #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL + #endif /* HAVE_MMAP && HAVE_MREMAP */ -/* mstate bit set if continguous morecore disabled or failed */ -#define USE_NONCONTIGUOUS_BIT (4U) - -/* segment bit set in create_mspace_with_base */ -#define EXTERN_BIT (8U) + /* mstate bit set if continguous morecore disabled or failed */ + #define USE_NONCONTIGUOUS_BIT (4U) + /* segment bit set in create_mspace_with_base */ + #define EXTERN_BIT (8U) /* --------------------------- Lock preliminaries ------------------------ */ @@ -1855,248 +1901,286 @@ static FORCEINLINE void* dlmremap(void* old_address, size_t old_size, size_t new */ -#if !USE_LOCKS -#define USE_LOCK_BIT (0U) -#define INITIAL_LOCK(l) (0) -#define DESTROY_LOCK(l) (0) -#define ACQUIRE_MALLOC_GLOBAL_LOCK() -#define RELEASE_MALLOC_GLOBAL_LOCK() - -#else -#if USE_LOCKS > 1 -/* ----------------------- User-defined locks ------------------------ */ -/* Define your own lock implementation here */ -/* #define INITIAL_LOCK(lk) ... */ -/* #define DESTROY_LOCK(lk) ... */ -/* #define ACQUIRE_LOCK(lk) ... */ -/* #define RELEASE_LOCK(lk) ... */ -/* #define TRY_LOCK(lk) ... */ -/* static MLOCK_T malloc_global_mutex = ... */ - -#elif USE_SPIN_LOCKS - -/* First, define CAS_LOCK and CLEAR_LOCK on ints */ -/* Note CAS_LOCK defined to return 0 on success */ - -#if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) -#define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) -#define CLEAR_LOCK(sl) __sync_lock_release(sl) - -#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) + #if !USE_LOCKS + #define USE_LOCK_BIT (0U) + #define INITIAL_LOCK(l) (0) + #define DESTROY_LOCK(l) (0) + #define ACQUIRE_MALLOC_GLOBAL_LOCK() + #define RELEASE_MALLOC_GLOBAL_LOCK() + + #else + #if USE_LOCKS > 1 + /* ----------------------- User-defined locks ------------------------ */ + /* Define your own lock implementation here */ + /* #define INITIAL_LOCK(lk) ... */ + /* #define DESTROY_LOCK(lk) ... */ + /* #define ACQUIRE_LOCK(lk) ... */ + /* #define RELEASE_LOCK(lk) ... */ + /* #define TRY_LOCK(lk) ... */ + /* static MLOCK_T malloc_global_mutex = ... */ + + #elif USE_SPIN_LOCKS + + /* First, define CAS_LOCK and CLEAR_LOCK on ints */ + /* Note CAS_LOCK defined to return 0 on success */ + + #if defined(__GNUC__) && \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) + #define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) + #define CLEAR_LOCK(sl) __sync_lock_release(sl) + + #elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) /* Custom spin locks for older gcc on x86 */ static FORCEINLINE int x86_cas_lock(int *sl) { + int ret; int val = 1; int cmp = 0; - __asm__ __volatile__ ("lock; cmpxchgl %1, %2" - : "=a" (ret) - : "r" (val), "m" (*(sl)), "0"(cmp) - : "memory", "cc"); + __asm__ __volatile__("lock; cmpxchgl %1, %2" + : "=a"(ret) + : "r"(val), "m"(*(sl)), "0"(cmp) + : "memory", "cc"); return ret; + } -static FORCEINLINE void x86_clear_lock(int* sl) { +static FORCEINLINE void x86_clear_lock(int *sl) { + assert(*sl != 0); int prev = 0; int ret; - __asm__ __volatile__ ("lock; xchgl %0, %1" - : "=r" (ret) - : "m" (*(sl)), "0"(prev) - : "memory"); + __asm__ __volatile__("lock; xchgl %0, %1" + : "=r"(ret) + : "m"(*(sl)), "0"(prev) + : "memory"); + } -#define CAS_LOCK(sl) x86_cas_lock(sl) -#define CLEAR_LOCK(sl) x86_clear_lock(sl) - -#else /* Win32 MSC */ -#define CAS_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)1) -#define CLEAR_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)0) - -#endif /* ... gcc spins locks ... */ - -/* How to yield for a spin lock */ -#define SPINS_PER_YIELD 63 -#if defined(_MSC_VER) -#define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ -#define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) -#elif defined (__SVR4) && defined (__sun) /* solaris */ -#define SPIN_LOCK_YIELD thr_yield(); -#elif !defined(LACKS_SCHED_H) -#define SPIN_LOCK_YIELD sched_yield(); -#else -#define SPIN_LOCK_YIELD -#endif /* ... yield ... */ - -#if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 + #define CAS_LOCK(sl) x86_cas_lock(sl) + #define CLEAR_LOCK(sl) x86_clear_lock(sl) + + #else /* Win32 MSC */ + #define CAS_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)1) + #define CLEAR_LOCK(sl) interlockedexchange((volatile LONG *)sl, (LONG)0) + + #endif /* ... gcc spins locks ... */ + + /* How to yield for a spin lock */ + #define SPINS_PER_YIELD 63 + #if defined(_MSC_VER) + #define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ + #define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) + #elif defined(__SVR4) && defined(__sun) /* solaris */ + #define SPIN_LOCK_YIELD thr_yield(); + #elif !defined(LACKS_SCHED_H) + #define SPIN_LOCK_YIELD sched_yield(); + #else + #define SPIN_LOCK_YIELD + #endif /* ... yield ... */ + + #if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 /* Plain spin locks use single word (embedded in malloc_states) */ static int spin_acquire_lock(int *sl) { + int spins = 0; while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) { - if ((++spins & SPINS_PER_YIELD) == 0) { - SPIN_LOCK_YIELD; - } + + if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } + } + return 0; + } -#define MLOCK_T int -#define TRY_LOCK(sl) !CAS_LOCK(sl) -#define RELEASE_LOCK(sl) CLEAR_LOCK(sl) -#define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0) -#define INITIAL_LOCK(sl) (*sl = 0) -#define DESTROY_LOCK(sl) (0) + #define MLOCK_T int + #define TRY_LOCK(sl) !CAS_LOCK(sl) + #define RELEASE_LOCK(sl) CLEAR_LOCK(sl) + #define ACQUIRE_LOCK(sl) (CAS_LOCK(sl) ? spin_acquire_lock(sl) : 0) + #define INITIAL_LOCK(sl) (*sl = 0) + #define DESTROY_LOCK(sl) (0) static MLOCK_T malloc_global_mutex = 0; -#else /* USE_RECURSIVE_LOCKS */ -/* types for lock owners */ -#ifdef WIN32 -#define THREAD_ID_T DWORD -#define CURRENT_THREAD GetCurrentThreadId() -#define EQ_OWNER(X,Y) ((X) == (Y)) -#else -/* - Note: the following assume that pthread_t is a type that can be - initialized to (casted) zero. If this is not the case, you will need to - somehow redefine these or not use spin locks. -*/ -#define THREAD_ID_T pthread_t -#define CURRENT_THREAD pthread_self() -#define EQ_OWNER(X,Y) pthread_equal(X, Y) -#endif + #else /* USE_RECURSIVE_LOCKS */ + /* types for lock owners */ + #ifdef WIN32 + #define THREAD_ID_T DWORD + #define CURRENT_THREAD GetCurrentThreadId() + #define EQ_OWNER(X, Y) ((X) == (Y)) + #else + /* + Note: the following assume that pthread_t is a type that can be + initialized to (casted) zero. If this is not the case, you will need + to somehow redefine these or not use spin locks. + */ + #define THREAD_ID_T pthread_t + #define CURRENT_THREAD pthread_self() + #define EQ_OWNER(X, Y) pthread_equal(X, Y) + #endif struct malloc_recursive_lock { - int sl; + + int sl; unsigned int c; - THREAD_ID_T threadid; + THREAD_ID_T threadid; + }; -#define MLOCK_T struct malloc_recursive_lock -static MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0}; + #define MLOCK_T struct malloc_recursive_lock +static MLOCK_T malloc_global_mutex = {0, 0, (THREAD_ID_T)0}; static FORCEINLINE void recursive_release_lock(MLOCK_T *lk) { + assert(lk->sl != 0); - if (--lk->c == 0) { - CLEAR_LOCK(&lk->sl); - } + if (--lk->c == 0) { CLEAR_LOCK(&lk->sl); } + } static FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) { + THREAD_ID_T mythreadid = CURRENT_THREAD; - int spins = 0; + int spins = 0; for (;;) { + if (*((volatile int *)(&lk->sl)) == 0) { + if (!CAS_LOCK(&lk->sl)) { + lk->threadid = mythreadid; lk->c = 1; return 0; + } - } - else if (EQ_OWNER(lk->threadid, mythreadid)) { + + } else if (EQ_OWNER(lk->threadid, mythreadid)) { + ++lk->c; return 0; + } - if ((++spins & SPINS_PER_YIELD) == 0) { - SPIN_LOCK_YIELD; - } + + if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } + } + } static FORCEINLINE int recursive_try_lock(MLOCK_T *lk) { + THREAD_ID_T mythreadid = CURRENT_THREAD; if (*((volatile int *)(&lk->sl)) == 0) { + if (!CAS_LOCK(&lk->sl)) { + lk->threadid = mythreadid; lk->c = 1; return 1; + } - } - else if (EQ_OWNER(lk->threadid, mythreadid)) { + + } else if (EQ_OWNER(lk->threadid, mythreadid)) { + ++lk->c; return 1; + } + return 0; + } -#define RELEASE_LOCK(lk) recursive_release_lock(lk) -#define TRY_LOCK(lk) recursive_try_lock(lk) -#define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) -#define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) -#define DESTROY_LOCK(lk) (0) -#endif /* USE_RECURSIVE_LOCKS */ - -#elif defined(WIN32) /* Win32 critical sections */ -#define MLOCK_T CRITICAL_SECTION -#define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) -#define RELEASE_LOCK(lk) LeaveCriticalSection(lk) -#define TRY_LOCK(lk) TryEnterCriticalSection(lk) -#define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000)) -#define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) -#define NEED_GLOBAL_LOCK_INIT - -static MLOCK_T malloc_global_mutex; + #define RELEASE_LOCK(lk) recursive_release_lock(lk) + #define TRY_LOCK(lk) recursive_try_lock(lk) + #define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) + #define INITIAL_LOCK(lk) \ + ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) + #define DESTROY_LOCK(lk) (0) + #endif /* USE_RECURSIVE_LOCKS */ + + #elif defined(WIN32) /* Win32 critical sections */ + #define MLOCK_T CRITICAL_SECTION + #define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) + #define RELEASE_LOCK(lk) LeaveCriticalSection(lk) + #define TRY_LOCK(lk) TryEnterCriticalSection(lk) + #define INITIAL_LOCK(lk) \ + (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000 | 4000)) + #define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) + #define NEED_GLOBAL_LOCK_INIT + +static MLOCK_T malloc_global_mutex; static volatile LONG malloc_global_mutex_status; /* Use spin loop to initialize global lock */ static void init_malloc_global_mutex() { + for (;;) { + long stat = malloc_global_mutex_status; - if (stat > 0) - return; + if (stat > 0) return; /* transition to < 0 while initializing, then to > 0) */ - if (stat == 0 && - interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) { + if (stat == 0 && interlockedcompareexchange(&malloc_global_mutex_status, + (LONG)-1, (LONG)0) == 0) { + InitializeCriticalSection(&malloc_global_mutex); interlockedexchange(&malloc_global_mutex_status, (LONG)1); return; + } + SleepEx(0, FALSE); + } + } -#else /* pthreads-based locks */ -#define MLOCK_T pthread_mutex_t -#define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) -#define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) -#define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) -#define INITIAL_LOCK(lk) pthread_init_lock(lk) -#define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) + #else /* pthreads-based locks */ + #define MLOCK_T pthread_mutex_t + #define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) + #define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) + #define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) + #define INITIAL_LOCK(lk) pthread_init_lock(lk) + #define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) -#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) + #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && \ + defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) /* Cope with old-style linux recursive lock initialization by adding */ /* skipped internal declaration from pthread.h */ -extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, - int __kind)); -#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP -#define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) -#endif /* USE_RECURSIVE_LOCKS ... */ +extern int pthread_mutexattr_setkind_np __P((pthread_mutexattr_t * __attr, + int __kind)); + #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP + #define pthread_mutexattr_settype(x, y) \ + pthread_mutexattr_setkind_np(x, y) + #endif /* USE_RECURSIVE_LOCKS ... */ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER; -static int pthread_init_lock (MLOCK_T *lk) { +static int pthread_init_lock(MLOCK_T *lk) { + pthread_mutexattr_t attr; if (pthread_mutexattr_init(&attr)) return 1; -#if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 + #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; -#endif + #endif if (pthread_mutex_init(lk, &attr)) return 1; if (pthread_mutexattr_destroy(&attr)) return 1; return 0; + } -#endif /* ... lock types ... */ + #endif /* ... lock types ... */ -/* Common code for all lock types */ -#define USE_LOCK_BIT (2U) + /* Common code for all lock types */ + #define USE_LOCK_BIT (2U) -#ifndef ACQUIRE_MALLOC_GLOBAL_LOCK -#define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); -#endif + #ifndef ACQUIRE_MALLOC_GLOBAL_LOCK + #define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); + #endif -#ifndef RELEASE_MALLOC_GLOBAL_LOCK -#define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); -#endif + #ifndef RELEASE_MALLOC_GLOBAL_LOCK + #define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); + #endif -#endif /* USE_LOCKS */ + #endif /* USE_LOCKS */ /* ----------------------- Chunk representations ------------------------ */ @@ -2236,56 +2320,56 @@ static int pthread_init_lock (MLOCK_T *lk) { */ struct malloc_chunk { - size_t prev_foot; /* Size of previous chunk (if free). */ - size_t head; /* Size and inuse bits. */ - struct malloc_chunk* fd; /* double links -- used only if free. */ - struct malloc_chunk* bk; + + size_t prev_foot; /* Size of previous chunk (if free). */ + size_t head; /* Size and inuse bits. */ + struct malloc_chunk *fd; /* double links -- used only if free. */ + struct malloc_chunk *bk; + }; typedef struct malloc_chunk mchunk; -typedef struct malloc_chunk* mchunkptr; -typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ -typedef unsigned int bindex_t; /* Described below */ -typedef unsigned int binmap_t; /* Described below */ -typedef unsigned int flag_t; /* The type of various bit flag sets */ +typedef struct malloc_chunk *mchunkptr; +typedef struct malloc_chunk *sbinptr; /* The type of bins of chunks */ +typedef unsigned int bindex_t; /* Described below */ +typedef unsigned int binmap_t; /* Described below */ +typedef unsigned int flag_t; /* The type of various bit flag sets */ /* ------------------- Chunks sizes and alignments ----------------------- */ -#define MCHUNK_SIZE (sizeof(mchunk)) + #define MCHUNK_SIZE (sizeof(mchunk)) -#if FOOTERS -#define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -#else /* FOOTERS */ -#define CHUNK_OVERHEAD (SIZE_T_SIZE) -#endif /* FOOTERS */ + #if FOOTERS + #define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) + #else /* FOOTERS */ + #define CHUNK_OVERHEAD (SIZE_T_SIZE) + #endif /* FOOTERS */ -/* MMapped chunks need a second word of overhead ... */ -#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) -/* ... and additional padding for fake next-chunk at foot */ -#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) + /* MMapped chunks need a second word of overhead ... */ + #define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) + /* ... and additional padding for fake next-chunk at foot */ + #define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) -/* The smallest size we can malloc is an aligned minimal chunk */ -#define MIN_CHUNK_SIZE\ - ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + /* The smallest size we can malloc is an aligned minimal chunk */ + #define MIN_CHUNK_SIZE ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) -/* conversion from malloc headers to user pointers, and back */ -#define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) -#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) -/* chunk associated with aligned address A */ -#define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) + /* conversion from malloc headers to user pointers, and back */ + #define chunk2mem(p) ((void *)((char *)(p) + TWO_SIZE_T_SIZES)) + #define mem2chunk(mem) ((mchunkptr)((char *)(mem)-TWO_SIZE_T_SIZES)) + /* chunk associated with aligned address A */ + #define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) -/* Bounds on request (not chunk) sizes. */ -#define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) -#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) + /* Bounds on request (not chunk) sizes. */ + #define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) + #define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) -/* pad request bytes into a usable size */ -#define pad_request(req) \ - (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) - -/* pad request, checking for minimum (but not maximum) */ -#define request2size(req) \ - (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) + /* pad request bytes into a usable size */ + #define pad_request(req) \ + (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) + /* pad request, checking for minimum (but not maximum) */ + #define request2size(req) \ + (((req) < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(req)) /* ------------------ Operations on head and foot fields ----------------- */ @@ -2297,61 +2381,60 @@ typedef unsigned int flag_t; /* The type of various bit flag sets */ FLAG4_BIT is not used by this malloc, but might be useful in extensions. */ -#define PINUSE_BIT (SIZE_T_ONE) -#define CINUSE_BIT (SIZE_T_TWO) -#define FLAG4_BIT (SIZE_T_FOUR) -#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) -#define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) + #define PINUSE_BIT (SIZE_T_ONE) + #define CINUSE_BIT (SIZE_T_TWO) + #define FLAG4_BIT (SIZE_T_FOUR) + #define INUSE_BITS (PINUSE_BIT | CINUSE_BIT) + #define FLAG_BITS (PINUSE_BIT | CINUSE_BIT | FLAG4_BIT) -/* Head value for fenceposts */ -#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) + /* Head value for fenceposts */ + #define FENCEPOST_HEAD (INUSE_BITS | SIZE_T_SIZE) -/* extraction of fields from head words */ -#define cinuse(p) ((p)->head & CINUSE_BIT) -#define pinuse(p) ((p)->head & PINUSE_BIT) -#define flag4inuse(p) ((p)->head & FLAG4_BIT) -#define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) -#define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) + /* extraction of fields from head words */ + #define cinuse(p) ((p)->head & CINUSE_BIT) + #define pinuse(p) ((p)->head & PINUSE_BIT) + #define flag4inuse(p) ((p)->head & FLAG4_BIT) + #define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) + #define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) -#define chunksize(p) ((p)->head & ~(FLAG_BITS)) + #define chunksize(p) ((p)->head & ~(FLAG_BITS)) -#define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) -#define set_flag4(p) ((p)->head |= FLAG4_BIT) -#define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) + #define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) + #define set_flag4(p) ((p)->head |= FLAG4_BIT) + #define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) -/* Treat space at ptr +/- offset as a chunk */ -#define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) -#define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) + /* Treat space at ptr +/- offset as a chunk */ + #define chunk_plus_offset(p, s) ((mchunkptr)(((char *)(p)) + (s))) + #define chunk_minus_offset(p, s) ((mchunkptr)(((char *)(p)) - (s))) -/* Ptr to next or previous physical malloc_chunk. */ -#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) -#define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) + /* Ptr to next or previous physical malloc_chunk. */ + #define next_chunk(p) ((mchunkptr)(((char *)(p)) + ((p)->head & ~FLAG_BITS))) + #define prev_chunk(p) ((mchunkptr)(((char *)(p)) - ((p)->prev_foot))) -/* extract next chunk's pinuse bit */ -#define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) + /* extract next chunk's pinuse bit */ + #define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) -/* Get/set size at footer */ -#define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) -#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) + /* Get/set size at footer */ + #define get_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot) + #define set_foot(p, s) (((mchunkptr)((char *)(p) + (s)))->prev_foot = (s)) -/* Set size, pinuse bit, and foot */ -#define set_size_and_pinuse_of_free_chunk(p, s)\ - ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) + /* Set size, pinuse bit, and foot */ + #define set_size_and_pinuse_of_free_chunk(p, s) \ + ((p)->head = (s | PINUSE_BIT), set_foot(p, s)) -/* Set size, pinuse bit, foot, and clear next pinuse */ -#define set_free_with_pinuse(p, s, n)\ - (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) + /* Set size, pinuse bit, foot, and clear next pinuse */ + #define set_free_with_pinuse(p, s, n) \ + (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) -/* Get the internal overhead associated with chunk p */ -#define overhead_for(p)\ - (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) + /* Get the internal overhead associated with chunk p */ + #define overhead_for(p) (is_mmapped(p) ? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) -/* Return true if malloced space is not necessarily cleared */ -#if MMAP_CLEARS -#define calloc_must_clear(p) (!is_mmapped(p)) -#else /* MMAP_CLEARS */ -#define calloc_must_clear(p) (1) -#endif /* MMAP_CLEARS */ + /* Return true if malloced space is not necessarily cleared */ + #if MMAP_CLEARS + #define calloc_must_clear(p) (!is_mmapped(p)) + #else /* MMAP_CLEARS */ + #define calloc_must_clear(p) (1) + #endif /* MMAP_CLEARS */ /* ---------------------- Overlaid data structures ----------------------- */ @@ -2445,23 +2528,25 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ struct malloc_tree_chunk { + /* The first four fields must be compatible with malloc_chunk */ size_t prev_foot; size_t head; - struct malloc_tree_chunk* fd; - struct malloc_tree_chunk* bk; + struct malloc_tree_chunk *fd; + struct malloc_tree_chunk *bk; - struct malloc_tree_chunk* child[2]; - struct malloc_tree_chunk* parent; + struct malloc_tree_chunk *child[2]; + struct malloc_tree_chunk *parent; bindex_t index; + }; typedef struct malloc_tree_chunk tchunk; -typedef struct malloc_tree_chunk* tchunkptr; -typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ +typedef struct malloc_tree_chunk *tchunkptr; +typedef struct malloc_tree_chunk *tbinptr; /* The type of bins of trees */ -/* A little helper macro for trees */ -#define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) + /* A little helper macro for trees */ + #define leftmost_child(t) ((t)->child[0] != 0 ? (t)->child[0] : (t)->child[1]) /* ----------------------------- Segments -------------------------------- */ @@ -2521,141 +2606,145 @@ typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ */ struct malloc_segment { - char* base; /* base address */ - size_t size; /* allocated size */ - struct malloc_segment* next; /* ptr to next segment */ - flag_t sflags; /* mmap and extern flag */ + + char * base; /* base address */ + size_t size; /* allocated size */ + struct malloc_segment *next; /* ptr to next segment */ + flag_t sflags; /* mmap and extern flag */ + }; -#define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) -#define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) + #define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) + #define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) typedef struct malloc_segment msegment; -typedef struct malloc_segment* msegmentptr; +typedef struct malloc_segment *msegmentptr; -/* ---------------------------- malloc_state ----------------------------- */ + /* ---------------------------- malloc_state ----------------------------- */ -/* - A malloc_state holds all of the bookkeeping for a space. - The main fields are: - - Top - The topmost chunk of the currently active segment. Its size is - cached in topsize. The actual size of topmost space is - topsize+TOP_FOOT_SIZE, which includes space reserved for adding - fenceposts and segment records if necessary when getting more - space from the system. The size at which to autotrim top is - cached from mparams in trim_check, except that it is disabled if - an autotrim fails. - - Designated victim (dv) - This is the preferred chunk for servicing small requests that - don't have exact fits. It is normally the chunk split off most - recently to service another small request. Its size is cached in - dvsize. The link fields of this chunk are not maintained since it - is not kept in a bin. - - SmallBins - An array of bin headers for free chunks. These bins hold chunks - with sizes less than MIN_LARGE_SIZE bytes. Each bin contains - chunks of all the same size, spaced 8 bytes apart. To simplify - use in double-linked lists, each bin header acts as a malloc_chunk - pointing to the real first node, if it exists (else pointing to - itself). This avoids special-casing for headers. But to avoid - waste, we allocate only the fd/bk pointers of bins, and then use - repositioning tricks to treat these as the fields of a chunk. - - TreeBins - Treebins are pointers to the roots of trees holding a range of - sizes. There are 2 equally spaced treebins for each power of two - from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything - larger. - - Bin maps - There is one bit map for small bins ("smallmap") and one for - treebins ("treemap). Each bin sets its bit when non-empty, and - clears the bit when empty. Bit operations are then used to avoid - bin-by-bin searching -- nearly all "search" is done without ever - looking at bins that won't be selected. The bit maps - conservatively use 32 bits per map word, even if on 64bit system. - For a good description of some of the bit-based techniques used - here, see Henry S. Warren Jr's book "Hacker's Delight" (and - supplement at http://hackersdelight.org/). Many of these are - intended to reduce the branchiness of paths through malloc etc, as - well as to reduce the number of memory locations read or written. - - Segments - A list of segments headed by an embedded malloc_segment record - representing the initial space. - - Address check support - The least_addr field is the least address ever obtained from - MORECORE or MMAP. Attempted frees and reallocs of any address less - than this are trapped (unless INSECURE is defined). - - Magic tag - A cross-check field that should always hold same value as mparams.magic. - - Max allowed footprint - The maximum allowed bytes to allocate from system (zero means no limit) - - Flags - Bits recording whether to use MMAP, locks, or contiguous MORECORE - - Statistics - Each space keeps track of current and maximum system memory - obtained via MORECORE or MMAP. - - Trim support - Fields holding the amount of unused topmost memory that should trigger - trimming, and a counter to force periodic scanning to release unused - non-topmost segments. - - Locking - If USE_LOCKS is defined, the "mutex" lock is acquired and released - around every public call using this mspace. - - Extension support - A void* pointer and a size_t field that can be used to help implement - extensions to this malloc. -*/ + /* + A malloc_state holds all of the bookkeeping for a space. + The main fields are: + + Top + The topmost chunk of the currently active segment. Its size is + cached in topsize. The actual size of topmost space is + topsize+TOP_FOOT_SIZE, which includes space reserved for adding + fenceposts and segment records if necessary when getting more + space from the system. The size at which to autotrim top is + cached from mparams in trim_check, except that it is disabled if + an autotrim fails. + + Designated victim (dv) + This is the preferred chunk for servicing small requests that + don't have exact fits. It is normally the chunk split off most + recently to service another small request. Its size is cached in + dvsize. The link fields of this chunk are not maintained since it + is not kept in a bin. + + SmallBins + An array of bin headers for free chunks. These bins hold chunks + with sizes less than MIN_LARGE_SIZE bytes. Each bin contains + chunks of all the same size, spaced 8 bytes apart. To simplify + use in double-linked lists, each bin header acts as a malloc_chunk + pointing to the real first node, if it exists (else pointing to + itself). This avoids special-casing for headers. But to avoid + waste, we allocate only the fd/bk pointers of bins, and then use + repositioning tricks to treat these as the fields of a chunk. + + TreeBins + Treebins are pointers to the roots of trees holding a range of + sizes. There are 2 equally spaced treebins for each power of two + from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything + larger. + + Bin maps + There is one bit map for small bins ("smallmap") and one for + treebins ("treemap). Each bin sets its bit when non-empty, and + clears the bit when empty. Bit operations are then used to avoid + bin-by-bin searching -- nearly all "search" is done without ever + looking at bins that won't be selected. The bit maps + conservatively use 32 bits per map word, even if on 64bit system. + For a good description of some of the bit-based techniques used + here, see Henry S. Warren Jr's book "Hacker's Delight" (and + supplement at http://hackersdelight.org/). Many of these are + intended to reduce the branchiness of paths through malloc etc, as + well as to reduce the number of memory locations read or written. + + Segments + A list of segments headed by an embedded malloc_segment record + representing the initial space. + + Address check support + The least_addr field is the least address ever obtained from + MORECORE or MMAP. Attempted frees and reallocs of any address less + than this are trapped (unless INSECURE is defined). + + Magic tag + A cross-check field that should always hold same value as mparams.magic. + + Max allowed footprint + The maximum allowed bytes to allocate from system (zero means no limit) + + Flags + Bits recording whether to use MMAP, locks, or contiguous MORECORE + + Statistics + Each space keeps track of current and maximum system memory + obtained via MORECORE or MMAP. + + Trim support + Fields holding the amount of unused topmost memory that should trigger + trimming, and a counter to force periodic scanning to release unused + non-topmost segments. + + Locking + If USE_LOCKS is defined, the "mutex" lock is acquired and released + around every public call using this mspace. + + Extension support + A void* pointer and a size_t field that can be used to help implement + extensions to this malloc. + */ -/* Bin types, widths and sizes */ -#define NSMALLBINS (32U) -#define NTREEBINS (32U) -#define SMALLBIN_SHIFT (3U) -#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) -#define TREEBIN_SHIFT (8U) -#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) -#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) -#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) + /* Bin types, widths and sizes */ + #define NSMALLBINS (32U) + #define NTREEBINS (32U) + #define SMALLBIN_SHIFT (3U) + #define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) + #define TREEBIN_SHIFT (8U) + #define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) + #define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) + #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) struct malloc_state { - binmap_t smallmap; - binmap_t treemap; - size_t dvsize; - size_t topsize; - char* least_addr; - mchunkptr dv; - mchunkptr top; - size_t trim_check; - size_t release_checks; - size_t magic; - mchunkptr smallbins[(NSMALLBINS+1)*2]; - tbinptr treebins[NTREEBINS]; - size_t footprint; - size_t max_footprint; - size_t footprint_limit; /* zero means no limit */ - flag_t mflags; -#if USE_LOCKS - MLOCK_T mutex; /* locate lock among fields that rarely change */ -#endif /* USE_LOCKS */ - msegment seg; - void* extp; /* Unused but available for extensions */ - size_t exts; + + binmap_t smallmap; + binmap_t treemap; + size_t dvsize; + size_t topsize; + char * least_addr; + mchunkptr dv; + mchunkptr top; + size_t trim_check; + size_t release_checks; + size_t magic; + mchunkptr smallbins[(NSMALLBINS + 1) * 2]; + tbinptr treebins[NTREEBINS]; + size_t footprint; + size_t max_footprint; + size_t footprint_limit; /* zero means no limit */ + flag_t mflags; + #if USE_LOCKS + MLOCK_T mutex; /* locate lock among fields that rarely change */ + #endif /* USE_LOCKS */ + msegment seg; + void * extp; /* Unused but available for extensions */ + size_t exts; + }; -typedef struct malloc_state* mstate; +typedef struct malloc_state *mstate; /* ------------- Global malloc_state and malloc_params ------------------- */ @@ -2667,123 +2756,128 @@ typedef struct malloc_state* mstate; */ struct malloc_params { + size_t magic; size_t page_size; size_t granularity; size_t mmap_threshold; size_t trim_threshold; flag_t default_mflags; + }; static struct malloc_params mparams; -/* Ensure mparams initialized */ -#define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) + /* Ensure mparams initialized */ + #define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) -#if !ONLY_MSPACES + #if !ONLY_MSPACES /* The global malloc_state used for all non-"mspace" calls */ static struct malloc_state _gm_; -#define gm (&_gm_) -#define is_global(M) ((M) == &_gm_) + #define gm (&_gm_) + #define is_global(M) ((M) == &_gm_) -#endif /* !ONLY_MSPACES */ + #endif /* !ONLY_MSPACES */ -#define is_initialized(M) ((M)->top != 0) + #define is_initialized(M) ((M)->top != 0) /* -------------------------- system alloc setup ------------------------- */ /* Operations on mflags */ -#define use_lock(M) ((M)->mflags & USE_LOCK_BIT) -#define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) -#if USE_LOCKS -#define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) -#else -#define disable_lock(M) -#endif - -#define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) -#define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) -#if HAVE_MMAP -#define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) -#else -#define disable_mmap(M) -#endif - -#define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) -#define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) - -#define set_lock(M,L)\ - ((M)->mflags = (L)?\ - ((M)->mflags | USE_LOCK_BIT) :\ - ((M)->mflags & ~USE_LOCK_BIT)) - -/* page-align a size */ -#define page_align(S)\ - (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) - -/* granularity-align a size */ -#define granularity_align(S)\ - (((S) + (mparams.granularity - SIZE_T_ONE))\ - & ~(mparams.granularity - SIZE_T_ONE)) - - -/* For mmap, use granularity alignment on windows, else page-align */ -#ifdef WIN32 -#define mmap_align(S) granularity_align(S) -#else -#define mmap_align(S) page_align(S) -#endif - -/* For sys_alloc, enough padding to ensure can malloc request on success */ -#define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) - -#define is_page_aligned(S)\ - (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) -#define is_granularity_aligned(S)\ - (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) - -/* True if segment S holds address A */ -#define segment_holds(S, A)\ - ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) + #define use_lock(M) ((M)->mflags & USE_LOCK_BIT) + #define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) + #if USE_LOCKS + #define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) + #else + #define disable_lock(M) + #endif + + #define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) + #define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) + #if HAVE_MMAP + #define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) + #else + #define disable_mmap(M) + #endif + + #define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) + #define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) + + #define set_lock(M, L) \ + ((M)->mflags = \ + (L) ? ((M)->mflags | USE_LOCK_BIT) : ((M)->mflags & ~USE_LOCK_BIT)) + + /* page-align a size */ + #define page_align(S) \ + (((S) + (mparams.page_size - SIZE_T_ONE)) & \ + ~(mparams.page_size - SIZE_T_ONE)) + + /* granularity-align a size */ + #define granularity_align(S) \ + (((S) + (mparams.granularity - SIZE_T_ONE)) & \ + ~(mparams.granularity - SIZE_T_ONE)) + + /* For mmap, use granularity alignment on windows, else page-align */ + #ifdef WIN32 + #define mmap_align(S) granularity_align(S) + #else + #define mmap_align(S) page_align(S) + #endif + + /* For sys_alloc, enough padding to ensure can malloc request on success */ + #define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) + + #define is_page_aligned(S) \ + (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) + #define is_granularity_aligned(S) \ + (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) + + /* True if segment S holds address A */ + #define segment_holds(S, A) \ + ((char *)(A) >= S->base && (char *)(A) < S->base + S->size) /* Return segment holding given address */ -static msegmentptr segment_holding(mstate m, char* addr) { +static msegmentptr segment_holding(mstate m, char *addr) { + msegmentptr sp = &m->seg; for (;;) { - if (addr >= sp->base && addr < sp->base + sp->size) - return sp; - if ((sp = sp->next) == 0) - return 0; + + if (addr >= sp->base && addr < sp->base + sp->size) return sp; + if ((sp = sp->next) == 0) return 0; + } + } /* Return true if segment contains a segment link */ static int has_segment_link(mstate m, msegmentptr ss) { + msegmentptr sp = &m->seg; for (;;) { - if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) - return 1; - if ((sp = sp->next) == 0) - return 0; + + if ((char *)sp >= ss->base && (char *)sp < ss->base + ss->size) return 1; + if ((sp = sp->next) == 0) return 0; + } -} -#ifndef MORECORE_CANNOT_TRIM -#define should_trim(M,s) ((s) > (M)->trim_check) -#else /* MORECORE_CANNOT_TRIM */ -#define should_trim(M,s) (0) -#endif /* MORECORE_CANNOT_TRIM */ +} -/* - TOP_FOOT_SIZE is padding at the end of a segment, including space - that may be needed to place segment records and fenceposts when new - noncontiguous segments are added. -*/ -#define TOP_FOOT_SIZE\ - (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) + #ifndef MORECORE_CANNOT_TRIM + #define should_trim(M, s) ((s) > (M)->trim_check) + #else /* MORECORE_CANNOT_TRIM */ + #define should_trim(M, s) (0) + #endif /* MORECORE_CANNOT_TRIM */ + /* + TOP_FOOT_SIZE is padding at the end of a segment, including space + that may be needed to place segment records and fenceposts when new + noncontiguous segments are added. + */ + #define TOP_FOOT_SIZE \ + (align_offset(chunk2mem(0)) + pad_request(sizeof(struct malloc_segment)) + \ + MIN_CHUNK_SIZE) /* ------------------------------- Hooks -------------------------------- */ @@ -2793,20 +2887,25 @@ static int has_segment_link(mstate m, msegmentptr ss) { anything you like. */ -#if USE_LOCKS -#define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) -#define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } -#else /* USE_LOCKS */ + #if USE_LOCKS + #define PREACTION(M) ((use_lock(M)) ? ACQUIRE_LOCK(&(M)->mutex) : 0) + #define POSTACTION(M) \ + { \ + \ + if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); \ + \ + } + #else /* USE_LOCKS */ -#ifndef PREACTION -#define PREACTION(M) (0) -#endif /* PREACTION */ + #ifndef PREACTION + #define PREACTION(M) (0) + #endif /* PREACTION */ -#ifndef POSTACTION -#define POSTACTION(M) -#endif /* POSTACTION */ + #ifndef POSTACTION + #define POSTACTION(M) + #endif /* POSTACTION */ -#endif /* USE_LOCKS */ + #endif /* USE_LOCKS */ /* CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. @@ -2816,7 +2915,7 @@ static int has_segment_link(mstate m, msegmentptr ss) { useful in custom actions that try to help diagnose errors. */ -#if PROCEED_ON_ERROR + #if PROCEED_ON_ERROR /* A count of the number of corruption errors causing resets */ int malloc_corruption_error_count; @@ -2824,211 +2923,240 @@ int malloc_corruption_error_count; /* default corruption action */ static void reset_on_error(mstate m); -#define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) -#define USAGE_ERROR_ACTION(m, p) - -#else /* PROCEED_ON_ERROR */ + #define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) + #define USAGE_ERROR_ACTION(m, p) -#ifndef CORRUPTION_ERROR_ACTION -#define CORRUPTION_ERROR_ACTION(m) ABORT -#endif /* CORRUPTION_ERROR_ACTION */ + #else /* PROCEED_ON_ERROR */ -#ifndef USAGE_ERROR_ACTION -#define USAGE_ERROR_ACTION(m,p) ABORT -#endif /* USAGE_ERROR_ACTION */ + #ifndef CORRUPTION_ERROR_ACTION + #define CORRUPTION_ERROR_ACTION(m) ABORT + #endif /* CORRUPTION_ERROR_ACTION */ -#endif /* PROCEED_ON_ERROR */ + #ifndef USAGE_ERROR_ACTION + #define USAGE_ERROR_ACTION(m, p) ABORT + #endif /* USAGE_ERROR_ACTION */ + #endif /* PROCEED_ON_ERROR */ /* -------------------------- Debugging setup ---------------------------- */ -#if ! DEBUG + #if !DEBUG -#define check_free_chunk(M,P) -#define check_inuse_chunk(M,P) -#define check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) -#define check_malloc_state(M) -#define check_top_chunk(M,P) + #define check_free_chunk(M, P) + #define check_inuse_chunk(M, P) + #define check_malloced_chunk(M, P, N) + #define check_mmapped_chunk(M, P) + #define check_malloc_state(M) + #define check_top_chunk(M, P) -#else /* DEBUG */ -#define check_free_chunk(M,P) do_check_free_chunk(M,P) -#define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) -#define check_top_chunk(M,P) do_check_top_chunk(M,P) -#define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) -#define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) -#define check_malloc_state(M) do_check_malloc_state(M) + #else /* DEBUG */ + #define check_free_chunk(M, P) do_check_free_chunk(M, P) + #define check_inuse_chunk(M, P) do_check_inuse_chunk(M, P) + #define check_top_chunk(M, P) do_check_top_chunk(M, P) + #define check_malloced_chunk(M, P, N) do_check_malloced_chunk(M, P, N) + #define check_mmapped_chunk(M, P) do_check_mmapped_chunk(M, P) + #define check_malloc_state(M) do_check_malloc_state(M) static void do_check_any_chunk(mstate m, mchunkptr p); static void do_check_top_chunk(mstate m, mchunkptr p); static void do_check_mmapped_chunk(mstate m, mchunkptr p); static void do_check_inuse_chunk(mstate m, mchunkptr p); static void do_check_free_chunk(mstate m, mchunkptr p); -static void do_check_malloced_chunk(mstate m, void* mem, size_t s); +static void do_check_malloced_chunk(mstate m, void *mem, size_t s); static void do_check_tree(mstate m, tchunkptr t); static void do_check_treebin(mstate m, bindex_t i); static void do_check_smallbin(mstate m, bindex_t i); static void do_check_malloc_state(mstate m); static int bin_find(mstate m, mchunkptr x); static size_t traverse_and_check(mstate m); -#endif /* DEBUG */ + #endif /* DEBUG */ /* ---------------------------- Indexing Bins ---------------------------- */ -#define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) -#define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) -#define small_index2size(i) ((i) << SMALLBIN_SHIFT) -#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) - -/* addressing by index. See above about smallbin repositioning */ -#define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) -#define treebin_at(M,i) (&((M)->treebins[i])) - -/* assign tree index for size S to variable I. Use x86 asm if possible */ -#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -#define compute_tree_index(S, I)\ -{\ - unsigned int X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} - -#elif defined (__INTEL_COMPILER) -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K = _bit_scan_reverse (X); \ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} + #define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) + #define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) + #define small_index2size(i) ((i) << SMALLBIN_SHIFT) + #define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) + + /* addressing by index. See above about smallbin repositioning */ + #define smallbin_at(M, i) ((sbinptr)((char *)&((M)->smallbins[(i) << 1]))) + #define treebin_at(M, i) (&((M)->treebins[i])) + + /* assign tree index for size S to variable I. Use x86 asm if possible */ + #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + #define compute_tree_index(S, I) \ + { \ + \ + unsigned int X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else { \ + \ + unsigned int K = (unsigned)sizeof(X) * __CHAR_BIT__ - 1 - \ + (unsigned)__builtin_clz(X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ + \ + } \ + \ + } -#elif defined(_MSC_VER) && _MSC_VER>=1300 -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int K;\ - _BitScanReverse((DWORD *) &K, (DWORD) X);\ - I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ - }\ -} + #elif defined(__INTEL_COMPILER) + #define compute_tree_index(S, I) \ + { \ + \ + size_t X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else { \ + \ + unsigned int K = _bit_scan_reverse(X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ + \ + } \ + \ + } -#else /* GNUC */ -#define compute_tree_index(S, I)\ -{\ - size_t X = S >> TREEBIN_SHIFT;\ - if (X == 0)\ - I = 0;\ - else if (X > 0xFFFF)\ - I = NTREEBINS-1;\ - else {\ - unsigned int Y = (unsigned int)X;\ - unsigned int N = ((Y - 0x100) >> 16) & 8;\ - unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ - N += K;\ - N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ - K = 14 - N + ((Y <<= K) >> 15);\ - I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ - }\ -} -#endif /* GNUC */ + #elif defined(_MSC_VER) && _MSC_VER >= 1300 + #define compute_tree_index(S, I) \ + { \ + \ + size_t X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else { \ + \ + unsigned int K; \ + _BitScanReverse((DWORD *)&K, (DWORD)X); \ + I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1))); \ + \ + } \ + \ + } -/* Bit representing maximum resolved size in a treebin at i */ -#define bit_for_tree_index(i) \ - (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) + #else /* GNUC */ + #define compute_tree_index(S, I) \ + { \ + \ + size_t X = S >> TREEBIN_SHIFT; \ + if (X == 0) \ + I = 0; \ + else if (X > 0xFFFF) \ + I = NTREEBINS - 1; \ + else { \ + \ + unsigned int Y = (unsigned int)X; \ + unsigned int N = ((Y - 0x100) >> 16) & 8; \ + unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4; \ + N += K; \ + N += K = (((Y <<= K) - 0x4000) >> 16) & 2; \ + K = 14 - N + ((Y <<= K) >> 15); \ + I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT - 1)) & 1)); \ + \ + } \ + \ + } + #endif /* GNUC */ -/* Shift placing maximum resolved bit in a treebin at i as sign bit */ -#define leftshift_for_tree_index(i) \ - ((i == NTREEBINS-1)? 0 : \ - ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + /* Bit representing maximum resolved size in a treebin at i */ + #define bit_for_tree_index(i) \ + (i == NTREEBINS - 1) ? (SIZE_T_BITSIZE - 1) \ + : (((i) >> 1) + TREEBIN_SHIFT - 2) -/* The size of the smallest chunk held in bin with index i */ -#define minsize_for_tree_index(i) \ - ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ - (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) + /* Shift placing maximum resolved bit in a treebin at i as sign bit */ + #define leftshift_for_tree_index(i) \ + ((i == NTREEBINS - 1) \ + ? 0 \ + : ((SIZE_T_BITSIZE - SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) + /* The size of the smallest chunk held in bin with index i */ + #define minsize_for_tree_index(i) \ + ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ + (((size_t)((i)&SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) -/* ------------------------ Operations on bin maps ----------------------- */ + /* ------------------------ Operations on bin maps ----------------------- */ -/* bit corresponding to given index */ -#define idx2bit(i) ((binmap_t)(1) << (i)) + /* bit corresponding to given index */ + #define idx2bit(i) ((binmap_t)(1) << (i)) -/* Mark/Clear bits with given index */ -#define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) -#define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) -#define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) + /* Mark/Clear bits with given index */ + #define mark_smallmap(M, i) ((M)->smallmap |= idx2bit(i)) + #define clear_smallmap(M, i) ((M)->smallmap &= ~idx2bit(i)) + #define smallmap_is_marked(M, i) ((M)->smallmap & idx2bit(i)) -#define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) -#define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) -#define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) + #define mark_treemap(M, i) ((M)->treemap |= idx2bit(i)) + #define clear_treemap(M, i) ((M)->treemap &= ~idx2bit(i)) + #define treemap_is_marked(M, i) ((M)->treemap & idx2bit(i)) -/* isolate the least set bit of a bitmap */ -#define least_bit(x) ((x) & -(x)) + /* isolate the least set bit of a bitmap */ + #define least_bit(x) ((x) & -(x)) -/* mask with all bits to left of least bit of x on */ -#define left_bits(x) ((x<<1) | -(x<<1)) + /* mask with all bits to left of least bit of x on */ + #define left_bits(x) ((x << 1) | -(x << 1)) -/* mask with all bits to left of or equal to least bit of x on */ -#define same_or_left_bits(x) ((x) | -(x)) + /* mask with all bits to left of or equal to least bit of x on */ + #define same_or_left_bits(x) ((x) | -(x)) /* index corresponding to given bit. Use x86 asm if possible */ -#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - J = __builtin_ctz(X); \ - I = (bindex_t)J;\ -} + #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + #define compute_bit2idx(X, I) \ + { \ + \ + unsigned int J; \ + J = __builtin_ctz(X); \ + I = (bindex_t)J; \ + \ + } -#elif defined (__INTEL_COMPILER) -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - J = _bit_scan_forward (X); \ - I = (bindex_t)J;\ -} + #elif defined(__INTEL_COMPILER) + #define compute_bit2idx(X, I) \ + { \ + \ + unsigned int J; \ + J = _bit_scan_forward(X); \ + I = (bindex_t)J; \ + \ + } -#elif defined(_MSC_VER) && _MSC_VER>=1300 -#define compute_bit2idx(X, I)\ -{\ - unsigned int J;\ - _BitScanForward((DWORD *) &J, X);\ - I = (bindex_t)J;\ -} + #elif defined(_MSC_VER) && _MSC_VER >= 1300 + #define compute_bit2idx(X, I) \ + { \ + \ + unsigned int J; \ + _BitScanForward((DWORD *)&J, X); \ + I = (bindex_t)J; \ + \ + } -#elif USE_BUILTIN_FFS -#define compute_bit2idx(X, I) I = ffs(X)-1 - -#else -#define compute_bit2idx(X, I)\ -{\ - unsigned int Y = X - 1;\ - unsigned int K = Y >> (16-4) & 16;\ - unsigned int N = K; Y >>= K;\ - N += K = Y >> (8-3) & 8; Y >>= K;\ - N += K = Y >> (4-2) & 4; Y >>= K;\ - N += K = Y >> (2-1) & 2; Y >>= K;\ - N += K = Y >> (1-0) & 1; Y >>= K;\ - I = (bindex_t)(N + Y);\ -} -#endif /* GNUC */ + #elif USE_BUILTIN_FFS + #define compute_bit2idx(X, I) I = ffs(X) - 1 + #else + #define compute_bit2idx(X, I) \ + { \ + \ + unsigned int Y = X - 1; \ + unsigned int K = Y >> (16 - 4) & 16; \ + unsigned int N = K; \ + Y >>= K; \ + N += K = Y >> (8 - 3) & 8; \ + Y >>= K; \ + N += K = Y >> (4 - 2) & 4; \ + Y >>= K; \ + N += K = Y >> (2 - 1) & 2; \ + Y >>= K; \ + N += K = Y >> (1 - 0) & 1; \ + Y >>= K; \ + I = (bindex_t)(N + Y); \ + \ + } + #endif /* GNUC */ /* ----------------------- Runtime Check Support ------------------------- */ @@ -3058,122 +3186,142 @@ static size_t traverse_and_check(mstate m); next, etc). This turns out to be cheaper than relying on hashes. */ -#if !INSECURE -/* Check if address a is at least as high as any from MORECORE or MMAP */ -#define ok_address(M, a) ((char*)(a) >= (M)->least_addr) -/* Check if address of next chunk n is higher than base chunk p */ -#define ok_next(p, n) ((char*)(p) < (char*)(n)) -/* Check if p has inuse status */ -#define ok_inuse(p) is_inuse(p) -/* Check if p has its pinuse bit on */ -#define ok_pinuse(p) pinuse(p) - -#else /* !INSECURE */ -#define ok_address(M, a) (1) -#define ok_next(b, n) (1) -#define ok_inuse(p) (1) -#define ok_pinuse(p) (1) -#endif /* !INSECURE */ - -#if (FOOTERS && !INSECURE) -/* Check if (alleged) mstate m has expected magic field */ -#define ok_magic(M) ((M)->magic == mparams.magic) -#else /* (FOOTERS && !INSECURE) */ -#define ok_magic(M) (1) -#endif /* (FOOTERS && !INSECURE) */ - -/* In gcc, use __builtin_expect to minimize impact of checks */ -#if !INSECURE -#if defined(__GNUC__) && __GNUC__ >= 3 -#define RTCHECK(e) __builtin_expect(e, 1) -#else /* GNUC */ -#define RTCHECK(e) (e) -#endif /* GNUC */ -#else /* !INSECURE */ -#define RTCHECK(e) (1) -#endif /* !INSECURE */ + #if !INSECURE + /* Check if address a is at least as high as any from MORECORE or MMAP */ + #define ok_address(M, a) ((char *)(a) >= (M)->least_addr) + /* Check if address of next chunk n is higher than base chunk p */ + #define ok_next(p, n) ((char *)(p) < (char *)(n)) + /* Check if p has inuse status */ + #define ok_inuse(p) is_inuse(p) + /* Check if p has its pinuse bit on */ + #define ok_pinuse(p) pinuse(p) + + #else /* !INSECURE */ + #define ok_address(M, a) (1) + #define ok_next(b, n) (1) + #define ok_inuse(p) (1) + #define ok_pinuse(p) (1) + #endif /* !INSECURE */ + + #if (FOOTERS && !INSECURE) + /* Check if (alleged) mstate m has expected magic field */ + #define ok_magic(M) ((M)->magic == mparams.magic) + #else /* (FOOTERS && !INSECURE) */ + #define ok_magic(M) (1) + #endif /* (FOOTERS && !INSECURE) */ + + /* In gcc, use __builtin_expect to minimize impact of checks */ + #if !INSECURE + #if defined(__GNUC__) && __GNUC__ >= 3 + #define RTCHECK(e) __builtin_expect(e, 1) + #else /* GNUC */ + #define RTCHECK(e) (e) + #endif /* GNUC */ + #else /* !INSECURE */ + #define RTCHECK(e) (1) + #endif /* !INSECURE */ /* macros to set up inuse chunks with or without footers */ -#if !FOOTERS + #if !FOOTERS -#define mark_inuse_foot(M,p,s) + #define mark_inuse_foot(M, p, s) -/* Macros for setting head/foot of non-mmapped chunks */ + /* Macros for setting head/foot of non-mmapped chunks */ -/* Set cinuse bit and pinuse bit of next chunk */ -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + /* Set cinuse bit and pinuse bit of next chunk */ + #define set_inuse(M, p, s) \ + ((p)->head = (((p)->head & PINUSE_BIT) | s | CINUSE_BIT), \ + ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) -/* Set cinuse and pinuse of this chunk and pinuse of next chunk */ -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) + /* Set cinuse and pinuse of this chunk and pinuse of next chunk */ + #define set_inuse_and_pinuse(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), \ + ((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT) -/* Set size, cinuse and pinuse bit of this chunk */ -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) + /* Set size, cinuse and pinuse bit of this chunk */ + #define set_size_and_pinuse_of_inuse_chunk(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT)) -#else /* FOOTERS */ + #else /* FOOTERS */ -/* Set foot of inuse chunk to be xor of mstate and seed */ -#define mark_inuse_foot(M,p,s)\ - (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) + /* Set foot of inuse chunk to be xor of mstate and seed */ + #define mark_inuse_foot(M, p, s) \ + (((mchunkptr)((char *)(p) + (s)))->prev_foot = \ + ((size_t)(M) ^ mparams.magic)) -#define get_mstate_for(p)\ - ((mstate)(((mchunkptr)((char*)(p) +\ - (chunksize(p))))->prev_foot ^ mparams.magic)) + #define get_mstate_for(p) \ + ((mstate)(((mchunkptr)((char *)(p) + (chunksize(p))))->prev_foot ^ \ + mparams.magic)) -#define set_inuse(M,p,s)\ - ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ - mark_inuse_foot(M,p,s)) + #define set_inuse(M, p, s) \ + ((p)->head = (((p)->head & PINUSE_BIT) | s | CINUSE_BIT), \ + (((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M, p, s)) -#define set_inuse_and_pinuse(M,p,s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ - mark_inuse_foot(M,p,s)) + #define set_inuse_and_pinuse(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), \ + (((mchunkptr)(((char *)(p)) + (s)))->head |= PINUSE_BIT), \ + mark_inuse_foot(M, p, s)) -#define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ - ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ - mark_inuse_foot(M, p, s)) + #define set_size_and_pinuse_of_inuse_chunk(M, p, s) \ + ((p)->head = (s | PINUSE_BIT | CINUSE_BIT), mark_inuse_foot(M, p, s)) -#endif /* !FOOTERS */ + #endif /* !FOOTERS */ /* ---------------------------- setting mparams -------------------------- */ -#if LOCK_AT_FORK -static void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); } -static void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); } -static void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); } -#endif /* LOCK_AT_FORK */ + #if LOCK_AT_FORK +static void pre_fork(void) { + + ACQUIRE_LOCK(&(gm)->mutex); + +} + +static void post_fork_parent(void) { + + RELEASE_LOCK(&(gm)->mutex); + +} + +static void post_fork_child(void) { + + INITIAL_LOCK(&(gm)->mutex); + +} + + #endif /* LOCK_AT_FORK */ /* Initialize mparams */ static int init_mparams(void) { -#ifdef NEED_GLOBAL_LOCK_INIT - if (malloc_global_mutex_status <= 0) - init_malloc_global_mutex(); -#endif + + #ifdef NEED_GLOBAL_LOCK_INIT + if (malloc_global_mutex_status <= 0) init_malloc_global_mutex(); + #endif ACQUIRE_MALLOC_GLOBAL_LOCK(); if (mparams.magic == 0) { + size_t magic; size_t psize; size_t gsize; -#ifndef WIN32 + #ifndef WIN32 psize = malloc_getpagesize; - gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); -#else /* WIN32 */ + gsize = ((DEFAULT_GRANULARITY != 0) ? DEFAULT_GRANULARITY : psize); + #else /* WIN32 */ { + SYSTEM_INFO system_info; GetSystemInfo(&system_info); psize = system_info.dwPageSize; - gsize = ((DEFAULT_GRANULARITY != 0)? - DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); + gsize = + ((DEFAULT_GRANULARITY != 0) ? DEFAULT_GRANULARITY + : system_info.dwAllocationGranularity); + } -#endif /* WIN32 */ + + #endif /* WIN32 */ /* Sanity-check configuration: size_t must be unsigned and as wide as pointer type. @@ -3181,187 +3329,216 @@ static int init_mparams(void) { alignment must be at least 8. Alignment, min chunk size, and page size must all be powers of 2. */ - if ((sizeof(size_t) != sizeof(char*)) || - (MAX_SIZE_T < MIN_CHUNK_SIZE) || - (sizeof(int) < 4) || - (MALLOC_ALIGNMENT < (size_t)8U) || - ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || - ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || - ((gsize & (gsize-SIZE_T_ONE)) != 0) || - ((psize & (psize-SIZE_T_ONE)) != 0)) + if ((sizeof(size_t) != sizeof(char *)) || (MAX_SIZE_T < MIN_CHUNK_SIZE) || + (sizeof(int) < 4) || (MALLOC_ALIGNMENT < (size_t)8U) || + ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT - SIZE_T_ONE)) != 0) || + ((MCHUNK_SIZE & (MCHUNK_SIZE - SIZE_T_ONE)) != 0) || + ((gsize & (gsize - SIZE_T_ONE)) != 0) || + ((psize & (psize - SIZE_T_ONE)) != 0)) ABORT; mparams.granularity = gsize; mparams.page_size = psize; mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; -#if MORECORE_CONTIGUOUS - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; -#else /* MORECORE_CONTIGUOUS */ - mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; -#endif /* MORECORE_CONTIGUOUS */ - -#if !ONLY_MSPACES + #if MORECORE_CONTIGUOUS + mparams.default_mflags = USE_LOCK_BIT | USE_MMAP_BIT; + #else /* MORECORE_CONTIGUOUS */ + mparams.default_mflags = + USE_LOCK_BIT | USE_MMAP_BIT | USE_NONCONTIGUOUS_BIT; + #endif /* MORECORE_CONTIGUOUS */ + + #if !ONLY_MSPACES /* Set up lock for main malloc area */ gm->mflags = mparams.default_mflags; (void)INITIAL_LOCK(&gm->mutex); -#endif -#if LOCK_AT_FORK + #endif + #if LOCK_AT_FORK pthread_atfork(&pre_fork, &post_fork_parent, &post_fork_child); -#endif + #endif { -#if USE_DEV_RANDOM - int fd; + + #if USE_DEV_RANDOM + int fd; unsigned char buf[sizeof(size_t)]; /* Try to use /dev/urandom, else fall back on using time */ if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && read(fd, buf, sizeof(buf)) == sizeof(buf)) { - magic = *((size_t *) buf); + + magic = *((size_t *)buf); close(fd); - } - else -#endif /* USE_DEV_RANDOM */ -#ifdef WIN32 - magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); -#elif defined(LACKS_TIME_H) + + } else + + #endif /* USE_DEV_RANDOM */ + #ifdef WIN32 + magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); + #elif defined(LACKS_TIME_H) magic = (size_t)&magic ^ (size_t)0x55555555U; -#else + #else magic = (size_t)(time(0) ^ (size_t)0x55555555U); -#endif - magic |= (size_t)8U; /* ensure nonzero */ - magic &= ~(size_t)7U; /* improve chances of fault for bad values */ + #endif + magic |= (size_t)8U; /* ensure nonzero */ + magic &= ~(size_t)7U; /* improve chances of fault for bad values */ /* Until memory modes commonly available, use volatile-write */ (*(volatile size_t *)(&(mparams.magic))) = magic; + } + } RELEASE_MALLOC_GLOBAL_LOCK(); return 1; + } /* support for mallopt */ static int change_mparam(int param_number, int value) { + size_t val; ensure_initialization(); - val = (value == -1)? MAX_SIZE_T : (size_t)value; - switch(param_number) { - case M_TRIM_THRESHOLD: - mparams.trim_threshold = val; - return 1; - case M_GRANULARITY: - if (val >= mparams.page_size && ((val & (val-1)) == 0)) { - mparams.granularity = val; + val = (value == -1) ? MAX_SIZE_T : (size_t)value; + switch (param_number) { + + case M_TRIM_THRESHOLD: + mparams.trim_threshold = val; return 1; - } - else + case M_GRANULARITY: + if (val >= mparams.page_size && ((val & (val - 1)) == 0)) { + + mparams.granularity = val; + return 1; + + } else + + return 0; + case M_MMAP_THRESHOLD: + mparams.mmap_threshold = val; + return 1; + default: return 0; - case M_MMAP_THRESHOLD: - mparams.mmap_threshold = val; - return 1; - default: - return 0; + } + } -#if DEBUG + #if DEBUG /* ------------------------- Debugging Support --------------------------- */ /* Check properties of any chunk, whether free, inuse, mmapped etc */ static void do_check_any_chunk(mstate m, mchunkptr p) { + assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); + } /* Check properties of top chunk */ static void do_check_top_chunk(mstate m, mchunkptr p) { - msegmentptr sp = segment_holding(m, (char*)p); - size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ + + msegmentptr sp = segment_holding(m, (char *)p); + size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ assert(sp != 0); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(sz == m->topsize); assert(sz > 0); - assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); + assert(sz == ((sp->base + sp->size) - (char *)p) - TOP_FOOT_SIZE); assert(pinuse(p)); assert(!pinuse(chunk_plus_offset(p, sz))); + } /* Check properties of (inuse) mmapped chunks */ static void do_check_mmapped_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); + + size_t sz = chunksize(p); size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); assert(is_mmapped(p)); assert(use_mmap(m)); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(!is_small(sz)); - assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); + assert((len & (mparams.page_size - SIZE_T_ONE)) == 0); assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); - assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); + assert(chunk_plus_offset(p, sz + SIZE_T_SIZE)->head == 0); + } /* Check properties of inuse chunks */ static void do_check_inuse_chunk(mstate m, mchunkptr p) { + do_check_any_chunk(m, p); assert(is_inuse(p)); assert(next_pinuse(p)); /* If not pinuse and not mmapped, previous chunk has OK offset */ assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); - if (is_mmapped(p)) - do_check_mmapped_chunk(m, p); + if (is_mmapped(p)) do_check_mmapped_chunk(m, p); + } /* Check properties of free chunks */ static void do_check_free_chunk(mstate m, mchunkptr p) { - size_t sz = chunksize(p); + + size_t sz = chunksize(p); mchunkptr next = chunk_plus_offset(p, sz); do_check_any_chunk(m, p); assert(!is_inuse(p)); assert(!next_pinuse(p)); - assert (!is_mmapped(p)); + assert(!is_mmapped(p)); if (p != m->dv && p != m->top) { + if (sz >= MIN_CHUNK_SIZE) { + assert((sz & CHUNK_ALIGN_MASK) == 0); assert(is_aligned(chunk2mem(p))); assert(next->prev_foot == sz); assert(pinuse(p)); - assert (next == m->top || is_inuse(next)); + assert(next == m->top || is_inuse(next)); assert(p->fd->bk == p); assert(p->bk->fd == p); - } - else /* markers are always of size SIZE_T_SIZE */ + + } else /* markers are always of size SIZE_T_SIZE */ + assert(sz == SIZE_T_SIZE); + } + } /* Check properties of malloced chunks at the point they are malloced */ -static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { +static void do_check_malloced_chunk(mstate m, void *mem, size_t s) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); - size_t sz = p->head & ~INUSE_BITS; + size_t sz = p->head & ~INUSE_BITS; do_check_inuse_chunk(m, p); assert((sz & CHUNK_ALIGN_MASK) == 0); assert(sz >= MIN_CHUNK_SIZE); assert(sz >= s); /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); + } + } /* Check a tree and its subtrees. */ static void do_check_tree(mstate m, tchunkptr t) { + tchunkptr head = 0; tchunkptr u = t; - bindex_t tindex = t->index; - size_t tsize = chunksize(t); - bindex_t idx; + bindex_t tindex = t->index; + size_t tsize = chunksize(t); + bindex_t idx; compute_tree_index(tsize, idx); assert(tindex == idx); assert(tsize >= MIN_LARGE_SIZE); assert(tsize >= minsize_for_tree_index(idx)); - assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); + assert((idx == NTREEBINS - 1) || (tsize < minsize_for_tree_index((idx + 1)))); - do { /* traverse through chain of same-sized nodes */ + do { /* traverse through chain of same-sized nodes */ do_check_any_chunk(m, ((mchunkptr)u)); assert(u->index == tindex); assert(chunksize(u) == tsize); @@ -3370,56 +3547,72 @@ static void do_check_tree(mstate m, tchunkptr t) { assert(u->fd->bk == u); assert(u->bk->fd == u); if (u->parent == 0) { + assert(u->child[0] == 0); assert(u->child[1] == 0); - } - else { - assert(head == 0); /* only one node on chain has parent */ + + } else { + + assert(head == 0); /* only one node on chain has parent */ head = u; assert(u->parent != u); - assert (u->parent->child[0] == u || - u->parent->child[1] == u || - *((tbinptr*)(u->parent)) == u); + assert(u->parent->child[0] == u || u->parent->child[1] == u || + *((tbinptr *)(u->parent)) == u); if (u->child[0] != 0) { + assert(u->child[0]->parent == u); assert(u->child[0] != u); do_check_tree(m, u->child[0]); + } + if (u->child[1] != 0) { + assert(u->child[1]->parent == u); assert(u->child[1] != u); do_check_tree(m, u->child[1]); + } + if (u->child[0] != 0 && u->child[1] != 0) { + assert(chunksize(u->child[0]) < chunksize(u->child[1])); + } + } + u = u->fd; + } while (u != t); + assert(head != 0); + } /* Check all the chunks in a treebin. */ static void do_check_treebin(mstate m, bindex_t i) { - tbinptr* tb = treebin_at(m, i); + + tbinptr * tb = treebin_at(m, i); tchunkptr t = *tb; - int empty = (m->treemap & (1U << i)) == 0; - if (t == 0) - assert(empty); - if (!empty) - do_check_tree(m, t); + int empty = (m->treemap & (1U << i)) == 0; + if (t == 0) assert(empty); + if (!empty) do_check_tree(m, t); + } /* Check all the chunks in a smallbin. */ static void do_check_smallbin(mstate m, bindex_t i) { - sbinptr b = smallbin_at(m, i); - mchunkptr p = b->bk; + + sbinptr b = smallbin_at(m, i); + mchunkptr p = b->bk; unsigned int empty = (m->smallmap & (1U << i)) == 0; - if (p == b) - assert(empty); + if (p == b) assert(empty); if (!empty) { + for (; p != b; p = p->bk) { - size_t size = chunksize(p); + + size_t size = chunksize(p); mchunkptr q; /* each chunk claims to be free */ do_check_free_chunk(m, p); @@ -3428,324 +3621,435 @@ static void do_check_smallbin(mstate m, bindex_t i) { assert(p->bk == b || chunksize(p->bk) == chunksize(p)); /* chunk is followed by an inuse chunk */ q = next_chunk(p); - if (q->head != FENCEPOST_HEAD) - do_check_inuse_chunk(m, q); + if (q->head != FENCEPOST_HEAD) do_check_inuse_chunk(m, q); + } + } + } /* Find x in a bin. Used in other check functions. */ static int bin_find(mstate m, mchunkptr x) { + size_t size = chunksize(x); if (is_small(size)) { + bindex_t sidx = small_index(size); - sbinptr b = smallbin_at(m, sidx); + sbinptr b = smallbin_at(m, sidx); if (smallmap_is_marked(m, sidx)) { + mchunkptr p = b; do { - if (p == x) - return 1; + + if (p == x) return 1; + } while ((p = p->fd) != b); + } - } - else { + + } else { + bindex_t tidx; compute_tree_index(size, tidx); if (treemap_is_marked(m, tidx)) { + tchunkptr t = *treebin_at(m, tidx); - size_t sizebits = size << leftshift_for_tree_index(tidx); + size_t sizebits = size << leftshift_for_tree_index(tidx); while (t != 0 && chunksize(t) != size) { - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; + + t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; sizebits <<= 1; + } + if (t != 0) { + tchunkptr u = t; do { - if (u == (tchunkptr)x) - return 1; + + if (u == (tchunkptr)x) return 1; + } while ((u = u->fd) != t); + } + } + } + return 0; + } /* Traverse each chunk and check it; return total */ static size_t traverse_and_check(mstate m) { + size_t sum = 0; if (is_initialized(m)) { + msegmentptr s = &m->seg; sum += m->topsize + TOP_FOOT_SIZE; while (s != 0) { + mchunkptr q = align_as_chunk(s->base); mchunkptr lastq = 0; assert(pinuse(q)); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { + while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { + sum += chunksize(q); if (is_inuse(q)) { + assert(!bin_find(m, q)); do_check_inuse_chunk(m, q); - } - else { + + } else { + assert(q == m->dv || bin_find(m, q)); - assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ + assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ do_check_free_chunk(m, q); + } + lastq = q; q = next_chunk(q); + } + s = s->next; + } + } + return sum; -} +} /* Check all properties of malloc_state. */ static void do_check_malloc_state(mstate m) { + bindex_t i; - size_t total; + size_t total; /* check bins */ for (i = 0; i < NSMALLBINS; ++i) do_check_smallbin(m, i); for (i = 0; i < NTREEBINS; ++i) do_check_treebin(m, i); - if (m->dvsize != 0) { /* check dv chunk */ + if (m->dvsize != 0) { /* check dv chunk */ do_check_any_chunk(m, m->dv); assert(m->dvsize == chunksize(m->dv)); assert(m->dvsize >= MIN_CHUNK_SIZE); assert(bin_find(m, m->dv) == 0); + } - if (m->top != 0) { /* check top chunk */ + if (m->top != 0) { /* check top chunk */ do_check_top_chunk(m, m->top); /*assert(m->topsize == chunksize(m->top)); redundant */ assert(m->topsize > 0); assert(bin_find(m, m->top) == 0); + } total = traverse_and_check(m); assert(total <= m->footprint); assert(m->footprint <= m->max_footprint); + } -#endif /* DEBUG */ + + #endif /* DEBUG */ /* ----------------------------- statistics ------------------------------ */ -#if !NO_MALLINFO + #if !NO_MALLINFO static struct mallinfo internal_mallinfo(mstate m) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + + struct mallinfo nm = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; ensure_initialization(); if (!PREACTION(m)) { + check_malloc_state(m); if (is_initialized(m)) { - size_t nfree = SIZE_T_ONE; /* top always free */ - size_t mfree = m->topsize + TOP_FOOT_SIZE; - size_t sum = mfree; + + size_t nfree = SIZE_T_ONE; /* top always free */ + size_t mfree = m->topsize + TOP_FOOT_SIZE; + size_t sum = mfree; msegmentptr s = &m->seg; while (s != 0) { + mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { + while (segment_holds(s, q) && q != m->top && + q->head != FENCEPOST_HEAD) { + size_t sz = chunksize(q); sum += sz; if (!is_inuse(q)) { + mfree += sz; ++nfree; + } + q = next_chunk(q); + } + s = s->next; + } - nm.arena = sum; - nm.ordblks = nfree; - nm.hblkhd = m->footprint - sum; - nm.usmblks = m->max_footprint; + nm.arena = sum; + nm.ordblks = nfree; + nm.hblkhd = m->footprint - sum; + nm.usmblks = m->max_footprint; nm.uordblks = m->footprint - mfree; nm.fordblks = mfree; nm.keepcost = m->topsize; + } POSTACTION(m); + } + return nm; + } -#endif /* !NO_MALLINFO */ -#if !NO_MALLOC_STATS + #endif /* !NO_MALLINFO */ + + #if !NO_MALLOC_STATS static void internal_malloc_stats(mstate m) { + ensure_initialization(); if (!PREACTION(m)) { + size_t maxfp = 0; size_t fp = 0; size_t used = 0; check_malloc_state(m); if (is_initialized(m)) { + msegmentptr s = &m->seg; maxfp = m->max_footprint; fp = m->footprint; used = fp - (m->topsize + TOP_FOOT_SIZE); while (s != 0) { + mchunkptr q = align_as_chunk(s->base); - while (segment_holds(s, q) && - q != m->top && q->head != FENCEPOST_HEAD) { - if (!is_inuse(q)) - used -= chunksize(q); + while (segment_holds(s, q) && q != m->top && + q->head != FENCEPOST_HEAD) { + + if (!is_inuse(q)) used -= chunksize(q); q = next_chunk(q); + } + s = s->next; + } + } - POSTACTION(m); /* drop lock */ + + POSTACTION(m); /* drop lock */ fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); + } + } -#endif /* NO_MALLOC_STATS */ -/* ----------------------- Operations on smallbins ----------------------- */ + #endif /* NO_MALLOC_STATS */ -/* - Various forms of linking and unlinking are defined as macros. Even - the ones for trees, which are very long but have very short typical - paths. This is ugly but reduces reliance on inlining support of - compilers. -*/ + /* ----------------------- Operations on smallbins ----------------------- */ -/* Link a free chunk into a smallbin */ -#define insert_small_chunk(M, P, S) {\ - bindex_t I = small_index(S);\ - mchunkptr B = smallbin_at(M, I);\ - mchunkptr F = B;\ - assert(S >= MIN_CHUNK_SIZE);\ - if (!smallmap_is_marked(M, I))\ - mark_smallmap(M, I);\ - else if (RTCHECK(ok_address(M, B->fd)))\ - F = B->fd;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - B->fd = P;\ - F->bk = P;\ - P->fd = F;\ - P->bk = B;\ -} + /* + Various forms of linking and unlinking are defined as macros. Even + the ones for trees, which are very long but have very short typical + paths. This is ugly but reduces reliance on inlining support of + compilers. + */ -/* Unlink a chunk from a smallbin */ -#define unlink_small_chunk(M, P, S) {\ - mchunkptr F = P->fd;\ - mchunkptr B = P->bk;\ - bindex_t I = small_index(S);\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \ - if (B == F) {\ - clear_smallmap(M, I);\ - }\ - else if (RTCHECK(B == smallbin_at(M,I) ||\ - (ok_address(M, B) && B->fd == P))) {\ - F->bk = B;\ - B->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} + /* Link a free chunk into a smallbin */ + #define insert_small_chunk(M, P, S) \ + { \ + \ + bindex_t I = small_index(S); \ + mchunkptr B = smallbin_at(M, I); \ + mchunkptr F = B; \ + assert(S >= MIN_CHUNK_SIZE); \ + if (!smallmap_is_marked(M, I)) \ + mark_smallmap(M, I); \ + else if (RTCHECK(ok_address(M, B->fd))) \ + F = B->fd; \ + else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + B->fd = P; \ + F->bk = P; \ + P->fd = F; \ + P->bk = B; \ + \ + } -/* Unlink the first chunk from a smallbin */ -#define unlink_first_small_chunk(M, B, P, I) {\ - mchunkptr F = P->fd;\ - assert(P != B);\ - assert(P != F);\ - assert(chunksize(P) == small_index2size(I));\ - if (B == F) {\ - clear_smallmap(M, I);\ - }\ - else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\ - F->bk = B;\ - B->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ -} + /* Unlink a chunk from a smallbin */ + #define unlink_small_chunk(M, P, S) \ + { \ + \ + mchunkptr F = P->fd; \ + mchunkptr B = P->bk; \ + bindex_t I = small_index(S); \ + assert(P != B); \ + assert(P != F); \ + assert(chunksize(P) == small_index2size(I)); \ + if (RTCHECK(F == smallbin_at(M, I) || \ + (ok_address(M, F) && F->bk == P))) { \ + \ + if (B == F) { \ + \ + clear_smallmap(M, I); \ + \ + } else if (RTCHECK(B == smallbin_at(M, I) || \ + \ + (ok_address(M, B) && B->fd == P))) { \ + \ + F->bk = B; \ + B->fd = F; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } -/* Replace dv node, binning the old one */ -/* Used only when dvsize known to be small */ -#define replace_dv(M, P, S) {\ - size_t DVS = M->dvsize;\ - assert(is_small(DVS));\ - if (DVS != 0) {\ - mchunkptr DV = M->dv;\ - insert_small_chunk(M, DV, DVS);\ - }\ - M->dvsize = S;\ - M->dv = P;\ -} + /* Unlink the first chunk from a smallbin */ + #define unlink_first_small_chunk(M, B, P, I) \ + { \ + \ + mchunkptr F = P->fd; \ + assert(P != B); \ + assert(P != F); \ + assert(chunksize(P) == small_index2size(I)); \ + if (B == F) { \ + \ + clear_smallmap(M, I); \ + \ + } else if (RTCHECK(ok_address(M, F) && F->bk == P)) { \ + \ + F->bk = B; \ + B->fd = F; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } -/* ------------------------- Operations on trees ------------------------- */ - -/* Insert chunk into tree */ -#define insert_large_chunk(M, X, S) {\ - tbinptr* H;\ - bindex_t I;\ - compute_tree_index(S, I);\ - H = treebin_at(M, I);\ - X->index = I;\ - X->child[0] = X->child[1] = 0;\ - if (!treemap_is_marked(M, I)) {\ - mark_treemap(M, I);\ - *H = X;\ - X->parent = (tchunkptr)H;\ - X->fd = X->bk = X;\ - }\ - else {\ - tchunkptr T = *H;\ - size_t K = S << leftshift_for_tree_index(I);\ - for (;;) {\ - if (chunksize(T) != S) {\ - tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ - K <<= 1;\ - if (*C != 0)\ - T = *C;\ - else if (RTCHECK(ok_address(M, C))) {\ - *C = X;\ - X->parent = T;\ - X->fd = X->bk = X;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - else {\ - tchunkptr F = T->fd;\ - if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ - T->fd = F->bk = X;\ - X->fd = F;\ - X->bk = T;\ - X->parent = 0;\ - break;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - break;\ - }\ - }\ - }\ - }\ -} + /* Replace dv node, binning the old one */ + /* Used only when dvsize known to be small */ + #define replace_dv(M, P, S) \ + { \ + \ + size_t DVS = M->dvsize; \ + assert(is_small(DVS)); \ + if (DVS != 0) { \ + \ + mchunkptr DV = M->dv; \ + insert_small_chunk(M, DV, DVS); \ + \ + } \ + M->dvsize = S; \ + M->dv = P; \ + \ + } + + /* ------------------------- Operations on trees ------------------------- */ + + /* Insert chunk into tree */ + #define insert_large_chunk(M, X, S) \ + { \ + \ + tbinptr *H; \ + bindex_t I; \ + compute_tree_index(S, I); \ + H = treebin_at(M, I); \ + X->index = I; \ + X->child[0] = X->child[1] = 0; \ + if (!treemap_is_marked(M, I)) { \ + \ + mark_treemap(M, I); \ + *H = X; \ + X->parent = (tchunkptr)H; \ + X->fd = X->bk = X; \ + \ + } else { \ + \ + tchunkptr T = *H; \ + size_t K = S << leftshift_for_tree_index(I); \ + for (;;) { \ + \ + if (chunksize(T) != S) { \ + \ + tchunkptr *C = \ + &(T->child[(K >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]); \ + K <<= 1; \ + if (*C != 0) \ + T = *C; \ + else if (RTCHECK(ok_address(M, C))) { \ + \ + *C = X; \ + X->parent = T; \ + X->fd = X->bk = X; \ + break; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + break; \ + \ + } \ + \ + } else { \ + \ + tchunkptr F = T->fd; \ + if (RTCHECK(ok_address(M, T) && ok_address(M, F))) { \ + \ + T->fd = F->bk = X; \ + X->fd = F; \ + X->bk = T; \ + X->parent = 0; \ + break; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + break; \ + \ + } \ + \ + } \ + \ + } \ + \ + } \ + \ + } /* Unlink steps: @@ -3764,104 +4068,145 @@ static void internal_malloc_stats(mstate m) { x's parent and children to x's replacement (or null if none). */ -#define unlink_large_chunk(M, X) {\ - tchunkptr XP = X->parent;\ - tchunkptr R;\ - if (X->bk != X) {\ - tchunkptr F = X->fd;\ - R = X->bk;\ - if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) {\ - F->bk = R;\ - R->fd = F;\ - }\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else {\ - tchunkptr* RP;\ - if (((R = *(RP = &(X->child[1]))) != 0) ||\ - ((R = *(RP = &(X->child[0]))) != 0)) {\ - tchunkptr* CP;\ - while ((*(CP = &(R->child[1])) != 0) ||\ - (*(CP = &(R->child[0])) != 0)) {\ - R = *(RP = CP);\ - }\ - if (RTCHECK(ok_address(M, RP)))\ - *RP = 0;\ - else {\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - }\ - if (XP != 0) {\ - tbinptr* H = treebin_at(M, X->index);\ - if (X == *H) {\ - if ((*H = R) == 0) \ - clear_treemap(M, X->index);\ - }\ - else if (RTCHECK(ok_address(M, XP))) {\ - if (XP->child[0] == X) \ - XP->child[0] = R;\ - else \ - XP->child[1] = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - if (R != 0) {\ - if (RTCHECK(ok_address(M, R))) {\ - tchunkptr C0, C1;\ - R->parent = XP;\ - if ((C0 = X->child[0]) != 0) {\ - if (RTCHECK(ok_address(M, C0))) {\ - R->child[0] = C0;\ - C0->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - if ((C1 = X->child[1]) != 0) {\ - if (RTCHECK(ok_address(M, C1))) {\ - R->child[1] = C1;\ - C1->parent = R;\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ - else\ - CORRUPTION_ERROR_ACTION(M);\ - }\ - }\ -} + #define unlink_large_chunk(M, X) \ + { \ + \ + tchunkptr XP = X->parent; \ + tchunkptr R; \ + if (X->bk != X) { \ + \ + tchunkptr F = X->fd; \ + R = X->bk; \ + if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) { \ + \ + F->bk = R; \ + R->fd = F; \ + \ + } else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } else { \ + \ + tchunkptr *RP; \ + if (((R = *(RP = &(X->child[1]))) != 0) || \ + ((R = *(RP = &(X->child[0]))) != 0)) { \ + \ + tchunkptr *CP; \ + while ((*(CP = &(R->child[1])) != 0) || \ + (*(CP = &(R->child[0])) != 0)) { \ + \ + R = *(RP = CP); \ + \ + } \ + if (RTCHECK(ok_address(M, RP))) \ + *RP = 0; \ + else { \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } \ + \ + } \ + if (XP != 0) { \ + \ + tbinptr *H = treebin_at(M, X->index); \ + if (X == *H) { \ + \ + if ((*H = R) == 0) clear_treemap(M, X->index); \ + \ + } else if (RTCHECK(ok_address(M, XP))) { \ + \ + if (XP->child[0] == X) \ + XP->child[0] = R; \ + else \ + XP->child[1] = R; \ + \ + } else \ + \ + CORRUPTION_ERROR_ACTION(M); \ + if (R != 0) { \ + \ + if (RTCHECK(ok_address(M, R))) { \ + \ + tchunkptr C0, C1; \ + R->parent = XP; \ + if ((C0 = X->child[0]) != 0) { \ + \ + if (RTCHECK(ok_address(M, C0))) { \ + \ + R->child[0] = C0; \ + C0->parent = R; \ + \ + } else \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + if ((C1 = X->child[1]) != 0) { \ + \ + if (RTCHECK(ok_address(M, C1))) { \ + \ + R->child[1] = C1; \ + C1->parent = R; \ + \ + } else \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } else \ + \ + CORRUPTION_ERROR_ACTION(M); \ + \ + } \ + \ + } \ + \ + } /* Relays to large vs small bin operations */ -#define insert_chunk(M, P, S)\ - if (is_small(S)) insert_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } - -#define unlink_chunk(M, P, S)\ - if (is_small(S)) unlink_small_chunk(M, P, S)\ - else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } + #define insert_chunk(M, P, S) \ + if (is_small(S)) insert_small_chunk(M, P, S) else { \ + \ + tchunkptr TP = (tchunkptr)(P); \ + insert_large_chunk(M, TP, S); \ + \ + } + #define unlink_chunk(M, P, S) \ + if (is_small(S)) unlink_small_chunk(M, P, S) else { \ + \ + tchunkptr TP = (tchunkptr)(P); \ + unlink_large_chunk(M, TP); \ + \ + } /* Relays to internal calls to malloc/free from realloc, memalign etc */ -#if ONLY_MSPACES -#define internal_malloc(m, b) mspace_malloc(m, b) -#define internal_free(m, mem) mspace_free(m,mem); -#else /* ONLY_MSPACES */ -#if MSPACES -#define internal_malloc(m, b)\ - ((m == gm)? dlmalloc(b) : mspace_malloc(m, b)) -#define internal_free(m, mem)\ - if (m == gm) dlfree(mem); else mspace_free(m,mem); -#else /* MSPACES */ -#define internal_malloc(m, b) dlmalloc(b) -#define internal_free(m, mem) dlfree(mem) -#endif /* MSPACES */ -#endif /* ONLY_MSPACES */ + #if ONLY_MSPACES + #define internal_malloc(m, b) mspace_malloc(m, b) + #define internal_free(m, mem) mspace_free(m, mem); + #else /* ONLY_MSPACES */ + #if MSPACES + #define internal_malloc(m, b) \ + ((m == gm) ? dlmalloc(b) : mspace_malloc(m, b)) + #define internal_free(m, mem) \ + if (m == gm) \ + dlfree(mem); \ + else \ + mspace_free(m, mem); + #else /* MSPACES */ + #define internal_malloc(m, b) dlmalloc(b) + #define internal_free(m, mem) dlfree(mem) + #endif /* MSPACES */ + #endif /* ONLY_MSPACES */ /* ----------------------- Direct-mmapping chunks ----------------------- */ @@ -3874,80 +4219,93 @@ static void internal_malloc_stats(mstate m) { */ /* Malloc using mmap */ -static void* mmap_alloc(mstate m, size_t nb) { +static void *mmap_alloc(mstate m, size_t nb) { + size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); if (m->footprint_limit != 0) { + size_t fp = m->footprint + mmsize; - if (fp <= m->footprint || fp > m->footprint_limit) - return 0; + if (fp <= m->footprint || fp > m->footprint_limit) return 0; + } - if (mmsize > nb) { /* Check for wrap around 0 */ - char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); + + if (mmsize > nb) { /* Check for wrap around 0 */ + char *mm = (char *)(CALL_DIRECT_MMAP(mmsize)); if (mm != CMFAIL) { - size_t offset = align_offset(chunk2mem(mm)); - size_t psize = mmsize - offset - MMAP_FOOT_PAD; + + size_t offset = align_offset(chunk2mem(mm)); + size_t psize = mmsize - offset - MMAP_FOOT_PAD; mchunkptr p = (mchunkptr)(mm + offset); p->prev_foot = offset; p->head = psize; mark_inuse_foot(m, p, psize); chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; + chunk_plus_offset(p, psize + SIZE_T_SIZE)->head = 0; - if (m->least_addr == 0 || mm < m->least_addr) - m->least_addr = mm; + if (m->least_addr == 0 || mm < m->least_addr) m->least_addr = mm; if ((m->footprint += mmsize) > m->max_footprint) m->max_footprint = m->footprint; assert(is_aligned(chunk2mem(p))); check_mmapped_chunk(m, p); return chunk2mem(p); + } + } + return 0; + } /* Realloc using mmap */ static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) { + size_t oldsize = chunksize(oldp); - (void)flags; /* placate people compiling -Wunused */ - if (is_small(nb)) /* Can't shrink mmap regions below small size */ + (void)flags; /* placate people compiling -Wunused */ + if (is_small(nb)) /* Can't shrink mmap regions below small size */ return 0; /* Keep old chunk if big enough but not too big */ if (oldsize >= nb + SIZE_T_SIZE && (oldsize - nb) <= (mparams.granularity << 1)) return oldp; else { + size_t offset = oldp->prev_foot; size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - char* cp = (char*)CALL_MREMAP((char*)oldp - offset, - oldmmsize, newmmsize, flags); + char * cp = + (char *)CALL_MREMAP((char *)oldp - offset, oldmmsize, newmmsize, flags); if (cp != CMFAIL) { + mchunkptr newp = (mchunkptr)(cp + offset); - size_t psize = newmmsize - offset - MMAP_FOOT_PAD; + size_t psize = newmmsize - offset - MMAP_FOOT_PAD; newp->head = psize; mark_inuse_foot(m, newp, psize); chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; - chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; + chunk_plus_offset(newp, psize + SIZE_T_SIZE)->head = 0; - if (cp < m->least_addr) - m->least_addr = cp; + if (cp < m->least_addr) m->least_addr = cp; if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) m->max_footprint = m->footprint; check_mmapped_chunk(m, newp); return newp; + } + } + return 0; -} +} /* -------------------------- mspace management -------------------------- */ /* Initialize top chunk and its size */ static void init_top(mstate m, mchunkptr p, size_t psize) { + /* Ensure alignment */ size_t offset = align_offset(chunk2mem(p)); - p = (mchunkptr)((char*)p + offset); + p = (mchunkptr)((char *)p + offset); psize -= offset; m->top = p; @@ -3955,23 +4313,29 @@ static void init_top(mstate m, mchunkptr p, size_t psize) { p->head = psize | PINUSE_BIT; /* set size of fake trailing chunk holding overhead space only once */ chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; - m->trim_check = mparams.trim_threshold; /* reset on each update */ + m->trim_check = mparams.trim_threshold; /* reset on each update */ + } /* Initialize bins for a new mstate that is otherwise zeroed out */ static void init_bins(mstate m) { + /* Establish circular links for smallbins */ bindex_t i; for (i = 0; i < NSMALLBINS; ++i) { - sbinptr bin = smallbin_at(m,i); + + sbinptr bin = smallbin_at(m, i); bin->fd = bin->bk = bin; + } + } -#if PROCEED_ON_ERROR + #if PROCEED_ON_ERROR /* default corruption action */ static void reset_on_error(mstate m) { + int i; ++malloc_corruption_error_count; /* Reinitialize fields to forget about all memory */ @@ -3984,67 +4348,78 @@ static void reset_on_error(mstate m) { for (i = 0; i < NTREEBINS; ++i) *treebin_at(m, i) = 0; init_bins(m); + } -#endif /* PROCEED_ON_ERROR */ + + #endif /* PROCEED_ON_ERROR */ /* Allocate chunk and prepend remainder with chunk in successor base. */ -static void* prepend_alloc(mstate m, char* newbase, char* oldbase, - size_t nb) { +static void *prepend_alloc(mstate m, char *newbase, char *oldbase, size_t nb) { + mchunkptr p = align_as_chunk(newbase); mchunkptr oldfirst = align_as_chunk(oldbase); - size_t psize = (char*)oldfirst - (char*)p; + size_t psize = (char *)oldfirst - (char *)p; mchunkptr q = chunk_plus_offset(p, nb); - size_t qsize = psize - nb; + size_t qsize = psize - nb; set_size_and_pinuse_of_inuse_chunk(m, p, nb); - assert((char*)oldfirst > (char*)q); + assert((char *)oldfirst > (char *)q); assert(pinuse(oldfirst)); assert(qsize >= MIN_CHUNK_SIZE); /* consolidate remainder with first chunk of old base */ if (oldfirst == m->top) { + size_t tsize = m->topsize += qsize; m->top = q; q->head = tsize | PINUSE_BIT; check_top_chunk(m, q); - } - else if (oldfirst == m->dv) { + + } else if (oldfirst == m->dv) { + size_t dsize = m->dvsize += qsize; m->dv = q; set_size_and_pinuse_of_free_chunk(q, dsize); - } - else { + + } else { + if (!is_inuse(oldfirst)) { + size_t nsize = chunksize(oldfirst); unlink_chunk(m, oldfirst, nsize); oldfirst = chunk_plus_offset(oldfirst, nsize); qsize += nsize; + } + set_free_with_pinuse(q, qsize, oldfirst); insert_chunk(m, q, qsize); check_free_chunk(m, q); + } check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); + } /* Add a segment to hold a new noncontiguous region */ -static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { +static void add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped) { + /* Determine locations and sizes of segment, fenceposts, old top */ - char* old_top = (char*)m->top; + char * old_top = (char *)m->top; msegmentptr oldsp = segment_holding(m, old_top); - char* old_end = oldsp->base + oldsp->size; - size_t ssize = pad_request(sizeof(struct malloc_segment)); - char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); - size_t offset = align_offset(chunk2mem(rawsp)); - char* asp = rawsp + offset; - char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; - mchunkptr sp = (mchunkptr)csp; + char * old_end = oldsp->base + oldsp->size; + size_t ssize = pad_request(sizeof(struct malloc_segment)); + char * rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); + size_t offset = align_offset(chunk2mem(rawsp)); + char * asp = rawsp + offset; + char * csp = (asp < (old_top + MIN_CHUNK_SIZE)) ? old_top : asp; + mchunkptr sp = (mchunkptr)csp; msegmentptr ss = (msegmentptr)(chunk2mem(sp)); - mchunkptr tnext = chunk_plus_offset(sp, ssize); - mchunkptr p = tnext; - int nfences = 0; + mchunkptr tnext = chunk_plus_offset(sp, ssize); + mchunkptr p = tnext; + int nfences = 0; /* reset top to new space */ init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); @@ -4052,7 +4427,7 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { /* Set up segment record */ assert(is_aligned(ss)); set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); - *ss = m->seg; /* Push current record */ + *ss = m->seg; /* Push current record */ m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmapped; @@ -4060,53 +4435,61 @@ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { /* Insert trailing fenceposts */ for (;;) { + mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); p->head = FENCEPOST_HEAD; ++nfences; - if ((char*)(&(nextp->head)) < old_end) + if ((char *)(&(nextp->head)) < old_end) p = nextp; else break; + } + assert(nfences >= 2); /* Insert the rest of old top into a bin as an ordinary free chunk */ if (csp != old_top) { + mchunkptr q = (mchunkptr)old_top; - size_t psize = csp - old_top; + size_t psize = csp - old_top; mchunkptr tn = chunk_plus_offset(q, psize); set_free_with_pinuse(q, psize, tn); insert_chunk(m, q, psize); + } check_top_chunk(m, m->top); + } /* -------------------------- System allocation -------------------------- */ /* Get memory from system using MORECORE or MMAP */ -static void* sys_alloc(mstate m, size_t nb) { - char* tbase = CMFAIL; +static void *sys_alloc(mstate m, size_t nb) { + + char * tbase = CMFAIL; size_t tsize = 0; flag_t mmap_flag = 0; - size_t asize; /* allocation size */ + size_t asize; /* allocation size */ ensure_initialization(); /* Directly map large chunks, but only if already initialized */ if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { - void* mem = mmap_alloc(m, nb); - if (mem != 0) - return mem; + + void *mem = mmap_alloc(m, nb); + if (mem != 0) return mem; + } asize = granularity_align(nb + SYS_ALLOC_PADDING); - if (asize <= nb) - return 0; /* wraparound */ + if (asize <= nb) return 0; /* wraparound */ if (m->footprint_limit != 0) { + size_t fp = m->footprint + asize; - if (fp <= m->footprint || fp > m->footprint_limit) - return 0; + if (fp <= m->footprint || fp > m->footprint_limit) return 0; + } /* @@ -4132,91 +4515,119 @@ static void* sys_alloc(mstate m, size_t nb) { */ if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { - char* br = CMFAIL; - size_t ssize = asize; /* sbrk call size */ - msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); + + char * br = CMFAIL; + size_t ssize = asize; /* sbrk call size */ + msegmentptr ss = (m->top == 0) ? 0 : segment_holding(m, (char *)m->top); ACQUIRE_MALLOC_GLOBAL_LOCK(); - if (ss == 0) { /* First time through or recovery */ - char* base = (char*)CALL_MORECORE(0); + if (ss == 0) { /* First time through or recovery */ + char *base = (char *)CALL_MORECORE(0); if (base != CMFAIL) { + size_t fp; /* Adjust to end on a page boundary */ if (!is_page_aligned(base)) ssize += (page_align((size_t)base) - (size_t)base); - fp = m->footprint + ssize; /* recheck limits */ + fp = m->footprint + ssize; /* recheck limits */ if (ssize > nb && ssize < HALF_MAX_SIZE_T && (m->footprint_limit == 0 || (fp > m->footprint && fp <= m->footprint_limit)) && - (br = (char*)(CALL_MORECORE(ssize))) == base) { + (br = (char *)(CALL_MORECORE(ssize))) == base) { + tbase = base; tsize = ssize; + } + } - } - else { + + } else { + /* Subtract out existing available top space from MORECORE request. */ ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); /* Use mem here only if it did continuously extend old space */ if (ssize < HALF_MAX_SIZE_T && - (br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) { + (br = (char *)(CALL_MORECORE(ssize))) == ss->base + ss->size) { + tbase = br; tsize = ssize; + } + } - if (tbase == CMFAIL) { /* Cope with partial failure */ - if (br != CMFAIL) { /* Try to use/extend the space we did get */ - if (ssize < HALF_MAX_SIZE_T && - ssize < nb + SYS_ALLOC_PADDING) { + if (tbase == CMFAIL) { /* Cope with partial failure */ + if (br != CMFAIL) { /* Try to use/extend the space we did get */ + if (ssize < HALF_MAX_SIZE_T && ssize < nb + SYS_ALLOC_PADDING) { + size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize); if (esize < HALF_MAX_SIZE_T) { - char* end = (char*)CALL_MORECORE(esize); + + char *end = (char *)CALL_MORECORE(esize); if (end != CMFAIL) ssize += esize; - else { /* Can't use; try to release */ - (void) CALL_MORECORE(-ssize); + else { /* Can't use; try to release */ + (void)CALL_MORECORE(-ssize); br = CMFAIL; + } + } + } + } - if (br != CMFAIL) { /* Use the space we did get */ + + if (br != CMFAIL) { /* Use the space we did get */ tbase = br; tsize = ssize; - } - else - disable_contiguous(m); /* Don't try contiguous path in the future */ + + } else + + disable_contiguous(m); /* Don't try contiguous path in the future */ + } RELEASE_MALLOC_GLOBAL_LOCK(); + } - if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ - char* mp = (char*)(CALL_MMAP(asize)); + if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ + char *mp = (char *)(CALL_MMAP(asize)); if (mp != CMFAIL) { + tbase = mp; tsize = asize; mmap_flag = USE_MMAP_BIT; + } + } - if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ + if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ if (asize < HALF_MAX_SIZE_T) { - char* br = CMFAIL; - char* end = CMFAIL; + + char *br = CMFAIL; + char *end = CMFAIL; ACQUIRE_MALLOC_GLOBAL_LOCK(); - br = (char*)(CALL_MORECORE(asize)); - end = (char*)(CALL_MORECORE(0)); + br = (char *)(CALL_MORECORE(asize)); + end = (char *)(CALL_MORECORE(0)); RELEASE_MALLOC_GLOBAL_LOCK(); if (br != CMFAIL && end != CMFAIL && br < end) { + size_t ssize = end - br; if (ssize > nb + TOP_FOOT_SIZE) { + tbase = br; tsize = ssize; + } + } + } + } if (tbase != CMFAIL) { @@ -4224,61 +4635,66 @@ static void* sys_alloc(mstate m, size_t nb) { if ((m->footprint += tsize) > m->max_footprint) m->max_footprint = m->footprint; - if (!is_initialized(m)) { /* first-time initialization */ - if (m->least_addr == 0 || tbase < m->least_addr) - m->least_addr = tbase; + if (!is_initialized(m)) { /* first-time initialization */ + if (m->least_addr == 0 || tbase < m->least_addr) m->least_addr = tbase; m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmap_flag; m->magic = mparams.magic; m->release_checks = MAX_RELEASE_CHECK_RATE; init_bins(m); -#if !ONLY_MSPACES + #if !ONLY_MSPACES if (is_global(m)) init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); else -#endif + #endif { + /* Offset top by embedded malloc_state */ mchunkptr mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); + init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); + } + } else { + /* Try to merge with an existing segment */ msegmentptr sp = &m->seg; /* Only consider most recent segment if traversal suppressed */ while (sp != 0 && tbase != sp->base + sp->size) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; - if (sp != 0 && - !is_extern_segment(sp) && + if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag && - segment_holds(sp, m->top)) { /* append */ + segment_holds(sp, m->top)) { /* append */ sp->size += tsize; init_top(m, m->top, m->topsize + tsize); - } - else { - if (tbase < m->least_addr) - m->least_addr = tbase; + + } else { + + if (tbase < m->least_addr) m->least_addr = tbase; sp = &m->seg; while (sp != 0 && sp->base != tbase + tsize) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; - if (sp != 0 && - !is_extern_segment(sp) && + if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag) { - char* oldbase = sp->base; + + char *oldbase = sp->base; sp->base = tbase; sp->size += tsize; return prepend_alloc(m, tbase, oldbase, nb); - } - else + + } else + add_segment(m, tbase, tsize, mmap_flag); + } + } - if (nb < m->topsize) { /* Allocate from new or extended top space */ - size_t rsize = m->topsize -= nb; + if (nb < m->topsize) { /* Allocate from new or extended top space */ + size_t rsize = m->topsize -= nb; mchunkptr p = m->top; mchunkptr r = m->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -4286,353 +4702,463 @@ static void* sys_alloc(mstate m, size_t nb) { check_top_chunk(m, m->top); check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); + } + } MALLOC_FAILURE_ACTION; return 0; + } /* ----------------------- system deallocation -------------------------- */ /* Unmap and unlink any mmapped segments that don't contain used chunks */ static size_t release_unused_segments(mstate m) { - size_t released = 0; - int nsegs = 0; + + size_t released = 0; + int nsegs = 0; msegmentptr pred = &m->seg; msegmentptr sp = pred->next; while (sp != 0) { - char* base = sp->base; - size_t size = sp->size; + + char * base = sp->base; + size_t size = sp->size; msegmentptr next = sp->next; ++nsegs; if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { + mchunkptr p = align_as_chunk(base); - size_t psize = chunksize(p); + size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ - if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { + if (!is_inuse(p) && (char *)p + psize >= base + size - TOP_FOOT_SIZE) { + tchunkptr tp = (tchunkptr)p; - assert(segment_holds(sp, (char*)sp)); + assert(segment_holds(sp, (char *)sp)); if (p == m->dv) { + m->dv = 0; m->dvsize = 0; - } - else { + + } else { + unlink_large_chunk(m, tp); + } + if (CALL_MUNMAP(base, size) == 0) { + released += size; m->footprint -= size; /* unlink obsoleted record */ sp = pred; sp->next = next; - } - else { /* back out if cannot unmap */ + + } else { /* back out if cannot unmap */ + insert_large_chunk(m, tp, psize); + } + } + } - if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ + + if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ break; pred = sp; sp = next; + } + /* Reset check counter */ - m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)? - (size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE); + m->release_checks = (((size_t)nsegs > (size_t)MAX_RELEASE_CHECK_RATE) + ? (size_t)nsegs + : (size_t)MAX_RELEASE_CHECK_RATE); return released; + } static int sys_trim(mstate m, size_t pad) { + size_t released = 0; ensure_initialization(); if (pad < MAX_REQUEST && is_initialized(m)) { - pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ + + pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ if (m->topsize > pad) { + /* Shrink top space in granularity-size units, keeping at least one */ size_t unit = mparams.granularity; - size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - - SIZE_T_ONE) * unit; - msegmentptr sp = segment_holding(m, (char*)m->top); + size_t extra = + ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - SIZE_T_ONE) * unit; + msegmentptr sp = segment_holding(m, (char *)m->top); if (!is_extern_segment(sp)) { + if (is_mmapped_segment(sp)) { - if (HAVE_MMAP && - sp->size >= extra && - !has_segment_link(m, sp)) { /* can't shrink if pinned */ + + if (HAVE_MMAP && sp->size >= extra && + !has_segment_link(m, sp)) { /* can't shrink if pinned */ size_t newsize = sp->size - extra; - (void)newsize; /* placate people compiling -Wunused-variable */ + (void)newsize; /* placate people compiling -Wunused-variable */ /* Prefer mremap, fall back to munmap */ if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { + released = extra; + } + } - } - else if (HAVE_MORECORE) { - if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ + + } else if (HAVE_MORECORE) { + + if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; ACQUIRE_MALLOC_GLOBAL_LOCK(); { + /* Make sure end of memory is where we last set it. */ - char* old_br = (char*)(CALL_MORECORE(0)); + char *old_br = (char *)(CALL_MORECORE(0)); if (old_br == sp->base + sp->size) { - char* rel_br = (char*)(CALL_MORECORE(-extra)); - char* new_br = (char*)(CALL_MORECORE(0)); + + char *rel_br = (char *)(CALL_MORECORE(-extra)); + char *new_br = (char *)(CALL_MORECORE(0)); if (rel_br != CMFAIL && new_br < old_br) released = old_br - new_br; + } + } + RELEASE_MALLOC_GLOBAL_LOCK(); + } + } if (released != 0) { + sp->size -= released; m->footprint -= released; init_top(m, m->top, m->topsize - released); check_top_chunk(m, m->top); + } + } /* Unmap any unused mmapped segments */ - if (HAVE_MMAP) - released += release_unused_segments(m); + if (HAVE_MMAP) released += release_unused_segments(m); /* On failure, disable autotrim to avoid repeated failed future calls */ - if (released == 0 && m->topsize > m->trim_check) - m->trim_check = MAX_SIZE_T; + if (released == 0 && m->topsize > m->trim_check) m->trim_check = MAX_SIZE_T; + } - return (released != 0)? 1 : 0; + return (released != 0) ? 1 : 0; + } /* Consolidate and bin a chunk. Differs from exported versions of free mainly in that the chunk need not be marked as inuse. */ static void dispose_chunk(mstate m, mchunkptr p, size_t psize) { + mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { + mchunkptr prev; - size_t prevsize = p->prev_foot; + size_t prevsize = p->prev_foot; if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) - m->footprint -= psize; + if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) m->footprint -= psize; return; + } + prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ if (p != m->dv) { + unlink_chunk(m, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { + + } else if ((next->head & INUSE_BITS) == INUSE_BITS) { + m->dvsize = psize; set_free_with_pinuse(p, psize, next); return; + } - } - else { + + } else { + CORRUPTION_ERROR_ACTION(m); return; + } + } + if (RTCHECK(ok_address(m, next))) { - if (!cinuse(next)) { /* consolidate forward */ + + if (!cinuse(next)) { /* consolidate forward */ if (next == m->top) { + size_t tsize = m->topsize += psize; m->top = p; p->head = tsize | PINUSE_BIT; if (p == m->dv) { + m->dv = 0; m->dvsize = 0; + } + return; - } - else if (next == m->dv) { + + } else if (next == m->dv) { + size_t dsize = m->dvsize += psize; m->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); return; - } - else { + + } else { + size_t nsize = chunksize(next); psize += nsize; unlink_chunk(m, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == m->dv) { + m->dvsize = psize; return; + } + } - } - else { + + } else { + set_free_with_pinuse(p, psize, next); + } + insert_chunk(m, p, psize); - } - else { + + } else { + CORRUPTION_ERROR_ACTION(m); + } + } /* ---------------------------- malloc --------------------------- */ /* allocate a large request from the best fitting chunk in a treebin */ -static void* tmalloc_large(mstate m, size_t nb) { +static void *tmalloc_large(mstate m, size_t nb) { + tchunkptr v = 0; - size_t rsize = -nb; /* Unsigned negation */ + size_t rsize = -nb; /* Unsigned negation */ tchunkptr t; - bindex_t idx; + bindex_t idx; compute_tree_index(nb, idx); if ((t = *treebin_at(m, idx)) != 0) { + /* Traverse tree for this bin looking for node with size == nb */ - size_t sizebits = nb << leftshift_for_tree_index(idx); - tchunkptr rst = 0; /* The deepest untaken right subtree */ + size_t sizebits = nb << leftshift_for_tree_index(idx); + tchunkptr rst = 0; /* The deepest untaken right subtree */ for (;;) { + tchunkptr rt; - size_t trem = chunksize(t) - nb; + size_t trem = chunksize(t) - nb; if (trem < rsize) { + v = t; - if ((rsize = trem) == 0) - break; + if ((rsize = trem) == 0) break; + } + rt = t->child[1]; - t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; - if (rt != 0 && rt != t) - rst = rt; + t = t->child[(sizebits >> (SIZE_T_BITSIZE - SIZE_T_ONE)) & 1]; + if (rt != 0 && rt != t) rst = rt; if (t == 0) { - t = rst; /* set t to least subtree holding sizes > nb */ + + t = rst; /* set t to least subtree holding sizes > nb */ break; + } + sizebits <<= 1; + } + } - if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ + + if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; if (leftbits != 0) { + bindex_t i; binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); t = *treebin_at(m, i); + } + } - while (t != 0) { /* find smallest of tree or subtree */ + while (t != 0) { /* find smallest of tree or subtree */ size_t trem = chunksize(t) - nb; if (trem < rsize) { + rsize = trem; v = t; + } + t = leftmost_child(t); + } /* If dv is a better fit, return 0 so malloc will use it */ if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { - if (RTCHECK(ok_address(m, v))) { /* split */ + + if (RTCHECK(ok_address(m, v))) { /* split */ mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); insert_chunk(m, r, rsize); + } + return chunk2mem(v); + } + } + CORRUPTION_ERROR_ACTION(m); + } + return 0; + } /* allocate a small request from the best fitting chunk in a treebin */ -static void* tmalloc_small(mstate m, size_t nb) { +static void *tmalloc_small(mstate m, size_t nb) { + tchunkptr t, v; - size_t rsize; - bindex_t i; - binmap_t leastbit = least_bit(m->treemap); + size_t rsize; + bindex_t i; + binmap_t leastbit = least_bit(m->treemap); compute_bit2idx(leastbit, i); v = t = *treebin_at(m, i); rsize = chunksize(t) - nb; while ((t = leftmost_child(t)) != 0) { + size_t trem = chunksize(t) - nb; if (trem < rsize) { + rsize = trem; v = t; + } + } if (RTCHECK(ok_address(m, v))) { + mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { + unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { + set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(m, r, rsize); + } + return chunk2mem(v); + } + } CORRUPTION_ERROR_ACTION(m); return 0; -} -#if !ONLY_MSPACES +} -void* dlmalloc(size_t bytes) { - /* - Basic algorithm: - If a small request (< 256 bytes minus per-chunk overhead): - 1. If one exists, use a remainderless chunk in associated smallbin. - (Remainderless means that there are too few excess bytes to - represent as a chunk.) - 2. If it is big enough, use the dv chunk, which is normally the - chunk adjacent to the one used for the most recent small request. - 3. If one exists, split the smallest available chunk in a bin, - saving remainder in dv. - 4. If it is big enough, use the top chunk. - 5. If available, get memory from system and use it - Otherwise, for a large request: - 1. Find the smallest available binned chunk that fits, and use it - if it is better fitting than dv chunk, splitting if necessary. - 2. If better fitting than any binned chunk, use the dv chunk. - 3. If it is big enough, use the top chunk. - 4. If request size >= mmap threshold, try to directly mmap this chunk. - 5. If available, get memory from system and use it - - The ugly goto's here ensure that postaction occurs along all paths. - */ + #if !ONLY_MSPACES + +void *dlmalloc(size_t bytes) { + + /* + Basic algorithm: + If a small request (< 256 bytes minus per-chunk overhead): + 1. If one exists, use a remainderless chunk in associated smallbin. + (Remainderless means that there are too few excess bytes to + represent as a chunk.) + 2. If it is big enough, use the dv chunk, which is normally the + chunk adjacent to the one used for the most recent small request. + 3. If one exists, split the smallest available chunk in a bin, + saving remainder in dv. + 4. If it is big enough, use the top chunk. + 5. If available, get memory from system and use it + Otherwise, for a large request: + 1. Find the smallest available binned chunk that fits, and use it + if it is better fitting than dv chunk, splitting if necessary. + 2. If better fitting than any binned chunk, use the dv chunk. + 3. If it is big enough, use the top chunk. + 4. If request size >= mmap threshold, try to directly mmap this chunk. + 5. If available, get memory from system and use it + + The ugly goto's here ensure that postaction occurs along all paths. + */ -#if USE_LOCKS - ensure_initialization(); /* initialize in sys_alloc if not using locks */ -#endif + #if USE_LOCKS + ensure_initialization(); /* initialize in sys_alloc if not using locks */ + #endif if (!PREACTION(gm)) { - void* mem; + + void * mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = gm->smallmap >> idx; - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ + idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(gm, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); @@ -4641,15 +5167,17 @@ void* dlmalloc(size_t bytes) { mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; + } else if (nb > gm->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(gm, i); p = b->fd; @@ -4660,54 +5188,71 @@ void* dlmalloc(size_t bytes) { if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(gm, p, small_index2size(i)); else { + set_size_and_pinuse_of_inuse_chunk(gm, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(gm, r, rsize); + } + mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; + } else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); goto postaction; + } + } - } - else if (bytes >= MAX_REQUEST) + + } else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { + nb = pad_request(bytes); if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { + check_malloced_chunk(gm, mem, nb); goto postaction; + } + } if (nb <= gm->dvsize) { - size_t rsize = gm->dvsize - nb; + + size_t rsize = gm->dvsize - nb; mchunkptr p = gm->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = gm->dv = chunk_plus_offset(p, nb); gm->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(gm, p, nb); - } - else { /* exhaust dv */ + + } else { /* exhaust dv */ + size_t dvs = gm->dvsize; gm->dvsize = 0; gm->dv = 0; set_inuse_and_pinuse(gm, p, dvs); + } + mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; + } - else if (nb < gm->topsize) { /* Split top */ - size_t rsize = gm->topsize -= nb; + else if (nb < gm->topsize) { /* Split top */ + size_t rsize = gm->topsize -= nb; mchunkptr p = gm->top; mchunkptr r = gm->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -4716,6 +5261,7 @@ void* dlmalloc(size_t bytes) { check_top_chunk(gm, gm->top); check_malloced_chunk(gm, mem, nb); goto postaction; + } mem = sys_alloc(gm, nb); @@ -4723,14 +5269,17 @@ void* dlmalloc(size_t bytes) { postaction: POSTACTION(gm); return mem; + } return 0; + } /* ---------------------------- free --------------------------- */ -void dlfree(void* mem) { +void dlfree(void *mem) { + /* Consolidate freed chunks with preceeding or succeeding bordering free chunks, if they exist, and then place in a bin. Intermixed @@ -4738,164 +5287,216 @@ void dlfree(void* mem) { */ if (mem != 0) { - mchunkptr p = mem2chunk(mem); -#if FOOTERS + + mchunkptr p = mem2chunk(mem); + #if FOOTERS mstate fm = get_mstate_for(p); if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); return; + } -#else /* FOOTERS */ -#define fm gm -#endif /* FOOTERS */ + + #else /* FOOTERS */ + #define fm gm + #endif /* FOOTERS */ if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { - size_t psize = chunksize(p); + + size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { + size_t prevsize = p->prev_foot; if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; - } - else { + + } else { + mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { + + } else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; + } - } - else + + } else + goto erroraction; + } + } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ + + if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { + size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { + fm->dv = 0; fm->dvsize = 0; + } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); + + if (should_trim(fm, tsize)) sys_trim(fm, 0); goto postaction; - } - else if (next == fm->dv) { + + } else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; - } - else { + + } else { + size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { + fm->dvsize = psize; goto postaction; + } + } - } - else + + } else + set_free_with_pinuse(p, psize, next); if (is_small(psize)) { + insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); - } - else { + + } else { + tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); - if (--fm->release_checks == 0) - release_unused_segments(fm); + if (--fm->release_checks == 0) release_unused_segments(fm); + } + goto postaction; + } + } + erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); + } + } -#if !FOOTERS -#undef fm -#endif /* FOOTERS */ + + #if !FOOTERS + #undef fm + #endif /* FOOTERS */ + } -void* dlcalloc(size_t n_elements, size_t elem_size) { - void* mem; +void *dlcalloc(size_t n_elements, size_t elem_size) { + + void * mem; size_t req = 0; if (n_elements != 0) { + req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = dlmalloc(req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) __builtin_memset(mem, 0, req); return mem; + } -#endif /* !ONLY_MSPACES */ + #endif /* !ONLY_MSPACES */ /* ------------ Internal support for realloc, memalign, etc -------------- */ /* Try to realloc; only in-place unless can_move true */ static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, int can_move) { + mchunkptr newp = 0; - size_t oldsize = chunksize(p); + size_t oldsize = chunksize(p); mchunkptr next = chunk_plus_offset(p, oldsize); - if (RTCHECK(ok_address(m, p) && ok_inuse(p) && - ok_next(p, next) && ok_pinuse(next))) { + if (RTCHECK(ok_address(m, p) && ok_inuse(p) && ok_next(p, next) && + ok_pinuse(next))) { + if (is_mmapped(p)) { + newp = mmap_resize(m, p, nb, can_move); - } - else if (oldsize >= nb) { /* already big enough */ + + } else if (oldsize >= nb) { /* already big enough */ + size_t rsize = oldsize - nb; - if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ + if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); + } + newp = p; - } - else if (next == m->top) { /* extend into top */ + + } else if (next == m->top) { /* extend into top */ + if (oldsize + m->topsize > nb) { - size_t newsize = oldsize + m->topsize; - size_t newtopsize = newsize - nb; + + size_t newsize = oldsize + m->topsize; + size_t newtopsize = newsize - nb; mchunkptr newtop = chunk_plus_offset(p, nb); set_inuse(m, p, nb); - newtop->head = newtopsize |PINUSE_BIT; + newtop->head = newtopsize | PINUSE_BIT; m->top = newtop; m->topsize = newtopsize; newp = p; + } - } - else if (next == m->dv) { /* extend into dv */ + + } else if (next == m->dv) { /* extend into dv */ + size_t dvs = m->dvsize; if (oldsize + dvs >= nb) { + size_t dsize = oldsize + dvs - nb; if (dsize >= MIN_CHUNK_SIZE) { + mchunkptr r = chunk_plus_offset(p, nb); mchunkptr n = chunk_plus_offset(r, dsize); set_inuse(m, p, nb); @@ -4903,64 +5504,87 @@ static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, clear_pinuse(n); m->dvsize = dsize; m->dv = r; - } - else { /* exhaust dv */ + + } else { /* exhaust dv */ + size_t newsize = oldsize + dvs; set_inuse(m, p, newsize); m->dvsize = 0; m->dv = 0; + } + newp = p; + } - } - else if (!cinuse(next)) { /* extend into next free chunk */ + + } else if (!cinuse(next)) { /* extend into next free chunk */ + size_t nextsize = chunksize(next); if (oldsize + nextsize >= nb) { + size_t rsize = oldsize + nextsize - nb; unlink_chunk(m, next, nextsize); if (rsize < MIN_CHUNK_SIZE) { + size_t newsize = oldsize + nextsize; set_inuse(m, p, newsize); - } - else { + + } else { + mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); + } + newp = p; + } + } - } - else { + + } else { + USAGE_ERROR_ACTION(m, chunk2mem(p)); + } + return newp; + } -static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { - void* mem = 0; - if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ +static void *internal_memalign(mstate m, size_t alignment, size_t bytes) { + + void *mem = 0; + if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ alignment = MIN_CHUNK_SIZE; - if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ + if ((alignment & (alignment - SIZE_T_ONE)) != 0) { /* Ensure a power of 2 */ size_t a = MALLOC_ALIGNMENT << 1; - while (a < alignment) a <<= 1; + while (a < alignment) + a <<= 1; alignment = a; + } + if (bytes >= MAX_REQUEST - alignment) { - if (m != 0) { /* Test isn't needed but avoids compiler warning */ + + if (m != 0) { /* Test isn't needed but avoids compiler warning */ MALLOC_FAILURE_ACTION; + } - } - else { + + } else { + size_t nb = request2size(bytes); size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; mem = internal_malloc(m, req); if (mem != 0) { + mchunkptr p = mem2chunk(mem); - if (PREACTION(m)) - return 0; - if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ + if (PREACTION(m)) return 0; + if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ /* Find an aligned spot inside chunk. Since we need to give back leading space in a chunk of at least MIN_CHUNK_SIZE, if @@ -4969,47 +5593,59 @@ static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { We've allocated enough total room so that this is always possible. */ - char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment - - SIZE_T_ONE)) & - -alignment)); - char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? - br : br+alignment; + char * br = (char *)mem2chunk((size_t)( + ((size_t)((char *)mem + alignment - SIZE_T_ONE)) & -alignment)); + char * pos = ((size_t)(br - (char *)(p)) >= MIN_CHUNK_SIZE) + ? br + : br + alignment; mchunkptr newp = (mchunkptr)pos; - size_t leadsize = pos - (char*)(p); - size_t newsize = chunksize(p) - leadsize; + size_t leadsize = pos - (char *)(p); + size_t newsize = chunksize(p) - leadsize; - if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ + if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ newp->prev_foot = p->prev_foot + leadsize; newp->head = newsize; - } - else { /* Otherwise, give back leader, use the rest */ + + } else { /* Otherwise, give back leader, use the rest */ + set_inuse(m, newp, newsize); set_inuse(m, p, leadsize); dispose_chunk(m, p, leadsize); + } + p = newp; + } /* Give back spare room at the end */ if (!is_mmapped(p)) { + size_t size = chunksize(p); if (size > nb + MIN_CHUNK_SIZE) { - size_t remainder_size = size - nb; + + size_t remainder_size = size - nb; mchunkptr remainder = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, remainder, remainder_size); dispose_chunk(m, remainder, remainder_size); + } + } mem = chunk2mem(p); - assert (chunksize(p) >= nb); + assert(chunksize(p) >= nb); assert(((size_t)mem & (alignment - 1)) == 0); check_inuse_chunk(m, p); POSTACTION(m); + } + } + return mem; + } /* @@ -5019,50 +5655,50 @@ static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { bit 0 set if all elements are same size (using sizes[0]) bit 1 set if elements should be zeroed */ -static void** ialloc(mstate m, - size_t n_elements, - size_t* sizes, - int opts, - void* chunks[]) { - - size_t element_size; /* chunksize of each element, if all same */ - size_t contents_size; /* total size of elements */ - size_t array_size; /* request size of pointer array */ - void* mem; /* malloced aggregate space */ - mchunkptr p; /* corresponding chunk */ - size_t remainder_size; /* remaining bytes while splitting */ - void** marray; /* either "chunks" or malloced ptr array */ - mchunkptr array_chunk; /* chunk for malloced ptr array */ - flag_t was_enabled; /* to disable mmap */ +static void **ialloc(mstate m, size_t n_elements, size_t *sizes, int opts, + void *chunks[]) { + + size_t element_size; /* chunksize of each element, if all same */ + size_t contents_size; /* total size of elements */ + size_t array_size; /* request size of pointer array */ + void * mem; /* malloced aggregate space */ + mchunkptr p; /* corresponding chunk */ + size_t remainder_size; /* remaining bytes while splitting */ + void ** marray; /* either "chunks" or malloced ptr array */ + mchunkptr array_chunk; /* chunk for malloced ptr array */ + flag_t was_enabled; /* to disable mmap */ size_t size; size_t i; ensure_initialization(); /* compute array length, if needed */ if (chunks != 0) { - if (n_elements == 0) - return chunks; /* nothing to do */ + + if (n_elements == 0) return chunks; /* nothing to do */ marray = chunks; array_size = 0; - } - else { + + } else { + /* if empty req, must still return chunk representing empty array */ - if (n_elements == 0) - return (void**)internal_malloc(m, 0); + if (n_elements == 0) return (void **)internal_malloc(m, 0); marray = 0; - array_size = request2size(n_elements * (sizeof(void*))); + array_size = request2size(n_elements * (sizeof(void *))); + } /* compute total element size */ - if (opts & 0x1) { /* all-same-size */ + if (opts & 0x1) { /* all-same-size */ element_size = request2size(*sizes); contents_size = n_elements * element_size; - } - else { /* add up all the sizes */ + + } else { /* add up all the sizes */ + element_size = 0; contents_size = 0; for (i = 0; i != n_elements; ++i) contents_size += request2size(sizes[i]); + } size = contents_size + array_size; @@ -5075,10 +5711,8 @@ static void** ialloc(mstate m, was_enabled = use_mmap(m); disable_mmap(m); mem = internal_malloc(m, size - CHUNK_OVERHEAD); - if (was_enabled) - enable_mmap(m); - if (mem == 0) - return 0; + if (was_enabled) enable_mmap(m); + if (mem == 0) return 0; if (PREACTION(m)) return 0; p = mem2chunk(mem); @@ -5086,24 +5720,30 @@ static void** ialloc(mstate m, assert(!is_mmapped(p)); - if (opts & 0x2) { /* optionally clear the elements */ - __builtin_memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); + if (opts & 0x2) { /* optionally clear the elements */ + __builtin_memset((size_t *)mem, 0, + remainder_size - SIZE_T_SIZE - array_size); + } /* If not provided, allocate the pointer array as final part of chunk */ if (marray == 0) { - size_t array_chunk_size; + + size_t array_chunk_size; array_chunk = chunk_plus_offset(p, contents_size); array_chunk_size = remainder_size - contents_size; - marray = (void**) (chunk2mem(array_chunk)); + marray = (void **)(chunk2mem(array_chunk)); set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); remainder_size = contents_size; + } /* split out elements */ - for (i = 0; ; ++i) { + for (i = 0;; ++i) { + marray[i] = chunk2mem(p); - if (i != n_elements-1) { + if (i != n_elements - 1) { + if (element_size != 0) size = element_size; else @@ -5111,31 +5751,42 @@ static void** ialloc(mstate m, remainder_size -= size; set_size_and_pinuse_of_inuse_chunk(m, p, size); p = chunk_plus_offset(p, size); - } - else { /* the final element absorbs any overallocation slop */ + + } else { /* the final element absorbs any overallocation slop */ + set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); break; + } + } -#if DEBUG + #if DEBUG if (marray != chunks) { + /* final element must have exactly exhausted chunk */ if (element_size != 0) { + assert(remainder_size == element_size); - } - else { + + } else { + assert(remainder_size == request2size(sizes[i])); + } + check_inuse_chunk(m, mem2chunk(marray)); + } + for (i = 0; i != n_elements; ++i) check_inuse_chunk(m, mem2chunk(marray[i])); -#endif /* DEBUG */ + #endif /* DEBUG */ POSTACTION(m); return marray; + } /* Try to free all pointers in the given array. @@ -5145,316 +5796,431 @@ static void** ialloc(mstate m, chunks before freeing, which will occur often if allocated with ialloc or the array is sorted. */ -static size_t internal_bulk_free(mstate m, void* array[], size_t nelem) { +static size_t internal_bulk_free(mstate m, void *array[], size_t nelem) { + size_t unfreed = 0; if (!PREACTION(m)) { - void** a; - void** fence = &(array[nelem]); + + void **a; + void **fence = &(array[nelem]); for (a = array; a != fence; ++a) { - void* mem = *a; + + void *mem = *a; if (mem != 0) { + mchunkptr p = mem2chunk(mem); - size_t psize = chunksize(p); -#if FOOTERS + size_t psize = chunksize(p); + #if FOOTERS if (get_mstate_for(p) != m) { + ++unfreed; continue; + } -#endif + + #endif check_inuse_chunk(m, p); *a = 0; if (RTCHECK(ok_address(m, p) && ok_inuse(p))) { - void ** b = a + 1; /* try to merge with next chunk */ + + void ** b = a + 1; /* try to merge with next chunk */ mchunkptr next = next_chunk(p); if (b != fence && *b == chunk2mem(next)) { + size_t newsize = chunksize(next) + psize; set_inuse(m, p, newsize); *b = chunk2mem(p); - } - else + + } else + dispose_chunk(m, p, psize); - } - else { + + } else { + CORRUPTION_ERROR_ACTION(m); break; + } + } + } - if (should_trim(m, m->topsize)) - sys_trim(m, 0); + + if (should_trim(m, m->topsize)) sys_trim(m, 0); POSTACTION(m); + } + return unfreed; + } -/* Traversal */ -#if MALLOC_INSPECT_ALL + /* Traversal */ + #if MALLOC_INSPECT_ALL static void internal_inspect_all(mstate m, - void(*handler)(void *start, - void *end, - size_t used_bytes, - void* callback_arg), - void* arg) { + void (*handler)(void *start, void *end, + size_t used_bytes, + void * callback_arg), + void *arg) { + if (is_initialized(m)) { - mchunkptr top = m->top; + + mchunkptr top = m->top; msegmentptr s; for (s = &m->seg; s != 0; s = s->next) { + mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) { + mchunkptr next = next_chunk(q); - size_t sz = chunksize(q); - size_t used; - void* start; + size_t sz = chunksize(q); + size_t used; + void * start; if (is_inuse(q)) { - used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ + + used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ start = chunk2mem(q); - } - else { + + } else { + used = 0; - if (is_small(sz)) { /* offset by possible bookkeeping */ - start = (void*)((char*)q + sizeof(struct malloc_chunk)); - } - else { - start = (void*)((char*)q + sizeof(struct malloc_tree_chunk)); + if (is_small(sz)) { /* offset by possible bookkeeping */ + start = (void *)((char *)q + sizeof(struct malloc_chunk)); + + } else { + + start = (void *)((char *)q + sizeof(struct malloc_tree_chunk)); + } + } - if (start < (void*)next) /* skip if all space is bookkeeping */ + + if (start < (void *)next) /* skip if all space is bookkeeping */ handler(start, next, used, arg); - if (q == top) - break; + if (q == top) break; q = next; + } + } + } + } -#endif /* MALLOC_INSPECT_ALL */ + + #endif /* MALLOC_INSPECT_ALL */ /* ------------------ Exported realloc, memalign, etc -------------------- */ -#if !ONLY_MSPACES + #if !ONLY_MSPACES -void* dlrealloc(void* oldmem, size_t bytes) { - void* mem = 0; +void *dlrealloc(void *oldmem, size_t bytes) { + + void *mem = 0; if (oldmem == 0) { + mem = dlmalloc(bytes); - } - else if (bytes >= MAX_REQUEST) { + + } else if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } -#ifdef REALLOC_ZERO_BYTES_FREES + + #ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { + dlfree(oldmem); + } -#endif /* REALLOC_ZERO_BYTES_FREES */ + + #endif /* REALLOC_ZERO_BYTES_FREES */ else { - size_t nb = request2size(bytes); + + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); -#if ! FOOTERS + #if !FOOTERS mstate m = gm; -#else /* FOOTERS */ + #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; + } -#endif /* FOOTERS */ + + #endif /* FOOTERS */ if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { + check_inuse_chunk(m, newp); mem = chunk2mem(newp); - } - else { + + } else { + mem = internal_malloc(m, bytes); if (mem != 0) { + size_t oc = chunksize(oldp) - overhead_for(oldp); - __builtin_memcpy(mem, oldmem, (oc < bytes)? oc : bytes); + __builtin_memcpy(mem, oldmem, (oc < bytes) ? oc : bytes); internal_free(m, oldmem); + } + } + } + } + return mem; + } -void* dlrealloc_in_place(void* oldmem, size_t bytes) { - void* mem = 0; +void *dlrealloc_in_place(void *oldmem, size_t bytes) { + + void *mem = 0; if (oldmem != 0) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; - } - else { - size_t nb = request2size(bytes); + + } else { + + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); -#if ! FOOTERS + #if !FOOTERS mstate m = gm; -#else /* FOOTERS */ + #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; + } -#endif /* FOOTERS */ + + #endif /* FOOTERS */ if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { + check_inuse_chunk(m, newp); mem = oldmem; + } + } + } + } + return mem; + } -void* dlmemalign(size_t alignment, size_t bytes) { - if (alignment <= MALLOC_ALIGNMENT) { - return dlmalloc(bytes); - } +void *dlmemalign(size_t alignment, size_t bytes) { + + if (alignment <= MALLOC_ALIGNMENT) { return dlmalloc(bytes); } return internal_memalign(gm, alignment, bytes); + } -int dlposix_memalign(void** pp, size_t alignment, size_t bytes) { - void* mem = 0; +int dlposix_memalign(void **pp, size_t alignment, size_t bytes) { + + void *mem = 0; if (alignment == MALLOC_ALIGNMENT) mem = dlmalloc(bytes); else { - size_t d = alignment / sizeof(void*); - size_t r = alignment % sizeof(void*); - if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0) + + size_t d = alignment / sizeof(void *); + size_t r = alignment % sizeof(void *); + if (r != 0 || d == 0 || (d & (d - SIZE_T_ONE)) != 0) return EINVAL; else if (bytes <= MAX_REQUEST - alignment) { - if (alignment < MIN_CHUNK_SIZE) - alignment = MIN_CHUNK_SIZE; + + if (alignment < MIN_CHUNK_SIZE) alignment = MIN_CHUNK_SIZE; mem = internal_memalign(gm, alignment, bytes); + } + } + if (mem == 0) return ENOMEM; else { + *pp = mem; return 0; + } + } -void* dlvalloc(size_t bytes) { +void *dlvalloc(size_t bytes) { + size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; return dlmemalign(pagesz, bytes); + } -void* dlpvalloc(size_t bytes) { +void *dlpvalloc(size_t bytes) { + size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; - return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); + return dlmemalign(pagesz, + (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); + } -void** dlindependent_calloc(size_t n_elements, size_t elem_size, - void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ +void **dlindependent_calloc(size_t n_elements, size_t elem_size, + void *chunks[]) { + + size_t sz = elem_size; /* serves as 1-element array */ return ialloc(gm, n_elements, &sz, 3, chunks); + } -void** dlindependent_comalloc(size_t n_elements, size_t sizes[], - void* chunks[]) { +void **dlindependent_comalloc(size_t n_elements, size_t sizes[], + void *chunks[]) { + return ialloc(gm, n_elements, sizes, 0, chunks); + } -size_t dlbulk_free(void* array[], size_t nelem) { +size_t dlbulk_free(void *array[], size_t nelem) { + return internal_bulk_free(gm, array, nelem); + } -#if MALLOC_INSPECT_ALL -void dlmalloc_inspect_all(void(*handler)(void *start, - void *end, - size_t used_bytes, - void* callback_arg), - void* arg) { + #if MALLOC_INSPECT_ALL +void dlmalloc_inspect_all(void (*handler)(void *start, void *end, + size_t used_bytes, + void * callback_arg), + void *arg) { + ensure_initialization(); if (!PREACTION(gm)) { + internal_inspect_all(gm, handler, arg); POSTACTION(gm); + } + } -#endif /* MALLOC_INSPECT_ALL */ + + #endif /* MALLOC_INSPECT_ALL */ int dlmalloc_trim(size_t pad) { + int result = 0; ensure_initialization(); if (!PREACTION(gm)) { + result = sys_trim(gm, pad); POSTACTION(gm); + } + return result; + } size_t dlmalloc_footprint(void) { + return gm->footprint; + } size_t dlmalloc_max_footprint(void) { + return gm->max_footprint; + } size_t dlmalloc_footprint_limit(void) { + size_t maf = gm->footprint_limit; return maf == 0 ? MAX_SIZE_T : maf; + } size_t dlmalloc_set_footprint_limit(size_t bytes) { - size_t result; /* invert sense of 0 */ - if (bytes == 0) - result = granularity_align(1); /* Use minimal size */ + + size_t result; /* invert sense of 0 */ + if (bytes == 0) result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) - result = 0; /* disable */ + result = 0; /* disable */ else result = granularity_align(bytes); return gm->footprint_limit = result; + } -#if !NO_MALLINFO + #if !NO_MALLINFO struct mallinfo dlmallinfo(void) { + return internal_mallinfo(gm); + } -#endif /* NO_MALLINFO */ -#if !NO_MALLOC_STATS + #endif /* NO_MALLINFO */ + + #if !NO_MALLOC_STATS void dlmalloc_stats() { + internal_malloc_stats(gm); + } -#endif /* NO_MALLOC_STATS */ + + #endif /* NO_MALLOC_STATS */ int dlmallopt(int param_number, int value) { + return change_mparam(param_number, value); + } -size_t dlmalloc_usable_size(void* mem) { +size_t dlmalloc_usable_size(void *mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); - if (is_inuse(p)) - return chunksize(p) - overhead_for(p); + if (is_inuse(p)) return chunksize(p) - overhead_for(p); + } + return 0; + } -#endif /* !ONLY_MSPACES */ + #endif /* !ONLY_MSPACES */ /* ----------------------------- user mspaces ---------------------------- */ -#if MSPACES + #if MSPACES + +static mstate init_user_mstate(char *tbase, size_t tsize) { -static mstate init_user_mstate(char* tbase, size_t tsize) { - size_t msize = pad_request(sizeof(struct malloc_state)); + size_t msize = pad_request(sizeof(struct malloc_state)); mchunkptr mn; mchunkptr msp = align_as_chunk(tbase); - mstate m = (mstate)(chunk2mem(msp)); + mstate m = (mstate)(chunk2mem(msp)); __builtin_memset(m, 0, msize); (void)INITIAL_LOCK(&m->mutex); - msp->head = (msize|INUSE_BITS); + msp->head = (msize | INUSE_BITS); m->seg.base = m->least_addr = tbase; m->seg.size = m->footprint = m->max_footprint = tsize; m->magic = mparams.magic; @@ -5465,82 +6231,111 @@ static mstate init_user_mstate(char* tbase, size_t tsize) { disable_contiguous(m); init_bins(m); mn = next_chunk(mem2chunk(m)); - init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); + init_top(m, mn, (size_t)((tbase + tsize) - (char *)mn) - TOP_FOOT_SIZE); check_top_chunk(m, m->top); return m; + } mspace create_mspace(size_t capacity, int locked) { + mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); - if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - size_t rs = ((capacity == 0)? mparams.granularity : - (capacity + TOP_FOOT_SIZE + msize)); + if (capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { + + size_t rs = ((capacity == 0) ? mparams.granularity + : (capacity + TOP_FOOT_SIZE + msize)); size_t tsize = granularity_align(rs); - char* tbase = (char*)(CALL_MMAP(tsize)); + char * tbase = (char *)(CALL_MMAP(tsize)); if (tbase != CMFAIL) { + m = init_user_mstate(tbase, tsize); m->seg.sflags = USE_MMAP_BIT; set_lock(m, locked); + } + } + return (mspace)m; + } -mspace create_mspace_with_base(void* base, size_t capacity, int locked) { +mspace create_mspace_with_base(void *base, size_t capacity, int locked) { + mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); if (capacity > msize + TOP_FOOT_SIZE && - capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { - m = init_user_mstate((char*)base, capacity); + capacity < (size_t) - (msize + TOP_FOOT_SIZE + mparams.page_size)) { + + m = init_user_mstate((char *)base, capacity); m->seg.sflags = EXTERN_BIT; set_lock(m, locked); + } + return (mspace)m; + } int mspace_track_large_chunks(mspace msp, int enable) { - int ret = 0; + + int ret = 0; mstate ms = (mstate)msp; if (!PREACTION(ms)) { - if (!use_mmap(ms)) { - ret = 1; - } + + if (!use_mmap(ms)) { ret = 1; } if (!enable) { + enable_mmap(ms); + } else { + disable_mmap(ms); + } + POSTACTION(ms); + } + return ret; + } size_t destroy_mspace(mspace msp) { + size_t freed = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + msegmentptr sp = &ms->seg; - (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ + (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ while (sp != 0) { - char* base = sp->base; + + char * base = sp->base; size_t size = sp->size; flag_t flag = sp->sflags; - (void)base; /* placate people compiling -Wunused-variable */ + (void)base; /* placate people compiling -Wunused-variable */ sp = sp->next; if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && CALL_MUNMAP(base, size) == 0) freed += size; + } + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return freed; + } /* @@ -5548,25 +6343,31 @@ size_t destroy_mspace(mspace msp) { versions. This is not so nice but better than the alternatives. */ -void* mspace_malloc(mspace msp, size_t bytes) { +void *mspace_malloc(mspace msp, size_t bytes) { + mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } + if (!PREACTION(ms)) { - void* mem; + + void * mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { + bindex_t idx; binmap_t smallbits; - nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); + nb = (bytes < MIN_REQUEST) ? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = ms->smallmap >> idx; - if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ + if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; - idx += ~smallbits & 1; /* Uses next bin if idx empty */ + idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(ms, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); @@ -5575,15 +6376,17 @@ void* mspace_malloc(mspace msp, size_t bytes) { mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; + } else if (nb > ms->dvsize) { - if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ + + if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; - size_t rsize; - bindex_t i; - binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); - binmap_t leastbit = least_bit(leftbits); + size_t rsize; + bindex_t i; + binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); + binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(ms, i); p = b->fd; @@ -5594,54 +6397,71 @@ void* mspace_malloc(mspace msp, size_t bytes) { if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(ms, p, small_index2size(i)); else { + set_size_and_pinuse_of_inuse_chunk(ms, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(ms, r, rsize); + } + mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; + } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); goto postaction; + } + } - } - else if (bytes >= MAX_REQUEST) + + } else if (bytes >= MAX_REQUEST) + nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { + nb = pad_request(bytes); if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { + check_malloced_chunk(ms, mem, nb); goto postaction; + } + } if (nb <= ms->dvsize) { - size_t rsize = ms->dvsize - nb; + + size_t rsize = ms->dvsize - nb; mchunkptr p = ms->dv; - if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ + if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = ms->dv = chunk_plus_offset(p, nb); ms->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(ms, p, nb); - } - else { /* exhaust dv */ + + } else { /* exhaust dv */ + size_t dvs = ms->dvsize; ms->dvsize = 0; ms->dv = 0; set_inuse_and_pinuse(ms, p, dvs); + } + mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; + } - else if (nb < ms->topsize) { /* Split top */ - size_t rsize = ms->topsize -= nb; + else if (nb < ms->topsize) { /* Split top */ + size_t rsize = ms->topsize -= nb; mchunkptr p = ms->top; mchunkptr r = ms->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; @@ -5650,6 +6470,7 @@ void* mspace_malloc(mspace msp, size_t bytes) { check_top_chunk(ms, ms->top); check_malloced_chunk(ms, mem, nb); goto postaction; + } mem = sys_alloc(ms, nb); @@ -5657,372 +6478,519 @@ void* mspace_malloc(mspace msp, size_t bytes) { postaction: POSTACTION(ms); return mem; + } return 0; + } -void mspace_free(mspace msp, void* mem) { +void mspace_free(mspace msp, void *mem) { + if (mem != 0) { - mchunkptr p = mem2chunk(mem); -#if FOOTERS + + mchunkptr p = mem2chunk(mem); + #if FOOTERS mstate fm = get_mstate_for(p); - (void)msp; /* placate people compiling -Wunused */ -#else /* FOOTERS */ + (void)msp; /* placate people compiling -Wunused */ + #else /* FOOTERS */ mstate fm = (mstate)msp; -#endif /* FOOTERS */ + #endif /* FOOTERS */ if (!ok_magic(fm)) { + USAGE_ERROR_ACTION(fm, p); return; + } + if (!PREACTION(fm)) { + check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { - size_t psize = chunksize(p); + + size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { + size_t prevsize = p->prev_foot; if (is_mmapped(p)) { + psize += prevsize + MMAP_FOOT_PAD; - if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) + if (CALL_MUNMAP((char *)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; - } - else { + + } else { + mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; - if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ + if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { + unlink_chunk(fm, p, prevsize); - } - else if ((next->head & INUSE_BITS) == INUSE_BITS) { + + } else if ((next->head & INUSE_BITS) == INUSE_BITS) { + fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; + } - } - else + + } else + goto erroraction; + } + } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { - if (!cinuse(next)) { /* consolidate forward */ + + if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { + size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { + fm->dv = 0; fm->dvsize = 0; + } - if (should_trim(fm, tsize)) - sys_trim(fm, 0); + + if (should_trim(fm, tsize)) sys_trim(fm, 0); goto postaction; - } - else if (next == fm->dv) { + + } else if (next == fm->dv) { + size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; - } - else { + + } else { + size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { + fm->dvsize = psize; goto postaction; + } + } - } - else + + } else + set_free_with_pinuse(p, psize, next); if (is_small(psize)) { + insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); - } - else { + + } else { + tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); - if (--fm->release_checks == 0) - release_unused_segments(fm); + if (--fm->release_checks == 0) release_unused_segments(fm); + } + goto postaction; + } + } + erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); + } + } + } -void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { - void* mem; +void *mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { + + void * mem; size_t req = 0; mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } + if (n_elements != 0) { + req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) - req = MAX_SIZE_T; /* force downstream failure on overflow */ + req = MAX_SIZE_T; /* force downstream failure on overflow */ + } + mem = internal_malloc(ms, req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) __builtin_memset(mem, 0, req); return mem; + } -void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { - void* mem = 0; +void *mspace_realloc(mspace msp, void *oldmem, size_t bytes) { + + void *mem = 0; if (oldmem == 0) { + mem = mspace_malloc(msp, bytes); - } - else if (bytes >= MAX_REQUEST) { + + } else if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; + } -#ifdef REALLOC_ZERO_BYTES_FREES + + #ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { + mspace_free(msp, oldmem); + } -#endif /* REALLOC_ZERO_BYTES_FREES */ + + #endif /* REALLOC_ZERO_BYTES_FREES */ else { - size_t nb = request2size(bytes); + + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); -#if ! FOOTERS + #if !FOOTERS mstate m = (mstate)msp; -#else /* FOOTERS */ + #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; + } -#endif /* FOOTERS */ + + #endif /* FOOTERS */ if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { + check_inuse_chunk(m, newp); mem = chunk2mem(newp); - } - else { + + } else { + mem = mspace_malloc(m, bytes); if (mem != 0) { + size_t oc = chunksize(oldp) - overhead_for(oldp); - __builtin_memcpy(mem, oldmem, (oc < bytes)? oc : bytes); + __builtin_memcpy(mem, oldmem, (oc < bytes) ? oc : bytes); mspace_free(m, oldmem); + } + } + } + } + return mem; + } -void* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) { - void* mem = 0; +void *mspace_realloc_in_place(mspace msp, void *oldmem, size_t bytes) { + + void *mem = 0; if (oldmem != 0) { + if (bytes >= MAX_REQUEST) { + MALLOC_FAILURE_ACTION; - } - else { - size_t nb = request2size(bytes); + + } else { + + size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); -#if ! FOOTERS + #if !FOOTERS mstate m = (mstate)msp; -#else /* FOOTERS */ + #else /* FOOTERS */ mstate m = get_mstate_for(oldp); - (void)msp; /* placate people compiling -Wunused */ + (void)msp; /* placate people compiling -Wunused */ if (!ok_magic(m)) { + USAGE_ERROR_ACTION(m, oldmem); return 0; + } -#endif /* FOOTERS */ + + #endif /* FOOTERS */ if (!PREACTION(m)) { + mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { + check_inuse_chunk(m, newp); mem = oldmem; + } + } + } + } + return mem; + } -void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { +void *mspace_memalign(mspace msp, size_t alignment, size_t bytes) { + mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } - if (alignment <= MALLOC_ALIGNMENT) - return mspace_malloc(msp, bytes); + + if (alignment <= MALLOC_ALIGNMENT) return mspace_malloc(msp, bytes); return internal_memalign(ms, alignment, bytes); + } -void** mspace_independent_calloc(mspace msp, size_t n_elements, - size_t elem_size, void* chunks[]) { - size_t sz = elem_size; /* serves as 1-element array */ +void **mspace_independent_calloc(mspace msp, size_t n_elements, + size_t elem_size, void *chunks[]) { + + size_t sz = elem_size; /* serves as 1-element array */ mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } + return ialloc(ms, n_elements, &sz, 3, chunks); + } -void** mspace_independent_comalloc(mspace msp, size_t n_elements, - size_t sizes[], void* chunks[]) { +void **mspace_independent_comalloc(mspace msp, size_t n_elements, + size_t sizes[], void *chunks[]) { + mstate ms = (mstate)msp; if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); + + USAGE_ERROR_ACTION(ms, ms); return 0; + } + return ialloc(ms, n_elements, sizes, 0, chunks); + } -size_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) { +size_t mspace_bulk_free(mspace msp, void *array[], size_t nelem) { + return internal_bulk_free((mstate)msp, array, nelem); + } -#if MALLOC_INSPECT_ALL + #if MALLOC_INSPECT_ALL void mspace_inspect_all(mspace msp, - void(*handler)(void *start, - void *end, - size_t used_bytes, - void* callback_arg), - void* arg) { + void (*handler)(void *start, void *end, + size_t used_bytes, void *callback_arg), + void *arg) { + mstate ms = (mstate)msp; if (ok_magic(ms)) { + if (!PREACTION(ms)) { + internal_inspect_all(ms, handler, arg); POSTACTION(ms); + } + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + } -#endif /* MALLOC_INSPECT_ALL */ + + #endif /* MALLOC_INSPECT_ALL */ int mspace_trim(mspace msp, size_t pad) { - int result = 0; + + int result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + if (!PREACTION(ms)) { + result = sys_trim(ms, pad); POSTACTION(ms); + } + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } -#if !NO_MALLOC_STATS + #if !NO_MALLOC_STATS void mspace_malloc_stats(mspace msp) { + mstate ms = (mstate)msp; if (ok_magic(ms)) { + internal_malloc_stats(ms); + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + } -#endif /* NO_MALLOC_STATS */ + + #endif /* NO_MALLOC_STATS */ size_t mspace_footprint(mspace msp) { + size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + result = ms->footprint; + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } size_t mspace_max_footprint(mspace msp) { + size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + result = ms->max_footprint; + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } size_t mspace_footprint_limit(mspace msp) { + size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { + size_t maf = ms->footprint_limit; result = (maf == 0) ? MAX_SIZE_T : maf; + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } size_t mspace_set_footprint_limit(mspace msp, size_t bytes) { + size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { - if (bytes == 0) - result = granularity_align(1); /* Use minimal size */ + + if (bytes == 0) result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) - result = 0; /* disable */ + result = 0; /* disable */ else result = granularity_align(bytes); ms->footprint_limit = result; + + } else { + + USAGE_ERROR_ACTION(ms, ms); + } - else { - USAGE_ERROR_ACTION(ms,ms); - } + return result; + } -#if !NO_MALLINFO + #if !NO_MALLINFO struct mallinfo mspace_mallinfo(mspace msp) { + mstate ms = (mstate)msp; - if (!ok_magic(ms)) { - USAGE_ERROR_ACTION(ms,ms); - } + if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms, ms); } return internal_mallinfo(ms); + } -#endif /* NO_MALLINFO */ -size_t mspace_usable_size(const void* mem) { + #endif /* NO_MALLINFO */ + +size_t mspace_usable_size(const void *mem) { + if (mem != 0) { + mchunkptr p = mem2chunk(mem); - if (is_inuse(p)) - return chunksize(p) - overhead_for(p); + if (is_inuse(p)) return chunksize(p) - overhead_for(p); + } + return 0; + } int mspace_mallopt(int param_number, int value) { + return change_mparam(param_number, value); -} -#endif /* MSPACES */ +} + #endif /* MSPACES */ /* -------------------- Alternative MORECORE functions ------------------- */ @@ -6067,35 +7035,48 @@ int mspace_mallopt(int param_number, int value) { void *osMoreCore(int size) { + void *ptr = 0; static void *sbrk_top = 0; if (size > 0) { + if (size < MINIMUM_MORECORE_SIZE) size = MINIMUM_MORECORE_SIZE; if (CurrentExecutionLevel() == kTaskLevel) ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); if (ptr == 0) { + return (void *) MFAIL; + } + // save ptrs so they can be freed during cleanup our_os_pools[next_os_pool] = ptr; next_os_pool++; ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); sbrk_top = (char *) ptr + size; return ptr; + } + else if (size < 0) { + // we don't currently support shrink behavior return (void *) MFAIL; + } + else { + return sbrk_top; + } + } // cleanup any allocated memory pools @@ -6103,19 +7084,22 @@ int mspace_mallopt(int param_number, int value) { void osCleanupMem(void) { + void **ptr; for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) if (*ptr) { + PoolDeallocate(*ptr); *ptr = 0; + } + } */ - /* ----------------------------------------------------------------------- History: v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea @@ -6335,4 +7319,5 @@ History: */ -#endif // __GLIBC__ +#endif // __GLIBC__ + diff --git a/qemu_mode/libqasan/hooks.c b/qemu_mode/libqasan/hooks.c index 3bb4cc42..405dddae 100644 --- a/qemu_mode/libqasan/hooks.c +++ b/qemu_mode/libqasan/hooks.c @@ -174,7 +174,9 @@ char *fgets(char *s, int size, FILE *stream) { QASAN_DEBUG("%14p: fgets(%p, %d, %p)\n", rtv, s, size, stream); QASAN_STORE(s, size); +#ifndef __ANDROID__ QASAN_LOAD(stream, sizeof(FILE)); +#endif char *r = __lq_libc_fgets(s, size, stream); QASAN_DEBUG("\t\t = %p\n", r); diff --git a/qemu_mode/libqasan/libqasan.c b/qemu_mode/libqasan/libqasan.c index 11b50270..9fc4ef7a 100644 --- a/qemu_mode/libqasan/libqasan.c +++ b/qemu_mode/libqasan/libqasan.c @@ -72,7 +72,7 @@ void __libqasan_print_maps(void) { QASAN_LOG("QEMU-AddressSanitizer (v%s)\n", QASAN_VERSTR); QASAN_LOG( - "Copyright (C) 2019-2020 Andrea Fioraldi \n"); + "Copyright (C) 2019-2021 Andrea Fioraldi \n"); QASAN_LOG("\n"); if (__qasan_log) __libqasan_print_maps(); diff --git a/qemu_mode/libqasan/malloc.c b/qemu_mode/libqasan/malloc.c index 54c1096a..5a2d2a0c 100644 --- a/qemu_mode/libqasan/malloc.c +++ b/qemu_mode/libqasan/malloc.c @@ -51,9 +51,9 @@ typedef struct { struct chunk_begin { size_t requested_size; - void* aligned_orig; // NULL if not aligned - struct chunk_begin* next; - struct chunk_begin* prev; + void * aligned_orig; // NULL if not aligned + struct chunk_begin *next; + struct chunk_begin *prev; char redzone[REDZONE_SIZE]; }; @@ -68,45 +68,45 @@ struct chunk_struct { #ifdef __GLIBC__ -void* (*__lq_libc_malloc)(size_t); -void (*__lq_libc_free)(void*); -#define backend_malloc __lq_libc_malloc -#define backend_free __lq_libc_free +void *(*__lq_libc_malloc)(size_t); +void (*__lq_libc_free)(void *); + #define backend_malloc __lq_libc_malloc + #define backend_free __lq_libc_free -#define TMP_ZONE_SIZE 4096 + #define TMP_ZONE_SIZE 4096 static int __tmp_alloc_zone_idx; static unsigned char __tmp_alloc_zone[TMP_ZONE_SIZE]; #else // From dlmalloc.c -void* dlmalloc(size_t); -void dlfree(void*); -#define backend_malloc dlmalloc -#define backend_free dlfree +void * dlmalloc(size_t); +void dlfree(void *); + #define backend_malloc dlmalloc + #define backend_free dlfree #endif int __libqasan_malloc_initialized; -static struct chunk_begin* quarantine_top; -static struct chunk_begin* quarantine_end; +static struct chunk_begin *quarantine_top; +static struct chunk_begin *quarantine_end; static size_t quarantine_bytes; #ifdef __BIONIC__ -static pthread_mutex_t quarantine_lock; -#define LOCK_TRY pthread_mutex_trylock -#define LOCK_INIT pthread_mutex_init -#define LOCK_UNLOCK pthread_mutex_unlock +static pthread_mutex_t quarantine_lock; + #define LOCK_TRY pthread_mutex_trylock + #define LOCK_INIT pthread_mutex_init + #define LOCK_UNLOCK pthread_mutex_unlock #else -static pthread_spinlock_t quarantine_lock; -#define LOCK_TRY pthread_spin_trylock -#define LOCK_INIT pthread_spin_init -#define LOCK_UNLOCK pthread_spin_unlock +static pthread_spinlock_t quarantine_lock; + #define LOCK_TRY pthread_spin_trylock + #define LOCK_INIT pthread_spin_init + #define LOCK_UNLOCK pthread_spin_unlock #endif // need qasan disabled -static int quanratine_push(struct chunk_begin* ck) { +static int quanratine_push(struct chunk_begin *ck) { if (ck->requested_size >= QUARANTINE_MAX_BYTES) return 0; @@ -114,7 +114,7 @@ static int quanratine_push(struct chunk_begin* ck) { while (ck->requested_size + quarantine_bytes >= QUARANTINE_MAX_BYTES) { - struct chunk_begin* tmp = quarantine_end; + struct chunk_begin *tmp = quarantine_end; quarantine_end = tmp->prev; quarantine_bytes -= tmp->requested_size; @@ -154,23 +154,23 @@ void __libqasan_init_malloc(void) { } -size_t __libqasan_malloc_usable_size(void* ptr) { +size_t __libqasan_malloc_usable_size(void *ptr) { - char* p = ptr; + char *p = ptr; p -= sizeof(struct chunk_begin); - return ((struct chunk_begin*)p)->requested_size; + return ((struct chunk_begin *)p)->requested_size; } -void* __libqasan_malloc(size_t size) { +void *__libqasan_malloc(size_t size) { if (!__libqasan_malloc_initialized) { - + __libqasan_init_malloc(); #ifdef __GLIBC__ - void* r = &__tmp_alloc_zone[__tmp_alloc_zone_idx]; + void *r = &__tmp_alloc_zone[__tmp_alloc_zone_idx]; if (size & (ALLOC_ALIGN_SIZE - 1)) __tmp_alloc_zone_idx += @@ -185,7 +185,7 @@ void* __libqasan_malloc(size_t size) { int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread - struct chunk_begin* p = backend_malloc(sizeof(struct chunk_struct) + size); + struct chunk_begin *p = backend_malloc(sizeof(struct chunk_struct) + size); QASAN_SWAP(state); @@ -197,14 +197,14 @@ void* __libqasan_malloc(size_t size) { p->aligned_orig = NULL; p->next = p->prev = NULL; - QASAN_ALLOC(&p[1], (char*)&p[1] + size); + QASAN_ALLOC(&p[1], (char *)&p[1] + size); QASAN_POISON(p->redzone, REDZONE_SIZE, ASAN_HEAP_LEFT_RZ); if (size & (ALLOC_ALIGN_SIZE - 1)) - QASAN_POISON((char*)&p[1] + size, + QASAN_POISON((char *)&p[1] + size, (size & ~(ALLOC_ALIGN_SIZE - 1)) + 8 - size + REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); else - QASAN_POISON((char*)&p[1] + size, REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); + QASAN_POISON((char *)&p[1] + size, REDZONE_SIZE, ASAN_HEAP_RIGHT_RZ); __builtin_memset(&p[1], 0xff, size); @@ -212,17 +212,17 @@ void* __libqasan_malloc(size_t size) { } -void __libqasan_free(void* ptr) { +void __libqasan_free(void *ptr) { if (!ptr) return; - + #ifdef __GLIBC__ - if (ptr >= (void*)__tmp_alloc_zone && - ptr < ((void*)__tmp_alloc_zone + TMP_ZONE_SIZE)) + if (ptr >= (void *)__tmp_alloc_zone && + ptr < ((void *)__tmp_alloc_zone + TMP_ZONE_SIZE)) return; #endif - struct chunk_begin* p = ptr; + struct chunk_begin *p = ptr; p -= 1; size_t n = p->requested_size; @@ -249,21 +249,22 @@ void __libqasan_free(void* ptr) { } -void* __libqasan_calloc(size_t nmemb, size_t size) { +void *__libqasan_calloc(size_t nmemb, size_t size) { size *= nmemb; #ifdef __GLIBC__ if (!__libqasan_malloc_initialized) { - void* r = &__tmp_alloc_zone[__tmp_alloc_zone_idx]; + void *r = &__tmp_alloc_zone[__tmp_alloc_zone_idx]; __tmp_alloc_zone_idx += size; return r; } + #endif - char* p = __libqasan_malloc(size); + char *p = __libqasan_malloc(size); if (!p) return NULL; __builtin_memset(p, 0, size); @@ -272,14 +273,14 @@ void* __libqasan_calloc(size_t nmemb, size_t size) { } -void* __libqasan_realloc(void* ptr, size_t size) { +void *__libqasan_realloc(void *ptr, size_t size) { - char* p = __libqasan_malloc(size); + char *p = __libqasan_malloc(size); if (!p) return NULL; if (!ptr) return p; - size_t n = ((struct chunk_begin*)ptr)[-1].requested_size; + size_t n = ((struct chunk_begin *)ptr)[-1].requested_size; if (size < n) n = size; __builtin_memcpy(p, ptr, n); @@ -289,9 +290,9 @@ void* __libqasan_realloc(void* ptr, size_t size) { } -int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { +int __libqasan_posix_memalign(void **ptr, size_t align, size_t len) { - if ((align % 2) || (align % sizeof(void*))) return EINVAL; + if ((align % 2) || (align % sizeof(void *))) return EINVAL; if (len == 0) { *ptr = NULL; @@ -305,7 +306,7 @@ int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { int state = QASAN_SWAP(QASAN_DISABLED); // disable qasan for this thread - char* orig = backend_malloc(sizeof(struct chunk_struct) + size); + char *orig = backend_malloc(sizeof(struct chunk_struct) + size); QASAN_SWAP(state); @@ -313,10 +314,10 @@ int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { QASAN_UNPOISON(orig, sizeof(struct chunk_struct) + size); - char* data = orig + sizeof(struct chunk_begin); + char *data = orig + sizeof(struct chunk_begin); data += align - ((uintptr_t)data % align); - struct chunk_begin* p = (struct chunk_begin*)data - 1; + struct chunk_begin *p = (struct chunk_begin *)data - 1; p->requested_size = len; p->aligned_orig = orig; @@ -339,9 +340,9 @@ int __libqasan_posix_memalign(void** ptr, size_t align, size_t len) { } -void* __libqasan_memalign(size_t align, size_t len) { +void *__libqasan_memalign(size_t align, size_t len) { - void* ret = NULL; + void *ret = NULL; __libqasan_posix_memalign(&ret, align, len); @@ -349,9 +350,9 @@ void* __libqasan_memalign(size_t align, size_t len) { } -void* __libqasan_aligned_alloc(size_t align, size_t len) { +void *__libqasan_aligned_alloc(size_t align, size_t len) { - void* ret = NULL; + void *ret = NULL; if ((len % align)) return NULL; diff --git a/qemu_mode/libqasan/string.c b/qemu_mode/libqasan/string.c index 4be01279..c850463b 100644 --- a/qemu_mode/libqasan/string.c +++ b/qemu_mode/libqasan/string.c @@ -271,7 +271,7 @@ void *__libqasan_memmem(const void *haystack, size_t haystack_len, } - } while (++h <= end); + } while (h++ <= end); return 0; diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index 47722f64..9a258d5b 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit 47722f64e4c1662bad97dc25f3e4cc63959ff5f3 +Subproject commit 9a258d5b7a38c045a6e385fcfcf80a746a60e557 diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c index 7844eedf..3ce4148d 100644 --- a/src/afl-fuzz-redqueen.c +++ b/src/afl-fuzz-redqueen.c @@ -1303,7 +1303,7 @@ static u8 cmp_extend_encoding(afl_state_t *afl, struct cmp_header *h, } -#endif /* CMPLOG_SOLVE_ARITHMETIC */ +#endif /* CMPLOG_SOLVE_ARITHMETIC */ return 0; @@ -2670,3 +2670,4 @@ exit_its: return r; } + -- cgit 1.4.1 From 7cfa690d1c677e04e0935d6ac3c6b94b5fed50ad Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 12 Feb 2021 11:05:46 +0100 Subject: typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f49bf99..e3886ca7 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ behaviours and defaults: * a caching of testcases can now be performed and can be modified by editing config.h for TESTCASE_CACHE or by specifying the env variable `AFL_TESTCACHE_SIZE` (in MB). Good values are between 50-500 (default: 50). - * -M mains does not perform trimming + * -M mains do not perform trimming * examples/ got renamed to utils/ * libtokencap/ libdislocator/ and qdbi_mode/ were moved to utils/ * afl-cmin/afl-cmin.bash now search first in PATH and last in AFL_PATH -- cgit 1.4.1 From c0b3127b9d3c0ef1ee9968f24c3c03b22b054e7b Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Fri, 12 Feb 2021 14:54:24 +0100 Subject: remove travis badge --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index e3886ca7..ef27e743 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ AFL++ Logo - ![Travis State](https://api.travis-ci.com/AFLplusplus/AFLplusplus.svg?branch=stable) - Release Version: [3.00c](https://github.com/AFLplusplus/AFLplusplus/releases) Github Version: 3.01a -- cgit 1.4.1 From 64e46dcefc938f6a6f6263f66d231009bb8b245c Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Fri, 12 Feb 2021 22:07:17 +0100 Subject: remvoe libcompcov 32 bits warnings --- qemu_mode/libcompcov/libcompcov.so.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/qemu_mode/libcompcov/libcompcov.so.c b/qemu_mode/libcompcov/libcompcov.so.c index 23f465a4..4fc84e62 100644 --- a/qemu_mode/libcompcov/libcompcov.so.c +++ b/qemu_mode/libcompcov/libcompcov.so.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include "types.h" #include "config.h" @@ -159,14 +161,15 @@ static void __compcov_load(void) { } -static void __compcov_trace(u64 cur_loc, const u8 *v0, const u8 *v1, size_t n) { +static void __compcov_trace(uintptr_t cur_loc, const u8 *v0, const u8 *v1, + size_t n) { size_t i; if (debug_fd != 1) { char debugbuf[4096]; - snprintf(debugbuf, sizeof(debugbuf), "0x%llx %s %s %zu\n", cur_loc, + snprintf(debugbuf, sizeof(debugbuf), "0x%" PRIxPTR " %s %s %zu\n", cur_loc, v0 == NULL ? "(null)" : (char *)v0, v1 == NULL ? "(null)" : (char *)v1, n); write(debug_fd, debugbuf, strlen(debugbuf)); @@ -206,7 +209,7 @@ int strcmp(const char *str1, const char *str2) { if (n <= MAX_CMP_LENGTH) { - u64 cur_loc = (u64)retaddr; + uintptr_t cur_loc = (uintptr_t)retaddr; cur_loc = (cur_loc >> 4) ^ (cur_loc << 8); cur_loc &= MAP_SIZE - 1; @@ -235,7 +238,7 @@ int strncmp(const char *str1, const char *str2, size_t len) { if (n <= MAX_CMP_LENGTH) { - u64 cur_loc = (u64)retaddr; + uintptr_t cur_loc = (uintptr_t)retaddr; cur_loc = (cur_loc >> 4) ^ (cur_loc << 8); cur_loc &= MAP_SIZE - 1; @@ -265,7 +268,7 @@ int strcasecmp(const char *str1, const char *str2) { if (n <= MAX_CMP_LENGTH) { - u64 cur_loc = (u64)retaddr; + uintptr_t cur_loc = (uintptr_t)retaddr; cur_loc = (cur_loc >> 4) ^ (cur_loc << 8); cur_loc &= MAP_SIZE - 1; @@ -296,7 +299,7 @@ int strncasecmp(const char *str1, const char *str2, size_t len) { if (n <= MAX_CMP_LENGTH) { - u64 cur_loc = (u64)retaddr; + uintptr_t cur_loc = (uintptr_t)retaddr; cur_loc = (cur_loc >> 4) ^ (cur_loc << 8); cur_loc &= MAP_SIZE - 1; @@ -324,7 +327,7 @@ int memcmp(const void *mem1, const void *mem2, size_t len) { if (n <= MAX_CMP_LENGTH) { - u64 cur_loc = (u64)retaddr; + uintptr_t cur_loc = (uintptr_t)retaddr; cur_loc = (cur_loc >> 4) ^ (cur_loc << 8); cur_loc &= MAP_SIZE - 1; -- cgit 1.4.1 From d827bc458061bc4320e25a27fd77cdbc4bba47ba Mon Sep 17 00:00:00 2001 From: aflpp Date: Sat, 13 Feb 2021 09:12:36 +0100 Subject: dont break on llvm 13 --- GNUmakefile.llvm | 7 ++++++- qemu_mode/qemuafl | 2 +- unicorn_mode/unicornafl | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/GNUmakefile.llvm b/GNUmakefile.llvm index d3691658..c23af200 100644 --- a/GNUmakefile.llvm +++ b/GNUmakefile.llvm @@ -43,7 +43,8 @@ endif LLVMVER = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/git//' | sed 's/svn//' ) LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/\..*//' ) LLVM_MINOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/.*\.//' | sed 's/git//' | sed 's/svn//' | sed 's/ .*//' ) -LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^3\.[0-3]|^1[3-9]' && echo 1 || echo 0 ) +LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^[0-2]\.|3\.[0-3]' && echo 1 || echo 0 ) +LLVM_TOO_NEW = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[3-9]' && echo 1 || echo 0 ) LLVM_NEW_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[0-9]' && echo 1 || echo 0 ) LLVM_10_OK = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[1-9]|^10\.[1-9]|^10\.0.[1-9]' && echo 1 || echo 0 ) LLVM_HAVE_LTO = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[1-9]' && echo 1 || echo 0 ) @@ -61,6 +62,10 @@ ifeq "$(LLVM_UNSUPPORTED)" "1" $(warning llvm_mode only supports llvm versions 3.4 up to 12) endif +ifeq "$(LLVM_TOO_NEW)" "1" + $(warning you are using an in-development llvm version - this might break llvm_mode!) +endif + LLVM_TOO_OLD=1 ifeq "$(LLVM_MAJOR)" "9" diff --git a/qemu_mode/qemuafl b/qemu_mode/qemuafl index 9a258d5b..246c1777 160000 --- a/qemu_mode/qemuafl +++ b/qemu_mode/qemuafl @@ -1 +1 @@ -Subproject commit 9a258d5b7a38c045a6e385fcfcf80a746a60e557 +Subproject commit 246c1777f453a280cbafc57f92742147ffc72818 diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index fb2fc9f2..80d31ef3 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit fb2fc9f25df32f17f6b6b859e4dbd70f9a857e0c +Subproject commit 80d31ef367f7a1a75fc48e08e129d10f2ffa0498 -- cgit 1.4.1 From 129a5adaf1cd5d1b602c49342badf586b415ca30 Mon Sep 17 00:00:00 2001 From: aflpp Date: Sat, 13 Feb 2021 09:29:35 +0100 Subject: fix --- GNUmakefile.llvm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GNUmakefile.llvm b/GNUmakefile.llvm index c23af200..cc332f6c 100644 --- a/GNUmakefile.llvm +++ b/GNUmakefile.llvm @@ -43,7 +43,7 @@ endif LLVMVER = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/git//' | sed 's/svn//' ) LLVM_MAJOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/\..*//' ) LLVM_MINOR = $(shell $(LLVM_CONFIG) --version 2>/dev/null | sed 's/.*\.//' | sed 's/git//' | sed 's/svn//' | sed 's/ .*//' ) -LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^[0-2]\.|3\.[0-3]' && echo 1 || echo 0 ) +LLVM_UNSUPPORTED = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^3\.[0-3]|^[0-2]\.' && echo 1 || echo 0 ) LLVM_TOO_NEW = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[3-9]' && echo 1 || echo 0 ) LLVM_NEW_API = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[0-9]' && echo 1 || echo 0 ) LLVM_10_OK = $(shell $(LLVM_CONFIG) --version 2>/dev/null | egrep -q '^1[1-9]|^10\.[1-9]|^10\.0.[1-9]' && echo 1 || echo 0 ) @@ -59,7 +59,7 @@ ifeq "$(LLVMVER)" "" endif ifeq "$(LLVM_UNSUPPORTED)" "1" - $(warning llvm_mode only supports llvm versions 3.4 up to 12) + $(error llvm_mode only supports llvm from version 3.4 onwards) endif ifeq "$(LLVM_TOO_NEW)" "1" -- cgit 1.4.1 From 1ba5d1008e749a12ac338f57adbac3b2b4cf9ea9 Mon Sep 17 00:00:00 2001 From: aflpp Date: Sat, 13 Feb 2021 10:53:40 +0100 Subject: fuck you llvm 13 --- src/afl-cc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/afl-cc.c b/src/afl-cc.c index 0ae401e7..9d88f262 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -554,6 +554,11 @@ static void edit_params(u32 argc, char **argv, char **envp) { } +#if LLVM_MAJOR >= 13 + // fuck you llvm 13 + cc_params[cc_par_cnt++] = "-fno-experimental-new-pass-manager"; +#endif + if (lto_mode && !have_c) { u8 *ld_path = strdup(AFL_REAL_LD); -- cgit 1.4.1 From 87a607c7d081dac1e4afd7c3cbe5accf62d355e4 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sat, 13 Feb 2021 11:17:53 +0100 Subject: update doc --- docs/Changelog.md | 1 + instrumentation/SanitizerCoveragePCGUARD.so.cc | 10 +++++----- unicorn_mode/unicornafl | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 919e2aeb..c59a1a7a 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -48,6 +48,7 @@ sending a mail to . support (less performant than our own), GCC for old afl-gcc and CLANG for old afl-clang - fixed a potential crash in the LAF feature + - workaround for llvm 13 - qemuafl - QASan (address sanitizer for Qemu) ported to qemuafl! See qemu_mode/libqasan/README.md diff --git a/instrumentation/SanitizerCoveragePCGUARD.so.cc b/instrumentation/SanitizerCoveragePCGUARD.so.cc index 5d6d6703..80c8f917 100644 --- a/instrumentation/SanitizerCoveragePCGUARD.so.cc +++ b/instrumentation/SanitizerCoveragePCGUARD.so.cc @@ -1088,7 +1088,7 @@ void ModuleSanitizerCoverage::InjectTraceForSwitch( } - llvm::sort(Initializers.begin() + 2, Initializers.end(), + llvm::sort(drop_begin(Initializers, 2), [](const Constant *A, const Constant *B) { return cast(A)->getLimitedValue() < @@ -1136,10 +1136,10 @@ void ModuleSanitizerCoverage::InjectTraceForGep( for (auto GEP : GepTraceTargets) { IRBuilder<> IRB(GEP); - for (auto I = GEP->idx_begin(); I != GEP->idx_end(); ++I) - if (!isa(*I) && (*I)->getType()->isIntegerTy()) - IRB.CreateCall(SanCovTraceGepFunction, - {IRB.CreateIntCast(*I, IntptrTy, true)}); + for (Use &Idx : GEP->indices()) + if (!isa(Idx) && Idx->getType()->isIntegerTy()) + IRB.CreateCall(SanCovTraceGepFunction, + {IRB.CreateIntCast(Idx, IntptrTy, true)}); } diff --git a/unicorn_mode/unicornafl b/unicorn_mode/unicornafl index 80d31ef3..fb2fc9f2 160000 --- a/unicorn_mode/unicornafl +++ b/unicorn_mode/unicornafl @@ -1 +1 @@ -Subproject commit 80d31ef367f7a1a75fc48e08e129d10f2ffa0498 +Subproject commit fb2fc9f25df32f17f6b6b859e4dbd70f9a857e0c -- cgit 1.4.1 From 385312c65858695b55607ccd376fb5ea8f83a688 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Sat, 13 Feb 2021 13:31:17 +0100 Subject: fix issue #732 afl-cmin and afl-showmap should support '-f' --- afl-cmin | 4 ++-- src/afl-showmap.c | 3 +-- test/test-basic.sh | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/afl-cmin b/afl-cmin index 31d7ddad..4ee79a79 100755 --- a/afl-cmin +++ b/afl-cmin @@ -411,8 +411,8 @@ BEGIN { retval = system( AFL_CMIN_CRASHES_ONLY"\""showmap"\" -m "mem_limit" -t "timeout" -o \""trace_dir"\" -Z "extra_par" -i \""in_dir"\" -- \""target_bin"\" "prog_args_string) } else { print " Processing "in_count" files (forkserver mode)..." -# print AFL_CMIN_CRASHES_ONLY"\""showmap"\" -m "mem_limit" -t "timeout" -o \""trace_dir"\" -Z "extra_par" -i \""in_dir"\" -- \""target_bin"\" "prog_args_string" use_stdin); } else { @@ -1169,7 +1168,7 @@ int main(int argc, char **argv_orig, char **envp) { } - stdin_file = + stdin_file = at_file ? strdup(at_file) : alloc_printf("%s/.afl-showmap-temp-%u", use_dir, (u32)getpid()); unlink(stdin_file); atexit(at_exit_handler); diff --git a/test/test-basic.sh b/test/test-basic.sh index 132610c0..b4bb9df2 100755 --- a/test/test-basic.sh +++ b/test/test-basic.sh @@ -7,7 +7,7 @@ AFL_GCC=afl-gcc $ECHO "$BLUE[*] Testing: ${AFL_GCC}, afl-showmap, afl-fuzz, afl-cmin and afl-tmin" test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc" -o "$SYS" = "i386" && { test -e ../${AFL_GCC} -a -e ../afl-showmap -a -e ../afl-fuzz && { - ../${AFL_GCC} -o test-instr.plain ../test-instr.c > /dev/null 2>&1 + ../${AFL_GCC} -o test-instr.plain -O0 ../test-instr.c > /dev/null 2>&1 AFL_HARDEN=1 ../${AFL_GCC} -o test-compcov.harden test-compcov.c > /dev/null 2>&1 test -e test-instr.plain && { $ECHO "$GREEN[+] ${AFL_GCC} compilation succeeded" @@ -39,7 +39,7 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc $ECHO "$RED[!] ${AFL_GCC} failed" echo CUT------------------------------------------------------------------CUT uname -a - ../${AFL_GCC} -o test-instr.plain ../test-instr.c + ../${AFL_GCC} -o test-instr.plain -O0 ../test-instr.c echo CUT------------------------------------------------------------------CUT CODE=1 } @@ -128,7 +128,7 @@ test "$SYS" = "i686" -o "$SYS" = "x86_64" -o "$SYS" = "amd64" -o "$SYS" = "i86pc $ECHO "$BLUE[*] Testing: ${AFL_GCC}, afl-showmap, afl-fuzz, afl-cmin and afl-tmin" SKIP= test -e ../${AFL_GCC} -a -e ../afl-showmap -a -e ../afl-fuzz && { - ../${AFL_GCC} -o test-instr.plain ../test-instr.c > /dev/null 2>&1 + ../${AFL_GCC} -o test-instr.plain -O0 ../test-instr.c > /dev/null 2>&1 AFL_HARDEN=1 ../${AFL_GCC} -o test-compcov.harden test-compcov.c > /dev/null 2>&1 test -e test-instr.plain && { $ECHO "$GREEN[+] ${AFL_GCC} compilation succeeded" -- cgit 1.4.1 From 1d60c39191478334e27ddf4f60cf9b27710502f0 Mon Sep 17 00:00:00 2001 From: hexcoder- Date: Sat, 13 Feb 2021 13:42:37 +0100 Subject: fix new compiler warning --- src/afl-showmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 2e421065..0d2c5ceb 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -1168,7 +1168,7 @@ int main(int argc, char **argv_orig, char **envp) { } - stdin_file = at_file ? strdup(at_file) : + stdin_file = at_file ? strdup(at_file) : (char *) alloc_printf("%s/.afl-showmap-temp-%u", use_dir, (u32)getpid()); unlink(stdin_file); atexit(at_exit_handler); -- cgit 1.4.1 From 6ce9230ed66dbd091001436cdab2fc1718e8e61e Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sat, 13 Feb 2021 14:24:21 +0100 Subject: afl-cmin/afl-showmap -f --- docs/Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/Changelog.md b/docs/Changelog.md index c59a1a7a..895ab845 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -59,6 +59,7 @@ sending a mail to . - Substantial speed gains in python bindings for certain use cases - Improved rust bindings - Added a new example harness to compare python, c, and rust bindings + - afl-cmin and afl-showmap now support the -f option - changed default: no memory limit for afl-cmin and afl-cmin.bash - warn on any _AFL and __AFL env vars - added dummy Makefile to instrumentation/ -- cgit 1.4.1 From 9bd1e19d7f004b4da6a610b07e59f99d66bb7ec2 Mon Sep 17 00:00:00 2001 From: vanhauser-thc Date: Sat, 13 Feb 2021 22:43:56 +0100 Subject: added AFL_IGNORE_UNKNOWN_ENVS --- docs/Changelog.md | 3 ++- docs/env_variables.md | 5 ++++- include/envs.h | 1 + instrumentation/SanitizerCoveragePCGUARD.so.cc | 2 +- src/afl-cc.c | 1 + src/afl-common.c | 4 ++-- src/afl-fuzz.c | 1 + src/afl-showmap.c | 5 +++-- 8 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 895ab845..71ef4c2c 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -61,7 +61,8 @@ sending a mail to . - Added a new example harness to compare python, c, and rust bindings - afl-cmin and afl-showmap now support the -f option - changed default: no memory limit for afl-cmin and afl-cmin.bash - - warn on any _AFL and __AFL env vars + - warn on any _AFL and __AFL env vars. + - set AFL_IGNORE_UNKNOWN_ENVS to not warn on unknown AFL_... env vars. - added dummy Makefile to instrumentation/ - Updated utils/afl_frida to be 5% faster, 7% on x86_x64 - Added AFL_KILL_SIGNAL env variable (thanks @v-p-b) diff --git a/docs/env_variables.md b/docs/env_variables.md index 886669ad..f7745247 100644 --- a/docs/env_variables.md +++ b/docs/env_variables.md @@ -5,6 +5,10 @@ users or for some types of custom fuzzing setups. See [README.md](README.md) for the general instruction manual. + Note that most tools will warn on any unknown AFL environment variables. + This is for warning on typos that can happen. If you want to disable this + check then set the `AFL_IGNORE_UNKNOWN_ENVS` environment variable. + ## 1) Settings for all compilers Starting with afl++ 3.0 there is only one compiler: afl-cc @@ -18,7 +22,6 @@ To select the different instrumentation modes this can be done by `MODE` can be one of `LTO` (afl-clang-lto*), `LLVM` (afl-clang-fast*), `GCC_PLUGIN` (afl-g*-fast) or `GCC` (afl-gcc/afl-g++). - Because (with the exception of the --afl-MODE command line option) the compile-time tools do not accept afl specific command-line options, they make fairly broad use of environmental variables instead: diff --git a/include/envs.h b/include/envs.h index 210b34a6..4313e053 100644 --- a/include/envs.h +++ b/include/envs.h @@ -61,6 +61,7 @@ static char *afl_environment_variables[] = { "AFL_FORKSRV_INIT_TMOUT", "AFL_HARDEN", "AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES", + "AFL_IGNORE_UNKNOWN_ENVS", "AFL_IMPORT_FIRST", "AFL_INST_LIBS", "AFL_INST_RATIO", diff --git a/instrumentation/SanitizerCoveragePCGUARD.so.cc b/instrumentation/SanitizerCoveragePCGUARD.so.cc index 80c8f917..9b1351b0 100644 --- a/instrumentation/SanitizerCoveragePCGUARD.so.cc +++ b/instrumentation/SanitizerCoveragePCGUARD.so.cc @@ -1138,7 +1138,7 @@ void ModuleSanitizerCoverage::InjectTraceForGep( IRBuilder<> IRB(GEP); for (Use &Idx : GEP->indices()) if (!isa(Idx) && Idx->getType()->isIntegerTy()) - IRB.CreateCall(SanCovTraceGepFunction, + IRB.CreateCall(SanCovTraceGepFunction, {IRB.CreateIntCast(Idx, IntptrTy, true)}); } diff --git a/src/afl-cc.c b/src/afl-cc.c index 9d88f262..d41f79a2 100644 --- a/src/afl-cc.c +++ b/src/afl-cc.c @@ -1587,6 +1587,7 @@ int main(int argc, char **argv, char **envp) { "libtokencap.so)\n" " AFL_PATH: path to instrumenting pass and runtime " "(afl-compiler-rt.*o)\n" + " AFL_IGNORE_UNKNOWN_ENVS: don't warn on unknown env vars\n" " AFL_INST_RATIO: percentage of branches to instrument\n" " AFL_QUIET: suppress verbose output\n" " AFL_HARDEN: adds code hardening to catch memory bugs\n" diff --git a/src/afl-common.c b/src/afl-common.c index 1cc7f462..589aac71 100644 --- a/src/afl-common.c +++ b/src/afl-common.c @@ -523,7 +523,7 @@ void check_environment_vars(char **envp) { if (be_quiet) { return; } int index = 0, issue_detected = 0; - char *env, *val; + char *env, *val, *ignore = getenv("AFL_IGNORE_UNKNOWN_ENVS"); while ((env = envp[index++]) != NULL) { if (strncmp(env, "ALF_", 4) == 0 || strncmp(env, "_ALF", 4) == 0 || @@ -582,7 +582,7 @@ void check_environment_vars(char **envp) { } - if (match == 0) { + if (match == 0 && !ignore) { WARNF("Mistyped AFL environment variable: %s", env); issue_detected = 1; diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c index e4139857..e0ac8840 100644 --- a/src/afl-fuzz.c +++ b/src/afl-fuzz.c @@ -198,6 +198,7 @@ static void usage(u8 *argv0, int more_help) { "AFL_FORKSRV_INIT_TMOUT: time spent waiting for forkserver during startup (in milliseconds)\n" "AFL_HANG_TMOUT: override timeout value (in milliseconds)\n" "AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES: don't warn about core dump handlers\n" + "AFL_IGNORE_UNKNOWN_ENVS: don't warn on unknown env vars\n" "AFL_IMPORT_FIRST: sync and import test cases from other fuzzer instances first\n" "AFL_KILL_SIGNAL: Signal ID delivered to child processes on timeout, etc. (default: SIGKILL)\n" "AFL_MAP_SIZE: the shared memory size for that target. must be >= the size\n" diff --git a/src/afl-showmap.c b/src/afl-showmap.c index 0d2c5ceb..b40527d3 100644 --- a/src/afl-showmap.c +++ b/src/afl-showmap.c @@ -1168,8 +1168,9 @@ int main(int argc, char **argv_orig, char **envp) { } - stdin_file = at_file ? strdup(at_file) : (char *) - alloc_printf("%s/.afl-showmap-temp-%u", use_dir, (u32)getpid()); + stdin_file = at_file ? strdup(at_file) + : (char *)alloc_printf("%s/.afl-showmap-temp-%u", + use_dir, (u32)getpid()); unlink(stdin_file); atexit(at_exit_handler); fsrv->out_file = stdin_file; -- cgit 1.4.1