@@ -245,45 +245,12 @@ void fir::runtime::genSignal(fir::FirOpBuilder &builder, mlir::Location loc,
245
245
mlir::Value number, mlir::Value handler,
246
246
mlir::Value status) {
247
247
assert (mlir::isa<mlir::IntegerType>(number.getType ()));
248
- if (status)
249
- assert (mlir::isa<mlir::IntegerType>(fir::unwrapRefType (status.getType ())));
250
248
mlir::Type int64 = builder.getIntegerType (64 );
251
249
number = builder.create <fir::ConvertOp>(loc, int64, number);
252
250
253
- // we can return like a function or via the status argument
254
- auto returnStatus = [&](mlir::Value stat) -> mlir::Value {
255
- if (status) {
256
- // status might be dynamically optional, so test if it is present
257
- mlir::Value isPresent =
258
- builder.create <IsPresentOp>(loc, builder.getI1Type (), status);
259
- builder.genIfOp (loc, /* results=*/ {}, isPresent, /* withElseRegion=*/ false )
260
- .genThen ([&]() {
261
- stat = builder.create <fir::ConvertOp>(
262
- loc, fir::unwrapRefType (status.getType ()), stat);
263
- builder.create <fir::StoreOp>(loc, stat, status);
264
- })
265
- .end ();
266
- }
267
- return {};
268
- };
269
-
270
251
mlir::Type handlerUnwrappedTy = fir::unwrapRefType (handler.getType ());
271
252
if (mlir::isa_and_nonnull<mlir::IntegerType>(handlerUnwrappedTy)) {
272
- #if _WIN32
273
- // The windows documentation doesn't mention any support for passing
274
- // SIG_DFL or SIG_IGN as integer arguments, so just return an error.
275
-
276
- // reinterpret cast: the GNU extension is defined with STATUS as an integer
277
- // but on Windows SIG_ERR is a void *
278
- const std::int64_t sigErrVal =
279
- static_cast <std::int64_t >(reinterpret_cast <std::uintptr_t >(SIG_ERR));
280
- mlir::Value sigErr = builder.createIntegerConstant (loc, int64, sigErrVal);
281
- returnStatus (sigErr);
282
- errno = EINVAL;
283
- return ;
284
- #endif // _WIN32
285
- // else just pass the integer as a function pointer like one would to
286
- // signal(2)
253
+ // pass the integer as a function pointer like one would to signal(2)
287
254
handler = builder.create <fir::LoadOp>(loc, handler);
288
255
mlir::Type fnPtrTy = fir::LLVMPointerType::get (
289
256
mlir::FunctionType::get (handler.getContext (), {}, {}));
@@ -298,7 +265,21 @@ void fir::runtime::genSignal(fir::FirOpBuilder &builder, mlir::Location loc,
298
265
mlir::Value stat =
299
266
builder.create <fir::CallOp>(loc, func, mlir::ValueRange{number, handler})
300
267
->getResult (0 );
301
- returnStatus (stat);
268
+
269
+ // return status code via status argument (if present)
270
+ if (status) {
271
+ assert (mlir::isa<mlir::IntegerType>(fir::unwrapRefType (status.getType ())));
272
+ // status might be dynamically optional, so test if it is present
273
+ mlir::Value isPresent =
274
+ builder.create <IsPresentOp>(loc, builder.getI1Type (), status);
275
+ builder.genIfOp (loc, /* results=*/ {}, isPresent, /* withElseRegion=*/ false )
276
+ .genThen ([&]() {
277
+ stat = builder.create <fir::ConvertOp>(
278
+ loc, fir::unwrapRefType (status.getType ()), stat);
279
+ builder.create <fir::StoreOp>(loc, stat, status);
280
+ })
281
+ .end ();
282
+ }
302
283
}
303
284
304
285
void fir::runtime::genSleep (fir::FirOpBuilder &builder, mlir::Location loc,
0 commit comments