diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-07-16 13:28:28 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-11-03 21:59:54 +0100 |
commit | 37388ebb0ef9085c841d7f94e665a5a77cfe0e92 (patch) | |
tree | b47d18bee4e7f661d9e6d794dac0ec1cebcd3a37 /osdep | |
parent | 891a2a1f474add323145e6b2cd2d29181830e4a4 (diff) | |
download | mpv-37388ebb0ef9085c841d7f94e665a5a77cfe0e92.tar.bz2 mpv-37388ebb0ef9085c841d7f94e665a5a77cfe0e92.tar.xz |
configure: uniform the defines to #define HAVE_xxx (0|1)
The configure followed 5 different convetions of defines because the next guy
always wanted to introduce a new better way to uniform it[1]. For an
hypothetic feature 'hurr' you could have had:
* #define HAVE_HURR 1 / #undef HAVE_DURR
* #define HAVE_HURR / #undef HAVE_DURR
* #define CONFIG_HURR 1 / #undef CONFIG_DURR
* #define HAVE_HURR 1 / #define HAVE_DURR 0
* #define CONFIG_HURR 1 / #define CONFIG_DURR 0
All is now uniform and uses:
* #define HAVE_HURR 1
* #define HAVE_DURR 0
We like definining to 0 as opposed to `undef` bcause it can help spot typos
and is very helpful when doing big reorganizations in the code.
[1]: http://xkcd.com/927/ related
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/getch2.c | 27 | ||||
-rw-r--r-- | osdep/io.c | 4 | ||||
-rw-r--r-- | osdep/timer-linux.c | 2 |
3 files changed, 17 insertions, 16 deletions
diff --git a/osdep/getch2.c b/osdep/getch2.c index 8b87e79c76..e3b1179fdf 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -30,11 +30,11 @@ #include <errno.h> #include <sys/ioctl.h> -#ifdef HAVE_TERMIOS -#ifdef HAVE_TERMIOS_H +#if HAVE_TERMIOS +#if HAVE_TERMIOS_H #include <termios.h> #endif -#ifdef HAVE_SYS_TERMIOS_H +#if HAVE_SYS_TERMIOS_H #include <sys/termios.h> #endif #endif @@ -47,7 +47,7 @@ #include "mpvcore/input/keycodes.h" #include "getch2.h" -#ifdef HAVE_TERMIOS +#if HAVE_TERMIOS static volatile struct termios tio_orig; static volatile int tio_orig_set; #endif @@ -71,12 +71,13 @@ typedef struct { static keycode_map getch2_keys; -#ifdef HAVE_TERMCAP +#if HAVE_TERMINFO || HAVE_TERMCAP + static char *term_rmkx = NULL; static char *term_smkx = NULL; -#ifdef HAVE_TERMINFO +#if HAVE_TERMINFO #include <curses.h> #endif #include <term.h> @@ -138,7 +139,7 @@ static keycode_st* keys_push_once(char *p, int code) { return st; } -#ifdef HAVE_TERMCAP +#if HAVE_TERMINFO || HAVE_TERMCAP typedef struct { char *buf; @@ -228,9 +229,9 @@ static void termcap_add_extra_f_keys(void) { #endif int load_termcap(char *termtype){ -#ifdef HAVE_TERMCAP +#if HAVE_TERMINFO || HAVE_TERMCAP -#ifdef HAVE_TERMINFO +#if HAVE_TERMINFO use_env(TRUE); int ret; if (setupterm(termtype, 1, &ret) != OK) { @@ -445,12 +446,12 @@ static void do_activate_getch2(void) if (getch2_active) return; -#ifdef HAVE_TERMCAP +#if HAVE_TERMINFO || HAVE_TERMCAP if (term_smkx) tputs(term_smkx, 1, putchar); #endif -#ifdef HAVE_TERMIOS +#if HAVE_TERMIOS struct termios tio_new; tcgetattr(0,&tio_new); @@ -473,12 +474,12 @@ static void do_deactivate_getch2(void) if (!getch2_active) return; -#ifdef HAVE_TERMCAP +#if HAVE_TERMINFO || HAVE_TERMCAP if (term_rmkx) tputs(term_rmkx, 1, putchar); #endif -#ifdef HAVE_TERMIOS +#if HAVE_TERMIOS if (tio_orig_set) { // once set, it will never be set again // so we can cast away volatile here diff --git a/osdep/io.c b/osdep/io.c index b618c76747..b949746e6e 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -58,7 +58,7 @@ char *mp_to_utf8(void *talloc_ctx, const wchar_t *s) #include <io.h> #include <fcntl.h> -#ifdef HAVE_PTHREADS +#if HAVE_PTHREADS #include <pthread.h> #endif @@ -298,7 +298,7 @@ static void init_getenv(void) char *mp_getenv(const char *name) { -#ifdef HAVE_PTHREADS +#if HAVE_PTHREADS static pthread_once_t once_init_getenv = PTHREAD_ONCE_INIT; pthread_once(&once_init_getenv, init_getenv); #else diff --git a/osdep/timer-linux.c b/osdep/timer-linux.c index 314aa47b27..1378e6ea7e 100644 --- a/osdep/timer-linux.c +++ b/osdep/timer-linux.c @@ -30,7 +30,7 @@ void mp_sleep_us(int64_t us) { if (us < 0) return; -#ifdef HAVE_NANOSLEEP +#if HAVE_NANOSLEEP struct timespec ts; ts.tv_sec = us / 1000000; ts.tv_nsec = (us % 1000000) * 1000; |