commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r898828 - in /commons/sandbox/runtime/trunk/src/main/native: include/ include/arch/windows/ os/unix/ os/win32/ shared/
Date Wed, 13 Jan 2010 16:34:43 GMT
Author: mturk
Date: Wed Jan 13 16:34:43 2010
New Revision: 898828

URL: http://svn.apache.org/viewvc?rev=898828&view=rev
Log:
Add Heap and Local alloc macros

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
    commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
    commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c
    commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_private.h Wed Jan 13 16:34:43
2010
@@ -521,7 +521,7 @@
 #define ACR_DO_STATS 1
 #endif
 #if defined(DEBUG)
-void acr_dbprintf(const char *, ...);
+void acr_dbprintf(const char *, int, const char *, ...);
 #define ACR_DEBUG(x) acr_dbprintf x
 #endif
 #else

Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
Wed Jan 13 16:34:43 2010
@@ -270,11 +270,11 @@
  */
 extern HANDLE dll_heap_handle;
 
-#define ACR_HMALLOC(T, S)   (T *)(HeapAlloc(dll_heap_handle, 0, (S)))
-#define ACR_HCALLOC(T, S)   (T *)(HeapAlloc(dll_heap_handle, HEAP_ZERO_MEMORY, (S)))
+#define ACR_HMALLOC(T, S)   (T *)HeapAlloc(dll_heap_handle, 0, (S))
+#define ACR_HCALLOC(T, S)   (T *)HeapAlloc(dll_heap_handle, HEAP_ZERO_MEMORY, (S))
 #define ACR_HFREE(M)        HeapFree(dll_heap_handle, 0, (M))
 
-#define ACR_LALLOC(T, S)    (T *)(LocalAlloc(LPTR, (S)))
+#define ACR_LALLOC(T, S)    (T *)LocalAlloc(LPTR, (S))
 #define ACR_LFREE(M)        if ((M)) LocalFree((M))
 
 /**

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/main.c Wed Jan 13 16:34:43 2010
@@ -89,7 +89,7 @@
 
     UNREFERENCED(reserved);
 
-    ACR_DEBUG(("JNI_Onload"));
+    ACR_DEBUG((THROW_FMARK, "JNI_Onload"));
     if ((*vm)->GetEnv(vm, &epp, JNI_VERSION_1_4))
         return JNI_ERR;
     if (ACR_Initialize(vm)) {

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/signals.c Wed Jan 13 16:34:43 2010
@@ -39,9 +39,9 @@
     acr_seh_ctxt_t *ctxt = (acr_seh_ctxt_t *)pthread_getspecific(seh_ctxt_key);
     if (sig == SIGSEGV || sig == SIGBUS) {
         if (ctxt && ctxt->init) {
-            ACR_DEBUG(("[ERROR] Executing SEH handler for signal: %d (%s)",
+            ACR_DEBUG((THROW_FMARK, "[ERROR] Executing SEH handler for signal: %d (%s)",
 		       sig, ACR_SignalDescription(sig)));
-            ACR_DEBUG(("        Line: %d - %s", ctxt->line, ctxt->file));
+            ACR_DEBUG((THROW_FMARK, "        Line: %d - %s", ctxt->line, ctxt->file));
             siglongjmp(ctxt->jump, 1);
         }
         else if (_signalset[sig]->sa_handler != SIG_DFL &&
@@ -55,9 +55,9 @@
             /* Not inside JVM.
              * Print some warning and abort
              */
-            ACR_DEBUG(("[error] Cannot find default handler for signal '%s'",
+            ACR_DEBUG((THROW_FMARK, "[ERROR] Cannot find default handler for signal '%s'",
 		       ACR_SignalDescription(sig)));
-            ACR_DEBUG(("        Aborting ..."));
+            ACR_DEBUG((THROW_FMARK, "        Aborting ..."));
             abort();
         }
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/uutils.c Wed Jan 13 16:34:43 2010
@@ -25,13 +25,17 @@
 #include "acr_time.h"
 
 #if defined(DEBUG) || defined(_DEBUG)
-void acr_dbprintf(const char *format, ...)
+void acr_dbprintf(const char *file, int line, const char *format, ...)
 {
     FILE    *stream;
     va_list ap;
 
     if (!(stream = fopen("/dev/tty", "a")))
         return;
+    if (file) {
+        const char *fn = ACR_FilePathNameGet(file);
+        fprintf(stream, "[%-20s %4d] ", fn, line);
+    }
     va_start(ap, format);
     vfprintf(stream, format, ap);
     va_end(ap);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Wed Jan 13 16:34:43 2010
@@ -342,11 +342,7 @@
 
     /* XXX: Can we come here if the DllMain returned FALSE? */
     if (dll_tls_index == TLS_OUT_OF_INDEXES) {
-#if defined(DEBUG)
-        fprintf(stderr, "Missing thread local storage (TLS) index.\n"
-                        "Cannot continue.\n");
-        fflush(stderr);
-#endif
+        ACR_DEBUG((THROW_FMARK, "Out of thread local storage (TLS) indexes. Cannot continue."));
         return ACR_ENOMEM;
     }
     GetSystemInfo(acr_osinf);
@@ -359,7 +355,7 @@
         acr_init_log_source(NULL);
         do_syslog(ACR_LOG_ERROR,
                   L"Failed loading system libraries", rc);
-        return (int)rc;
+        return rc;
     }
     /* Up to here we can be called multiple times.
      */
@@ -377,8 +373,7 @@
             /* Log that we couldn't set privilege */
             acr_init_log_source(NULL);
             do_syslog(ACR_LOG_WARN, buf, rc);
-            fprintf(stderr, "[WARN]  %S\n", buf);
-            fflush(stderr);
+            ACR_DEBUG((THROW_FMARK, "Failed enabling %S", sePrivileges[i]));
         }
 #else
         ACR_EnablePrivilege(sePrivileges[i]);
@@ -393,13 +388,10 @@
     if ((rc = acr_SignalsInit())) {
         /* Failed initializing signaling sub system
          */
-        return (int)rc;
+        return rc;
     }
-#if defined(DEBUG)
-    fprintf(stdout, "\nInitialized ACR : %S\n", dll_file_name);
-    fprintf(stdout, "                : %S\n", dos_file_name);
-    fflush(stdout);
-#endif
+    ACR_DEBUG((THROW_FMARK, "Initialized ACR : %S", dll_file_name));
+    ACR_DEBUG((THROW_FMARK, "                : %S", dos_file_name));
 
     return 0;
 }
@@ -411,10 +403,7 @@
     void   *epp;
 
     UNREFERENCED(reserved);
-#if defined(DEBUG)
-    fprintf(stdout, "JNI_Onload()\n");
-    fflush(stdout);
-#endif
+    ACR_DEBUG((THROW_FMARK, "JNI_Onload()"));
     if ((*vm)->GetEnv(vm, &epp, JNI_VERSION_1_4)) {
         return JNI_ERR;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/subproc.c Wed Jan 13 16:34:43 2010
@@ -76,11 +76,11 @@
 
 
     if ((rc = ACR_Initialize(NULL))) {
-        ACR_DEBUG(("Failed to initialize the ACR error=%d\n", rc));
+        ACR_DEBUG((THROW_FMARK, "Failed to initialize the ACR error=%d\n", rc));
         goto cleanup;
     }
     if ((rc = ACR_PlatformInitialize(INVALID_HANDLE_VALUE, 0))) {
-        ACR_DEBUG(("Failed to initialize the ACR platform error=%d\n", rc));
+        ACR_DEBUG((THROW_FMARK, "Failed to initialize the ACR platform error=%d\n", rc));
         goto cleanup;
     }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wutil.c Wed Jan 13 16:34:43 2010
@@ -29,15 +29,26 @@
 #define NON_UNC_PATH_LENGTH 248
 
 #if defined(DEBUG) || defined(_DEBUG)
-void acr_dbprintf(const char *format, ...)
+void acr_dbprintf(const char *file, int line, const char *format, ...)
 {
-    char    buf[8192];
+    char    buf[ACR_HBUFF_SIZ];
+    char    fmt[ACR_HBUFF_SIZ];
+    char    *bp = buf;
     va_list ap;
 
     va_start(ap, format);
     _vsnprintf(buf, sizeof(buf), format, ap);
     va_end(ap);
-    OutputDebugStringA(buf);
+    if (file) {
+        const char *fn = ACR_FilePathNameGet(file);
+        snprintf(fmt, ACR_HBUFF_LEN, "[%-20s %4d] %s", fn, line, buf);
+        bp = fmt;
+    }
+
+    OutputDebugStringA(bp);
+    fputs(bp,  stdout);
+    fputc('\n', stdout);
+    fflush(stdout);
 }
 #endif
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/bzip2.c Wed Jan 13 16:34:43 2010
@@ -29,6 +29,6 @@
     /* TODO: Make this as configurable callback
      * So that those messages can pop up in Java loggers.
      */
-    ACR_DEBUG(("Internal bzlib error=(%d)", errorcode));
+    ACR_DEBUG((THROW_FMARK, "Internal bzlib error=(%d)", errorcode));
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Wed Jan 13 16:34:43 2010
@@ -204,13 +204,15 @@
             core_classes[i].clazz = (jclass)(*_E)->NewGlobalRef(_E, o);
             (*_E)->DeleteLocalRef(_E, o);
             if (core_classes[i].clazz == NULL) {
-                ACR_DEBUG(("[ERROR] Cannot reference core class '%s'",
+                ACR_DEBUG((THROW_FMARK,
+                           "[ERROR] Cannot reference core class '%s'",
                            core_classes[i].name));
                 return ACR_ENOMEM;
             }
         }
         else {
-            ACR_DEBUG(("[ERROR] Cannot find core class '%s'",
+            ACR_DEBUG((THROW_FMARK,
+                       "[ERROR] Cannot find core class '%s'",
                        core_classes[i].name));
             return ACR_ESYMNOTFOUND;
         }
@@ -260,7 +262,9 @@
             /* According to the JNI spec this can
              * happen if the system runs out of memory.
              */
-            ACR_DEBUG(("[ERROR] Cannot reference class '%s'", name));
+            ACR_DEBUG((THROW_FMARK,
+                       "[ERROR] Cannot reference class '%s'",
+                       name));
             return NULL;
         }
         (*_E)->DeleteLocalRef(_E, o);
@@ -274,7 +278,7 @@
         /* Class cannot fe found. The exception has already
          * been thrown.
          */
-        ACR_DEBUG(("[ERROR] Cannot find class '%s'", name));
+        ACR_DEBUG((THROW_FMARK, "[ERROR] Cannot find class '%s'", name));
     }
     return c;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=898828&r1=898827&r2=898828&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Wed Jan 13 16:34:43 2010
@@ -65,19 +65,19 @@
     if (env == NULL)
         env = ACR_GetJNIEnv();
     if (IS_INVALID_HANDLE(env)) {
-        ACR_DEBUG(("[ERROR]  JNI Environment is invalid or unavailable."));
-        ACR_DEBUG(("[ERROR]  Throwing class '%s'", clazz));
+        ACR_DEBUG((THROW_NMARK, "[ERROR]  JNI Environment is invalid or unavailable."));
+        ACR_DEBUG((THROW_NMARK, "[ERROR]  Throwing class '%s'", clazz));
         if (msg) {
-            ACR_DEBUG(("[ERROR]  %s", msg));
+            ACR_DEBUG((THROW_NMARK, "[ERROR]  %s", msg));
         }
         return;
     }
     if ((*env)->ExceptionCheck(env)) {
         /* We already have a pending exception. */
-        ACR_DEBUG(("[INFO]   Exception is already in the queue."));
-        ACR_DEBUG(("[INFO]   Class '%s' was not thrown.", clazz));
+        ACR_DEBUG((THROW_NMARK, "[INFO]   Exception is already in the queue."));
+        ACR_DEBUG((THROW_NMARK, "[INFO]   Class '%s' was not thrown.", clazz));
         if (msg) {
-            ACR_DEBUG(("[INFO]   %s", msg));
+            ACR_DEBUG((THROW_NMARK, "[INFO]   %s", msg));
         }
         return;
     }
@@ -87,9 +87,9 @@
          * the Exception has already been thrown.
          * See JNI Find Class for the Exceptions thrown.
          */
-        ACR_DEBUG(("[ERROR]  Cannot find class '%s'", clazz));
+        ACR_DEBUG((THROW_NMARK, "[ERROR]  Cannot find class '%s'", clazz));
         if (msg) {
-            ACR_DEBUG(("[ERROR]  %s", msg));
+            ACR_DEBUG((THROW_NMARK, "[ERROR]  %s", msg));
         }
         return;
     }



Mime
View raw message