提交 2db7eea6 编写于 作者: O ohair

7197771: Adjust jdk sources to avoid use of implementation defined value of __FILE__

7180608: Sort the order of object files when building shared libraries
Reviewed-by: ohrstrom, erikj, tbell
上级 0070da84
......@@ -542,6 +542,21 @@ CFLAGS_$(VARIANT)/BYFILE = $(CFLAGS_$(VARIANT)/$(@F)) \
CXXFLAGS_$(VARIANT)/BYFILE = $(CXXFLAGS_$(VARIANT)/$(@F)) \
$(CXXFLAGS_$(VARIANT)$(CXXFLAGS_$(VARIANT)/$(@F)))
# Command line define to provide basename of file being compiled to source.
# The C macro THIS_FILE can replace the use of __FILE__ in the source
# files for the current filename being compiled.
# The value of the __FILE__ macro is unpredictable and can be anything
# from a relative path to a full path, THIS_FILE will be more consistent..
# The THIS_FILE macro will always be just the basename of the file being
# compiled.
# Different string literals in the the object files makes it difficult to
# compare shared libraries from different builds.
#
# NOTE: If the THIS_FILE macro is actually expanded while in an included
# source file, it will not return the name of the included file.
#
CPP_THIS_FILE = -DTHIS_FILE='"$(<F)"'
#
# Tool flags
#
......@@ -551,7 +566,7 @@ ASFLAGS = $(ASFLAGS_$(VARIANT)) $(ASFLAGS_COMMON) $(OTHER_ASFLAGS)
CFLAGS = $(CFLAGS_$(VARIANT)/BYFILE) $(CFLAGS_COMMON) $(OTHER_CFLAGS) $(EXTRA_CFLAGS)
CXXFLAGS = $(CXXFLAGS_$(VARIANT)/BYFILE) $(CXXFLAGS_COMMON) $(OTHER_CXXFLAGS) $(EXTRA_CFLAGS)
CPPFLAGS = $(CPPFLAGS_$(VARIANT)) $(CPPFLAGS_COMMON) $(OTHER_CPPFLAGS) \
$(DEFINES) $(OPTIONS:%=-D%)
$(DEFINES) $(OPTIONS:%=-D%) $(CPP_THIS_FILE)
LDFLAGS = $(LDFLAGS_$(VARIANT)) $(LDFLAGS_COMMON) $(OTHER_LDFLAGS)
LDLIBS = $(OTHER_LDLIBS) $(LDLIBS_$(VARIANT)) $(LDLIBS_COMMON)
LINTFLAGS = $(LINTFLAGS_$(VARIANT)) $(LINTFLAGS_COMMON) \
......
......@@ -320,10 +320,10 @@ $(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS)
ifeq ($(PLATFORM),windows)
$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE)
$(LINK.demo) $(SHARED_LIBRARY_FLAG) -Fe$@ \
$(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
$(sort $(DEMO_FULL_OBJECTS)) $(LDLIBS.demo)
else
$(LINK.demo) $(SHARED_LIBRARY_FLAG) -o $@ \
$(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
$(sort $(DEMO_FULL_OBJECTS)) $(LDLIBS.demo)
endif
@$(call binary_file_verification,$@)
......
......@@ -199,7 +199,7 @@ endif # LIBRARY
$(OBJDIR)/$(LIBRARY).lcf: $(OBJDIR)/$(LIBRARY).res $(COMPILE_FILES_o) $(FILES_m)
@$(prep-target)
@$(MKDIR) -p $(TEMPDIR)
@$(ECHO) $(FILES_o) > $@
@$(ECHO) $(sort $(FILES_o)) > $@
ifndef LOCAL_RESOURCE_FILE
@$(ECHO) $(OBJDIR)/$(LIBRARY).res >> $@
endif
......@@ -256,9 +256,9 @@ $(ACTUAL_LIBRARY):: $(COMPILE_FILES_o) $(FILES_m) $(FILES_reorder)
@$(ECHO) "STATS: LIBRARY=$(LIBRARY), PRODUCT=$(PRODUCT), OPTIMIZATION_LEVEL=$(OPTIMIZATION_LEVEL)"
@$(ECHO) "Rebuilding $@ because of $?"
ifeq ($(LIBRARY), fdlibm)
$(AR) $(ARFLAGS) $@ $(FILES_o)
$(AR) $(ARFLAGS) $@ $(sort $(FILES_o))
else # LIBRARY
$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(FILES_o) $(LDLIBS)
$(LINKER) $(SHARED_LIBRARY_FLAG) -o $@ $(sort $(FILES_o)) $(LDLIBS)
@$(call binary_file_verification,$@)
ifeq ($(WRITE_LIBVERSION),true)
$(MCS) -d -a "$(FULL_VERSION)" $@
......
......@@ -242,7 +242,7 @@ else
$(ECHO) Rebuilding $@ because of $$1 $$2 $$3 $$4 $$5 $$6 $${7:+...};
@$(MKDIR) -p $(TEMPDIR)
$(LINK_PRE_CMD) $(CC) $(CC_OBJECT_OUTPUT_FLAG)$@ $(LDFLAGS) \
$(FILES_o) $(THREADLIBS) $(LDLIBS)
$(sort $(FILES_o)) $(THREADLIBS) $(LDLIBS)
ifeq ($(findstring privileged, $(INFO_PLIST_FILE)), privileged)
-codesign -s openjdk_codesign $@
endif
......@@ -372,8 +372,6 @@ VERSION_DEFINES += -DFULL_VERSION='"$(FULL_VERSION)"'
VERSION_DEFINES += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
-DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"'
$(OBJDIR)/main.$(OBJECT_SUFFIX): $(LAUNCHER_SHARE_SRC)/bin/main.c
@$(prep-target)
$(COMPILE.c) $(CC_OBJECT_OUTPUT_FLAG)$(OBJDIR)/main.$(OBJECT_SUFFIX) \
......
......@@ -37,7 +37,11 @@
#import "ThreadUtilities.h"
#import "CMenuBar.h"
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
static JNF_CLASS_CACHE(sjc_ScreenMenu, "com/apple/laf/ScreenMenu");
static jint ns2awtModifiers(NSUInteger keyMods) {
......@@ -97,7 +101,7 @@ static jint ns2awtMouseButton(NSInteger mouseButton) {
{
if (self.javaObjectWrapper == nil) {
#ifdef DEBUG
NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
#endif
return;
}
......@@ -115,7 +119,7 @@ JNF_COCOA_EXIT(env);
{
if (self.javaObjectWrapper == nil) {
#ifdef DEBUG
NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
#endif
return;
}
......@@ -133,7 +137,7 @@ JNF_COCOA_EXIT(env);
{
if (self.javaObjectWrapper == nil) {
#ifdef DEBUG
NSLog(@"_javaObject is NULL: (%s - %s : %d)", __FILE__, __FUNCTION__, __LINE__);
NSLog(@"_javaObject is NULL: (%s - %s : %d)", THIS_FILE, __FUNCTION__, __LINE__);
#endif
return;
}
......
......@@ -26,6 +26,11 @@
//#define USE_ERROR
//#define USE_TRACE
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#if USE_PLATFORM_MIDI_OUT == TRUE
#include "PLATFORM_API_MacOSX_MidiUtils.h"
......@@ -128,7 +133,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT
case 0xF7:
// System exclusive
fprintf(stderr, "%s: %d->internal error: sysex message status=0x%X while sending short message\n",
__FILE__, __LINE__, data[0]);
THIS_FILE, __LINE__, data[0]);
byteIsInvalid = TRUE;
break;
......@@ -154,7 +159,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT
default:
// Invalid message
fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
__FILE__, __LINE__, data[0]);
THIS_FILE, __LINE__, data[0]);
byteIsInvalid = TRUE;
break;
}
......@@ -164,7 +169,7 @@ INT32 MIDI_OUT_SendShortMessage(MidiDeviceHandle* handle, UINT32 packedMsg, UINT
default:
// This can't happen, but handle it anyway.
fprintf(stderr, "%s: %d->Invalid message: message status=0x%X while sending short message\n",
__FILE__, __LINE__, data[0]);
THIS_FILE, __LINE__, data[0]);
byteIsInvalid = TRUE;
break;
}
......
......@@ -42,6 +42,11 @@
//#define USE_ERROR
//#define USE_TRACE
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#if (USE_PLATFORM_MIDI_IN == TRUE) || (USE_PLATFORM_MIDI_OUT == TRUE)
#include "PLATFORM_API_MacOSX_MidiUtils.h"
......@@ -317,7 +322,7 @@ static void processMessagesForPacket(const MIDIPacket* packet, MacMidiDeviceHand
packedMsg = pendingMessageStatus | pendingData[0] << 8;
} else {
fprintf(stderr, "%s: %d->internal error: pendingMessageStatus=0x%X, pendingDataLength=%d\n",
__FILE__, __LINE__, pendingMessageStatus, pendingDataLength);
THIS_FILE, __LINE__, pendingMessageStatus, pendingDataLength);
byteIsInvalid = TRUE;
}
pendingDataLength = 0;
......
......@@ -33,6 +33,11 @@
#import "ThreadUtilities.h"
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
NSColor **sColors = nil;
NSColor **appleColors = nil;
......@@ -130,7 +135,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_systemColorsChanged, jc_LWCToolkit, "systemCol
result = (useAppleColor ? appleColors : sColors)[colorIndex];
}
else {
NSLog(@"%s: %s %sColor: %ld not found, returning black.", __FILE__, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
NSLog(@"%s: %s %sColor: %ld not found, returning black.", THIS_FILE, __FUNCTION__, (useAppleColor) ? "Apple" : "System", colorIndex);
result = [NSColor blackColor];
}
......
......@@ -36,6 +36,10 @@
#import "QuartzSurfaceData.h"
#include "AWTStrike.h"
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
static const CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
......@@ -488,7 +492,7 @@ static inline void doDrawGlyphsPipe_getGlyphVectorLengthAndAlloc
if (glyphs == NULL || advances == NULL)
{
(*env)->DeleteLocalRef(env, glyphsArray);
[NSException raise:NSMallocException format:@"%s-%s:%d", __FILE__, __FUNCTION__, __LINE__];
[NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__];
return;
}
......
......@@ -33,6 +33,11 @@
#import "CoreTextSupport.h"
//#import "jni_util.h"
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
@implementation AWTStrike
static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
......@@ -102,7 +107,7 @@ static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
#define AWT_FONT_CLEANUP_FINISH \
if (_fontThrowJavaException == YES) { \
char s[512]; \
sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__); \
sprintf(s, "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__); \
[JNFException raise:env as:kRuntimeException reason:s]; \
}
......
......@@ -42,31 +42,36 @@ const char * jvmtiErrorText(jvmtiError);
const char * eventText(int);
const char * jdwpErrorText(jdwpError);
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#define EXIT_ERROR(error,msg) \
{ \
print_message(stderr, "JDWP exit error ", "\n", \
"%s(%d): %s [%s:%d]", \
jvmtiErrorText((jvmtiError)error), error, (msg==NULL?"":msg), \
__FILE__, __LINE__); \
THIS_FILE, __LINE__); \
debugInit_exit((jvmtiError)error, msg); \
}
#define JDI_ASSERT(expression) \
do { \
if (gdata && gdata->assertOn && !(expression)) { \
jdiAssertionFailed(__FILE__, __LINE__, #expression); \
jdiAssertionFailed(THIS_FILE, __LINE__, #expression); \
} \
} while (0)
#define JDI_ASSERT_MSG(expression, msg) \
do { \
if (gdata && gdata->assertOn && !(expression)) { \
jdiAssertionFailed(__FILE__, __LINE__, msg); \
jdiAssertionFailed(THIS_FILE, __LINE__, msg); \
} \
} while (0)
#define JDI_ASSERT_FAILED(msg) \
jdiAssertionFailed(__FILE__, __LINE__, msg)
jdiAssertionFailed(THIS_FILE, __LINE__, msg)
void do_pause(void);
......
......@@ -33,11 +33,15 @@ void finish_logging(int);
#define LOG_NULL ((void)0)
#ifdef JDWP_LOGGING
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#ifdef JDWP_LOGGING
#define _LOG(flavor,args) \
(log_message_begin(flavor,__FILE__,__LINE__), \
(log_message_begin(flavor,THIS_FILE,__LINE__), \
log_message_end args)
#define LOG_TEST(flag) (gdata->log_flags & (flag))
......
......@@ -59,6 +59,11 @@
#include <stdlib.h>
#include <string.h>
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
/* The real functions behind the macro curtains. */
void *debug_malloc(size_t, const char *, int);
......@@ -71,10 +76,10 @@ void debug_free(void *, const char *, int);
void debug_malloc_verify(const char*, int);
#undef malloc_verify
#define malloc_verify() debug_malloc_verify(__FILE__, __LINE__)
#define malloc_verify() debug_malloc_verify(THIS_FILE, __LINE__)
void debug_malloc_police(const char*, int);
#undef malloc_police
#define malloc_police() debug_malloc_police(__FILE__, __LINE__)
#define malloc_police() debug_malloc_police(THIS_FILE, __LINE__)
#endif
......@@ -41,20 +41,25 @@
#ifndef HPROF_ERROR_H
#define HPROF_ERROR_H
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
/* Macros over assert and error functions so we can capture the source loc. */
#define HPROF_BOOL(x) ((jboolean)((x)==0?JNI_FALSE:JNI_TRUE))
#define HPROF_ERROR(fatal,msg) \
error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, __FILE__, __LINE__)
error_handler(HPROF_BOOL(fatal), JVMTI_ERROR_NONE, msg, THIS_FILE, __LINE__)
#define HPROF_JVMTI_ERROR(error,msg) \
error_handler(HPROF_BOOL(error!=JVMTI_ERROR_NONE), \
error, msg, __FILE__, __LINE__)
error, msg, THIS_FILE, __LINE__)
#if defined(DEBUG) || !defined(NDEBUG)
#define HPROF_ASSERT(cond) \
(((int)(cond))?(void)0:error_assert(#cond, __FILE__, __LINE__))
(((int)(cond))?(void)0:error_assert(#cond, THIS_FILE, __LINE__))
#else
#define HPROF_ASSERT(cond)
#endif
......@@ -77,11 +82,11 @@
#define LOG_FORMAT(format) "HPROF LOG: " format " [%s:%d]\n"
#define LOG1(str1) LOG_STDERR((stderr, LOG_FORMAT("%s"), \
str1, __FILE__, __LINE__ ))
str1, THIS_FILE, __LINE__ ))
#define LOG2(str1,str2) LOG_STDERR((stderr, LOG_FORMAT("%s %s"), \
str1, str2, __FILE__, __LINE__ ))
str1, str2, THIS_FILE, __LINE__ ))
#define LOG3(str1,str2,num) LOG_STDERR((stderr, LOG_FORMAT("%s %s 0x%x"), \
str1, str2, num, __FILE__, __LINE__ ))
str1, str2, num, THIS_FILE, __LINE__ ))
#define LOG(str) LOG1(str)
......
......@@ -41,6 +41,11 @@
#ifndef HPROF_UTIL_H
#define HPROF_UTIL_H
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
/* Macros that protect code from accidently using a local ref improperly */
#define WITH_LOCAL_REFS(env, number) \
{ \
......@@ -184,8 +189,8 @@ void hprof_free(void *ptr);
#ifdef DEBUG
void * hprof_debug_malloc(int size, char *file, int line);
void hprof_debug_free(void *ptr, char *file, int line);
#define HPROF_MALLOC(size) hprof_debug_malloc(size, __FILE__, __LINE__)
#define HPROF_FREE(ptr) hprof_debug_free(ptr, __FILE__, __LINE__)
#define HPROF_MALLOC(size) hprof_debug_malloc(size, THIS_FILE, __LINE__)
#define HPROF_FREE(ptr) hprof_debug_free(ptr, THIS_FILE, __LINE__)
#else
#define HPROF_MALLOC(size) hprof_malloc(size)
#define HPROF_FREE(ptr) hprof_free(ptr)
......
......@@ -70,12 +70,20 @@
/* Macros over error functions to capture line numbers */
#define CRW_FATAL(ci, message) fatal_error(ci, message, __FILE__, __LINE__)
/* Fatal error used in all builds. */
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE "java_crw.demo.c" /* Never use __FILE__ */
#endif
#define CRW_FATAL(ci, message) fatal_error(ci, message, THIS_FILE, __LINE__)
#if defined(DEBUG) || !defined(NDEBUG)
/* This assert macro is only used in the debug builds. */
#define CRW_ASSERT(ci, cond) \
((cond)?(void)0:assert_error(ci, #cond, __FILE__, __LINE__))
((cond)?(void)0:assert_error(ci, #cond, THIS_FILE, __LINE__))
#else
......
......@@ -49,10 +49,14 @@ extern "C" {
#define JPLISASSERT_ENABLEASSERTIONS (0)
#endif
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#if JPLISASSERT_ENABLEASSERTIONS
#define jplis_assert(x) JPLISAssertCondition((jboolean)(x), #x, __FILE__, __LINE__)
#define jplis_assert_msg(x, msg) JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, __FILE__, __LINE__)
#define jplis_assert(x) JPLISAssertCondition((jboolean)(x), #x, THIS_FILE, __LINE__)
#define jplis_assert_msg(x, msg) JPLISAssertConditionWithMessage((jboolean)(x), #x, msg, THIS_FILE, __LINE__)
#else
#define jplis_assert(x)
#define jplis_assert_msg(x, msg)
......
......@@ -32,17 +32,22 @@ extern "C" {
#include "debug_util.h"
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#if defined(DEBUG)
#define DASSERT(_expr) \
if ( !(_expr) ) { \
DAssert_Impl( #_expr, __FILE__, __LINE__); \
DAssert_Impl( #_expr, THIS_FILE, __LINE__); \
} else { \
}
#define DASSERTMSG(_expr, _msg) \
if ( !(_expr) ) { \
DAssert_Impl( (_msg), __FILE__, __LINE__); \
DAssert_Impl( (_msg), THIS_FILE, __LINE__); \
} else { \
}
......
......@@ -27,6 +27,11 @@
#include "debug_util.h"
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#define DMEM_MIN(a,b) (a) < (b) ? (a) : (b)
#define DMEM_MAX(a,b) (a) > (b) ? (a) : (b)
......@@ -291,7 +296,7 @@ void DMem_ReportLeaks() {
DMutex_Enter(DMemMutex);
/* Force memory leaks to be output regardless of trace settings */
DTrace_EnableFile(__FILE__, TRUE);
DTrace_EnableFile(THIS_FILE, TRUE);
DTRACE_PRINTLN("--------------------------");
DTRACE_PRINTLN("Debug Memory Manager Leaks");
DTRACE_PRINTLN("--------------------------");
......
......@@ -34,6 +34,11 @@ extern "C" {
#include "debug_util.h"
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
typedef int dtrace_id;
enum {
UNDEFINED_TRACE_ID = -1 /* indicates trace point has not been registered yet */
......@@ -69,7 +74,7 @@ static dtrace_id _Dt_FileTraceId = UNDEFINED_TRACE_ID;
#define _DTrace_Template(_func, _ac, _f, _a1, _a2, _a3, _a4, _a5, _a6, _a7, _a8) \
{ \
static dtrace_id _dt_lineid_ = UNDEFINED_TRACE_ID; \
DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, __FILE__, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
DTrace_PrintFunction((_func), &_Dt_FileTraceId, &_dt_lineid_, THIS_FILE, __LINE__, (_ac), (_f), (_a1), (_a2), (_a3), (_a4), (_a5), (_a6), (_a7), (_a8) ); \
}
/* printf style trace macros */
......
......@@ -452,7 +452,12 @@ extern CK_C_INITIALIZE_ARGS_PTR ckpGlobalInitArgs;
void *p11malloc(size_t c, char *file, int line);
void p11free(void *p, char *file, int line);
#define malloc(c) (p11malloc((c), __FILE__, __LINE__))
#define free(c) (p11free((c), __FILE__, __LINE__))
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#define malloc(c) (p11malloc((c), THIS_FILE, __LINE__))
#define free(c) (p11free((c), THIS_FILE, __LINE__))
#endif
......@@ -33,8 +33,13 @@
#include "jni.h"
#include "utf_md.h"
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
/* Error and assert macros */
#define UTF_ERROR(m) utfError(__FILE__, __LINE__, m)
#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__, m)
#define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
void utfError(char *file, int line, char *message);
......
......@@ -49,11 +49,16 @@ jint shmemBase_receivePacket(SharedMemoryConnection *, jdwpPacket *packet);
jint shmemBase_name(SharedMemoryTransport *, char **name);
jint shmemBase_getlasterror(char *msg, jint size);
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#ifdef DEBUG
#define SHMEM_ASSERT(expression) \
do { \
if (!(expression)) { \
exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
} \
} while (0)
#else
......@@ -63,7 +68,7 @@ do { \
#define SHMEM_GUARANTEE(expression) \
do { \
if (!(expression)) { \
exitTransportWithError("assertion failed", __FILE__, __DATE__, __LINE__); \
exitTransportWithError("assertion failed", THIS_FILE, __DATE__, __LINE__); \
} \
} while (0)
......
......@@ -33,8 +33,13 @@
/* Routines to convert back and forth between Platform Encoding and UTF-8 */
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
/* Error and assert macros */
#define UTF_ERROR(m) utfError(__FILE__, __LINE__, m)
#define UTF_ERROR(m) utfError(THIS_FILE, __LINE__, m)
#define UTF_ASSERT(x) ( (x)==0 ? UTF_ERROR("ASSERT ERROR " #x) : (void)0 )
#define UTF_DEBUG(x)
......
......@@ -35,9 +35,15 @@ extern "C" {
#ifdef USE_ERROR
#include <stdio.h>
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#define MIDIIN_CHECK_ERROR { \
if (err != MMSYSERR_NOERROR) \
ERROR3("MIDI IN Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
ERROR3("MIDI IN Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_IN_GetErrorStr((INT32) err)); \
}
#else
#define MIDIIN_CHECK_ERROR
......
......@@ -33,9 +33,15 @@
#ifdef USE_ERROR
#include <stdio.h>
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#define MIDIOUT_CHECK_ERROR { \
if (err != MMSYSERR_NOERROR) \
ERROR3("MIDI OUT Error in %s:%d : %s\n", __FILE__, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
ERROR3("MIDI OUT Error in %s:%d : %s\n", THIS_FILE, __LINE__, MIDI_OUT_GetErrorStr((INT32) err)); \
}
#else
#define MIDIOUT_CHECK_ERROR
......
......@@ -28,6 +28,11 @@
#define D3D_DEBUG_INFO
#endif // DEBUG
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE THIS_FILE
#endif
#ifdef D3D_PPL_DLL
......@@ -104,7 +109,7 @@ do { \
#define ACT_IF_NULL(ACTION, value) \
if ((value) == NULL) { \
J2dTraceLn3(J2D_TRACE_ERROR, \
"%s is null in %s:%d", #value, __FILE__, __LINE__); \
"%s is null in %s:%d", #value, THIS_FILE, __LINE__); \
ACTION; \
} else do { } while (0)
#define RETURN_IF_NULL(value) ACT_IF_NULL(return, value)
......@@ -114,12 +119,12 @@ do { \
#define RETURN_STATUS_IF_EXP_FAILED(EXPR) \
if (FAILED(res = (EXPR))) { \
DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## __FILE__); \
DebugPrintD3DError(res, " " ## #EXPR ## " failed in " ## THIS_FILE); \
return res; \
} else do { } while (0)
#define RETURN_STATUS_IF_FAILED(status) \
if (FAILED((status))) { \
DebugPrintD3DError((status), " failed in " ## __FILE__ ## ", return;");\
DebugPrintD3DError((status), " failed in " ## THIS_FILE ## ", return;");\
return (status); \
} else do { } while (0)
......@@ -26,6 +26,11 @@
#ifndef _ALLOC_H_
#define _ALLOC_H_
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#include "stdhdrs.h"
// By defining std::bad_alloc in a local header file instead of including
......@@ -127,12 +132,12 @@ void handle_bad_alloc(void);
throw (std::bad_alloc);
#define safe_Malloc(size) \
safe_Malloc_outofmem(size, __FILE__, __LINE__)
safe_Malloc_outofmem(size, THIS_FILE, __LINE__)
#define safe_Calloc(num, size) \
safe_Calloc_outofmem(num, size, __FILE__, __LINE__)
safe_Calloc_outofmem(num, size, THIS_FILE, __LINE__)
#define safe_Realloc(memblock, size) \
safe_Realloc_outofmem(memblock, size, __FILE__, __LINE__)
#define new new(__FILE__, __LINE__)
safe_Realloc_outofmem(memblock, size, THIS_FILE, __LINE__)
#define new new(THIS_FILE, __LINE__)
#endif /* OUTOFMEM_TEST */
#define TRY \
......
......@@ -65,7 +65,12 @@
#define AWT_DUMP_CLIP_RECTANGLE(_msg, _hwnd) \
_DTrace_Template(DumpClipRectangle, 2, "", (_msg), (_hwnd), 0, 0, 0, 0, 0, 0)
#define new new(__FILE__, __LINE__)
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#define new new(THIS_FILE, __LINE__)
#define VERIFY(exp) DASSERT(exp)
#define UNIMPLEMENTED() DASSERT(FALSE)
......
......@@ -132,24 +132,30 @@ class CriticalSection {
// Macros for using CriticalSection objects that help trace
// lock/unlock actions
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
#define CRITICAL_SECTION_ENTER(cs) { \
J2dTraceLn4(J2D_TRACE_VERBOSE2, \
"CS.Wait: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
(cs).Enter(); \
J2dTraceLn4(J2D_TRACE_VERBOSE2, \
"CS.Enter: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
}
#define CRITICAL_SECTION_LEAVE(cs) { \
J2dTraceLn4(J2D_TRACE_VERBOSE2, \
"CS.Leave: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
(cs).Leave(); \
J2dTraceLn4(J2D_TRACE_VERBOSE2, \
"CS.Left: tid, cs, file, line = 0x%x, 0x%x, %s, %d", \
GetCurrentThreadId(), &(cs), __FILE__, __LINE__); \
GetCurrentThreadId(), &(cs), THIS_FILE, __LINE__); \
}
/************************************************************************
......
......@@ -30,6 +30,11 @@
#include "sysShmem.h"
#include "shmemBase.h" /* for exitTransportWithError */
/* Use THIS_FILE when it is available. */
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif
/*
* These functions are not completely universal. For now, they are used
* exclusively for Jbug's shared memory transport mechanism. They have
......@@ -44,7 +49,7 @@ static HANDLE memHandle = NULL;
if (!(expression)) { \
exitTransportWithError \
("\"%s\", line %d: assertion failure\n", \
__FILE__, __DATE__, __LINE__); \
THIS_FILE, __DATE__, __LINE__); \
} \
}
#else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册