Use #pragma once instead of #ifndef

Only the public header maintains #ifndef in the header, together with
pragma. The other ones contain only pragma.

As reported by Shawn Landden on systemd mailing list this is compatible
with all major compilers and gcc has this since version 3.3.
This commit is contained in:
Lucas De Marchi 2012-07-18 10:19:48 -03:00
parent 4e7f0f204b
commit e8fd8fec23
11 changed files with 11 additions and 41 deletions

View File

@ -1,5 +1,4 @@
#ifndef _LIBKMOD_ARRAY_H_
#define _LIBKMOD_ARRAY_H_
#pragma once
/*
* Declaration of struct array is in header because we may want to embed the
@ -19,5 +18,3 @@ void array_pop(struct array *array);
void array_free_array(struct array *array);
void array_sort(struct array *array, int (*cmp)(const void *a, const void *b));
int array_remove_at(struct array *array, unsigned int pos);
#endif

View File

@ -1,5 +1,4 @@
#ifndef _LIBKMOD_HASH_H_
#define _LIBKMOD_HASH_H_
#pragma once
#include <stdbool.h>
@ -21,5 +20,3 @@ unsigned int hash_get_count(const struct hash *hash);
void hash_iter_init(const struct hash *hash, struct hash_iter *iter);
bool hash_iter_next(struct hash_iter *iter, const char **key,
const void **value);
#endif

View File

@ -18,8 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _LIBKMOD_INDEX_H
#define _LIBKMOD_INDEX_H
#pragma once
#include <stdint.h>
@ -127,5 +126,3 @@ void index_mm_close(struct index_mm *index);
char *index_mm_search(struct index_mm *idx, const char *key);
struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key);
void index_mm_dump(struct index_mm *idx, int fd, const char *prefix);
#endif

View File

@ -1,5 +1,4 @@
#ifndef _LIBKMOD_PRIVATE_H_
#define _LIBKMOD_PRIVATE_H_
#pragma once
#include <stdbool.h>
#include <stdio.h>
@ -170,5 +169,3 @@ int kmod_elf_get_section(const struct kmod_elf *elf, const char *section, const
/* util functions */
#include "libkmod-util.h"
#endif

View File

@ -1,6 +1,4 @@
#ifndef _LIBKMOD_UTIL_H_
#define _LIBKMOD_UTIL_H_
#pragma once
#include "macro.h"
#include <limits.h>
@ -42,5 +40,3 @@ do { \
} *__p = (typeof(__p)) (ptr); \
__p->__v = (val); \
} while(0)
#endif

View File

@ -18,6 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#ifndef _LIBKMOD_H_
#define _LIBKMOD_H_

View File

@ -17,9 +17,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _LIBKMOD_MACRO_H_
#define _LIBKMOD_MACRO_H_
#pragma once
#include <stddef.h>
@ -82,5 +80,3 @@
#define _printf_format_(a,b) __attribute__((format (printf, a, b)))
#define _unused_ __attribute__((unused))
#define _always_inline_ __inline__ __attribute__((always_inline))
#endif

View File

@ -16,12 +16,9 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _LIBKMOD_TESTSUITE_MKDIR_
#define _LIBKMOD_TESTSUITE_MKDIR_
#pragma once
#include <sys/stat.h>
#include <sys/types.h>
int mkdir_p(const char *path, mode_t mode);
#endif

View File

@ -1,5 +1,4 @@
#ifndef _TESTSUITE_STRIPPED_MODULE_H
#define _TESTSUITE_STRIPPED_MODULE_H
#pragma once
enum module_state
{
@ -28,5 +27,3 @@ struct module
/* padding */
#define MODULE_NAME_OFFSET_64 4 + 4 + 2 * 8
#define MODULE_NAME_OFFSET_32 4 + 2 * 4
#endif

View File

@ -16,8 +16,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _LIBKMOD_TESTSUITE_
#define _LIBKMOD_TESTSUITE_
#pragma once
#include <stdbool.h>
#include <stdarg.h>
@ -144,6 +143,4 @@ int test_run(const struct test *t);
exit(EXIT_SUCCESS); \
} \
#endif
#define __noreturn __attribute__((noreturn))

View File

@ -17,8 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _KMOD_MACRO_H_
#define _KMOD_MACRO_H_
#pragma once
#include "macro.h"
@ -36,4 +35,3 @@ extern const struct kmod_cmd kmod_cmd_compat_modprobe;
extern const struct kmod_cmd kmod_cmd_compat_depmod;
extern const struct kmod_cmd kmod_cmd_list;
#endif