diff --git a/swisseph/swecl.c b/swisseph/swecl.c index 9ddafc2..a47a2ca 100644 --- a/swisseph/swecl.c +++ b/swisseph/swecl.c @@ -72,7 +72,7 @@ static int find_zero(double y00, double y11, double y2, double dx, double *dxret, double *dxret2); static double calc_dip(double geoalt, double atpress, double attemp, double lapse_rate); static double calc_astronomical_refr(double geoalt,double atpress, double attemp); -static double const_lapse_rate = SE_LAPSE_RATE; /* for refraction */ +static TLS double const_lapse_rate = SE_LAPSE_RATE; /* for refraction */ #if 0 #define DSUN (1391978489.9 / AUNIT) /* this value is consistent with @@ -549,7 +549,7 @@ struct saros_data saros_data_lunar[NSAROS_LUNAR] = { * attr[7] angular distance of moon from sun in degrees * declare as attr[20] at least ! */ -int32 FAR PASCAL_CONV swe_sol_eclipse_where( +int32 swe_sol_eclipse_where( double tjd_ut, int32 ifl, double *geopos, @@ -568,7 +568,7 @@ int32 FAR PASCAL_CONV swe_sol_eclipse_where( return retflag; } -int32 FAR PASCAL_CONV swe_lun_occult_where( +int32 swe_lun_occult_where( double tjd_ut, int32 ipl, char *starname, @@ -896,7 +896,7 @@ static int32 calc_planet_star(double tjd_et, int32 ipl, char *starname, int32 if * declare as attr[20] at least ! * */ -int32 FAR PASCAL_CONV swe_sol_eclipse_how( +int32 swe_sol_eclipse_how( double tjd_ut, int32 ifl, double *geopos, @@ -1148,7 +1148,7 @@ static int32 eclipse_how( double tjd_ut, int32 ipl, char *starname, int32 ifl, * declare as tret[10] at least! * */ -int32 FAR PASCAL_CONV swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, int32 ifltype, +int32 swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr) { int i, j, k, m, n, o, i1 = 0, i2 = 0; @@ -1535,7 +1535,7 @@ int32 FAR PASCAL_CONV swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, int * declare as tret[10] at least! * */ -int32 FAR PASCAL_CONV swe_lun_occult_when_glob( +int32 swe_lun_occult_when_glob( double tjd_start, int32 ipl, char *starname, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr) { @@ -1982,7 +1982,7 @@ int32 FAR PASCAL_CONV swe_lun_occult_when_glob( * attr[10] saros series member number * declare as attr[20] at least ! */ -int32 FAR PASCAL_CONV swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, +int32 swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr) { int32 retflag = 0, retflag2 = 0; @@ -2034,7 +2034,7 @@ int32 FAR PASCAL_CONV swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, * * for all other parameters, see function swe_sol_eclipse_when_loc(). */ -int32 FAR PASCAL_CONV swe_lun_occult_when_loc(double tjd_start, int32 ipl, char *starname, int32 ifl, +int32 swe_lun_occult_when_loc(double tjd_start, int32 ipl, char *starname, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr) { int32 retflag = 0, retflag2 = 0; @@ -2748,7 +2748,7 @@ static int32 occult_when_loc( * if a non-zero height above sea is given, atpress is estimated. * geohgt height of observer above sea (optional) */ -void FAR PASCAL_CONV swe_azalt( +void swe_azalt( double tjd_ut, int32 calc_flag, double *geopos, @@ -2799,7 +2799,7 @@ void FAR PASCAL_CONV swe_azalt( * iflag either SE_HOR2ECL or SE_HOR2EQU * xin[2] azimut and true altitude, in degrees */ -void FAR PASCAL_CONV swe_azalt_rev( +void swe_azalt_rev( double tjd_ut, int32 calc_flag, double *geopos, @@ -2847,7 +2847,7 @@ void FAR PASCAL_CONV swe_azalt_rev( * int32 calc_flag; * either SE_CALC_APP_TO_TRUE or * * SE_CALC_TRUE_TO_APP */ -double FAR PASCAL_CONV swe_refrac(double inalt, double atpress, double attemp, int32 calc_flag) +double swe_refrac(double inalt, double atpress, double attemp, int32 calc_flag) { double a, refr; double pt_factor = atpress / 1010.0 * 283.0 / (273.0 + attemp); @@ -2946,7 +2946,7 @@ double FAR PASCAL_CONV swe_refrac(double inalt, double atpress, double attemp, i } } -void FAR PASCAL_CONV swe_set_lapse_rate(double lapse_rate) +void swe_set_lapse_rate(double lapse_rate) { const_lapse_rate = lapse_rate; } @@ -2993,7 +2993,7 @@ void FAR PASCAL_CONV swe_set_lapse_rate(double lapse_rate) * * The body is above the horizon if the dret[0] != dret[1] */ -double FAR PASCAL_CONV swe_refrac_extended(double inalt, double geoalt, double atpress, double attemp, double lapse_rate, int32 calc_flag, double *dret) +double swe_refrac_extended(double inalt, double geoalt, double atpress, double attemp, double lapse_rate, int32 calc_flag, double *dret) { double refr; double trualt; @@ -3143,7 +3143,7 @@ static double calc_dip(double geoalt, double atpress, double attemp, double laps * declare as attr[20] at least ! * */ -int32 FAR PASCAL_CONV swe_lun_eclipse_how( +int32 swe_lun_eclipse_how( double tjd_ut, int32 ifl, double *geopos, @@ -3330,7 +3330,7 @@ static int32 lun_eclipse_how( * tret[6] time of penumbral phase begin * tret[7] time of penumbral phase end */ -int32 FAR PASCAL_CONV swe_lun_eclipse_when(double tjd_start, int32 ifl, int32 ifltype, +int32 swe_lun_eclipse_when(double tjd_start, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr) { int i, j, m, n, o, i1 = 0, i2 = 0; @@ -3585,7 +3585,7 @@ int32 FAR PASCAL_CONV swe_lun_eclipse_when(double tjd_start, int32 ifl, int32 if * attr[10] saros series member number * declare as attr[20] at least ! */ -int32 FAR PASCAL_CONV swe_lun_eclipse_when_loc(double tjd_start, int32 ifl, +int32 swe_lun_eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr) { int32 retflag = 0, retflag2 = 0, retc; @@ -3701,19 +3701,32 @@ int32 FAR PASCAL_CONV swe_lun_eclipse_when_loc(double tjd_start, int32 ifl, */ #define EULER 2.718281828459 #define NMAG_ELEM (SE_VESTA + 1) -static double mag_elem[NMAG_ELEM][4] = { +#define MAG_IAU_1986 +static const double mag_elem[NMAG_ELEM][4] = { /* DTV-Atlas Astronomie, p. 32 */ - {-26.86, 0, 0, 0}, - {-12.55, 0, 0, 0}, + {-26.86, 0, 0, 0}, /* Sun */ + {-12.55, 0, 0, 0}, /* Moon */ +#ifdef MAG_IAU_1986 /* IAU 1986 */ - {-0.42, 3.80, -2.73, 2.00}, - {-4.40, 0.09, 2.39, -0.65}, + {-0.42, 3.80, -2.73, 2.00}, /* Mercury */ + {-4.40, 0.09, 2.39, -0.65}, /* Venus */ {- 1.52, 1.60, 0, 0}, /* Mars */ {- 9.40, 0.5, 0, 0}, /* Jupiter */ {- 8.88, -2.60, 1.25, 0.044}, /* Saturn */ {- 7.19, 0.0, 0, 0}, /* Uranus */ {- 6.87, 0.0, 0, 0}, /* Neptune */ {- 1.00, 0.0, 0, 0}, /* Pluto */ +#else + /* IAU ???? */ + {-0.60, 0.0498, -0.000488, 0.00000302}, /* Mercury */ + {-5.18, 0.0103, 0.000057, 0.00000013}, /* Venus */ + {- 1.52, 0.016, 0, 0}, /* Mars */ + {- 9.40, 0.005, 0, 0}, /* Jupiter */ + {- 8.88, 0.044, 0, 0}, /* Saturn */ + {- 7.19, 0.0028, 0, 0}, /* Uranus */ + {- 6.87, 0.041, 0, 0}, /* Neptune */ + {- 1.00, 0.041, 0, 0}, /* Pluto */ +#endif {99, 0, 0, 0}, /* nodes and apogees */ {99, 0, 0, 0}, {99, 0, 0, 0}, @@ -3727,7 +3740,7 @@ static double mag_elem[NMAG_ELEM][4] = { {5.33, 0.32, 0, 0}, /* Juno */ {3.20, 0.32, 0, 0}, /* Vesta */ }; -int32 FAR PASCAL_CONV swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr, char *serr) +int32 swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr, char *serr) { int i; double xx[6], xx2[6], xxs[6], lbr[6], lbr2[6], dt = 0, dd; @@ -3862,11 +3875,19 @@ int32 FAR PASCAL_CONV swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr + mag_elem[ipl][3] * du + mag_elem[ipl][0]; } else if (ipl < SE_CHIRON) { +#ifdef MAG_IAU_1986 attr[4] = 5 * log10(lbr2[2] * lbr[2]) + mag_elem[ipl][1] * attr[0] /100.0 + mag_elem[ipl][2] * attr[0] * attr[0] / 10000.0 + mag_elem[ipl][3] * attr[0] * attr[0] * attr[0] / 1000000.0 + mag_elem[ipl][0]; +#else + attr[4] = 5 * log10(lbr2[2] * lbr[2]) + + mag_elem[ipl][1] * attr[0] + + mag_elem[ipl][2] * attr[0] * attr[0] + + mag_elem[ipl][3] * attr[0] * attr[0] * attr[0] + + mag_elem[ipl][0]; +#endif } else if (ipl < NMAG_ELEM || ipl > SE_AST_OFFSET) { /* asteroids */ ph1 = pow(EULER, -3.33 * pow(tan(attr[0] * DEGTORAD / 2), 0.63)); ph2 = pow(EULER, -1.87 * pow(tan(attr[0] * DEGTORAD / 2), 1.22)); @@ -3942,7 +3963,7 @@ int32 FAR PASCAL_CONV swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr return OK; } -int32 FAR PASCAL_CONV swe_pheno_ut(double tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr) +int32 swe_pheno_ut(double tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr) { double deltat; int32 retflag = OK; @@ -4025,7 +4046,7 @@ double rdi_twilight(int32 rsmi) * serr[256] error string * function return value -2 means that the body does not rise or set */ #define SEFLG_EPHMASK (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH) -int32 FAR PASCAL_CONV swe_rise_trans( +int32 swe_rise_trans( double tjd_ut, int32 ipl, char *starname, int32 epheflag, int32 rsmi, double *geopos, @@ -4038,7 +4059,7 @@ int32 FAR PASCAL_CONV swe_rise_trans( /* same as swe_rise_trans(), but allows to define the height of the horizon * at the point of the rising or setting (horhgt) */ -int32 FAR PASCAL_CONV swe_rise_trans_true_hor( +int32 swe_rise_trans_true_hor( double tjd_ut, int32 ipl, char *starname, int32 epheflag, int32 rsmi, double *geopos, @@ -4613,7 +4634,7 @@ barycentric position. * be returned instead of the aphelia. */ /* mean elements for Mercury - Neptune from VSOP87 (mean equinox of date) */ -static double el_node[8][4] = +static const double el_node[8][4] = {{ 48.330893, 1.1861890, 0.00017587, 0.000000211,}, /* Mercury */ { 76.679920, 0.9011190, 0.00040665, -0.000000080,}, /* Venus */ { 0 , 0 , 0 , 0 ,}, /* Earth */ @@ -4623,7 +4644,7 @@ static double el_node[8][4] = { 74.005947, 0.5211258, 0.00133982, 0.000018516,}, /* Uranus */ {131.784057, 1.1022057, 0.00026006, -0.000000636,}, /* Neptune */ }; -static double el_peri[8][4] = +static const double el_peri[8][4] = {{ 77.456119, 1.5564775, 0.00029589, 0.000000056,}, /* Mercury */ {131.563707, 1.4022188, -0.00107337, -0.000005315,}, /* Venus */ {102.937348, 1.7195269, 0.00045962, 0.000000499,}, /* Earth */ @@ -4633,7 +4654,7 @@ static double el_peri[8][4] = {173.005159, 1.4863784, 0.00021450, 0.000000433,}, /* Uranus */ { 48.123691, 1.4262677, 0.00037918, -0.000000003,}, /* Neptune */ }; -static double el_incl[8][4] = +static const double el_incl[8][4] = {{ 7.004986, 0.0018215, -0.00001809, 0.000000053,}, /* Mercury */ { 3.394662, 0.0010037, -0.00000088, -0.000000007,}, /* Venus */ { 0, 0, 0, 0 ,}, /* Earth */ @@ -4643,7 +4664,7 @@ static double el_incl[8][4] = { 0.773196, 0.0007744, 0.00003749, -0.000000092,}, /* Uranus */ { 1.769952, -0.0093082, -0.00000708, 0.000000028,}, /* Neptune */ }; -static double el_ecce[8][4] = +static const double el_ecce[8][4] = {{ 0.20563175, 0.000020406, -0.0000000284, -0.00000000017,}, /* Mercury */ { 0.00677188, -0.000047766, 0.0000000975, 0.00000000044,}, /* Venus */ { 0.01670862, -0.000042037, -0.0000001236, 0.00000000004,}, /* Earth */ @@ -4653,7 +4674,7 @@ static double el_ecce[8][4] = { 0.04629590, -0.000027337, 0.0000000790, 0.00000000025,}, /* Uranus */ { 0.00898809, 0.000006408, -0.0000000008, -0.00000000005,}, /* Neptune */ }; -static double el_sema[8][4] = +static const double el_sema[8][4] = {{ 0.387098310, 0.0, 0.0, 0.0,}, /* Mercury */ { 0.723329820, 0.0, 0.0, 0.0,}, /* Venus */ { 1.000001018, 0.0, 0.0, 0.0,}, /* Earth */ @@ -4664,7 +4685,7 @@ static double el_sema[8][4] = { 30.110386869, -0.0000001663, 0.00000000069, 0.0,}, /* Neptune */ }; /* Ratios of mass of Sun to masses of the planets */ -static double plmass[9] = { +static const double plmass[9] = { 6023600, /* Mercury */ 408523.5, /* Venus */ 328900.5, /* Earth and Moon */ @@ -4675,8 +4696,8 @@ static double plmass[9] = { 19314, /* Neptune */ 130000000, /* Pluto */ }; -static int ipl_to_elem[15] = {2, 0, 0, 1, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 2,}; -int32 FAR PASCAL_CONV swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, +static const int ipl_to_elem[15] = {2, 0, 0, 1, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 2,}; +int32 swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, int32 method, double *xnasc, double *xndsc, double *xperi, double *xaphe, @@ -4702,7 +4723,7 @@ int32 FAR PASCAL_CONV swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, struct plan_data pldat; double *xsun = psbdp->x; double *xear = pedp->x; - double *ep; + const double *ep; double Gmsm, dzmin; double rxy, rxyz, fac, sgn; double sinnode, cosnode, sinincl, cosincl, sinu, cosu, sinE, cosE, cosE2; @@ -5189,11 +5210,11 @@ int32 FAR PASCAL_CONV swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, if (iflag & SEFLG_SIDEREAL) { /* project onto ecliptic t0 */ if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { - if (swi_trop_ra2sid_lon(x2000, pldat.xreturn+6, pldat.xreturn+18, iflag, serr) != OK) + if (swi_trop_ra2sid_lon(x2000, pldat.xreturn+6, pldat.xreturn+18, iflag) != OK) return ERR; /* project onto solar system equator */ } else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { - if (swi_trop_ra2sid_lon_sosy(x2000, pldat.xreturn+6, pldat.xreturn+18, iflag, serr) != OK) + if (swi_trop_ra2sid_lon_sosy(x2000, pldat.xreturn+6, iflag) != OK) return ERR; } else { /* traditional algorithm */ @@ -5255,7 +5276,7 @@ int32 FAR PASCAL_CONV swe_nod_aps(double tjd_et, int32 ipl, int32 iflag, return OK; } -int32 FAR PASCAL_CONV swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, +int32 swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, int32 method, double *xnasc, double *xndsc, double *xperi, double *xaphe, @@ -5285,7 +5306,7 @@ int32 FAR PASCAL_CONV swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag, * dgsect is return area (pointer to a double) * serr is pointer to error string, may be NULL */ -int32 FAR PASCAL_CONV swe_gauquelin_sector(double t_ut, int32 ipl, char *starname, int32 iflag, int32 imeth, double *geopos, double atpress, double attemp, double *dgsect, char *serr) +int32 swe_gauquelin_sector(double t_ut, int32 ipl, char *starname, int32 iflag, int32 imeth, double *geopos, double atpress, double attemp, double *dgsect, char *serr) { AS_BOOL rise_found = TRUE; AS_BOOL set_found = TRUE; diff --git a/swisseph/swedate.c b/swisseph/swedate.c index 838ed06..e605dbe 100644 --- a/swisseph/swedate.c +++ b/swisseph/swedate.c @@ -86,10 +86,10 @@ # include "swephexp.h" # include "sweph.h" -static AS_BOOL init_leapseconds_done = FALSE; +static TLS AS_BOOL init_leapseconds_done = FALSE; -int FAR PASCAL_CONV swe_date_conversion(int y, +int swe_date_conversion(int y, int m, int d, /* day, month, year */ double uttime, /* UT in hours (decimal) */ @@ -161,7 +161,7 @@ int FAR PASCAL_CONV swe_date_conversion(int y, and notifies errors like 32 January. ****************************************************************/ -double FAR PASCAL_CONV swe_julday(int year, int month, int day, double hour, int gregflag) +double swe_julday(int year, int month, int day, double hour, int gregflag) { double jd; double u,u0,u1,u2; @@ -202,7 +202,7 @@ double FAR PASCAL_CONV swe_julday(int year, int month, int day, double hour, int Original author Mark Pottenger, Los Angeles. with bug fix for year < -4711 16-aug-88 Alois Treindl *************************************************************************/ -void FAR PASCAL_CONV swe_revjul (double jd, int gregflag, +void swe_revjul (double jd, int gregflag, int *jyear, int *jmon, int *jday, double *jut) { double u0,u1,u2,u3,u4; @@ -236,7 +236,7 @@ void FAR PASCAL_CONV swe_revjul (double jd, int gregflag, * For conversion from local time to utc, use +d_timezone. * For conversion from utc to local time, use -d_timezone. */ -void FAR PASCAL_CONV swe_utc_time_zone( +void swe_utc_time_zone( int32 iyear, int32 imonth, int32 iday, int32 ihour, int32 imin, double dsec, double d_timezone, @@ -278,7 +278,7 @@ void FAR PASCAL_CONV swe_utc_time_zone( /* Leap seconds were inserted at the end of the following days:*/ #define NLEAP_SECONDS 26 #define NLEAP_SECONDS_SPACE 100 -static int leap_seconds[NLEAP_SECONDS_SPACE] = { +static TLS int leap_seconds[NLEAP_SECONDS_SPACE] = { 19720630, 19721231, 19731231, @@ -376,7 +376,7 @@ static int init_leapsec(void) * the leap seconds table (or the Swiss Ephemeris version) is not updated * for a long time. */ -int32 FAR PASCAL_CONV swe_utc_to_jd(int32 iyear, int32 imonth, int32 iday, int32 ihour, int32 imin, double dsec, int32 gregflag, double *dret, char *serr) +int32 swe_utc_to_jd(int32 iyear, int32 imonth, int32 iday, int32 ihour, int32 imin, double dsec, int32 gregflag, double *dret, char *serr) { double tjd_ut1, tjd_et, tjd_et_1972, dhour, d; int iyear2, imonth2, iday2; @@ -487,7 +487,7 @@ int32 FAR PASCAL_CONV swe_utc_to_jd(int32 iyear, int32 imonth, int32 iday, int32 * the leap seconds table (or the Swiss Ephemeris version) has not been * updated for a long time. */ -void FAR PASCAL_CONV swe_jdet_to_utc(double tjd_et, int32 gregflag, int32 *iyear, int32 *imonth, int32 *iday, int32 *ihour, int32 *imin, double *dsec) +void swe_jdet_to_utc(double tjd_et, int32 gregflag, int32 *iyear, int32 *imonth, int32 *iday, int32 *ihour, int32 *imin, double *dsec) { int i; int second_60 = 0; @@ -584,7 +584,7 @@ void FAR PASCAL_CONV swe_jdet_to_utc(double tjd_et, int32 gregflag, int32 *iyear * the leap seconds table (or the Swiss Ephemeris version) has not been * updated for a long time. */ -void FAR PASCAL_CONV swe_jdut1_to_utc(double tjd_ut, int32 gregflag, int32 *iyear, int32 *imonth, int32 *iday, int32 *ihour, int32 *imin, double *dsec) +void swe_jdut1_to_utc(double tjd_ut, int32 gregflag, int32 *iyear, int32 *imonth, int32 *iday, int32 *ihour, int32 *imin, double *dsec) { double tjd_et = tjd_ut + swe_deltat_ex(tjd_ut, -1, NULL); swe_jdet_to_utc(tjd_et, gregflag, iyear, imonth, iday, ihour, imin, dsec); diff --git a/swisseph/swedate.h b/swisseph/swedate.h index a03e3e1..86749cc 100644 --- a/swisseph/swedate.h +++ b/swisseph/swedate.h @@ -62,17 +62,17 @@ extern "C" { #endif #ifndef _SWEDLL_H -extern EXP32 int FAR PASCAL_CONV EXP16 swe_date_conversion ( +extern EXP32 int swe_date_conversion ( int y , int m , int d , /* year, month, day */ double utime, /* universal time in hours (decimal) */ char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */ double *tgmt); -extern EXP32 double *FAR PASCAL_CONV EXP16 swe_julday( +extern EXP32 double *swe_julday( int year, int month, int day, double hour, int gregflag); -extern EXP32 void FAR PASCAL_CONV EXP16 swe_revjul ( +extern EXP32 void swe_revjul ( double jd, int gregflag, int *jyear, int *jmon, int *jday, double *jut); diff --git a/swisseph/swehel.c b/swisseph/swehel.c index 518bcb7..708e5dd 100644 --- a/swisseph/swehel.c +++ b/swisseph/swehel.c @@ -320,9 +320,9 @@ int32 call_swe_calc(double tjd, int32 ipl, int32 iflag, double *x, char *serr) { int32 retval = OK, ipli, i; double dtjd; - static double tjdsv[3]; - static double xsv[3][6]; - static int32 iflagsv[3]; + static TLS double tjdsv[3]; + static TLS double xsv[3][6]; + static TLS int32 iflagsv[3]; ipli = ipl; if (ipli > SE_MOON) ipli = 2; @@ -360,8 +360,8 @@ int32 call_swe_fixstar_mag(char *star, double *mag, char *serr) { int32 retval; char star2[AS_MAXCH]; - static double dmag; - static char star_save[AS_MAXCH]; + static TLS double dmag; + static TLS char star_save[AS_MAXCH]; if (strcmp(star, star_save) == 0) { *mag = dmag; return OK; @@ -530,8 +530,8 @@ static double SunRA(double JDNDaysUT, int32 helflag, char *serr) { int imon, iday, iyar, calflag = SE_GREG_CAL; double dut; - static double tjdlast; - static double ralast; + static TLS double tjdlast; + static TLS double ralast; if (JDNDaysUT == tjdlast) return ralast; #ifndef SIMULATE_VICTORVB @@ -789,7 +789,7 @@ static double kW(double HeightEye, double TempS, double RH) static double kOZ(double AltS, double sunra, double Lat) { double CHANGEKO, OZ, LT, kOZret; - static double koz_last, alts_last, sunra_last; + static TLS double koz_last, alts_last, sunra_last; if (AltS == alts_last && sunra == sunra_last) return koz_last; alts_last = AltS; sunra_last = sunra; @@ -849,7 +849,7 @@ static double ka(double AltS, double sunra, double Lat, double HeightEye, double /* depending on day/night vision (altitude of sun < start astronomical twilight), * lambda eye sensibility changes * see extinction section of Vistas in Astronomy page 343 */ - static double alts_last, sunra_last, ka_last; + static TLS double alts_last, sunra_last, ka_last; if (AltS == alts_last && sunra == sunra_last) return ka_last; alts_last = AltS; sunra_last = sunra; @@ -1001,7 +1001,7 @@ static double Deltam(double AltO, double AltS, double sunra, double Lat, double double TempE = TempEfromTempS(datm[1], HeightEye, LapseSA); double AppAltO = AppAltfromTopoAlt(AltO, TempE, PresE, helflag); double deltam; - static double alts_last, alto_last, sunra_last, deltam_last; + static TLS double alts_last, alto_last, sunra_last, deltam_last; if (AltS == alts_last && AltO == alto_last && sunra == sunra_last) return deltam_last; alts_last = AltS; alto_last = AltO; sunra_last = sunra; @@ -1095,9 +1095,9 @@ static int32 fast_magnitude(double tjd, double *dgeo, char *ObjectName, int32 he { int32 retval = OK, ipl, ipli; double dtjd; - static double tjdsv[3]; - static double dmagsv[3]; - static int32 helflagsv[3]; + static TLS double tjdsv[3]; + static TLS double dmagsv[3]; + static TLS int32 helflagsv[3]; ipl = DeterObject(ObjectName); ipli = ipl; if (ipli > SE_MOON) @@ -1376,7 +1376,7 @@ static double VisLimMagn(double *dobs, double AltO, double AziO, double AltM, do * |1 OK, scotopic vision * |2 OK, near limit photopic/scotopic */ -int32 FAR PASCAL_CONV swe_vis_limit_mag(double tjdut, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, double *dret, char *serr) +int32 swe_vis_limit_mag(double tjdut, double *dgeo, double *datm, double *dobs, char *ObjectName, int32 helflag, double *dret, char *serr) { int32 retval = OK, i, scotopic_flag = 0; double AltO, AziO, AltM, AziM, AltS, AziS; @@ -1512,7 +1512,7 @@ static int32 TopoArcVisionis(double Magn, double *dobs, double AltO, double AziO return OK; } -int32 FAR PASCAL_CONV swe_topo_arcus_visionis(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double alt_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr) +int32 swe_topo_arcus_visionis(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double alt_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr) { double sunra; swi_set_tid_acc(tjdut, helflag, 0, serr); @@ -1605,7 +1605,7 @@ static int32 HeliacalAngle(double Magn, double *dobs, double AziO, double AltM, return OK; } -int32 FAR PASCAL_CONV swe_heliacal_angle(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr) +int32 swe_heliacal_angle(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr) { if (dgeo[2] < SEI_ECL_GEOALT_MIN || dgeo[2] > SEI_ECL_GEOALT_MAX) { if (serr != NULL) @@ -1768,7 +1768,7 @@ static void strcpy_VBsafe(char *sout, char *sin) '28=CVAact [deg] 'new '29=MSk [-] */ -int32 FAR PASCAL_CONV swe_heliacal_pheno_ut(double JDNDaysUT, double *dgeo, double *datm, double *dobs, char *ObjectNameIn, int32 TypeEvent, int32 helflag, double *darr, char *serr) +int32 swe_heliacal_pheno_ut(double JDNDaysUT, double *dgeo, double *datm, double *dobs, char *ObjectNameIn, int32 TypeEvent, int32 helflag, double *darr, char *serr) { double AziS, AltS, AltS2, AziO, AltO, AltO2, GeoAltO, AppAltO, DAZact, TAVact, ParO, MagnO; double ARCVact, ARCLact, kact, WMoon, LMoon = 0, qYal, qCrit; @@ -1982,7 +1982,7 @@ darr[30] = darr[26] + darr[27] + darr[28] + darr[29]; } #if 0 -int32 FAR PASCAL_CONV HeliacalJDut(double JDNDaysUTStart, double Age, double SN, double Lat, double Longitude, double HeightEye, double Temperature, double Pressure, double RH, double VR, char *ObjectName, int TypeEvent, char *AVkind, double *dret, char *serr) +int32 HeliacalJDut(double JDNDaysUTStart, double Age, double SN, double Lat, double Longitude, double HeightEye, double Temperature, double Pressure, double RH, double VR, char *ObjectName, int TypeEvent, char *AVkind, double *dret, char *serr) { double dgeo[3], datm[4], dobs[6]; int32 helflag = SE_HELFLAG_HIGH_PRECISION; @@ -2471,7 +2471,7 @@ static int32 get_asc_obl_diff_old(double tjd, int32 ipl, char *star, int32 iflag * - superior and inferior conjunction (Mercury and Venus) * - conjunction and opposition (ipl >= Mars) */ -static double tcon[] = +static const double tcon[] = { 0, 0, 2451550, 2451550, /* Moon */ @@ -3237,7 +3237,7 @@ static int32 heliacal_ut(double JDNDaysUTStart, double *dgeo, double *datm, doub ' dret[2]: end of visibility (Julian day number; 0 if SE_HELFLAG_AV) ' see http://www.iol.ie/~geniet/eng/atmoastroextinction.htm */ -int32 FAR PASCAL_CONV swe_heliacal_ut(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, char *ObjectNameIn, int32 TypeEvent, int32 helflag, double *dret, char *serr_ret) +int32 swe_heliacal_ut(double JDNDaysUTStart, double *dgeo, double *datm, double *dobs, char *ObjectNameIn, int32 TypeEvent, int32 helflag, double *dret, char *serr_ret) { int32 retval, Planet, itry; char ObjectName[AS_MAXCH], serr[AS_MAXCH], s[AS_MAXCH]; diff --git a/swisseph/swehouse.c b/swisseph/swehouse.c index fd11f61..41b5c70 100644 --- a/swisseph/swehouse.c +++ b/swisseph/swehouse.c @@ -112,7 +112,7 @@ static int sidereal_houses_ssypl(double tjde, * ascmc[6] = coasc2 * "co-ascendant" (M. Munkasey) * * ascmc[7] = polasc * "polar ascendant" (M. Munkasey) * */ -int FAR PASCAL_CONV swe_houses(double tjd_ut, +int swe_houses(double tjd_ut, double geolat, double geolon, int hsys, @@ -162,7 +162,7 @@ int FAR PASCAL_CONV swe_houses(double tjd_ut, * ascmc[6] = coasc2 * "co-ascendant" (M. Munkasey) * * ascmc[7] = polasc * "polar ascendant" (M. Munkasey) * */ -int FAR PASCAL_CONV swe_houses_ex(double tjd_ut, +int swe_houses_ex(double tjd_ut, int32 iflag, double geolat, double geolon, @@ -497,7 +497,7 @@ static int sidereal_houses_trad(double tjde, * ascmc[6] = coasc2 * "co-ascendant" (M. Munkasey) * * ascmc[7] = polasc * "polar ascendant" (M. Munkasey) * */ -int FAR PASCAL_CONV swe_houses_armc( +int swe_houses_armc( double armc, double geolat, double eps, @@ -556,7 +556,7 @@ int FAR PASCAL_CONV swe_houses_armc( fprintf(swi_fp_trace_out, "swe_houses_armc: %f\t%f\t%f\t%c\t\n", armc, geolat, eps, hsys); fprintf(swi_fp_trace_out, "retc = %d\n", retc); fputs("cusp:\n", swi_fp_trace_out); - for (i = 0; i < 12; i++) + for (i = 1; i <= 12; i++) fprintf(swi_fp_trace_out, " %d\t%f\n", i, cusp[i]); fputs("ascmc:\n", swi_fp_trace_out); for (i = 0; i < 10; i++) @@ -617,7 +617,7 @@ static double apc_sector(int n, double ph, double e, double az) return dret; } -char *FAR PASCAL_CONV swe_house_name(int hsys) +char *swe_house_name(int hsys) { switch (toupper(hsys)) { case 'A': return "equal"; @@ -1376,7 +1376,7 @@ static double Asc2 (double x, double f, double sine, double cose) * equal, Porphyry, Alcabitius, Koch, Krusinski (all others should work). * The Swiss Ephemeris currently does not handle these cases. */ -double FAR PASCAL_CONV swe_house_pos( +double swe_house_pos( double armc, double geolat, double eps, int hsys, double *xpin, char *serr) { double xp[6], xeq[6], ra, de, mdd, mdn, sad, san; diff --git a/swisseph/swejpl.c b/swisseph/swejpl.c index 5f39625..053aa72 100644 --- a/swisseph/swejpl.c +++ b/swisseph/swejpl.c @@ -106,11 +106,11 @@ struct jpl_save { short do_km; }; -static struct jpl_save *FAR js; +static TLS struct jpl_save *js; static int state (double et, int32 *list, int do_bary, double *pv, double *pvsun, double *nut, char *serr); -static int interp(double FAR *buf, double t, double intv, int32 ncfin, +static int interp(double *buf, double t, double intv, int32 ncfin, int32 ncmin, int32 nain, int32 ifl, double *pv); static int32 fsizer(char *serr); static void reorder(char *x, int size, int number); @@ -349,8 +349,8 @@ int swi_pleph(double et, int ntarg, int ncent, double *rrd, char *serr) { int i, retc; int32 list[12]; - double FAR *pv = js->pv; - double FAR *pvsun = js->pvsun; + double *pv = js->pv; + double *pvsun = js->pvsun; for (i = 0; i < 6; ++i) rrd[i] = 0.0; if (ntarg == ncent) @@ -455,18 +455,18 @@ int swi_pleph(double et, int ntarg, int ncent, double *rrd, char *serr) * pv d.p. interpolated quantities requested. * assumed dimension is pv(ncm,fl). */ -static int interp(double FAR *buf, double t, double intv, int32 ncfin, +static int interp(double *buf, double t, double intv, int32 ncfin, int32 ncmin, int32 nain, int32 ifl, double *pv) { /* Initialized data */ - static int FAR np, nv; - static int FAR nac; - static int FAR njk; - static double FAR twot = 0.; - double FAR *pc = js->pc; - double FAR *vc = js->vc; - double FAR *ac = js->ac; - double FAR *jc = js->jc; + static TLS int np, nv; + static TLS int nac; + static TLS int njk; + static TLS double twot = 0.; + double *pc = js->pc; + double *vc = js->vc; + double *ac = js->ac; + double *jc = js->jc; int ncf = (int) ncfin; int ncm = (int) ncmin; int na = (int) nain; @@ -641,15 +641,15 @@ static int state(double et, int32 *list, int do_bary, int i, j, k; int32 nseg; off_t flen, nb; - double FAR *buf = js->buf; + double *buf = js->buf; double aufac, s, t, intv, ts[4]; int32 nrecl, ksize; int32 nr; double et_mn, et_fr; - int32 FAR *ipt = js->eh_ipt; + int32 *ipt = js->eh_ipt; char ch_ttl[252]; - static int32 irecsz; - static int32 nrl, lpt[3], ncoeffs; + static TLS int32 irecsz; + static TLS int32 nrl, lpt[3], ncoeffs; if (js->jplfptr == NULL) { ksize = fsizer(serr); /* the number of single precision words in a record */ nrecl = 4; @@ -839,7 +839,7 @@ static int read_const_jpl(double *ss, char *serr) ss[i] = js->eh_ss[i]; #if DEBUG_DO_SHOW { - static char FAR *bname[] = { + static const char *bname[] = { "Mercury", "Venus", "EMB", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto", "Moon", "SunBary", "Nut", "Libr"}; int j, k; diff --git a/swisseph/swemmoon.c b/swisseph/swemmoon.c index 92c71f3..16595e6 100644 --- a/swisseph/swemmoon.c +++ b/swisseph/swemmoon.c @@ -187,7 +187,7 @@ static void mean_elements(void); static void mean_elements_pl(void); static double mods3600(double x); static void ecldat_equ2000(double tjd, double *xpm); -static void chewm(short *pt, int nlines, int nangles, +static void chewm(const short *pt, int nlines, int nangles, int typflg, double *ans ); static void sscc(int k, double arg, int n ); static void moon1(void); @@ -203,7 +203,7 @@ static void moon4(void); * See references to the array z[] later on in the program. * The 71 coefficients were estimated from 42,529 Lunar positions. */ -static double z[] = { +static const double z[] = { -1.225346551567e+001, /* F, t^2 */ -1.096676093208e-003, /* F, t^3 */ -2.165750777942e-006, /* F, t^4 */ @@ -282,7 +282,7 @@ static double z[] = { * interval from -3000 to +3000. * The coefficients were estimated from 34,247 Lunar positions. */ -static double FAR z[] = { +static const double z[] = { /* The following are scaled in arc seconds, time in Julian centuries. They replace the corresponding terms in the mean elements. */ -1.312045233711e+01, /* F, t^2 */ @@ -317,7 +317,7 @@ static double FAR z[] = { /* Perturbation tables */ #define NLR 118 -static short FAR LR[8*NLR] = { +static const short LR[8*NLR] = { /* Longitude Radius D l' l F 1" .0001" 1km .0001km */ @@ -445,7 +445,7 @@ static short FAR LR[8*NLR] = { #ifdef MOSH_MOON_200 #define NMB 56 -static short FAR MB[6*NMB] = { +static const short MB[6*NMB] = { /* Latitude D l' l F 1" .0001" */ @@ -509,7 +509,7 @@ static short FAR MB[6*NMB] = { }; #else #define NMB 77 -static short FAR MB[6*NMB] = { +static const short MB[6*NMB] = { /* Latitude D l' l F 1" .0001" */ @@ -595,7 +595,7 @@ static short FAR MB[6*NMB] = { #endif /* ! MOSH_MOON_200 */ #define NLRT 38 -static short FAR LRT[8*NLRT] = { +static const short LRT[8*NLRT] = { /* Multiply by T Longitude Radius @@ -642,7 +642,7 @@ Multiply by T }; #define NBT 16 -static short FAR BT[5*NBT] = { +static const short BT[5*NBT] = { /* Multiply by T Latitude @@ -667,7 +667,7 @@ Multiply by T }; #define NLRT2 25 -static short FAR LRT2[6*NLRT2] = { +static const short LRT2[6*NLRT2] = { /* Multiply by T^2 Longitude Radius @@ -701,7 +701,7 @@ Multiply by T^2 }; #define NBT2 12 -static short FAR BT2[5*NBT2] = { +static const short BT2[5*NBT2] = { /* Multiply by T^2 Latitiude @@ -723,7 +723,7 @@ Multiply by T^2 /* corrections for mean lunar node in degrees, from -13100 to 17200, * in 100-year steps. corrections are set to 0 between the years 0 and 3000 */ -static double mean_node_corr[] = { +static const double mean_node_corr[] = { -2.56, -2.473, -2.392347, -2.316425, -2.239639, -2.167764, -2.095100, -2.024810, -1.957622, -1.890097, -1.826389, -1.763335, -1.701047, -1.643016, -1.584186, -1.527309, -1.473352, -1.418917, -1.367736, -1.317202, -1.267269, @@ -765,7 +765,7 @@ static double mean_node_corr[] = { /* corrections for mean lunar apsides in degrees, from -13100 to 17200, * in 100-year steps. corrections are set to 0 between the years 0 and 3000 */ -static double mean_apsis_corr[] = { +static const double mean_apsis_corr[] = { 7.525, 7.290, 7.057295, 6.830813, 6.611723, 6.396775, 6.189569, 5.985968, 5.788342, 5.597304, 5.410167, 5.229946, 5.053389, 4.882187, 4.716494, 4.553532, 4.396734, 4.243718, 4.094282, 3.950865, 3.810366, @@ -809,39 +809,39 @@ static double mean_apsis_corr[] = { * to the same instant. The distinction between them * is required by altaz(). */ -static double FAR ss[5][8]; -static double FAR cc[5][8]; +static TLS double ss[5][8]; +static TLS double cc[5][8]; -static double l; /* Moon's ecliptic longitude */ -static double B; /* Ecliptic latitude */ +static TLS double l; /* Moon's ecliptic longitude */ +static TLS double B; /* Ecliptic latitude */ -static double moonpol[3]; +static TLS double moonpol[3]; /* Orbit calculation begins. */ -static double SWELP; -static double M; -static double MP; -static double D; -static double NF; -static double T; -static double T2; - -static double T3; -static double T4; -static double f; -static double g; -static double Ve; -static double Ea; -static double Ma; -static double Ju; -static double Sa; -static double cg; -static double sg; -static double l1; -static double l2; -static double l3; -static double l4; +static TLS double SWELP; +static TLS double M; +static TLS double MP; +static TLS double D; +static TLS double NF; +static TLS double T; +static TLS double T2; + +static TLS double T3; +static TLS double T4; +static TLS double f; +static TLS double g; +static TLS double Ve; +static TLS double Ea; +static TLS double Ma; +static TLS double Ju; +static TLS double Sa; +static TLS double cg; +static TLS double sg; +static TLS double l1; +static TLS double l2; +static TLS double l3; +static TLS double l4; /* Calculate geometric coordinates of Moon * without light time or nutation correction. @@ -1626,7 +1626,7 @@ int swi_mean_apog(double J, double *pol, char *serr) /* Program to step through the perturbation table */ -static void chewm(short *pt, int nlines, int nangles, int typflg, double *ans ) +static void chewm(const short *pt, int nlines, int nangles, int typflg, double *ans ) { int i, j, k, k1, m; double cu, su, cv, sv, ff; diff --git a/swisseph/swemplan.c b/swisseph/swemplan.c index 5f1b5f4..51794b6 100644 --- a/swisseph/swemplan.c +++ b/swisseph/swemplan.c @@ -82,11 +82,11 @@ static int read_elements_file(int32 ipl, double tjd, double *parg, double *node, double *incl, char *pname, int32 *fict_ifl, char *serr); -static int pnoint2msh[] = {2, 2, 0, 1, 3, 4, 5, 6, 7, 8, }; +static const int pnoint2msh[] = {2, 2, 0, 1, 3, 4, 5, 6, 7, 8, }; /* From Simon et al (1994) */ -static double freqs[] = +static const double freqs[] = { /* Arc sec per 10000 Julian years. */ 53810162868.8982, @@ -100,7 +100,7 @@ static double freqs[] = 52272245.1795 }; -static double phases[] = +static const double phases[] = { /* Arc sec. */ 252.25090552 * 3600., @@ -114,7 +114,7 @@ static double phases[] = 860492.1546, }; -static struct plantbl *planets[] = +static const struct plantbl *planets[] = { &mer404, &ven404, @@ -127,19 +127,19 @@ static struct plantbl *planets[] = &plu404 }; -static double FAR ss[9][24]; -static double FAR cc[9][24]; +static TLS double ss[9][24]; +static TLS double cc[9][24]; static void sscc (int k, double arg, int n); int swi_moshplan2 (double J, int iplm, double *pobj) { int i, j, k, m, k1, ip, np, nt; - signed char FAR *p; - double FAR *pl, *pb, *pr; + signed char *p; + double *pl, *pb, *pr; double su, cu, sv, cv, T; double t, sl, sb, sr; - struct plantbl *plan = planets[iplm]; + const struct plantbl *plan = planets[iplm]; T = (J - J2000) / TIMESCALE; /* Calculate sin( i*MM ), etc. for needed multiple angles. */ @@ -504,7 +504,7 @@ static void embofs_mosh(double tjd, double *xemb) */ #define SE_NEELY /* use James Neely's revised elements * of Uranian planets*/ -static char *plan_fict_nam[SE_NFICT_ELEM] = +static const char *plan_fict_nam[SE_NFICT_ELEM] = {"Cupido", "Hades", "Zeus", "Kronos", "Apollon", "Admetos", "Vulkanus", "Poseidon", "Isis-Transpluto", "Nibiru", "Harrington", @@ -520,7 +520,7 @@ char *swi_get_fict_name(int32 ipl, char *snam) return snam; } -static double plan_oscu_elem[SE_NFICT_ELEM][8] = { +static const double plan_oscu_elem[SE_NFICT_ELEM][8] = { #ifdef SE_NEELY {J1900, J1900, 163.7409, 40.99837, 0.00460, 171.4333, 129.8325, 1.0833},/* Cupido Neely */ {J1900, J1900, 27.6496, 50.66744, 0.00245, 148.1796, 161.3339, 1.0500},/* Hades Neely */ diff --git a/swisseph/swemptab.h b/swisseph/swemptab.h index 54612d3..2059056 100644 --- a/swisseph/swemptab.h +++ b/swisseph/swemptab.h @@ -1,10 +1,9 @@ /* SWISSEPH - $Header: /home/dieter/sweph/RCS/swemptab.h,v 1.74 2008/06/16 10:07:20 dieter Exp $ + $Header: /home/dieter/sweph/RCS/swemptab.c,v 1.74 2008/06/16 10:07:20 dieter Exp $ ATTENTION: this source file is not to be compiled separately, as it is #included by swemplan - -**************************************************************/ + */ /* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved. License conditions @@ -76,7 +75,7 @@ Days per record = 4.0 2500.0 to 3000.0: 0.42 0.13 0.16 3000.0 to 3000.8: 0.252 0.087 0.115 */ -static double FAR mertabl[] = { +static double mertabl[] = { 35.85255, -163.26379, 53810162857.56026, 908082.18475, 0.05214, -0.07712, @@ -363,7 +362,7 @@ static double FAR mertabl[] = { -0.00013, -0.00986, }; -static double FAR mertabb[] = { +static double mertabb[] = { 68.33369, 422.77623, -2057.26405, -2522.29068, -0.00030, -0.00009, @@ -650,7 +649,7 @@ static double FAR mertabb[] = { -0.01665, -0.00199, }; -static double FAR mertabr[] = { +static double mertabr[] = { -8.30490, -11.68232, 86.54880, 4361.05018, 0.00002, -0.00001, @@ -938,7 +937,7 @@ static double FAR mertabr[] = { }; -static signed char FAR merargs[] = { +static signed char merargs[] = { 0, 3, 3, 1, 1,-10, 3, 11, 4, 0, 2, 2, 5, -5, 6, 2, @@ -1072,7 +1071,7 @@ static signed char FAR merargs[] = { -1 }; /* Total terms = 130, small = 128 */ -static struct plantbl FAR mer404 = { +static struct plantbl mer404 = { { 11, 14, 10, 11, 4, 5, 2, 0, 0,}, 6, merargs, @@ -1100,7 +1099,7 @@ Days per record = 4.0 2500.0 to 3000.0: 0.30 0.15 0.10 3000.0 to 3000.8: 0.116 0.062 0.058 */ -static double FAR ventabl[] = { +static double ventabl[] = { 9.08078, 55.42416, 21066413644.98911, 655127.20186, 0.00329, 0.10408, @@ -1328,7 +1327,7 @@ static double FAR ventabl[] = { -0.00004, 0.00645, }; -static double FAR ventabb[] = { +static double ventabb[] = { -23.91858, 31.44154, 25.93273, -67.68643, -0.00171, 0.00123, @@ -1556,7 +1555,7 @@ static double FAR ventabb[] = { 0.00002, 0.00020, }; -static double FAR ventabr[] = { +static double ventabr[] = { -0.24459, 3.72698, -6.67281, 5.24378, 0.00030, 0.00003, @@ -1785,7 +1784,7 @@ static double FAR ventabr[] = { }; -static signed char FAR venargs[] = { +static signed char venargs[] = { 0, 3, 2, 2, 5, -5, 6, 0, 3, 2, 2, 1, 3, -8, 4, 0, @@ -1897,7 +1896,7 @@ static signed char FAR venargs[] = { -1 }; /* Total terms = 108, small = 107 */ -static struct plantbl FAR ven404 = { +static struct plantbl ven404 = { { 5, 14, 13, 8, 4, 5, 1, 0, 0,}, 5, venargs, @@ -1924,7 +1923,7 @@ Days per record = 6.0 3000.0 to 3000.8: 0.074 0.048 0.044 */ -static double FAR eartabl[] = { +static double eartabl[] = { -65.54655, -232.74963, 12959774227.57587, 361678.59587, 2.52679, -4.93511, 2.46852, -8.88928, @@ -2216,7 +2215,7 @@ static double FAR eartabl[] = { 0.00002, -0.00623, }; -static double FAR eartabb[] = { +static double eartabb[] = { -41.97860, -48.43539, 74.72897, 0.00075, -0.12774, -0.10188, -0.00943, -0.04574, @@ -2508,7 +2507,7 @@ static double FAR eartabb[] = { 0.00025, 0.00021, }; -static double FAR eartabr[] = { +static double eartabr[] = { 0.64577, -2.90183, -14.50280, 28.85196, 0.08672, -0.05643, 0.02353, -0.00404, @@ -2801,7 +2800,7 @@ static double FAR eartabr[] = { }; -static signed char FAR earargs[] = { +static signed char earargs[] = { 0, 3, 3, 4, 3, -8, 4, 3, 5, 2, 2, 2, 5, -5, 6, 1, @@ -2940,7 +2939,7 @@ static signed char FAR earargs[] = { -1 }; /* Total terms = 135, small = 134 */ -static struct plantbl FAR ear404 = { +static struct plantbl ear404 = { { 1, 9, 14, 17, 5, 5, 2, 1, 0,}, 4, earargs, @@ -2967,7 +2966,7 @@ Days per record = 4.0 3000.0 to 3000.8: 0.182 0.125 0.087 */ -static double FAR martabl[] = { +static double martabl[] = { 43471.66140, 21291.11063, 2033.37848, 6890507597.78366, 1279543.73631, @@ -3409,7 +3408,7 @@ static double FAR martabl[] = { -0.00723, -0.01536, }; -static double FAR martabb[] = { +static double martabb[] = { -364.49380, -47.17612, -554.97858, -430.63121, 596.44312, @@ -3851,7 +3850,7 @@ static double FAR martabb[] = { 0.00826, -0.00524, }; -static double FAR martabr[] = { +static double martabr[] = { -816.07287, -381.41365, -33.69436, 177.22955, 0.18630, @@ -4294,7 +4293,7 @@ static double FAR martabr[] = { }; -static signed char FAR marargs[] = { +static signed char marargs[] = { 0, 4, 3, 4, 3, -8, 4, 3, 5, 2, 3, 5, 2, -6, 3, -4, 4, 0, @@ -4499,7 +4498,7 @@ static signed char FAR marargs[] = { -1 }; /* Total terms = 201, small = 199 */ -static struct plantbl FAR mar404 = { +static struct plantbl mar404 = { { 0, 5, 12, 24, 9, 7, 3, 2, 0,}, 5, marargs, @@ -4528,7 +4527,7 @@ Days per record = 131.0 2500.0 to 3000.0: 0.70 0.09 0.36 3000.0 to 3000.4: 0.526 0.023 0.190 */ -static double FAR juptabl[] = { +static double juptabl[] = { 153429.13855, 130818.16897, 18120.42948, -8463.12663, -5058.91447, 1092566021.02148, 123671.25097, @@ -4874,7 +4873,7 @@ static double FAR juptabl[] = { 0.00011, 0.12033, }; -static double FAR juptabb[] = { +static double juptabb[] = { 548.59659, 594.29629, 219.97664, 59.71822, 23.62157, 40.77732, 227.07380, @@ -5220,7 +5219,7 @@ static double FAR juptabb[] = { -0.00006, 0.00001, }; -static double FAR juptabr[] = { +static double juptabr[] = { -734.58857, -1081.04460, -551.65750, -148.79782, -25.23171, 164.64781, 248.64813, @@ -5567,7 +5566,7 @@ static double FAR juptabr[] = { }; -static signed char FAR jupargs[] = { +static signed char jupargs[] = { 0, 6, 3, 2, 5, -6, 6, 3, 7, 0, 2, 2, 5, -5, 6, 6, @@ -5713,7 +5712,7 @@ static signed char FAR jupargs[] = { -1 }; /* Total terms = 142, small = 140 */ -static struct plantbl FAR jup404 = { +static struct plantbl jup404 = { { 0, 0, 1, 0, 9, 16, 7, 5, 0,}, 6, jupargs, @@ -5742,7 +5741,7 @@ Days per record = 131.0 2500.0 to 3000.0: 0.63 0.22 0.53 3000.0 to 3000.4: 0.047 0.073 0.086 */ -static double FAR sattabl[] = { +static double sattabl[] = { 1788381.26240, 2460423.68044, 1370113.15868, 415406.99187, 72040.39885, 12669.58806, 439960754.85333, 180256.80433, @@ -6231,7 +6230,7 @@ static double FAR sattabl[] = { -0.00010, 0.06547, }; -static double FAR sattabb[] = { +static double sattabb[] = { -567865.62548, -796277.29029, -410804.00791, -91793.12562, -6268.13975, 398.64391, -710.67442, 175.29456, @@ -6720,7 +6719,7 @@ static double FAR sattabb[] = { -0.00003, -0.00013, }; -static double FAR sattabr[] = { +static double sattabr[] = { -38127.94034, -48221.08524, -20986.93487, -3422.75861, -8.97362, 53.34259, -404.15708, -0.05434, @@ -7210,7 +7209,7 @@ static double FAR sattabr[] = { }; -static signed char FAR satargs[] = { +static signed char satargs[] = { 0, 7, 3, 2, 5, -6, 6, 3, 7, 0, 2, 2, 5, -5, 6, 5, @@ -7429,7 +7428,7 @@ static signed char FAR satargs[] = { -1 }; /* Total terms = 215, small = 211 */ -static struct plantbl FAR sat404 = { +static struct plantbl sat404 = { { 0, 0, 1, 0, 8, 18, 9, 5, 0,}, 7, satargs, @@ -7458,7 +7457,7 @@ Days per record = 131.0 2500.0 to 3000.0: 0.34 0.06 0.32 3000.0 to 3000.4: 0.406 0.035 0.172 */ -static double FAR uratabl[] = { +static double uratabl[] = { 21.56000, -4652.06828, 154246324.90417, 1130486.05080, 330.11531, -3020.20235, @@ -7842,7 +7841,7 @@ static double FAR uratabl[] = { -0.01517, 0.03748, }; -static double FAR uratabb[] = { +static double uratabb[] = { 0.00000, 107.91527, 83.39404, -124.29804, -7.73277, -3.99442, @@ -8226,7 +8225,7 @@ static double FAR uratabb[] = { 0.00005, 0.00003, }; -static double FAR uratabr[] = { +static double uratabr[] = { 0.00000, -53.23277, -44.70609, -62.54432, -19.15218, 0.10867, @@ -8611,7 +8610,7 @@ static double FAR uratabr[] = { }; -static signed char FAR uraargs[] = { +static signed char uraargs[] = { 0, 3, 2, 1, 7, -2, 8, 0, 2, 2, 7, -4, 8, 0, @@ -8792,7 +8791,7 @@ static signed char FAR uraargs[] = { -1 }; /* Total terms = 177, small = 171 */ -static struct plantbl FAR ura404 = { +static struct plantbl ura404 = { { 0, 0, 0, 0, 5, 10, 9, 12, 0,}, 6, uraargs, @@ -8821,7 +8820,7 @@ Days per record = 131.0 2500.0 to 3000.0: 0.43 0.25 0.46 3000.0 to 3000.4: 0.122 0.071 0.260 */ -static double FAR neptabl[] = { +static double neptabl[] = { -1376.86480, 730.38970, 78655362.50948, 1095691.38676, -196.19023, 2086.77782, @@ -8943,7 +8942,7 @@ static double FAR neptabl[] = { -0.28141, 0.25061, -0.20293, 0.79930, }; -static double FAR neptabb[] = { +static double neptabb[] = { -391.05987, -243.95958, -23.83558, 58.13857, 5.04859, -3.93183, @@ -9065,7 +9064,7 @@ static double FAR neptabb[] = { 0.00106, 0.00025, 0.00013, -0.00019, }; -static double FAR neptabr[] = { +static double neptabr[] = { -767.68936, -460.59576, -52.41861, -273.85897, 59.52489, 1.85006, @@ -9188,7 +9187,7 @@ static double FAR neptabr[] = { }; -static signed char FAR nepargs[] = { +static signed char nepargs[] = { 0, 3, 2, 1, 7, -2, 8, 0, 3, 3, 5, -8, 6, 3, 8, 0, @@ -9251,7 +9250,7 @@ static signed char FAR nepargs[] = { -1 }; /* Total terms = 59, small = 58 */ -static struct plantbl FAR nep404 = { +static struct plantbl nep404 = { { 0, 0, 0, 0, 3, 8, 7, 9, 0,}, 3, nepargs, @@ -9280,7 +9279,7 @@ Days per record = 131.0 2500.0 to 3000.0: 1.09 0.70 0.46 3000.0 to 3000.4: 0.871 0.395 0.051 */ -static double FAR plutabl[] = { +static double plutabl[] = { 74986469.33577, 100898343.73690, 48199471.54076, 9520076.03177, 690431.67340, -427355.12716, 52266623.77862, 860190.70714, @@ -9671,7 +9670,7 @@ static double FAR plutabl[] = { -0.06243, 0.04306, }; -static double FAR plutabb[] = { +static double plutabb[] = { -35042727.30412, -49049197.81293, -25374963.60995, -5761406.03035, -467370.57540, 14040.11453, 2329.15763, -13978.69390, @@ -10062,7 +10061,7 @@ static double FAR plutabb[] = { 0.05985, 0.04130, }; -static double FAR plutabr[] = { +static double plutabr[] = { 17990649.12487, 24806479.30874, 12690953.00645, 2892671.69562, 249947.71316, -5138.71425, 1142.68629, 6075.25751, @@ -10454,7 +10453,7 @@ static double FAR plutabr[] = { }; -static signed char FAR pluargs[] = { +static signed char pluargs[] = { 0, 7, 2, 3, 7, -9, 9, 0, 2, 4, 7,-12, 9, 0, @@ -10631,7 +10630,7 @@ static signed char FAR pluargs[] = { -1 }; /* Total terms = 173, small = 156 */ -static struct plantbl FAR plu404 = { +static struct plantbl plu404 = { { 0, 0, 0, 0, 2, 2, 9, 13, 13,}, 7, pluargs, diff --git a/swisseph/swenut2000a.h b/swisseph/swenut2000a.h index b62b0f9..2845add 100644 --- a/swisseph/swenut2000a.h +++ b/swisseph/swenut2000a.h @@ -69,7 +69,7 @@ #define NPL 687 /* Luni-Solar argument multipliers L L' F D Om */ -static int16 nls[] = { +static const int16 nls[] = { 0, 0, 0, 0, 1, 0, 0, 2, -2, 2, 0, 0, 2, 0, 2, @@ -752,7 +752,7 @@ static int16 nls[] = { /* Luni-Solar nutation coefficients, unit 1e-7 arcsec * longitude (sin, t*sin, cos), obliquity (cos, t*cos, sin) */ -static int32 cls[] = { +static const int32 cls[] = { -172064161, -174666, 33386, 92052331, 9086, 15377, -13170906, -1675, -13696, 5730336, -3015, -4587, -2276413, -234, 2796, 978459, -485, 1374, @@ -1436,7 +1436,7 @@ static int32 cls[] = { /*#if NUT_IAU_2000A*/ /* Planetary argument multipliers * L L' F D Om Me Ve E Ma Ju Sa Ur Ne pre */ -static int16 npl[] = { +static const int16 npl[] = { 0, 0, 0, 0, 0, 0, 0, 8,-16, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -8, 16, -4, -5, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 8,-16, 4, 5, 0, 0, 2, @@ -2128,7 +2128,7 @@ static int16 npl[] = { /* Planetary nutation coefficients, unit 1e-7 arcsec * longitude (sin, cos), obliquity (sin, cos) */ -static int16 icpl[] = { +static const int16 icpl[] = { 1440, 0, 0, 0, 56, -117, -42, -40, 125, -43, 0, -54, diff --git a/swisseph/sweodef.h b/swisseph/sweodef.h index 2d5bbac..9221856 100644 --- a/swisseph/sweodef.h +++ b/swisseph/sweodef.h @@ -75,6 +75,16 @@ # define MY_TRUE 1 /* for use in other defines, before TRUE is defined */ # define MY_FALSE 0 /* for use in other defines, before TRUE is defined */ +/* TLS support + * + * Sun Studio C/C++, IBM XL C/C++, GNU C and Intel C/C++ (Linux systems) -> __thread + * Borland, VC++ -> __declspec(thread) + */ +#if defined( __GNUC__ ) +#define TLS __thread +#else +#define TLS __declspec(thread) +#endif #ifdef _WIN32 /* Microsoft VC 5.0 does not define MSDOS anymore */ # undef MSDOS @@ -135,12 +145,10 @@ # ifndef TURBO_C # define MS_C /* assume Microsoft C compiler */ # endif -# define MYFAR far # define UNIX_FS MY_FALSE #else # ifdef MACOS # define HPUNIX MY_FALSE -# define MYFAR # define UNIX_FS MY_FALSE # else # define MSDOS MY_FALSE @@ -148,7 +156,6 @@ # ifndef _HPUX_SOURCE # define _HPUX_SOURCE # endif -# define MYFAR # define UNIX_FS MY_TRUE # endif #endif diff --git a/swisseph/sweph.c b/swisseph/sweph.c index 116fc21..72e1f30 100644 --- a/swisseph/sweph.c +++ b/swisseph/sweph.c @@ -85,7 +85,7 @@ struct meff_ele {double r,m;}; /**************** * global stuff * ****************/ -struct swe_data FAR swed = {FALSE, /* ephe_path_is_set = FALSE */ +TLS struct swe_data swed = {FALSE, /* ephe_path_is_set = FALSE */ FALSE, /* jpl_file_is_open = FALSE */ NULL, /* fixfp, fixed stars file pointer */ #if 0 @@ -101,14 +101,17 @@ struct swe_data FAR swed = {FALSE, /* ephe_path_is_set = FALSE */ FALSE, /* ayana_is_set, ayanamsa is set */ FALSE, /* is_old_starfile, fixstars.cat is used (default is sefstars.txt) */ 0.0, 0.0, 0.0, 0.0, /* eop_tjd_... */ - 0, /* eop_dpsi_loaded */ + 0, /* eop_dpsi_loaded */ + 0.0, /* tid_acc */ + FALSE, /* is_tid_acc_manual */ + FALSE, /* init_dt_done */ }; /************* * constants * *************/ -static char *ayanamsa_name[] = { +static const char *ayanamsa_name[] = { "Fagan/Bradley", "Lahiri", "De Luce", @@ -140,7 +143,7 @@ static char *ayanamsa_name[] = { "True Revati", "True Pushya", }; -static const int FAR pnoint2jpl[] = PNOINT2JPL; +static const int pnoint2jpl[] = PNOINT2JPL; static const int pnoext2int[] = {SEI_SUN, SEI_MOON, SEI_MERCURY, SEI_VENUS, SEI_MARS, SEI_JUPITER, SEI_SATURN, SEI_URANUS, SEI_NEPTUNE, SEI_PLUTO, 0, 0, 0, 0, SEI_EARTH, SEI_CHIRON, SEI_PHOLUS, SEI_CERES, SEI_PALLAS, SEI_JUNO, SEI_VESTA, }; @@ -182,7 +185,7 @@ static double meff(double r); static void denormalize_positions(double *x0, double *x1, double *x2); static void calc_speed(double *x0, double *x1, double *x2, double dt); static int32 plaus_iflag(int32 iflag, int32 ipl, double tjd, char *serr); -void FAR PASCAL_CONV swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0); +void swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0); static int app_pos_rest(struct plan_data *pdp, int32 iflag, double *xx, double *x2000, struct epsilon *oe, char *serr); static int open_jpl_file(double *ss, char *fname, char *fpath, char *serr); @@ -194,7 +197,7 @@ static void trace_swe_fixstar(int swtch, char *star, double tjd, int32 iflag, do static void trace_swe_get_planet_name(int swtch, int ipl, char *s); #endif -char *FAR PASCAL_CONV swe_version(char *s) +char *swe_version(char *s) { strcpy(s, SE_VERSION); return s; @@ -213,7 +216,7 @@ char *FAR PASCAL_CONV swe_version(char *s) * program tests only. * -> If no speed flag has been specified, no speed will be returned. */ -int32 FAR PASCAL_CONV swe_calc(double tjd, int ipl, int32 iflag, +int32 swe_calc(double tjd, int ipl, int32 iflag, double *xx, char *serr) { int i, j; @@ -239,9 +242,9 @@ int32 FAR PASCAL_CONV swe_calc(double tjd, int ipl, int32 iflag, * FORCE_IFLAG and then running the application with this DLL (we had no * source code of the application itself). */ - static int force_flag = 0; - static int32 iflag_forced = 0; - static int force_flag_checked = 0; + static TLS int force_flag = 0; + static TLS int32 iflag_forced = 0; + static TLS int force_flag_checked = 0; FILE *fp; char s[AS_MAXCH], *sp; memset(x, 0, sizeof(double) * 6); @@ -430,12 +433,14 @@ int32 FAR PASCAL_CONV swe_calc(double tjd, int ipl, int32 iflag, return ERR; } -int32 FAR PASCAL_CONV swe_calc_ut(double tjd_ut, int32 ipl, int32 iflag, +int32 swe_calc_ut(double tjd_ut, int32 ipl, int32 iflag, double *xx, char *serr) { double deltat; int32 retval = OK; - int32 epheflag = iflag & SEFLG_EPHMASK; + int32 epheflag = 0; + iflag = plaus_iflag(iflag, ipl, tjd_ut, serr); + epheflag = iflag & SEFLG_EPHMASK; if (epheflag == 0) { epheflag = SEFLG_SWIEPH; iflag |= SEFLG_SWIEPH; @@ -1084,7 +1089,7 @@ int32 swi_init_swed_if_start(void) { /* initialisation of swed, when called first time from */ if (!swed.ephe_path_is_set) { - //memset((void *) &swed, 0, sizeof(struct swe_data)); + memset((void *) &swed, 0, sizeof(struct swe_data)); strcpy(swed.ephepath, SE_EPHE_PATH); strcpy(swed.jplfnam, SE_FNAME_DFT); swe_set_tid_acc(SE_TIDAL_AUTOMATIC); @@ -1131,7 +1136,7 @@ static void swi_close_keep_topo_etc(void) /* closes all open files, frees space of planetary data, * deletes memory of all computed positions */ -void FAR PASCAL_CONV swe_close(void) +void swe_close(void) { int i; /* close SWISSEPH files */ @@ -1206,7 +1211,7 @@ void FAR PASCAL_CONV swe_close(void) * won't return planet positions previously computed from other * ephemerides */ -void FAR PASCAL_CONV swe_set_ephe_path(char *path) +void swe_set_ephe_path(char *path) { int i, iflag; char s[AS_MAXCH]; @@ -1362,7 +1367,7 @@ void load_dpsi_deps(void) * won't return planet positions previously computed from other * ephemerides */ -void FAR PASCAL_CONV swe_set_jpl_file(char *fname) +void swe_set_jpl_file(char *fname) { char *sp; int retc; @@ -1464,8 +1469,9 @@ static int main_planet(double tjd, int ipli, int32 epheflag, int32 iflag, if (serr != NULL && strlen(serr) + 30 < AS_MAXCH) strcat(serr, " \nusing Moshier Eph; "); goto moshier_planet; - } else + } else { return ERR; + } } /* geocentric, lighttime etc. */ if (ipli == SEI_SUN) @@ -1914,16 +1920,16 @@ static int jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save, /* barycentric earth */ if (tjd != pedp->teval || tjd == 0) { retc = swi_pleph(tjd, J_EARTH, J_SBARY, xpe, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - return retc; - } if (do_save) { pedp->teval = tjd; pedp->xflgs = -1; /* new light-time etc. required */ pedp->iephe = SEFLG_JPLEPH; } + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + return retc; + } } else { xpe = pedp->x; } @@ -1936,16 +1942,16 @@ static int jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save, /* barycentric sun */ if (tjd != psdp->teval || tjd == 0) { retc = swi_pleph(tjd, J_SUN, J_SBARY, xps, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - return retc; - } if (do_save) { psdp->teval = tjd; psdp->xflgs = -1; psdp->iephe = SEFLG_JPLEPH; } + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + return retc; + } } else { xps = psdp->x; } @@ -1968,16 +1974,16 @@ static int jplplan(double tjd, int ipli, int32 iflag, AS_BOOL do_save, xp = pdp->x; } else { retc = swi_pleph(tjd, pnoint2jpl[ipli], ictr, xp, serr); - if (retc != OK) { - swi_close_jpl_file(); - swed.jpl_file_is_open = FALSE; - return retc; - } if (do_save) { pdp->teval = tjd; pdp->xflgs = -1; pdp->iephe = SEFLG_JPLEPH; } + if (retc != OK) { + swi_close_jpl_file(); + swed.jpl_file_is_open = FALSE; + return retc; + } } } if (xpret != NULL) @@ -2249,6 +2255,40 @@ FILE *swi_fopen(int ifno, char *fname, char *ephepath, char *serr) return NULL; } +static int32 get_denum(int32 ipli, int32 iflag) +{ + struct file_data *fdp = NULL; + if (iflag & SEFLG_MOSEPH) + return 403; + if (iflag & SEFLG_JPLEPH) { + if (swed.jpldenum > 0) + return swed.jpldenum; + else + return SE_DE_NUMBER; + } + if (ipli > SE_AST_OFFSET) { + fdp = &swed.fidat[SEI_FILE_ANY_AST]; + } else if (ipli == SEI_CHIRON + || ipli == SEI_PHOLUS + || ipli == SEI_CERES + || ipli == SEI_PALLAS + || ipli == SEI_JUNO + || ipli == SEI_VESTA) { + fdp = &swed.fidat[SEI_FILE_MAIN_AST]; + } else if (ipli == SEI_MOON) { + fdp = &swed.fidat[SEI_FILE_MOON]; + } else { + fdp = &swed.fidat[SEI_FILE_PLANET]; + } + if (fdp != NULL) { + if (fdp->sweph_denum != 0) + return fdp->sweph_denum; + else + return SE_DE_NUMBER; + } + return SE_DE_NUMBER; +} + /* converts planets from barycentric to geocentric, * apparent positions * precession and nutation @@ -2552,7 +2592,7 @@ xx[0] -= 0.053 / 3600.0 * DEGTORAD; swi_polcart(xx, xx); #endif /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && (swed.jpldenum >= 403 || (iflag & SEFLG_MOSEPH))) { + if (!(iflag & SEFLG_ICRS) && get_denum(ipli, epheflag) >= 403) { swi_bias(xx, t, iflag, FALSE); }/**/ /* save J2000 coordinates; required for sidereal positions */ @@ -2609,11 +2649,11 @@ static int app_pos_rest(struct plan_data *pdp, int32 iflag, if (iflag & SEFLG_SIDEREAL) { /* project onto ecliptic t0 */ if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { - if (swi_trop_ra2sid_lon(x2000, pdp->xreturn+6, pdp->xreturn+18, iflag, serr) != OK) + if (swi_trop_ra2sid_lon(x2000, pdp->xreturn+6, pdp->xreturn+18, iflag) != OK) return ERR; /* project onto solar system equator */ } else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { - if (swi_trop_ra2sid_lon_sosy(x2000, pdp->xreturn+6, pdp->xreturn+18, iflag, serr) != OK) + if (swi_trop_ra2sid_lon_sosy(x2000, pdp->xreturn+6, iflag) != OK) return ERR; } else { /* traditional algorithm */ @@ -2655,7 +2695,7 @@ static int app_pos_rest(struct plan_data *pdp, int32 iflag, return OK; } -void FAR PASCAL_CONV swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0) +void swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0) { struct sid_data *sip = &swed.sidd; swi_init_swed_if_start(); @@ -2686,7 +2726,7 @@ void FAR PASCAL_CONV swe_set_sid_mode(int32 sid_mode, double t0, double ayan_t0) swi_force_app_pos_etc(); } -int32 FAR PASCAL_CONV swe_get_ayanamsa_ex(double tjd_et, int32 iflag, double *daya, char *serr) +int32 swe_get_ayanamsa_ex(double tjd_et, int32 iflag, double *daya, char *serr) { double x[6], eps; struct sid_data *sip = &swed.sidd; @@ -2749,7 +2789,7 @@ int32 FAR PASCAL_CONV swe_get_ayanamsa_ex(double tjd_et, int32 iflag, double *da return iflag; } -int32 FAR PASCAL_CONV swe_get_ayanamsa_ex_ut(double tjd_ut, int32 iflag, double *daya, char *serr) +int32 swe_get_ayanamsa_ex_ut(double tjd_ut, int32 iflag, double *daya, char *serr) { double deltat; int32 retflag = OK; @@ -2773,7 +2813,7 @@ int32 FAR PASCAL_CONV swe_get_ayanamsa_ex_ut(double tjd_ut, int32 iflag, double * longitude of the vernal point of t referred to the * ecliptic of t0. */ -double FAR PASCAL_CONV swe_get_ayanamsa(double tjd_et) +double swe_get_ayanamsa(double tjd_et) { double daya; int32 iflag = swi_guess_ephe_flag(); @@ -2781,7 +2821,7 @@ double FAR PASCAL_CONV swe_get_ayanamsa(double tjd_et) return daya; } -double FAR PASCAL_CONV swe_get_ayanamsa_ut(double tjd_ut) +double swe_get_ayanamsa_ut(double tjd_ut) { double daya; int32 iflag = swi_guess_ephe_flag(); @@ -2794,7 +2834,7 @@ double FAR PASCAL_CONV swe_get_ayanamsa_ut(double tjd_ut) * xout ecliptical sidereal position * xoutr equatorial sidereal position */ -int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag, char *serr) +int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag) { double x[6]; int i; @@ -2827,7 +2867,7 @@ int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag, c * xout ecliptical sidereal position * xoutr equatorial sidereal position */ -int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, double *xoutr, int32 iflag, char *serr) +int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, int32 iflag) { double x[6], x0[6]; int i; @@ -3508,7 +3548,7 @@ static int app_pos_etc_sun(int32 iflag, char *serr) for (i = 3; i <= 5; i++) xx[i] = 0; /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && (swed.jpldenum >= 403 || (iflag & SEFLG_MOSEPH))) { + if (!(iflag & SEFLG_ICRS) && get_denum(SEI_SUN, iflag) >= 403) { swi_bias(xx, t, iflag, FALSE); }/**/ /* save J2000 coordinates; required for sidereal positions */ @@ -3683,7 +3723,7 @@ static int app_pos_etc_moon(int32 iflag, char *serr) for (i = 3; i <= 5; i++) xx[i] = 0; /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && (swed.jpldenum >= 403 || (iflag & SEFLG_MOSEPH))) { + if (!(iflag & SEFLG_ICRS) && get_denum(SEI_MOON, iflag) >= 403) { swi_bias(xx, t, iflag, FALSE); }/**/ /* save J2000 coordinates; required for sidereal positions */ @@ -3730,7 +3770,7 @@ static int app_pos_etc_sbar(int32 iflag, char *serr) for (i = 3; i <= 5; i++) xx[i] = 0; /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && (swed.jpldenum >= 403 || (iflag & SEFLG_MOSEPH))) { + if (!(iflag & SEFLG_ICRS) && get_denum(SEI_SUN, iflag) >= 403) { swi_bias(xx, psdp->teval, iflag, FALSE); }/**/ /* save J2000 coordinates; required for sidereal positions */ @@ -4110,9 +4150,9 @@ static int read_const(int ifno, char *serr) if (fread((void *) &testendian, 4, 1, fp) != 1) goto file_damage; /* is byte order correct? */ - if (testendian == SEI_FILE_TEST_ENDIAN) + if (testendian == SEI_FILE_TEST_ENDIAN) { freord = SEI_FILE_NOREORD; - else { + } else { freord = SEI_FILE_REORD; sp = (char *) &lng; c = (char *) &testendian; @@ -4151,7 +4191,6 @@ fendian, ifno, serr); fendian, ifno, serr); if (retc != OK) goto return_error; - swed.jpldenum = fdp->sweph_denum; /************************************* * start and end epoch of file * *************************************/ @@ -4996,10 +5035,10 @@ static int lunar_osc_elem(double tjd, int ipl, int32 iflag, char *serr) if (iflag & SEFLG_SPEED) swi_precess_speed(x, tjd, iflag, J_TO_J2000); if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) - swi_trop_ra2sid_lon(x, ndp->xreturn+6, ndp->xreturn+18, iflag, NULL); + swi_trop_ra2sid_lon(x, ndp->xreturn+6, ndp->xreturn+18, iflag); /* project onto solar system equator */ else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) - swi_trop_ra2sid_lon_sosy(x, ndp->xreturn+6, ndp->xreturn+18, iflag, NULL); + swi_trop_ra2sid_lon_sosy(x, ndp->xreturn+6, iflag); /* to polar */ swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); @@ -5130,10 +5169,10 @@ static int intp_apsides(double tjd, int ipl, int32 iflag, char *serr) if (iflag & SEFLG_SPEED) swi_precess_speed(x, tjd, iflag, J_TO_J2000); if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) - swi_trop_ra2sid_lon(x, ndp->xreturn+6, ndp->xreturn+18, iflag, NULL); + swi_trop_ra2sid_lon(x, ndp->xreturn+6, ndp->xreturn+18, iflag); /* project onto solar system equator */ else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) - swi_trop_ra2sid_lon_sosy(x, ndp->xreturn+6, ndp->xreturn+18, iflag, NULL); + swi_trop_ra2sid_lon_sosy(x, ndp->xreturn+6, iflag); /* to polar */ swi_cartpol_sp(ndp->xreturn+6, ndp->xreturn); swi_cartpol_sp(ndp->xreturn+18, ndp->xreturn+12); @@ -5217,7 +5256,7 @@ int swi_plan_for_osc_elem(int32 iflag, double tjd, double *xx) struct epsilon *oe = &swed.oec; struct epsilon oectmp; /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && (swed.jpldenum >= 403 || (iflag & SEFLG_MOSEPH))) { + if (!(iflag & SEFLG_ICRS) && get_denum(SEI_SUN, iflag) >= 403) { swi_bias(xx, tjd, iflag, FALSE); }/**/ /************************************************ @@ -5307,7 +5346,7 @@ int swi_plan_for_osc_elem(int32 iflag, double tjd, double *xx) return(OK); } -static const struct meff_ele FAR eff_arr[] = { +static const struct meff_ele eff_arr[] = { /* * r , m_eff for photon passing the sun at min distance r (fraction of Rsun) * the values where computed with sun_model.c, which is a classic @@ -5484,7 +5523,7 @@ void swi_check_ecliptic(double tjd, int32 iflag) void swi_check_nutation(double tjd, int32 iflag) { int32 speedf1, speedf2; - static int32 nutflag = 0; + static TLS int32 nutflag = 0; double t; speedf1 = nutflag & SEFLG_SPEED; speedf2 = iflag & SEFLG_SPEED; @@ -5610,7 +5649,7 @@ static int32 plaus_iflag(int32 iflag, int32 ipl, double tjd, char *serr) * x pointer for returning the ecliptic coordinates * serr error return string **********************************************************/ -int32 FAR PASCAL_CONV swe_fixstar(char *star, double tjd, int32 iflag, +int32 swe_fixstar(char *star, double tjd, int32 iflag, double *xx, char *serr) { int i; @@ -5622,8 +5661,8 @@ int32 FAR PASCAL_CONV swe_fixstar(char *star, double tjd, int32 iflag, char *cpos[20]; char sstar[SE_MAX_STNAME + 1]; char fstar[SE_MAX_STNAME + 1]; - static char slast_stardata[AS_MAXCH]; - static char slast_starname[AS_MAXCH]; + static TLS char slast_stardata[AS_MAXCH]; + static TLS char slast_starname[AS_MAXCH]; char s[AS_MAXCH + 20], *sp, *sp2; /* 20 byte for SE_STARFILE */ double ra_s, ra_pm, de_pm, ra, de, t, cosra, cosde, sinra, sinde; double ra_h, ra_m, de_d, de_m, de_s; @@ -5881,7 +5920,7 @@ int32 FAR PASCAL_CONV swe_fixstar(char *star, double tjd, int32 iflag, if (epoch != 0) { swi_icrs2fk5(x, iflag, TRUE); /* backward, i. e. to icrf */ /* with ephemerides < DE403, we now convert to J2000 */ - if (swed.jpldenum < 403) { + if (get_denum(SEI_SUN, iflag) >= 403) { swi_bias(x, J2000, SEFLG_SPEED, FALSE); } } @@ -5968,7 +6007,7 @@ int32 FAR PASCAL_CONV swe_fixstar(char *star, double tjd, int32 iflag, if ((iflag & SEFLG_TRUEPOS) == 0 && (iflag & SEFLG_NOABERR) == 0) swi_aberr_light(x, xpo, iflag & SEFLG_SPEED); /* ICRS to J2000 */ - if (!(iflag & SEFLG_ICRS) && (swed.jpldenum >= 403 || (iflag & SEFLG_MOSEPH) || (iflag & SEFLG_BARYCTR))) { + if (!(iflag & SEFLG_ICRS) && (get_denum(SEI_SUN, iflag) >= 403 || (iflag & SEFLG_BARYCTR))) { swi_bias(x, tjd, iflag, FALSE); }/**/ /* save J2000 coordinates; required for sidereal positions */ @@ -6029,14 +6068,14 @@ if (0) { if (iflag & SEFLG_SIDEREAL) { /* rigorous algorithm */ if (swed.sidd.sid_mode & SE_SIDBIT_ECL_T0) { - if (swi_trop_ra2sid_lon(xxsv, x, xxsv, iflag, serr) != OK) + if (swi_trop_ra2sid_lon(xxsv, x, xxsv, iflag) != OK) goto return_err; if (iflag & SEFLG_EQUATORIAL) for (i = 0; i <= 5; i++) x[i] = xxsv[i]; /* project onto solar system equator */ } else if (swed.sidd.sid_mode & SE_SIDBIT_SSY_PLANE) { - if (swi_trop_ra2sid_lon_sosy(xxsv, x, xxsv, iflag, serr) != OK) + if (swi_trop_ra2sid_lon_sosy(xxsv, x, iflag) != OK) return ERR; if (iflag & SEFLG_EQUATORIAL) for (i = 0; i <= 5; i++) @@ -6083,12 +6122,14 @@ if (0) { return retc; } -int32 FAR PASCAL_CONV swe_fixstar_ut(char *star, double tjd_ut, int32 iflag, +int32 swe_fixstar_ut(char *star, double tjd_ut, int32 iflag, double *xx, char *serr) { double deltat; int32 retflag; - int32 epheflag = iflag & SEFLG_EPHMASK; + int32 epheflag = 0; + iflag = plaus_iflag(iflag, -1, tjd_ut, serr); + epheflag = iflag & SEFLG_EPHMASK; if (epheflag == 0) { epheflag = SEFLG_SWIEPH; iflag |= SEFLG_SWIEPH; @@ -6114,7 +6155,7 @@ int32 FAR PASCAL_CONV swe_fixstar_ut(char *star, double tjd_ut, int32 iflag, * mag pointer to a double, for star magnitude * serr error return string **********************************************************/ -int32 FAR PASCAL_CONV swe_fixstar_mag(char *star, double *mag, char *serr) +int32 swe_fixstar_mag(char *star, double *mag, char *serr) { int i; int star_nr = 0; @@ -6279,7 +6320,7 @@ int swe_fixstar(char *star, double tjd, int32 iflag, double *xx, char *serr) #endif -char *FAR PASCAL_CONV swe_get_planet_name(int ipl, char *s) +char *swe_get_planet_name(int ipl, char *s) { int i; int32 retc; @@ -6288,6 +6329,7 @@ char *FAR PASCAL_CONV swe_get_planet_name(int ipl, char *s) swi_open_trace(NULL); trace_swe_get_planet_name(1, ipl, s); #endif + swi_init_swed_if_start(); /* function calls for Pluto with asteroid number 134340 * are treated as calls for Pluto as main body SE_PLUTO */ if (ipl == SE_AST_OFFSET + 134340) @@ -6454,7 +6496,7 @@ char *FAR PASCAL_CONV swe_get_planet_name(int ipl, char *s) return s; } -char *FAR PASCAL_CONV swe_get_ayanamsa_name(int32 isidmode) +const char *swe_get_ayanamsa_name(int32 isidmode) { isidmode %= SE_SIDBITS; if (isidmode < SE_NSIDM_PREDEF) @@ -6576,7 +6618,7 @@ static void trace_swe_get_planet_name(int swtch, int ipl, char *s) #endif /* set geographic position and altitude of observer */ -void FAR PASCAL_CONV swe_set_topo(double geolon, double geolat, double geoalt) +void swe_set_topo(double geolon, double geolat, double geoalt) { swi_init_swed_if_start(); swed.topd.geolon = geolon; @@ -6707,7 +6749,7 @@ int swi_get_observer(double tjd, int32 iflag, * E = LAT - LMT * Input variable tjd is UT. */ -int32 FAR PASCAL_CONV swe_time_equ(double tjd_ut, double *E, char *serr) +int32 swe_time_equ(double tjd_ut, double *E, char *serr) { int32 retval; double t, dt, x[6]; @@ -6735,7 +6777,7 @@ int32 FAR PASCAL_CONV swe_time_equ(double tjd_ut, double *E, char *serr) return OK; } -int32 FAR PASCAL_CONV swe_lmt_to_lat(double tjd_lmt, double geolon, double *tjd_lat, char *serr) +int32 swe_lmt_to_lat(double tjd_lmt, double geolon, double *tjd_lat, char *serr) { int32 retval; double E, tjd_lmt0; @@ -6745,7 +6787,7 @@ int32 FAR PASCAL_CONV swe_lmt_to_lat(double tjd_lmt, double geolon, double *tjd_ return retval; } -int32 FAR PASCAL_CONV swe_lat_to_lmt(double tjd_lat, double geolon, double *tjd_lmt, char *serr) +int32 swe_lat_to_lmt(double tjd_lat, double geolon, double *tjd_lmt, char *serr) { int32 retval; double E, tjd_lmt0; @@ -6793,7 +6835,7 @@ static int open_jpl_file(double *ss, char *fname, char *fpath, char *serr) } #if 0 -void FAR PASCAL_CONV swe_set_timeout(int32 tsec) +void swe_set_timeout(int32 tsec) { if (tsec < 0) tsec = 0; swed.timeout = tsec; @@ -6801,7 +6843,7 @@ void FAR PASCAL_CONV swe_set_timeout(int32 tsec) #endif #if 0 -int FAR PASCAL_CONV swe_time_equ(double tjd_ut, double *E, char *serr) +int swe_time_equ(double tjd_ut, double *E, char *serr) /* Algorithm according to Meeus, German, p. 190ff.*/ double L0, dpsi, eps, x[6], nutlo[2]; double tau = (tjd - J2000) / 365250; diff --git a/swisseph/sweph.h b/swisseph/sweph.h index cbe55a5..7f757a6 100644 --- a/swisseph/sweph.h +++ b/swisseph/sweph.h @@ -63,7 +63,7 @@ * move over from swephexp.h */ -#define SE_VERSION "2.02.01" +#define SE_VERSION "2.03" #define J2000 2451545.0 /* 2000 January 1.5 */ #define B1950 2433282.42345905 /* 1950 January 0.923 */ @@ -600,4 +600,4 @@ struct swe_data { int32 timeout; }; -extern struct swe_data FAR swed; +extern TLS struct swe_data swed; diff --git a/swisseph/swephexp.h b/swisseph/swephexp.h index f852e02..d3adf1e 100644 --- a/swisseph/swephexp.h +++ b/swisseph/swephexp.h @@ -551,16 +551,10 @@ extern "C" { #if defined(DOS32) || !MSDOS || defined(WIN32) /* use compiler switch to define DOS32 */ -# ifndef FAR -# define FAR -# endif # define MALLOC malloc # define CALLOC calloc # define FREE free #else -# ifndef FAR -# define FAR far -# endif # ifdef __BORLANDC__ # include # define MALLOC farmalloc @@ -575,25 +569,10 @@ extern "C" { /* DLL defines */ #ifdef MAKE_DLL - #if defined (PASCAL) - #define PASCAL_CONV PASCAL - #else - #define PASCAL_CONV - #endif - #ifdef MAKE_DLL16 /* 16bit DLL */ - /* We compiled the 16bit DLL for Windows 3.x using Borland C/C++ Ver:3.x - and the -WD or -WDE compiler switch. */ - #define EXP16 __export - #define EXP32 - #else /* 32bit DLL */ - /* To export symbols in the new DLL model of Win32, Microsoft - recommends the following approach */ - #define EXP16 - #define EXP32 __declspec( dllexport ) - #endif + /* To export symbols in the new DLL model of Win32, Microsoft + recommends the following approach */ + #define EXP32 __declspec( dllexport ) #else - #define PASCAL_CONV - #define EXP16 #define EXP32 #endif @@ -603,7 +582,7 @@ extern "C" { * exported functions ***********************************************************/ -#define ext_def(x) extern EXP32 x FAR PASCAL_CONV EXP16 +#define ext_def(x) extern EXP32 x /* ext_def(x) evaluates to x on Unix */ ext_def(int32) swe_heliacal_ut(double tjdstart_ut, double *geopos, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 iflag, double *dret, char *serr); @@ -669,7 +648,7 @@ ext_def(double) swe_get_ayanamsa(double tjd_et); ext_def(double) swe_get_ayanamsa_ut(double tjd_ut); -ext_def( char *) swe_get_ayanamsa_name(int32 isidmode); +ext_def(const char *) swe_get_ayanamsa_name(int32 isidmode); /*ext_def(void) swe_set_timeout(int32 tsec);*/ diff --git a/swisseph/swephlib.c b/swisseph/swephlib.c index dd4e034..c5ab0a7 100644 --- a/swisseph/swephlib.c +++ b/swisseph/swephlib.c @@ -84,9 +84,9 @@ #ifdef TRACE void swi_open_trace(char *serr); -FILE *swi_fp_trace_c = NULL; -FILE *swi_fp_trace_out = NULL; -int32 swi_trace_count = 0; +TLS FILE *swi_fp_trace_c = NULL; +TLS FILE *swi_fp_trace_out = NULL; +TLS int32 swi_trace_count = 0; #endif static void init_crc32(void); @@ -101,7 +101,7 @@ static double deltat_aa(double tjd, double tid_acc); /* Reduce x modulo 360 degrees */ -double FAR PASCAL_CONV swe_degnorm(double x) +double swe_degnorm(double x) { double y; y = fmod(x, 360.0); @@ -112,7 +112,7 @@ double FAR PASCAL_CONV swe_degnorm(double x) /* Reduce x modulo TWOPI degrees */ -double FAR PASCAL_CONV swe_radnorm(double x) +double swe_radnorm(double x) { double y; y = fmod(x, TWOPI); @@ -121,7 +121,7 @@ double FAR PASCAL_CONV swe_radnorm(double x) return(y); } -double FAR PASCAL_CONV swe_deg_midp(double x1, double x0) +double swe_deg_midp(double x1, double x0) { double d, y; d = swe_difdeg2n(x1, x0); /* arc from x0 to x1 */ @@ -129,7 +129,7 @@ double FAR PASCAL_CONV swe_deg_midp(double x1, double x0) return(y); } -double FAR PASCAL_CONV swe_rad_midp(double x1, double x0) +double swe_rad_midp(double x1, double x0) { return DEGTORAD * swe_deg_midp(x1 * RADTODEG, x0 * RADTODEG); } @@ -218,7 +218,7 @@ double swi_edcheb(double x, double *coef, int ncf) * xpo, xpn are arrays of 3 doubles containing position. * attention: input must be in degrees! */ -void FAR PASCAL_CONV swe_cotrans(double *xpo, double *xpn, double eps) +void swe_cotrans(double *xpo, double *xpn, double eps) { int i; double x[6], e = eps * DEGTORAD; @@ -246,7 +246,7 @@ void FAR PASCAL_CONV swe_cotrans(double *xpo, double *xpn, double eps) * xpo, xpn are arrays of 6 doubles containing position and speed. * attention: input must be in degrees! */ -void FAR PASCAL_CONV swe_cotrans_sp(double *xpo, double *xpn, double eps) +void swe_cotrans_sp(double *xpo, double *xpn, double eps) { int i; double x[6], e = eps * DEGTORAD; @@ -465,7 +465,7 @@ double swi_dot_prod_unit(double *x, double *y) /* for pre_peps(): */ /* polynomials */ -static double pepol[NPOL_PEPS][2] = { +static const double pepol[NPOL_PEPS][2] = { {+8134.017132, +84028.206305}, {+5043.0520035, +0.3624445}, {-0.00710733, -0.00004039}, @@ -473,7 +473,7 @@ static double pepol[NPOL_PEPS][2] = { }; /* periodics */ -static double peper[5][NPER_PEPS] = { +static const double peper[5][NPER_PEPS] = { {+409.90, +396.15, +537.22, +402.90, +417.15, +288.92, +4043.00, +306.00, +277.00, +203.00}, {-6908.287473, -3198.706291, +1453.674527, -857.748557, +1173.231614, -156.981465, +371.836550, -216.619040, +193.691479, +11.891524}, {+753.872780, -247.805823, +379.471484, -53.880558, -90.109153, -353.600190, -63.115353, -28.248187, +17.703387, +38.911307}, @@ -483,7 +483,7 @@ static double peper[5][NPER_PEPS] = { /* for pre_pecl(): */ /* polynomials */ -static double pqpol[NPOL_PECL][2] = { +static const double pqpol[NPOL_PECL][2] = { {+5851.607687, -1600.886300}, {-0.1189000, +1.1689818}, {-0.00028913, -0.00000020}, @@ -491,7 +491,7 @@ static double pqpol[NPOL_PECL][2] = { }; /* periodics */ -static double pqper[5][NPER_PECL] = { +static const double pqper[5][NPER_PECL] = { {708.15, 2309, 1620, 492.2, 1183, 622, 882, 547}, {-5486.751211, -17.127623, -617.517403, 413.44294, 78.614193, -180.732815, -87.676083, 46.140315}, {-684.66156, 2446.28388, 399.671049, -356.652376, -186.387003, -316.80007, 198.296701, 101.135679}, /* typo in publication fixed */ @@ -501,7 +501,7 @@ static double pqper[5][NPER_PECL] = { /* for pre_pequ(): */ /* polynomials */ -static double xypol[NPOL_PEQU][2] = { +static const double xypol[NPOL_PEQU][2] = { {+5453.282155, -73750.930350}, {+0.4252841, -0.7675452}, {-0.00037173, -0.00018725}, @@ -509,7 +509,7 @@ static double xypol[NPOL_PEQU][2] = { }; /* periodics */ -static double xyper[5][NPER_PEQU] = { +static const double xyper[5][NPER_PEQU] = { {256.75, 708.15, 274.2, 241.45, 2309, 492.2, 396.1, 288.9, 231.1, 1610, 620, 157.87, 220.3, 1200}, {-819.940624, -8444.676815, 2600.009459, 2755.17563, -167.659835, 871.855056, 44.769698, -512.313065, -819.415595, -538.071099, -189.793622, -402.922932, 179.516345, -9.814756}, {75004.344875, 624.033993, 1251.136893, -1102.212834, -2660.66498, 699.291817, 153.16722, -950.865637, 499.754645, -145.18821, 558.116553, -23.923029, -165.405086, 9.344131}, @@ -891,46 +891,46 @@ static int precess_1(double *R, double J, int direction, int prec_method) is the same except for the lower order terms. */ /* SEMOD_PREC_WILLIAMS_1994 */ -static double pAcof_williams[] = { +static const double pAcof_williams[] = { -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, -0.235316, 0.076, 110.5407, 50287.70000 }; -static double nodecof_williams[] = { +static const double nodecof_williams[] = { 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 1.9e-10, -3.54e-9, -1.8103e-7, 1.26e-7, 7.436169e-5, -0.04207794833, 3.052115282424}; -static double inclcof_williams[] = { +static const double inclcof_williams[] = { 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, -5.4000441e-11, 1.32115526e-9, -6.012e-7, -1.62442e-5, 0.00227850649, 0.0 }; /* SEMOD_PREC_SIMON_1994 */ /* Precession coefficients from Simon et al: */ -static double pAcof_simon[] = { +static const double pAcof_simon[] = { -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, -0.235316, 0.07732, 111.2022, 50288.200 }; -static double nodecof_simon[] = { +static const double nodecof_simon[] = { 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 1.9e-10, -3.54e-9, -1.8103e-7, 2.579e-8, 7.4379679e-5, -0.0420782900, 3.0521126906}; -static double inclcof_simon[] = { +static const double inclcof_simon[] = { 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, -5.4000441e-11, 1.32115526e-9, -5.99908e-7, -1.624383e-5, 0.002278492868, 0.0 }; /* SEMOD_PREC_LASKAR_1986 */ /* Precession coefficients taken from Laskar's paper: */ -static double pAcof_laskar[] = { +static const double pAcof_laskar[] = { -8.66e-10, -4.759e-8, 2.424e-7, 1.3095e-5, 1.7451e-4, -1.8055e-3, -0.235316, 0.07732, 111.1971, 50290.966 }; /* Node and inclination of the earth's orbit computed from * Laskar's data as done in Bretagnon and Francou's paper. * Units are radians. */ -static double nodecof_laskar[] = { +static const double nodecof_laskar[] = { 6.6402e-16, -2.69151e-15, -1.547021e-12, 7.521313e-12, 6.3190131e-10, -3.48388152e-9, -1.813065896e-7, 2.75036225e-8, 7.4394531426e-5, -0.042078604317, 3.052112654975 }; -static double inclcof_laskar[] = { +static const double inclcof_laskar[] = { 1.2147e-16, 7.3759e-17, -8.26287e-14, 2.503410e-13, 2.4650839e-11, -5.4000441e-11, 1.32115526e-9, -5.998737027e-7, -1.6242797091e-5, 0.002278495537, 0.0 }; @@ -941,9 +941,9 @@ static int precess_2(double *R, double J, int32 iflag, int direction, int prec_m double T, z; double eps, sineps, coseps; double x[3]; - double *p; + const double *p; double A, B, pA, W; - double *pAcof, *inclcof, *nodecof; + const double *pAcof, *inclcof, *nodecof; if( J == J2000 ) return(0); if (prec_method == SEMOD_PREC_LASKAR_1986) { @@ -1181,7 +1181,7 @@ int swi_precess(double *R, double J, int32 iflag, int direction ) * .0123 .0880 .0224 .0905 * .0386 .1808 .0895 .1129 */ -static short FAR nt[] = { +static const short nt[] = { /* LS and OC are units of 0.0001" *LS2 and OC2 are units of 0.00001" *MM,MS,FF,DD,OM, LS, LS2,OC, OC2 */ @@ -1320,7 +1320,7 @@ static int swi_nutation_iau1980(double J, double *nutlo) double C, D; int i, j, k, k1, m, n; int ns[5]; - short *p; + const short *p; int nut_model = swed.astro_models[SE_MODEL_NUT]; if (nut_model == 0) nut_model = SEMOD_NUT_DEFAULT; /* Julian centuries from 2000 January 1.5, @@ -2024,7 +2024,7 @@ void swi_icrs2fk5(double *x, int32 iflag, AS_BOOL backward) #define TABSIZ (TABEND-TABSTART+1) /* we make the table greater for additional values read from external file */ #define TABSIZ_SPACE (TABSIZ+100) -static double FAR dt[TABSIZ_SPACE] = { +static TLS double dt[TABSIZ_SPACE] = { /* 1620.0 thru 1659.0 */ 124.00, 119.00, 115.00, 110.00, 106.00, 102.00, 98.00, 95.00, 91.00, 88.00, 85.00, 82.00, 79.00, 77.00, 74.00, 72.00, 70.00, 67.00, 65.00, 63.00, @@ -2089,7 +2089,7 @@ static double FAR dt[TABSIZ_SPACE] = { #define LTERM_EQUATION_YSTART 1820 #define LTERM_EQUATION_COEFF 32 /* Table for -1000 through 1600, from Morrison & Stephenson (2004). */ -static short FAR dt2[TAB2_SIZ] = { +static const short dt2[TAB2_SIZ] = { /*-1000 -900 -800 -700 -600 -500 -400 -300 -200 -100*/ 25400,23700,22000,21000,19040,17190,15530,14080,12790,11640, /* 0 100 200 300 400 500 600 700 800 900*/ @@ -2204,14 +2204,14 @@ static int32 calc_deltat(double tjd, int32 iflag, double *deltat, char *serr) return iflag; } -double FAR PASCAL_CONV swe_deltat_ex(double tjd, int32 iflag, char *serr) +double swe_deltat_ex(double tjd, int32 iflag, char *serr) { double deltat; calc_deltat(tjd, iflag, &deltat, serr); return deltat; } -double FAR PASCAL_CONV swe_deltat(double tjd) +double swe_deltat(double tjd) { int32 iflag = swi_guess_ephe_flag(); return swe_deltat_ex(tjd, iflag, NULL); /* with default tidal acceleration/default ephemeris */ @@ -2475,7 +2475,7 @@ static double adjust_for_tidacc(double ans, double Y, double tid_acc) } /* returns tidal acceleration used in swe_deltat() and swe_deltat_ex() */ -double FAR PASCAL_CONV swe_get_tid_acc() +double swe_get_tid_acc() { return swed.tid_acc; } @@ -2486,7 +2486,7 @@ double FAR PASCAL_CONV swe_get_tid_acc() * of the Moon will be set consistent with that ephemeris. * - SE_TIDAL_AUTOMATIC, */ -void FAR PASCAL_CONV swe_set_tid_acc(double t_acc) +void swe_set_tid_acc(double t_acc) { if (t_acc == SE_TIDAL_AUTOMATIC) { swed.tid_acc = SE_TIDAL_DEFAULT; @@ -2576,10 +2576,11 @@ int32 swi_get_tid_acc(double tjd_ut, int32 iflag, int32 denum, int32 *denumret, int32 swi_set_tid_acc(double tjd_ut, int32 iflag, int32 denum, char *serr) { int32 retc = iflag; + int32 denumret; /* manual tid_acc overrides automatic tid_acc */ if (swed.is_tid_acc_manual) return retc; - retc = swi_get_tid_acc(tjd_ut, iflag, denum, &(swed.jpldenum), &(swed.tid_acc), serr); + retc = swi_get_tid_acc(tjd_ut, iflag, denum, &denumret, &(swed.tid_acc), serr); #if TRACE swi_open_trace(NULL); if (swi_trace_count < TRACE_COUNT_MAX) { @@ -2671,7 +2672,7 @@ static double sidtime_long_term(double tjd_ut, double eps, double nut) */ /* C'_{s,j})_i C'_{c,j})_i */ #define SIDTNTERM 33 -static double stcf[SIDTNTERM * 2] = { +static const double stcf[SIDTNTERM * 2] = { 2640.96,-0.39, 63.52,-0.02, 11.75,0.01, @@ -2708,7 +2709,7 @@ static double stcf[SIDTNTERM * 2] = { }; #define SIDTNARG 14 /* l l' F D Om L_Me L_Ve L_E L_Ma L_J L_Sa L_U L_Ne p_A*/ -static int stfarg[SIDTNTERM * SIDTNARG] = { +static const int stfarg[SIDTNTERM * SIDTNARG] = { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, -2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -2788,7 +2789,7 @@ static double sidtime_non_polynomial_part(double tt) #define SIDT_LTERM_T1 2469807.5 /* 1 Jan 2050 */ #define SIDT_LTERM_OFS0 (0.000378172 / 15.0) #define SIDT_LTERM_OFS1 (0.001385646 / 15.0) -double FAR PASCAL_CONV swe_sidtime0( double tjd, double eps, double nut ) +double swe_sidtime0( double tjd, double eps, double nut ) { double jd0; /* Julian day at midnight Universal Time */ double secs; /* Time of day, UT seconds since UT midnight */ @@ -2886,7 +2887,7 @@ double FAR PASCAL_CONV swe_sidtime0( double tjd, double eps, double nut ) * tjd must be UT !!! * for more informsation, see comment with swe_sidtime0() */ -double FAR PASCAL_CONV swe_sidtime(double tjd_ut) +double swe_sidtime(double tjd_ut) { int i; double eps, nutlo[2], tsid; @@ -3061,7 +3062,7 @@ char *swi_right_trim(char *s) * The CRCs this code generates agree with the vendor-supplied Verilog models * of several of the popular FDDI "MAC" chips. */ -static uint32 crc32_table[256]; +static TLS uint32 crc32_table[256]; /* Initialized first time "crc32()" is called. If you prefer, you can * statically initialize it at compile time. [Another exercise.] */ @@ -3103,7 +3104,7 @@ static void init_crc32(void) /************************************ normalize argument into interval [0..DEG360] *************************************/ -centisec FAR PASCAL_CONV swe_csnorm(centisec p) +centisec swe_csnorm(centisec p) { if (p < 0) do { p += DEG360; } while (p < 0); @@ -3116,12 +3117,12 @@ centisec FAR PASCAL_CONV swe_csnorm(centisec p) distance in centisecs p1 - p2 normalized to [0..360[ **************************************/ -centisec FAR PASCAL_CONV swe_difcsn (centisec p1, centisec p2) +centisec swe_difcsn (centisec p1, centisec p2) { return (swe_csnorm(p1 - p2)); } -double FAR PASCAL_CONV swe_difdegn (double p1, double p2) +double swe_difdegn (double p1, double p2) { return (swe_degnorm(p1 - p2)); } @@ -3130,21 +3131,21 @@ double FAR PASCAL_CONV swe_difdegn (double p1, double p2) distance in centisecs p1 - p2 normalized to [-180..180[ **************************************/ -centisec FAR PASCAL_CONV swe_difcs2n(centisec p1, centisec p2) +centisec swe_difcs2n(centisec p1, centisec p2) { centisec dif; dif = swe_csnorm(p1 - p2); if (dif >= DEG180) return (dif - DEG360); return (dif); } -double FAR PASCAL_CONV swe_difdeg2n(double p1, double p2) +double swe_difdeg2n(double p1, double p2) { double dif; dif = swe_degnorm(p1 - p2); if (dif >= 180.0) return (dif - 360.0); return (dif); } -double FAR PASCAL_CONV swe_difrad2n(double p1, double p2) +double swe_difrad2n(double p1, double p2) { double dif; dif = swe_radnorm(p1 - p2); if (dif >= TWOPI / 2) return (dif - TWOPI); @@ -3154,7 +3155,7 @@ double FAR PASCAL_CONV swe_difrad2n(double p1, double p2) /************************************* round second, but at 29.5959 always down *************************************/ -centisec FAR PASCAL_CONV swe_csroundsec(centisec x) +centisec swe_csroundsec(centisec x) { centisec t; t = (x + 50) / 100 *100L; /* round to seconds */ @@ -3166,7 +3167,7 @@ centisec FAR PASCAL_CONV swe_csroundsec(centisec x) /************************************* double to int32 with rounding, no overflow check *************************************/ -int32 FAR PASCAL_CONV swe_d2l(double x) +int32 swe_d2l(double x) { if (x >=0) return ((int32) (x + 0.5)); @@ -3177,12 +3178,12 @@ int32 FAR PASCAL_CONV swe_d2l(double x) /* * monday = 0, ... sunday = 6 */ -int FAR PASCAL_CONV swe_day_of_week(double jd) +int swe_day_of_week(double jd) { return (((int) floor (jd - 2433282 - 1.5) %7) + 7) % 7; } -char *FAR PASCAL_CONV swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, char *a) +char *swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, char *a) /* does not suppress zeros in hours or minutes */ { /* static char a[9];*/ @@ -3206,7 +3207,7 @@ char *FAR PASCAL_CONV swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, char return (a); } /* swe_cs2timestr() */ -char *FAR PASCAL_CONV swe_cs2lonlatstr(CSEC t, char pchar, char mchar, char *sp) +char *swe_cs2lonlatstr(CSEC t, char pchar, char mchar, char *sp) { char a[10]; /* must be initialized at each call */ char *aa; @@ -3236,7 +3237,7 @@ char *FAR PASCAL_CONV swe_cs2lonlatstr(CSEC t, char pchar, char mchar, char *sp) return (sp); } /* swe_cs2lonlatstr() */ -char *FAR PASCAL_CONV swe_cs2degstr(CSEC t, char *a) +char *swe_cs2degstr(CSEC t, char *a) /* does suppress leading zeros in degrees */ { /* char a[9]; must be initialized at each call */ @@ -3259,7 +3260,7 @@ char *FAR PASCAL_CONV swe_cs2degstr(CSEC t, char *a) * or +/- sign * *********************************************************/ -void FAR PASCAL_CONV swe_split_deg(double ddeg, int32 roundflag, int32 *ideg, int32 *imin, int32 *isec, double *dsecfr, int32 *isgn) +void swe_split_deg(double ddeg, int32 roundflag, int32 *ideg, int32 *imin, int32 *isec, double *dsecfr, int32 *isgn) { double dadd = 0; *isgn = 1; @@ -3351,7 +3352,7 @@ void swi_FK5_FK4(double *xp, double tjd) swi_polcart(xp, xp); } -void FAR PASCAL_CONV swe_set_astro_models(int32 *imodel) +void swe_set_astro_models(int32 *imodel) { int *pmodel = &(swed.astro_models[0]); swi_init_swed_if_start(); @@ -3359,7 +3360,7 @@ void FAR PASCAL_CONV swe_set_astro_models(int32 *imodel) } #if 0 -void FAR PASCAL_CONV swe_get_prec_nut_models(int *imodel) +void swe_get_prec_nut_models(int *imodel) { int *pmodel = &(swed.astro_models[0]); memcpy(imodel, pmodel, SEI_NMODELS * sizeof(int)); diff --git a/swisseph/swephlib.h b/swisseph/swephlib.h index 477e8e8..2ed2c23 100644 --- a/swisseph/swephlib.h +++ b/swisseph/swephlib.h @@ -157,8 +157,8 @@ extern int32 swi_guess_ephe_flag(); extern void swi_deflect_light(double *xx, double dt, int32 iflag); extern void swi_aberr_light(double *xx, double *xe, int32 iflag); extern int swi_plan_for_osc_elem(int32 iflag, double tjd, double *xx); -extern int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag, char *serr); -extern int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, double *xoutr, int32 iflag, char *serr); +extern int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag); +extern int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, int32 iflag); extern int swi_get_observer(double tjd, int32 iflag, AS_BOOL do_save, double *xobs, char *serr); extern void swi_force_app_pos_etc(); @@ -212,13 +212,13 @@ extern double swi_deltat_ephe(double tjd_ut, int32 epheflag); #ifdef TRACE # define TRACE_COUNT_MAX 10000 - extern FILE *swi_fp_trace_c; - extern FILE *swi_fp_trace_out; + extern TLS FILE *swi_fp_trace_c; + extern TLS FILE *swi_fp_trace_out; + extern TLS int32 swi_trace_count; extern void swi_open_trace(char *serr); - extern int32 swi_trace_count; - static char *fname_trace_c = "swetrace.c"; - static char *fname_trace_out = "swetrace.txt"; + static const char *fname_trace_c = "swetrace.c"; + static const char *fname_trace_out = "swetrace.txt"; #ifdef FORCE_IFLAG - static char *fname_force_flg = "force.flg"; + static const char *fname_force_flg = "force.flg"; #endif #endif /* TRACE */