llog10.c revision 2
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc/*
3caf11144eab1a56717f986d44ae7f40ee8b28fcxc * CDDL HEADER START
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc *
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * The contents of this file are subject to the terms of the
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * Common Development and Distribution License (the "License").
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * You may not use this file except in compliance with the License.
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc *
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * or http://www.opensolaris.org/os/licensing.
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * See the License for the specific language governing permissions
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * and limitations under the License.
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc *
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * When distributing Covered Code, include this CDDL HEADER in each
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * If applicable, add the following below this CDDL HEADER, with the
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * fields enclosed by brackets "[]" replaced with your own identifying
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * information: Portions Copyright [yyyy] [name of copyright owner]
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc *
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * CDDL HEADER END
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc */
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc/*
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc * Use is subject to license terms.
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc */
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc/* Copyright (c) 1988 AT&T */
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc/* All Rights Reserved */
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc#pragma ident "%Z%%M% %I% %E% SMI"
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc#include "lint.h"
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc#include <sys/types.h>
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc#include <sys/dl.h>
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc
7a1306a70fee0e017a445bde1dcfd1997f691cf4xcdl_t
7a1306a70fee0e017a445bde1dcfd1997f691cf4xcllog10(dl_t val)
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc{
bcb5c89da22515e2ccf139578bad3caebcd716adSowmini Varadhan dl_t result;
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc result = lzero;
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc val = ldivide(val, lten);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc while (val.dl_hop != 0 || val.dl_lop != 0) {
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc val = ldivide(val, lten);
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc result = ladd(result, lone);
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc }
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc
7a1306a70fee0e017a445bde1dcfd1997f691cf4xc return (result);
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc}
0ba2cbe97e0678a691742f98d2532caed0a2c4aaxc