Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

sincos.c

Go to the documentation of this file.
00001 /*
00002    sincos.c
00003 
00004    single-instruction sine and cosine function, intended to benefit
00005    user of chips with built-in single instructions which return the
00006    sine and cosine in one call.
00007 
00008    If no support is available, it does the trivial mapping of ANSI C
00009    functions.
00010 
00011    Modifying this file:
00012 
00013    If there is already a library version of sincos() for your platform,
00014    then copy the #ifdef PLATFORM_WITH_LIBRARY_SUPPORT section,
00015    change PLATFORM_WITH_LIBRARY_SUPPORT to your platform token,
00016    and nothing will be defined.
00017 
00018    If there is no software support for your platform, but the chip has
00019    a sincos analogy, copy the #ifdef PLATFORM_WITH_CHIP_SUPPORT section,
00020    change PLATFORM_WITH_CHIP_SUPPORT to your platform token, and
00021    implement the function with the asm keyword in assembly language.
00022 
00023    If there is no software or hardware support for sincos, just leave
00024    this file alone. You will get a multiple-call implementation.
00025 
00026    Modification history:
00027 
00028    30-Jan-1997  FMP added #ifdef __CPLUSPLUS__ around math.h include
00029    29-Jan-1997  FMP changed added PLATFORM_WITH_ to make more obvious
00030 */
00031 
00032 /*
00033    Modification history:
00034 
00035    14-Apr-1997  FMP made C-only
00036    31-Mar-1997  FMP added sincos support for SunOS 4, which has _sincos
00037    in libm.a
00038    4-Nov-1996  Fred Proctor created
00039 */
00040 
00041 #include <math.h>
00042 
00043 #ifdef __GLIBC__
00044 #define SINCOS_SUPPORT
00045 #else
00046 
00047 #include "sincos.h"             /* this declaration */
00048 #endif
00049 
00050 /* -------------------------------------------------------------------- */
00051 
00052 /* TEMPLATES */
00053 
00054 #ifdef PLATFORM_WITH_LIBRARY_SUPPORT /* use if sincos exists already */
00055 
00056 #define SINCOS_SUPPORT          /* define to remove trivial implementation
00057                                    at end */
00058 
00059 #endif /* #ifdef PLATFORM_WITH_LIBRARY_SUPPORT */
00060 
00061 #ifdef PLATFORM_WITH_CHIP_SUPPORT /* use if sincos is on chip */
00062 
00063 #define SINCOS_SUPPORT          /* define to remove trivial implementation
00064                                    at end */
00065 
00066 void sincos(double x, double *s, double *c)
00067 {
00068   /* use asm keyword to get at SINCOS instruction */
00069 }
00070 
00071 #endif /* #ifdef PLATFORM_WITH_CHIP_SUPPORT */
00072 
00073 /* END TEMPLATES */
00074 
00075 /* -------------------------------------------------------------------- */
00076 
00077 /* PLATFORMS-- copy templates from above into here */
00078 
00079 #ifdef sunos4
00080 
00081 #define SINCOS_SUPPORT          /* define to remove trivial implementation
00082                                    at end */
00083 
00084 #endif /* #ifdef PLATFORM_WITH_LIBRARY_SUPPORT */
00085 
00086 #ifdef VXWORKS
00087 #ifndef POWERPC
00088 
00089 #define SINCOS_SUPPORT          /* define to remove trivial implementation
00090                                    at end */
00091 
00092 #endif /* POWERPC */
00093 #endif /* #ifdef VXWORKS */
00094 
00095 /* END PLATFORMS */
00096 
00097 /* -------------------------------------------------------------------- */
00098 
00099 /* last resort- define with ANSI implementation */
00100 
00101 #ifndef SINCOS_SUPPORT
00102 
00103 #include <math.h>               /* sin(), cos() */
00104 
00105 void sincos(double x, double *s, double *c)
00106 {
00107   *s = sin(x);
00108   *c = cos(x);
00109 }
00110 
00111 #endif /* #ifndef SINCOS_SUPPORT */
00112 
00113 /* -------------------------------------------------------------------- */
00114 
00115 

Generated on Sun Dec 2 15:56:52 2001 for rcslib by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001