Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile error when unthreded execution and tracing are both enabl… #182

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions core/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ void start_trace(char* filename) {

lf_thread_create(&_lf_flush_trace_thread, flush_trace, NULL);

#ifdef LF_UNTHREADED
// FIXME: If LF_UNTHREADED is defined, then no thread will be create to
// flush the file (instruction above).
// A sequential mechanism is needed for emptying the buffer into the
// file when needed.
; // WIP
#endif // LF_UNTHREADED

LF_PRINT_DEBUG("Started tracing.");
}

Expand Down
27 changes: 25 additions & 2 deletions include/core/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,16 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#error "Platform not supported"
#endif

#if !defined(LF_THREADED) && !defined(_LF_TRACE)
typedef void lf_mutex_t;
#if defined(LF_UNTHREADED)
#if defined(LF_TRACE)
typedef void *lf_mutex_t;
typedef void *lf_cond_t;
typedef void *lf_thread_t;
#else // !defined(_LF_TRACE) ???
// FIXME: Not sure if _LF_TRACE is needed anymore, as it is commented
// out in trace.c. In both case, shouldn't it lf_mutex_t be void*?
typedef void lf_mutex_t;
#endif
#endif

#define LF_TIMEOUT _LF_TIMEOUT
Expand Down Expand Up @@ -334,4 +342,19 @@ extern int lf_sleep_until_locked(instant_t wakeup_time);
*/
DEPRECATED(extern int lf_nanosleep(interval_t sleep_duration));

// empty definition in case we have LF_UNTHREADED and LF_TRACE
#if (defined LF_UNTHREADED && defined LF_TRACE)
#define lf_available_cores(...);
#define lf_thread_create(...);
#define lf_thread_join(...);
#define lf_mutex_init(...);
#define lf_mutex_lock(...);
#define lf_mutex_unlock(...);
#define lf_cond_init(...);
#define lf_cond_broadcast(...);
#define lf_cond_signal(...);
#define lf_cond_wait(...);
#define lf_cond_timedwait(...);
#endif // LF_UNTHREADED && LF_TRACE

#endif // PLATFORM_H