]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge the memory allocation bits from libvex.h into main_util.c.
authorFlorian Krohm <florian@eich-krohm.de>
Sat, 11 Oct 2014 14:48:38 +0000 (14:48 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sat, 11 Oct 2014 14:48:38 +0000 (14:48 +0000)
This is to avoid linkage problems due to unresolved symbols for
some compilers. See also valgrind r14600 and BZ #339542.

git-svn-id: svn://svn.valgrind.org/vex/trunk@2974

VEX/priv/main_util.c
VEX/pub/libvex.h

index 31652304f19dfb249165dfa1405e6701237b68f0..2031b8869e221c8531503e36db17e4b43e09d6a0 100644 (file)
@@ -67,6 +67,11 @@ static HChar* permanent_first = &permanent[0];
 static HChar* permanent_curr  = &permanent[0];
 static HChar* permanent_last  = &permanent[N_PERMANENT_BYTES-1];
 
+static HChar* private_LibVEX_alloc_first = &temporary[0];
+static HChar* private_LibVEX_alloc_curr  = &temporary[0];
+static HChar* private_LibVEX_alloc_last  = &temporary[N_TEMPORARY_BYTES-1];
+
+
 static VexAllocMode mode = VexAllocModeTEMP;
 
 void vexAllocSanityCheck ( void )
@@ -149,14 +154,8 @@ VexAllocMode vexGetAllocMode ( void )
    return mode;
 }
 
-/* Visible to library client, unfortunately. */
-
-HChar* private_LibVEX_alloc_first = &temporary[0];
-HChar* private_LibVEX_alloc_curr  = &temporary[0];
-HChar* private_LibVEX_alloc_last  = &temporary[N_TEMPORARY_BYTES-1];
-
 __attribute__((noreturn))
-void private_LibVEX_alloc_OOM(void)
+static void private_LibVEX_alloc_OOM(void)
 {
    const HChar* pool = "???";
    if (private_LibVEX_alloc_first == &temporary[0]) pool = "TEMP";
@@ -197,6 +196,51 @@ void vexSetAllocModeTEMP_and_clear ( void )
 
 /* Exported to library client. */
 
+/* Allocate in Vex's temporary allocation area.  Be careful with this.
+   You can only call it inside an instrumentation or optimisation
+   callback that you have previously specified in a call to
+   LibVEX_Translate.  The storage allocated will only stay alive until
+   translation of the current basic block is complete.
+ */
+
+void* LibVEX_Alloc ( Int nbytes )
+{
+   struct align {
+      char c;
+      union {
+         char c;
+         short s;
+         int i;
+         long l;
+         long long ll;
+         float f;
+         double d;
+         /* long double is currently not used and would increase alignment
+            unnecessarily. */
+         /* long double ld; */
+         void *pto;
+         void (*ptf)(void);
+      } x;
+   };
+
+#if 0
+  /* Nasty debugging hack, do not use. */
+  return malloc(nbytes);
+#else
+   HChar* curr;
+   HChar* next;
+   Int    ALIGN;
+   ALIGN  = offsetof(struct align,x) - 1;
+   nbytes = (nbytes + ALIGN) & ~ALIGN;
+   curr   = private_LibVEX_alloc_curr;
+   next   = curr + nbytes;
+   if (next >= private_LibVEX_alloc_last)
+      private_LibVEX_alloc_OOM();
+   private_LibVEX_alloc_curr = next;
+   return curr;
+#endif
+}
+
 void LibVEX_ShowAllocStats ( void )
 {
    vex_printf("vex storage: T total %lld bytes allocated\n",
index 7ebe26fa0afda0747fd2da8ea4ee9e7f274f4cf5..6da02daf23bf88f1bd29ead5aed1b13e51b6c2c1 100644 (file)
@@ -452,50 +452,8 @@ void LibVEX_default_VexControl ( /*OUT*/ VexControl* vcon );
    You can only call it inside an instrumentation or optimisation
    callback that you have previously specified in a call to
    LibVEX_Translate.  The storage allocated will only stay alive until
-   translation of the current basic block is complete.
- */
-extern HChar* private_LibVEX_alloc_first;
-extern HChar* private_LibVEX_alloc_curr;
-extern HChar* private_LibVEX_alloc_last;
-extern void   private_LibVEX_alloc_OOM(void) __attribute__((noreturn));
-
-static inline void* LibVEX_Alloc ( Int nbytes )
-{
-   struct align {
-      char c;
-      union {
-         char c;
-         short s;
-         int i;
-         long l;
-         long long ll;
-         float f;
-         double d;
-         /* long double is currently not used and would increase alignment
-            unnecessarily. */
-         /* long double ld; */
-         void *pto;
-         void (*ptf)(void);
-      } x;
-   };
-
-#if 0
-  /* Nasty debugging hack, do not use. */
-  return malloc(nbytes);
-#else
-   HChar* curr;
-   HChar* next;
-   Int    ALIGN;
-   ALIGN  = offsetof(struct align,x) - 1;
-   nbytes = (nbytes + ALIGN) & ~ALIGN;
-   curr   = private_LibVEX_alloc_curr;
-   next   = curr + nbytes;
-   if (next >= private_LibVEX_alloc_last)
-      private_LibVEX_alloc_OOM();
-   private_LibVEX_alloc_curr = next;
-   return curr;
-#endif
-}
+   translation of the current basic block is complete. */
+extern void* LibVEX_Alloc ( Int nbytes );
 
 /* Show Vex allocation statistics. */
 extern void LibVEX_ShowAllocStats ( void );