bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 06/11] selinux-h: better 'inline'


From: Paul Eggert
Subject: [PATCH 06/11] selinux-h: better 'inline'
Date: Mon, 29 Oct 2012 00:16:43 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1

* lib/se-context.c, lib/se-selinux.c: New files.
* lib/getfilecon.c (map_to_failure): Omit 'inline' for static function.
* lib/se-context.in.h (SE_CONTEXT_INLINE):
New macro.  Replace all uses of 'static inline' with it.
Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
* lib/se-selinux.in.h (SE_SELINUX_INLINE):
New macro.  Replace all uses of 'static inline' with it.
Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
* modules/selinux-h (Files, lib_SOURCES):
Add lib/se-context.c, lib/se-selinux.c.
(Depends-on): Add extern-inline.
(configure.ac): Do not require AC_C_INLINE.
---
 ChangeLog           | 14 +++++++++
 lib/getfilecon.c    |  2 +-
 lib/se-context.c    |  3 ++
 lib/se-context.in.h | 29 ++++++++++++-------
 lib/se-selinux.c    |  3 ++
 lib/se-selinux.in.h | 83 ++++++++++++++++++++++++++++++++---------------------
 modules/selinux-h   |  6 ++--
 7 files changed, 93 insertions(+), 47 deletions(-)
 create mode 100644 lib/se-context.c
 create mode 100644 lib/se-selinux.c

diff --git a/ChangeLog b/ChangeLog
index 86893db..5af7e53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2012-10-28  Paul Eggert  <address@hidden>
 
+       selinux-h: better 'inline'
+       * lib/se-context.c, lib/se-selinux.c: New files.
+       * lib/getfilecon.c (map_to_failure): Omit 'inline' for static function.
+       * lib/se-context.in.h (SE_CONTEXT_INLINE):
+       New macro.  Replace all uses of 'static inline' with it.
+       Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
+       * lib/se-selinux.in.h (SE_SELINUX_INLINE):
+       New macro.  Replace all uses of 'static inline' with it.
+       Use _GL_INLINE_HEADER_BEGIN, _GL_INLINE_HEADER_END.
+       * modules/selinux-h (Files, lib_SOURCES):
+       Add lib/se-context.c, lib/se-selinux.c.
+       (Depends-on): Add extern-inline.
+       (configure.ac): Do not require AC_C_INLINE.
+
        pthread: better 'inline'
        * lib/pthread.c: New file.
        * lib/pthread.in.h (_GL_PTHREAD_INLINE):
diff --git a/lib/getfilecon.c b/lib/getfilecon.c
index bc8288f..f9c3f58 100644
--- a/lib/getfilecon.c
+++ b/lib/getfilecon.c
@@ -45,7 +45,7 @@ int fgetfilecon (int fd, security_context_t *con);
    "unlabeled" context.  Map both failures to a return value of -1, and
    set errno to ENOTSUP in the first case, and ENODATA in the latter.  */
 
-static inline int
+static int
 map_to_failure (int ret, security_context_t *con)
 {
   if (ret == 0)
diff --git a/lib/se-context.c b/lib/se-context.c
new file mode 100644
index 0000000..2e5aa13
--- /dev/null
+++ b/lib/se-context.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define SE_CONTEXT_INLINE _GL_EXTERN_INLINE
+#include <selinux/context.h>
diff --git a/lib/se-context.in.h b/lib/se-context.in.h
index cb7419a..a692f5a 100644
--- a/lib/se-context.in.h
+++ b/lib/se-context.in.h
@@ -3,26 +3,33 @@
 
 # include <errno.h>
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef SE_CONTEXT_INLINE
+# define SE_CONTEXT_INLINE _GL_INLINE
+#endif
+
 /* The definition of _GL_UNUSED_PARAMETER is copied here.  */
 
 typedef int context_t;
-static inline context_t context_new (char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE context_t context_new (char const *s _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return 0; }
-static inline char *context_str (context_t con _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE char *context_str (context_t con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return (void *) 0; }
-static inline void context_free (context_t c _GL_UNUSED_PARAMETER) {}
+SE_CONTEXT_INLINE void context_free (context_t c _GL_UNUSED_PARAMETER) {}
 
-static inline int context_user_set (context_t sc _GL_UNUSED_PARAMETER,
-                                    char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE int context_user_set (context_t sc _GL_UNUSED_PARAMETER,
+                                        char const *s _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int context_role_set (context_t sc _GL_UNUSED_PARAMETER,
-                                    char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE int context_role_set (context_t sc _GL_UNUSED_PARAMETER,
+                                        char const *s _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int context_range_set (context_t sc _GL_UNUSED_PARAMETER,
-                                     char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE int context_range_set (context_t sc _GL_UNUSED_PARAMETER,
+                                         char const *s _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int context_type_set (context_t sc _GL_UNUSED_PARAMETER,
-                                    char const *s _GL_UNUSED_PARAMETER)
+SE_CONTEXT_INLINE int context_type_set (context_t sc _GL_UNUSED_PARAMETER,
+                                        char const *s _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
 
+_GL_INLINE_HEADER_END
+
 #endif
diff --git a/lib/se-selinux.c b/lib/se-selinux.c
new file mode 100644
index 0000000..ee4e57f
--- /dev/null
+++ b/lib/se-selinux.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define SE_SELINUX_INLINE _GL_EXTERN_INLINE
+#include <selinux/selinux.h>
diff --git a/lib/se-selinux.in.h b/lib/se-selinux.in.h
index 9e8d8d2..78d7d14 100644
--- a/lib/se-selinux.in.h
+++ b/lib/se-selinux.in.h
@@ -31,6 +31,11 @@
 #  include <sys/types.h>
 #  include <errno.h>
 
+_GL_INLINE_HEADER_BEGIN
+#  ifndef SE_SELINUX_INLINE
+#   define SE_SELINUX_INLINE _GL_INLINE
+#  endif
+
 /* The definition of _GL_UNUSED_PARAMETER is copied here.  */
 
 #  if !GNULIB_defined_security_types
@@ -39,59 +44,71 @@ typedef unsigned short security_class_t;
 #   define security_context_t char*
 #   define is_selinux_enabled() 0
 
-static inline int getcon (security_context_t *con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+getcon (security_context_t *con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline void freecon (security_context_t con _GL_UNUSED_PARAMETER) {}
+SE_SELINUX_INLINE void
+freecon (security_context_t con _GL_UNUSED_PARAMETER) {}
 
-
-static inline int getfscreatecon (security_context_t *con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+getfscreatecon (security_context_t *con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int setfscreatecon (security_context_t con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+setfscreatecon (security_context_t con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int matchpathcon (char const *file _GL_UNUSED_PARAMETER,
-                                mode_t m _GL_UNUSED_PARAMETER,
-                                security_context_t *con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+matchpathcon (char const *file _GL_UNUSED_PARAMETER,
+              mode_t m _GL_UNUSED_PARAMETER,
+  security_context_t *con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int getfilecon (char const *file _GL_UNUSED_PARAMETER,
-                              security_context_t *con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+getfilecon (char const *file _GL_UNUSED_PARAMETER,
+            security_context_t *con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int lgetfilecon (char const *file _GL_UNUSED_PARAMETER,
-                               security_context_t *con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+lgetfilecon (char const *file _GL_UNUSED_PARAMETER,
+             security_context_t *con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int fgetfilecon (int fd,
-                               security_context_t *con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+fgetfilecon (int fd, security_context_t *con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int setfilecon (char const *file _GL_UNUSED_PARAMETER,
-                              security_context_t con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+setfilecon (char const *file _GL_UNUSED_PARAMETER,
+            security_context_t con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int lsetfilecon (char const *file _GL_UNUSED_PARAMETER,
-                               security_context_t con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+lsetfilecon (char const *file _GL_UNUSED_PARAMETER,
+             security_context_t con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int fsetfilecon (int fd _GL_UNUSED_PARAMETER,
-                               security_context_t con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+fsetfilecon (int fd _GL_UNUSED_PARAMETER,
+             security_context_t con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
 
-static inline int security_check_context
-    (security_context_t con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+security_check_context (security_context_t con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int security_check_context_raw
-    (security_context_t con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+security_check_context_raw (security_context_t con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int setexeccon (security_context_t con _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+setexeccon (security_context_t con _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int security_compute_create
-    (security_context_t scon _GL_UNUSED_PARAMETER,
-     security_context_t tcon _GL_UNUSED_PARAMETER,
-     security_class_t tclass _GL_UNUSED_PARAMETER,
-     security_context_t *newcon _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+security_compute_create (security_context_t scon _GL_UNUSED_PARAMETER,
+                         security_context_t tcon _GL_UNUSED_PARAMETER,
+                         security_class_t tclass _GL_UNUSED_PARAMETER,
+                         security_context_t *newcon _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
-static inline int matchpathcon_init_prefix
-    (char const *path _GL_UNUSED_PARAMETER,
-     char const *prefix _GL_UNUSED_PARAMETER)
+SE_SELINUX_INLINE int
+matchpathcon_init_prefix (char const *path _GL_UNUSED_PARAMETER,
+                          char const *prefix _GL_UNUSED_PARAMETER)
   { errno = ENOTSUP; return -1; }
 
 #   define GNULIB_defined_security_types 1
 #  endif
 
+_GL_INLINE_HEADER_BEGIN
+
 # endif
 #endif /* address@hidden@_SELINUX_SELINUX_H */
diff --git a/modules/selinux-h b/modules/selinux-h
index 2064eb9..e074e67 100644
--- a/modules/selinux-h
+++ b/modules/selinux-h
@@ -5,23 +5,25 @@ Files:
 lib/getfilecon.c
 lib/se-context.in.h
 lib/se-selinux.in.h
+lib/se-context.c
+lib/se-selinux.c
 m4/selinux-context-h.m4
 m4/selinux-selinux-h.m4
 
 Depends-on:
 errno
+extern-inline
 snippet/unused-parameter
 
 configure.ac:
 gl_HEADERS_SELINUX_SELINUX_H
 gl_HEADERS_SELINUX_CONTEXT_H
-AC_REQUIRE([AC_C_INLINE])
 if test "$with_selinux" != no && test "$ac_cv_header_selinux_selinux_h" = yes; 
then
   AC_LIBOBJ([getfilecon])
 fi
 
 Makefile.am:
-lib_SOURCES += se-context.in.h se-selinux.in.h
+lib_SOURCES += se-context.in.h se-selinux.in.h se-context.c se-selinux.c
 
 BUILT_SOURCES += selinux/selinux.h
 selinux/selinux.h: se-selinux.in.h $(top_builddir)/config.status 
$(UNUSED_PARAMETER_H)
-- 
1.7.11.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]