ffi library port to Windows (MSCV_X86_WIN32): notes
Enrico Migliore <[email protected]> Fri, 12 May 2006 12:26:38 +0200
| Newsgroups | gmane.comp.java.vm.sablevm.general |
|---|---|
| Organization | - |
| Message-ID | <[email protected]> |
Hi Etienne,
I just finished to compile on MSVC the C part of the ffi library. So,
the next step will be translating the win32.s (assembly for GCC) for MSVC
During this initial part of the work, I noticed the following things:
warings
--------
I'm working at warning level 4 and MSVC issues a few warnings which I'm
gonna fix later on.
config.h
--------
I'm porting an "instance" of the ffi library, based on a successful
build on Cigwin. By that I mean that I'm working on a source tree and a
config.h file, generated by ./configure on my PC. That means that some
macros of the config.h file might change on another PC.
alloca() function limitations
--------------------------
The ffi library makes use of the function: alloca(); I attach here what
MSVC says about it:
*_alloca* allocates /size/ bytes from the program stack. The allocated
space is automatically freed when the calling function exits. Therefore,
do not pass the pointer value returned by *_alloca* as an argument to
free <_crt_free.htm>.
There are restrictions to explicitly calling _*alloca* in an exception
handler (EH). EH routines that run on x86-class processors operate in
their own memory “frame”: They perform their tasks in memory space that
is not based on the current location of the stack pointer of the
enclosing function. The most common implementations include Windows NT
structured exception handling (SEH) and C++ catch clause expressions.
Therefore, explicitly calling _*alloca* in any of the following
scenarios results in program failure during the return to the calling EH
routine:
* Windows NT SEH exception filter expression: __*except* ( *alloca()* )
* Windows NT SEH final exception handler: __*finally* { *alloca()* }
* C++ EH catch clause expression
However, _*alloca* can be called directly from within an EH routine or
from an application-supplied callback that gets invoked by one of the EH
scenarios listed above
Enrico