From 0470c81c6861ed3dca39051588805bde4bec0c31 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 30 Mar 2013 12:02:13 +0000 Subject: [PATCH] Make all public libsolv headers C++ safe A few headers already included 'export "C"' blocks, also wrapping other #include's. This patch cleanly wraps the contents of all public headers instead. --- src/bitmap.h | 8 ++++++++ src/chksum.h | 8 ++++++++ src/dataiterator.h | 8 ++++++++ src/dirpool.h | 8 ++++++++ src/hash.h | 8 ++++++++ src/policy.h | 7 +++++++ src/pool.h | 8 ++++---- src/poolarch.h | 8 ++++++++ src/poolid.h | 8 ++++++++ src/poolvendor.h | 8 ++++++++ src/queue.h | 8 ++++++++ src/repo.h | 8 +++++++- src/repo_solv.h | 8 ++++---- src/repo_write.h | 8 ++++++++ src/repodata.h | 8 ++++++++ src/repopage.h | 8 ++++++++ src/selection.h | 8 ++++++++ src/solvable.h | 8 ++++++++ src/solver.h | 7 +++---- src/solverdebug.h | 7 +++++++ src/strpool.h | 8 ++++++++ src/transaction.h | 8 ++++---- src/util.h | 9 +++++++++ 23 files changed, 165 insertions(+), 17 deletions(-) diff --git a/src/bitmap.h b/src/bitmap.h index c6993caa..5784e6c0 100644 --- a/src/bitmap.h +++ b/src/bitmap.h @@ -15,6 +15,10 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct _Map { unsigned char *map; int size; @@ -59,4 +63,8 @@ static inline int map_tst(Map *m, int n) return MAPTST(m, n); } +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_BITMAP_H */ diff --git a/src/chksum.h b/src/chksum.h index 0239844b..7272c783 100644 --- a/src/chksum.h +++ b/src/chksum.h @@ -10,6 +10,10 @@ #include "pool.h" +#ifdef __cplusplus +extern "C" { +#endif + void *solv_chksum_create(Id type); void *solv_chksum_create_from_bin(Id type, const unsigned char *buf); void solv_chksum_add(void *handle, const void *data, int len); @@ -21,4 +25,8 @@ const char *solv_chksum_type2str(Id type); Id solv_chksum_str2type(const char *str); int solv_chksum_len(Id type); +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_CHKSUM_H */ diff --git a/src/dataiterator.h b/src/dataiterator.h index a77d902f..df103495 100644 --- a/src/dataiterator.h +++ b/src/dataiterator.h @@ -16,6 +16,10 @@ #include "pooltypes.h" #include "pool.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _Repo; typedef struct _KeyValue { @@ -182,4 +186,8 @@ void dataiterator_strdup(Dataiterator *di); #define DI_SEEK_PARENT 2 #define DI_SEEK_REWIND 3 +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_DATAITERATOR_H */ diff --git a/src/dirpool.h b/src/dirpool.h index 29ed109f..fe05cc65 100644 --- a/src/dirpool.h +++ b/src/dirpool.h @@ -11,6 +11,10 @@ #include "pooltypes.h" #include "util.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct _Dirpool { Id *dirs; int ndirs; @@ -74,4 +78,8 @@ dirpool_compid(Dirpool *dp, Id did) return dp->dirs[did]; } +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_DIRPOOL_H */ diff --git a/src/hash.h b/src/hash.h index a606ca0c..b3cfbde4 100644 --- a/src/hash.h +++ b/src/hash.h @@ -15,6 +15,10 @@ #include "pooltypes.h" +#ifdef __cplusplus +extern "C" { +#endif + /* value of a hash */ typedef unsigned int Hashval; /* mask for hash, used as modulo operator to ensure 'wrapping' of hash @@ -85,4 +89,8 @@ mkmask(unsigned int num) return num * 2 - 1; } +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_HASH_H */ diff --git a/src/policy.h b/src/policy.h index 8f81ca3d..01cfcc19 100644 --- a/src/policy.h +++ b/src/policy.h @@ -12,6 +12,10 @@ #include "solver.h" +#ifdef __cplusplus +extern "C" { +#endif + #define POLICY_MODE_CHOOSE 0 #define POLICY_MODE_RECOMMEND 1 #define POLICY_MODE_SUGGEST 2 @@ -30,3 +34,6 @@ extern void policy_findupdatepackages(Solver *solv, Solvable *s, Queue *qs, int extern void policy_create_obsolete_index(Solver *solv); +#ifdef __cplusplus +} +#endif diff --git a/src/pool.h b/src/pool.h index 8f100b2d..77808bd3 100644 --- a/src/pool.h +++ b/src/pool.h @@ -13,10 +13,6 @@ #ifndef LIBSOLV_POOL_H #define LIBSOLV_POOL_H -#ifdef __cplusplus -extern "C" { -#endif - #include #include "solvversion.h" @@ -30,6 +26,10 @@ extern "C" { /* well known ids */ #include "knownid.h" +#ifdef __cplusplus +extern "C" { +#endif + /* well known solvable */ #define SYSTEMSOLVABLE 1 diff --git a/src/poolarch.h b/src/poolarch.h index 9f5829d6..3fe5f022 100644 --- a/src/poolarch.h +++ b/src/poolarch.h @@ -10,6 +10,10 @@ #include "pool.h" +#ifdef __cplusplus +extern "C" { +#endif + extern void pool_setarch(Pool *, const char *); extern void pool_setarchpolicy(Pool *, const char *); extern unsigned char pool_arch2color_slow(Pool *pool, Id arch); @@ -36,4 +40,8 @@ static inline int pool_colormatch(Pool *pool, Solvable *s1, Solvable *s2) return 0; } +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_POOLARCH_H */ diff --git a/src/poolid.h b/src/poolid.h index f5ea82ec..a232290f 100644 --- a/src/poolid.h +++ b/src/poolid.h @@ -16,6 +16,10 @@ #include "pooltypes.h" #include "hash.h" +#ifdef __cplusplus +extern "C" { +#endif + /*----------------------------------------------- * Ids with relation */ @@ -38,4 +42,8 @@ extern void pool_shrink_strings(Pool *pool); extern void pool_shrink_rels(Pool *pool); extern void pool_freeidhashes(Pool *pool); +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_POOLID_H */ diff --git a/src/poolvendor.h b/src/poolvendor.h index 2e14450d..873e0904 100644 --- a/src/poolvendor.h +++ b/src/poolvendor.h @@ -10,8 +10,16 @@ #include "pool.h" +#ifdef __cplusplus +extern "C" { +#endif + Id pool_vendor2mask(Pool *pool, Id vendor); void pool_setvendorclasses(Pool *pool, const char **vendorclasses); void pool_addvendorclass(Pool *pool, const char **vendorclass); +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_POOLVENDOR_H */ diff --git a/src/queue.h b/src/queue.h index d5380c32..a80cd061 100644 --- a/src/queue.h +++ b/src/queue.h @@ -15,6 +15,10 @@ #include "pooltypes.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct _Queue { Id *elements; /* pointer to elements */ int count; /* current number of elements in queue */ @@ -116,4 +120,8 @@ extern void queue_delete2(Queue *q, int pos); extern void queue_deleten(Queue *q, int pos, int n); extern void queue_prealloc(Queue *q, int n); +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_QUEUE_H */ diff --git a/src/repo.h b/src/repo.h index a7a56ae1..130afb00 100644 --- a/src/repo.h +++ b/src/repo.h @@ -19,7 +19,9 @@ #include "dataiterator.h" #include "hash.h" - +#ifdef __cplusplus +extern "C" { +#endif typedef struct _Repo { const char *name; /* name pointer */ @@ -176,4 +178,8 @@ void repo_disable_paging(Repo *repo); for (rdid = 1; rdid < repo->nrepodata && (data = repo_id2repodata(repo, rdid)); rdid++) #endif +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_REPO_H */ diff --git a/src/repo_solv.h b/src/repo_solv.h index 8d5c32be..0c663949 100644 --- a/src/repo_solv.h +++ b/src/repo_solv.h @@ -13,15 +13,15 @@ #ifndef LIBSOLV_REPO_SOLVE_H #define LIBSOLV_REPO_SOLVE_H -#ifdef __cplusplus -extern "C" { -#endif - #include #include "pool.h" #include "repo.h" +#ifdef __cplusplus +extern "C" { +#endif + extern int repo_add_solv(Repo *repo, FILE *fp, int flags); #define SOLV_ADD_NO_STUBS (1 << 8) diff --git a/src/repo_write.h b/src/repo_write.h index 46e1d4a2..763147e0 100644 --- a/src/repo_write.h +++ b/src/repo_write.h @@ -18,6 +18,10 @@ #include "repo.h" #include "queue.h" +#ifdef __cplusplus +extern "C" { +#endif + extern int repo_write(Repo *repo, FILE *fp); extern int repo_write_filtered(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void *kfdata), void *kfdata, Queue *keyq); @@ -26,4 +30,8 @@ extern int repodata_write_filtered(Repodata *data , FILE *fp, int (*keyfilter)(R extern int repo_write_stdkeyfilter(Repo *repo, Repokey *key, void *kfdata); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/repodata.h b/src/repodata.h index 54fb3df0..2b458866 100644 --- a/src/repodata.h +++ b/src/repodata.h @@ -23,6 +23,10 @@ #include "repopage.h" #endif +#ifdef __cplusplus +extern "C" { +#endif + #define SIZEOF_MD5 16 #define SIZEOF_SHA1 20 #define SIZEOF_SHA256 32 @@ -296,4 +300,8 @@ Id repodata_lookup_id_uninternalized(Repodata *data, Id solvid, Id keyname, Id v /* stats */ unsigned int repodata_memused(Repodata *data); +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_REPODATA_H */ diff --git a/src/repopage.h b/src/repopage.h index 633456fa..739345ed 100644 --- a/src/repopage.h +++ b/src/repopage.h @@ -41,6 +41,10 @@ typedef struct _Repopagestore { unsigned int rr_counter; } Repopagestore; +#ifdef __cplusplus +extern "C" { +#endif + void repopagestore_init(Repopagestore *store); void repopagestore_free(Repopagestore *store); @@ -55,4 +59,8 @@ int repopagestore_read_or_setup_pages(Repopagestore *store, FILE *fp, unsigned i void repopagestore_disable_paging(Repopagestore *store); +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_REPOPAGE_H */ diff --git a/src/selection.h b/src/selection.h index f3716678..0ff1d76e 100644 --- a/src/selection.h +++ b/src/selection.h @@ -15,6 +15,10 @@ #include "pool.h" +#ifdef __cplusplus +extern "C" { +#endif + #define SELECTION_NAME (1 << 0) #define SELECTION_PROVIDES (1 << 1) #define SELECTION_FILELIST (1 << 2) @@ -34,4 +38,8 @@ extern void selection_filter(Pool *pool, Queue *sel1, Queue *sel2); extern void selection_add(Pool *pool, Queue *sel1, Queue *sel2); extern void selection_solvables(Pool *pool, Queue *selection, Queue *pkgs); +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/solvable.h b/src/solvable.h index a6490b84..ad06533b 100644 --- a/src/solvable.h +++ b/src/solvable.h @@ -18,6 +18,10 @@ #include "pooltypes.h" #include "queue.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _Repo; typedef struct _Solvable { @@ -75,4 +79,8 @@ void solvable_unset(Solvable *s, Id keyname); int solvable_identical(Solvable *s1, Solvable *s2); Id solvable_selfprovidedep(Solvable *s); +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_SOLVABLE_H */ diff --git a/src/solver.h b/src/solver.h index 89bea663..ae71f586 100644 --- a/src/solver.h +++ b/src/solver.h @@ -13,10 +13,6 @@ #ifndef LIBSOLV_SOLVER_H #define LIBSOLV_SOLVER_H -#ifdef __cplusplus -extern "C" { -#endif - #include "pooltypes.h" #include "pool.h" #include "repo.h" @@ -26,6 +22,9 @@ extern "C" { #include "rules.h" #include "problems.h" +#ifdef __cplusplus +extern "C" { +#endif struct _Solver { Pool *pool; /* back pointer to pool */ diff --git a/src/solverdebug.h b/src/solverdebug.h index 2b67b89e..ea31e3cc 100644 --- a/src/solverdebug.h +++ b/src/solverdebug.h @@ -17,6 +17,10 @@ #include "pool.h" #include "solver.h" +#ifdef __cplusplus +extern "C" { +#endif + extern Id *solver_create_decisions_obsoletesmap(Solver *solv); extern void solver_printruleelement(Solver *solv, int type, Rule *r, Id v); extern void solver_printrule(Solver *solv, int type, Rule *r); @@ -41,6 +45,9 @@ extern const char *solver_problemruleinfo2str(Solver *solv, SolverRuleinfo type, extern const char *solver_solutionelement2str(Solver *solv, Id p, Id rp); extern const char *policy_illegal2str(Solver *solv, int illegal, Solvable *s, Solvable *rs); +#ifdef __cplusplus +} +#endif #endif /* LIBSOLV_SOLVERDEBUG_H */ diff --git a/src/strpool.h b/src/strpool.h index 1a385c91..6745be8d 100644 --- a/src/strpool.h +++ b/src/strpool.h @@ -10,6 +10,10 @@ #include "pooltypes.h" #include "hash.h" +#ifdef __cplusplus +extern "C" { +#endif + #define STRID_NULL 0 #define STRID_EMPTY 1 @@ -42,4 +46,8 @@ stringpool_id2str(Stringpool *ss, Id id) return ss->stringspace + ss->strings[id]; } +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/transaction.h b/src/transaction.h index 5e8054cf..4f9acf3a 100644 --- a/src/transaction.h +++ b/src/transaction.h @@ -13,14 +13,14 @@ #ifndef LIBSOLV_TRANSACTION_H #define LIBSOLV_TRANSACTION_H -#ifdef __cplusplus -extern "C" { -#endif - #include "pooltypes.h" #include "queue.h" #include "bitmap.h" +#ifdef __cplusplus +extern "C" { +#endif + struct _Pool; struct _DUChanges; struct _TransactionOrderdata; diff --git a/src/util.h b/src/util.h index fcb92c2d..82ad7779 100644 --- a/src/util.h +++ b/src/util.h @@ -16,6 +16,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + /** * malloc * exits with error message on error @@ -82,4 +86,9 @@ static inline void *solv_calloc_block(size_t len, size_t size, size_t block) memset(buf, 0, ((len + block) & ~block) * size); return buf; } + +#ifdef __cplusplus +} +#endif + #endif /* LIBSOLV_UTIL_H */ -- 2.47.2