From a8a78f935dcefa8a7fcda8dae80bca64fe39d632 Mon Sep 17 00:00:00 2001 From: Andre Date: Sat, 15 Apr 2006 17:58:13 +0200 Subject: [PATCH] Rename MIN, MAX, ABS macros MIN and MAX are already defined on MacOS. --- audioc.c | 4 ++-- audiod.c | 4 ++-- compress.c | 3 ++- dccp_send.c | 4 ++-- fd.c | 2 +- grab_client.c | 2 +- gui.c | 7 ++++--- http_send.c | 9 +++++---- mp3dec.c | 2 +- ogg.c | 4 ++-- oggdec.c | 2 +- para.h | 6 +++--- playlist_selector.c | 2 +- random_selector.c | 2 +- recv.c | 2 +- server.c | 4 ++-- time.c | 2 +- wav.c | 2 +- 18 files changed, 33 insertions(+), 30 deletions(-) diff --git a/audioc.c b/audioc.c index 55314264..1fa98802 100644 --- a/audioc.c +++ b/audioc.c @@ -121,11 +121,11 @@ int main(int argc, char *argv[]) fprintf(stderr, "loaded: %d\n", loaded); if (loaded < conf.bufsize_arg) { FD_SET(fd, &rfd); - max_fileno = MAX(max_fileno, fd); + max_fileno = PARA_MAX(max_fileno, fd); } if (loaded > 0) { FD_SET(STDOUT_FILENO, &wfd); - max_fileno = MAX(max_fileno, STDOUT_FILENO); + max_fileno = PARA_MAX(max_fileno, STDOUT_FILENO); check_write = 1; } ret = -E_OVERRUN; diff --git a/audiod.c b/audiod.c index 0e5fed48..f15ab710 100644 --- a/audiod.c +++ b/audiod.c @@ -1157,7 +1157,7 @@ static int init_stream_io(void) free(cmd); /* filters */ filter_init(filters); - nf = MAX(2, conf.filter_given) + 1; + nf = PARA_MAX(2, conf.filter_given) + 1; PARA_INFO_LOG("allocating space for %d filters\n", nf); FOR_EACH_AUDIO_FORMAT(i) { afi[i].filter_conf = para_malloc(nf * sizeof(char *)); @@ -1525,7 +1525,7 @@ static void audiod_pre_select(fd_set *rfds, fd_set *wfds, struct timeval *tv, a = &afi[s->format]; ret = a->receiver->pre_select(rn, rfds, wfds, tv); // PARA_NOTICE_LOG("%s preselect: %d\n", a->receiver->name, ret); - *max_fileno = MAX(*max_fileno, ret); + *max_fileno = PARA_MAX(*max_fileno, ret); } } static void audiod_post_select(int select_ret, fd_set *rfds, fd_set *wfds) diff --git a/compress.c b/compress.c index de5448fb..b4e4c40a 100644 --- a/compress.c +++ b/compress.c @@ -49,7 +49,8 @@ struct private_compress_data { static ssize_t compress(char *inbuf, size_t inbuf_len, struct filter_node *fn) { - size_t i, length = MIN((inbuf_len / 2) * 2, (fn->bufsize - fn->loaded) / 2 * 2); + size_t i, length = PARA_MIN((inbuf_len / 2) * 2, + (fn->bufsize - fn->loaded) / 2 * 2); struct private_compress_data *pcd = fn->private_data; int16_t *ip = (int16_t *)inbuf, *op = (int16_t *)(fn->buf + fn->loaded); unsigned gain_shift = pcd->conf->inertia_arg + pcd->conf->damp_arg, diff --git a/dccp_send.c b/dccp_send.c index 55548620..7fad4f7d 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -56,7 +56,7 @@ static void dccp_pre_select(__a_unused struct audio_format *af, int *max_fileno, if (listen_fd < 0) return; FD_SET(listen_fd, rfds); - *max_fileno = MAX(*max_fileno, listen_fd); + *max_fileno = PARA_MAX(*max_fileno, listen_fd); } static void dccp_post_select(__a_unused struct audio_format *af, fd_set *rfds, @@ -119,7 +119,7 @@ static int dccp_write(int fd, const char *buf, size_t len) size_t send, written = 0; int ret; again: - send = MIN(1024, len - written); + send = PARA_MIN(1024, len - written); ret = write(fd, buf + written, send); if (ret < 0) goto err_out; diff --git a/fd.c b/fd.c index dc22d147..c5a37cdd 100644 --- a/fd.c +++ b/fd.c @@ -98,5 +98,5 @@ int mark_fd_nonblock(int fd) void para_fd_set(int fd, fd_set *fds, int *max_fileno) { FD_SET(fd, fds); - *max_fileno = MAX(*max_fileno, fd); + *max_fileno = PARA_MAX(*max_fileno, fd); } diff --git a/grab_client.c b/grab_client.c index f853a764..ee07d875 100644 --- a/grab_client.c +++ b/grab_client.c @@ -43,7 +43,7 @@ static int max_num_filters(void) for (i = 0; audio_formats[i]; i++) { PARA_INFO_LOG("%s filter chain length: %d\n", audio_formats[i], num_filters(i)); - ret = MAX(ret, num_filters(i)); + ret = PARA_MAX(ret, num_filters(i)); } PARA_INFO_LOG("maximal filter chain length: %d\n", ret); return ret; diff --git a/gui.c b/gui.c index 23257291..0babfa83 100644 --- a/gui.c +++ b/gui.c @@ -886,18 +886,19 @@ repeat: /* audiod pipe */ if (audiod_pipe < 0) audiod_pipe = open_audiod_pipe(); + /* FIXME: para_fd_set */ if (audiod_pipe >= 0) { FD_SET(audiod_pipe, &rfds); - max_fileno = MAX(max_fileno, audiod_pipe); + max_fileno = PARA_MAX(max_fileno, audiod_pipe); } /* signal pipe */ FD_SET(signal_pipe, &rfds); - max_fileno = MAX(max_fileno, signal_pipe); + max_fileno = PARA_MAX(max_fileno, signal_pipe); /* command pipe only for COMMAND_MODE */ if (command_pipe >= 0 && mode == COMMAND_MODE) { FD_SET(command_pipe, &rfds); - max_fileno = MAX(max_fileno, command_pipe); + max_fileno = PARA_MAX(max_fileno, command_pipe); } if (curses_active) FD_SET(STDIN_FILENO, &rfds); diff --git a/http_send.c b/http_send.c index 926f7808..bb9534cb 100644 --- a/http_send.c +++ b/http_send.c @@ -346,6 +346,7 @@ err_out: free(hc); } +/* FIXME: use para_fdset */ static void http_pre_select(struct audio_format *af, int *max_fileno, fd_set *rfds, fd_set *wfds) { @@ -354,7 +355,7 @@ static void http_pre_select(struct audio_format *af, int *max_fileno, fd_set *rf if (server_fd < 0) return; FD_SET(server_fd, rfds); - *max_fileno = MAX(*max_fileno, server_fd); + *max_fileno = PARA_MAX(*max_fileno, server_fd); list_for_each_entry_safe(hc, tmp, &clients, node) { //PARA_DEBUG_LOG("hc %p on fd %d: status %d\n", hc, hc->fd, hc->status); hc->check_r = 0; @@ -365,20 +366,20 @@ static void http_pre_select(struct audio_format *af, int *max_fileno, fd_set *rf break; case HTTP_CONNECTED: /* need to recv get request */ FD_SET(hc->fd, rfds); - *max_fileno = MAX(*max_fileno, hc->fd); + *max_fileno = PARA_MAX(*max_fileno, hc->fd); hc->check_r = 1; break; case HTTP_GOT_GET_REQUEST: /* need to send ok msg */ case HTTP_INVALID_GET_REQUEST: /* need to send err msg */ FD_SET(hc->fd, wfds); - *max_fileno = MAX(*max_fileno, hc->fd); + *max_fileno = PARA_MAX(*max_fileno, hc->fd); hc->check_w = 1; break; case HTTP_SENT_OK_MSG: if (!af || !afs_playing()) break; /* wait until server starts playing */ FD_SET(hc->fd, wfds); - *max_fileno = MAX(*max_fileno, hc->fd); + *max_fileno = PARA_MAX(*max_fileno, hc->fd); hc->check_w = 1; break; } diff --git a/mp3dec.c b/mp3dec.c index 0d0906b7..4599df90 100644 --- a/mp3dec.c +++ b/mp3dec.c @@ -52,7 +52,7 @@ static ssize_t mp3dec(char *inbuffer, size_t len, struct filter_node *fn) { int i, ret; struct private_mp3dec_data *pmd = fn->private_data; - size_t copy = MIN(len, 4096); + size_t copy = PARA_MIN(len, 4096); if (fn->loaded > fn->bufsize * 4 / 5) return 0; diff --git a/ogg.c b/ogg.c index b38a8f49..2d584e5b 100644 --- a/ogg.c +++ b/ogg.c @@ -170,8 +170,8 @@ static void ogg_compute_chunk_table(double time_total) break; pos = ov_raw_tell(oggvorbis_file); diff = pos - old_pos; - max_chunk_len = MAX(max_chunk_len, diff); - min = (i == 1)? diff : MIN(min, diff); + max_chunk_len = PARA_MAX(max_chunk_len, diff); + min = (i == 1)? diff : PARA_MIN(min, diff); chunk_table[i] = pos; if (i < 11 || !((i - 1) % 1000)|| i > num - 11) PARA_DEBUG_LOG("chunk #%d: %g secs, pos: %zd, " diff --git a/oggdec.c b/oggdec.c index b1ddd975..3554eb1b 100644 --- a/oggdec.c +++ b/oggdec.c @@ -61,7 +61,7 @@ static size_t cb_read(void *buf, size_t size, size_t nmemb, void *datasource) errno = EAGAIN; return -1; } - ret = MIN(nmemb, have / size) * size; + ret = PARA_MIN(nmemb, have / size) * size; memcpy(buf, p, ret); pod->converted += ret; return ret; diff --git a/para.h b/para.h index 1ac056b3..3f050797 100644 --- a/para.h +++ b/para.h @@ -43,9 +43,9 @@ #define MAXLINE 255 -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#define ABS(a) ((a) > 0 ? (a) : -(a)) +#define PARA_MIN(a,b) ((a) < (b) ? (a) : (b)) +#define PARA_MAX(a,b) ((a) > (b) ? (a) : (b)) +#define PARA_ABS(a) ((a) > 0 ? (a) : -(a)) /* Loglevels */ #define DEBUG 1 diff --git a/playlist_selector.c b/playlist_selector.c index e5329bac..ee619b31 100644 --- a/playlist_selector.c +++ b/playlist_selector.c @@ -192,7 +192,7 @@ static char **pls_get_audio_file_list(unsigned int num) char **file_list; unsigned i; - num = MIN(num, playlist_len); + num = PARA_MIN(num, playlist_len); if (!num) return NULL; file_list = para_malloc((num + 1) * sizeof(char *)); diff --git a/random_selector.c b/random_selector.c index a90822c5..ec1f5c6c 100644 --- a/random_selector.c +++ b/random_selector.c @@ -98,7 +98,7 @@ static char **random_get_audio_file_list(unsigned int num) goto out; /* careful, files might got deleted underneath */ num_audio_files = audio_file_count; /* can only decrease */ - len = MIN(num, num_audio_files); + len = PARA_MIN(num, num_audio_files); ret = -E_NOTHING_FOUND; if (!len) /* nothing found, return NULL */ goto out; diff --git a/recv.c b/recv.c index ba1cfd20..95711f1f 100644 --- a/recv.c +++ b/recv.c @@ -85,7 +85,7 @@ recv: timeout.tv_usec = 1000 * 1000; max = -1; ret = r->pre_select(&rn, &rfds, &wfds, &timeout); - max = MAX(max, ret); + max = PARA_MAX(max, ret); PARA_DEBUG_LOG("timeout: %lums\n", tv2ms(&timeout)); ret = para_select(max + 1, &rfds, &wfds, &timeout); diff --git a/server.c b/server.c index bcb43a20..e10c1e03 100644 --- a/server.c +++ b/server.c @@ -442,7 +442,7 @@ repeat: FD_SET(sockfd, &rfds); max_fileno = sockfd; FD_SET(signal_pipe, &rfds); - max_fileno = MAX(max_fileno, signal_pipe); + max_fileno = PARA_MAX(max_fileno, signal_pipe); timeout = afs_preselect(); status_refresh(); @@ -458,7 +458,7 @@ repeat: } if (selectors[mmd->selector_num].pre_select) { ret = selectors[mmd->selector_num].pre_select(&rfds, &wfds); - max_fileno = MAX(max_fileno, ret); + max_fileno = PARA_MAX(max_fileno, ret); } mmd_unlock(); ret = para_select(max_fileno + 1, &rfds, &wfds, timeout); diff --git a/time.c b/time.c index f659b16f..34e3de95 100644 --- a/time.c +++ b/time.c @@ -141,7 +141,7 @@ int tv_convex_combination(const long a, const struct timeval *tv1, { struct timeval tmp1, tmp2, tmp3; int ret = 1, subtract = ((a > 0 && b < 0) || (a < 0 && b > 0)); - unsigned long a1 = ABS(a), b1 = ABS(b); + unsigned long a1 = PARA_ABS(a), b1 = PARA_ABS(b); tv_scale(a1, tv1, &tmp1); tv_scale(b1, tv2, &tmp2); diff --git a/wav.c b/wav.c index 879b1887..e229317d 100644 --- a/wav.c +++ b/wav.c @@ -71,7 +71,7 @@ static ssize_t wav_convert(char *inbuf, size_t len, struct filter_node *fn) *bof = 0; // return 0; } - copy = MIN(len, fn->bufsize - fn->loaded); + copy = PARA_MIN(len, fn->bufsize - fn->loaded); memmove(fn->buf + fn->loaded, inbuf, copy); fn->loaded += copy; // PARA_DEBUG_LOG("len = %d, copy = %d\n", len, copy); -- 2.39.2