More cruft removal. Remove platform.h xp_debug.h xpassert.h & xp_trace.h from the build.

Replace currently unused references to XP_ASSERT with one of NS_ASSERTION & friends.
Bug #38061 r=bryner sr=alecf a=tor/drivers a=putterman/adt
This commit is contained in:
seawood%netscape.com 2002-04-02 07:57:02 +00:00
parent 318fbe638f
commit 090c63d423
14 changed files with 7 additions and 445 deletions

View File

@ -2,11 +2,6 @@
# This is a list of local files which get copied to the mozilla:dist directory
#
minicom.h
platform.h
xpassert.h
xp_debug.h
xp_mcom.h
xp_path.h
xp_str.h
xp_trace.h

View File

@ -25,7 +25,6 @@ srcdir = @srcdir@
VPATH = @srcdir@
EXPORTS = \
platform.h \
xp_path.h \
xp_str.h \
$(NULL)

View File

@ -50,7 +50,6 @@ DEPTH = ..
#INSTALL_DIR=$(XPDIST)\include
EXPORTS = \
minicom.h \
platform.h \
xp_path.h \
xp_str.h \
$(NULL)

View File

@ -1,45 +0,0 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is this file as it appears in the Mozilla source tree.
*
* The Initial Developer of the Original Code is Christopher
* Seawood. Portions created by Christopher Seawood are
* Copyright (C) 1998 Christopher Seawood. All
* Rights Reserved.
*
* Contributor(s):
*/
/* The purpose of this file is to convert various compiler defines into
* a single define for each platform. This will allow developers to
* continue to use -Dplatform WHERE NECESSARY instead of learning each
* set of compiler defines.
*/
#ifndef _platform_h
#define _platform_h
#ifdef __sun
#ifdef __SVR4
#undef SOLARIS
#define SOLARIS 1
#else
#undef SUNOS4
#define SUNOS4 1
#endif /* __SVR4 */
#endif /* __sun */
#ifdef linux
#undef LINUX
#define LINUX 1
#endif /* linux */
#endif /* _platform_h */

View File

@ -1,75 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*-----------------------------------------------------------------------------
XPUtil.h
Cross-Platform Debugging
These routines are NOT for handling expected error conditions! They are
for detecting *program logic* errors. Error conditions (such as running
out of memory) cannot be predicted at compile-time and must be handled
gracefully at run-time.
-----------------------------------------------------------------------------*/
#ifndef _XPDebug_
#define _XPDebug_
#include "xpassert.h"
#include "xp_trace.h"
/*-----------------------------------------------------------------------------
DEBUG (macro)
-----------------------------------------------------------------------------*/
#ifdef DEBUG
/*
* MSVC seems to have a problem with Debug as an int (it was probably
* previously defined as a macro).
*/
#ifdef __cplusplus
#ifndef Debug
#define Debug 1
#endif
#else
extern int Debug;
#endif
#else
#define Debug 0
#endif
#endif /* _XPDebug_ */

View File

@ -1,90 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _XP_Trace_
#define _XP_Trace_
#include <stdarg.h>
#ifdef __cplusplus
#if defined(_WINDOWS) && !defined(DEBUG)
inline void FE_Trace( const char *msg ) {} /* implemented by the platform */
inline void XP_Trace( const char *format, ... ) {}
inline void XP_Trace1( const char *format, ... ) {} /* XP_Trace without the newline */
inline void XP_TraceV( const char *msg, va_list args ) {} /* varargs XP_Trace without the newline */
#else
extern "C" void FE_Trace( const char * ); /* implemented by the platform */
extern "C" void XP_Trace( const char *, ... );
extern "C" void XP_Trace1( const char *, ... ); /* XP_Trace without the newline */
extern "C" void XP_TraceV( const char *msg, va_list args ); /* varargs XP_Trace without the newline */
#if defined(XP_MAC)
extern "C" void XP_TraceInit(void);
#endif /* XP_MAC */
#endif /* _WINDOWS && !DEBUG */
#else
void FE_Trace( const char * ); /* implemented by the platform */
void XP_Trace( const char *, ... );
void XP_Trace1( const char *, ... ); /* XP_Trace without the newline */
void XP_TraceV( const char *msg, va_list args ); /* varargs XP_Trace without the newline */
#if defined(XP_MAC)
extern void XP_TraceInit(void);
#endif
#endif /* __cplusplus */
#ifdef DEBUG
#define XP_TRACE(MESSAGE) XP_Trace MESSAGE
#define XP_TRACE1(MESSAGE) XP_Trace1 MESSAGE
#define XP_LTRACE(FLAG,LEVEL,MESSAGE) \
do { if (FLAG >= (LEVEL)) XP_Trace MESSAGE; } while (0)
#else
#define XP_TRACE(MESSAGE) ((void) (MESSAGE))
#define XP_TRACE1(MESSAGE) ((void) (MESSAGE))
#define XP_LTRACE(FLAG,LEVEL,MESSAGE) ((void) (MESSAGE))
#endif
#endif /* _XP_Trace_ */

View File

@ -1,206 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _XP_Assert_
#define _XP_Assert_
#include "prtypes.h"
#include "xp_trace.h"
/*include <stdlib.h>*/
/*-----------------------------------------------------------------------------
abort
For debug builds...
XP_ABORT(X), unlike abort(), takes a text string argument. It will print
it out and then call abort (to drop you into your debugger).
For release builds...
XP_ABORT will call abort(). Whether you #define NDEBUG or not is up
to you.
-----------------------------------------------------------------------------*/
#define XP_ABORT(MESSAGE) (XP_TRACE(MESSAGE),abort())
/*-----------------------------------------------------------------------------
XP_ASSERT is just like "assert" but calls XP_ABORT if it fails the test.
I need this (on a Mac) because "assert" and "abort" are braindead,
whereas my XP_Abort function will invoke the debugger. It could
possibly have been easier to just #define assert to be something decent.
-----------------------------------------------------------------------------*/
#if defined (XP_UNIX)
#if !defined(NO_UNIX_SKIP_ASSERTS)
/* Turning UNIX_SKIP_ASSERTS on by default. */
/* (Solaris 2.x) on Sol2.5, assert() does not work. Too bad... */
/* Therefore, we print the line where assert happened instead. */
/* Print out a \007 to sound the bell. -mcafee */
#ifdef DEBUG
#define XP_AssertAtLine() fprintf(stderr, "assert: line %d, file %s%c\n", __LINE__, __FILE__, 7)
#define XP_ASSERT(X) ( (((X))!=0)? (void)0: (void)XP_AssertAtLine() )
#else
#define XP_AssertAtLine()
#define XP_ASSERT(X) (void)0
#endif
#else
#include <assert.h>
#define XP_ASSERT(X) assert(X) /* are we having fun yet? */
#endif
#elif defined (XP_BEOS)
#ifdef DEBUG
#include <assert.h>
#define XP_ASSERT(X) assert(X)
#else
#define XP_ASSERT(X)
#endif
#elif defined (XP_WIN)
#ifdef DEBUG
/* LTNOTE: I got tired of seeing all asserts at FEGUI.CPP. This should
* Fix the problem. I intentionally left out Win16 because strings are stuffed
* into the datasegment we probably couldn't build.
*/
#ifdef WIN32
PR_BEGIN_EXTERN_C
extern void XP_AssertAtLine( char *pFileName, int iLine );
PR_END_EXTERN_C
#define XP_ASSERT(X) ( ((X)!=0)? (void)0: XP_AssertAtLine(__FILE__,__LINE__))
#else /* win16 */
#define XP_ASSERT(X) ( ((X)!=0)? (void)0: XP_Assert((X) != 0) )
PR_BEGIN_EXTERN_C
void XP_Assert(int);
PR_END_EXTERN_C
#endif
#else
#define XP_ASSERT(X) ((void) 0)
#endif
#elif defined (XP_OS2)
#ifdef DEBUG
#include <assert.h>
#define XP_ASSERT(X) assert(X) /* IBM-DAK same as UNIX */
#else
#define XP_ASSERT(X)
#endif
#elif defined(XP_MAC)
#ifdef DEBUG
#ifndef XP_ASSERT
#include <Memory.h>
#include <string.h>
/* Carbon doesn't support debugstr(), so we have to do it ourselves. Also, Carbon */
/* may have read-only strings so that we need a temp buffer to use c2pstr(). */
static StringPtr XP_c2pstrcpy(StringPtr pstr, const char* str)
{
int len = (int) strlen(str);
if (len > 255) len = 255;
pstr[0] = (unsigned char)len;
BlockMoveData(str, pstr + 1, len);
return pstr;
}
#define XP_ASSERT(X) do {if (!(X)) {Str255 pstr; DebugStr(XP_c2pstrcpy(pstr, #X));} } while (PR_FALSE)
#endif
#else
#define XP_ASSERT(X)
#endif
#endif /* XP_MAC */
/*-----------------------------------------------------------------------------
assert variants
XP_WARN_ASSERT if defined to nothing for release builds. This means
that instead of
#ifdef DEBUG
assert (X);
#endif
you can just do
XP_WARN_ASSERT(X);
Of course when asserts fail that means something is going wrong and you
*should* have normal code to deal with that.
I frequently found myself writing code like this:
#ifdef DEBUG
assert (aPtr);
#endif
if (!aPtr)
return error_something_has_gone_wrong;
so I just combined them into a macro that can be used like this:
if (XP_FAIL_ASSERT(aPtr))
return; // or whatever else you do when things go wrong
What this means is it will return if X *fails* the test. Essentially
the XP_FAIL_ASSERT bit replaces the "!" in the if test.
XP_OK_ASSERT is the opposite. If if you want to do something only if
something is OK, then use it. For example:
if (XP_OK_ASSERT(aPtr))
aPtr->aField = 25;
Use this if you are 99% sure that aPtr will be valid. If it ever is not,
you'll drop into the debugger. For release builds, it turns into an
if statement, so it's completely safe to execute.
You can also do XP_VERIFY, which essentially will throw an assert if a
condition fails in debug mode, but just do whatever at runtime. For
example:
XP_VERIFY(PR_LoadLibrary("foo") == 0);
This will trigger an XP_ASSERT if the condition fails during debug, bug
just run the PR_LoadLibrary in release. Kind of the same as XP_WARN_ASSERT,
but the "verbiage" is a bit clearer (to me, anyway).
-----------------------------------------------------------------------------*/
#ifdef DEBUG
# define XP_WARN_ASSERT(X) ( ((X)!=0)? (void)0: XP_ABORT((#X)) )
# define XP_OK_ASSERT(X) (((X)!=0)? 1: (XP_ABORT((#X)),0))
# define XP_FAIL_ASSERT(X) (((X)!=0)? 0: (XP_ABORT((#X)),1))
# define XP_VERIFY(X) ( (X)? (void)0: XP_ASSERT(0) )
#else
# define XP_WARN_ASSERT(X) (void)((X)!=0)
# define XP_OK_ASSERT(X) (((X)!=0)? 1: 0)
# define XP_FAIL_ASSERT(X) (((X)!=0)? 0: 1)
# define XP_VERIFY(X) ( (void)(X) )
#endif
#endif /* _XP_Assert_ */

View File

@ -53,9 +53,6 @@
#include <math.h>
#include "jsconfig.h"
#ifdef MOZILLA_CLIENT
#include "platform.h"
#endif
/*
* Define which platforms on which to use fdlibm. Not used

View File

@ -38,10 +38,6 @@
* OS (and machine, and compiler XXX) dependent information.
*/
#ifdef MOZILLA_CLIENT
#include "platform.h"
#endif
#ifdef XP_PC
#if defined(_WIN32) || defined (XP_OS2)

View File

@ -36,9 +36,6 @@
* PR time code.
*/
#include "jsstddef.h"
#ifdef MOZILLA_CLIENT
#include "platform.h"
#endif
#ifdef SOLARIS
#define _REENTRANT 1
#endif

View File

@ -544,7 +544,7 @@ nsresult nsMsgSearchNewsEx::SaveProfile (const char *profileName)
else if (FOLDER_CONTAINERONLY == folder->GetType())
host = ((MSG_NewsFolderInfoContainer*) folder)->GetHost();
XP_ASSERT(nsnull != host && nsnull != profileName);
NS_ABORT_IF_FALSE(nsnull != host && nsnull != profileName, "host and profileName should not be NULL");
if (nsnull != host && nsnull != profileName)
{
char *scopeString = nsnull;
@ -637,7 +637,7 @@ SEARCH_API nsresult MSG_SaveProfileStatus (MSG_Pane *searchPane, PRBool *cmdEnab
{
nsresult err = NS_OK;
XP_ASSERT(cmdEnabled);
NS_ABORT_IF_FALSE(cmdEnabled, "cmdEnabled cannot be NULL");
if (cmdEnabled)
{
*cmdEnabled = PR_FALSE;
@ -659,19 +659,17 @@ SEARCH_API nsresult MSG_SaveProfile (MSG_Pane *searchPane, const char * profileN
#ifdef _DEBUG
PRBool enabled = PR_FALSE;
MSG_SaveProfileStatus (searchPane, &enabled);
XP_ASSERT(enabled);
if (!enabled)
return SearchError_ScopeAgreement;
NS_ENSURE_TRUE(enabled, SearchError_ScopeAgreement);
#endif
if (profileName)
{
MSG_SearchFrame *frame = MSG_SearchFrame::FromPane (searchPane);
XP_ASSERT(frame);
NS_ASSERTION(frame, "frame cannot be NULL");
if (frame)
{
nsMsgSearchNewsEx *adapter = frame->GetProfileAdapter();
XP_ASSERT(adapter);
NS_ASSERTION(adapter, "adaptor cannot be NULL");
if (adapter)
err = adapter->SaveProfile (profileName);
}

View File

@ -548,7 +548,7 @@ NS_IMETHODIMP nsDBFolderInfo::ChangeNumNewMessages(PRInt32 delta)
if (m_numNewMessages < 0)
{
#ifdef DEBUG_bienvenu1
XP_ASSERT(FALSE);
NS_ASSERTION(PR_FALSE, "Hardcoded assertion");
#endif
m_numNewMessages = 0;
}

View File

@ -699,7 +699,7 @@ nsresult nsImapOfflineSync::ProcessNextOperation()
else if (folderFlags & MSG_FOLDER_FLAG_IMAPBOX)
{
// if (imapFolder->GetHasOfflineEvents())
// XP_ASSERT(PR_FALSE);
// NS_ASSERTION(PR_FALSE, "Hardcoded assertion");
if (!m_pseudoOffline) // if pseudo offline, falls through to playing ops back.
{

View File

@ -47,9 +47,6 @@
#define MAXSOCKADDR 128
#ifndef macintosh
#include "platform.h" // for SOLARIS define
#endif
#if defined(SOLARIS) || defined(_WINDOWS) || defined(IRIX)
#define socklen_t int
#endif