Skip to content

Commit

Permalink
Merge pull request #316 from insertinterestingnamehere/cmake
Browse files Browse the repository at this point in the history
Allow Building Using CMake
  • Loading branch information
insertinterestingnamehere authored Dec 18, 2024
2 parents 1e23280 + 95e80e9 commit 4319d8d
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 30 deletions.
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.30)

set(CMAKE_C_STANDARD 11)

project(qthreads
VERSION 1.22
DESCRIPTION "A user-level threading library"
LANGUAGES C ASM)

add_subdirectory(src)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
add_subdirectory(test)
endif()

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ AC_CACHE_SAVE
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_CHECK_HEADERS([stdlib.h fcntl.h ucontext.h sys/time.h sys/resource.h mach/mach_time.h malloc.h math.h sys/types.h sys/sysctl.h unistd.h sys/syscall.h])
AC_CHECK_HEADERS([stdlib.h fcntl.h ucontext.h sys/time.h sys/resource.h mach/mach_time.h malloc.h math.h sys/types.h sys/sysctl.h])

AC_CACHE_SAVE

Expand Down
52 changes: 52 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
set(QTHREADS_SCHEDULER nemesis CACHE STRING "Which scheduler to use for qthreads. Valid options are nemesis, sherwood, and distrib.")
set(QTHREADS_TOPOLOGY no CACHE STRING "Which topology detection/management system to use for qthreads. Valid options are no, hwloc, and binders.")
set(QTHREADS_BARRIER feb CACHE STRING "Which barrier implementation to use for qthreads. Valid options are feb, sinc, array, and log.")
set(QTHREADS_SINC donecount CACHE STRING "Which sinc implementation to use for qthreads. Valid options are donecount, donecoutn_cas, snzi, and original.")
set(QTHREADS_ALLOC base CACHE STRING "Wich allocation implementation to use for qthreads. Valid options are base, and chapel.")
set(QTHREADS_CACHELINE_SIZE_ESTIMATE 64 CACHE STRING "Estimate of the cacheline size of the target machine (used for optimizing data structure layouts).")
set(QTHREADS_DEFAULT_STACK_SIZE 32768 CACHE STRING "Default qthread stack size.")
set(QTHREADS_HASHMAP hashmap CACHE STRING "Which hashmap implementation to use. Valid values are \"hashmap\" and \"lf_hashmap\".")

set(QTHREADS_SOURCES
cacheline.c
envariables.c
feb.c
hazardptrs.c
io.c
locks.c
qalloc.c
qloop.c
queue.c
barrier/${QTHREADS_BARRIER}.c
qutil.c
syncvar.c
qthread.c
mpool.c
shepherds.c
workers.c
threadqueues/${QTHREADS_SCHEDULER}_threadqueues.c
sincs/${QTHREADS_SINC}.c
alloc/${QTHREADS_ALLOC}.c
affinity/common.c
affinity/${QTHREADS_TOPOLOGY}.c
touch.c
tls.c
teams.c
fastcontext/asm.S
fastcontext/context.c
${QTHREADS_HASHMAP}.c
)

# TODO: switch/checks necessary to include the correct
# fastcontext version when we need the fallback.

add_library(qthread SHARED ${QTHREADS_SOURCES})
target_include_directories(qthread
PUBLIC "../include/qthread"
PRIVATE "../include"
)
# TODO: move these into a configure header instead of piping them through the flags.
target_compile_definitions(qthread
PRIVATE CACHELINE_WIDTH=${QTHREADS_CACHELINE_SIZE_ESTIMATE}
PRIVATE QTHREAD_DEFAULT_STACK_SIZE=${QTHREADS_DEFAULT_STACK_SIZE}
)
5 changes: 0 additions & 5 deletions src/fastcontext/asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
/* Portions of this file are Copyright (c) 2005-2006 Russ Cox, MIT; see COPYRIGHT */
/* Portions of this file are Copyright Sandia National Laboratories */
#endif
#ifdef HAVE_CONFIG_H
# include "config.h"
#else
# error no config.h
#endif
#include "qthread/common.h"

#define _(x)
Expand Down
2 changes: 0 additions & 2 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
#include <stdio.h> /* for fprintf() */
#include <stdlib.h> /* for abort() */
#include <sys/time.h> /* for gettimeofday() */
#ifdef HAVE_SYS_SYSCALL_H
/* - syscall(2) */
#include <sys/syscall.h>
#include <unistd.h>
#endif
/* - accept(2) */
#include <sys/socket.h>
/* - connect(2) */
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#include <stdint.h>

/* System Headers */
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#include <stdint.h>

/* System Headers */
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

#include <stdint.h>

#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/pread.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
/* System Headers */
#include <sys/types.h>

#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/pwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
/* System Headers */
#include <sys/types.h>

#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
/* System Headers */
#include <sys/types.h>

#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/select.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
/* System Headers */
#include <sys/select.h>

#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include <stdint.h>

/* System Headers */
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/user_defined.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
#include <sys/uio.h>
#include <unistd.h>

#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#endif

/* Internal Headers */
#include "qt_asserts.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/wait4.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#include <stdint.h>

/* System Headers */
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
/* System Headers */
#include <sys/types.h>

#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h> /* for SYS_accept and others */
#include <unistd.h>
#endif

/* Public Headers */
#include "qthread/qt_syscalls.h"
Expand Down
Empty file added test/CMakeLists.txt
Empty file.

0 comments on commit 4319d8d

Please sign in to comment.