This one fixes the annoying but that FreeBSD i386 is missing __va_copy.
It's not nice because I had to differ between 32 and 64 bit. But at least it works.

--
Ulrich Wilkens
Email: m...@uwilkens.de

>From c4233c7bd3d8ba145ab2e9b8df011ff94c683afd Mon Sep 17 00:00:00 2001
From: Ulrich Wilkens <m...@uwilkens.de>
Date: Wed, 5 Sep 2012 16:49:35 +0200
Subject: [PATCH] Fix for __va_copy on FreeBSD i386.

---
 cde/programs/dtappbuilder/src/abmf/write_c.c       |    4 +++-
 .../dtksh/ksh93/src/lib/libast/hash/hashalloc.c    |    9 +++++++++
 .../dtksh/ksh93/src/lib/libast/sfio/sfvprintf.c    |   14 ++++++++++++++
 3 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/cde/programs/dtappbuilder/src/abmf/write_c.c 
b/cde/programs/dtappbuilder/src/abmf/write_c.c
index 93d5619..7a41b85 100644
--- a/cde/programs/dtappbuilder/src/abmf/write_c.c
+++ b/cde/programs/dtappbuilder/src/abmf/write_c.c
@@ -350,8 +350,10 @@ write_func_def_params(
        va_list va_params
 )
 {
-#if defined(__ppc) || defined(linux)  || defined(CSRG_BASED)
+#if defined(__ppc) || defined(linux)  || defined(__OpenBSD__)
 #define va_start_params() __va_copy(params, va_params)
+#elif defined(__FreeBSD__)
+#define va_start_params() va_copy(params, va_params)
 #else
 #define va_start_params() (params = va_params)
 #endif
diff --git a/cde/programs/dtksh/ksh93/src/lib/libast/hash/hashalloc.c 
b/cde/programs/dtksh/ksh93/src/lib/libast/hash/hashalloc.c
index d09af24..361bd14 100644
--- a/cde/programs/dtksh/ksh93/src/lib/libast/hash/hashalloc.c
+++ b/cde/programs/dtksh/ksh93/src/lib/libast/hash/hashalloc.c
@@ -214,6 +214,10 @@ hashalloc __PARAM__((Hash_table_t* ref, ...), (va_alist)) 
__OTORP__(va_dcl)
                        tab->flags |= HASH_STATIC;
                        break;
                case HASH_va_list:
+#if defined(__FreeBSD__) && !defined(__LP64__)
+                       if (vp < &va[elementsof(va)]) *vp++ = ap;
+                       ap = va_arg(ap, va_list);
+#else
                        if (vp < &va[elementsof(va)])
                        {
                                __va_copy( *vp, ap );
@@ -221,12 +225,17 @@ hashalloc __PARAM__((Hash_table_t* ref, ...), (va_alist)) 
__OTORP__(va_dcl)
                        }
                        vl = va_arg(ap, va_list);
                        __va_copy(ap, vl);
+#endif
                        break;
                case 0:
                        if (vp > va)
                        {
+#if defined(__FreeBSD__) && !defined(__LP64__)
+                               ap = *--vp;
+#else
                                vp--;
                                __va_copy( ap, *vp );
+#endif
                                break;
                        }
                        if (tab->flags & HASH_SCOPE)
diff --git a/cde/programs/dtksh/ksh93/src/lib/libast/sfio/sfvprintf.c 
b/cde/programs/dtksh/ksh93/src/lib/libast/sfio/sfvprintf.c
index a95084b..4a93a8d 100644
--- a/cde/programs/dtksh/ksh93/src/lib/libast/sfio/sfvprintf.c
+++ b/cde/programs/dtksh/ksh93/src/lib/libast/sfio/sfvprintf.c
@@ -301,9 +301,15 @@ loop_fa :
                        
GETARG(form,form,argf,args,char*,char*,'1',t_user,n_user);
                        if(!form)
                                form = "";
+#if defined(__FreeBSD__) && !defined(__LP64__)
+                       
GETARG(argsp,argsp,argf,args,va_list*,va_list*,'2',t_user,n_user);
+                       memcpy((Void_t*)(&(fa->args)), (Void_t*)(&args), 
sizeof(va_list));
+                       memcpy((Void_t*)(&args), (Void_t*)argsp, 
sizeof(va_list));
+#else
                        
GETARGL(argsp,argsp,argf,args,va_list*,va_list*,'2',t_user,n_user);
                        __va_copy( fa->args, args );
                        __va_copy( args, argsp );
+#endif
                        fa->argf.p = argf;
                        fa->extf.p = extf;
                        fa->next = fast;
@@ -313,8 +319,12 @@ loop_fa :
                default :       /* unknown directive */
                        if(extf)
                        {
+#if defined(__FreeBSD__) && !defined(__LP64__)
+                               va_list savarg = args;  /* is this portable? */
+#else
                                va_list savarg;         /* is this portable?   
Sorry .. NO. */
                                __va_copy( savarg, args );
+#endif
 
                                
GETARG(sp,astr,argf,args,char*,char*,fmt,t_user,n_user);
                                astr = NIL(char*);
@@ -322,7 +332,11 @@ loop_fa :
                                if((sp = astr) )
                                        goto s_format;
 
+#if defined(__FreeBSD__) && !defined(__LP64__)
+                               args = savarg;  /* extf failed, treat as if 
unmatched */
+#else
                                __va_copy( args, savarg ); /* extf failed, 
treat as if unmatched */
+#endif
                        }
 
                        /* treat as text */
-- 
1.7.8

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel

Reply via email to