4747import static com .oracle .graal .python .annotations .NativeSimpleType .VOID ;
4848import static com .oracle .graal .python .nodes .StringLiterals .J_NFI_LANGUAGE ;
4949import static com .oracle .graal .python .nodes .StringLiterals .T_NATIVE ;
50- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_IN6_ADDR_S6_ADDR ;
51- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_IN_ADDR_S_ADDR ;
52- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN6_SIN6_ADDR ;
53- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN6_SIN6_FLOWINFO ;
54- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN6_SIN6_PORT ;
55- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID ;
56- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN_SIN_ADDR ;
57- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN_SIN_PORT ;
58- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_SOCKADDR_SA_FAMILY ;
59- import static com .oracle .graal .python .runtime .NFIPosixConstants .OFFSETOF_STRUCT_SOCKADDR_UN_SUN_PATH ;
60- import static com .oracle .graal .python .runtime .NFIPosixConstants .SIZEOF_STRUCT_SOCKADDR_IN ;
61- import static com .oracle .graal .python .runtime .NFIPosixConstants .SIZEOF_STRUCT_SOCKADDR_IN6 ;
62- import static com .oracle .graal .python .runtime .NFIPosixConstants .SIZEOF_STRUCT_SOCKADDR_SA_FAMILY ;
63- import static com .oracle .graal .python .runtime .NFIPosixConstants .SIZEOF_STRUCT_SOCKADDR_STORAGE ;
64- import static com .oracle .graal .python .runtime .NFIPosixConstants .SIZEOF_STRUCT_SOCKADDR_UN_SUN_PATH ;
50+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_IN6_ADDR_S6_ADDR ;
51+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_IN_ADDR_S_ADDR ;
52+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN6_SIN6_ADDR ;
53+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN6_SIN6_FLOWINFO ;
54+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN6_SIN6_PORT ;
55+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID ;
56+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN_SIN_ADDR ;
57+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_SOCKADDR_IN_SIN_PORT ;
58+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_SOCKADDR_SA_FAMILY ;
59+ import static com .oracle .graal .python .runtime .NativePosixConstants .OFFSETOF_STRUCT_SOCKADDR_UN_SUN_PATH ;
60+ import static com .oracle .graal .python .runtime .NativePosixConstants .SIZEOF_STRUCT_SOCKADDR_IN ;
61+ import static com .oracle .graal .python .runtime .NativePosixConstants .SIZEOF_STRUCT_SOCKADDR_IN6 ;
62+ import static com .oracle .graal .python .runtime .NativePosixConstants .SIZEOF_STRUCT_SOCKADDR_SA_FAMILY ;
63+ import static com .oracle .graal .python .runtime .NativePosixConstants .SIZEOF_STRUCT_SOCKADDR_STORAGE ;
64+ import static com .oracle .graal .python .runtime .NativePosixConstants .SIZEOF_STRUCT_SOCKADDR_UN_SUN_PATH ;
6565import static com .oracle .graal .python .runtime .PosixConstants .AF_INET ;
6666import static com .oracle .graal .python .runtime .PosixConstants .AF_INET6 ;
6767import static com .oracle .graal .python .runtime .PosixConstants .AF_UNIX ;
148148 * downcalls.
149149 */
150150@ ExportLibrary (PosixSupportLibrary .class )
151- public final class NFIPosixSupport extends PosixSupport {
151+ public final class NativePosixSupport extends PosixSupport {
152152 private static final String SUPPORTING_NATIVE_LIB_NAME = "posix" ;
153153 private static final Source NFI_WARMUP_SIGNATURE = Source .newBuilder (J_NFI_LANGUAGE , "with native ():void" , "python-nfi-warmup" ).internal (true ).build ();
154154
@@ -160,7 +160,7 @@ public final class NFIPosixSupport extends PosixSupport {
160160
161161 private static final int MAX_READ = Integer .MAX_VALUE / 2 ;
162162
163- private static final TruffleLogger LOGGER = PythonLanguage .getLogger (NFIPosixSupport .class );
163+ private static final TruffleLogger LOGGER = PythonLanguage .getLogger (NativePosixSupport .class );
164164
165165 private static final Unsafe UNSAFE = PythonUtils .initUnsafe ();
166166
@@ -626,24 +626,24 @@ static NativeLibrary loadNativeLibrary(PythonContext context) {
626626 }
627627
628628 private final PythonContext context ;
629- private final TruffleString nfiBackend ;
629+ private final TruffleString nativeBackend ;
630630 private final PosixNativeFunctionInvoker posixNativeFunctionInvoker ;
631631 private final CryptNativeFunctionInvoker cryptNativeFunctionInvoker ;
632632 @ CompilationFinal (dimensions = 1 ) private long [] constantValues ;
633633
634- public NFIPosixSupport (PythonContext context , TruffleString nfiBackend ) {
635- assert nfiBackend .equalsUncached (T_NATIVE , TS_ENCODING );
634+ public NativePosixSupport (PythonContext context , TruffleString nativeBackend ) {
635+ assert nativeBackend .equalsUncached (T_NATIVE , TS_ENCODING );
636636 this .context = context ;
637- this .nfiBackend = nfiBackend ;
637+ this .nativeBackend = nativeBackend ;
638638 this .posixNativeFunctionInvoker = new PosixNativeFunctionInvokerGen (context );
639639 this .cryptNativeFunctionInvoker = new CryptNativeFunctionInvokerGen (context );
640640 setEnv (context .getEnv ());
641641 }
642642
643- long getConstant (NFIPosixConstants constant ) {
643+ long getConstant (NativePosixConstants constant ) {
644644 if (constantValues == null ) {
645645 CompilerDirectives .transferToInterpreterAndInvalidate ();
646- long [] values = new long [NFIPosixConstants .values ().length ];
646+ long [] values = new long [NativePosixConstants .values ().length ];
647647 long nativeValues = NativeMemory .mallocLongArray (values .length );
648648 try {
649649 int result = posixNativeFunctionInvoker .init_constants (nativeValues , values .length );
@@ -680,7 +680,7 @@ public void setEnv(Env env) {
680680 // native cwd is global, but Truffle cwd is per context.
681681 // TruffleFile will be unaware of the real working directory and keep resolving against the
682682 // original working directory. This should not matter since we do not use TruffleFile for
683- // ordinary I/O when using NFI backend.
683+ // ordinary I/O when using the native backend.
684684 try {
685685 TruffleFile truffleFile = context .getEnv ().getInternalTruffleFile ("." ).getAbsoluteFile ();
686686 context .getEnv ().setCurrentWorkingDirectory (truffleFile );
@@ -691,7 +691,7 @@ public void setEnv(Env env) {
691691
692692 @ ExportMessage
693693 public TruffleString getBackend () {
694- return nfiBackend ;
694+ return nativeBackend ;
695695 }
696696
697697 @ ExportMessage
@@ -1305,7 +1305,7 @@ public Object dirEntryGetName(Object dirEntryObj) {
13051305 @ ExportMessage
13061306 public static class DirEntryGetPath {
13071307 @ Specialization (guards = "endsWithSlash(scandirPath)" )
1308- static Buffer withSlash (@ SuppressWarnings ("unused" ) NFIPosixSupport receiver , DirEntry dirEntry , Object scandirPath ) {
1308+ static Buffer withSlash (@ SuppressWarnings ("unused" ) NativePosixSupport receiver , DirEntry dirEntry , Object scandirPath ) {
13091309 Buffer scandirPathBuffer = (Buffer ) scandirPath ;
13101310 int pathLen = scandirPathBuffer .data .length ;
13111311 int nameLen = (int ) dirEntry .name .length ;
@@ -1316,7 +1316,7 @@ static Buffer withSlash(@SuppressWarnings("unused") NFIPosixSupport receiver, Di
13161316 }
13171317
13181318 @ Specialization (guards = "!endsWithSlash(scandirPath)" )
1319- static Buffer withoutSlash (@ SuppressWarnings ("unused" ) NFIPosixSupport receiver , DirEntry dirEntry , Object scandirPath ) {
1319+ static Buffer withoutSlash (@ SuppressWarnings ("unused" ) NativePosixSupport receiver , DirEntry dirEntry , Object scandirPath ) {
13201320 Buffer scandirPathBuffer = (Buffer ) scandirPath ;
13211321 int pathLen = scandirPathBuffer .data .length ;
13221322 int nameLen = (int ) dirEntry .name .length ;
@@ -2627,7 +2627,7 @@ private TruffleString gai_strerror(Node inliningTarget, int errorCode, NativeMem
26272627 * }
26282628 * </pre>
26292629 *
2630- * To avoid multiple NFI calls, we transfer the data in batch using arrays of {@code int}s and
2630+ * To avoid multiple native calls, we transfer the data in batch using arrays of {@code int}s and
26312631 * {@code long}s - int values are stored in {@code intData}, the {@code ai_canonname} and
26322632 * {@code ai_next} pointers are stored in {@code longData} and the socket address pointed to by
26332633 * {@code ai_addr} is copied into Java byte array {@code socketAddress}. We also cache two
@@ -2647,16 +2647,16 @@ private static class AddrInfo {
26472647 private final long [] longData = new long [2 ];
26482648 private byte [] socketAddress ;
26492649
2650- private void update (long ptr , NFIPosixSupport nfiPosixSupport ) {
2651- socketAddress = new byte [(int ) nfiPosixSupport .getConstant (SIZEOF_STRUCT_SOCKADDR_STORAGE )];
2650+ private void update (long ptr , NativePosixSupport nativePosixSupport ) {
2651+ socketAddress = new byte [(int ) nativePosixSupport .getConstant (SIZEOF_STRUCT_SOCKADDR_STORAGE )];
26522652 long nativeIntData = NULLPTR ;
26532653 long nativeLongData = NULLPTR ;
26542654 long nativeSocketAddress = NULLPTR ;
26552655 try {
26562656 nativeIntData = NativeMemory .mallocIntArray (intData .length );
26572657 nativeLongData = NativeMemory .mallocLongArray (longData .length );
26582658 nativeSocketAddress = NativeMemory .mallocByteArray (socketAddress .length );
2659- int res = nfiPosixSupport .posixNativeFunctionInvoker .get_addrinfo_members (ptr , nativeIntData , nativeLongData , nativeSocketAddress );
2659+ int res = nativePosixSupport .posixNativeFunctionInvoker .get_addrinfo_members (ptr , nativeIntData , nativeLongData , nativeSocketAddress );
26602660 if (res != 0 ) {
26612661 throw shouldNotReachHere ("the length of ai_canonname does not fit into an int" );
26622662 }
@@ -2711,21 +2711,21 @@ long getNextPtr() {
27112711 @ ExportLibrary (AddrInfoCursorLibrary .class )
27122712 protected static class AddrInfoCursorImpl implements AddrInfoCursor {
27132713
2714- private final NFIPosixSupport nfiPosixSupport ;
2714+ private final NativePosixSupport nativePosixSupport ;
27152715 private long head ;
27162716 private AddrInfo info ;
27172717
2718- AddrInfoCursorImpl (NFIPosixSupport nfiPosixSupport , long head ) {
2719- this .nfiPosixSupport = nfiPosixSupport ;
2718+ AddrInfoCursorImpl (NativePosixSupport nativePosixSupport , long head ) {
2719+ this .nativePosixSupport = nativePosixSupport ;
27202720 this .head = head ;
27212721 info = new AddrInfo ();
2722- info .update (head , nfiPosixSupport );
2722+ info .update (head , nativePosixSupport );
27232723 }
27242724
27252725 @ ExportMessage
27262726 void release () {
27272727 checkReleased ();
2728- nfiPosixSupport .posixNativeFunctionInvoker .call_freeaddrinfo (head );
2728+ nativePosixSupport .posixNativeFunctionInvoker .call_freeaddrinfo (head );
27292729 head = 0 ;
27302730 }
27312731
@@ -2736,7 +2736,7 @@ boolean next() {
27362736 if (nextPtr == 0 ) {
27372737 return false ;
27382738 }
2739- info .update (nextPtr , nfiPosixSupport );
2739+ info .update (nextPtr , nativePosixSupport );
27402740 return true ;
27412741 }
27422742
@@ -2779,7 +2779,7 @@ Object getCanonName() {
27792779
27802780 @ ExportMessage
27812781 UniversalSockAddr getSockAddr () {
2782- UniversalSockAddrImpl addr = new UniversalSockAddrImpl (nfiPosixSupport );
2782+ UniversalSockAddrImpl addr = new UniversalSockAddrImpl (nativePosixSupport );
27832783 PythonUtils .arraycopy (info .socketAddress , 0 , addr .data , 0 , info .getAddrLen ());
27842784 addr .setFamily (info .getAddrFamily ());
27852785 addr .setLen (info .getAddrLen ());
@@ -2833,12 +2833,12 @@ UniversalSockAddr createUniversalSockAddrUnix(UnixSockAddr src) throws InvalidUn
28332833 @ ExportLibrary (UniversalSockAddrLibrary .class )
28342834 protected static class UniversalSockAddrImpl implements UniversalSockAddr {
28352835
2836- private final NFIPosixSupport nfiPosixSupport ;
2836+ private final NativePosixSupport nativePosixSupport ;
28372837 private final byte [] data ;
28382838 private int len = 0 ;
28392839
2840- UniversalSockAddrImpl (NFIPosixSupport nfiPosixSupport ) {
2841- this .nfiPosixSupport = nfiPosixSupport ;
2840+ UniversalSockAddrImpl (NativePosixSupport nativePosixSupport ) {
2841+ this .nativePosixSupport = nativePosixSupport ;
28422842 this .data = new byte [(int ) getConstant (SIZEOF_STRUCT_SOCKADDR_STORAGE )];
28432843 }
28442844
@@ -2924,8 +2924,8 @@ UnixSockAddr asUnixSockAddr() {
29242924 return new UnixSockAddr (pathBuf );
29252925 }
29262926
2927- long getConstant (NFIPosixConstants constant ) {
2928- return nfiPosixSupport .getConstant (constant );
2927+ long getConstant (NativePosixConstants constant ) {
2928+ return nativePosixSupport .getConstant (constant );
29292929 }
29302930
29312931 int getLen () {
0 commit comments