1/* Definitions for SPARC running Linux-based GNU systems with a.out.
2   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3   Contributed by Eddie C. Dost (ecd@skynet.be)
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING.  If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA.  */
21
22#include <aoutos.h>
23#include <sparc/sparc.h>
24
25/* Don't assume anything about the header files. */
26#define NO_IMPLICIT_EXTERN_C
27
28#undef HAVE_ATEXIT
29#define HAVE_ATEXIT
30
31/* GNU/Linux uses ctype from glibc.a. I am not sure how complete it is.
32   For now, we play safe. It may change later. */
33
34#if 0
35#undef MULTIBYTE_CHARS
36#define MULTIBYTE_CHARS 1
37#endif
38
39/* We need that too. */
40#define HANDLE_SYSV_PRAGMA
41
42#undef MD_EXEC_PREFIX
43#undef MD_STARTFILE_PREFIX
44
45/* Output at beginning of assembler file.  */
46/* The .file command should always begin the output.  */
47#undef ASM_FILE_START
48#define ASM_FILE_START(FILE)                                            \
49  do {                                                                  \
50        output_file_directive (FILE, main_input_filename);              \
51        fprintf (FILE, "\t.version\t\"01.01\"\n");                      \
52  } while (0)
53
54#undef STARTFILE_SPEC
55#define STARTFILE_SPEC  "%{pg:gcrt0.o%s} %{!pg:%{p:gcrt0.o%s} %{!p:crt0.o%s}} %{static:-static}"
56
57#undef TARGET_VERSION
58#define TARGET_VERSION fprintf (stderr, " (sparc GNU/Linux with a.out)");
59
60#undef SIZE_TYPE
61#define SIZE_TYPE "unsigned int"
62
63#undef PTRDIFF_TYPE
64#define PTRDIFF_TYPE "int"
65
66#undef WCHAR_TYPE
67#define WCHAR_TYPE "long int"
68
69#undef WCHAR_TYPE_SIZE
70#define WCHAR_TYPE_SIZE BITS_PER_WORD
71
72#undef CPP_PREDEFINES
73#define CPP_PREDEFINES "-Dunix -Dsparc -Dlinux -Asystem(unix) -Asystem(posix)"
74
75#undef CPP_SUBTARGET_SPEC
76#define CPP_SUBTARGET_SPEC \
77"%{fPIC:-D__PIC__ -D__pic__} %{fpic:-D__PIC__ -D__pic__} %{posix:-D_POSIX_SOURCE}"
78
79/* Don't default to pcc-struct-return, because gcc is the only compiler,
80   and we want to retain compatibility with older gcc versions.  */
81#define DEFAULT_PCC_STRUCT_RETURN 0
82
83#undef LIB_SPEC
84
85#if 1
86/* We no longer link with libc_p.a or libg.a by default. If you
87   want to profile or debug the GNU/Linux C library, please add
88   -lc_p or -ggdb to LDFLAGS at the link time, respectively.  */
89#define LIB_SPEC \
90"%{mieee-fp:-lieee} %{p:-lgmon} %{pg:-lgmon} %{!ggdb:-lc} %{ggdb:-lg}"
91#else
92#define LIB_SPEC \
93"%{mieee-fp:-lieee} %{p:-lgmon -lc_p} %{pg:-lgmon -lc_p} \
94 %{!p:%{!pg:%{!g*:-lc} %{g*:-lg -static}}}"
95#endif
96
97#undef LINK_SPEC
98#define LINK_SPEC	"-m sparclinux"
99
100/* The sun bundled assembler doesn't accept -Yd, (and neither does gas).
101   It's safe to pass -s always, even if -g is not used. */
102#undef ASM_SPEC
103#define ASM_SPEC \
104  "%{V} %{v:%{!V:-V}} %{n} %{T} %{Ym,*} %{Wa,*:%*} -s %{fpic:-K PIC} %{fPIC:-K PIC}"
105
106#if 0
107/* Define for support of TFmode long double and REAL_ARITHMETIC.
108   Sparc ABI says that long double is 4 words. GNU/Linux does not support
109   long double yet.  */
110#define LONG_DOUBLE_TYPE_SIZE 128
111#endif
112
113/* Override MACHINE_STATE_{SAVE,RESTORE} because we have special
114   traps available which can get and set the condition codes
115   reliably.  */
116#undef MACHINE_STATE_SAVE
117#define MACHINE_STATE_SAVE(ID)				\
118  unsigned long int ms_flags, ms_saveret;		\
119  asm volatile("ta	0x20\n\t"			\
120	       "mov	%%g1, %0\n\t"			\
121	       "mov	%%g2, %1\n\t"			\
122	       : "=r" (ms_flags), "=r" (ms_saveret));
123
124#undef MACHINE_STATE_RESTORE
125#define MACHINE_STATE_RESTORE(ID)			\
126  asm volatile("mov	%0, %%g1\n\t"			\
127	       "mov	%1, %%g2\n\t"			\
128	       "ta	0x21\n\t"			\
129	       : /* no outputs */			\
130	       : "r" (ms_flags), "r" (ms_saveret));
131