mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-14 23:33:28 +00:00
fixes#23665; rework spawn with gcc 14 and fixes other tests (#23660)
fixes #23665
This commit is contained in:
@@ -109,6 +109,16 @@ stmtList:
|
||||
|
||||
"""
|
||||
|
||||
proc castToVoidPointer(g: ModuleGraph, n: PNode, fvField: PNode): PNode =
|
||||
if g.config.backend == backendCpp:
|
||||
result = fvField
|
||||
else:
|
||||
let ptrType = getSysType(g, n.info, tyPointer)
|
||||
result = newNodeI(nkCast, fvField.info)
|
||||
result.add newNodeI(nkEmpty, fvField.info)
|
||||
result.add fvField
|
||||
result.typ = ptrType
|
||||
|
||||
proc createWrapperProc(g: ModuleGraph; f: PNode; threadParam, argsParam: PSym;
|
||||
varSection, varInit, call, barrier, fv: PNode;
|
||||
idgen: IdGenerator;
|
||||
@@ -156,8 +166,9 @@ proc createWrapperProc(g: ModuleGraph; f: PNode; threadParam, argsParam: PSym;
|
||||
if barrier == nil:
|
||||
# by now 'fv' is shared and thus might have beeen overwritten! we need
|
||||
# to use the thread-local view instead:
|
||||
let castExpr = castToVoidPointer(g, f, threadLocalProm.newSymNode)
|
||||
body.add callCodegenProc(g, "nimFlowVarSignal", threadLocalProm.info,
|
||||
threadLocalProm.newSymNode)
|
||||
castExpr)
|
||||
else:
|
||||
body.add call
|
||||
if barrier != nil:
|
||||
@@ -413,7 +424,8 @@ proc wrapProcForSpawn*(g: ModuleGraph; idgen: IdGenerator; owner: PSym; spawnExp
|
||||
# create flowVar:
|
||||
result.add newFastAsgnStmt(fvField, callProc(spawnExpr[^1]))
|
||||
if barrier == nil:
|
||||
result.add callCodegenProc(g, "nimFlowVarCreateSemaphore", fvField.info, fvField)
|
||||
let castExpr = castToVoidPointer(g, n, fvField)
|
||||
result.add callCodegenProc(g, "nimFlowVarCreateSemaphore", fvField.info, castExpr)
|
||||
|
||||
elif spawnKind == srByVar:
|
||||
var field = newSym(skField, getIdent(g.cache, "fv"), idgen, owner, n.info, g.config.options)
|
||||
|
||||
@@ -4,6 +4,7 @@ discard """
|
||||
# Test the new ``emit`` pragma:
|
||||
|
||||
{.emit: """
|
||||
#include <stdio.h>
|
||||
static int cvariable = 420;
|
||||
|
||||
""".}
|
||||
|
||||
@@ -18,7 +18,7 @@ renderer.setDrawColor 29, 64, 153, 255
|
||||
renderer.clear
|
||||
renderer.setDrawColor 255, 255, 255, 255
|
||||
|
||||
when defined(c):
|
||||
when false: # no long work with gcc 14!
|
||||
# just to ensure code from NimInAction still works, but
|
||||
# the `else` branch would work as well in C mode
|
||||
var points = [
|
||||
|
||||
Reference in New Issue
Block a user