2015-08-06 07:22:21 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Andrew Kelley
|
|
|
|
*
|
|
|
|
* This file is part of zig, which is MIT licensed.
|
|
|
|
* See http://opensource.org/licenses/MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "util.hpp"
|
|
|
|
|
|
|
|
void zig_panic(const char *format, ...) {
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
|
|
|
vfprintf(stderr, format, ap);
|
|
|
|
fprintf(stderr, "\n");
|
2017-10-02 09:05:08 +08:00
|
|
|
fflush(stderr);
|
2015-08-06 07:22:21 +08:00
|
|
|
va_end(ap);
|
|
|
|
abort();
|
|
|
|
}
|
2015-12-07 23:29:19 +08:00
|
|
|
|
|
|
|
uint32_t int_hash(int i) {
|
2015-12-14 17:46:37 +08:00
|
|
|
return (uint32_t)(i % UINT32_MAX);
|
2015-12-07 23:29:19 +08:00
|
|
|
}
|
|
|
|
bool int_eq(int a, int b) {
|
|
|
|
return a == b;
|
|
|
|
}
|
2015-12-14 17:46:37 +08:00
|
|
|
|
|
|
|
uint32_t uint64_hash(uint64_t i) {
|
|
|
|
return (uint32_t)(i % UINT32_MAX);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool uint64_eq(uint64_t a, uint64_t b) {
|
|
|
|
return a == b;
|
|
|
|
}
|
2016-04-23 12:43:48 +08:00
|
|
|
|
|
|
|
uint32_t ptr_hash(const void *ptr) {
|
2017-04-11 08:02:39 +08:00
|
|
|
return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX);
|
2016-04-23 12:43:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ptr_eq(const void *a, const void *b) {
|
|
|
|
return a == b;
|
|
|
|
}
|