Bug 340443 - Not possible to use the XPCOM glue with the static CRT, r=neil sr=darin

This commit is contained in:
benjamin%smedbergs.us 2006-09-12 18:22:40 +00:00
Родитель b93c1412be
Коммит f8b7089d8a
5 изменённых файлов: 47 добавлений и 6 удалений

Просмотреть файл

@ -31,3 +31,4 @@ s/JS_NewDHashTable/PL_NewDHashTable/
s/JS_ASSERT(0)/NS_NOTREACHED("0")/
s/\( *\)JS_ASSERT(\(.*\));/\1NS_ASSERTION(\2,\n\1 "\2");/
s/JS_/PR_/g
s/fprintf(stderr,/printf_stderr(/

Просмотреть файл

@ -40,7 +40,11 @@
#include "nsCRTGlue.h"
#include "nsXPCOM.h"
#include "nsDebug.h"
#include <string.h>
#include <stdio.h>
#include <io.h>
#include <stdarg.h>
const char*
NS_strspnp(const char *delims, const char *str)
@ -258,3 +262,27 @@ PRBool NS_IsAsciiDigit(PRUnichar aChar)
{
return aChar >= '0' && aChar <= '9';
}
#ifdef XP_WIN
void
printf_stderr(const char *fmt, ...)
{
FILE *fp = _fdopen(_dup(2), "a");
va_list args;
va_start(args, fmt);
vfprintf(fp, fmt, args);
va_end(args);
fclose(fp);
}
#else
void
printf_stderr(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
}
#endif

Просмотреть файл

@ -243,4 +243,16 @@
NS_ASSERTION(owningThread == PR_GetCurrentThread(), msg)
#endif
/* When compiling the XPCOM Glue on Windows, we pretend that it's going to
* be linked with a static CRT (-MT) even when it's not. This means that we
* cannot link to data exports from the CRT, only function exports. So,
* instead of referencing "stderr" directly, use fdopen.
*/
PR_BEGIN_EXTERN_C
void
printf_stderr(const char *fmt, ...);
PR_END_EXTERN_C
#endif /* nsDebug_h___ */

Просмотреть файл

@ -390,7 +390,7 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
nsresult rv = NS_OK;
#ifdef DEBUG
fprintf(stderr, "*** Registering %s components (all right -- a generic module!)\n", mModuleName);
printf_stderr("*** Registering %s components (all right -- a generic module!)\n", mModuleName);
#endif
const nsModuleComponentInfo* cp = mComponents;
@ -407,7 +407,7 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
componentType);
if (NS_FAILED(rv)) {
#ifdef DEBUG
fprintf(stderr, "nsGenericModule %s: unable to register %s component => %x\n",
printf_stderr("nsGenericModule %s: unable to register %s component => %x\n",
mModuleName?mModuleName:"(null)", cp->mDescription?cp->mDescription:"(null)", rv);
#endif
break;
@ -420,7 +420,7 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
componentType, cp);
if (NS_FAILED(rv)) {
#ifdef DEBUG
fprintf(stderr, "nsGenericModule %s: Register hook for %s component returned error => %x\n",
printf_stderr("nsGenericModule %s: Register hook for %s component returned error => %x\n",
mModuleName?mModuleName:"(null)", cp->mDescription?cp->mDescription:"(null)", rv);
#endif
break;
@ -438,7 +438,7 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
const char* registryLocation)
{
#ifdef DEBUG
fprintf(stderr, "*** Unregistering %s components (all right -- a generic module!)\n", mModuleName);
printf_stderr("*** Unregistering %s components (all right -- a generic module!)\n", mModuleName);
#endif
const nsModuleComponentInfo* cp = mComponents;
for (PRUint32 i = 0; i < mComponentCount; i++) {
@ -455,7 +455,7 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
rv = registrar->UnregisterFactoryLocation(cp->mCID, aPath);
if (NS_FAILED(rv)) {
#ifdef DEBUG
fprintf(stderr, "nsGenericModule %s: unable to unregister %s component => %x\n",
printf_stderr("nsGenericModule %s: unable to unregister %s component => %x\n",
mModuleName, cp->mDescription, rv);
#endif
}

Просмотреть файл

@ -221,7 +221,7 @@ PL_DHashTableInit(PLDHashTable *table, const PLDHashTableOps *ops, void *data,
#ifdef DEBUG
if (entrySize > 10 * sizeof(void *)) {
fprintf(stderr,
printf_stderr(
"pldhash: for the table at address %p, the given entrySize"
" of %lu %s favors chaining over double hashing.\n",
(void *)table,