]> git.alsa-project.org Git - alsa-lib.git/commitdiff
test: BSD-like fixes
authorSASANO Takayoshi <uaa@uaa.org.uk>
Thu, 2 Feb 2023 07:00:45 +0000 (16:00 +0900)
committerJaroslav Kysela <perex@perex.cz>
Fri, 3 Feb 2023 12:22:04 +0000 (13:22 +0100)
- rename devname -> pcmdev, it conflicts *BSD <stdlib.h> function
- replace <values.h> -> <limits.h> and fix K&R style related warning
- use config.h to determine include <malloc.h>
- add OpenBSD support and fix printf() warning
- fix warning

Fixes: https://github.com/alsa-project/alsa-lib/pull/298
Signed-off-by: SASANO Takayoshi <uaa@uaa.org.uk>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
test/audio_time.c
test/latency.c
test/midifile.c
test/namehint.c
test/pcm-multi-thread.c
test/queue_timer.c

index 919bebe3605fcaffe4bda16aece253d000305035..1c8481bee41035a70804e1bd58ea7734a094dd0c 100644 (file)
@@ -4,8 +4,11 @@
  * helpful to verify the information reported by drivers.
  */
 
+#include "../include/config.h"
 #include <stdio.h>
+#if HAVE_MALLOC_H
 #include <malloc.h>
+#endif
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
index 5e67015cace70ee1f3f3ced13cb5eb90bbca7f81..40c63e2442656a55e0f03d1378bb0850bb627097 100644 (file)
 #include <sys/time.h>
 #include <math.h>
 
+#ifndef CLOCK_MONOTONIC_RAW
+#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
+#endif
+
+#if defined(__OpenBSD__)
+#define sched_getparam(pid, parm) (-1)
+#define sched_setscheduler(pid, policy, parm) (-1)
+#endif
+
 typedef struct timespec timestamp_t;
 
 char *sched_policy = "rr";
@@ -839,9 +848,9 @@ int main(int argc, char *argv[])
                if (ok) {
 #if 1
                        printf("Playback time = %li.%i, Record time = %li.%i, diff = %li\n",
-                              p_tstamp.tv_sec,
+                              (long)p_tstamp.tv_sec,
                               (int)p_tstamp.tv_usec,
-                              c_tstamp.tv_sec,
+                              (long)c_tstamp.tv_sec,
                               (int)c_tstamp.tv_usec,
                               timediff(p_tstamp, c_tstamp));
 #endif
index 3d72b9f9980eba827133b3ace6f93d4c4b535e9e..4862b199c7e710a56c92f61568f45e3c8e9fc365 100644 (file)
@@ -71,7 +71,7 @@
 #endif
 
 #include <stdio.h>
-#include <values.h>
+#include <limits.h>
 
 #include <string.h>
 /*void exit(), free();*/
@@ -148,7 +148,7 @@ static void msginit ();
 static int msgleng ();
 static void msgadd ();
 static void biggermsg ();
-static int eputc (unsigned char c);
+static int eputc ();
 
 double mf_ticks2sec (unsigned long ticks, int division, unsigned long tempo);
 int mf_write_meta_event ();
@@ -328,7 +328,7 @@ readtrack ()                        /* read a track chunk */
 
   if (Mf_interactive)
     {
-      Mf_toberead = MAXINT;
+      Mf_toberead = INT_MAX;
     }
   else
     {
index e978d5ca34eddf507895f87543c7d1bb1a1defa2..18bad1d885005e29e6d834398a96493248076e07 100644 (file)
@@ -4,7 +4,8 @@
 int main(int argc, char *argv[])
 {
        const char *iface = "pcm";
-       char **hints, **n;
+       void **hints;
+       char **n;
        int err;
 
        if (argc > 1)
@@ -12,7 +13,7 @@ int main(int argc, char *argv[])
        err = snd_device_name_hint(-1, iface, &hints);
        if (err < 0)
                errx(1, "snd_device_name_hint error: %s", snd_strerror(err));
-       n = hints;
+       n = (char **)hints;
        while (*n != NULL) {
                printf("%s\n", *n);
                n++;
index da1b87c60b1628b0b8b3f42d10e0d82b96376b98..de178899d044f79838d7586db485be3147f548a2 100644 (file)
@@ -37,7 +37,7 @@ static char mode_suffix[] = {
        'a', 's', 'h', 't', 'd', 'r'
 };
 
-static const char *devname = "default";
+static const char *pcmdev = "default";
 static int stream = SND_PCM_STREAM_PLAYBACK;
 static int num_threads = 1;
 static int periodsize = 16 * 1024;
@@ -127,7 +127,7 @@ static int parse_options(int argc, char **argv)
        while ((c = getopt(argc, argv, "D:r:f:p:b:s:t:m:vq")) >= 0) {
                switch (c) {
                case 'D':
-                       devname = optarg;
+                       pcmdev = optarg;
                        break;
                case 'r':
                        rate = atoi(optarg);
@@ -213,9 +213,9 @@ int main(int argc, char **argv)
        if (parse_options(argc, argv))
                return 1;
 
-       err = snd_pcm_open(&pcm, devname, stream, 0);
+       err = snd_pcm_open(&pcm, pcmdev, stream, 0);
        if (err < 0) {
-               fprintf(stderr, "cannot open pcm %s\n", devname);
+               fprintf(stderr, "cannot open pcm %s\n", pcmdev);
                return 1;
        }
 
index c4ffb19211d309d5cf11385d954e1f556cd9cc89..4e1fa9672fb7193a43ae0e826e658feaa40338e1 100644 (file)
@@ -100,9 +100,9 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
        prevdiff = diff;
 
        fprintf(stderr, " real time: %12ld sec %8ld usec\nqueue time: %12ld sec %8ld usec\n      diff: %12ld sec %8ld usec\n  diffdiff: %12ld sec %8ld usec\n",
-               tv.tv_sec, tv.tv_usec,
+               (long)tv.tv_sec, tv.tv_usec,
                (long)rtime->tv_sec, (long)rtime->tv_nsec / 1000,
-               diff.tv_sec, diff.tv_usec,
+               (long)diff.tv_sec, diff.tv_usec,
                (long)diffdiff.tv_sec, (long)diffdiff.tv_usec);
 
        if (diffdiff.tv_usec >  5000 ||