aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/amd64/gen
Commit message (Collapse)AuthorAgeFilesLines
* Unify i386 and amd64 getcontextx.c, and use ifuncs while there.Konstantin Belousov2019-02-142-114/+1
| | | | | | | | | | | In particular, use ifuncs for __getcontextx_size(), also calculate the size of the extended save area in resolver. Same for __fillcontextx2(). Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=344120
* Remove support for SYS_sys_exit in favor of SYS_exit.Brooks Davis2018-06-011-4/+0
| | | | | | | | SYS_exit has been defined in the repo since 1994 except for a brief window when SYS_sys_exit was defined in 2000. Notes: svn path=/head/; revision=334500
* libc: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-254-3/+11
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326193
* Renumber copyright clause 4Warner Losh2017-02-283-3/+3
| | | | | | | | | | | | Renumber cluase 4 to 3, per what everybody else did when BSD granted them permission to remove clause 3. My insistance on keeping the same numbering for legal reasons is too pedantic, so give up on that point. Submitted by: Jan Schaumann <jschauma@stevens.edu> Pull Request: https://github.com/freebsd/freebsd/pull/96 Notes: svn path=/head/; revision=314436
* Add include for declaration of _set_tp(). Eliminates -Wmissing-prototypes ↵Craig Rodrigues2015-09-201-0/+1
| | | | | | | warnings. Notes: svn path=/head/; revision=288019
* Switch libc from using _sig{procmask,action,suspend} symbols, whichKonstantin Belousov2015-08-292-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | are aliases for the syscall stubs and are plt-interposed, to the libc-private aliases of internally interposed sigprocmask() etc. Since e.g. _sigaction is not interposed by libthr, calling signal() removes thr_sighandler() from the handler slot etc. The result was breaking signal semantic and rtld locking. The added __libc_sigprocmask and other symbols are hidden, they are not exported and cannot be called through PLT. The setjmp/longjmp functions for x86 were changed to use direct calls, and since PIC_PROLOGUE only needed for functional PLT indirection on i386, it is removed as well. The PowerPC bug of calling the syscall directly in the setjmp/longjmp implementation is kept as is. Reported by: Pete French <petefrench@ingresso.co.uk> Tested by: Michiel Boland <boland37@xs4all.nl> Reviewed by: jilles (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=287292
* siglongjmp(): Preserve floating point exception flags on i386 and amd64.Jilles Tjoelker2014-06-091-1/+0
| | | | | | | | | | | | | Per POSIX, siglongjmp() shall be equivalent to longjmp() except that it must match sigsetjmp() instead of setjmp() and except for the effect on the signal mask. Therefore, it should preserve the floating point exception flags. This was fixed for longjmp() and _longjmp() in r180080 and r180081 for amd64 and i386 respectively. Notes: svn path=/head/; revision=267307
* Introduce a WEAK_REFERENCE() alias and use it. Get rid of the CNAME and theAndreas Tobler2013-11-213-6/+3
| | | | | | | | | CONCAT macros in SYS.h. Reviewed by: bde, kib Notes: svn path=/head/; revision=258447
* The getcontext() from the __fillcontextx() call in theKonstantin Belousov2013-05-281-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=251047
* libc/amd64: Do not export .cerror.Jilles Tjoelker2012-09-061-5/+0
| | | | | | | | | | | | | | | | | | | | For some reason, libc exports the symbol .cerror (HIDENAME(cerror)), albeit in the FBSDprivate_1.0 version. It looks like there is no reason for this since it is not used from other libraries. Given that it cannot be accessed from C and its strange calling convention, it is rather unlikely that other things rely on it. Perhaps it is from a time when symbols could not be hidden. Most of the amd64 assembler code jumps to .cerror using the GOT. It can jump to it directly now, as in non-PIC mode. There are also some minor size optimizations to instructions but they yield virtually no benefit in the size of libc.so.7 due to padding. Reviewed by: kib Notes: svn path=/head/; revision=240178
* Make the sys/ucontext.h self-contained by changing the return typeKonstantin Belousov2012-02-011-1/+1
| | | | | | | | | | of __getcontextx_size(3) from size_t to int. PR: ports/164654 MFC after: 1 month Notes: svn path=/head/; revision=230864
* Add API for obtaining extended machine context states that cannot beKonstantin Belousov2012-01-212-1/+102
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=230429
* Make sure that stack is 16-byte aligned before calling a function,Konstantin Belousov2011-11-022-0/+6
| | | | | | | | | | | | as it is required by amd64 ABI. Add a comment for the places were the stack is accidentally properly aligned already. PR: amd64/162214 Submitted by: yamayan <yamayan kbh biglobe ne jp> MFC after: 1 week Notes: svn path=/head/; revision=227023
* Replace a proliferation of buggy MD implementations of modf() with aDavid Schultz2011-10-212-92/+1
| | | | | | | | | | 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. Notes: svn path=/head/; revision=226606
* Add section .note.GNU-stack for assembly files used by 386 and amd64.Konstantin Belousov2011-01-076-0/+12
| | | | Notes: svn path=/head/; revision=217106
* Retire the amd64 and i386 specific inline assembly versions of ldexp.c,Dimitry Andric2010-09-301-68/+0
| | | | | | | | | | | as they are slower than the generic version in C, at least on modern hardware. This leaves us with just five implementations. Suggested by: bde Approved by: rpaulo (mentor) Notes: svn path=/head/; revision=213308
* Apply the same workaround for clang to amd64's version of ldexp.c (as inDimitry Andric2010-09-291-3/+9
| | | | | | | | | | | | | | | | r212976): order the incoming arguments to fscale as st(0), st(1), and mark temp2 volatile (only in case of compilation with clang) to force clang to pop it correctly. No binary change when compiled with gcc. This fixes ldexp() when compiled with clang on amd64, which makes drand48() and friends work correctly again, and this in turn fixes perl's tempfile(). Reported by: Renato Botelho, Derek Tattersall Approved by: rpaulo (mentor) Notes: svn path=/head/; revision=213281
* We've been lax about matching END() macros in asm code for some time. ThisPeter Wemm2008-11-026-0/+9
| | | | | | | | | | is used to set the ELF size attribute for functions. It isn't normally critical but some things can make use of it (gdb for stack traces). Valgrind needs it so I'm adding it in. The problem is present on all branches and on both i386 and amd64. Notes: svn path=/head/; revision=184547
* Two FP-related setjmp/longjmp changes:David Schultz2008-06-282-2/+20
| | | | | | | | | | | | | | | | | | 1. Save and restore the control part of the MXCSR in addition to the i387 control word to ensure that the two are consistent. Note that standards don't require longjmp to restore either control word, and none of Linux, MacOS X 10.3 and earlier, NetBSD, OpenBSD, or Solaris do it. However, it is historical FreeBSD behavior, and bde points out that it is needed to make longjmping out of a signal handler work properly, given the way FreeBSD clobbers the FPU state on signal handler entry. 2. Don't clobber the FPU exception flags in longjmp. C99 requires them to remain unchanged. Notes: svn path=/head/; revision=180080
* Remove silly n that crept inWarner Losh2007-01-091-1/+1
| | | | Notes: svn path=/head/; revision=165905
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-095-21/+1
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Remove fpsetsticky(). This was added for SysV compatibility, but dueDavid Schultz2005-03-152-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=143658
* Add support for TLS in statically linked programs.Doug Rabson2004-08-152-1/+39
| | | | Notes: svn path=/head/; revision=133754
* 1. Use correct alignment mask, -15 != ~15David Xu2004-07-311-2/+2
| | | | | | | 2. Make end of frames Notes: svn path=/head/; revision=132912
* Set fpu context flags to known values, zero is illegal.David Xu2004-07-281-0/+2
| | | | Notes: svn path=/head/; revision=132795
* Make FLT_ROUNDS correctly reflect the dynamic rounding mode.David Schultz2004-07-192-1/+27
| | | | Notes: svn path=/head/; revision=132383
* Replace seven nominally MD implementations of frexp() that are brokenDavid Schultz2004-07-182-69/+1
| | | | | | | for subnormals with one implementation that works. Notes: svn path=/head/; revision=132366
* Implement the classification macros isfinite(), isinf(), isnan(), andDavid Schultz2004-07-092-76/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=131852
* Avoid to touch red zone, in libpthread, ucontext may be saved by kernel'sDavid Xu2004-06-151-1/+1
| | | | | | | | | | get_mcontext, and libpthread will use signalcontext to deliver signal in userland, it looks same as kernel's send_sig does. Reviewed by: deischen, tjr Notes: svn path=/head/; revision=130546
* Fix Yet Another 16 byte stack alignment bug. Thankfully, this one isPeter Wemm2004-03-312-10/+10
| | | | | | | | | | | | | | solved by a simple 'make world'. The signalcontext function was going to the trouble of generating an even 16 byte alignment, but in fact it needed to be odd aligned to simulate the 8-byte return address having been pushed by the caller. This fixes yet another group of crashes in applications using libpthread. And yet again, it was my fault all along. While here, rename the duplicate internal ctx_wrapper() functions to makectx_wrapper() and sigctx_wrapper() so that traces aren't ambiguous. Notes: svn path=/head/; revision=127658
* Fix a typo in the !__GNUC__ case and remove an obsolete comment.David Schultz2004-02-161-3/+1
| | | | Notes: svn path=/head/; revision=125866
* Fix some aliasing problems.David Schultz2004-02-161-14/+19
| | | | Notes: svn path=/head/; revision=125865
* Rewrite fabs.S to use pure SSE2 operations. I got the clues how to doPeter Wemm2004-02-081-10/+35
| | | | | | | this from looking at code generated by gcc. Notes: svn path=/head/; revision=125600
* "Fix" makecontext() so that the C code begins execution with itsPeter Wemm2003-12-051-2/+6
| | | | | | | | | | | | | | | | ABI-required stack alignment. C code expects that the push of the return address disturbed the 16 byte alignment and it will take corrective measures to fix it before making another call. Of course, if its wrong to start with, then all hell breaks loose. Essentially we "fix" this by making the stack alignment odd to start with. This was one of the things that broke on libkse with apps that use floating point/varargs/etc. Approved by: re (scottl) Notes: svn path=/head/; revision=123154
* Add rfork_thread(3).Alan Cox2003-10-132-1/+102
| | | | Notes: svn path=/head/; revision=121074
* Fix fabs(). This commit brought to you by the letter 'l'.Peter Wemm2003-09-261-1/+1
| | | | | | | | | | | | (fstp stores a mem32 value, fstpl stores a mem64 value) This fixes ghostscript for 'make release' on amd64. Ghostscript for some reason thinks it is a good idea to use -fno-builtin, which means it is vulnerable to bugs in libc that are normally hidden by the builtin gcc functions. Oops. Notes: svn path=/head/; revision=120448
* Set mc_len to sizeof(mcontext_t), otherwise it is an invalid context.David Xu2003-07-261-0/+1
| | | | Notes: svn path=/head/; revision=118058
* Instantiate explicit callable versions of the machine/ieeefp.h inlinesPeter Wemm2003-07-229-1/+67
| | | | | | | for the use of non-GCC compilers and C++ code. Notes: svn path=/head/; revision=117864
* Add amd64 versions of makecontext() and signalcontext() neededDaniel Eischen2003-07-193-1/+208
| | | | | | | | for libkse (makecontext() is also needed for libthr). These probably will need some tweaking. Notes: svn path=/head/; revision=117755
* This is unusable on amd64. Remove it before it causes more confusion.Peter Wemm2003-06-131-53/+0
| | | | | | | | | It is only possible to do this on an ABI that has a compulsory frame pointer, which the amd64 ABI does not. Thus, it is only possible to implement this as a compiler builtin. Notes: svn path=/head/; revision=116317
* Use C99 compatible ASM statements.David E. O'Brien2003-06-101-1/+1
| | | | | | | | (untested, but existing state breaks http://triangle.rtp.freebsd.org/~des/tinderbox-CURRENT-amd64-amd64.brief) Notes: svn path=/head/; revision=116172
* Cosmetic; record offsets used within jmpbufPeter Wemm2003-06-023-30/+30
| | | | Notes: svn path=/head/; revision=115745
* Fix sigsetjmp(). It helps if we do not try to save the old signal maskPeter Wemm2003-06-021-0/+1
| | | | | | | to a random memory location. Perl works a lot better with this. Notes: svn path=/head/; revision=115738
* Update ldexp.c for amd64.Peter Wemm2003-05-102-7/+1
| | | | Notes: svn path=/head/; revision=114866
* SIG_SETMASK is 3, not 1. Sigh.Peter Wemm2003-05-081-1/+1
| | | | Notes: svn path=/head/; revision=114835
* Fix an embarresing transcription error from i386 to amd64. Put the argumentsPeter Wemm2003-05-082-13/+12
| | | | | | | | to sigprocmask(2) int the correct order. *blush*. For sigsetjmp(), match up the pushq/popq in the non-savemask case. Notes: svn path=/head/; revision=114829
* Tidy up modf.S and make it actually work. It wasn't extractingPeter Wemm2003-05-081-16/+13
| | | | | | | | the value out of ST(0) before copying it to %xmm0. Also remove bogus stack frame and work in the red zone. Notes: svn path=/head/; revision=114827
* Fix typo, even though this is unused.Peter Wemm2003-05-081-1/+1
| | | | Notes: svn path=/head/; revision=114818
* Turn off alloca.S - it cannot possibly work like this since on AMD64, gccPeter Wemm2003-05-071-1/+1
| | | | | | | | | | doesn't use stack frames. It uses offsets relative to %rsp, not %rbp. So we cannot just change %rsp like this. Approved by: re (blanket amd64) Notes: svn path=/head/; revision=114815
* Convert the i386 alloca(3) to the x86-64 ISA.David E. O'Brien2003-05-011-0/+53
| | | | | | | Alignment hack from: NetBSD Notes: svn path=/head/; revision=114430