diff options
author | Josh Rickmar <jrick@devio.us> | 2012-09-15 12:06:23 -0400 |
---|---|---|
committer | Josh Rickmar <jrick@devio.us> | 2012-09-15 12:06:23 -0400 |
commit | 6a2a1deae1e0f80cb1d74b847f7b34bb08b0d5d6 (patch) | |
tree | 4298502b46d78958c7045df53483a83fec4051cb /netbsd/util.h | |
parent | f0ad34061db3c598230cf569f5f84d4a8af3761a (diff) | |
download | xombrero-6a2a1deae1e0f80cb1d74b847f7b34bb08b0d5d6.tar.gz |
Include NetBSD port, from Zplay
Diffstat (limited to 'netbsd/util.h')
-rw-r--r-- | netbsd/util.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/netbsd/util.h b/netbsd/util.h new file mode 100644 index 0000000..d08783f --- /dev/null +++ b/netbsd/util.h @@ -0,0 +1,35 @@ +#define RB_FOREACH(x, name, head) \ + for ((x) = RB_MIN(name, head); \ + (x) != NULL; \ + (x) = name##_RB_NEXT(x)) + +#define RB_FOREACH_SAFE(x, name, head, y) \ + for ((x) = RB_MIN(name, head); \ + ((x) != NULL) && ((y) = name##_RB_NEXT(x), 1); \ + (x) = (y)) + +#define RB_FOREACH_REVERSE(x, name, head) \ + for ((x) = RB_MAX(name, head); \ + (x) != NULL; \ + (x) = name##_RB_PREV(x)) + +#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ + for ((x) = RB_MAX(name, head); \ + ((x) != NULL) && ((y) = name##_RB_PREV(x), 1); \ + (x) = (y)) + + +#ifndef TAILQ_END +#define TAILQ_END(head) NULL +#endif + +#ifndef TAILQ_FOREACH_SAFE +#define TAILQ_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = TAILQ_FIRST(head); \ + (var) != TAILQ_END(head) && \ + ((tvar) = TAILQ_NEXT(var, field), 1); \ + (var) = (tvar)) +#endif + +#define FMT_SCALED_STRSIZE 7 /* minus sign, 4 digits, suffix, null byte */ +int fmt_scaled(long long number, char *result); |