Cross Reference: safe_math.h
xref
: /
openjdk7
/
jdk
/
src
/
share
/
native
/
sun
/
awt
/
medialib
/
safe_math.h
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
5817
N/A
/*
5817
N/A
* Copyright (c) 2013, Oracle
and
/
or
its affiliates. All rights reserved.
5817
N/A
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5817
N/A
*
5817
N/A
* This code is free software; you can redistribute it
and
/
or
modify it
5817
N/A
* under the terms of the GNU General Public License version 2 only, as
5817
N/A
* published by the Free Software Foundation. Oracle designates this
5817
N/A
* particular file as subject to the "Classpath" exception as provided
5817
N/A
* by Oracle in the LICENSE file that accompanied this code.
5817
N/A
*
5817
N/A
* This code is distributed in the hope that it will be useful, but WITHOUT
5817
N/A
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5817
N/A
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5817
N/A
* version 2 for more details (a copy is included in the LICENSE file that
5817
N/A
* accompanied this code).
5817
N/A
*
5817
N/A
* You should have received a copy of the GNU General Public License version
5817
N/A
* 2 along with this work; if not, write to the Free Software Foundation,
5817
N/A
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5817
N/A
*
5817
N/A
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5817
N/A
* or visit
www.oracle.c
om if you need additional information or have any
5817
N/A
* questions.
5817
N/A
*/
5817
N/A
5817
N/A
#
ifndef
__SAFE_MATH_H__
5817
N/A
#
define
__SAFE_MATH_H__
5817
N/A
5817
N/A
#
define
SAFE_TO_MULT
(a, b) \
5817
N/A
(((a) > 0) && ((b) >= 0) && ((
0x7fffffff
/ (a)) > (b)))
5817
N/A
5817
N/A
#
define
SAFE_TO_ADD
(a, b) \
5817
N/A
(((a) >= 0) && ((b) >= 0) && ((
0x7fffffff
- (a)) > (b)))
5817
N/A
5817
N/A
#
endif
// __SAFE_MATH_H__