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*6515Sraf * Common Development and Distribution License (the "License"). 6*6515Sraf * 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*6515Sraf 22*6515Sraf /* 23*6515Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*6515Sraf * Use is subject to license terms. 25*6515Sraf */ 26*6515Sraf 270Sstevel@tonic-gate /* 280Sstevel@tonic-gate * Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. 290Sstevel@tonic-gate * Copyright (c) 1988 AT&T 300Sstevel@tonic-gate * All Rights Reserved 310Sstevel@tonic-gate */ 320Sstevel@tonic-gate 330Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * Establish the default settings for the floating-point state for a C language 370Sstevel@tonic-gate * program: 380Sstevel@tonic-gate * rounding mode -- round to nearest default by OS, 390Sstevel@tonic-gate * exceptions enabled -- all masked 400Sstevel@tonic-gate * sticky bits -- all clear by default by OS. 410Sstevel@tonic-gate * precision control -- double extended 420Sstevel@tonic-gate */ 430Sstevel@tonic-gate 440Sstevel@tonic-gate #pragma weak _fpstart = __fpstart 450Sstevel@tonic-gate 460Sstevel@tonic-gate #include "synonyms.h" 470Sstevel@tonic-gate #include <sys/types.h> 480Sstevel@tonic-gate #include <sys/sysi86.h> /* for SI86FPHW/SI86FPSTART definitions */ 490Sstevel@tonic-gate #include <sys/fp.h> /* for FPU_CW_INIT and SSE_MXCSR_INIT */ 500Sstevel@tonic-gate 510Sstevel@tonic-gate int __flt_rounds; /* ANSI rounding mode */ 520Sstevel@tonic-gate 530Sstevel@tonic-gate void 540Sstevel@tonic-gate __fpstart() 550Sstevel@tonic-gate { 560Sstevel@tonic-gate int _fp_hw; /* default: bss: 0 == no hardware */ 570Sstevel@tonic-gate 580Sstevel@tonic-gate /* 590Sstevel@tonic-gate * query OS for HW status and ensure the x87 and (optional) 600Sstevel@tonic-gate * SSE control words are (will be) set correctly. 610Sstevel@tonic-gate * This "cannot fail". 620Sstevel@tonic-gate */ 63*6515Sraf (void) sysi86(SI86FPSTART, 640Sstevel@tonic-gate &_fp_hw, FPU_CW_INIT, SSE_MXCSR_INIT); 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * At this point the x87 fp environment that has been (or more 680Sstevel@tonic-gate * hopefully, will be) established by the kernel is: 690Sstevel@tonic-gate * 700Sstevel@tonic-gate * affine infinity 0x1000 710Sstevel@tonic-gate * round to nearest 0x0000 720Sstevel@tonic-gate * 64-bit doubles 0x0300 730Sstevel@tonic-gate * precision, underflow, overflow, zero-divide, denorm, invalid masked 740Sstevel@tonic-gate * 0x003f 750Sstevel@tonic-gate * 760Sstevel@tonic-gate * which conforms to the 4th edition i386 ABI definition. 770Sstevel@tonic-gate * 780Sstevel@tonic-gate * Additionally, if we have SSE hardware, we've also masked all 790Sstevel@tonic-gate * the same traps, and have round to nearest. 800Sstevel@tonic-gate */ 810Sstevel@tonic-gate 820Sstevel@tonic-gate __flt_rounds = 1; /* ANSI way of saying round-to-nearest */ 830Sstevel@tonic-gate } 84