2015-02-28 19:58:37 +00:00
|
|
|
/*
|
2015-03-14 15:42:05 +00:00
|
|
|
This file is part of ethash.
|
2015-02-28 19:58:37 +00:00
|
|
|
|
2015-03-14 15:42:05 +00:00
|
|
|
ethash is free software: you can redistribute it and/or modify
|
2015-02-28 19:58:37 +00:00
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
2015-03-14 15:42:05 +00:00
|
|
|
ethash is distributed in the hope that it will be useful,
|
2015-02-28 19:58:37 +00:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2015-03-14 15:42:05 +00:00
|
|
|
along with ethash. If not, see <http://www.gnu.org/licenses/>.
|
2015-02-28 19:58:37 +00:00
|
|
|
*/
|
|
|
|
/** @file util.h
|
|
|
|
* @author Tim Hughes <tim@twistedfury.com>
|
|
|
|
* @date 2015
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "compiler.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-05-07 17:39:55 +00:00
|
|
|
#ifdef _MSC_VER
|
2015-05-05 05:50:04 +00:00
|
|
|
void debugf(char const* str, ...);
|
2015-05-07 17:39:55 +00:00
|
|
|
#else
|
|
|
|
#define debugf printf
|
|
|
|
#endif
|
2015-02-28 19:58:37 +00:00
|
|
|
|
|
|
|
static inline uint32_t min_u32(uint32_t a, uint32_t b)
|
|
|
|
{
|
|
|
|
return a < b ? a : b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t clamp_u32(uint32_t x, uint32_t min_, uint32_t max_)
|
|
|
|
{
|
|
|
|
return x < min_ ? min_ : (x > max_ ? max_ : x);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|