Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-igraph
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-igraph
Commits
bf067015
Commit
bf067015
authored
May 26, 2025
by
Alfredo Di Napoli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'glocqueville/relax-bounds' into 'master'
Relax dependency bounds See merge request
!8
parents
6f7e4208
786f459f
Pipeline
#7606
failed with stage
in 0 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
97 deletions
+10
-97
haskell_igraph.c
cbits/haskell_igraph.c
+6
-0
haskell_igraph.h
cbits/haskell_igraph.h
+1
-0
haskell-igraph.cabal
haskell-igraph.cabal
+1
-1
pkgs.nix
nix/pkgs.nix
+0
-95
Internal.chs
src/IGraph/Internal.chs
+2
-1
No files found.
cbits/haskell_igraph.c
View file @
bf067015
...
@@ -30,3 +30,9 @@ void haskelligraph_init()
...
@@ -30,3 +30,9 @@ void haskelligraph_init()
/* attach attribute table */
/* attach attribute table */
igraph_set_attribute_table
(
&
igraph_haskell_attribute_table
);
igraph_set_attribute_table
(
&
igraph_haskell_attribute_table
);
}
}
igraph_rng_t
*
igraph_rng_set_default_return_old
(
igraph_rng_t
*
rng
)
{
igraph_rng_t
*
old_rng
=
igraph_rng_default
();
igraph_rng_set_default
(
rng
);
return
old_rng
;
}
cbits/haskell_igraph.h
View file @
bf067015
...
@@ -4,5 +4,6 @@
...
@@ -4,5 +4,6 @@
#include <igraph.h>
#include <igraph.h>
void
haskelligraph_init
();
void
haskelligraph_init
();
igraph_rng_t
*
igraph_rng_set_default_return_old
(
igraph_rng_t
*
rng
);
#endif
#endif
haskell-igraph.cabal
View file @
bf067015
...
@@ -71,7 +71,7 @@ library
...
@@ -71,7 +71,7 @@ library
cereal >= 0.5.8 && < 0.6,
cereal >= 0.5.8 && < 0.6,
containers >= 0.6.7 && < 0.7,
containers >= 0.6.7 && < 0.7,
conduit >= 1.3.6 && < 1.4,
conduit >= 1.3.6 && < 1.4,
primitive >= 0.
9
.0 && < 0.10,
primitive >= 0.
8
.0 && < 0.10,
data-ordlist >= 0.4.7 && < 0.5,
data-ordlist >= 0.4.7 && < 0.5,
safe-exceptions <= 0.2,
safe-exceptions <= 0.2,
singletons-base >= 3.2 && < 3.3,
singletons-base >= 3.2 && < 3.3,
...
...
nix/pkgs.nix
View file @
bf067015
...
@@ -15,101 +15,6 @@ rec {
...
@@ -15,101 +15,6 @@ rec {
hash
=
"sha256-LsTOxUktGZcp46Ec9QH3+9C+VADMYTZZCjKF1gp36xk="
;
hash
=
"sha256-LsTOxUktGZcp46Ec9QH3+9C+VADMYTZZCjKF1gp36xk="
;
};
};
# https://gitlab.iscpif.fr/gargantext/haskell-igraph/issues/5
# As per https://github.com/igraph/igraph/commit/e905376dd5965f3b423fc31450f347d4247fd41c
# this patch modifies the `igraph` C library to have the `igraph_rng_set_default` return
# the previos RNG. We couldn't use an upstream release as this function is present only
# on the `develop` branch of the `igraph` project and likely will be present in version
# 0.11, which we don't support just yet.
patches
=
[
(
pkgs
.
writeText
"igraph-return-old-rng.patch"
''
diff --git a/include/igraph_random.h b/include/igraph_random.h
index 71b4e2557d..070115312e 100644
--- a/include/igraph_random.h
+++ b/include/igraph_random.h
@@ -152,7 +152,7 @@ IGRAPH_EXPORT extern const igraph_rng_type_t igraph_rngtype_pcg32;
IGRAPH_EXPORT extern const igraph_rng_type_t igraph_rngtype_pcg64;
IGRAPH_EXPORT igraph_rng_t *igraph_rng_default(void);
-IGRAPH_EXPORT void igraph_rng_set_default(igraph_rng_t *rng);
+IGRAPH_EXPORT igraph_rng_t *igraph_rng_set_default(igraph_rng_t *rng);
/* --------------------------------- */
diff --git a/src/random/random.c b/src/random/random.c
index a37495e804..b644ef5229 100644
--- a/src/random/random.c
+++ b/src/random/random.c
@@ -145,32 +145,32 @@
* igraph_rng_set_default() function.
*/
-extern IGRAPH_THREAD_LOCAL igraph_rng_t igraph_i_rng_default; /* defined in rng_pcg32.c */
+extern igraph_rng_t igraph_i_rng_default; /* defined in rng_pcg32.c */
+IGRAPH_THREAD_LOCAL igraph_rng_t *igraph_i_rng_default_ptr = &igraph_i_rng_default;
/**
* \function igraph_rng_set_default
* \brief Set the default igraph random number generator.
*
- * This function \em copies the internal structure of the given \type igraph_rng_t
- * object to igraph's internal default RNG structure. The structure itself
- * contains two pointers only, one to the "methods" of the RNG and one to the
- * memory buffer holding the internal state of the RNG. This means that if you
- * keep on generating random numbers from the RNG after setting it as the
- * default, it will affect the state of the default RNG as well because the two
- * share the same state pointer. However, do \em not expect
- * \ref igraph_rng_default() to return the same pointer as the one you passed
- * in here - the state is shared, but the entire structure is not.
+ * This function updates the default RNG used by igraph to be the one
+ * pointed to by \p rng, and returns a pointer to the previous default
+ * RNG. Future calls to \ref igraph_rng_default() will return the same
+ * pointer as \p rng. The RNG pointed to by \p rng must not be destroyed
+ * for as long as it is used as the default.
*
* \param rng The random number generator to use as default from now
* on. Calling \ref igraph_rng_destroy() on it, while it is still
* being used as the default will result in crashes and/or
* unpredictable results.
+ * \return Pointer the previous default RNG.
*
* Time complexity: O(1).
*/
-void igraph_rng_set_default(igraph_rng_t *rng) {
- igraph_i_rng_default = (*rng);
+igraph_rng_t *igraph_rng_set_default(igraph_rng_t *rng) {
+ igraph_rng_t *old_rng = igraph_i_rng_default_ptr;
+ igraph_i_rng_default_ptr = rng;
+ return old_rng;
}
@@ -186,7 +186,7 @@ void igraph_rng_set_default(igraph_rng_t *rng) {
*/
igraph_rng_t *igraph_rng_default(void) {
- return &igraph_i_rng_default;
+ return igraph_i_rng_default_ptr;
}
/* ------------------------------------ */
diff --git a/src/random/rng_pcg32.c b/src/random/rng_pcg32.c
index fb51b1ba2f..7d5655eb4f 100644
--- a/src/random/rng_pcg32.c
+++ b/src/random/rng_pcg32.c
@@ -115,7 +115,7 @@ const igraph_rng_type_t igraph_rngtype_pcg32 = {
static pcg32_random_t igraph_i_rng_default_state = PCG32_INITIALIZER;
-IGRAPH_THREAD_LOCAL igraph_rng_t igraph_i_rng_default = {
+igraph_rng_t igraph_i_rng_default = {
addr(igraph_rngtype_pcg32),
addr(igraph_i_rng_default_state),
/* is_seeded = */ true
''
)
];
postPatch
=
''
postPatch
=
''
echo "0.10.4" > IGRAPH_VERSION
echo "0.10.4" > IGRAPH_VERSION
''
;
''
;
...
...
src/IGraph/Internal.chs
View file @
bf067015
...
@@ -943,7 +943,8 @@ data RNG
...
@@ -943,7 +943,8 @@ data RNG
-- As per https://github.com/igraph/igraph/commit/e905376dd5965f3b423fc31450f347d4247fd41c
-- As per https://github.com/igraph/igraph/commit/e905376dd5965f3b423fc31450f347d4247fd41c
-- and documentation for 0.10.4, returns the pointer to the previous
-- and documentation for 0.10.4, returns the pointer to the previous
-- default RNG.
-- default RNG.
{#fun igraph_rng_set_default as ^ { castPtr `Ptr RNG' } -> `Ptr RNG' castPtr #}
-- Using a shim C function defined in \"cbits\".
{#fun igraph_rng_set_default_return_old as igraphRngSetDefault { castPtr `Ptr RNG' } -> `Ptr RNG' castPtr #}
-- | Allocate and initialize a RNG.
-- | Allocate and initialize a RNG.
allocaRng :: (Ptr RNG -> IO a) -> IO a
allocaRng :: (Ptr RNG -> IO a) -> IO a
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment