avoid namespace conflicts with __attribute__(…)

This commit is contained in:
tg 2011-04-09 21:01:03 +00:00
parent e39dea490f
commit 6c45e3e764
5 changed files with 46 additions and 46 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.476 2011/04/09 15:14:51 tg Exp $'
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.477 2011/04/09 21:00:58 tg Exp $'
#-
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
# Thorsten Glaser <tg@mirbsd.org>
@ -961,7 +961,7 @@ test $ct = pcc && phase=u
#
# Compiler: check for stuff that only generates warnings
#
ac_test attribute_bounded '' 'for __attribute__((bounded))' <<-'EOF'
ac_test attribute_bounded '' 'for __attribute__((__bounded__))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
@ -969,15 +969,15 @@ ac_test attribute_bounded '' 'for __attribute__((bounded))' <<-'EOF'
#include <string.h>
#undef __attribute__
int xcopy(const void *, void *, size_t)
__attribute__((bounded (buffer, 1, 3)))
__attribute__((bounded (buffer, 2, 3)));
__attribute__((__bounded__ (__buffer__, 1, 3)))
__attribute__((__bounded__ (__buffer__, 2, 3)));
int main(int ac, char *av[]) { return (xcopy(av[0], av[--ac], 1)); }
int xcopy(const void *s, void *d, size_t n) {
memmove(d, s, n); return ((int)n);
}
#endif
EOF
ac_test attribute_format '' 'for __attribute__((format))' <<-'EOF'
ac_test attribute_format '' 'for __attribute__((__format__))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
@ -987,51 +987,51 @@ ac_test attribute_format '' 'for __attribute__((format))' <<-'EOF'
#undef __attribute__
#undef fprintf
extern int fprintf(FILE *, const char *format, ...)
__attribute__((format (printf, 2, 3)));
__attribute__((__format__ (__printf__, 2, 3)));
int main(int ac, char **av) { return (fprintf(stderr, "%s%d", *av, ac)); }
#endif
EOF
ac_test attribute_nonnull '' 'for __attribute__((nonnull))' <<-'EOF'
ac_test attribute_nonnull '' 'for __attribute__((__nonnull__))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
int foo(char *s1, char *s2) __attribute__((nonnull));
int bar(char *s1, char *s2) __attribute__((nonnull (1, 2)));
int baz(char *s) __attribute__((nonnull (1)));
int foo(char *s1, char *s2) __attribute__((__nonnull__));
int bar(char *s1, char *s2) __attribute__((__nonnull__ (1, 2)));
int baz(char *s) __attribute__((__nonnull__ (1)));
int foo(char *s1, char *s2) { return (bar(s2, s1)); }
int bar(char *s1, char *s2) { return (baz(s1) - baz(s2)); }
int baz(char *s) { return (*s); }
int main(int ac, char **av) { return (ac == foo(av[0], av[ac-1])); }
#endif
EOF
ac_test attribute_noreturn '' 'for __attribute__((noreturn))' <<-'EOF'
ac_test attribute_noreturn '' 'for __attribute__((__noreturn__))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
#include <stdlib.h>
#undef __attribute__
void fnord(void) __attribute__((noreturn));
void fnord(void) __attribute__((__noreturn__));
int main(void) { fnord(); }
void fnord(void) { exit(0); }
#endif
EOF
ac_test attribute_unused '' 'for __attribute__((unused))' <<-'EOF'
ac_test attribute_unused '' 'for __attribute__((__unused__))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
int main(int ac __attribute__((unused)), char **av
__attribute__((unused))) { return (0); }
int main(int ac __attribute__((__unused__)), char **av
__attribute__((__unused__))) { return (0); }
#endif
EOF
ac_test attribute_used '' 'for __attribute__((used))' <<-'EOF'
ac_test attribute_used '' 'for __attribute__((__used__))' <<-'EOF'
#if defined(__GNUC__) && (__GNUC__ < 2)
/* force a failure: gcc 1.42 has a false positive here */
int main(void) { return (thiswillneverbedefinedIhope()); }
#else
static const char fnord[] __attribute__((used)) = "42";
static const char fnord[] __attribute__((__used__)) = "42";
int main(void) { return (0); }
#endif
EOF

4
edit.c
View File

@ -25,7 +25,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.207 2011/03/16 20:31:32 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.208 2011/04/09 21:01:00 tg Exp $");
/*
* in later versions we might use libtermcap for this, but since external
@ -908,7 +908,7 @@ static int x_match(char *, char *);
static void x_redraw(int);
static void x_push(int);
static char *x_mapin(const char *, Area *)
MKSH_A_NONNULL((nonnull (1)));
MKSH_A_NONNULL((__nonnull__ (1)));
static char *x_mapout(int);
static void x_mapout2(int, char **);
static void x_print(int, int);

View File

@ -38,7 +38,7 @@
#endif
#endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.184 2011/04/09 15:21:36 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.185 2011/04/09 21:01:01 tg Exp $");
#if HAVE_KILLPG
/*
@ -205,7 +205,7 @@ static void ptest_error(Test_env *, int, const char *);
static char *kill_fmt_entry(char *, int, int, const void *);
static void p_time(struct shf *, bool, long, int, int,
const char *, const char *)
MKSH_A_NONNULL((nonnull (6, 7)));
MKSH_A_NONNULL((__nonnull__ (6, 7)));
int
c_pwd(const char **wp)

4
main.c
View File

@ -33,7 +33,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.188 2011/04/02 13:55:35 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.189 2011/04/09 21:01:02 tg Exp $");
extern char **environ;
@ -1009,7 +1009,7 @@ tty_close(void)
#define VWARNINGF_BUILTIN 4
#define VWARNINGF_INTERNAL 8
static void MKSH_A_FORMAT(printf, 2, 0)
static void MKSH_A_FORMAT(__printf__, 2, 0)
vwarningf(unsigned int flags, const char *fmt, va_list ap)
{
if (*fmt != 1) {

46
sh.h
View File

@ -90,12 +90,12 @@
#undef __attribute__
#if HAVE_ATTRIBUTE_BOUNDED
#define MKSH_A_BOUNDED(x,y,z) __attribute__((bounded (x, y, z)))
#define MKSH_A_BOUNDED(x,y,z) __attribute__((__bounded__ (x, y, z)))
#else
#define MKSH_A_BOUNDED(x,y,z) /* nothing */
#endif
#if HAVE_ATTRIBUTE_FORMAT
#define MKSH_A_FORMAT(x,y,z) __attribute__((format (x, y, z)))
#define MKSH_A_FORMAT(x,y,z) __attribute__((__format__ (x, y, z)))
#else
#define MKSH_A_FORMAT(x,y,z) /* nothing */
#endif
@ -105,17 +105,17 @@
#define MKSH_A_NONNULL(a) /* nothing */
#endif
#if HAVE_ATTRIBUTE_NORETURN
#define MKSH_A_NORETURN __attribute__((noreturn))
#define MKSH_A_NORETURN __attribute__((__noreturn__))
#else
#define MKSH_A_NORETURN /* nothing */
#endif
#if HAVE_ATTRIBUTE_UNUSED
#define MKSH_A_UNUSED __attribute__((unused))
#define MKSH_A_UNUSED __attribute__((__unused__))
#else
#define MKSH_A_UNUSED /* nothing */
#endif
#if HAVE_ATTRIBUTE_USED
#define MKSH_A_USED __attribute__((used))
#define MKSH_A_USED __attribute__((__used__))
#else
#define MKSH_A_USED /* nothing */
#endif
@ -151,7 +151,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.461 2011/04/09 18:47:14 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.462 2011/04/09 21:01:03 tg Exp $");
#endif
#define MKSH_VERSION "R39 2011/04/09"
@ -1623,7 +1623,7 @@ int j_stopped_running(void);
int yylex(int);
void yyerror(const char *, ...)
MKSH_A_NORETURN
MKSH_A_FORMAT(printf, 1, 2);
MKSH_A_FORMAT(__printf__, 1, 2);
Source *pushs(int, Area *);
void set_prompt(int, Source *);
void pprompt(const char *, int);
@ -1639,27 +1639,27 @@ void cleanup_parents_env(void);
void cleanup_proc_env(void);
void errorf(const char *, ...)
MKSH_A_NORETURN
MKSH_A_FORMAT(printf, 1, 2);
MKSH_A_FORMAT(__printf__, 1, 2);
void errorfx(int, const char *, ...)
MKSH_A_NORETURN
MKSH_A_FORMAT(printf, 2, 3);
MKSH_A_FORMAT(__printf__, 2, 3);
void warningf(bool, const char *, ...)
MKSH_A_FORMAT(printf, 2, 3);
MKSH_A_FORMAT(__printf__, 2, 3);
void bi_errorf(const char *, ...)
MKSH_A_FORMAT(printf, 1, 2);
MKSH_A_FORMAT(__printf__, 1, 2);
#define errorfz() errorf("\1")
#define errorfxz(rc) errorfx((rc), "\1")
#define bi_errorfz() bi_errorf("\1")
void internal_errorf(const char *, ...)
MKSH_A_NORETURN
MKSH_A_FORMAT(printf, 1, 2);
MKSH_A_FORMAT(__printf__, 1, 2);
void internal_warningf(const char *, ...)
MKSH_A_FORMAT(printf, 1, 2);
MKSH_A_FORMAT(__printf__, 1, 2);
void error_prefix(bool);
void shellf(const char *, ...)
MKSH_A_FORMAT(printf, 1, 2);
MKSH_A_FORMAT(__printf__, 1, 2);
void shprintf(const char *, ...)
MKSH_A_FORMAT(printf, 1, 2);
MKSH_A_FORMAT(__printf__, 1, 2);
int can_seek(int);
void initio(void);
int ksh_dup2(int, int, bool);
@ -1703,7 +1703,7 @@ void print_columns(struct shf *, int,
const void *, int, int, bool);
void strip_nuls(char *, int);
ssize_t blocking_read(int, char *, size_t)
MKSH_A_BOUNDED(buffer, 2, 3);
MKSH_A_BOUNDED(__buffer__, 2, 3);
int reset_nonblock(int);
char *ksh_get_wd(void);
char *do_realpath(const char *);
@ -1732,14 +1732,14 @@ int shf_putchar(int, struct shf *);
int shf_puts(const char *, struct shf *);
int shf_write(const char *, int, struct shf *);
int shf_fprintf(struct shf *, const char *, ...)
MKSH_A_FORMAT(printf, 2, 3);
MKSH_A_FORMAT(__printf__, 2, 3);
int shf_snprintf(char *, int, const char *, ...)
MKSH_A_FORMAT(printf, 3, 4)
MKSH_A_BOUNDED(string, 1, 2);
MKSH_A_FORMAT(__printf__, 3, 4)
MKSH_A_BOUNDED(__string__, 1, 2);
char *shf_smprintf(const char *, ...)
MKSH_A_FORMAT(printf, 1, 2);
MKSH_A_FORMAT(__printf__, 1, 2);
int shf_vfprintf(struct shf *, const char *, va_list)
MKSH_A_FORMAT(printf, 2, 0);
MKSH_A_FORMAT(__printf__, 2, 0);
/* syn.c */
void initkeywords(void);
struct op *compile(Source *, bool);
@ -1757,7 +1757,7 @@ void dumpchar(struct shf *, int);
void dumptree(struct shf *, struct op *);
void dumpwdvar(struct shf *, const char *);
void vistree(char *, size_t, struct op *)
MKSH_A_BOUNDED(string, 1, 2);
MKSH_A_BOUNDED(__string__, 1, 2);
void fpFUNCTf(struct shf *, int, bool, const char *, struct op *);
/* var.c */
void newblock(void);
@ -1770,7 +1770,7 @@ int setstr(struct tbl *, const char *, int);
struct tbl *setint_v(struct tbl *, struct tbl *, bool);
void setint(struct tbl *, mksh_ari_t);
struct tbl *typeset(const char *, Tflag, Tflag, int, int)
MKSH_A_NONNULL((nonnull (1)));
MKSH_A_NONNULL((__nonnull__ (1)));
void unset(struct tbl *, int);
const char *skip_varname(const char *, int);
const char *skip_wdvarname(const char *, int);