summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/compiler.h4
-rw-r--r--libdimension/platform.h10
-rw-r--r--libdimension/profile.h6
-rw-r--r--libdimension/progress-impl.h9
-rw-r--r--libdimension/threads.c26
-rw-r--r--libdimension/threads.h12
6 files changed, 35 insertions, 32 deletions
diff --git a/libdimension/compiler.h b/libdimension/compiler.h
index b647aea..7166a19 100644
--- a/libdimension/compiler.h
+++ b/libdimension/compiler.h
@@ -42,9 +42,11 @@
#endif
#ifdef __GNUC__
- #define DMNSN_HOT __attribute__((hot))
+ #define DMNSN_HOT __attribute__((hot))
+ #define DMNSN_INTERNAL __attribute__((visibility("hidden")))
#else
#define DMNSN_HOT
+ #define DMNSN_INTERNAL
#endif
#endif /* DIMENSION_IMPL_COMPILER_H */
diff --git a/libdimension/platform.h b/libdimension/platform.h
index 797135d..95f8fed 100644
--- a/libdimension/platform.h
+++ b/libdimension/platform.h
@@ -34,32 +34,32 @@
* Print a stack trace, if implemented for the current platform.
* @param[in,out] file The file to which to write the stack trace.
*/
-void dmnsn_backtrace(FILE *file);
+DMNSN_INTERNAL void dmnsn_backtrace(FILE *file);
/**
* Is the calling thread the main thread?
* @return Whether this is the main execution thread, or \c true if we can't
* tell.
*/
-bool dmnsn_is_main_thread(void);
+DMNSN_INTERNAL bool dmnsn_is_main_thread(void);
/**
* Are we running on a little-endian computer?
* @return Whether the current architecture is little-endian.
*/
-bool dmnsn_is_little_endian(void);
+DMNSN_INTERNAL bool dmnsn_is_little_endian(void);
/**
* How many CPUs are available?
* @return The number of CPUs available to dimension.
*/
-size_t dmnsn_ncpus(void);
+DMNSN_INTERNAL size_t dmnsn_ncpus(void);
/**
* Calculate process times.
* @param[out] timer The timer in which to store the current total process
* times.
*/
-void dmnsn_get_times(dmnsn_timer *timer);
+DMNSN_INTERNAL void dmnsn_get_times(dmnsn_timer *timer);
#endif /* DIMENSION_IMPL_PLATFORM_H */
diff --git a/libdimension/profile.h b/libdimension/profile.h
index 04c77e2..f7359a3 100644
--- a/libdimension/profile.h
+++ b/libdimension/profile.h
@@ -29,7 +29,7 @@
#include <stdbool.h>
/**
- * Record an test and its expected result. Called by dmnsn_[un]likely();
+ * Record a test and its expected result. Called by dmnsn_[un]likely();
* don't call directly.
* @param[in] result The result of the test.
* @param[in] expected The expected result of the test.
@@ -38,7 +38,7 @@
* @param[in] line The line number on which the test occurs.
* @return \p result.
*/
-bool dmnsn_expect(bool result, bool expected,
- const char *func, const char *file, unsigned int line);
+DMNSN_INTERNAL bool dmnsn_expect(bool result, bool expected, const char *func,
+ const char *file, unsigned int line);
#endif /* DIMENSION_IMPL_PROFILE_H */
diff --git a/libdimension/progress-impl.h b/libdimension/progress-impl.h
index d7b1c96..1ca9b25 100644
--- a/libdimension/progress-impl.h
+++ b/libdimension/progress-impl.h
@@ -29,14 +29,15 @@
#include <pthread.h>
/** Allocate a new progress object. */
-dmnsn_progress *dmnsn_new_progress(void);
+DMNSN_INTERNAL dmnsn_progress *dmnsn_new_progress(void);
/** Set the total number of loop iterations. */
-void dmnsn_set_progress_total(dmnsn_progress *progress, size_t total);
+DMNSN_INTERNAL void dmnsn_set_progress_total(dmnsn_progress *progress,
+ size_t total);
/** Increment the progress counter. */
-void dmnsn_increment_progress(dmnsn_progress *progress);
+DMNSN_INTERNAL void dmnsn_increment_progress(dmnsn_progress *progress);
/** Instantly complete the progress. */
-void dmnsn_done_progress(dmnsn_progress *progress);
+DMNSN_INTERNAL void dmnsn_done_progress(dmnsn_progress *progress);
struct dmnsn_progress {
size_t progress; /**< Completed loop iterations. */
diff --git a/libdimension/threads.c b/libdimension/threads.c
index 00f0e33..54939e6 100644
--- a/libdimension/threads.c
+++ b/libdimension/threads.c
@@ -73,35 +73,35 @@ dmnsn_new_thread(dmnsn_progress *progress, dmnsn_thread_fn *thread_fn,
}
/** Payload for threads executed by dmnsn_execute_concurrently(). */
-typedef struct dmnsn_concurrent_thread_payload {
- dmnsn_concurrent_thread_fn *thread_fn;
+typedef struct dmnsn_ccthread_payload {
+ dmnsn_ccthread_fn *ccthread_fn;
void *arg;
unsigned int thread, nthreads;
int ret;
-} dmnsn_concurrent_thread_payload;
+} dmnsn_ccthread_payload;
static void *
dmnsn_concurrent_thread(void *ptr)
{
- dmnsn_concurrent_thread_payload *payload = ptr;
- payload->ret = payload->thread_fn(payload->arg, payload->thread,
- payload->nthreads);
+ dmnsn_ccthread_payload *payload = ptr;
+ payload->ret = payload->ccthread_fn(payload->arg, payload->thread,
+ payload->nthreads);
return NULL;
}
int
-dmnsn_execute_concurrently(dmnsn_concurrent_thread_fn *thread_fn,
+dmnsn_execute_concurrently(dmnsn_ccthread_fn *ccthread_fn,
void *arg, unsigned int nthreads)
{
pthread_t threads[nthreads];
- dmnsn_concurrent_thread_payload payloads[nthreads];
+ dmnsn_ccthread_payload payloads[nthreads];
for (unsigned int i = 0; i < nthreads; ++i) {
- payloads[i].thread_fn = thread_fn;
- payloads[i].arg = arg;
- payloads[i].thread = i;
- payloads[i].nthreads = nthreads;
- payloads[i].ret = -1;
+ payloads[i].ccthread_fn = ccthread_fn;
+ payloads[i].arg = arg;
+ payloads[i].thread = i;
+ payloads[i].nthreads = nthreads;
+ payloads[i].ret = -1;
if (pthread_create(&threads[i], NULL, dmnsn_concurrent_thread,
&payloads[i]) != 0)
{
diff --git a/libdimension/threads.h b/libdimension/threads.h
index 1ead66d..17019b0 100644
--- a/libdimension/threads.h
+++ b/libdimension/threads.h
@@ -40,8 +40,8 @@ typedef int dmnsn_thread_fn(void *ptr);
* @param[in] nthreads The number of concurrent threads.
* @return 0 on success, non-zero on failure.
*/
-typedef int dmnsn_concurrent_thread_fn(void *ptr, unsigned int thread,
- unsigned int nthreads);
+typedef int dmnsn_ccthread_fn(void *ptr, unsigned int thread,
+ unsigned int nthreads);
/**
* Create a thread that cleans up after itself on errors.
@@ -49,8 +49,8 @@ typedef int dmnsn_concurrent_thread_fn(void *ptr, unsigned int thread,
* @param[in] thread_fn The thread callback.
* @param[in,out] arg The pointer to pass to the thread callback.
*/
-void dmnsn_new_thread(dmnsn_progress *progress, dmnsn_thread_fn *thread_fn,
- void *arg);
+DMNSN_INTERNAL void dmnsn_new_thread(dmnsn_progress *progress,
+ dmnsn_thread_fn *thread_fn, void *arg);
/**
* Run \p nthreads threads in parallel.
@@ -59,7 +59,7 @@ void dmnsn_new_thread(dmnsn_progress *progress, dmnsn_thread_fn *thread_fn,
* @param[in] nthreads The number of concurrent threads to run.
* @return 0 if all threads were successful, and an error code otherwise.
*/
-int dmnsn_execute_concurrently(dmnsn_concurrent_thread_fn *thread_fn,
- void *arg, unsigned int nthreads);
+DMNSN_INTERNAL int dmnsn_execute_concurrently(dmnsn_ccthread_fn *ccthread_fn,
+ void *arg, unsigned int nthreads);
#endif /* DIMENSION_IMPL_THREADS_H */