Commit Graph

78 Commits

Author SHA1 Message Date
David Schultz
479f8d2214 Make FLT_ROUNDS correctly reflect the dynamic rounding mode. 2004-07-19 08:17:25 +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
David Xu
39ba326d65 Follow previous change in makecontext. Use %esi to store next ucp
pointer, here we keep orignal %ebp, so we can see where signal handler
comes in and interrupt normal code.
2004-07-02 23:20:05 +00:00
David Xu
a5a5d84784 Use %esi to store next ucp pointer. Mark end of stack by
setting %ebp to zero, this avoids new gdb to dump a weird
backtrace.
2004-07-02 14:19:44 +00:00
David Schultz
a94707138b Remove the code and an associated comment for gcc 1.x compatibility
and fix a typo in the !__GNUC__ case.
2004-02-16 10:03:02 +00:00
David Schultz
36e22bed27 Fix some aliasing problems. 2004-02-16 10:02:40 +00:00
Colin Percival
d623b765cf style cleanup: Remove duplicate $FreeBSD$ tags.
These files had tags after the copyright notice,
inside the comment block (incorrect, removed),
and outside the comment block (correct).

Approved by:	rwatson (mentor)
2004-02-10 20:42:33 +00:00
David E. O'Brien
0ab6a0c787 Push the alloca #error warning farther down to play nicer with some out of
tree local translator.

Requested by:	 jmallett
2003-06-25 19:06:40 +00:00
David E. O'Brien
5c784c8f4b Only use this with a non-GCC compiler. 2003-06-14 06:04:23 +00:00
David E. O'Brien
e683295e39 Use C99 compatible ASM statements. 2003-06-02 02:32:22 +00:00
John Baldwin
664234c6e2 Properly cleanup the stack before jumping to cerror() if rfork(2) fails.
Submitted by:	Igor Sysoev <is@rambler-co.ru>
Approved by:	re (scottl)
2003-05-07 17:23:25 +00:00
Daniel Eischen
67aba1c6a4 Align signal frame placed on stack to 16 bytes so that SSE FPU register
restores can work.  Also correct allocation for signal frame size.

Reviewed by:	mini
2003-03-29 16:38:15 +00:00
Daniel Eischen
cd7be69206 Remove these from libc; they are now system calls.
Prompted by:	mini
2003-02-18 12:31:57 +00:00
Jonathan Mini
2129373618 Call the weak symbol for sigprocmask, so that it can be overridden. 2003-02-17 07:47:13 +00:00
Jacques Vidrine
e0554a531f Eliminate 61 warnings emitted at WARNS=2 (leaving 53 to go).
Only warnings that could be fixed without changing the generated object
code and without restructuring the source code have been handled.

Reviewed by:	/sbin/md5
2003-02-16 17:29:11 +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
Daniel Eischen
9ed358fddc Disconnect the userland get/set/swapcontext() functions from
libc.  I want to keep these in some version for the thread
library/ies, but don't know whether to have them repo-copied
to libc_r or renamed and kept in libc.

Change the name of an alpha macro that was changed with the
system call commit.
2002-11-16 06:39:11 +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
Jonathan Mini
dcf0aad852 Style cleanup:
- Sort local variable declarations.
- Protect a hand-formatted comment from indent(1).
- Use portable casts, even though this is machine-dependant code.
- Remove extraneous blank lines.
- Remove trailing newline.
- Use sigdelset(3), not SIGDELSET(9).

Requested by:	bde
2002-09-21 23:54:32 +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
Bruce Evans
ff5250b3e7 Fixed editing error in previous commit (*blush*). 2002-09-17 19:43:53 +00:00
Bruce Evans
803e437fb0 Fixed unsorting of SRCS. 2002-09-17 14:33:23 +00:00
Jonathan Mini
7630ea31ed Use a weak symbol for signalcontext(). 2002-09-17 03:15:47 +00:00
Jonathan Mini
1d6e1c66b2 Add signalcontext(), which adds a signal frame to a ucontext_t. 2002-09-17 03:11:07 +00:00
Jonathan Mini
f990583656 Save and restore FPU state properly in ucontext_t's.
Reviewed by:	deischen, julian
Approved by:	-arch
2002-09-16 19:24:31 +00:00
Robert Drehmel
b78411b153 Include <stdlib.h> to have abort() and exit() declared. 2002-08-15 11:58:24 +00:00
David E. O'Brien
c04447ba03 Standardize on our SCM ID style. 2002-03-23 02:44:19 +00:00
David E. O'Brien
0f4f02856d Restore CSRG ID's lost in January 1995. 2002-03-23 02:10:28 +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
Peter Wemm
cc2dbb21e5 Move swapcontext.c to the ${MACHINE_ARCH}/gen/Makefile.inc area, otherwise
it causes undefined references to getcontext() and setcontext() on
platforms other than i386 and alpha.
2002-03-21 06:45:32 +00:00
Bruce Evans
b9c35b6942 Fixed unsorting and splitting of SRCS in previous commit. 2002-01-11 17:10:35 +00:00
Daniel Eischen
b66b8326e5 Add getcontext, setcontext, makecontext, and swapcontext. These
functions are defined in SUSv2 and the latest POSIX spec.

Thanks to Bernd Walter <ticso@cicely8.cicely.de> for helping debug my
alpha assembly.

Approved by:	-arch
2002-01-10 02:40:59 +00:00
John Baldwin
a1d8094b9e Use 'mov' instead of 'lea' for setting the syscall number in %eax as that
is clearer about what we are actually doing.

Requested by:	bde
2001-11-27 20:51:26 +00:00
Peter Wemm
e6d808aee3 De-orbit DEFS.h - the other arches do not use it, and it got replaced
with <machine/asm.h>.

Reviewed by:	bde
2001-10-24 20:29:14 +00:00
Ruslan Ermilov
8af1452cf8 Removed duplicate VCS ID tags, as per style(9). 2001-08-13 14:06:34 +00:00
Daniel Eischen
d201fe46e3 Remove _THREAD_SAFE and make libc thread-safe by default by
adding (weak definitions to) stubs for some of the pthread
functions.  If the threads library is linked in, the real
pthread functions will pulled in.

Use the following convention for system calls wrapped by the
threads library:
	__sys_foo - actual system call
	_foo - weak definition to __sys_foo
	foo - weak definition to __sys_foo

Change all libc uses of system calls wrapped by the threads
library from foo to _foo.  In order to define the prototypes
for _foo(), we introduce namespace.h and un-namespace.h
(suggested by bde).  All files that need to reference these
system calls, should include namespace.h before any standard
includes, then include un-namespace.h after the standard
includes and before any local includes.  <db.h> is an exception
and shouldn't be included in between namespace.h and
un-namespace.h  namespace.h will define foo to _foo, and
un-namespace.h will undefine foo.

Try to eliminate some of the recursive calls to MT-safe
functions in libc/stdio in preparation for adding a mutex
to FILE.  We have recursive mutexes, but would like to avoid
using them if possible.

Remove uneeded includes of <errno.h> from a few files.

Add $FreeBSD$ to a few files in order to pass commitprep.

Approved by:	-arch
2001-01-24 13:01:12 +00:00
John Baldwin
9a51cfcde1 Prefix the register argument of indirect 'jmp's with a * to make gas 2.10.x
happy.
2000-11-28 22:59:14 +00:00
Peter Wemm
ea3d353444 Fix some rather interesting bugs that managed to not turn up in various
testing and real-life applications:
1) If you returned from the thread function, you got a segv instead of
  calling _exit() with your return code.
2) clean up some bogus stack management.  There was also an underflow
  on function return.
3) when making syscalls, the kernel is expecting to have to leave space
  for the function's return address.  We need to duplicate this.  It was
  an accident that the rfork syscall actually worked here. :-/
2000-07-29 11:34:01 +00:00
Peter Wemm
c932e5d18f rfork(2) wrapper for simple rfork-style threads. I have lost count of
the number of times I have given this to people and got asked: why isn't
it in libc?  It is impossible to do this without assembler glue to reset
the stack for the new child process.

int rfork_thread(flags, stack_addr, start_fnc, start_arg)
int flags;                 Flags to rfork system call.  See rfork(2).
void *stack_addr;          Top of stack for thread.
int (*start_fnc)(void *);  Address of thread function to call in child.
void *start_arg;           Argument to pass to the thread function in child.

This is deliberately not documented or prototyped in includes until the
corresponding alpha version is written.
2000-07-29 07:14:04 +00:00
Jason Evans
9976e59211 Use assembler directives rather than ALTENTRY() so that longjmp() and
siglongjmp() are weak symbols.  This is necessary to allow static linking
with the linuxthreads library port.
2000-05-04 04:36:26 +00:00
Jason Evans
bafd6b2f76 Remove unnecessary alternate entry points for *setjmp(). Make the main
entry point the standard name when not compiling libc_r (for example,
longjmp is the main entry point instead of __longjmp).

Suggested by:	bde
2000-01-20 21:58:27 +00:00
Jason Evans
1c12990b99 Make minor entry point changes to support libc_r. 2000-01-19 07:01:40 +00:00
Jason Evans
929273386f Add three-tier symbol naming in support of POSIX thread cancellation
points.  For library functions, the pattern is __sleep() <--
_libc_sleep() <-- sleep().  The arrows represent weak aliases.  For
system calls, the pattern is _read() <-- _libc_read() <-- read().
2000-01-12 09:23:48 +00:00
Jason Evans
0105d67807 Unbreak profiling. bde says this is not the cleanest way to fix the
problem, but that it works.

Submitted by:	bde
2000-01-04 00:02:21 +00:00
Jason Evans
ec9d5fa5f8 Creating weak symbols doesn't work correctly when building an aout libc.
Doing the "right thing" here is difficult, so create two ENTRY points for
each function (for example, __setjmp and setjmp are equivalent).  This
isn't pretty, but it works for both aout and ELF.

libc symbol naming needs an overhaul in order to properly support function
wrapping, specifically in the case of a real libpthread, and these
duplicate entry points should be fixed as part of that overhaul.

Pointed out by:	bde
1999-12-24 00:03:00 +00:00
Jason Evans
ea8271a8bb Make setjmp, longjmp, sigsetjmp, and siglongjmp weak aliases for
__setjmp, __longjmp, __sigsetjmp, and __siglongjmp, respectively.
This supports cancellation in the linuxthreads port.  In the long run,
a much more comprehensive solution will necessitate more dramatic changes
to libc symbol naming, and these aliases will probably need modification
at that time.
1999-12-14 20:17:52 +00:00
Marcel Moolenaar
23cd96d8ce \begin{quote}
setjmp() gets the jmp_buf pointer from the wrong place (the place
where the return address is) in the shlib case, and uses it (only)
to fetch the current signal mask to address (return_address + 28).
This address is normally read-only (I hope), so the sigprocmask()
call has no effect except to return an error code.
\end{quote}

Submitted by: bde
1999-10-10 08:38:33 +00:00