Commit Graph

137 Commits

Author SHA1 Message Date
David Schultz
f154b03b25 Update my email address. 2005-02-06 03:23:31 +00:00
David Schultz
00646ca204 Replace the ldexp() implementation in libc with a renamed copy of the
scalbn() implementation from libm.  (The two functions are defined to
be identical, but ldexp() lives in libc for backwards compatibility.)
The old ldexp() implementation...
  - was more complicated than this one
  - set errno instead of raising FP exceptions
  - got some corner cases wrong
    (e.g. ldexp(1.0, 2000) in round-to-zero mode)

The new implementation lives in libc/gen instead of
libc/$MACHINE_ARCH/gen, since we don't need N copies of a
machine-independent file.  The amd64 and i386 platforms
retain their fast and correct MD implementations and
override this one.
2005-01-22 06:03:40 +00:00
David Schultz
929ab920ae Correct the values of FLT_ROUNDS for the FE_UPWARD and FE_DOWNWARD cases. 2005-01-18 15:29:28 +00:00
David Schultz
bd15659f64 Eliminate gdtoa.mk and move its contents to ${MACHINE_ARCH}/Makefile.inc.
The purpose of having a separate file involved an abandoned scheme that
would have kept contrib/gdtoa out of the include path for the rest of libc.
2005-01-15 05:23:58 +00:00
Ruslan Ermilov
a35d88931c For variables that are only checked with defined(), don't provide
any fake value.
2004-10-24 15:33:08 +00:00
Doug Rabson
ccd13c49b5 Add support for TLS in statically linked programs. 2004-08-15 16:18:52 +00:00
Alexander Kabaev
698784bef7 s/round/fpround/ to avoid naming clash with GCC builtin function. 2004-07-28 05:41:05 +00:00
David Schultz
39bcea8689 Replace seven nominally MD implementations of frexp() that are broken
for subnormals with one implementation that works.
2004-07-18 21:23:39 +00:00
David Schultz
240dbabfa8 Implement the classification macros isfinite(), isinf(), isnan(), and
isnormal() the hard way, rather than relying on fpclassify().  This is
a lose in the sense that we need a total of 12 functions, but it is
necessary for binary compatibility because we have never bumped libm's
major version number.  In particular, isinf(), isnan(), and isnanf()
were BSD libc functions before they were C99 macros, so we can't
reimplement them in terms of fpclassify() without adding a dependency
on libc.so.5.  I have tried to arrange things so that programs that
could be compiled in FreeBSD 4.X will generate the same external
references when compiled in 5.X.  At the same time, the new macros
should remain C99-compliant.

The isinf() and isnan() functions remain in libc for historical
reasons; however, I have moved the functions that implement the macros
isfinite() and isnormal() to libm where they belong.  Moreover,
half a dozen MD versions of isinf() and isnan() have been replaced
with MI versions that work equally well.

Prodded by:	kris
2004-07-09 03:32:40 +00:00
Dag-Erling Smørgrav
261e614637 Use unions to avoid violating C99 strict aliasing rules. 2004-03-16 20:42:02 +00:00
David Schultz
36e22bed27 Fix some aliasing problems. 2004-02-16 10:02:40 +00:00
Colin Percival
1c81bd2c60 style cleanup: Remove duplicate $FreeBSD$ tags.
These files had tags after teh copyright notice,
inside the comment block (incorrect, removed),
and outside the comment block (correct).

Approved by:	rwatson (mentor)
2004-02-10 20:45:28 +00:00
Jacques Vidrine
07a6d1d3f2 Add prototypes for the three syscall stubs that are invoked here,
in order to quiet warnings.
2004-01-19 16:14:58 +00:00
David Schultz
a8cb7cca02 Define LDBL_MANH_SIZE and LDBL_MANL_SIZE to be the sizes of the
high and low words of the mantissa in bits, respectively.
2004-01-18 07:57:02 +00:00
Jacques Vidrine
3d7cd67f51 We need to discard `const'ness explicitly when invoking sysarch.
Reported by:	sparc64 tinderbox via bde
2004-01-10 15:57:06 +00:00
Jacques Vidrine
e4dc8baa84 Provide sysarch(2) prototypes in the MD sysarch.h headers. While I'm
at it, use the ANSI C generic pointer type for the second argument,
thus matching the documentation.

Remove the now extraneous (and now conflicting) function declarations
in various libc sources.  Remove now unnecessary casts.

Reviewed by:	bde
2004-01-09 16:52:09 +00:00
Jacques Vidrine
78ea1df143 Remove unused variables. Add required headers and function
declarations.
2004-01-06 18:53:26 +00:00
Jake Burkholder
eaf21f315e Install the user trap handlers that libc provides from a constructor, so
that they will be installed before application constructors are invoked.
Its possible to link applications such that this fails, application code
is invoked before they are installed, but, well, Don't Do That.

Approved by:	re (jhb)
2003-11-18 14:21:41 +00:00
Bruce M Simpson
abd498aa71 Add the mlockall() and munlockall() system calls.
- All those diffs to syscalls.master for each architecture *are*
   necessary. This needed clarification; the stub code generation for
   mlockall() was disabled, which would prevent applications from
   linking to this API (suggested by mux)
 - Giant has been quoshed. It is no longer held by the code, as
   the required locking has been pushed down within vm_map.c.
 - Callers must specify VM_MAP_WIRE_HOLESOK or VM_MAP_WIRE_NOHOLES
   to express their intention explicitly.
 - Inspected at the vmstat, top and vm pager sysctl stats level.
   Paging-in activity is occurring correctly, using a test harness.
 - The RES size for a process may appear to be greater than its SIZE.
   This is believed to be due to mappings of the same shared library
   page being wired twice. Further exploration is needed.
 - Believed to back out of allocations and locks correctly
   (tested with WITNESS, MUTEX_PROFILING, INVARIANTS and DIAGNOSTIC).

PR:             kern/43426, standards/54223
Reviewed by:    jake, alc
Approved by:    jake (mentor)
MFC after:	2 weeks
2003-08-11 07:14:08 +00:00
Jake Burkholder
b551cb80d4 Implement signalcontext. 2003-08-08 15:40:28 +00:00
David Schultz
b7412bf571 Add a comment describing why it's important for the values in this
file to be correct, and how to generate them automatically.

Caused much pain and suffering for:	peter
2003-05-08 13:50:44 +00:00
David Schultz
92b93b37c0 Add __ldtoa(), a wrapper around gdtoa() to make it look like dtoa().
In support of this, add some MD macros to assist in converting long
doubles to the format expected by gdtoa().

Reviewed by:	silence on standards@
2003-04-05 22:10:13 +00:00
Jake Burkholder
9f5a511863 Implement makecontext. 2003-04-01 23:28:50 +00:00
David Schultz
6a66acb565 Replace our ancient dtoa/strtod implementation with the gdtoa
package, a more recent, generalized set of routines.  Among the
changes:
- Declare strtof() and strtold() in stdlib.h.
- Add glue to libc to support these routines for all kinds
  of ``long double''.
- Update printf() to reflect the fact that dtoa works slightly
  differently now.

As soon as I see that nothing has blown up, I will kill
src/lib/libc/stdlib/strtod.c.  Soon printf() will be able
to use the new routines to output long doubles without loss
of precision, but numerous bugs in the existing code must
be addressed first.

Reviewed by:	bde (briefly), mike (mentor), obrien
2003-03-12 20:30:00 +00:00
Mike Barcroft
5d62092f94 o Implement C99 classification macros isfinite(), isinf(), isnan(),
isnormal().  The current isinf() and isnan() are perserved for
  binary compatibility with 5.0, but new programs will use the macros.
o Implement C99 comparison macros isgreater(), isgreaterequal(),
  isless(), islessequal(), islessgreater(), isunordered().

Submitted by:	David Schultz <dschultz@uclink.Berkeley.EDU>
2003-02-12 20:03:41 +00:00
Mike Barcroft
8cf5ed5125 Implement fpclassify():
o Add a MD header private to libc called _fpmath.h; this header
  contains bitfield layouts of MD floating-point types.
o Add a MI header private to libc called fpmath.h; this header
  contains bitfield layouts of MI floating-point types.
o Add private libc variables to lib/libc/$arch/gen/infinity.c for
  storing NaN values.
o Add __double_t and __float_t to <machine/_types.h>, and provide
  double_t and float_t typedefs in <math.h>.
o Add some C99 manifest constants (FP_ILOGB0, FP_ILOGBNAN, HUGE_VALF,
  HUGE_VALL, INFINITY, NAN, and return values for fpclassify()) to
  <math.h> and others (FLT_EVAL_METHOD, DECIMAL_DIG) to <float.h> via
  <machine/float.h>.
o Add C99 macro fpclassify() which calls __fpclassify{d,f,l}() based
  on the size of its argument.  __fpclassifyl() is never called on
  alpha because (sizeof(long double) == sizeof(double)), which is good
  since __fpclassifyl() can't deal with such a small `long double'.

This was developed by David Schultz and myself with input from bde and
fenner.

PR:		23103
Submitted by:	David Schultz <dschultz@uclink.Berkeley.EDU>
		(significant portions)
Reviewed by:	bde, fenner (earlier versions)
2003-02-08 20:37:55 +00:00
Thomas Moestl
e506034ec1 Rewrite longjmp() and _longjmp() to directly restore the saved frame,
instead of unwinding the call stack. This makes them usable to switch
stacks, e.g. for libc_r.
Do not save the frame pointer in setjmp() and _setjmp(), it is not needed
any more.
Rename _longjmp() to ___longjmp(), with a weak alias to _longjmp(), like
the other architectures did.
2003-01-05 22:17:32 +00:00
Thomas Moestl
6c83076634 Rename siglongjmp() to __siglongjmp(), with a weak alias to siglongjmp(),
like the other architectures do.
2003-01-05 22:10:06 +00:00
Ruslan Ermilov
c51d717f0c libc_r wasn't so tied to libc for 22 months. 2002-11-18 09:50:57 +00:00
Archie Cobbs
83999f5a32 Re-apply the previously backed-out commit that fixes the problem where
HUGE_VAL is not properly aligned on some architectures. The previous
fix now works because the two versions of 'math.h' (include/math.h
and lib/msun/src/math.h) have since been merged into one.

PR:	bin/43544
2002-10-31 23:05:20 +00:00
Jake Burkholder
2ecf9f7162 Rename the libc signal trampoline to __sigtramp to match netbsd. This
should allow gdb to detect when we're executing in a signal trampoline.
2002-10-22 15:15:39 +00:00
Archie Cobbs
ae8a4b2f36 Revert previous commit to unbreak world until we figure out the
right way to do it.
2002-09-20 15:43:26 +00:00
Archie Cobbs
f5f1272284 Fix a problem with the definition of HUGE_VAL causing the gcc warning
"cast increases required alignment of target type" on some platforms.

Reviewed by:	bde
2002-09-19 19:47:27 +00:00
Thomas Moestl
6c788325fa Use the macros from machine/fsr.h; some minor cleanups. 2002-09-14 18:07:03 +00:00
Thomas Moestl
8579151e4b Add implementations of fpgetmask(), fpgetround(), fpgetsticky(),
fpsetround(), fpsetsticky(), obtained from NetBSD and tweaked a little
to use definitions from machine/fsr.h instead of magic numbers.
2002-09-14 18:06:21 +00:00
Thomas Moestl
f085ae60c0 Add an implementation of fabs() (which is quite trivial).
When it is called directly, gcc is smart enough to generate inline
code for it, which is why it wasn't noticed before that it was missing.

fabs() would probably better fit into libm, but it has traditionally been
in libc on FreeBSD, so there is probably software around that makes
assumptions about this by now.
2002-09-13 16:01:26 +00:00
Jake Burkholder
89172e2e25 Install the userland signal trampoline when sigaction is first called,
instead of on startup.  This fixes binary compatibility of dynamically
linked binaries from before the signal code move.

Suggested by:	wollman (a long time ago)
2002-09-03 14:55:29 +00:00
Jake Burkholder
ae162f3f31 Use FOO(a) for macros with variadic args, instead of FOO(a,) or FOO(a, ).
Submitted by:	gcc3.2
2002-09-02 02:30:20 +00:00
Thomas Moestl
58d646cdd3 Add missing ret instruction to the ptrace() syscall wrapper. 2002-07-11 15:48:02 +00:00
David E. O'Brien
3b7de54d68 Use FBSDID 2002-06-30 05:36:49 +00:00
David E. O'Brien
2d39517f33 Use __FBSDID. 2002-06-29 03:23:51 +00:00
David E. O'Brien
45d767fbbe Add frexp(3).
Obtained from:	OpenBSD
2002-06-29 03:23:18 +00:00
Jake Burkholder
dbf51f8db4 Remove unneeded include of machine/emul.h. 2002-06-18 02:15:11 +00:00
Jake Burkholder
3671cacae1 Implement _Qp_sqrt. I've been unable to find a C program that gcc generates
a call to this for, but apparently somehing in libstdc++ does.
2002-06-04 17:02:27 +00:00
Jake Burkholder
530622075e Generate the normal asm stubs for all sysv system calls. Use these instead
of C wrappers for the *sys indirect system calls.  The indirect system calls
are horribly broken on sparc64.

Submitted by:	tmm
2002-05-23 23:51:57 +00:00
Jake Burkholder
5893472b2d Use the right byte order for unaligned stores. <blush>. 2002-05-13 22:48:01 +00:00
Jake Burkholder
30eeff14ef Handle alignment fault fixups in libc rather than in the kernel. 2002-05-13 04:35:08 +00:00
Jake Burkholder
025c284b8d Add a support macro to convert the 5-bit packed register field of
a floating point instruction into a 6-bit register number for
double and quad arguments.
Make use of the new INSFPdq_RN macro where apporpriate; this
is required for correctly handling the "high" fp registers
(>= %f32).
Fix a number of bugs related to the handling of the high registers
which were caused by using __fpu_[gs]etreg() where __fpu_[gs]etreg64()
should be used (the former can only access the low, single-precision,
registers).

Submitted by:	tmm
2002-05-11 21:20:05 +00:00
David E. O'Brien
1f92f7e5d3 Use __FBSDID 2002-05-06 23:24:39 +00:00
David E. O'Brien
fd97c6aea9 We typically don't add trailing /'s. 2002-05-06 23:24:16 +00:00
Jake Burkholder
621136996a Add an alternate signal trampoline to libc; add a wrapper for the sigtramp
install sysarch, to be called from _start.

This will allow the stack to be mapped non-executable, as required by the
sparc v9 abi.
2002-04-29 18:14:44 +00:00
Jake Burkholder
05f2fa5cee Add code to emulate arithmetic, comparison and conversion operations
on long double, which are not implemented in hardware on any UltraSPARC
chip that I know of.  This just calls into the existing floating point
emulator, which is still needed to emulate other floating point operations
in certain conditions.  Without this gcc has to generate the quad floating
point instructions directly, which sometimes causes internal compiler
errors.

Reviewed by:	tmm
2002-04-28 02:36:36 +00:00
Jake Burkholder
8c93421144 Emulate ldq and stq (load/store long double) instructions. GCC has started
using these to load long doubles, but they aren't implemented in hardware
on (at least) UltraSPARC I and II machines.
Emulate popc in the user trap handler as well.
Re-arrange slightly to make support functions more accessible.

Reviewed by:	tmm
2002-04-27 21:56:28 +00:00
Jake Burkholder
82436f1067 Rename some fields in struct frame to be compatible with NetBSD/OpenBSD,
and add some compatibility defines.  Add fields for ins and locals to
struct reg also for the same reason; these aren't filled in yet because
getting at those registers sucks and I'd rather not save them in the
trapframe just for this.  Reorder struct reg to be ABI compatible as
well.  Add needed include of machine/emul.h.

This gets pmdb (poor man's debugger) from OpenBSD mostly compiling but it
doesn't work yet :(
2002-04-09 00:57:23 +00:00
Thomas Moestl
ca31253aa8 htonl() and ntohl() operate on unsinged types, so they must zero-extend,
not sign-extend. Fix a comment in the former to that effect, and change
the latter over to do the right conversion.
2002-04-06 00:07:15 +00:00
David E. O'Brien
1114a754ed Fix the style of the SCM ID's.
I believe have made all of libc .h's as consistent as possible.
2002-03-22 23:42:05 +00:00
David E. O'Brien
333fc21e3c Fix the style of the SCM ID's.
I believe have made all of libc .c's as consistent as possible.
2002-03-22 21:53:29 +00:00
David E. O'Brien
078c6f985a SCM ID tweak. 2002-03-22 09:27:59 +00:00
David E. O'Brien
c05ac53b8b Remove __P() usage. 2002-03-21 22:49:10 +00:00
David E. O'Brien
8fb3f3f682 Remove 'register' keyword. 2002-03-21 18:49:23 +00:00
Thomas Moestl
d095bc220d Fix some bugs that would prevent %fsr to be set correctly, and add
support for fcmp and fcmpe instructions with a condition code
specification other than %fcc0.
This (primarily the first part) seems to fix a lot of problems that
people were seeing, e.g. perl and gawk failures.

Reported and analyzed by:	wollman
2002-03-11 03:18:17 +00:00
Thomas Moestl
61de6bb54c Account for <machine/fsr.h> no longer being usable for assembler code. 2002-03-11 03:13:02 +00:00
Thomas Moestl
57f31f4714 Fix __dtoul to work on sparc64 (it used a half-way v8 stack layout),
and make it PIC-aware.
2002-03-11 03:10:55 +00:00
Thomas Moestl
9300cb7db7 Save/restore the %y register around calls to the C user trap handler;
gcc emits the deprecated sparc v8 instructions that use this register
when optimizing for UltraSparc machines because they are apparetly
faster then their v9 counterpars there.
2002-03-11 02:53:03 +00:00
Jake Burkholder
3ff2c61db8 Add fpsetmask(). Needed to build miniperl.
Obtained from:	netbsd
2002-03-05 04:03:57 +00:00
Jake Burkholder
f496405572 Fix a bug where siglongjmp would clobber the argument to return from
sigsetjmp.  It would return the value of the signal flag, instead.

Pointy hat to:	jake
2002-03-05 04:02:04 +00:00
Thomas Moestl
49a64cb475 Connect the sparc64 userland fp emulator to the build. 2002-03-05 00:00:40 +00:00
Thomas Moestl
4895e965c3 Add userland floating point emulator code for sparc64. This is a port
of the (never committed) in-kernel version (with some optimizations and
cleanups), which in turn was ported from NetBSD.
2002-02-23 21:37:18 +00:00
Jake Burkholder
3b16ee2c6c Fix wrong offsets. Add offsets for %fsr and %tstate.
Submitted by:	tmm
2002-02-23 19:01:22 +00:00
Jake Burkholder
d1497824f0 Add space for %fsr and %tstate to utrapframe. Save them in the generic
user trap entry code.  Restore %asi and %ccr from the saved %tstate before
returning to the trapping user code.

Submitted by:	tmm
2002-02-23 19:00:30 +00:00
Mike Barcroft
fd8e4ebc8c o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
  source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
  Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
  POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
  and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
  complexities associated with having MD (asm and inline) versions, and
  having to prevent exposure of these functions in other headers that
  happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
  third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.

Tested on:	alpha, i386
Reviewed by:	bde, jake, tmm
2002-02-18 20:35:27 +00:00
Jake Burkholder
29c3ea8424 Connect user trap code to the build. 2002-01-01 21:59:53 +00:00
Jake Burkholder
6ce4e876a7 Add libc side of user trap handling.
Add support for handling floating point disabled traps mostly in userland
for the simple single threaded case.  Not yet enabled by default.
Implement __sparc_utrap_install as specified by the sparc abi.
2002-01-01 21:58:32 +00:00
Jake Burkholder
1b46a084f3 Make sure curbrk is well aligned. 2001-12-29 06:40:58 +00:00
Jake Burkholder
c0c4d2cf25 Use jmpbuf offsets, not ucontext_t. 2001-12-29 06:40:35 +00:00
Jake Burkholder
cd4f8a8c2c Add .register directives for gcc3.
Adapt to jmpbuf no longer being a ucontext_t.
Restore the context "by hand" in longjmp and call sigprocmask, instead
of just using sigreturn.
2001-12-29 06:39:53 +00:00
Jake Burkholder
c5a29982d3 __infinity is not const. 2001-12-29 06:38:31 +00:00
Jake Burkholder
c1682cb423 Add jmpbuf offsets. Remove ucontext offsets. 2001-12-29 06:38:06 +00:00
Jake Burkholder
5b3fb165d9 Add .register directives for gcc3.
Adapt to jmpbuf no longer being a ucontext_t.
Call abort if longjmperror returns.
2001-12-29 06:37:33 +00:00
Jake Burkholder
cafb96f2df Include utrap.h for soft trap types. 2001-12-29 06:36:07 +00:00
Jake Burkholder
125ccd2e6d Actually build new files.
Forgotten by:	jake
2001-11-19 00:19:49 +00:00
Jake Burkholder
b6d97b0c52 Need .type and .size here too. 2001-11-18 04:48:34 +00:00
Jake Burkholder
84a23d72a0 Add more libc stuff.
Obtained from:	netbsd
2001-11-18 04:40:30 +00:00
Jake Burkholder
c8efb16966 Catch up to jmpbuf changes. Define offsets used from assmebly language
in another file so that it is easy to see what they are and keep them in
sync with the headers (grafted from the kernel generated assym.s).
2001-11-18 04:35:09 +00:00
Jake Burkholder
29e5109c5f Remove fork and vfork wrappers. The kernel does the right thing. 2001-11-18 04:31:36 +00:00
Jake Burkholder
3b3cc5736a Add .type and .size pseudo-ops to system call macros so that dynamic binaries
will link.  They must be used for weak symbols as well as strong ones.
2001-11-18 04:29:20 +00:00
Jake Burkholder
e74ea2d01a Minimal libc for sparc64.
Reviewed by:	obrien
2001-10-26 05:40:07 +00:00