xref: /onnv-gate/usr/src/common/mpi/mpi.h (revision 13066:6cb0e0fdae86)
1*13066SDina.Nimeh@Sun.COM /* BEGIN CSTYLED */
25697Smcpowers /*
35697Smcpowers  *  mpi.h
45697Smcpowers  *
55697Smcpowers  *  Arbitrary precision integer arithmetic library
65697Smcpowers  *
75697Smcpowers  * ***** BEGIN LICENSE BLOCK *****
85697Smcpowers  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
95697Smcpowers  *
105697Smcpowers  * The contents of this file are subject to the Mozilla Public License Version
115697Smcpowers  * 1.1 (the "License"); you may not use this file except in compliance with
125697Smcpowers  * the License. You may obtain a copy of the License at
135697Smcpowers  * http://www.mozilla.org/MPL/
145697Smcpowers  *
155697Smcpowers  * Software distributed under the License is distributed on an "AS IS" basis,
165697Smcpowers  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
175697Smcpowers  * for the specific language governing rights and limitations under the
185697Smcpowers  * License.
195697Smcpowers  *
205697Smcpowers  * The Original Code is the MPI Arbitrary Precision Integer Arithmetic library.
215697Smcpowers  *
225697Smcpowers  * The Initial Developer of the Original Code is
235697Smcpowers  * Michael J. Fromberger.
245697Smcpowers  * Portions created by the Initial Developer are Copyright (C) 1998
255697Smcpowers  * the Initial Developer. All Rights Reserved.
265697Smcpowers  *
275697Smcpowers  * Contributor(s):
285697Smcpowers  *   Netscape Communications Corporation
295697Smcpowers  *
305697Smcpowers  * Alternatively, the contents of this file may be used under the terms of
315697Smcpowers  * either the GNU General Public License Version 2 or later (the "GPL"), or
325697Smcpowers  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
335697Smcpowers  * in which case the provisions of the GPL or the LGPL are applicable instead
345697Smcpowers  * of those above. If you wish to allow use of your version of this file only
355697Smcpowers  * under the terms of either the GPL or the LGPL, and not to allow others to
365697Smcpowers  * use your version of this file under the terms of the MPL, indicate your
375697Smcpowers  * decision by deleting the provisions above and replace them with the notice
385697Smcpowers  * and other provisions required by the GPL or the LGPL. If you do not delete
395697Smcpowers  * the provisions above, a recipient may use your version of this file under
405697Smcpowers  * the terms of any one of the MPL, the GPL or the LGPL.
415697Smcpowers  *
425697Smcpowers  * ***** END LICENSE BLOCK ***** */
435697Smcpowers /*
44*13066SDina.Nimeh@Sun.COM  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
455697Smcpowers  *
465697Smcpowers  * Sun elects to use this software under the MPL license.
475697Smcpowers  */
485697Smcpowers 
495697Smcpowers #ifndef _MPI_H
505697Smcpowers #define _MPI_H
515697Smcpowers 
525697Smcpowers /* $Id: mpi.h,v 1.22 2004/04/27 23:04:36 gerv%gerv.net Exp $ */
535697Smcpowers 
545697Smcpowers #include "mpi-config.h"
555697Smcpowers #include <sys/param.h>
565697Smcpowers #ifdef _KERNEL
575697Smcpowers #include <sys/debug.h>
585697Smcpowers #include <sys/systm.h>
595697Smcpowers #define assert ASSERT
605697Smcpowers #define	labs(a) (a >= 0 ? a : -a)
615697Smcpowers #define	UCHAR_MAX 255
625697Smcpowers #define	memset(s, c, n) bzero(s, n)
635697Smcpowers #define	memcpy(a,b,c) bcopy((caddr_t)b, (caddr_t)a, c)
645697Smcpowers /*
655697Smcpowers  * Generic #define's to cover missing things in the kernel
665697Smcpowers  */
675697Smcpowers #ifndef isdigit
685697Smcpowers #define isdigit(x)	((x) >= '0' && (x) <= '9')
695697Smcpowers #endif
705697Smcpowers #ifndef isupper
715697Smcpowers #define isupper(x)	(((unsigned)(x) >= 'A') && ((unsigned)(x) <= 'Z'))
725697Smcpowers #endif
735697Smcpowers #ifndef islower
745697Smcpowers #define islower(x)	(((unsigned)(x) >= 'a') && ((unsigned)(x) <= 'z'))
755697Smcpowers #endif
765697Smcpowers #ifndef isalpha
775697Smcpowers #define isalpha(x)	(isupper(x) || islower(x))
785697Smcpowers #endif
795697Smcpowers #ifndef toupper
805697Smcpowers #define toupper(x)	(islower(x) ? (x) - 'a' + 'A' : (x))
815697Smcpowers #endif
825697Smcpowers #ifndef tolower
835697Smcpowers #define tolower(x)	(isupper(x) ? (x) + 'a' - 'A' : (x))
845697Smcpowers #endif
855697Smcpowers #ifndef isspace
865697Smcpowers #define isspace(x)	(((x) == ' ') || ((x) == '\r') || ((x) == '\n') || \
875697Smcpowers 			 ((x) == '\t') || ((x) == '\b'))
885697Smcpowers #endif
895697Smcpowers #endif /* _KERNEL */
905697Smcpowers 
915697Smcpowers #if MP_DEBUG
925697Smcpowers #undef MP_IOFUNC
935697Smcpowers #define MP_IOFUNC 1
945697Smcpowers #endif
955697Smcpowers 
965697Smcpowers #if MP_IOFUNC
975697Smcpowers #include <stdio.h>
985697Smcpowers #include <ctype.h>
995697Smcpowers #endif
1005697Smcpowers 
1015697Smcpowers #ifndef _KERNEL
1025697Smcpowers #include <limits.h>
1035697Smcpowers #endif
1045697Smcpowers 
1055697Smcpowers #if defined(BSDI)
1065697Smcpowers #undef ULLONG_MAX
1075697Smcpowers #endif
1085697Smcpowers 
1095697Smcpowers #if defined( macintosh )
1105697Smcpowers #include <Types.h>
1115697Smcpowers #elif defined( _WIN32_WCE)
1125697Smcpowers /* #include <sys/types.h> What do we need here ?? */
1135697Smcpowers #else
1145697Smcpowers #include <sys/types.h>
1155697Smcpowers #endif
1165697Smcpowers 
1175697Smcpowers #define  MP_NEG    1
1185697Smcpowers #define  MP_ZPOS   0
1195697Smcpowers 
1205697Smcpowers #define  MP_OKAY          0 /* no error, all is well */
1215697Smcpowers #define  MP_YES           0 /* yes (boolean result)  */
1225697Smcpowers #define  MP_NO           -1 /* no (boolean result)   */
1235697Smcpowers #define  MP_MEM          -2 /* out of memory         */
1245697Smcpowers #define  MP_RANGE        -3 /* argument out of range */
1255697Smcpowers #define  MP_BADARG       -4 /* invalid parameter     */
1265697Smcpowers #define  MP_UNDEF        -5 /* answer is undefined   */
1275697Smcpowers #define  MP_LAST_CODE    MP_UNDEF
1285697Smcpowers 
1295697Smcpowers typedef unsigned int      mp_sign;
1305697Smcpowers typedef unsigned int      mp_size;
1315697Smcpowers typedef int               mp_err;
1325697Smcpowers typedef int               mp_flag;
1335697Smcpowers 
1345697Smcpowers #define MP_32BIT_MAX 4294967295U
1355697Smcpowers 
1365697Smcpowers #if !defined(ULONG_MAX)
1375697Smcpowers #error "ULONG_MAX not defined"
1385697Smcpowers #elif !defined(UINT_MAX)
1395697Smcpowers #error "UINT_MAX not defined"
1405697Smcpowers #elif !defined(USHRT_MAX)
1415697Smcpowers #error "USHRT_MAX not defined"
1425697Smcpowers #endif
1435697Smcpowers 
1445697Smcpowers #if defined(ULONG_LONG_MAX)			/* GCC, HPUX */
1455697Smcpowers #define MP_ULONG_LONG_MAX ULONG_LONG_MAX
1465697Smcpowers #elif defined(ULLONG_MAX)			/* Solaris */
1475697Smcpowers #define MP_ULONG_LONG_MAX ULLONG_MAX
1485697Smcpowers /* MP_ULONG_LONG_MAX was defined to be ULLONG_MAX */
1495697Smcpowers #elif defined(ULONGLONG_MAX)			/* IRIX, AIX */
1505697Smcpowers #define MP_ULONG_LONG_MAX ULONGLONG_MAX
1515697Smcpowers #endif
1525697Smcpowers 
1535697Smcpowers /* We only use unsigned long for mp_digit iff long is more than 32 bits. */
1545697Smcpowers #if !defined(MP_USE_UINT_DIGIT) && ULONG_MAX > MP_32BIT_MAX
1555697Smcpowers typedef unsigned long     mp_digit;
1565697Smcpowers #define MP_DIGIT_MAX      ULONG_MAX
1575697Smcpowers #define MP_DIGIT_FMT      "%016lX"   /* printf() format for 1 digit */
1585697Smcpowers #define MP_HALF_DIGIT_MAX UINT_MAX
1595697Smcpowers #undef  MP_NO_MP_WORD
1605697Smcpowers #define MP_NO_MP_WORD 1
1615697Smcpowers #undef  MP_USE_LONG_DIGIT
1625697Smcpowers #define MP_USE_LONG_DIGIT 1
1635697Smcpowers #undef  MP_USE_LONG_LONG_DIGIT
1645697Smcpowers 
1655697Smcpowers #elif !defined(MP_USE_UINT_DIGIT) && defined(MP_ULONG_LONG_MAX)
1665697Smcpowers typedef unsigned long long mp_digit;
1675697Smcpowers #define MP_DIGIT_MAX       MP_ULONG_LONG_MAX
1685697Smcpowers #define MP_DIGIT_FMT      "%016llX"  /* printf() format for 1 digit */
1695697Smcpowers #define MP_HALF_DIGIT_MAX  UINT_MAX
1705697Smcpowers #undef  MP_NO_MP_WORD
1715697Smcpowers #define MP_NO_MP_WORD 1
1725697Smcpowers #undef  MP_USE_LONG_LONG_DIGIT
1735697Smcpowers #define MP_USE_LONG_LONG_DIGIT 1
1745697Smcpowers #undef  MP_USE_LONG_DIGIT
1755697Smcpowers 
1765697Smcpowers #else
1775697Smcpowers typedef unsigned int      mp_digit;
1785697Smcpowers #define MP_DIGIT_MAX      UINT_MAX
1795697Smcpowers #define MP_DIGIT_FMT      "%08X"     /* printf() format for 1 digit */
1805697Smcpowers #define MP_HALF_DIGIT_MAX USHRT_MAX
1815697Smcpowers #undef  MP_USE_UINT_DIGIT
1825697Smcpowers #define MP_USE_UINT_DIGIT 1
1835697Smcpowers #undef  MP_USE_LONG_LONG_DIGIT
1845697Smcpowers #undef  MP_USE_LONG_DIGIT
1855697Smcpowers #endif
1865697Smcpowers 
1875697Smcpowers #if !defined(MP_NO_MP_WORD)
1885697Smcpowers #if  defined(MP_USE_UINT_DIGIT) && \
1895697Smcpowers     (defined(MP_ULONG_LONG_MAX) || (ULONG_MAX > UINT_MAX))
1905697Smcpowers 
1915697Smcpowers #if (ULONG_MAX > UINT_MAX)
1925697Smcpowers typedef unsigned long     mp_word;
1935697Smcpowers typedef          long     mp_sword;
1945697Smcpowers #define MP_WORD_MAX       ULONG_MAX
1955697Smcpowers 
1965697Smcpowers #else
1975697Smcpowers typedef unsigned long long mp_word;
1985697Smcpowers typedef          long long mp_sword;
1995697Smcpowers #define MP_WORD_MAX       MP_ULONG_LONG_MAX
2005697Smcpowers #endif
2015697Smcpowers 
2025697Smcpowers #else
2035697Smcpowers #define MP_NO_MP_WORD 1
2045697Smcpowers #endif
2055697Smcpowers #endif /* !defined(MP_NO_MP_WORD) */
2065697Smcpowers 
2075697Smcpowers #if !defined(MP_WORD_MAX) && defined(MP_DEFINE_SMALL_WORD)
2085697Smcpowers typedef unsigned int      mp_word;
2095697Smcpowers typedef          int      mp_sword;
2105697Smcpowers #define MP_WORD_MAX       UINT_MAX
2115697Smcpowers #endif
2125697Smcpowers 
2135697Smcpowers #ifndef CHAR_BIT
2145697Smcpowers #define	CHAR_BIT 8
2155697Smcpowers #endif
2165697Smcpowers 
2175697Smcpowers #define MP_DIGIT_BIT      (CHAR_BIT*sizeof(mp_digit))
2185697Smcpowers #define MP_WORD_BIT       (CHAR_BIT*sizeof(mp_word))
2195697Smcpowers #define MP_RADIX          (1+(mp_word)MP_DIGIT_MAX)
2205697Smcpowers 
2215697Smcpowers #define MP_HALF_DIGIT_BIT (MP_DIGIT_BIT/2)
2225697Smcpowers #define MP_HALF_RADIX     (1+(mp_digit)MP_HALF_DIGIT_MAX)
2235697Smcpowers /* MP_HALF_RADIX really ought to be called MP_SQRT_RADIX, but it's named
2245697Smcpowers ** MP_HALF_RADIX because it's the radix for MP_HALF_DIGITs, and it's
2255697Smcpowers ** consistent with the other _HALF_ names.
2265697Smcpowers */
2275697Smcpowers 
2285697Smcpowers 
2295697Smcpowers /* Macros for accessing the mp_int internals           */
2305697Smcpowers #define  MP_FLAG(MP)     ((MP)->flag)
2315697Smcpowers #define  MP_SIGN(MP)     ((MP)->sign)
2325697Smcpowers #define  MP_USED(MP)     ((MP)->used)
2335697Smcpowers #define  MP_ALLOC(MP)    ((MP)->alloc)
2345697Smcpowers #define  MP_DIGITS(MP)   ((MP)->dp)
2355697Smcpowers #define  MP_DIGIT(MP,N)  (MP)->dp[(N)]
2365697Smcpowers 
2375697Smcpowers /* This defines the maximum I/O base (minimum is 2)   */
2385697Smcpowers #define MP_MAX_RADIX         64
2395697Smcpowers 
2405697Smcpowers typedef struct {
241*13066SDina.Nimeh@Sun.COM   mp_flag       flag;    /* KM_SLEEP/KM_NOSLEEP        */
2425697Smcpowers   mp_sign       sign;    /* sign of this quantity      */
2435697Smcpowers   mp_size       alloc;   /* how many digits allocated  */
2445697Smcpowers   mp_size       used;    /* how many digits used       */
2455697Smcpowers   mp_digit     *dp;      /* the digits themselves      */
2465697Smcpowers } mp_int;
2475697Smcpowers 
2485697Smcpowers /* Default precision       */
2495697Smcpowers mp_size mp_get_prec(void);
2505697Smcpowers void    mp_set_prec(mp_size prec);
2515697Smcpowers 
2525697Smcpowers /* Memory management       */
2535697Smcpowers mp_err mp_init(mp_int *mp, int kmflag);
2545697Smcpowers mp_err mp_init_size(mp_int *mp, mp_size prec, int kmflag);
2555697Smcpowers mp_err mp_init_copy(mp_int *mp, const mp_int *from);
2565697Smcpowers mp_err mp_copy(const mp_int *from, mp_int *to);
2575697Smcpowers void   mp_exch(mp_int *mp1, mp_int *mp2);
2585697Smcpowers void   mp_clear(mp_int *mp);
2595697Smcpowers void   mp_zero(mp_int *mp);
2605697Smcpowers void   mp_set(mp_int *mp, mp_digit d);
2615697Smcpowers mp_err mp_set_int(mp_int *mp, long z);
2625697Smcpowers #define mp_set_long(mp,z) mp_set_int(mp,z)
2635697Smcpowers mp_err mp_set_ulong(mp_int *mp, unsigned long z);
2645697Smcpowers 
2655697Smcpowers /* Single digit arithmetic */
2665697Smcpowers mp_err mp_add_d(const mp_int *a, mp_digit d, mp_int *b);
2675697Smcpowers mp_err mp_sub_d(const mp_int *a, mp_digit d, mp_int *b);
2685697Smcpowers mp_err mp_mul_d(const mp_int *a, mp_digit d, mp_int *b);
2695697Smcpowers mp_err mp_mul_2(const mp_int *a, mp_int *c);
2705697Smcpowers mp_err mp_div_d(const mp_int *a, mp_digit d, mp_int *q, mp_digit *r);
2715697Smcpowers mp_err mp_div_2(const mp_int *a, mp_int *c);
2725697Smcpowers mp_err mp_expt_d(const mp_int *a, mp_digit d, mp_int *c);
2735697Smcpowers 
2745697Smcpowers /* Sign manipulations      */
2755697Smcpowers mp_err mp_abs(const mp_int *a, mp_int *b);
2765697Smcpowers mp_err mp_neg(const mp_int *a, mp_int *b);
2775697Smcpowers 
2785697Smcpowers /* Full arithmetic         */
2795697Smcpowers mp_err mp_add(const mp_int *a, const mp_int *b, mp_int *c);
2805697Smcpowers mp_err mp_sub(const mp_int *a, const mp_int *b, mp_int *c);
2815697Smcpowers mp_err mp_mul(const mp_int *a, const mp_int *b, mp_int *c);
2825697Smcpowers #if MP_SQUARE
2835697Smcpowers mp_err mp_sqr(const mp_int *a, mp_int *b);
2845697Smcpowers #else
2855697Smcpowers #define mp_sqr(a, b) mp_mul(a, a, b)
2865697Smcpowers #endif
2875697Smcpowers mp_err mp_div(const mp_int *a, const mp_int *b, mp_int *q, mp_int *r);
2885697Smcpowers mp_err mp_div_2d(const mp_int *a, mp_digit d, mp_int *q, mp_int *r);
2895697Smcpowers mp_err mp_expt(mp_int *a, mp_int *b, mp_int *c);
2905697Smcpowers mp_err mp_2expt(mp_int *a, mp_digit k);
2915697Smcpowers mp_err mp_sqrt(const mp_int *a, mp_int *b);
2925697Smcpowers 
2935697Smcpowers /* Modular arithmetic      */
2945697Smcpowers #if MP_MODARITH
2955697Smcpowers mp_err mp_mod(const mp_int *a, const mp_int *m, mp_int *c);
2965697Smcpowers mp_err mp_mod_d(const mp_int *a, mp_digit d, mp_digit *c);
2975697Smcpowers mp_err mp_addmod(const mp_int *a, const mp_int *b, const mp_int *m, mp_int *c);
2985697Smcpowers mp_err mp_submod(const mp_int *a, const mp_int *b, const mp_int *m, mp_int *c);
2995697Smcpowers mp_err mp_mulmod(const mp_int *a, const mp_int *b, const mp_int *m, mp_int *c);
3005697Smcpowers #if MP_SQUARE
3015697Smcpowers mp_err mp_sqrmod(const mp_int *a, const mp_int *m, mp_int *c);
3025697Smcpowers #else
3035697Smcpowers #define mp_sqrmod(a, m, c) mp_mulmod(a, a, m, c)
3045697Smcpowers #endif
3055697Smcpowers mp_err mp_exptmod(const mp_int *a, const mp_int *b, const mp_int *m, mp_int *c);
3065697Smcpowers mp_err mp_exptmod_d(const mp_int *a, mp_digit d, const mp_int *m, mp_int *c);
3075697Smcpowers #endif /* MP_MODARITH */
3085697Smcpowers 
3095697Smcpowers /* Comparisons             */
3105697Smcpowers int    mp_cmp_z(const mp_int *a);
3115697Smcpowers int    mp_cmp_d(const mp_int *a, mp_digit d);
3125697Smcpowers int    mp_cmp(const mp_int *a, const mp_int *b);
3135697Smcpowers int    mp_cmp_mag(mp_int *a, mp_int *b);
3145697Smcpowers int    mp_cmp_int(const mp_int *a, long z, int kmflag);
3155697Smcpowers int    mp_isodd(const mp_int *a);
3165697Smcpowers int    mp_iseven(const mp_int *a);
3175697Smcpowers 
3185697Smcpowers /* Number theoretic        */
3195697Smcpowers #if MP_NUMTH
3205697Smcpowers mp_err mp_gcd(mp_int *a, mp_int *b, mp_int *c);
3215697Smcpowers mp_err mp_lcm(mp_int *a, mp_int *b, mp_int *c);
3225697Smcpowers mp_err mp_xgcd(const mp_int *a, const mp_int *b, mp_int *g, mp_int *x, mp_int *y);
3235697Smcpowers mp_err mp_invmod(const mp_int *a, const mp_int *m, mp_int *c);
3245697Smcpowers mp_err mp_invmod_xgcd(const mp_int *a, const mp_int *m, mp_int *c);
3255697Smcpowers #endif /* end MP_NUMTH */
3265697Smcpowers 
3275697Smcpowers /* Input and output        */
3285697Smcpowers #if MP_IOFUNC
3295697Smcpowers void   mp_print(mp_int *mp, FILE *ofp);
3305697Smcpowers #endif /* end MP_IOFUNC */
3315697Smcpowers 
3325697Smcpowers /* Base conversion         */
3335697Smcpowers mp_err mp_read_raw(mp_int *mp, char *str, int len);
3345697Smcpowers int    mp_raw_size(mp_int *mp);
3355697Smcpowers mp_err mp_toraw(mp_int *mp, char *str);
3365697Smcpowers mp_err mp_read_radix(mp_int *mp, const char *str, int radix);
3375697Smcpowers mp_err mp_read_variable_radix(mp_int *a, const char * str, int default_radix);
3385697Smcpowers int    mp_radix_size(mp_int *mp, int radix);
3395697Smcpowers mp_err mp_toradix(mp_int *mp, char *str, int radix);
3405697Smcpowers int    mp_tovalue(char ch, int r);
3415697Smcpowers 
3425697Smcpowers #define mp_tobinary(M, S)  mp_toradix((M), (S), 2)
3435697Smcpowers #define mp_tooctal(M, S)   mp_toradix((M), (S), 8)
3445697Smcpowers #define mp_todecimal(M, S) mp_toradix((M), (S), 10)
3455697Smcpowers #define mp_tohex(M, S)     mp_toradix((M), (S), 16)
3465697Smcpowers 
3475697Smcpowers /* Error strings           */
3485697Smcpowers const  char  *mp_strerror(mp_err ec);
3495697Smcpowers 
3505697Smcpowers /* Octet string conversion functions */
3515697Smcpowers mp_err mp_read_unsigned_octets(mp_int *mp, const unsigned char *str, mp_size len);
3525697Smcpowers int    mp_unsigned_octet_size(const mp_int *mp);
3535697Smcpowers mp_err mp_to_unsigned_octets(const mp_int *mp, unsigned char *str, mp_size maxlen);
3545697Smcpowers mp_err mp_to_signed_octets(const mp_int *mp, unsigned char *str, mp_size maxlen);
3555697Smcpowers mp_err mp_to_fixlen_octets(const mp_int *mp, unsigned char *str, mp_size len);
3565697Smcpowers 
3575697Smcpowers /* Miscellaneous */
3585697Smcpowers mp_size mp_trailing_zeros(const mp_int *mp);
3595697Smcpowers 
3605697Smcpowers #define MP_CHECKOK(x)  if (MP_OKAY > (res = (x))) goto CLEANUP
3615697Smcpowers #define MP_CHECKERR(x) if (MP_OKAY > (res = (x))) goto CLEANUP
3625697Smcpowers 
3635697Smcpowers #if defined(MP_API_COMPATIBLE)
3645697Smcpowers #define NEG             MP_NEG
3655697Smcpowers #define ZPOS            MP_ZPOS
3665697Smcpowers #define DIGIT_MAX       MP_DIGIT_MAX
3675697Smcpowers #define DIGIT_BIT       MP_DIGIT_BIT
3685697Smcpowers #define DIGIT_FMT       MP_DIGIT_FMT
3695697Smcpowers #define RADIX           MP_RADIX
3705697Smcpowers #define MAX_RADIX       MP_MAX_RADIX
3715697Smcpowers #define FLAG(MP)        MP_FLAG(MP)
3725697Smcpowers #define SIGN(MP)        MP_SIGN(MP)
3735697Smcpowers #define USED(MP)        MP_USED(MP)
3745697Smcpowers #define ALLOC(MP)       MP_ALLOC(MP)
3755697Smcpowers #define DIGITS(MP)      MP_DIGITS(MP)
3765697Smcpowers #define DIGIT(MP,N)     MP_DIGIT(MP,N)
3775697Smcpowers 
3785697Smcpowers #if MP_ARGCHK == 1
3795697Smcpowers #define  ARGCHK(X,Y)  {if(!(X)){return (Y);}}
3805697Smcpowers #elif MP_ARGCHK == 2
3815697Smcpowers #ifdef _KERNEL
3825697Smcpowers #define  ARGCHK(X,Y)  ASSERT(X)
3835697Smcpowers #else
3845697Smcpowers #include <assert.h>
3855697Smcpowers #define  ARGCHK(X,Y)  assert(X)
3865697Smcpowers #endif
3875697Smcpowers #else
3885697Smcpowers #define  ARGCHK(X,Y)  /*  */
3895697Smcpowers #endif
3905697Smcpowers #endif /* defined MP_API_COMPATIBLE */
3915697Smcpowers 
3925697Smcpowers #endif /* _MPI_H */
393*13066SDina.Nimeh@Sun.COM /* END CSTYLED */
394