/* $NetBSD: div.c,v 1.6 1998/01/30 23:37:52 perry Exp $ */ /* * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Chris Torek. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #if defined(LIBC_SCCS) && !defined(lint) #if 0 static char sccsid[] = "@(#)div.c 8.1 (Berkeley) 6/4/93"; #else __RCSID("$NetBSD: div.c,v 1.6 1998/01/30 23:37:52 perry Exp $"); #endif #endif /* LIBC_SCCS and not lint */ #include /* div_t */ div_t div(num, denom) int num, denom; { div_t r; r.quot = num / denom; r.rem = num % denom; /* * The ANSI standard says that |r.quot| <= |n/d|, where * n/d is to be computed in infinite precision. In other * words, we should always truncate the quotient towards * 0, never -infinity. * * Machine division and remainer may work either way when * one or both of n or d is negative. If only one is * negative and r.quot has been truncated towards -inf, * r.rem will have the same sign as denom and the opposite * sign of num; if both are negative and r.quot has been * truncated towards -inf, r.rem will be positive (will * have the opposite sign of num). These are considered * `wrong'. * * If both are num and denom are positive, r will always * be positive. * * This all boils down to: * if num >= 0, but r.rem < 0, we got the wrong answer. * In that case, to get the right answer, add 1 to r.quot and * subtract denom from r.rem. */ if (num >= 0 && r.rem < 0) { r.quot++; r.rem -= denom; } return (r); } /td>use __KERNEL_RCSID()lukem 2007-10-19machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.had 2007-08-28Make ath(4) work again on sparc64 (and other big-endian machines).nakayama 2007-08-24The Atheros HAL on MIPS uses %s7 as a general purpose register, but thead rest of the kernel uses it to store the value of curlwp. Sam won't recompile the HAL for us (fair enough), and we can't modify the HAL to use another register because doing so could put us in breach of the license (v. crappy). So, do a save/set/restore on %s7 in KernIntr() and in the stubs that the HAL uses to call back into the kernel. 2007-04-08Remove support for NetBSD/{,evb}sh5.scw 2007-01-14Use consistent option names (i.e., those that are defflag'd). Ok dyoung@.cube 2006-11-16__unused removal on arguments; approved by core.christos 2006-10-30depend on the cardbus version too.christos 2006-10-21Kill KAUTH_GENERIC_ISSUSER usage.elad 2006-10-12- sprinkle __unused on function decls.christos - fix a couple of unused bugs - no more -Wno-unused for i386 2006-08-17Fix all the -D*DEBUG* code that it was rotting away and did not even compile.christos Mostly from Arnaud Lacombe, many thanks! 2006-07-21- Use the LWP cached credentials where sane.ad - Minor cosmetic changes. 2006-07-04put depend back.christos 2006-07-04more typos.christos 2006-07-04another dependency.christos 2006-07-04typochristos 2006-07-04athrate_sample.o needs the generated header filechristos 2006-06-25add a missing dependency.christos 2006-06-07merge FreeBSD timecounters from branch simonb-timecounterskardel - struct timeval time is gone time.tv_sec -> time_second - struct timeval mono_time is gone mono_time.tv_sec -> time_uptime - access to time via {get,}{micro,nano,bin}time() get* versions are fast but less precise - support NTP nanokernel implementation (NTP API 4) - further reading: Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html 2006-06-07For cases where AH_REGOPS_FUNC is not defined, the bus tag is not defined.gdamore In these cases, passing NULL for it solves a problem on AMD64 where the bus tag is an integer rather than uintptr_t. (I.e. fix the cast warning on amd64.) 2006-06-07Add missing file (forgot to commit this) for AR531X systems.gdamore 2006-06-05Import new HAL 0.9.17.2. Approved by sam@gdamore New HAL includes some driver changes to register accesses. Adds support for WLAN devices on AR5312 family devices. Adds support 32-bit SPARC ath devices (untested). ath enabled in SPARC64 GENERIC builds. This HAL is tested and known to work for i386 PCI devices, SPARC64 PCI devices, and AR5312 WiSoC devices. MIPS PCI devices appear to be busted (possibly only on Alchemy hardware, unconfirmed), and cardbus support is untested due to lack of test hardware. Please report any new problems with this import to garrett@. 2006-05-14integrate kauth.elad 2006-04-06Undo an accidental commit of ah.h from an unreleased version of the HAL.gdamore 2006-04-05Use a -I to add path to netbsd/ah_osdep, and remove #ifdef __NetBSD__gdamore logic from ah.h. This was done at the request of sam@. 2006-04-05Move "depend" target into block which is only used if ath(4) is enabledtron in the kernel configuration. This makes it possible to build kernels without that driver again. 2006-04-05Rename AH_DEBUG, AH_ASSERT, and AH_DEBUG_ALQ to ATH_XXX.gdamore Use the opt_ah.h for the provided HAL to get options like AH_REGOPS_FUNC. Add AH_REGOPS_FUNC to a few opt_ah.h that don't have it in this version of the HAL but need it. (The next version from Sam should have this fixed in it. If it doesn't, then we'll have to take care at import time.) Ultimately, this should make future imports even easier, and individual ports should not have to worry about whether AH_REGOPS_FUNC is properly defined or not, since the opt_ah.h will just take care of it automatically. Ok'd by dyoung@. 2006-04-05Add rule to make athhal_options.h from ${ATH_HAL}.opt_ah.h, so that wegdamore can automatically use the AH_XXX options that the HAL was built, without requiring additional machine-specific configuration. A follow up commit will activate this change. 2006-04-04Add missing "-elf" suffix to ATH_HAL for sparc and sparc64.nakayama 2006-04-04Convert existing ath users to new Makefile, except for amd64, which needsgdamore the rules due to needing to conditionally postprocess the HAL object file. Macppc needs a a non-ELF HAL (EABI) object, so take care of that by default in the atheros include file. 2006-04-04Centralize rules for building atheros HAL for various supported platforms,gdamore including easy override mechanism for ports that need it. To use this, just .include this file instead of listing explicit rules for building the target. A change to std/conf/files will be made shortly that lists /athhal.o as an object if "ath" is defined. If you need to override the default HAL selected for some reason (for example to use an xscale version of the HAL on evbarm kernels that support it), add a "makeoptions ATH_MACHINE_HAL=<hal>", for example to select the XScale LE configuration you could use "makeoptions ATH_MACHINE_HAL=xscale-le-elf". 2006-04-02Reorganize ath layout as requested by sam@ and suggested by dyoung@ ingdamore http://mail-index.netbsd.org/tech-net/2006/03/15/0000.html. The new layout almost precisely matches FreeBSD, and should make future imports much easier. At the same time, import the current 0.9.16.16 HAL from FreeBSD. According to sam@, this is the proper version we should be using. 2006-03-08Use the SI capitalization for "Hz", "kHz", and "MHz" in comments and strings.lukem Add a space between numbers and Hz unit. 2006-03-02Miscellaneous ath(4) and net80211 updates and bug-fixes coming fromdyoung sam@ and various open source repositories: ath(4): Ignore "phantom" beacon misses: should stabilize connections to access points (no more ceaseless link-UP/DOWN indications). Also, re-synchronize beacon timer using the TSF in the first beacon received after joining a BSS---this should also help suppress spurious beacon misses. I am hopeful that this will help ath(4) lossage reported by perry@ and smb@. Add new configuration through sysctl. Use a shorter calibration interval until IQ calibration finishes. Report antenna noise through radiotap. Rudiments of Radar Detection / Dynamic Frequency Selection. Update to HAL version 0.9.16.13. Update open sources for changes to the HAL API. Add HALs for additional architectures: add big-endian ELF HALs for sparc64 and for PowerPC. Also add a Alpha HAL. These new HALs are untested under NetBSD. ath(4) + net80211: Make the multicast transmit rate configurable by ioctl. Miscellaneous bug fixes. 2005-12-11merge ktrace-lwp.christos 2005-10-19For clarify, use the name opt_athhal.h instead of opt_ah.h for thedyoung file where Atheros HAL options go. 2005-09-13The entity passed to the HAL as a HAL_BUS_HANDLE needs to be an integralmartin or pointer type. So on sparc64 (and maybe others too?) where bus_space_handle_t is a struct, pass the address of the bus_space_handle_t and adjust the register access functions accordingly. While there, slightly optimize the bus_space_* usage in the register access functions and macros. 2005-07-04Our bus_space_{read,write}_4 routines convert from host to busdyoung byte-order, but FreeBSD's does not. ath(4) expects the FreeBSD convention. Meet ath(4)'s expectations, use bus_space_{read,write}_stream_4, instead. Now, the HAL seems to work on macppc. 2005-06-22Resolve conflicts in importation of 18-May-2005 ath(4) / net80211(9)dyoung from FreeBSD. Introduce compatibility shims (sys/dev/ic/ath_netbsd.[ch], sys/net80211/ieee80211_netbsd.[ch]). Update drivers (an, atu, atw, awi, ipw, iwi, rtw, wi) for the new net80211(9) API. 2005-06-21Import FreeBSD's ath(4) of 2005-05-18dyoung