aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-10-05 12:04:45 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-10-05 12:04:45 -0700
commit57c0820992c7b735c7d6283e451b6dac49bf8b05 (patch)
tree61d6b0e9c3a906af0eea3ba520e3f44aee93efed
parent44f2fb5fcc3701c8f36e25ddb2a9e88f47aef8ed (diff)
downloadklibc-57c0820992c7b735c7d6283e451b6dac49bf8b05.tar.gz
[klibc] Macros to handle inlines when compiling in c99 mode
Use some macros to tell gcc that we're using gnu89-style inlines even if the compiler is in c99/gnu99 mode. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--usr/include/ctype.h2
-rw-r--r--usr/include/klibc/compiler.h34
-rw-r--r--usr/include/stdio.h17
3 files changed, 38 insertions, 15 deletions
diff --git a/usr/include/ctype.h b/usr/include/ctype.h
index dfe1c46504359..4fd162bbc001c 100644
--- a/usr/include/ctype.h
+++ b/usr/include/ctype.h
@@ -133,7 +133,7 @@ __must_inline int __ctype_tolower(int __c)
__extern int X(int);
#else
#define __CTYPEFUNC(X) \
- __extern inline int X(int __c) \
+ __extern_inline int X(int __c) \
{ \
return __ctype_##X(__c); \
}
diff --git a/usr/include/klibc/compiler.h b/usr/include/klibc/compiler.h
index 9dee7427cd5c8..08e330f8a88af 100644
--- a/usr/include/klibc/compiler.h
+++ b/usr/include/klibc/compiler.h
@@ -20,16 +20,38 @@
# define __cdecl /* Meaningless on non-i386 */
#endif
+/*
+ * How to declare a function which should be inlined or instantiated locally
+ */
+#ifdef __GNUC__
+# ifdef __GNUC_STDC_INLINE__
+# define __static_inline static __inline__ __attribute__((__gnu_inline__))
+# else
+# define __static_inline static __inline__
+# endif
+#else
+# define __extern_inline inline /* Just hope this works... */
+#endif
+
+/*
+ * How to declare a function which should be inlined or have a call to
+ * an external module
+ */
+#ifdef __GNUC__
+# ifdef __GNUC_STDC_INLINE__
+# define __extern_inline extern __inline__ __attribute__((__gnu_inline__))
+# else
+# define __extern_inline extern __inline__
+# endif
+#else
+# define __extern_inline inline /* Just hope this works... */
+#endif
+
/* How to declare a function that *must* be inlined */
/* Use "extern inline" even in the gcc3+ case to avoid warnings in ctype.h */
#ifdef __GNUC__
# if __GNUC__ >= 3
-# ifdef __GNUC_STDC_INLINE__
-# define __must_inline extern __inline__ \
- __attribute__((__gnu_inline__,__always_inline__))
-# else
-# define __must_inline extern __inline__ __attribute__((__always_inline__))
-# endif
+# define __must_inline __extern_inline __attribute__((__always_inline__))
# else
# define __must_inline extern __inline__
# endif
diff --git a/usr/include/stdio.h b/usr/include/stdio.h
index 7d2c86d7db444..2db63beebdb34 100644
--- a/usr/include/stdio.h
+++ b/usr/include/stdio.h
@@ -49,22 +49,22 @@ static __inline__ int fileno(FILE * __f)
__extern FILE *fopen(const char *, const char *);
-static __inline__ FILE *fdopen(int __fd, const char *__m)
+__static_inline FILE *fdopen(int __fd, const char *__m)
{
(void)__m;
return __create_file(__fd);
}
-static __inline__ int fclose(FILE * __f)
+__static_inline int fclose(FILE * __f)
{
extern int close(int);
return close(fileno(__f));
}
-static __inline__ int fseek(FILE * __f, off_t __o, int __w)
+__static_inline int fseek(FILE * __f, off_t __o, int __w)
{
extern off_t lseek(int, off_t, int);
return (lseek(fileno(__f), __o, __w) == (off_t) - 1) ? -1 : 0;
}
-static __inline__ off_t ftell(FILE * __f)
+__static_inline off_t ftell(FILE * __f)
{
extern off_t lseek(int, off_t, int);
return lseek(fileno(__f), 0, SEEK_CUR);
@@ -85,12 +85,13 @@ __extern size_t _fread(void *, size_t, FILE *);
__extern size_t _fwrite(const void *, size_t, FILE *);
#ifndef __NO_FREAD_FWRITE_INLINES
-extern __inline__ size_t fread(void *__p, size_t __s, size_t __n, FILE * __f)
+__extern_inline size_t
+fread(void *__p, size_t __s, size_t __n, FILE * __f)
{
return _fread(__p, __s * __n, __f) / __s;
}
-extern __inline__ size_t
+__extern_inline size_t
fwrite(const void *__p, size_t __s, size_t __n, FILE * __f)
{
return _fwrite(__p, __s * __n, __f) / __s;
@@ -109,14 +110,14 @@ __extern int asprintf(char **, const char *, ...);
__extern int vasprintf(char **, const char *, va_list);
/* No buffering, so no flushing needed */
-static __inline__ int fflush(FILE * __f)
+__static_inline int fflush(FILE * __f)
{
(void)__f;
return 0;
}
/* stream errors are not kept track of by klibc implementation */
-static __inline__ int ferror(FILE * __f)
+__static_inline int ferror(FILE * __f)
{
(void)__f;
return 0;