aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/CBackend
diff options
context:
space:
mode:
authorJoel Stanley <jstanley@cs.uiuc.edu>2003-02-12 20:45:00 +0000
committerJoel Stanley <jstanley@cs.uiuc.edu>2003-02-12 20:45:00 +0000
commitecd78ac1cb0f31a6a206eb82dff25eac249309fc (patch)
tree3e008ea1dc889d34a75c7787e7c8c17558005db3 /lib/Target/CBackend
parent98d829c22fe836de0e1e6491aeecbda7217ae05e (diff)
downloadexternal_llvm-ecd78ac1cb0f31a6a206eb82dff25eac249309fc.zip
external_llvm-ecd78ac1cb0f31a6a206eb82dff25eac249309fc.tar.gz
external_llvm-ecd78ac1cb0f31a6a206eb82dff25eac249309fc.tar.bz2
Fixed alloca declaration problem on sun.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5546 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/CBackend')
-rw-r--r--lib/Target/CBackend/CBackend.cpp27
-rw-r--r--lib/Target/CBackend/Writer.cpp27
2 files changed, 38 insertions, 16 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 8d9b314..88e0a26 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/lib/Target/CBackend/CBackend.cpp
@@ -504,6 +504,17 @@ bool CWriter::nameAllUsedStructureTypes(Module &M) {
return Changed;
}
+static void generateAllocaDecl(ostream& Out)
+{
+ // On SunOS, we need to insert the alloca macro & proto for the builtin.
+ Out << "#ifdef sun\n"
+ << "extern void *__builtin_alloca(unsigned long);\n"
+ << "#define alloca(x) __builtin_alloca(x)\n"
+ << "#else\n"
+ << "#include <alloca.h>\n"
+ << "#endif\n\n";
+}
+
void CWriter::printModule(Module *M) {
// Calculate which global values have names that will collide when we throw
// away type information.
@@ -528,18 +539,18 @@ void CWriter::printModule(Module *M) {
//Out << "#include <stdlib.h>\n";
// get declaration for alloca
- Out << "/* Provide Declarations */\n"
- << "#include <alloca.h>\n\n"
-
- // Provide a definition for null if one does not already exist,
- // and for `bool' if not compiling with a C++ compiler.
- << "#ifndef NULL\n#define NULL 0\n#endif\n\n"
+ Out << "/* Provide Declarations */\n";
+ generateAllocaDecl(Out);
+
+ // Provide a definition for null if one does not already exist,
+ // and for `bool' if not compiling with a C++ compiler.
+ Out << "#ifndef NULL\n#define NULL 0\n#endif\n\n"
<< "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n"
-
+
<< "\n\n/* Support for floating point constants */\n"
<< "typedef unsigned long long ConstantDoubleTy;\n"
<< "typedef unsigned int ConstantFloatTy;\n"
-
+
<< "\n\n/* Global Declarations */\n";
// First output all the declarations for the program, because C requires
diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp
index 8d9b314..88e0a26 100644
--- a/lib/Target/CBackend/Writer.cpp
+++ b/lib/Target/CBackend/Writer.cpp
@@ -504,6 +504,17 @@ bool CWriter::nameAllUsedStructureTypes(Module &M) {
return Changed;
}
+static void generateAllocaDecl(ostream& Out)
+{
+ // On SunOS, we need to insert the alloca macro & proto for the builtin.
+ Out << "#ifdef sun\n"
+ << "extern void *__builtin_alloca(unsigned long);\n"
+ << "#define alloca(x) __builtin_alloca(x)\n"
+ << "#else\n"
+ << "#include <alloca.h>\n"
+ << "#endif\n\n";
+}
+
void CWriter::printModule(Module *M) {
// Calculate which global values have names that will collide when we throw
// away type information.
@@ -528,18 +539,18 @@ void CWriter::printModule(Module *M) {
//Out << "#include <stdlib.h>\n";
// get declaration for alloca
- Out << "/* Provide Declarations */\n"
- << "#include <alloca.h>\n\n"
-
- // Provide a definition for null if one does not already exist,
- // and for `bool' if not compiling with a C++ compiler.
- << "#ifndef NULL\n#define NULL 0\n#endif\n\n"
+ Out << "/* Provide Declarations */\n";
+ generateAllocaDecl(Out);
+
+ // Provide a definition for null if one does not already exist,
+ // and for `bool' if not compiling with a C++ compiler.
+ Out << "#ifndef NULL\n#define NULL 0\n#endif\n\n"
<< "#ifndef __cplusplus\ntypedef unsigned char bool;\n#endif\n"
-
+
<< "\n\n/* Support for floating point constants */\n"
<< "typedef unsigned long long ConstantDoubleTy;\n"
<< "typedef unsigned int ConstantFloatTy;\n"
-
+
<< "\n\n/* Global Declarations */\n";
// First output all the declarations for the program, because C requires