4272N/A/*
4272N/A * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
4272N/A * Use is subject to license terms.
4272N/A *
4272N/A * This library is free software; you can redistribute it and/or
4272N/A * modify it under the terms of the GNU Lesser General Public
4272N/A * License as published by the Free Software Foundation; either
4272N/A * version 2.1 of the License, or (at your option) any later version.
1674N/A *
4272N/A * This library is distributed in the hope that it will be useful,
4272N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
4272N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4272N/A * Lesser General Public License for more details.
1674N/A *
4272N/A * You should have received a copy of the GNU Lesser General Public License
4272N/A * along with this library; if not, write to the Free Software Foundation,
4272N/A * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1674N/A *
4272N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4272N/A * or visit www.oracle.com if you need additional information or have any
4272N/A * questions.
4272N/A */
4272N/A
4272N/A/* *********************************************************************
1674N/A *
1674N/A * The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
1674N/A *
1674N/A * The Initial Developer of the Original Code is
1674N/A * Michael J. Fromberger.
1674N/A * Portions created by the Initial Developer are Copyright (C) 1998
1674N/A * the Initial Developer. All Rights Reserved.
1674N/A *
1674N/A * Contributor(s):
1674N/A *
1674N/A *********************************************************************** */
4272N/A
4272N/A/* Bitwise logical operations on MPI values */
1674N/A
1674N/A#ifndef _MPLOGIC_H
1674N/A#define _MPLOGIC_H
1674N/A
1674N/A/* $Id: mplogic.h,v 1.7 2004/04/27 23:04:36 gerv%gerv.net Exp $ */
1674N/A
1674N/A#include "mpi.h"
1674N/A
1674N/A/*
1674N/A The logical operations treat an mp_int as if it were a bit vector,
1674N/A without regard to its sign (an mp_int is represented in a signed
1674N/A magnitude format). Values are treated as if they had an infinite
1674N/A string of zeros left of the most-significant bit.
1674N/A */
1674N/A
1674N/A/* Parity results */
1674N/A
1674N/A#define MP_EVEN MP_YES
1674N/A#define MP_ODD MP_NO
1674N/A
1674N/A/* Bitwise functions */
1674N/A
1674N/Amp_err mpl_not(mp_int *a, mp_int *b); /* one's complement */
1674N/Amp_err mpl_and(mp_int *a, mp_int *b, mp_int *c); /* bitwise AND */
1674N/Amp_err mpl_or(mp_int *a, mp_int *b, mp_int *c); /* bitwise OR */
1674N/Amp_err mpl_xor(mp_int *a, mp_int *b, mp_int *c); /* bitwise XOR */
1674N/A
1674N/A/* Shift functions */
1674N/A
1674N/Amp_err mpl_rsh(const mp_int *a, mp_int *b, mp_digit d); /* right shift */
1674N/Amp_err mpl_lsh(const mp_int *a, mp_int *b, mp_digit d); /* left shift */
1674N/A
1674N/A/* Bit count and parity */
1674N/A
1674N/Amp_err mpl_num_set(mp_int *a, int *num); /* count set bits */
1674N/Amp_err mpl_num_clear(mp_int *a, int *num); /* count clear bits */
1674N/Amp_err mpl_parity(mp_int *a); /* determine parity */
1674N/A
1674N/A/* Get & Set the value of a bit */
1674N/A
1674N/Amp_err mpl_set_bit(mp_int *a, mp_size bitNum, mp_size value);
1674N/Amp_err mpl_get_bit(const mp_int *a, mp_size bitNum);
1674N/Amp_err mpl_get_bits(const mp_int *a, mp_size lsbNum, mp_size numBits);
1674N/Amp_err mpl_significant_bits(const mp_int *a);
1674N/A
1674N/A#endif /* _MPLOGIC_H */