Main Page | Alphabetical List | Class List | File List | Class Members | File Members

gnu.h

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------------------------------
00002  * /
00003  * / apeNEXT/non-apeNext macros and functions for nlcc/g++
00004  * /
00005  * / $Id: gnu.h,v 1.5 2005/10/27 20:04:44 morinl Exp $
00006  * /
00007  * / #include <gnu.h>
00008  * /
00009  * / IMPLEMENTATION for APEnext: done, tested        (gnu.h)                [completed yes]
00010  * /
00011  * / Notes:
00012  * /           Definition of macros and functions for consistent use with g++, 
00013  * /           except for apeNEXT specific cases.
00014  * /           gnu_init() should be called a the beginning of main().
00015  * / Author:   
00016  * /           Olaf Kaczmarek (okacz@physik.uni-bielefeld.de) 
00017  * /---------------------------------------------------------------------------------------------*/
00018  
00019 #ifndef _GNU_H_
00020 #define _GNU_H_
00021 
00022 #include <nlibc.h>
00023 
00024 #if defined(__NLCC__) && defined(apenext)
00025 
00026 #define complex(a,b) {a,b}
00027 #define vector(a,b) {a,b}
00028 
00029 #else
00030 
00031 #include <complex.h>
00032 #include <inttypes.h>
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include <fpu_control.h>
00036 
00037 #define complex double_complex
00038 #define float double
00039 #define int int64_t
00040 
00041 typedef struct { double lo; double hi; } vector;
00042 
00043 void write_int(int y)
00044 {
00045   if(y>=0xffffffffLL || y<0)
00046     printf("0x%llx \n",(int)y);
00047   else
00048     printf("%lld  \n",(int)y);
00049 }
00050 
00051 #define write_double(y) printf("%1.15e \n",y)
00052 #define write_float(y) printf("%1.15e \n",y)
00053 #define write_complex(y) printf("(%1.15e,%1.15e) \n",real(y),imag(y))
00054 #define write_vector(y) printf("(%1.15e,%1.15e)\n",y.lo,y.hi)
00055 #define write_string(y) printf("%s",y)
00056 
00057 #ifndef __HAS_MAIN
00058 extern void write_double_array(double *y, int x);
00059 #else
00060 #if !defined(__cflow_processed) || defined(_uses_write_double_array_time_h)
00061 void write_double_array(double *y, int x)
00062 {
00063   int i; 
00064 
00065   for(i=0;i<x;i++)
00066     {
00067       printf("%1.15e ",*y);
00068       y++;
00069     }
00070   printf("\n");
00071 }
00072 #endif
00073 #endif // __HAS_MAIN
00074 
00075 #ifndef __HAS_MAIN
00076 extern void write_int_array(int *y, int x);
00077 #else
00078 #if !defined(__cflow_processed) || defined(_uses_write_int_array_time_h)
00079 void write_int_array(int *y, int x)
00080 {
00081   int i; 
00082 
00083   for(i=0;i<x;i++)
00084     {
00085       if(*y>=0xffffffffLL || *y<0)
00086         printf("0x%llx ",(int)*y);
00087       else
00088         printf("%lld  ",(int)*y);
00089       y++;
00090     }
00091   printf("\n");
00092 }
00093 #endif
00094 #endif // __HAS_MAIN
00095 
00096 #ifndef __HAS_MAIN
00097 extern void write_complex_array(complex *y, int x);
00098 #else
00099 #if !defined(__cflow_processed) || defined(_uses_write_complex_array_time_h)
00100 void write_complex_array(complex *y, int x)
00101 {
00102   int i; 
00103 
00104   for(i=0;i<x;i++)
00105     {
00106       printf("(%1.15e,%1.15e) ",real(*y),imag(*y));
00107       y++;
00108     }
00109   printf("\n");
00110 }
00111 #endif
00112 #endif // __HAS_MAIN
00113 
00114 #ifndef __HAS_MAIN
00115 extern void write_vector_array(vector *y, int x);
00116 #else
00117 #if !defined(__cflow_processed) || defined(_uses_write_vector_array_time_h)
00118 void write_vector_array(vector *y, int x)
00119 {
00120   int i; 
00121 
00122   for(i=0;i<x;i++)
00123     {
00124       printf("(%1.15e,%1.15e)",y->lo,y->hi);
00125       y++;
00126     }
00127   printf("\n");
00128 }
00129 #endif
00130 #endif // __HAS_MAIN
00131 
00139 #if defined(__GNUC__) && defined(__i386__)
00140 static void __attribute__ ((constructor))
00141 gnu_init()
00142 {
00143         fpu_control_t cw;
00144         _FPU_GETCW(cw);
00145         cw &= ~(_FPU_EXTENDED);
00146         cw |= _FPU_DOUBLE;
00147         _FPU_SETCW(cw);
00148   printf("here\n");
00149 }
00150 #endif
00151 
00152 #endif
00153 
00154 
00155 #endif // _GNU_H_

Generated on Fri Jul 14 10:51:31 2006 for nlibc by doxygen 1.3.5