10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*6812Sraf * Common Development and Distribution License (the "License").
6*6812Sraf * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
21*6812Sraf
220Sstevel@tonic-gate /*
23*6812Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
240Sstevel@tonic-gate * Use is subject to license terms.
250Sstevel@tonic-gate */
260Sstevel@tonic-gate
270Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
280Sstevel@tonic-gate /* All Rights Reserved */
290Sstevel@tonic-gate
30*6812Sraf #pragma ident "%Z%%M% %I% %E% SMI"
310Sstevel@tonic-gate
320Sstevel@tonic-gate /*
330Sstevel@tonic-gate * This set of routines used to be implemented mostly in assembler.
340Sstevel@tonic-gate *
350Sstevel@tonic-gate * Since the purpose they have is now rather vestigial, and 64-bit
360Sstevel@tonic-gate * machines can do operations on 64-bit quantities pretty efficiently,
370Sstevel@tonic-gate * a C implementation seems quite adequate and much more maintainable.
380Sstevel@tonic-gate */
390Sstevel@tonic-gate
40*6812Sraf #include "lint.h"
410Sstevel@tonic-gate #include <sys/types.h>
420Sstevel@tonic-gate #include <sys/dl.h>
430Sstevel@tonic-gate
440Sstevel@tonic-gate typedef union {
450Sstevel@tonic-gate long xword;
460Sstevel@tonic-gate dl_t dl;
470Sstevel@tonic-gate } dlx_t;
480Sstevel@tonic-gate
490Sstevel@tonic-gate dl_t
ladd(dl_t lop,dl_t rop)500Sstevel@tonic-gate ladd(dl_t lop, dl_t rop)
510Sstevel@tonic-gate {
520Sstevel@tonic-gate dlx_t r;
530Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */
540Sstevel@tonic-gate r.xword = *(long *)&lop + *(long *)&rop;
550Sstevel@tonic-gate return (r.dl);
560Sstevel@tonic-gate }
570Sstevel@tonic-gate
580Sstevel@tonic-gate dl_t
lshiftl(dl_t op,int cnt)590Sstevel@tonic-gate lshiftl(dl_t op, int cnt)
600Sstevel@tonic-gate {
610Sstevel@tonic-gate dlx_t r;
620Sstevel@tonic-gate if (cnt < 0)
630Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */
640Sstevel@tonic-gate r.xword = (long)(*(ulong_t *)&op >> (-cnt));
650Sstevel@tonic-gate else
660Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */
670Sstevel@tonic-gate r.xword = *(long *)&op << cnt;
680Sstevel@tonic-gate return (r.dl);
690Sstevel@tonic-gate }
700Sstevel@tonic-gate
710Sstevel@tonic-gate int
lsign(dl_t op)720Sstevel@tonic-gate lsign(dl_t op)
730Sstevel@tonic-gate {
740Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */
750Sstevel@tonic-gate return ((*(long *)&op) >> 63);
760Sstevel@tonic-gate }
770Sstevel@tonic-gate
780Sstevel@tonic-gate dl_t
lsub(dl_t lop,dl_t rop)790Sstevel@tonic-gate lsub(dl_t lop, dl_t rop)
800Sstevel@tonic-gate {
810Sstevel@tonic-gate dlx_t r;
820Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */
830Sstevel@tonic-gate r.xword = *(long *)&lop - *(long *)&rop;
840Sstevel@tonic-gate return (r.dl);
850Sstevel@tonic-gate }
860Sstevel@tonic-gate
870Sstevel@tonic-gate dl_t
lmul(dl_t lop,dl_t rop)880Sstevel@tonic-gate lmul(dl_t lop, dl_t rop)
890Sstevel@tonic-gate {
900Sstevel@tonic-gate dlx_t r;
910Sstevel@tonic-gate /* LINTED pointer cast may result in improper alignment */
920Sstevel@tonic-gate r.xword = *(long *)&lop * *(long *)&rop;
930Sstevel@tonic-gate return (r.dl);
940Sstevel@tonic-gate }
95