mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
Simplify SharedArray.
This commit is contained in:
@@ -185,19 +185,13 @@ else:
|
||||
import locks
|
||||
|
||||
type
|
||||
SharedArrayHolder[T] = object
|
||||
part: array[1, T]
|
||||
SharedArray {.unchecked.}[T] = array[0..100_000_000, T]
|
||||
|
||||
proc allocSharedArray[T](nsize: int): ptr SharedArray[T] =
|
||||
let holder = cast[ptr SharedArrayHolder[T]](
|
||||
allocShared0(sizeof(T) * nsize)
|
||||
)
|
||||
result = cast[ptr SharedArray[T]](addr(holder.part[0]))
|
||||
result = cast[ptr SharedArray[T]](allocShared0(sizeof(T) & nsize))
|
||||
|
||||
proc deallocSharedArray[T](sa: ptr SharedArray[T]) =
|
||||
deallocShared(cast[pointer](sa))
|
||||
|
||||
type
|
||||
Event* {.pure.} = enum
|
||||
Read, Write, Timer, Signal, Process, Vnode, User, Error, Oneshot
|
||||
|
||||
@@ -25,7 +25,7 @@ when defined(macosx) or defined(freebsd):
|
||||
proc sysctl(name: ptr cint, namelen: cuint, oldp: pointer, oldplen: ptr int,
|
||||
newp: pointer, newplen: int): cint
|
||||
{.importc: "sysctl",header: """#include <sys/types.h>
|
||||
#include <sys/sysctl.h>"""}
|
||||
#include <sys/sysctl.h>"""}
|
||||
elif defined(netbsd) or defined(openbsd):
|
||||
# OpenBSD and NetBSD don't have KERN_MAXFILESPERPROC, so we are using
|
||||
# KERN_MAXFILES, because KERN_MAXFILES is always bigger,
|
||||
|
||||
Reference in New Issue
Block a user