xref: /titanic_51/usr/src/common/bignum/amd64/bignum_amd64.c (revision 8475e04352e630e4bd0f59a283286ee2475a14ce)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*8475e043SDan OpenSolaris Anderson  * Common Development and Distribution License (the "License").
6*8475e043SDan OpenSolaris Anderson  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*8475e043SDan OpenSolaris Anderson  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
277c478bd9Sstevel@tonic-gate  * This file contains bignum implementation code that
287c478bd9Sstevel@tonic-gate  * is specific to AMD64, but which is still more appropriate
297c478bd9Sstevel@tonic-gate  * to write in C, rather than assembly language.
307c478bd9Sstevel@tonic-gate  * bignum_amd64_asm.s does all the assembly language code
317c478bd9Sstevel@tonic-gate  * for AMD64 specific bignum support.  The assembly language
327c478bd9Sstevel@tonic-gate  * source file has pure code, no data.  Let the C compiler
337c478bd9Sstevel@tonic-gate  * generate what is needed to handle the variations in
347c478bd9Sstevel@tonic-gate  * data representation and addressing, for example,
357c478bd9Sstevel@tonic-gate  * statically linked vs PIC.
367c478bd9Sstevel@tonic-gate  */
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #include "bignum.h"
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
41*8475e043SDan OpenSolaris Anderson  * The bignum interface deals with arrays of 64-bit "chunks" or "digits".
42*8475e043SDan OpenSolaris Anderson  * Data should be aligned on 8-byte address boundaries for best performance.
437c478bd9Sstevel@tonic-gate  */
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate void
47*8475e043SDan OpenSolaris Anderson big_mul_vec(BIG_CHUNK_TYPE *r, BIG_CHUNK_TYPE *a, int alen,
48*8475e043SDan OpenSolaris Anderson     BIG_CHUNK_TYPE *b, int blen)
497c478bd9Sstevel@tonic-gate {
507c478bd9Sstevel@tonic-gate 	int	i;
517c478bd9Sstevel@tonic-gate 
52*8475e043SDan OpenSolaris Anderson 	r[alen] = big_mul_set_vec(r, a, alen, b[0]);
537c478bd9Sstevel@tonic-gate 	for (i = 1; i < blen; ++i)
54*8475e043SDan OpenSolaris Anderson 		r[alen + i] = big_mul_add_vec(r + i, a, alen, b[i]);
557c478bd9Sstevel@tonic-gate }
56