[RESEND] [PATCH] Better vxWorks support in longlong.h

Mark Haigh mhaigh at sonicwall.com
Fri Mar 19 01:29:37 CET 2004


[Resend, anyone home?]

Hello,

Here's a patch for better vxWorks support in longlong.h.  It fixes the 
FIXME for vxWorks PPC in there as well.

The problem with the way longlong.h is currently set up is that the PPC 
macro is used to determine whether we're running on GNU/Linux or SysV.  
However, this usage is ambiguous because vxWorks always defines PPC, 
regardless of the actual target architecture.  When compiling under 
vxWorks, this causes longlong.h to unconditionally emit powerpc 
assembly, causing breakage on all non-PPC targets.

The patch here is as minimal and uninvasive as possible.  I'm working 
with the gcc folks to get something that's acceptable to everyone, 
because currently gcc will not build for any non-PPC vxWorks platforms 
without a bit of manual hackery.

The patch is against the 4.1.2 release.  I would appreciate it's 
inclusion so I can get the vxWorks gcc builds working again.  If there's 
anything you would like done differently, please let me know.

Thanks,


Mark F. Haigh
mfhaigh at acm.org


-------------- next part --------------
*** longlong.h.orig	Tue Mar  9 14:45:34 2004
--- longlong.h	Tue Mar  9 18:43:29 2004
*************** MA 02111-1307, USA. */
*** 37,42 ****
--- 37,54 ----
  #define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
  #define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
  
+ /* VxWorks always defines PPC, even for non-PPC targets.  This conflicts 
+    with GNU/Linux and SysV usage.  Here we resolve the ambiguity.  */
+ #ifdef PPC
+ #if (defined(__vxworks) || defined(__vxworks__)) && defined(CPU_FAMILY)
+ #if CPU_FAMILY == PPC		/* VxWorks defined PPC.  Check CPU family. */
+ #define __PPC_VXWORKS		/* We are VxWorks for PPC */
+ #endif
+ #else
+ #define __PPC_LINUX_OR_SYSV	/* Not VxWorks, must be GNU/Linux or SysV. */
+ #endif
+ #endif
+ 
  /* This is used to make sure no undesirable sharing between different libraries
     that use this file takes place.  */
  #ifndef __MPN
*************** extern UWtype __MPN(udiv_qrnnd) _PROTO (
*** 955,969 ****
  #endif /* __ns32000__ */
  
  /* FIXME: We should test _IBMR2 here when we add assembly support for the
!    system vendor compilers.
!    FIXME: What's needed for gcc PowerPC VxWorks?  __vxworks__ is not good
!    enough, since that hits ARM and m68k too.  */
! #if (defined (_ARCH_PPC)	/* AIX */				\
!      || defined (_ARCH_PWR)	/* AIX */				\
!      || defined (__powerpc__)	/* gcc */				\
!      || defined (__POWERPC__)	/* BEOS */				\
!      || defined (__ppc__)	/* Darwin */				\
!      || defined (PPC)		/* GNU/Linux, SysV */			\
       ) && W_TYPE_SIZE == 32
  #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
    do {									\
--- 967,980 ----
  #endif /* __ns32000__ */
  
  /* FIXME: We should test _IBMR2 here when we add assembly support for the
!    system vendor compilers.  */
! #if (defined (_ARCH_PPC)		/* AIX */			\
!      || defined (_ARCH_PWR)		/* AIX */			\
!      || defined (__powerpc__)		/* gcc */			\
!      || defined (__POWERPC__)		/* BEOS */			\
!      || defined (__ppc__)		/* Darwin */			\
!      || defined (__PPC_LINUX_OR_SYSV)	/* GNU/Linux, SysV */		\
!      || defined (__PPC_VXWORKS) 	/* VxWorks */			\
       ) && W_TYPE_SIZE == 32
  #define add_ssaaaa(sh, sl, ah, al, bh, bl) \
    do {									\
*************** extern UWtype __MPN(udiv_qrnnd) _PROTO (
*** 1001,1007 ****
    __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
  #define COUNT_LEADING_ZEROS_0 32
  #if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \
!   || defined (__ppc__) || defined (PPC) || defined (__vxworks__)
  #define umul_ppmm(ph, pl, m0, m1) \
    do {									\
      USItype __m0 = (m0), __m1 = (m1);					\
--- 1012,1019 ----
    __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
  #define COUNT_LEADING_ZEROS_0 32
  #if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \
!   || defined (__ppc__) || defined (__PPC_LINUX_OR_SYSV)			\
!   || defined (__PPC_VXWORKS)
  #define umul_ppmm(ph, pl, m0, m1) \
    do {									\
      USItype __m0 = (m0), __m1 = (m1);					\


More information about the gmp-bugs mailing list