delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2015/05/23/09:40:34

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
Message-ID: <55608E9F.50406@gmx.de>
Date: Sat, 23 May 2015 16:28:47 +0200
From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de)" <djgpp-workers AT delorie DOT com>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Order of arguments passed to sincos changed.
X-Provags-ID: V03:K0:5/oMfjcYrfWgp5reLehkw+taRBAvnCInzeQ+xEU2VemWz/DD5yG
wKDIhHJ0Lwn/+OJAOws76rjF4Okr3OCASCSnxBl3163Q1ygWKtCJYlnzb2JT63Bmle9KVke
Qk1/CpdhP48pqmlk2kCQYzNPGJo7JBEKPzqVgG3G4hjUCFmhAMw6W4+CtaCG3TM+bI5P3sy
dARiEP50mpnEeyqDDyxlg==
X-UI-Out-Filterresults: notjunk:1;
Reply-To: djgpp-workers AT delorie DOT com

OFYI, I have applied the patch below.

Regards,
Juan M. Guerrero






2015-05-17  Juan Manuel Guerrero  <juan DOT guerrero AT gmx DOT de>


	* djgpp/include/math.h:  Order of arguments of sincos function changed to
	match the order used by GNU systems.

	* djgpp/src/libc/compat/math/sincos.S:  Order of arguments of sincos function
	changed to match the order used by GNU systems.

	* djgpp/src/libc/compat/math/sincos.txh:  Order of arguments of sincos function
	changed to match the order used by GNU systems.

	* djgpp/tests/libc/compat/math/makefile:  sincos test program added.

	* djgpp/tests/libc/compat/math/sincos.c:  sincos test program added.








Index: djgpp/include/math.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/math.h,v
retrieving revision 1.25
diff -U 5 -r1.25 math.h
--- djgpp/include/math.h	16 Nov 2013 21:48:26 -0000	1.25
+++ djgpp/include/math.h	23 May 2015 13:00:30 -0000
@@ -256,11 +256,11 @@

  double exp10(double _x);
  double pow10(double _x);
  double pow2(double _x);
  double powi(double _base, int _exp);
-void   sincos(double *_cos, double *_sin, double _x);
+void   sincos(double _x, double *_sin, double *_cos);

  /* These are in libm.a (Cygnus).  You must link -lm to get these */
  /* See libm/math.h for comments */

  #ifndef __cplusplus
Index: djgpp/src/docs/kb/wc205.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc205.txi,v
retrieving revision 1.4
diff -U 5 -r1.4 wc205.txi
--- djgpp/src/docs/kb/wc205.txi	16 May 2015 18:50:04 -0000	1.4
+++ djgpp/src/docs/kb/wc205.txi	23 May 2015 13:00:30 -0000
@@ -12,12 +12,12 @@
  @code{free}. In DJGPP v2.05, memory management was replaced by the
  @strong{nmalloc} implementation written by Charles B. Falconer (1931-2012).
  nmalloc was already used for a rather long time for various DJGPP packages
  including DJGPP port of GCC.

-@subsection Update of DXE lookup
-
+@cindex Update of @acronym{DXE3} lookup
+@cindex @env{SYSTEM_DXE_PATH}, new search path for @acronym{DXE3} modules
  Updated handling of DXE search path for relative file names

  @itemize @bullet
  @item At first, directories from @env{LD_LIBRARY_PATH} are tried. The
  predefined value of @env{LD_LIBRARY_PATH} is currently kept for
@@ -32,11 +32,14 @@

  Both environment variables contain @strong{;} separated lists of directories.
  Before DJGPP-v2.05, only @env{LD_LIBRARY_PATH} was used. The result was DXE
  lookup failure when @env{LD_LIBRARY_PATH} was redefined by user.

-@subsection Bug Fixes
-
+@cindex @file{dir.h},  fixed a wrong structure packing directive
  @file{dir.h}: Fixed a wrong structure packing directive (bug introduced by
  djgpp-v2.01 back in 1996) that would infect other sources and headers with
  potentially adverse effects. NOTE: You might want to recompile your libraries.

+@cindex @file{math.h}, order of arguments of @code{sincos} changed
+@findex sincos AT r{, order of arguments of @code{sincos} changed}
+The Order of arguments passed to the @code{sincos} function has been changed to
+match the order used by the function version as implemented in @acronym{GNU} systems.
Index: djgpp/src/libc/compat/math/sincos.S
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/math/sincos.S,v
retrieving revision 1.4
diff -U 5 -r1.4 sincos.S
--- djgpp/src/libc/compat/math/sincos.S	17 Apr 2011 18:49:47 -0000	1.4
+++ djgpp/src/libc/compat/math/sincos.S	23 May 2015 13:00:30 -0000
@@ -1,25 +1,26 @@
+/* Copyright (C) 2015 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 2011 DJ Delorie, see COPYING.DJ for details */
  /* Copyright (C) 1999 DJ Delorie, see COPYING.DJ for details */
  NaN:
  	.long	0x00000000, 0xFFF80000

  	.globl	_sincos
  _sincos:

-	/* void sincos(double *cosine, double *sine, double x); */
+	/* void sincos(double x, double *sine, double *cosine); */

-	movl	16(%esp), %ecx
+	movl	8(%esp), %ecx

-	movl	4(%esp), %eax		/* Point to cosine. */
-	movl	8(%esp), %edx		/* Point to sine. */
+	movl	12(%esp), %edx		/* Point to sine. */
+	movl	16(%esp), %eax		/* Point to cosine. */

  	andl	$0x7FF00000, %ecx	/* Examine exponent of x. */
  	cmpl	$0x43E00000, %ecx	/* |x| >= 2^63 */
  	jae	bigarg

-	fldl	12(%esp)
+	fldl	4(%esp)
  	fsincos
  	fstpl	(%eax)			/* cos */
  	fstpl	(%edx)			/* sin */
  	ret

Index: djgpp/src/libc/compat/math/sincos.txh
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/math/sincos.txh,v
retrieving revision 1.2
diff -U 5 -r1.2 sincos.txh
--- djgpp/src/libc/compat/math/sincos.txh	29 Jan 2003 12:36:37 -0000	1.2
+++ djgpp/src/libc/compat/math/sincos.txh	23 May 2015 13:00:30 -0000
@@ -4,11 +4,11 @@
  @subheading Syntax

  @example
  #include <math.h>

-void   sincos(double *cosine, double *sine, double x);
+void   sincos(double x, double *sine, double *cosine);
  @end example

  @subheading Description

  This function computes the cosine and the sine of @var{x} in a single
diff -aprNU5 djgpp.orig/tests/libc/compat/math/makefile djgpp/tests/libc/compat/math/makefile
--- djgpp.orig/tests/libc/compat/math/makefile	1970-01-01 00:00:00 +0000
+++ djgpp/tests/libc/compat/math/makefile	2015-05-18 00:51:30 +0000
@@ -0,0 +1,5 @@
+TOP=../..
+
+SRC += sincos.c
+
+include $(TOP)/../makefile.inc
diff -aprNU5 djgpp.orig/tests/libc/compat/math/sincos.c djgpp/tests/libc/compat/math/sincos.c
--- djgpp.orig/tests/libc/compat/math/sincos.c	1970-01-01 00:00:00 +0000
+++ djgpp/tests/libc/compat/math/sincos.c	2015-05-18 00:51:30 +0000
@@ -0,0 +1,78 @@
+#include <math.h>
+#include <stdio.h>
+
+static double argument[] = {
+  -1.5707963267948966192313216916398L,  /* -90 degree.  */
+  -1.3089969389957471826927680763665L,  /* -75 degree.  */
+  -1.0471975511965977461542144610932L,  /* -60 degree.  */
+  -0.7853981633974483096156608458199L,  /* -45 degree.  */
+  -0.5235987755982988730771072305466L,  /* -30 degree.  */
+  -0.2617993877991494365385536152733L,  /* -15 degree.  */
+  +0.0000000000000000000000000000000L,  /* +0  degree.  */
+  +0.2617993877991494365385536152733L,  /* +15 degree.  */
+  +0.5235987755982988730771072305466L,  /* +30 degree.  */
+  +0.7853981633974483096156608458199L,  /* +45 degree.  */
+  +1.0471975511965977461542144610932L,  /* +60 degree.  */
+  +1.3089969389957471826927680763665L,  /* +75 degree.  */
+  +1.5707963267948966192313216916398L,  /* +90 degree.  */
+  +2.0943951023931954923084289221863L,  /* +120 degree. */
+  +2.6179938779914943653855361527329L,  /* +150 degree. */
+  +3.1415926535897932384626433832795L,  /* +180 degree. */
+  +3.1415926535897932384626433832795L,  /* +180 degree. */
+  +3.9269908169872415480783042290994L,  /* +225 degree. */
+  +4.7123889803846898576939650749193L,  /* +270 degree. */
+  +5.4977871437821381673096259207391L,  /* +315 degree. */
+  +6.283185307179586476925286766559L,   /* +360 degree. */
+};
+
+static double should_be[][2] = {
+  /*   sine value        cosine value   */
+  {-1.000000000000000, 0.000000000000000},
+  {-0.965925826289068, 0.258819045102521},
+  {-0.866025403784439, 0.500000000000000},
+  {-0.707106781186547, 0.707106781186548},
+  {-0.500000000000000, 0.866025403784439},
+  {-0.258819045102521, 0.965925826289068},
+  {0.000000000000000, 1.000000000000000},
+  {0.258819045102521, 0.965925826289068},
+  {0.500000000000000, 0.866025403784439},
+  {0.707106781186547, 0.707106781186548},
+  {0.866025403784439, 0.500000000000000},
+  {0.965925826289068, 0.258819045102521},
+  {1.000000000000000, 0.000000000000000},
+  {0.866025403784439, -0.500000000000000},
+  {0.500000000000000, -0.866025403784439},
+  {0.000000000000000, -1.000000000000000},
+  {0.000000000000000, -1.000000000000000},
+  {-0.707106781186547, -0.707106781186548},
+  {-1.000000000000000, -0.000000000000000},
+  {-0.707106781186548, 0.707106781186547},
+  {-0.000000000000000, 1.000000000000000}
+};
+
+static const size_t n_test_arguments = sizeof(argument) / sizeof(argument[0]);
+
+
+int main(void)
+{
+  unsigned int i, error_counter;
+
+  for (error_counter = i = 0; i < n_test_arguments; i++)
+  {
+    double sv, cv;
+    sincos(argument[i], &sv, &cv);
+    if (fabs(sv - should_be[i][0]) > 1.E-15 || fabs(cv - should_be[i][1]) > 1.E-15)
+    {
+      printf("sincos failed for %.15f\n"
+             "returned values: sine value   = %.15f,  should be = %.15f\n"
+             "                 cosine value = %.15f,  should be = %.15f\n",
+             argument[i], sv, should_be[i][0], cv, should_be[i][1]);
+      error_counter++;
+    }
+  }
+
+  if (error_counter == 0)
+    printf("sincos test passed.\n");
+
+  return error_counter;
+}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019