zig/src/util.cpp
Andrew Kelley e411467e1d add number literal type
it gets implicitly casted to whatever is needed.

closes #24
2015-12-14 02:46:37 -07:00

37 lines
656 B
C++

/*
* 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");
va_end(ap);
abort();
}
uint32_t int_hash(int i) {
return (uint32_t)(i % UINT32_MAX);
}
bool int_eq(int a, int b) {
return a == b;
}
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;
}