This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add TARGET_GNU_SINCOS target macro


On Thu, 18 Jan 2007, Kaveh R. GHAZI wrote:

> On Thu, 18 Jan 2007, Richard Guenther wrote:
> 
> > On Thu, 18 Jan 2007, Kaveh R. GHAZI wrote:
> >
> > > I still don't see anything GNU specific about it.  Solaris10 has these
> > > prototypes:
> > >
> > > %uname -rs
> > > SunOS 5.10
> > > %grep sincos /usr/include/math.h
> > > extern void sincos __P((double, double *, double *));
> > > extern void sincosf __P((float, float *, float *));
> > > extern void sincosl __P((long double, long double *, long double *));
> > >
> > > Here's a link showing the same thing for hpux11.
> > > http://docs.hp.com/en/B2355-60105/sincos.3M.html
> > >
> > > I agree its an extension, but what makes you say its a "GNU extension"?
> >
> > The glibc manpage of course.  As sincos is not defined in any standard
> > we at least need something to refer to - and using GNU is not worse
> > than anything else?  (Are we just arguing about the name here??)
> > Richard.
> 
> Yeah, we're debating the name.  (I'm fine with the feature and thanks for
> implementing it.)  But sometimes names are important too.
> 
> Your choice of macro name makes it sounds like glibc invented the
> interface.  Is that the case?  If so, then it makes sense.

I cannot prove that nor do I have the energy to research it ;)

> Otherwise IMHO, it's odd to have other OSes claim to have something GNU in
> them.  Instead please call it TARGET_SINCOS (or something neutral) and
> document the required interface in the manual.

So here's a variant with TARGET_HAS_SINCOS.  I kept the comment before
the defines as they map to OPTION_GLIBC and the interface of the
GNU extension sincos is what we require.

Other systems should be handled in followup patches I think, as other
pending patches depend on this one.

Richard.


2007-01-17  Richard Guenther  <rguenther@suse.de>

	* doc/tm.texi (TARGET_HAS_SINCOS): Document new target macro.
	* defaults.h (TARGET_HAS_SINCOS): Default to off.
	* config/linux.h (TARGET_HAS_SINCOS): Set to on if we have glibc.
	* config/alpha/linux.h (TARGET_HAS_SINCOS): Likewise.
	* config/sparc/linux.h (TARGET_HAS_SINCOS): Likewise.
	* config/sparc/linux64.h (TARGET_HAS_SINCOS): Likewise.
	* config/rs6000/linux.h (TARGET_HAS_SINCOS): Likewise.
	* config/rs6000/linux64.h (TARGET_HAS_SINCOS): Likewise.

Index: doc/tm.texi
===================================================================
*** doc/tm.texi	(revision 120895)
--- doc/tm.texi	(working copy)
*************** number of existing systems lacks support
*** 5056,5061 ****
--- 5056,5073 ----
  they needs this macro to be redefined to 0.
  @end defmac
  
+ @cindex sincos math function, implicit usage
+ @defmac TARGET_HAS_SINCOS
+ When this macro is nonzero, GCC will implicitly optimize calls to @code{sin}
+ and @code{cos} with the same argument to a call to @code{sincos}.  The
+ default is zero.  The target has to provide the following functions:
+ @smallexample
+ void sincos(double x, double *sin, double *cos);
+ void sincosf(float x, float *sin, float *cos);
+ void sincosl(long double x, long double *sin, long double *cos);
+ @end smallexample
+ @end defmac
+ 
  @defmac NEXT_OBJC_RUNTIME
  Define this macro to generate code for Objective-C message sending using
  the calling convention of the NeXT system.  This calling convention
Index: defaults.h
===================================================================
*** defaults.h	(revision 120895)
--- defaults.h	(working copy)
*************** Software Foundation, 51 Franklin Street,
*** 796,801 ****
--- 796,807 ----
  #define TARGET_C99_FUNCTIONS 0
  #endif
  
+ /* Determine whether the target runtime library has
+    a sincos implementation following the GNU extension.  */
+ #ifndef TARGET_HAS_SINCOS
+ #define TARGET_HAS_SINCOS 0
+ #endif
+ 
  /* Indicate that CLZ and CTZ are undefined at zero.  */
  #ifndef CLZ_DEFINED_VALUE_AT_ZERO
  #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE)  0
Index: config/alpha/linux.h
===================================================================
*** config/alpha/linux.h	(revision 120895)
--- config/alpha/linux.h	(working copy)
*************** Boston, MA 02110-1301, USA.  */
*** 66,71 ****
--- 66,74 ----
     runtime library.  */
  #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
  
+ /* Whether we have sincos that follows the GNU extension.  */
+ #define TARGET_HAS_SINCOS (OPTION_GLIBC)
+ 
  #define TARGET_POSIX_IO
  
  #define LINK_GCC_C_SEQUENCE_SPEC \
Index: config/linux.h
===================================================================
*** config/linux.h	(revision 120895)
--- config/linux.h	(working copy)
*************** Boston, MA 02110-1301, USA.  */
*** 126,129 ****
--- 126,132 ----
     is present in the runtime library.  */
  #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
  
+ /* Whether we have sincos that follows the GNU extension.  */
+ #define TARGET_HAS_SINCOS (OPTION_GLIBC)
+ 
  #define TARGET_POSIX_IO
Index: config/sparc/linux.h
===================================================================
*** config/sparc/linux.h	(revision 120895)
--- config/sparc/linux.h	(working copy)
*************** do {									\
*** 215,220 ****
--- 215,223 ----
     runtime library.  */
  #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
  
+ /* Whether we have sincos that follows the GNU extension.  */
+ #define TARGET_HAS_SINCOS (OPTION_GLIBC)
+ 
  #define TARGET_POSIX_IO
  
  #undef LINK_GCC_C_SEQUENCE_SPEC
Index: config/sparc/linux64.h
===================================================================
*** config/sparc/linux64.h	(revision 120895)
--- config/sparc/linux64.h	(working copy)
*************** do {									\
*** 347,352 ****
--- 347,355 ----
     runtime library.  */
  #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
  
+ /* Whether we have sincos that follows the GNU extension.  */
+ #define TARGET_HAS_SINCOS (OPTION_GLIBC)
+ 
  #define TARGET_POSIX_IO
  
  #undef LINK_GCC_C_SEQUENCE_SPEC
Index: config/rs6000/linux.h
===================================================================
*** config/rs6000/linux.h	(revision 120895)
--- config/rs6000/linux.h	(working copy)
***************
*** 35,40 ****
--- 35,44 ----
  #undef  TARGET_C99_FUNCTIONS
  #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
  
+ /* Whether we have sincos that follows the GNU extension.  */
+ #undef  TARGET_HAS_SINCOS
+ #define TARGET_HAS_SINCOS (OPTION_GLIBC)
+ 
  #undef  TARGET_OS_CPP_BUILTINS
  #define TARGET_OS_CPP_BUILTINS()		\
    do						\
Index: config/rs6000/linux64.h
===================================================================
*** config/rs6000/linux64.h	(revision 120895)
--- config/rs6000/linux64.h	(working copy)
*************** extern int dot_symbols;
*** 285,290 ****
--- 285,294 ----
  #undef  TARGET_C99_FUNCTIONS
  #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
  
+ /* Whether we have sincos that follows the GNU extension.  */
+ #undef  TARGET_HAS_SINCOS
+ #define TARGET_HAS_SINCOS (OPTION_GLIBC)
+ 
  #undef  TARGET_OS_CPP_BUILTINS
  #define TARGET_OS_CPP_BUILTINS()			\
    do							\


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]