Skip to content

Commit

Permalink
libsmartcols: make __attributes__ more portable
Browse files Browse the repository at this point in the history
Let's use what is already used for libmount. The header file is a public
header and does not require support for the __attribute__() compiler
feature. We need an additional #ifdef to ensure portability.

Signed-off-by: Karel Zak <kzak@redhat.com>
  • Loading branch information
karelzak committed Nov 5, 2024
1 parent 34a6ce0 commit 4508f7a
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions libsmartcols/src/libsmartcols.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,23 @@ enum {
SCOLS_CELL_FL_RIGHT = (1 << 1)
};


#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif

#ifndef __ul_attribute__
# if __GNUC_PREREQ (3, 4)
# define __ul_attribute__(_a_) __attribute__(_a_)
# else
# define __ul_attribute__(_a_)
# endif
#endif

extern struct libscols_iter *scols_new_iter(int direction);
extern void scols_free_iter(struct libscols_iter *itr);
extern void scols_reset_iter(struct libscols_iter *itr, int direction);
Expand Down Expand Up @@ -293,17 +310,17 @@ extern struct libscols_cell *scols_line_get_column_cell(
extern int scols_line_set_data(struct libscols_line *ln, size_t n, const char *data);
extern int scols_line_refer_data(struct libscols_line *ln, size_t n, char *data);
extern int scols_line_vprintf(struct libscols_line *ln, size_t n, const char *fmt, va_list ap)
__attribute__((format(printf, 3, 0)));
__ul_attribute__((format(printf, 3, 0)));
extern int scols_line_sprintf(struct libscols_line *ln, size_t n, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
__ul_attribute__((format(printf, 3, 4)));
extern int scols_line_is_filled(struct libscols_line *ln, size_t n);
extern int scols_line_set_column_data(struct libscols_line *ln, struct libscols_column *cl, const char *data);
extern const char *scols_line_get_column_data(struct libscols_line *ln, struct libscols_column *cl);
extern int scols_line_refer_column_data(struct libscols_line *ln, struct libscols_column *cl, char *data);
extern int scols_line_vprintf_column(struct libscols_line *ln, struct libscols_column *cl, const char *fmt, va_list ap)
__attribute__((format(printf, 3, 0)));
__ul_attribute__((format(printf, 3, 0)));
extern int scols_line_sprintf_column(struct libscols_line *ln, struct libscols_column *cl, const char *fmt, ...)
__attribute__((format(printf, 3, 4)));
__ul_attribute__((format(printf, 3, 4)));
extern struct libscols_line *scols_copy_line(const struct libscols_line *ln);

/* table */
Expand Down

0 comments on commit 4508f7a

Please sign in to comment.