Skip to content

Commit

Permalink
runtime: rename the MAXPROCS function as NumCPU
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Jan 4, 2025
1 parent e11f1a1 commit efa09d4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions std/runtime/thread.jule
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ const threadSC_EmptySelect = 1 << 0
static threadMutex = fmutex{}
static mut threads = (&thread)(nil)
static mut threadCases = threadSC_NA
static mut maxprocs = 0
static mut numcpu = 0

// Returns the number of cores.
// Returns the number of CPUs.
// Returns zero until data initialized by the runtime.
fn MAXPROCS(): int { ret maxprocs }
fn NumCPU(): int { ret numcpu }

// Allocates a new thread and sets state as running.
fn newThread(): &thread {
Expand Down
2 changes: 1 addition & 1 deletion std/runtime/thread_unix.jule
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn init() {
// See the documentation of the pushNewThread function.
threadMutex.lock()
// We already locked the mutex, set maxproc too.
maxprocs = unsafe { int(cpp.sysconf(_SC_NPROCESSORS_ONLN)) }
numcpu = unsafe { int(cpp.sysconf(_SC_NPROCESSORS_ONLN)) }
mut t := newThread()
t.os.handle = currentThreadID()
threads = t
Expand Down
2 changes: 1 addition & 1 deletion std/runtime/thread_windows.jule
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn init() {
// We already locked the mutex, set maxproc too.
let info: cpp.SYSTEM_INFO
unsafe { cpp.GetSystemInfo(&info) }
maxprocs = int(info.dwNumberOfProcessors)
numcpu = int(info.dwNumberOfProcessors)
}
mut t := newThread()
t.os.id = currentThreadID()
Expand Down

0 comments on commit efa09d4

Please sign in to comment.