unstack, sort: cleanup and improvement
[minix.git] / tools / gcc / files / values.c
blobc8d2f943aa72a9d6507c766125874b777bd63ec4
1 #if 0 /* $NetBSD$ */
3 # This is Solaris x86 specific GCC run-time environment patch, which
4 # makes it possible to reliably deploy .init snippets. Trouble is that
5 # Solaris linker erroneously pads .init segment with zeros [instead of
6 # nops], which is bound to SEGV early upon program start-up. This bug
7 # was recognized by GCC team [it is mentioned in source code], but
8 # workaround apparently and obviously erroneously slipped away in some
9 # newer GCC release. This patch compensates for this mishap by dropping
10 # modified values-X*.o into GCC installation tree. Object modules in
11 # question are normally provided by Sun and linked prior crtbegin.o.
12 # Modified versions are additionally crafted with custom .init segment,
13 # which does some magic:-)
14 # <appro@fy.chalmers.se>
15 set -e
16 gcc=gcc
17 if [[ "x$1" = x*gcc ]]; then
18 gcc=$1; shift
20 gcc_dir=`${gcc} "$@" -print-libgcc-file-name`
21 gcc_dir=${gcc_dir%/*} #*/
22 set -x
23 ${gcc} "$@" -c -o $gcc_dir/values-Xa.o -DXa $0
24 ${gcc} "$@" -c -o $gcc_dir/values-Xc.o -DXc $0
25 ${gcc} "$@" -c -o $gcc_dir/values-Xt.o -DXt $0
26 exit
27 #endif
29 #include <math.h>
31 #if defined(Xa)
32 const enum version _lib_version = ansi_1;
33 #elif defined(Xc)
34 const enum version _lib_version = strict_ansi;
35 #elif defined(Xt)
36 const enum version _lib_version = c_issue_4;
37 #else
38 #error "compile by issuing 'ksh -f values.c [gcc] [-m64]'"
39 #endif
41 #if defined(__x86_64__)
42 asm("\n"
43 ".section .init\n"
44 ".align 1\n"
45 " leaq 1f(%rip),%rax\n"
46 "1: cmpl $0,2f-1b(%rax)\n"
47 " jne 2f\n"
48 " jmp 2f+5\n"
49 " .skip 9\n" /* pad up to 0x1b bytes */
50 "2:\n"
52 #else
53 asm("\n"
54 ".section .init\n"
55 ".align 1\n"
56 " call 1f\n"
57 "1: popl %eax\n"
58 " cmpl $0,2f-1b(%eax)\n"
59 " jne 2f\n"
60 " jmp 2f+5\n"
61 " .skip 10\n" /* pad up to 0x1b bytes */
62 "2:\n"
64 #endif