]> Savannah Git Hosting - gnulib.git/commitdiff
selinux-h: better 'inline'
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 21 Nov 2012 06:25:06 +0000 (22:25 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Nov 2012 07:38:51 +0000 (23:38 -0800)
* 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
lib/getfilecon.c
lib/se-context.c [new file with mode: 0644]
lib/se-context.in.h
lib/se-selinux.c [new file with mode: 0644]
lib/se-selinux.in.h
modules/selinux-h

index fc80def13557af2edd08b972a0117cba9f5a0c37..5ca3bb3d359c73f8d001547d7e7f6067df872314 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2012-11-29  Paul Eggert  <eggert@cs.ucla.edu>
 
+       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):
index bc8288f561d3958b37755c3278e8f4c84720af98..f9c3f5896bb45c368d6454d0c0fc584aaae4011d 100644 (file)
@@ -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 (file)
index 0000000..2e5aa13
--- /dev/null
@@ -0,0 +1,3 @@
+#include <config.h>
+#define SE_CONTEXT_INLINE _GL_EXTERN_INLINE
+#include <selinux/context.h>
index cb7419a5686e2a8292ac5a3bd8ece6294fbad04d..a692f5a0604da7cf9b78efd0ef8239e4cb08365d 100644 (file)
@@ -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 (file)
index 0000000..ee4e57f
--- /dev/null
@@ -0,0 +1,3 @@
+#include <config.h>
+#define SE_SELINUX_INLINE _GL_EXTERN_INLINE
+#include <selinux/selinux.h>
index 9e8d8d2126c42806e211a3f12d794721b9d42baf..78d7d141c1bb6322d80127dbda29d09859bba2bb 100644 (file)
 #  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 /* _@GUARD_PREFIX@_SELINUX_SELINUX_H */
index 2064eb939bbbc733c9fec2dc547ae96fb6cbed73..e074e673f341bd3852c283d12dce4f911fc459d6 100644 (file)
@@ -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)