Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

70 lines (56 sloc) 1.591 kb
/*
* Copyright (C) 2010 Ajax.org BV
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this library; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef O3_TOOLS_H
#define O3_TOOLS_H
#include <stdarg.h>
namespace o3 {
template<typename T>
inline T min(T x, T y)
{
o3_trace_tools("min");
return x < y ? x : y;
}
template<typename T>
inline T max(T x, T y)
{
o3_trace_tools("max");
return x < y ? y : x;
}
template<typename T>
inline void swap(T& x, T& y)
{
o3_trace_tools("swap");
uint8_t z[sizeof(T)];
memCopy(z, &x, sizeof(T));
memCopy(&x, &y, sizeof(T));
memCopy(&y, z, sizeof(T));
}
__inline int DoubleToInt(double d)
{
o3_trace_tools("DoubleToInt");
const double magic = 6755399441055744.0; // 2^51 + 2^52
double tmp = (d-0.5) + magic;
return *(int*) &tmp;
}
}
#define o3_unused(x) ((void)x)
#include "tools_atomic.h"
#include "tools_chr.h"
#include "tools_mem.h"
#include "tools_str.h"
#endif // O3_TOOLS_H
Jump to Line
Something went wrong with that request. Please try again.