lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suggestion GNU lightning: use lightning_protected instead of protect


From: Paul Cercueil
Subject: Re: suggestion GNU lightning: use lightning_protected instead of protected identifier (for C++ compatibility)
Date: Thu, 03 Aug 2023 12:17:52 +0200

Hi,

Le jeudi 03 août 2023 à 11:49 +0200, Basile Starynkevitch a écrit :
> Hello all
> 
> 
> In GNU lightning git commit 875b701732 the protected identifier is
> used 
> in file include/lightning/jit_private.h
> 
> That jit_private.h file is needed in the RefPerSys open source
> inference 
> engine (see https://github.com/RefPerSys/RefPerSys/ ....) because we
> use 
> and need sizeof(jit_state) and alignof(jit_state). Since RefPerSys is
> generating (also) C++ code at runtime, then compiling it as a plugin
> and 
> dlopen-ing it.
> 
> My suggestion would be to use something which is not a C++ keyword 
> instead. Maybe lightning_protected instead of protected.

The real fix for you would probably be

extern "C" {
#include <lightning/jit_private.h>
}

Cheers,
-Paul

> 
> Apparently the protected field name is used in six lines:
> 
> include/lightning/jit_private.h:776:        jit_word_t protected;
> lib/lightning.c:2556:    _jit->code.protected = _jit->pc.uc - 
> _jit->code.ptr;
> lib/lightning.c:2559:    _jit->code.protected -= 
> _jitc->consts.hash.count * sizeof(jit_word_t);
> lib/lightning.c:2561:    result = mprotect(_jit->code.ptr, 
> _jit->code.protected, PROT_READ | PROT_EXEC);
> lib/lightning.c:2579:  result = mprotect (_jit->code.ptr, 
> _jit->code.protected, PROT_READ | PROT_EXEC);
> lib/lightning.c:2592:  result = mprotect (_jit->code.ptr, 
> _jit->code.protected, PROT_READ | PROT_WRITE);
> 
> 
> Cheers
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]