Discussion:
[PATCH 1/6] compiler.h: make __builtin_expect depend on __GNUC__
Johannes Weißl
2011-02-16 05:05:07 UTC
Permalink
__builtin_expect is only available in gcc-compatible compilers like
clang and icc, not tcc (tinyCC).
---
compiler.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/compiler.h b/compiler.h
index 061da77..98f6566 100644
--- a/compiler.h
+++ b/compiler.h
@@ -8,6 +8,7 @@
/*
* GCC 2.96 or compatible required
*/
+#if defined(__GNUC__)

/* Optimization: Condition @x is likely */
#define likely(x) __builtin_expect(!!(x), 1)
@@ -15,6 +16,13 @@
/* Optimization: Condition @x is unlikely */
#define unlikely(x) __builtin_expect(!!(x), 0)

+#else
+
+#define likely(x) (x)
+#define unlikely(x) (x)
+
+#endif
+
/* Optimization: Function never returns */
#define __NORETURN __attribute__((__noreturn__))
--
1.7.2.3
Johannes Weißl
2011-02-16 05:05:08 UTC
Permalink
* defined central in compiler.h, no code duplication
* offsetof() uses builtin in clang and icc now (fixes icc warning), and
stddef.h default else (e.g. tcc)
* container_of() has non-gcc fallback (works with tcc)
---
compiler.h | 25 +++++++++++++++++++++++++
list.h | 18 +-----------------
rbtree.h | 15 +--------------
3 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/compiler.h b/compiler.h
index 98f6566..87fc3ed 100644
--- a/compiler.h
+++ b/compiler.h
@@ -5,11 +5,16 @@
#ifndef COMPILER_H
#define COMPILER_H

+#include <stddef.h>
+
/*
* GCC 2.96 or compatible required
*/
#if defined(__GNUC__)

+#undef offsetof
+#define offsetof(type, member) __builtin_offsetof(type, member)
+
/* Optimization: Condition @x is likely */
#define likely(x) __builtin_expect(!!(x), 1)

@@ -41,4 +46,24 @@

#endif

+
+/**
+ * container_of - cast a member of a structure out to the containing structure
+ *
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#define container_of_portable(ptr, type, member) \
+ ((type *)( (char *)(ptr) - offsetof(type,member) ))
+#undef container_of
+#if defined(__GNUC__)
+#define container_of(ptr, type, member) ({ \
+ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
+ container_of_portable(__mptr, type, member);})
+#else
+#define container_of(ptr, type, member) container_of_portable(ptr, type, member)
+#endif
+
#endif
diff --git a/list.h b/list.h
index 0a28cf2..0abf70a 100644
--- a/list.h
+++ b/list.h
@@ -2,7 +2,7 @@
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H

-#include <stdlib.h>
+#include "compiler.h" /* container_of */

static inline void prefetch(const void *x)
{
@@ -192,22 +192,6 @@ static inline void list_splice_init(struct list_head *list,
}
}

-#undef offsetof
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-
-/**
- * container_of - cast a member of a structure out to the containing structure
- *
- * @ptr: the pointer to the member.
- * @type: the type of the container struct this is embedded in.
- * @member: the name of the member within the struct.
- *
- */
-#undef container_of
-#define container_of(ptr, type, member) ({ \
- const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
diff --git a/rbtree.h b/rbtree.h
index 2554be6..cc7020f 100644
--- a/rbtree.h
+++ b/rbtree.h
@@ -96,22 +96,9 @@ static inline struct page * rb_insert_page_cache(struct inode * inode,
#ifndef _LINUX_RBTREE_H
#define _LINUX_RBTREE_H

+#include "compiler.h" /* container_of */
#include <stddef.h>

-/**
- * container_of - cast a member of a structure out to the containing structure
- *
- * @ptr: the pointer to the member.
- * @type: the type of the container struct this is embedded in.
- * @member: the name of the member within the struct.
- *
- */
-#undef container_of
-#define container_of(ptr, type, member) ({ \
- const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
-
struct rb_node
{
unsigned long rb_parent_color;
--
1.7.2.3
Johannes Weißl
2011-02-16 05:05:09 UTC
Permalink
Fails in some compilers, e.g. tcc (tinyCC).
Autoconf uses (now?) the same test, so it should be fine.
---
scripts/checks.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/checks.sh b/scripts/checks.sh
index 266ae14..6e5f591 100644
--- a/scripts/checks.sh
+++ b/scripts/checks.sh
@@ -495,7 +495,7 @@ check_function()
__func="$1"
shift
msg_checking "for function $__func"
- if try_compile_link "char $__func(); char (*f)() = $__func; int main(int argc, char *argv[]) { return f != $__func; }" "$@" && ./$__exe
+ if try_compile_link "char $__func(); int main(int argc, char *argv[]) { return $__func; }" "$@"
then
msg_result yes
return 0
--
1.7.2.3
Johannes Weißl
2011-02-16 05:05:10 UTC
Permalink
tcc (tinyCC) doesn't understand -Wl,--export-dynamic.
Otherwise dynamic libraries fail to load (undefined symbols).
---
scripts/checks.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/checks.sh b/scripts/checks.sh
index 6e5f591..6d3d9f5 100644
--- a/scripts/checks.sh
+++ b/scripts/checks.sh
@@ -598,7 +598,7 @@ check_pthread()
# adds DL_LIBS to config.mk
check_dl()
{
- for DL_LIBS in "-ldl -Wl,--export-dynamic" "-Wl,--export-dynamic" "-ldl"
+ for DL_LIBS in "-ldl -Wl,--export-dynamic" "-ldl -rdynamic" "-Wl,--export-dynamic" "-rdynamic" "-ldl"
do
check_library DL "" "$DL_LIBS" && return 0
done
--
1.7.2.3
Johannes Weißl
2011-02-16 05:05:11 UTC
Permalink
Otherwise colors are wrong (e.g. black text on black background) anyway,
so better disable colors completely.
---
ui_curses.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ui_curses.c b/ui_curses.c
index d217d7d..097ac42 100644
--- a/ui_curses.c
+++ b/ui_curses.c
@@ -2074,8 +2074,8 @@ static void init_curses(void)

noecho();
if (has_colors()) {
- start_color();
#if HAVE_USE_DEFAULT_COLORS
+ start_color();
use_default_colors();
#endif
}
--
1.7.2.3
Jason Woofenden
2011-02-22 06:10:51 UTC
Permalink
Post by Johannes Weißl
Otherwise colors are wrong (e.g. black text on black background) anyway,
so better disable colors completely.
Looks like a great change, but now that I've tried cmus with colors
disabled (accidentally, because I still had "-Wall -Werror" in my
CFLAGS from earlier experimentation, and that made the
use_default_colors function check fail) I think the colorless UI
needs a little work.

Screenshot attached.

The main problem is that you can't see what track is selected.
(Which track will play if you press enter.) We need to either
reverse video that line, or show the cursor (and make sure it's on
that line).

Take care, - Jason
Johannes Weißl
2011-02-22 21:33:36 UTC
Permalink
Post by Jason Woofenden
Post by Johannes Weißl
Otherwise colors are wrong (e.g. black text on black background) anyway,
so better disable colors completely.
Looks like a great change, but now that I've tried cmus with colors
disabled (accidentally, because I still had "-Wall -Werror" in my
CFLAGS from earlier experimentation, and that made the
use_default_colors function check fail) I think the colorless UI
needs a little work.
Screenshot attached.
The main problem is that you can't see what track is selected.
(Which track will play if you press enter.) We need to either
reverse video that line, or show the cursor (and make sure it's on
that line).
I tried it, and here the selected track is bold. But it is still hard to
see. Maybe it would be better to have white background / black
foreground for selected tracks? What terminal / version of ncurses are
you using?

Johannes
Jason Woofenden
2011-02-24 06:12:53 UTC
Permalink
Post by Johannes Weißl
Post by Jason Woofenden
Post by Johannes Weißl
Otherwise colors are wrong (e.g. black text on black background) anyway,
so better disable colors completely.
Looks like a great change, but now that I've tried cmus with colors
disabled (accidentally, because I still had "-Wall -Werror" in my
CFLAGS from earlier experimentation, and that made the
use_default_colors function check fail) I think the colorless UI
needs a little work.
Screenshot attached.
The main problem is that you can't see what track is selected.
(Which track will play if you press enter.) We need to either
reverse video that line, or show the cursor (and make sure it's on
that line).
I tried it, and here the selected track is bold. But it is still hard to
see. Maybe it would be better to have white background / black
foreground for selected tracks? What terminal / version of ncurses are
you using?
Ahh, bold! I didn't think to check for that.

Apparently at some point I disabled bold text in my terminal
(gnome-terminal has a checkbox for this.) Or maybe disabled used to
be the default. I checked on a new account on my computer that by
default gnome-terminal does show bold.

OK, now I've got bold working again, and tried cmus without color.
I agree that it's hard to pick out which one is bold. I think we
should swap the fg and bg colors for the first line, third to last
line, and the cursor line. I think the currently playing track
needs to look different than the cursor line, perhaps the currently
playing track should be bold?

Take care, - Jason

Johannes Weißl
2011-02-16 05:05:12 UTC
Permalink
source:
http://openvswitch.org/pipermail/dev_openvswitch.org/2010-May/001995.html

Reported by Jason Woofenden <***@jasonwoof.com>.
---
compiler.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/compiler.h b/compiler.h
index 87fc3ed..279ed4a 100644
--- a/compiler.h
+++ b/compiler.h
@@ -56,7 +56,7 @@
*
*/
#define container_of_portable(ptr, type, member) \
- ((type *)( (char *)(ptr) - offsetof(type,member) ))
+ ((type *)(void *)( (char *)(ptr) - offsetof(type,member) ))
#undef container_of
#if defined(__GNUC__)
#define container_of(ptr, type, member) ({ \
--
1.7.2.3
Gregory Petrosyan
2011-02-19 13:07:47 UTC
Permalink
Merged all 6 to master, thanks!

Gregorg
Johannes Weißl
2011-02-21 15:50:04 UTC
Permalink
Post by Gregory Petrosyan
Merged all 6 to master, thanks!
Thanks! I have some more patches that ultimately enable compilation of
cmus with tcc, which is neat for development because the already fast
compilation of cmus becomes lightning fast!

Johannes
Johannes Weißl
2011-02-21 15:58:26 UTC
Permalink
Old syntax was most probably not correct, and worked only in gcc and
icc (did not compile with tcc at all).

http://stackoverflow.com/questions/5063548/initialization-of-anonymous-structures-or-unions-in-c1x
---
format_print.h | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/format_print.h b/format_print.h
index b2ec560..de35472 100644
--- a/format_print.h
+++ b/format_print.h
@@ -15,10 +15,19 @@ struct format_option {
char ch;
};

-#define DEF_FO_STR(ch) { { .fo_str = NULL }, 0, FO_STR, ch }
-#define DEF_FO_INT(ch) { { .fo_int = 0 }, 0, FO_INT, ch }
-#define DEF_FO_TIME(ch) { { .fo_time = 0 }, 0, FO_TIME, ch }
-#define DEF_FO_END { { .fo_str = NULL }, 0, 0, 0 }
+/* gcc < 4.6 and icc < 12.0 can't properly initialize anonymous unions */
+#if (defined(__GNUC__) && defined(__GNUC_MINOR__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6))) || \
+ (defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1200)
+#define DEF_FO_STR(c) { .type = FO_STR, .ch = c }
+#define DEF_FO_INT(c) { .type = FO_INT, .ch = c }
+#define DEF_FO_TIME(c) { .type = FO_TIME, .ch = c }
+#define DEF_FO_END { .type = 0, .ch = 0 }
+#else
+#define DEF_FO_STR(c) { .fo_str = NULL, .type = FO_STR, .ch = c }
+#define DEF_FO_INT(c) { .fo_int = 0 , .type = FO_INT, .ch = c }
+#define DEF_FO_TIME(c) { .fo_time = 0 , .type = FO_TIME, .ch = c }
+#define DEF_FO_END { .fo_str = NULL, .type = 0, .ch = 0 }
+#endif

int format_print(char *str, int width, const char *format, const struct format_option *fopts);
int format_valid(const char *format);
--
1.7.4.1
Johannes Weißl
2011-02-21 15:58:27 UTC
Permalink
glibc defines e.g. open as open64 (LFS for non-gcc compilers), which
breakes usage of "open" as struct member.

Fixes compile errors like:
input.c:488: field not found: open64

(Similar) bug report is here:
http://www.mail-archive.com/tinycc-***@nongnu.org/msg01339.html
---
ip.h | 5 +++++
mixer.h | 4 ++++
nomad.h | 4 ++++
op.h | 4 ++++
4 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/ip.h b/ip.h
index 5dd9b21..f44cf29 100644
--- a/ip.h
+++ b/ip.h
@@ -23,6 +23,11 @@
#include "comment.h"
#include "sf.h"

+#ifndef __GNUC__
+#include <fcntl.h>
+#include <unistd.h>
+#endif
+
enum {
/* no error */
IP_ERROR_SUCCESS,
diff --git a/mixer.h b/mixer.h
index e60e059..9ac2943 100644
--- a/mixer.h
+++ b/mixer.h
@@ -20,6 +20,10 @@
#ifndef _MIXER_H
#define _MIXER_H

+#ifndef __GNUC__
+#include <fcntl.h>
+#endif
+
#define NR_MIXER_FDS 4

struct mixer_plugin_ops {
diff --git a/nomad.h b/nomad.h
index 4425342..de1227b 100644
--- a/nomad.h
+++ b/nomad.h
@@ -23,6 +23,10 @@
#include <mad.h>
#include <sys/types.h>

+#ifndef __GNUC__
+#include <unistd.h>
+#endif
+
#define INPUT_BUFFER_SIZE (5 * 8192)

#define SEEK_IDX_INTERVAL 15
diff --git a/op.h b/op.h
index 5cca228..f7591ee 100644
--- a/op.h
+++ b/op.h
@@ -22,6 +22,10 @@

#include "sf.h"

+#ifndef __GNUC__
+#include <fcntl.h>
+#endif
+
enum {
/* no error */
OP_ERROR_SUCCESS,
--
1.7.4.1
Johannes Weißl
2011-02-21 15:58:28 UTC
Permalink
glibc defines readdir as readdir64, returning a struct dirent64 pointer
(LFS for non-gcc compilers). This fix silences a compiler warning.

Upstream bug report is here:
http://sources.redhat.com/ml/libc-alpha/2001-11/msg00093.html
---
input.c | 2 +-
load_dir.c | 2 +-
output.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/input.c b/input.c
index 3fdf612..f8358db 100644
--- a/input.c
+++ b/input.c
@@ -397,7 +397,7 @@ void ip_load_plugins(void)
error_msg("couldn't open directory `%s': %s", plugin_dir, strerror(errno));
return;
}
- while ((d = readdir(dir)) != NULL) {
+ while ((d = (struct dirent *) readdir(dir)) != NULL) {
char filename[256];
struct ip *ip;
void *so;
diff --git a/load_dir.c b/load_dir.c
index 57de105..a0c8b2f 100644
--- a/load_dir.c
+++ b/load_dir.c
@@ -51,7 +51,7 @@ const char *dir_read(struct directory *dir)
full++;
#endif

- while ((de = readdir(d))) {
+ while ((de = (struct dirent *) readdir(d))) {
const char *name = de->d_name;
int nlen = strlen(name);

diff --git a/output.c b/output.c
index 74a55e9..d1abc1d 100644
--- a/output.c
+++ b/output.c
@@ -87,7 +87,7 @@ void op_load_plugins(void)
error_msg("couldn't open directory `%s': %s", plugin_dir, strerror(errno));
return;
}
- while ((d = readdir(dir)) != NULL) {
+ while ((d = (struct dirent *) readdir(dir)) != NULL) {
char filename[256];
struct output_plugin *plug;
void *so, *symptr;
--
1.7.4.1
Johannes Weißl
2011-02-21 15:58:30 UTC
Permalink
---
history.c | 7 ++-----
http.c | 2 +-
input.c | 2 +-
mp4.c | 2 +-
4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/history.c b/history.c
index 9344513..6c9f3f7 100644
--- a/history.c
+++ b/history.c
@@ -35,11 +35,8 @@ struct history_entry {
static struct history_entry *history_entry_new(const char *text)
{
struct history_entry *new;
- int size = strlen(text) + 1;
-
- new = xmalloc(sizeof(struct history_entry));
- new->text = xmalloc(size);
- memcpy(new->text, text, size);
+ new = xnew(struct history_entry, 1);
+ new->text = xstrdup(text);
return new;
}

diff --git a/http.c b/http.c
index 92851c4..ad6efe8 100644
--- a/http.c
+++ b/http.c
@@ -143,7 +143,7 @@ int http_open(struct http_get *hg, int timeout_ms)

char *proxy = getenv("http_proxy");
if (proxy) {
- hg->proxy = xmalloc(sizeof(*hg->proxy));
+ hg->proxy = xnew(struct http_uri, 1);
if (http_parse_uri(proxy, hg->proxy)) {
d_print("Failed to parse HTTP proxy URI '%s'\n", proxy);
return -1;
diff --git a/input.c b/input.c
index f8358db..65f9d5e 100644
--- a/input.c
+++ b/input.c
@@ -264,7 +264,7 @@ static int setup_remote(struct input_plugin *ip, const struct keyval *headers, i
}

ip->data.fd = sock;
- ip->data.metadata = xmalloc(16 * 255 + 1);
+ ip->data.metadata = xnew(char, 16 * 255 + 1);

val = keyvals_get_val(headers, "icy-metaint");
if (val) {
diff --git a/mp4.c b/mp4.c
index dad5403..06043cd 100644
--- a/mp4.c
+++ b/mp4.c
@@ -361,7 +361,7 @@ static int mp4_read_comments(struct input_plugin_data *ip_data,
ustr += 16;
size -= 16;
}
- xstr = xmalloc(size + 1);
+ xstr = xnew(char, size + 1);
memcpy(xstr, ustr, size);
xstr[size] = 0;
comments_add(&c, "albumartist", xstr);
--
1.7.4.1
Johannes Weißl
2011-02-21 15:58:29 UTC
Permalink
(void *) can only store data pointers, but not function pointers.

Fixes this icc warning:
command_mode.c(1388): warning #144: a value of type "void *" cannot be used to initialize an entity of type "add_ti_cb"
---
command_mode.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/command_mode.c b/command_mode.c
index 159b768..0ab072c 100644
--- a/command_mode.c
+++ b/command_mode.c
@@ -1382,12 +1382,17 @@ static for_each_sel_ti_cb view_for_each_sel[4] = {
pq_for_each_sel
};

+/* wrapper for add_ti_cb, (void *) can't store function pointers */
+struct wrapper_cb_data {
+ add_ti_cb cb;
+};
+
/* wrapper for void lib_add_track(struct track_info *) etc. */
static int wrapper_cb(void *data, struct track_info *ti)
{
- add_ti_cb add = data;
+ struct wrapper_cb_data *add = data;

- add(ti);
+ add->cb(ti);
return 0;
}

@@ -1415,8 +1420,9 @@ static void cmd_win_add_l(char *arg)
return;

if (cur_view <= QUEUE_VIEW) {
+ struct wrapper_cb_data add = { lib_add_track };
editable_lock();
- view_for_each_sel[cur_view](wrapper_cb, lib_add_track, 0);
+ view_for_each_sel[cur_view](wrapper_cb, &add, 0);
editable_unlock();
} else if (cur_view == BROWSER_VIEW) {
add_from_browser(lib_add_track, JOB_TYPE_LIB);
@@ -1430,8 +1436,9 @@ static void cmd_win_add_p(char *arg)
return;

if (cur_view <= QUEUE_VIEW) {
+ struct wrapper_cb_data add = { pl_add_track };
editable_lock();
- view_for_each_sel[cur_view](wrapper_cb, pl_add_track, 0);
+ view_for_each_sel[cur_view](wrapper_cb, &add, 0);
editable_unlock();
} else if (cur_view == BROWSER_VIEW) {
add_from_browser(pl_add_track, JOB_TYPE_PL);
@@ -1444,8 +1451,9 @@ static void cmd_win_add_Q(char *arg)
return;

if (cur_view <= QUEUE_VIEW) {
+ struct wrapper_cb_data add = { play_queue_prepend };
editable_lock();
- view_for_each_sel[cur_view](wrapper_cb, play_queue_prepend, 1);
+ view_for_each_sel[cur_view](wrapper_cb, &add, 1);
editable_unlock();
} else if (cur_view == BROWSER_VIEW) {
add_from_browser(play_queue_prepend, JOB_TYPE_QUEUE);
@@ -1458,8 +1466,9 @@ static void cmd_win_add_q(char *arg)
return;

if (cur_view <= QUEUE_VIEW) {
+ struct wrapper_cb_data add = { play_queue_append };
editable_lock();
- view_for_each_sel[cur_view](wrapper_cb, play_queue_append, 0);
+ view_for_each_sel[cur_view](wrapper_cb, &add, 0);
editable_unlock();
} else if (cur_view == BROWSER_VIEW) {
add_from_browser(play_queue_append, JOB_TYPE_QUEUE);
--
1.7.4.1
Johannes Weißl
2011-02-21 15:58:32 UTC
Permalink
Zero-length arrays are GNU extensions. Since we use many C99 features we
can just use flexible array members:
http://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
---
browser.h | 2 +-
cache.c | 2 +-
expr.c | 2 +-
glob.c | 2 +-
keys.h | 2 +-
load_dir.h | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/browser.h b/browser.h
index 99fcbc5..9608f27 100644
--- a/browser.h
+++ b/browser.h
@@ -29,7 +29,7 @@ struct browser_entry {
struct list_head node;

enum { BROWSER_ENTRY_DIR, BROWSER_ENTRY_FILE, BROWSER_ENTRY_PLLINE } type;
- char name[0];
+ char name[];
};

static inline struct browser_entry *iter_to_browser_entry(struct iter *iter)
diff --git a/cache.c b/cache.c
index f999036..46752f5 100644
--- a/cache.c
+++ b/cache.c
@@ -32,7 +32,7 @@ struct cache_entry {
time_t mtime;

// filename and N * (key, val)
- char strings[0];
+ char strings[];
};

#define ALIGN(size) (((size) + sizeof(long) - 1) & ~(sizeof(long) - 1))
diff --git a/expr.c b/expr.c
index 4928631..8490494 100644
--- a/expr.c
+++ b/expr.c
@@ -53,7 +53,7 @@ struct token {
struct list_head node;
enum token_type type;
/* for TOK_KEY, TOK_INT_OR_KEY and TOK_STR */
- char str[0];
+ char str[];
};

/* same order as TOK_* */
diff --git a/glob.c b/glob.c
index f75a8a4..866075f 100644
--- a/glob.c
+++ b/glob.c
@@ -17,7 +17,7 @@ struct glob_item {
GLOB_QMARK,
GLOB_TEXT
} type;
- char text[0];
+ char text[];
};

/* simplification:
diff --git a/keys.h b/keys.h
index b7782dd..27f7c1f 100644
--- a/keys.h
+++ b/keys.h
@@ -45,7 +45,7 @@ struct binding {
struct binding *next;
const struct key *key;
enum key_context ctx;
- char cmd[0];
+ char cmd[];
};

extern const char * const key_context_names[NR_CTXS + 1];
diff --git a/load_dir.h b/load_dir.h
index 009e4c2..61d02b4 100644
--- a/load_dir.h
+++ b/load_dir.h
@@ -34,7 +34,7 @@ struct ptr_array {
/* ptr_array.ptrs is either char ** or struct dir_entry ** */
struct dir_entry {
mode_t mode;
- char name[0];
+ char name[];
};

#define PTR_ARRAY(name) struct ptr_array name = { NULL, 0, 0 }
--
1.7.4.1
Johannes Weißl
2011-02-21 15:58:31 UTC
Permalink
This is a GNU extension.
---
ui_curses.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ui_curses.c b/ui_curses.c
index a39e3a8..8412439 100644
--- a/ui_curses.c
+++ b/ui_curses.c
@@ -1453,7 +1453,7 @@ void search_not_found(void)
break;
}
}
- info_msg("%s not found: %s", what, search_str ? : "");
+ info_msg("%s not found: %s", what, search_str ? search_str : "");
}

void set_client_fd(int fd)
--
1.7.4.1
Johannes Weißl
2011-02-21 15:58:33 UTC
Permalink
<strings.h> for strcasecmp()
<sys/select.h> and <sys/time.h> for select()
---
ao.c | 1 +
ape.c | 1 +
cmus.c | 1 +
comment.c | 1 +
id3.c | 1 +
input.c | 3 +++
keyval.c | 2 +-
mixer_alsa.c | 2 ++
mixer_oss.c | 1 +
mp4.c | 1 +
options.c | 1 +
output.c | 1 +
tree.c | 1 +
13 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/ao.c b/ao.c
index 9e02f0c..af7fe19 100644
--- a/ao.c
+++ b/ao.c
@@ -27,6 +27,7 @@
* Also we use snprintf().
*/
#include <stdio.h>
+#include <strings.h>
#include <ao/ao.h>

static ao_device *libao_device;
diff --git a/ape.c b/ape.c
index 63c5758..f9eaed6 100644
--- a/ape.c
+++ b/ape.c
@@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <strings.h>

/* http://www.personal.uni-jena.de/~pfk/mpp/sv8/apetag.html */

diff --git a/cmus.c b/cmus.c
index c05719f..c925761 100644
--- a/cmus.c
+++ b/cmus.c
@@ -27,6 +27,7 @@
#include <dirent.h>
#include <stdlib.h>
#include <ctype.h>
+#include <strings.h>

/* save_playlist_cb, save_ext_playlist_cb */
typedef int (*save_tracks_cb)(void *data, struct track_info *ti);
diff --git a/comment.c b/comment.c
index 198976d..71139fb 100644
--- a/comment.c
+++ b/comment.c
@@ -8,6 +8,7 @@
#include "uchar.h"

#include <string.h>
+#include <strings.h>

int track_is_compilation(const struct keyval *comments)
{
diff --git a/id3.c b/id3.c
index dcb7d9a..c77d960 100644
--- a/id3.c
+++ b/id3.c
@@ -16,6 +16,7 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <strings.h>
#include <limits.h>

/*
diff --git a/input.c b/input.c
index 65f9d5e..dcff162 100644
--- a/input.c
+++ b/input.c
@@ -36,11 +36,14 @@
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
+#include <sys/select.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <dlfcn.h>
+#include <strings.h>

struct input_plugin {
const struct input_plugin_ops *ops;
diff --git a/keyval.c b/keyval.c
index c802f22..2d41bd6 100644
--- a/keyval.c
+++ b/keyval.c
@@ -2,7 +2,7 @@
#include "keyval.h"
#include "xmalloc.h"

-#include <string.h>
+#include <strings.h>

struct keyval *keyvals_dup(const struct keyval *keyvals)
{
diff --git a/mixer_alsa.c b/mixer_alsa.c
index 5d9b425..3f4727f 100644
--- a/mixer_alsa.c
+++ b/mixer_alsa.c
@@ -22,6 +22,8 @@
#include "xmalloc.h"
#include "debug.h"

+#include <strings.h>
+
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API

diff --git a/mixer_oss.c b/mixer_oss.c
index 79241b1..e4a87dc 100644
--- a/mixer_oss.c
+++ b/mixer_oss.c
@@ -23,6 +23,7 @@
#include "xmalloc.h"
#include "debug.h"

+#include <strings.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
diff --git a/mp4.c b/mp4.c
index 06043cd..4d1d0f5 100644
--- a/mp4.c
+++ b/mp4.c
@@ -35,6 +35,7 @@
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
+#include <strings.h>

struct mp4_private {
char *overflow_buf;
diff --git a/options.c b/options.c
index 43ab196..0febb78 100644
--- a/options.c
+++ b/options.c
@@ -26,6 +26,7 @@

#include <stdio.h>
#include <errno.h>
+#include <strings.h>

#if defined(__sun__)
#include <ncurses.h>
diff --git a/output.c b/output.c
index d1abc1d..5a4f269 100644
--- a/output.c
+++ b/output.c
@@ -30,6 +30,7 @@
#include "config/libdir.h"

#include <string.h>
+#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
diff --git a/tree.c b/tree.c
index 0871b5d..7ea5b26 100644
--- a/tree.c
+++ b/tree.c
@@ -15,6 +15,7 @@

#include <ctype.h>
#include <stdio.h>
+#include <strings.h>

struct searchable *tree_searchable;
struct window *lib_tree_win;
--
1.7.4.1
Gregory Petrosyan
2011-02-21 21:35:50 UTC
Permalink
Hm, I am trying to do

./configure CC=tcc
make

and this results in

LD cmus
tcc: undefined symbol 'memcmp'
tcc: undefined symbol 'strlen'
tcc: undefined symbol 'strcmp'
tcc: undefined symbol 'memcpy'
tcc: undefined symbol 'strncmp'
tcc: undefined symbol 'memmove'
tcc: undefined symbol 'memset'
tcc: undefined symbol 'strstr'

(This is on Ubuntu 10.04). Does it work for you? May this be related to
http://savannah.nongnu.org/bugs/?30457 ?

Gregory
Johannes Weißl
2011-02-21 23:43:38 UTC
Permalink
Post by Gregory Petrosyan
Hm, I am trying to do
./configure CC=tcc
make
and this results in
LD cmus
tcc: undefined symbol 'memcmp'
tcc: undefined symbol 'strlen'
tcc: undefined symbol 'strcmp'
tcc: undefined symbol 'memcpy'
tcc: undefined symbol 'strncmp'
tcc: undefined symbol 'memmove'
tcc: undefined symbol 'memset'
tcc: undefined symbol 'strstr'
(This is on Ubuntu 10.04). Does it work for you? May this be related to
http://savannah.nongnu.org/bugs/?30457 ?
Yes, it works for me... strange. I had this error once, but not anymore.
It compiles fine using the Debian package and the git version (mob
branch).

Johannes
Gregory Petrosyan
2011-02-22 18:39:26 UTC
Permalink
Post by Johannes Weißl
Post by Gregory Petrosyan
Hm, I am trying to do
./configure CC=tcc
make
and this results in
LD cmus
tcc: undefined symbol 'memcmp'
tcc: undefined symbol 'strlen'
tcc: undefined symbol 'strcmp'
tcc: undefined symbol 'memcpy'
tcc: undefined symbol 'strncmp'
tcc: undefined symbol 'memmove'
tcc: undefined symbol 'memset'
tcc: undefined symbol 'strstr'
(This is on Ubuntu 10.04). Does it work for you? May this be related to
http://savannah.nongnu.org/bugs/?30457 ?
Yes, it works for me... strange. I had this error once, but not anymore.
It compiles fine using the Debian package and the git version (mob
branch).
If you'll find a fix by accident — please submit! I've merged the patches to
master, since they look good.

Gregory
Johannes Weißl
2011-02-22 18:59:27 UTC
Permalink
Post by Gregory Petrosyan
Post by Johannes Weißl
Post by Gregory Petrosyan
Hm, I am trying to do
./configure CC=tcc
make
and this results in
LD cmus
tcc: undefined symbol 'memcmp'
tcc: undefined symbol 'strlen'
tcc: undefined symbol 'strcmp'
tcc: undefined symbol 'memcpy'
tcc: undefined symbol 'strncmp'
tcc: undefined symbol 'memmove'
tcc: undefined symbol 'memset'
tcc: undefined symbol 'strstr'
(This is on Ubuntu 10.04). Does it work for you? May this be related to
http://savannah.nongnu.org/bugs/?30457 ?
Yes, it works for me... strange. I had this error once, but not anymore.
It compiles fine using the Debian package and the git version (mob
branch).
If you'll find a fix by accident — please submit! I've merged the patches to
master, since they look good.
Thanks for merging! This could be the solution:
http://www.mail-archive.com/tinycc-***@nongnu.org/msg02855.html

The commit is in tcc's mob branch, but there is a backported version in
the latest Debian package (0.9.25-5). I think it is available in Ubuntu
"natty". Does it work with this version?


Johannes
Gregory Petrosyan
2011-02-23 18:05:40 UTC
Permalink
Post by Johannes Weißl
Post by Johannes Weißl
Post by Gregory Petrosyan
Hm, I am trying to do
./configure CC=tcc
make
and this results in
LD cmus
tcc: undefined symbol 'memcmp'
tcc: undefined symbol 'strlen'
tcc: undefined symbol 'strcmp'
tcc: undefined symbol 'memcpy'
tcc: undefined symbol 'strncmp'
tcc: undefined symbol 'memmove'
tcc: undefined symbol 'memset'
tcc: undefined symbol 'strstr'
(This is on Ubuntu 10.04). Does it work for you? May this be related to
http://savannah.nongnu.org/bugs/?30457 ?
Yes, it works for me... strange. I had this error once, but not anymore.
It compiles fine using the Debian package and the git version (mob
branch).
If you'll find a fix by accident — please submit! I've merged the patches to
master, since they look good.
The commit is in tcc's mob branch, but there is a backported version in
the latest Debian package (0.9.25-5). I think it is available in Ubuntu
"natty". Does it work with this version?
Yeah, it does — thanks!

Gregory
Loading...