Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 May 2001 14:43:26 +0200
From:      Cyrille Artho <cartho@silmaril.org>
To:        freebsd-java@freebsd.org
Cc:        Ernst de Haan <ernst@jollem.com>
Subject:   First FreeBSD port of Jlint
Message-ID:  <3B03C76E.C6EC9496@silmaril.org>

next in thread | raw e-mail | index | archive | help
Hi,
Ernst de Haan has tried to compile my Jlint Java program checker,
http://artho.com/jlint/ under FreeBSD. The compilation failed due to
va_arg macro problems.
Jlint is a Java class file checker that finds NULL pointer, array bound,
multi-threading and other problems at compile-time.
I have now made a provisional patch for Jlint, such that it should
compile under FreeBSD as well. I would be glad if someone could try it
under BSD versions other than FreeBSD 4.3, and see if it compiles. The
patch is very short and attached below:

--- /tmp/jlint/jlint.cc	Fri Mar 16 22:03:51 2001
+++ /home/cartho/jlint/jlint.cc	Thu May 17 12:40:19 2001
@@ -13,6 +13,15 @@
 #include <stdlib.h>
 #include <assert.h>
 #include <stdarg.h>
+// FreeBSD 4.3 and lower fix
+#if defined(__FreeBSD__)
+#define VA_ARG(ap, type) \
+        (*(type *)((ap) = (type *)((char *)ap + __va_size(type)), \
+	(type *)(((char *)ap) - __va_size(type))))
+#else
+#define VA_ARG va_arg
+#endif
+
 #include <ctype.h>
 #ifdef _WIN32
 #include <windows.h>
@@ -138,7 +146,7 @@
   int   n_parameters = 2;
   
   if (code == msg_loop || code == msg_sync_loop) { // extract loop
identifier
-    parameter[n_parameters++] = va_arg(ap, void*);
+    parameter[n_parameters++] = VA_ARG(ap, void*);
   }
   if (history != NULL) { 
     if (compound_message != NULL
@@ -198,7 +206,7 @@
           assert(n == 1);
           assert(index < MAX_MSG_PARAMETERS);
           while (index >= n_parameters) { 
-            parameter[n_parameters++] = va_arg(ap, void*);
+            parameter[n_parameters++] = VA_ARG(ap, void*);
           }
           src += pos;
           char* save_dst = dst;

-- 
Regards,
Cyrille Artho - http://artho.com/ - Tel. +41 - [0]1 - 632 09 88
If you go on with this nuclear arms race, all you are going to do is
make the rubble bounce.         
                -- Winston Churchill

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B03C76E.C6EC9496>