harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlyd...@apache.org
Subject svn commit: r565183 - /harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/tmparea.c
Date Sun, 12 Aug 2007 22:24:39 GMT
Author: dlydick
Date: Sun Aug 12 15:24:38 2007
New Revision: 565183

URL: http://svn.apache.org/viewvc?view=rev&rev=565183
Log:
Conditionally compile temporary directory area support.
Though technically deprecated for the JVM itself, it will
be supported to facilitate usage in other contexts.

Modified:
    harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/tmparea.c

Modified: harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/tmparea.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/tmparea.c?view=diff&rev=565183&r1=565182&r2=565183
==============================================================================
--- harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/tmparea.c (original)
+++ harmony/enhanced/sandbox/bootjvm/bootJVM/jvm/src/tmparea.c Sun Aug 12 15:24:38 2007
@@ -4,6 +4,12 @@
  * @brief Create and manage temporary directory area for class files,
  * etc.
  *
+ * @deprecated Used for facilitating Java archiving activities
+ * during initial development, it is now available for any general
+ * purpose should it prove useful in another capacity.
+ *
+ * @see JVMCFG_TMPAREA_IN_USE
+ *
  *
  * @section Control
  *
@@ -47,16 +53,31 @@
 
  
 #include "jvmcfg.h"
+#include "classfile.h"
 #include "exit.h"
 #include "heap.h" 
+#include "jvm.h"
+#include "pjvm.h" 
 #include "util.h"
 
 
+#if JVMCFG_TMPAREA_IN_USE
 /*!
  * @brief Initialize the class area of the JVM model
  *
  *
- * @b Parameters: @link #rvoid rvoid@endlink
+ * @param[in]  argv               Pointer to rboolean, set
+ *
+ * @param[in]  heap_get_data      Heap allocation function to use
+ *                                for geting heap areas to use.
+ *
+ * @param[in]  heap_free_data     Heap delallocation function to use
+ *                                for freeing up heap areas.
+ *
+ * @param[out] tmparea_init_flag  Pointer to rboolean, changed to
+ *                                @link #rtrue rtrue@endlink
+ *                                to indicate temporary area
+ *                                now available.
  *
  *
  * @returns @link #rvoid rvoid@endlink
@@ -64,12 +85,15 @@
  */
 static rchar *env_tmpdir = CHEAT_AND_USE_NULL_TO_INITIALIZE;
 
-static rchar tmparea[100];
-
-rvoid tmparea_init(char **argv)
+rvoid tmparea_init(char     **argv,
+                   rvoid     *(* heap_get_data)(rint, rboolean),
+                   rvoid      (* heap_free_data)(rvoid *),
+                   rboolean  *tmparea_init_flag)
 {
     ARCH_FUNCTION_NAME(tmparea_init);
 
+    rchar tmparea[100];
+
     rvoid *statbfr; /* Portability library does (struct stat) part */
     char *argv0name = portable_strrchr(argv[0],
                                        JVMCFG_PATHNAME_DELIMITER_CHAR);
@@ -100,30 +124,33 @@
         env_tmpdir = JVMCFG_TMPAREA_DEFAULT;
     }
 
+    /* Create temporary area name and allocate string for keeping name*/
     sprintfLocal(tmparea,
                  "%s%ctmp.%s.%d",
                  env_tmpdir,
                  JVMCFG_PATHNAME_DELIMITER_CHAR,
                  argv0name,
                  pid);
+    pjvm->tmparea = heap_get_data(portable_strlen(tmparea), rfalse);
+    portable_strcpy(pjvm->tmparea, tmparea);
 
     /* Could use <sys/stat.h> constants for directory creation mode */
-    (rvoid) portable_mkdir(tmparea, 0755);
+    (rvoid) portable_mkdir(pjvm->tmparea, 0755);
 
     /* Verify existence of directory */
-    statbfr = portable_stat(tmparea);
-    HEAP_FREE_DATA(statbfr);
+    statbfr = portable_stat(pjvm->tmparea);
+    heap_free_data(statbfr);
 
     if (rnull == statbfr)
     {
         sysErrMsg(arch_function_name,
                   "Cannot create temp directory %s",
-                  tmparea);
+                  pjvm->tmparea);
         exit_jvm(EXIT_TMPAREA_MKDIR);
 /*NOTREACHED*/
     }
     /* Declare this module initialized */
-    jvm_tmparea_initialized = rtrue;
+    *tmparea_init_flag = rtrue;
 
     return;
 
@@ -140,11 +167,11 @@
  * @returns Null-terminated string to temp area.
  *
  */
-const rchar *tmparea_get()
+const rchar *tmparea_get(rvoid)
 {
     ARCH_FUNCTION_NAME(tmparea_get);
 
-    return((const rchar *) tmparea);
+    return((const rchar *) pjvm->tmparea);
 
 } /* END of tmparea_get() */
 
@@ -153,26 +180,37 @@
  * @brief Shut down the temporary directory area after JVM execution.
  *
  *
- * @b Parameters: @link #rvoid rvoid@endlink
+ * @param[in]  heap_get_data      Heap allocation function to use
+ *                                for geting heap areas to use.
+ *
+ * @param[in]  heap_free_data     Heap delallocation function to use
+ *                                for freeing up heap areas.
+ *
+ * @param[out] tmparea_init_flag  Pointer to rboolean, changed to
+ *                                @link #rfalse rfalse@endlink
+ *                                to indicate temporary area
+ *                                no longer available.
  *
  *
  * @returns @link #rvoid rvoid@endlink
  *
  */
-rvoid tmparea_shutdown(rvoid)
+rvoid tmparea_shutdown(rvoid    *(* heap_get_data)(rint, rboolean),
+                       rvoid     (* heap_free_data)(rvoid *),
+                       rboolean *tmparea_init_flag)
 {
     ARCH_FUNCTION_NAME(tmparea_shutdown);
 
 
 /* Normal method requires directory to be empty:
  *
- *  int rc = rmdir(tmparea);
+ *  int rc = rmdir(pjvm->tmparea);
  *
  *  if (0 != rc)
  *  {
  *      sysErrMsg(arch_function_name,
  *                "Cannot remove temp directory %s",
- *                tmparea);
+ *                pjvm->tmparea);
  *      exit_jvm(EXIT_TMPAREA_RMDIR);
 **NOTREACHED**
  *  }
@@ -186,34 +224,40 @@
 
     rchar *rmscript =        /* format spec %s make strlen longer than
                                 it needs to be, but it is benign */
-        HEAP_GET_DATA(portable_strlen(JVMCFG_TMPAREA_REMOVE_SCRIPT) +
-                          portable_strlen(tmparea) +
+        heap_get_data(portable_strlen(JVMCFG_TMPAREA_REMOVE_SCRIPT) +
+                          portable_strlen(pjvm->tmparea) +
                           sizeof(rchar) /* NUL byte */,
                       rfalse);
 
-    sprintfLocal(rmscript, JVMCFG_TMPAREA_REMOVE_SCRIPT, tmparea);
+    sprintfLocal(rmscript, JVMCFG_TMPAREA_REMOVE_SCRIPT, pjvm->tmparea);
 
     /* int rc = */ portable_system(rmscript);
 
     /* Verify missing directory */
-    statbfr = portable_stat(tmparea);
-    HEAP_FREE_DATA(statbfr);
+    statbfr = portable_stat(pjvm->tmparea);
+    heap_free_data(statbfr);
 
     if (rnull != statbfr)
     {
         sysErrMsg(arch_function_name,
                   "Cannot remove temp directory %s",
-                  tmparea);
+                  pjvm->tmparea);
+        heap_free_data(pjvm->tmparea);
         exit_jvm(EXIT_TMPAREA_RMDIR);
 /*NOTREACHED*/
     }
 
+    /* Clean up */
+    heap_free_data(pjvm->tmparea);
+    pjvm->tmparea = (rchar *) rnull;
+
     /* Declare this module uninitialized */
-    jvm_tmparea_initialized = rfalse;
+    *tmparea_init_flag = rfalse;
 
     return;
 
 } /* END of tmparea_shutdown() */
 
+#endif /* JVMCFG_TMPAREA_IN_USE */
 
 /* EOF */



Mime
View raw message