Skip to content

Commit

Permalink
gccxml 2007-06-27 (0066c57a)
Browse files Browse the repository at this point in the history
  • Loading branch information
GCC-XML committed Jun 27, 2007
1 parent ff8d1b3 commit 8eb1734
Show file tree
Hide file tree
Showing 16 changed files with 426 additions and 49 deletions.
46 changes: 45 additions & 1 deletion GCC/gcc/cp/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
# define XML_PRE_3_4_TREE_VIA_PUBLIC
#endif

#define GCC_XML_C_VERSION "$Revision: 1.114 $"
#define GCC_XML_C_VERSION "$Revision: 1.115 $"

/*--------------------------------------------------------------------------*/
/* Data structures for the actual XML dump. */
Expand Down Expand Up @@ -1504,6 +1504,46 @@ xml_document_add_attribute_bits(xml_document_element_p element)
xml_document_attribute_use_optional, 0);
}

/*--------------------------------------------------------------------------*/
/* Print the XML attribute befriending="..." for a function or class. */
static void
xml_print_befriending_attribute (xml_dump_info_p xdi, tree befriending)
{
int have_befriending = 0;
tree frnd;
for (frnd = befriending ; frnd && !have_befriending ;
frnd = TREE_CHAIN (frnd))
{
if(TREE_CODE (TREE_VALUE (frnd)) != TEMPLATE_DECL)
{
have_befriending = 1;
}
}
if(have_befriending)
{
const char* sep = "";
fprintf (xdi->file, " befriending=\"");
for (frnd = befriending ; frnd ; frnd = TREE_CHAIN (frnd))
{
if(TREE_CODE (TREE_VALUE (frnd)) != TEMPLATE_DECL)
{
fprintf (xdi->file,
"%s_%d", sep, xml_add_node (xdi, TREE_VALUE (frnd), 0));
sep = " ";
}
}
fprintf (xdi->file, "\"");
}
}

static void
xml_document_add_attribute_befriending(xml_document_element_p element)
{
xml_document_add_attribute(element, "befriending",
xml_document_attribute_type_idrefs,
xml_document_attribute_use_optional, 0);
}

/*--------------------------------------------------------------------------*/
/* Print XML empty tag describing an unimplemented TREE_CODE that has been
encountered. */
Expand Down Expand Up @@ -1888,6 +1928,7 @@ xml_output_function_decl (xml_dump_info_p xdi, tree fd, xml_dump_node_p dn)
xml_print_inline_attribute (xdi, fd);
xml_print_attributes_attribute (xdi, GCC_XML_DECL_ATTRIBUTES(fd),
TYPE_ATTRIBUTES(TREE_TYPE(fd)));
xml_print_befriending_attribute (xdi, DECL_BEFRIENDING_CLASSES (fd));

/* Prepare to iterator through argument list. */
arg = DECL_ARGUMENTS (fd);
Expand Down Expand Up @@ -1979,6 +2020,7 @@ xml_document_add_element_function_helper (xml_document_info_p xdi,
xml_document_add_attribute_extern(e);
xml_document_add_attribute_inline(e);
xml_document_add_attribute_attributes(e);
xml_document_add_attribute_befriending(e);
if(allow_arguments)
{
xml_document_add_element_argument (xdi, e);
Expand Down Expand Up @@ -2148,6 +2190,7 @@ xml_output_record_type (xml_dump_info_p xdi, tree rt, xml_dump_node_p dn)
xml_print_attributes_attribute (xdi, TYPE_ATTRIBUTES(rt), 0);
xml_print_size_attribute (xdi, rt);
xml_print_align_attribute (xdi, rt);
xml_print_befriending_attribute (xdi, CLASSTYPE_BEFRIENDING_CLASSES (rt));

if (dn->complete && COMPLETE_TYPE_P (rt))
{
Expand Down Expand Up @@ -2337,6 +2380,7 @@ xml_document_add_element_record_type_helper (xml_document_info_p xdi,
xml_document_add_attribute_attributes(e);
xml_document_add_attribute_size(e);
xml_document_add_attribute_align(e);
xml_document_add_attribute_befriending(e);
xml_document_add_attribute(e, "members",
xml_document_attribute_type_idrefs,
xml_document_attribute_use_optional, 0);
Expand Down
16 changes: 10 additions & 6 deletions GCC_XML/KWSys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -395,17 +395,17 @@ ELSE(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
ENDIF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_OBJECTS
"Checking whether stl containers support allocator objects." DIRECT)
IF(KWSYS_IOS_USE_ANSI)
IF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
# ANSI streams always have string operators.
SET(KWSYS_STL_STRING_HAVE_OSTREAM 1)
SET(KWSYS_STL_STRING_HAVE_ISTREAM 1)
ELSE(KWSYS_IOS_USE_ANSI)
ELSE(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
# There may not be string operators for old streams.
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_OSTREAM
"Checking whether stl string has ostream operator<<" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_ISTREAM
"Checking whether stl string has istream operator>>" DIRECT)
ENDIF(KWSYS_IOS_USE_ANSI)
ENDIF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)

KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS
Expand Down Expand Up @@ -872,9 +872,13 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
ENDFOREACH(test)

# C++ tests
SET(KWSYS_CXX_TESTS
testAutoPtr
testHashSTL
IF(NOT WATCOM)
SET(KWSYS_CXX_TESTS
testAutoPtr
testHashSTL
)
ENDIF(NOT WATCOM)
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
testRegistry
testIOS
testSystemTools
Expand Down
49 changes: 30 additions & 19 deletions GCC_XML/KWSys/DynamicLoader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@
// (default) Each part of the ifdef contains a complete implementation for
// the static methods of DynamicLoader.

namespace KWSYS_NAMESPACE
{

//----------------------------------------------------------------------------
DynamicLoader::DynamicLoader()
{
}

//----------------------------------------------------------------------------
DynamicLoader::~DynamicLoader()
{
}

}

// ---------------------------------------------------------------
// 1. Implementation for HPUX machines
#ifdef __hpux
Expand Down Expand Up @@ -251,13 +236,35 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
DynamicLoader::LibraryHandle lib, const char* sym)
{
// TODO: The calling convention affects the name of the symbol. We
// should have a tool to help get the symbol with the desired
// calling convention. Currently we assume cdecl.
//
// Borland:
// __cdecl = "_func" (default)
// __fastcall = "@_func"
// __stdcall = "func"
//
// Watcom:
// __cdecl = "_func"
// __fastcall = "@_func@X"
// __stdcall = "_func@X"
// __watcall = "func_" (default)
//
// MSVC:
// __cdecl = "func" (default)
// __fastcall = "@_func@X"
// __stdcall = "_func@X"
//
// Note that the "@X" part of the name above is the total size (in
// bytes) of the arguments on the stack.
void *result;
#ifdef __BORLANDC__
// Need to prepend symbols with '_' on borland compilers
#if defined(__BORLANDC__) || defined(__WATCOMC__)
// Need to prepend symbols with '_'
size_t len = strlen(sym);
char *rsym = new char[len + 1 + 1];
strcpy(rsym, "_");
strcat(rsym+1, sym);
strcat(rsym, sym);
#else
const char *rsym = sym;
#endif
Expand All @@ -268,11 +275,15 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
#else
result = (void*)GetProcAddress(lib, rsym);
#endif
#ifdef __BORLANDC__
#if defined(__BORLANDC__) || defined(__WATCOMC__)
delete[] rsym;
#endif
// Hack to cast pointer-to-data to pointer-to-function.
#ifdef __WATCOMC__
return *(DynamicLoader::SymbolPointer*)(&result);
#else
return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
#endif
}

//----------------------------------------------------------------------------
Expand Down
3 changes: 0 additions & 3 deletions GCC_XML/KWSys/DynamicLoader.hxx.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ public:
// Return type from DynamicLoader::GetSymbolAddress.
typedef void (*SymbolPointer)();

DynamicLoader();
~DynamicLoader();

/** Load a dynamic library into the current process.
* The returned LibraryHandle can be used to access the symbols in the
* library. */
Expand Down
20 changes: 16 additions & 4 deletions GCC_XML/KWSys/EncodeExecutable.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ int main(int argc, char* argv[])
fprintf(ofp, "#include \"kwsysPrivate.h\"\n");
fprintf(ofp, "#include KWSYS_HEADER(Configure.h)\n\n");
fprintf(ofp, "#include <stdio.h>\n\n");
fprintf(ofp, "#if defined(_WIN32)\n");
fprintf(ofp, "# include <io.h>\n");
fprintf(ofp, "#else\n");
fprintf(ofp, "# include <unistd.h>\n");
fprintf(ofp, "#endif\n");
fprintf(ofp, "\n");
fprintf(ofp, "static void kwsys_unlink(const char* fname)\n");
fprintf(ofp, "{\n");
fprintf(ofp, "#if defined(__WATCOMC__)\n");
fprintf(ofp, " unlink(fname);\n");
fprintf(ofp, "#else\n");
fprintf(ofp, " _unlink(fname);\n");
fprintf(ofp, "#endif\n");
fprintf(ofp, "}\n");
fprintf(ofp, "\n");

/* Split file up in 1024-byte chunks. */
while((n = (int)fread(buffer, 1, 1024, ifp)) > 0)
Expand All @@ -78,9 +93,6 @@ int main(int argc, char* argv[])
fprintf(ofp, "extern %s_EXPORT int %sEncodedWriteArray%s(const char* fname)\n",
argv[3], argv[3], argv[4]);
fprintf(ofp, "{\n");
fprintf(ofp, "#ifdef __WATCOMC__\n");
fprintf(ofp, "#define _unlink unlink\n");
fprintf(ofp, "#endif\n");
fprintf(ofp, " FILE* ofp = fopen(fname, \"wb\");\n");
fprintf(ofp, " if(!ofp) { return 0; }\n");
for(i=0; i < count; ++i)
Expand All @@ -91,7 +103,7 @@ int main(int argc, char* argv[])
argv[4], i, argv[4], i, argv[4], i);
fprintf(ofp, " {\n");
fprintf(ofp, " fclose(ofp);\n");
fprintf(ofp, " _unlink(fname);\n");
fprintf(ofp, " kwsys_unlink(fname);\n");
fprintf(ofp, " return 0;\n");
fprintf(ofp, " }\n");
}
Expand Down
24 changes: 16 additions & 8 deletions GCC_XML/KWSys/ProcessUNIX.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ static inline void kwsysProcess_usleep(unsigned int msec)
# define KWSYSPE_USE_SELECT 1
#endif

/* BeOS does not have siginfo on its signal handlers. */
#if !defined(__BEOS__)
/* Some platforms do not have siginfo on their signal handlers. */
#if defined(SA_SIGINFO) && !defined(__BEOS__)
# define KWSYSPE_USE_SIGINFO 1
#endif

Expand Down Expand Up @@ -2227,6 +2227,12 @@ static void kwsysProcessRestoreDefaultSignalHandlers(void)
#endif
}

/*--------------------------------------------------------------------------*/
static void kwsysProcessExit(void)
{
_exit(0);
}

/*--------------------------------------------------------------------------*/
static pid_t kwsysProcessFork(kwsysProcess* cp,
kwsysProcessCreateInformation* si)
Expand Down Expand Up @@ -2257,7 +2263,7 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
(errno == EINTR));

/* Exit without cleanup. The parent holds all resources. */
_exit(0);
kwsysProcessExit();
return 0; /* Never reached, but avoids SunCC warning. */
}
}
Expand Down Expand Up @@ -2306,8 +2312,13 @@ static void kwsysProcessKill(pid_t process_id)
DIR* procdir;
#endif

/* Suspend the process to be sure it will not create more children. */
kill(process_id, SIGSTOP);
/* Kill the process now to make sure it does not create more
children. Do not reap it yet so we can identify its existing
children. There is a small race condition here. If the child
forks after we begin looking for children below but before it
receives this kill signal we might miss a child. Also we might
not be able to catch up to a fork bomb. */
kill(process_id, SIGKILL);

/* Kill all children if we can find them. */
#if defined(__linux__) || defined(__CYGWIN__)
Expand Down Expand Up @@ -2395,9 +2406,6 @@ static void kwsysProcessKill(pid_t process_id)
}
#endif
}

/* Kill the process. */
kill(process_id, SIGKILL);
}

/*--------------------------------------------------------------------------*/
Expand Down
Loading

0 comments on commit 8eb1734

Please sign in to comment.