Commit Graph

136 Commits

Author SHA1 Message Date
Konstantin Belousov
55a1911ef2 The getcontext() from the __fillcontextx() call in the
check_deferred_signal() returns twice, since handle_signal() emulates
the return from the normal signal handler by sigreturn(2)ing the
passed context.  Second return is performed on the destroyed stack
frame, because __fillcontextx() has already returned.  This causes
undefined and bad behaviour, usually the victim thread gets SIGSEGV.

Avoid nested frame and the need to return from it by doing direct call
to getcontext() in the check_deferred_signal() and using a new private
libc helper __fillcontextx2() to complement the context with the
extended CPU state if the deferred signal is still present.

The __fillcontextx() is now unused, but is kept to allow older
libthr.so to be used with the new libc.

Mark __fillcontextx() as returning twice [1].

Reported by:	pgj
Pointy hat to:	kib
Discussed with:	dim
Tested by:	pgj, dim
Suggested by:	jilles [1]
MFC after:	1 week
2013-05-28 04:54:16 +00:00
Konstantin Belousov
150facd256 Rework the __vdso_* symbols attributes to only make the symbols weak,
but use normal references instead of weak.  This makes the statically
linked binaries to use fast gettimeofday(2) by forcing the linker to
resolve references and providing the neccessary functions.

Reported by:	bde
Tested by:	marius (sparc64)
MFC after:	2 weeks
2013-01-30 12:48:16 +00:00
Konstantin Belousov
754f1c1e63 Make the sys/ucontext.h self-contained by changing the return type
of __getcontextx_size(3) from size_t to int.

PR:	ports/164654
MFC after:	1 month
2012-02-01 13:33:53 +00:00
Konstantin Belousov
2b1de0afd1 Add API for obtaining extended machine context states that cannot be
fit into existing mcontext_t.

On i386 and amd64 do return the extended FPU states using
getcontextx(3). For other architectures, getcontextx(3) returns the
same information as getcontext(2).

Tested by:  pho
MFC after:  1 month
2012-01-21 18:00:28 +00:00
David Schultz
8ff9d52cd0 Computations on NaNs are supposed to return one of the input NaNs unchanged.
Fix a few places in the sparc64 floating-point emulator where this wasn't
being handled properly.

Submitted by:	bde
2012-01-16 04:09:45 +00:00
David Schultz
6232589aeb Replace a proliferation of buggy MD implementations of modf() with a
working MI one.  The MI one only needs to be overridden on machines
with non-IEEE754 arithmetic.  (The last supported one was the VAX.)
It can also be overridden if someone comes up with a faster one that
actually passes the regression tests -- but this is harder than it sounds.
2011-10-21 06:40:36 +00:00
Ed Schouten
3a28b8a49f Fix whitespace inconsistencies found in homegrown Symbol.maps. 2011-10-07 15:05:24 +00:00
Attilio Rao
4b547324c0 Disconnect sun4v architecture from the three.
Some files keep the SUN4V tags as a code reference, for the future,
if any rewamped sun4v support wants to be added again.

Reviewed by:	marius
Tested by:	sbruno
Approved by:	re
2011-05-14 01:53:38 +00:00
Marius Strobl
be05bc3ffb Avoid aliasing which leads to incorrect results when compiling with the
default strict aliasing rules.

PR:		144900
Submitted by:	Peter Jeremy
MFC after:	3 days
2010-03-21 13:18:08 +00:00
Marius Strobl
b28ad3ebc9 - While SPARC V9 allows tininess to be detected either before or after
rounding (impl. dep. #55), the SPARC JPS1 responsible for SPARC64 and
  UltraSPARC processors defines that in all cases tinyness is detected
  before rounding, therefore rounding up to the smallest normalised
  number should set the underflow flag.
- If an infinite result is rounded down, the result should have an
  exponent 1 less than the value for infinity.

PR:		144900
Submitted by:	Peter Jeremy
MFC after:	3 days
2010-03-20 22:32:13 +00:00
Marius Strobl
bd2ec8519e Division should take both arguments' signs into account when the
the dividend is infinity or zero and the divisor is not the same.

PR:		144900
Submitted by:	Peter Jeremy
MFC after:	3 days
2010-03-20 22:12:15 +00:00
Marius Strobl
484bacf4b9 FPU_DEBUG requires <stdio.h>.
PR:		144900
Submitted by:	Peter Jeremy
MFC after:	3 days
2010-03-20 21:27:44 +00:00
Marius Strobl
4dda9dfd81 Ensure that __fpu_ftox() both returns the high bits and res[1] contains
the low bits also in the default case.

PR:		144900
Obtained from:	OpenBSD
MFC after:	3 days
2010-03-20 21:15:56 +00:00
Marius Strobl
564b3fffdd - Remove a bogus forward declaration.
- Fix whitespace.
2010-03-20 21:04:47 +00:00
Marius Strobl
7e0e1004f3 Fix a typo in r204974 so that FTYPE_LNG matches the initialisers of
the opmask array.

Pointed out by:	Peter Jeremy
2010-03-11 07:46:17 +00:00
Marius Strobl
ff2f66ea79 - The OPSZ macro actually only does the right thing for int32 and int64
operands but not for double and extended double ones. Instead of trying
  to fix the macro just nuke it and unroll the loops in the correct way
  though as extended double operands turn out to be the only special case.
- For FxTO{s,d,q} the source operand is int64 so rs2 has to be re-decoded
  after setting type accordingly as it's generally decoded using the low
  2 bits as the type, which are 0 for these three instructions.
- Similarly, in case of F{s,d,q}TOx the target is int64 so rd has to be
  re-decoded using not only the operand mask appropriate for int64 but
  also the correct register number encoding.
- Use const where appropriate.
- Wrap long lines.

Submitted by:	Peter Jeremy (partly)
MFC after:	3 days
2010-03-10 19:55:48 +00:00
Joel Dahl
2598954edc The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Obtained from:	NetBSD
2010-03-03 17:07:02 +00:00
Ed Schouten
dc428c2ffe Remove unneeded stdlib directories.
It's not necessary to add stdlib directories for each architecture, even
if the architecture doesn't implement any files of its own.

Submitted by:	Christoph Mallon
2009-06-23 14:11:41 +00:00
Roman Divacky
b1e58dd43e Provide a type for the argument.
Approved by:	kib (mentor)
2009-02-02 21:51:52 +00:00
Ed Schouten
a1b5a8955e Mark uname(), getdomainname() and setdomainname() with COMPAT_FREEBSD4.
Looking at our source code history, it seems the uname(),
getdomainname() and setdomainname() system calls got deprecated
somewhere after FreeBSD 1.1, but they have never been phased out
properly. Because we don't have a COMPAT_FREEBSD1, just use
COMPAT_FREEBSD4.

Also fix the Linuxolator to build without the setdomainname() routine by
just making it call userland_sysctl on kern.domainname. Also replace the
setdomainname()'s implementation to use this approach, because we're
duplicating code with sysctl_domainname().

I wasn't able to keep these three routines working in our
COMPAT_FREEBSD32, because that would require yet another keyword for
syscalls.master (COMPAT4+NOPROTO). Because this routine is probably
unused already, this won't be a problem in practice. If it turns out to
be a problem, we'll just restore this functionality.

Reviewed by:	rdivacky, kib
2008-11-09 10:45:13 +00:00
David Schultz
10a465e525 Fix some bugs that caused sparc64's quad precision sqrt to get
the wrong answer for virtually all inputs.

Thanks to remko for access to a sparc64 box for testing.
2008-04-12 03:10:13 +00:00
David Schultz
a9d5aa6aeb Make the software emulator for long doubles set the FPU exception
flags appropriately. The next step is to make it raise a SIGFPE if
any exceptions are unmasked.

Thanks to remko for access to a sparc64 box for testing.
2008-04-12 03:09:51 +00:00
David Schultz
b3b2ea5930 Add a new union member to access the exponent and sign of a long double
in a single op. Idea from bde.
2008-01-18 21:25:51 +00:00
David Schultz
7cd4a83267 Since nan() is supposed to work the same as strtod("nan(...)", NULL),
my original implementation made both use the same code. Unfortunately,
this meant libm depended on a vendor header at compile time and previously-
unexposed vendor bits in libc at runtime.

Hence, I just wrote my own version of the relevant vendor routine. As it
turns out, mine has a factor of 8 fewer of lines of code, and is a bit more
readable anyway. The strtod() and *scanf() routines still use vendor code.

Reviewed by:	bde
2007-12-18 23:46:32 +00:00
David Schultz
39e7abef0e Export gdtoa's __ULto{x,Q}_D2A routine in a private namespace so
libm can use it.
2007-12-16 21:15:57 +00:00
David Schultz
199cdab56f Arrange so that the NaN returned by strtod("nan", NULL) is the same as
the NaN returned by strtod("nan()", NULL).
2007-12-16 21:15:09 +00:00
David Schultz
9c90f85a6b In scanf, round according to the current rounding mode. 2007-12-03 07:17:33 +00:00
John Birrell
37e19e1d85 Use an intermediate pointer to avoid a strict aliasing warning. 2007-11-23 05:52:13 +00:00
Peter Wemm
65a6d893ba Classify mmap, lseek, pread, pwrite, truncate, ftruncate as pseudo
syscalls, unless WITHOUT_SYSCALL_COMPAT is defined.  The default case
will have the .c wrappers still.  If you define WITHOUT_SYSCALL_COMPAT,
the .c wrappers will go away and libc will make direct syscalls.

After 7-stable starts, the direct syscall method will be default.

Approved by:  re (kensmith)
2007-07-04 23:23:01 +00:00
Peter Wemm
eabc04d472 Adjust the syscall stub macros to be consistent in their meaning. In
particular:
SYSCALL() makes a syscall, with errno handling, and continues execution
directly after the macro in the non-error case.
RSYSCALL() is just like SYSCALL(), but returns after success.
Both SYSCALL(name) and RSYSCALL(name) export  "__sys_name" as a strong
symbol, with "_name" and "name" as weak aliases.
PSEUDO() is just like RSYSCALL(), but skipping the "name" weak alias.  It
still does "__sys_name" and "_name".

Change i386 to add errno handling to PSEUDO.  The same for amd64 and
sparc64, with appear to have copied the behavior.
ia64 was correct (as was alpha).  Just remove some apparently unused
variants of the macros. (untested!)
I believe powerpc is correct.
Fix arm to not export "name" from the PSEUDO case.  Remove apparently
extra unused variants.  (untested!)

The errno problem manifested on i386/amd64/sparc64 by having "PSEUDO"
classified syscalls return without setting errno.  eg: "addr = mmap()"
could return with "addr" = 22 instead of setting errno to 22 and
returning -1.

Approved by: re (kensmith)
2007-07-04 23:18:38 +00:00
Daniel Eischen
2665faf497 Some libc symbol map cleanups.
net: endhostdnsent is named _endhostdnsent and is
  private to netdb family of functions.

  posix1e: acl_size.c has been never compiled in,
  so there's no "acl_size".

  rpc: "getnetid" is a static function.

  stdtime: "gtime" is #ifdef'ed out in the source.

  some symbols are specific only to some architectures,
  e.g., ___tls_get_addr is only defined on i386.

  __htonl, __htons, __ntohl and __ntohs are no longer
  functions, they are now (internal) defines in
  <machine/endian.h>.

Submitted by:	ru
2007-05-31 13:01:34 +00:00
Marius Strobl
ac474f9545 - Add bits for userland profiling. For sun4u this is compile-tested only.
- Replace magic 14 with PIL_TICK.
2007-05-11 23:43:55 +00:00
Daniel Eischen
5f864214bb Use C comments since we now preprocess these files with CPP. 2007-04-29 14:05:22 +00:00
Warner Losh
c879ae3536 Per Regents of the University of Calfornia letter, remove advertising
clause.

# If I've done so improperly on a file, please let me know.
2007-01-09 00:28:16 +00:00
David Schultz
266cb5ad57 The distinction between quiet and signaling NaN formats is
machine-dependent; these files tell the latest version of gdtoa
what to do.
2007-01-03 05:00:03 +00:00
Marius Strobl
63067c1af8 Fix a typo in __fpu_ftox() that caused long double to long (and long long)
conversion of negative numbers to always result in -1.
While at it, rearrange the nearby comment so it fits in 80 chars per line,
like the rest of this file does.

PR:		107130
MFC after:	1 day
2006-12-24 22:24:39 +00:00
Olivier Houchard
05b432d2d1 Instead of re-implementing hton[ls] and friends for each arch, add a new MI
file, net/ntoh.c, which just implement them using the inline functions from
<sys/endian.h>.

Suggested by:	bde
2006-11-06 22:07:47 +00:00
Kip Macy
7b5cdd4faf - change ABI for user trap handler for sun4v (eventually will sync sparc64 no
hardware set up to test at the moment)

Approved by: scottl (standing in for mentor rwatson)
2006-11-03 23:43:18 +00:00
Kip Macy
5fe4c0e842 fix bus error in newsyslog by making sure that fields in struct fpemu
that are accessed as 8 byte quantities are 8 byte aligned
2006-10-12 04:38:41 +00:00
Kip Macy
b84c7a797c Fix TLS on sparc64 for statically and dynamically linked binaries
Approved by: rwatson (mentor)
Reviewed by: jmg and marcel
2006-10-08 02:50:34 +00:00
Marius Strobl
f2189783c9 For _Qp_{fge,fgt,fle,flt}() the SCD states that "Exceptions mimic fcmpeq",
this means they should set the cmpe flag when calling __fpu_compare().

Submitted by:	stefanf
MFC after:	2 weeks
2006-04-16 14:32:53 +00:00
Marius Strobl
ea84e2b899 - Move _Qp_* and __dtoul from FBSDprivate to the list of FBSD_1.0 symbols
as well as add __sparc_utrap_install to FBSD_1.0; these are required by
  the SCD libc 64 psABI and thus meant to be officially exported symbols.
- Remove the __fpu_* entries as well as the __sigtramp entry altogether as
  these are internal to the libc FPU emulation and the signal trampoline
  initialization in sigaction(2) respectively and thus don't need to be
  externally visible.
- Add __sparc_utrap_setup to the list of FBSDprivate symbols as it's used
  in src/lib/csu/sparc64/crt1.c to initialize the libc FPU emulation (I
  think alternatively src/lib/csu/sparc64/crt1.c could be changed to use
  __sparc_utrap_install instead, at the expense of increasing the size of
  executables a bit).
- Add an entry for the vfork symbol to the FBSD_1 list and entries for it's
  associated symbols generated by the RSYSCALL() macro to the FBSDprivate
  list. There's some magic in place that automatically generates code for
  vfork() if there's no explicit MD code for it so it might make sense to
  move these symbols from the MD symbol map files to a MI one.

The last two changes make the libc symbol versioning useable on sparc64.

Ok'ed by:	deischen
2006-04-11 19:43:36 +00:00
Ruslan Ermilov
3029eff743 Desupport the undocumented NO_QUAD option, just don't compile
the quad support on 64-bit platforms.
2006-03-16 14:22:19 +00:00
Daniel Eischen
6fad3aaf15 Add each directory's symbol map file to SYM_MAPS. 2006-03-13 01:15:01 +00:00
Daniel Eischen
cce72e8860 Add symbol maps and initial symbol version definitions to libc.
Reviewed by:	davidxu
2006-03-13 00:53:21 +00:00
Stefan Farfeleder
882cf65dd6 Add the functions _Qp_cmp() and _Qp_cmpe() as described in the Sparc
Compliance Definition.  On sparc64, GCC emits _Qp_cmp() calls for its
__builtin_isfoo() functions which are used for C99's isfoo() macros.

Approved by:	re(dwhite)
PR:		73782
2005-06-21 21:13:07 +00:00
Stefan Farfeleder
1470d46611 Fix long (and long long) to long double, unsigned to long double and unsigned
long (and unsigned long long) to long double conversions.
- Add a parameter that specifies the position of the sign bit to the _QP_TTOQ
  macro, previously it always looked at bit 31.  Pass a negative number to
  disable sign inspection for unsigned types.  This fixes _Qp_xtoq(),
  _Qp_uitoq() and _Qp_uxtoq().
- In the functions __fpu_itof() and __fpu_xtof(), look at the sign bit to
  decide whether we're doing a conversion from an unsigned type.  If so, don't
  negate the mantissa if the integer exceeds the biggest signed number.

PR:		55773
Patch by:	Stephen Paskaluk (based upon)
MFC after:	2 weeks
2005-05-27 10:00:22 +00:00
David Schultz
7b74e4a759 Remove fpsetsticky(). This was added for SysV compatibility, but due
to mistakes from day 1, it has always had semantics inconsistent with
SVR4 and its successors.  In particular, given argument M:

- On Solaris and FreeBSD/{alpha,sparc64}, it clobbers the old flags
  and *sets* the new flag word to M.  (NetBSD, too?)
- On FreeBSD/{amd64,i386}, it *clears* the flags that are specified in M
  and leaves the remaining flags unchanged (modulo a small bug on amd64.)
- On FreeBSD/ia64, it is not implemented.

There is no way to fix fpsetsticky() to DTRT for both old FreeBSD apps
and apps ported from other operating systems, so the best approach
seems to be to kill the function and fix any apps that break.  I
couldn't find any ports that use it, and any such ports would already
be broken on FreeBSD/ia64 and Linux anyway.

By the way, the routine has always been undocumented in FreeBSD,
except for an MLINK to a manpage that doesn't describe it.  This
manpage has stated since 5.3-RELEASE that the functions it describes
are deprecated, so that must mean that functions that it is *supposed*
to describe but doesn't are even *more* deprecated.  ;-)

Note that fpresetsticky() has been retained on FreeBSD/i386.  As far
as I can tell, no other operating systems or ports of FreeBSD
implement it, so there's nothing for it to be inconsistent with.

PR:		75862
Suggested by:	bde
2005-03-15 15:53:39 +00:00
David Schultz
1dfab5edec Define LDBL_NBIT to be a mask indicating the position of the integer
bit in a long double.  For architectures that don't have such a bit,
LDBL_NBIT is 0.  This makes it possible to say `mantissa & ~LDBL_NBIT'
in places that previously used an #ifdef to select the right expression.
The optimizer should dispense with the extra arithmetic when LDBL_NBIT
is 0.
2005-03-07 04:55:22 +00:00
David Schultz
f154b03b25 Update my email address. 2005-02-06 03:23:31 +00:00