]> sigrok.org Git - libsigrok.git/commitdiff
Define our own constant for PI.
authorAurelien Jacobs <redacted>
Sun, 26 Apr 2015 22:42:05 +0000 (00:42 +0200)
committerUwe Hermann <redacted>
Tue, 28 Apr 2015 20:07:03 +0000 (22:07 +0200)
M_PI is not defined in the C standard nor in POSIX, it is a
non-standard GNU extension.

src/hardware/demo/demo.c
src/hardware/saleae-logic16/protocol.c
src/libsigrok-internal.h

index 7111097bb7657046d70c4f1efcf03e4cf39092cf..44b9293133faba108c1218a7b0ff76b1c664d3b0 100644 (file)
@@ -225,7 +225,7 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
                for (i = 0; i < num_samples; i++) {
                        t = (double) i / (double) sample_rate;
                        ag->pattern_data[i] = ag->amplitude *
-                                               sin(2 * M_PI * frequency * t);
+                                               sin(2 * PI * frequency * t);
                }
 
                ag->num_samples = num_samples;
@@ -238,8 +238,8 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
 
                for (i = 0; i < num_samples; i++) {
                        t = (double) i / (double) sample_rate;
-                       ag->pattern_data[i] = (2 * ag->amplitude / M_PI) *
-                                               asin(sin(2 * M_PI * frequency * t));
+                       ag->pattern_data[i] = (2 * ag->amplitude / PI) *
+                                               asin(sin(2 * PI * frequency * t));
                }
 
                ag->num_samples = num_samples;
index 3db8a82f0b8577b9bf580324b9f2a96598dcb013..1e900c15850541552298253ff81be676844074dd 100644 (file)
@@ -307,7 +307,7 @@ static void make_heartbeat(uint8_t *table, int len)
        len >>= 3;
        for (i = 0; i < 2; i++)
                for (j = 0; j < len; j++)
-                       *table++ = sin(j * M_PI / len) * 255;
+                       *table++ = sin(j * PI / len) * 255;
 }
 
 static int configure_led(const struct sr_dev_inst *sdi)
index b4b32f23ac2a6df21edd845dabe9dc8a3b2e3efe..9060e2a77b707a913363aa4ea1662b317b6699a0 100644 (file)
                          ((uint8_t*)(p))[2] = (uint8_t)((x)>>16); \
                          ((uint8_t*)(p))[3] = (uint8_t)((x)>>24); } while (0)
 
+#define PI 3.1415926535897932384626433832795
+
 /* Portability fixes for FreeBSD. */
 #ifdef __FreeBSD__
 #define LIBUSB_CLASS_APPLICATION 0xfe