Re: Extension to the FFI to allow macro expansions to be avoided

2004-04-16 Thread Fergus Henderson
On 15-Apr-2004, Sven Panne <[EMAIL PROTECTED]> wrote: > Fergus Henderson wrote: > >I'd rather fix GHC so that interfacing with C macros works with ghc -fasm. > >The equivalent works fine with the Mercury implementation ("mmc --target > >asm" > >gene

Re: Extension to the FFI to allow macro expansions to be avoided

2004-04-14 Thread Fergus Henderson
x27;t work! As the C standard says: |It is unspecified whether errno |is a macro or an identifier declared with external linkage. |If a macro definition is suppressed in order to access an |actual object ... the behavior is undefined. -

Re: Extension to the FFI to allow macro expansions to be avoided

2004-04-14 Thread Fergus Henderson
st by default. I'd rather fix GHC so that interfacing with C macros works with ghc -fasm. The equivalent works fine with the Mercury implementation ("mmc --target asm" generates assembler for the Mercury code and C stubs for the FFI glue), so it's clearly possible. -- Fergus Henders

Re: Extension to the FFI to allow macro expansions to be avoided

2004-04-14 Thread Fergus Henderson
Haskell implementations to do the same, even if this goes above and beyond the requirements standardized in the Haskell FFI report. -- Fergus Henderson| "I have always known that the pursuit | of excellence is a lethal habit" WWW:

Re: Extension to the FFI to allow macro expansions to be avoided

2004-04-14 Thread Fergus Henderson
quot;curses.h WINDOW" WINDOW Then ghc could generate C code which uses "WINDOW *" rather than "void *", and there would be no need to use parentheses or #undef to stop the macro being invoked. -- Fergus Henderson| "I have always

Re:

2003-12-02 Thread Fergus Henderson
nal. Cheers, Fergus. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp. _

Re: Handle to haskell data

2003-11-30 Thread Fergus Henderson
kell code (c/c++). I haven't tried it myself, but I think the answer is yes: use the StablePtr type, which in C is the HsStablePtr typedef in "HsFFI.h". -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 15

2003-11-12 Thread Fergus Henderson
6__, i.e. whose wchar_t values are represented using the encoding specified by ISO/IEC 10646? -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh

Re: More Finaliser Trouble

2003-07-14 Thread Fergus Henderson
t; Should there perhaps be something like ... > > newForeignPtrWithUserData :: Ptr a -> Ptr b -> FunPtr (Ptr a -> Ptr b -> IO > ()) -> IO (ForeignPtr a) > > ... where the second argument is a "userData" pointer that gets passed on > to the finalizer? IMHO yes! -- Fergus Hende

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Fergus Henderson
} else { *(CT *)&boxed_y = y; } return boxed_y; } Note that if compiling to C, such wrappers can be inlined. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Mel

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Fergus Henderson
ed using the FFI, of course. > > But the FFI lists the types that may be returned by a foreign function, > and T is not one of them. Ah, I see. > Are you suggesting we ought to be able to define new primitive types? I think it is at least worth considering. See my other message about h

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-03 Thread Fergus Henderson
t; with a builtin type is a different thing from what we're doing when we write: > > data T > > for some foreign type. Sure. In fact, the "data Int" declaration need not even be physically present; the implementation could just insert it in the Prelude automatically. (

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Fergus Henderson
On 02-Jun-2003, Simon Marlow <[EMAIL PROTECTED]> wrote: > > I can't see how to acquire a value of type T that isn't bottom. By calling a function defined using the FFI, of course. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pu

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 10

2003-06-02 Thread Fergus Henderson
ypes, of course. ghc has some complicated extension to the type system to deal with it, which makes examples like the one above type errors if T is an unboxed type. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of

Re: need help with ffi function pointers

2003-03-02 Thread Fergus Henderson
On 02-Mar-2003, Wolfgang Thaller <[EMAIL PROTECTED]> wrote: > >I have a C function: > > > >f_setCallback( void (funptr*) () ); That is a very bad design. You should change the interface of your C function to f_setCallback( void (funptr*) (void *), void * ); --

Re: Repeated hs_init()/hs_exit()

2003-01-28 Thread Fergus Henderson
ted. Sometimes standards should serve to advance the state of the art, rather than merely standardizing on the flaws of existing implementations, and I think this is one of those time.s -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of M

Re: Finalizers finalized

2003-01-21 Thread Fergus Henderson
On 22-Jan-2003, Manuel M T Chakravarty <[EMAIL PROTECTED]> wrote: > Finally, I am not sure whether we really want to allow that > `reallocBytes' may be used on `alloca'ed memory, which the > spec currently explicitly admits. I agree, allowing this is a bad idea. --

Re: Proposal: Pooled memory management

2003-01-20 Thread Fergus Henderson
ups (e.g. for the Pseudoknot benchmark, about a factor of two) from using pool-like memory management rather than the Boehm collector. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal h

Re: Proposal: Pooled memory management

2003-01-19 Thread Fergus Henderson
inishing the spec. ... > In particular, I don't want to add a largely untested > library. ... > So, I propose to add Pool to the portable libraries package, > but leave it out of the spec. I agree. I support the inclusion of this proposal in FFI v1.1 or v2.0, but let's ship v1

Re: Proposal: Pooled memory management

2003-01-18 Thread Fergus Henderson
ontains at least one bug: the lines pooledMallocArray0 pool size = pooledMallocArray0 pool (size + 1) ^ | | oops! should be pooledMallocArray0 pool size =

Re: alignment

2003-01-11 Thread Fergus Henderson
required to be 8-byte aligned. (This is something the C standard got wrong, IMHO.) -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh

Re: declaring C enum types

2002-10-17 Thread Fergus Henderson
t file format, name mangling, the usage of registers and stack, the sizes and representations of the basic types such as `int', struct padding, alignment, and so on. If two C compilers both support the same C ABI, then it is possible to mix code between them. -- Fergus Henderson <[EMAIL PROTECT

Re: declaring C enum types

2002-10-17 Thread Fergus Henderson
e of representing the values of all the members of the |enumeration. | Footnote 108: |An implementation may delay the choice of which integer |type until all enumeration constants have been seen. -- Fergus Henderson <[EMAIL PROTECTED]> | "I h

Re: declaring C enum types

2002-10-16 Thread Fergus Henderson
ow should enum values be declared in the FFI? -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh

Re: Finalizers strike back

2002-10-11 Thread Fergus Henderson
non-thread-safe". So you want to disallow non-thread-safe Haskell implementations from supporting the FFI? -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is a letha

Re: Updates to FFI spec

2002-08-12 Thread Fergus Henderson
#x27; options), yes, but the part of the name which goes in between the quotes or angle brackets in a #include line, no. They are part of the API. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is

Re: More on Ptr types

2002-07-22 Thread Fergus Henderson
tive machine representation, but pointers of type `char *', `signed char *', `unsigned char *', and `void *' need a different (and probably larger) representation, because they can point to bytes within a word. -- Fergus Henderson <[EM

Re: Type promotion in ccall arguments

2002-03-22 Thread Fergus Henderson
argument passing convention, but known-prototype functions can use a more efficient callee-pops convention. Some C compilers have taken advantage of this. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellenc

Re: FFI Report, CVS Id 1.5

2001-06-18 Thread Fergus Henderson
ace qualification; it's similar in some ways, but not quite the same. The closest .NET equivalent would be assembly qualification, which is written as "[mylib]foo" in ILASM and "foo,mylib" in ASP+ web.config files. So I suggest using the ILASM syntax, i.e. &qu

Re: FFI Report, CVS Id 1.5

2001-06-15 Thread Fergus Henderson
the C calling convention specify a "package name" rather > than a header file name. Thus > > foreign import ccall "wuggle::foo" foo :: Int -> Int > > rather than wuggle.h The main problem with that is that in general there will not be any relationshi

comments on FFI 1.4

2001-06-12 Thread Fergus Henderson
ted/, s/the language/the source language/ -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.

Re: Again: FFI syntax

2001-06-01 Thread Fergus Henderson
On 01-Jun-2001, Manuel M. T. Chakravarty <[EMAIL PROTECTED]> wrote: > Fergus Henderson <[EMAIL PROTECTED]> wrote, > > > I would be fine to say that some other name, e.g. `c', means that. > > But `ccall' already has an existing meaning, and it would be >

Re: Again: FFI syntax

2001-05-31 Thread Fergus Henderson
On 31-May-2001, Manuel M. T. Chakravarty <[EMAIL PROTECTED]> wrote: > Fergus Henderson <[EMAIL PROTECTED]> wrote, > > Making the semantics of a particular construct implementation-dependent is > > a good thing if the semantics that you want are implementation-dependent

Re: Again: FFI syntax

2001-05-29 Thread Fergus Henderson
he identical contained sequence (including > |characters, if any) from the original directive. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit | of excellence is a lethal habit" WWW: <http://ww

Re: Again: FFI syntax

2001-05-29 Thread Fergus Henderson
On 29-May-2001, Manuel M. T. Chakravarty <[EMAIL PROTECTED]> wrote: > Sven Panne <[EMAIL PROTECTED]> wrote, > > > Fergus Henderson wrote: > > > > > The calling convention should not necessarily default to 'ccall'. > > > That would no

Re: extent strings

2001-05-14 Thread Fergus Henderson
fi? This is useful for tools that parse Haskell source code but which are not compilers -- e.g. documentation generators. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit | of excellence is a lethal habit

Re: Again: FFI syntax

2001-05-13 Thread Fergus Henderson
7; The calling convention should not necessarily default to 'ccall'. That would not be appropriate for all implementations. Instead, I think the default calling convention should be implementation-dependent. Also, implementations should be allowed to provide calling conventions not on

CfP: Babel01 Workshop on Multi-Language Infrastructure and Interoperability

2001-03-22 Thread Fergus Henderson
TECTED]). PROGRAMME COMMITTEE Nick Benton (chair) Microsoft Research Fergus Henderson University of Melbourne Andrew Kennedy (organiser) Microsoft Research Greg Morrisett Cornell University Martin Odersky Ecole Polytechnique Federale de La

Re: unsafePerformIO and unsafeInterleaveIO

2001-03-19 Thread Fergus Henderson
a to document their semantics. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp. ___

Re: Modified proposal for default decls

2001-02-26 Thread Fergus Henderson
will want to support it. I also think that it would be nice to standardize on the syntax used to tell the compiler which include files are needed. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit | of excellence i

Re: Modified proposal for default decls

2001-02-26 Thread Fergus Henderson
d it either! The Mercury compiler has an attribute `will_not_call_mercury', which I believe is analagous to ghc's `unsafe' attribute. So ghc is not entirely alone here. (Furthermore, AFAIK these two instances evolved independently, rather than either being influenced by the other,

Re: Modified proposal for default decls

2001-02-26 Thread Fergus Henderson
foreign import ccall "gtk:foo" foo :: Int -> IO Int [...] > * The "gtk:foo" is a string in language-specific format >that uniquely specifies the thing being called. [...] > * The "gtk:" part is a concession to (b). It specifies a C package > from which >

Re: Summary of current change suggestions

2001-02-23 Thread Fergus Henderson
rt before the user's #includes. Another (probably better) alternative is to pass the `-ffixed-' option to gcc to reserve the registers. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit | of excellence is a lethal

Re: Summary of current change suggestions

2001-02-23 Thread Fergus Henderson
** __KERNEL__ to get sigcontext_struct from . */ #define __KERNEL__ #include #undef __KERNEL__ /* ** Some versions of Linux define it in , others define it in ** . We try both. */ #ifdef HAVE_ASM_SIGCONTEXT #include #endif #else #include #endif -- Fergus Henderson

Re: cpp

2001-02-23 Thread Fergus Henderson
out it being implemented in Haskell > > 2) Have any desire to spend half a day installing lots of Haskell-related tools >(greencard, c2hs, happy, etc.) on their machine before they can try out my > tool. Why not just distribute binaries for the platforms of interest? Or runhugs scr

Re: Typing f.e.d.

2001-02-12 Thread Fergus Henderson
ough I'm not sure which architectures > > this applies to. You don't need to know. It's clearly reasonable to have architectures on which pointers to code and pointers to data have different sizes. That's all you need to know. > AFAIK IA64. And MS-DOS. You're wron

Re: nhc98-1.{00,01} produce crashing programs

2001-01-07 Thread Fergus Henderson
ad for performance. On some systems that I've used (some version of DEC Ultrix, if I recall correctly), you had to be super-user to flush the instruction cache. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit |

Re: extended foreign decls

2001-01-03 Thread Fergus Henderson
On 03-Jan-2001, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > Wed, 3 Jan 2001 21:44:03 +1100, Fergus Henderson <[EMAIL PROTECTED]> pisze: > > > Personally I'd rather have a single well-designed convenient foreign > > language interface as

Re: extended foreign decls

2001-01-03 Thread Fergus Henderson
mpile via C. But I want inline C to be fast in the one that compiles via C, and I want inline Java to be fast in the Java back-end. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit | of excellence is a lethal habit"

Re: extended foreign decls

2001-01-03 Thread Fergus Henderson
ement the other FFI constructs that don't involve inline foreign code in such a way that if you don't use inline foreign code, you don't need a foreign language compiler. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pu

Re: freeHaskellFunctionPtr

2001-01-03 Thread Fergus Henderson
On 03-Jan-2001, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > Wed, 3 Jan 2001 21:12:54 +1100, Fergus Henderson <[EMAIL PROTECTED]> pisze: > > > Well, if they are left, then at very least they should be > > very clearly documented as being non

Re: extended foreign decls

2001-01-03 Thread Fergus Henderson
On 02-Jan-2001, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > Tue, 2 Jan 2001 22:28:02 +1100, Fergus Henderson <[EMAIL PROTECTED]> pisze: > > > Doing it in a separate tool will lose efficiency in some important > > cases. If the compile

Re: freeHaskellFunctionPtr

2001-01-03 Thread Fergus Henderson
inter > or a real data pointer to a function, together with an enumeration > value indicating which one is this. Ugly, but that's life. > > Another example is dlopen. I think you mean dlsym(). -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known t

Re: extended foreign decls

2001-01-03 Thread Fergus Henderson
version depending on which target language you are compiling to. For those who are not fans of polyglot-style obfuscated programs, (a) generally only works in the case of languages which are syntactically quite similar, such as C and C++, where you can easily write code that is in the intersect

Re: freeHaskellFunctionPtr

2001-01-02 Thread Fergus Henderson
tee that a data pointer will fit in a function pointer or vice versa. If you want something that could be either a data pointer or a function pointer, you need to use a union: union { void *data; void (*func)(void); } -- Fergus Henderson <[EMAIL PROT

Re: extended foreign decls

2001-01-02 Thread Fergus Henderson
inline C code directly in the generated code, and thus get inlining. But I think a separate tool would have to put the C code in a separate C file, which would prevent inlining. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit

Re: freeHaskellFunctionPtr

2001-01-02 Thread Fergus Henderson
function pointers are the same size as data pointers, and so I'd be somewhat surprised if they've really done that.) -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit | of excellence is a lethal habit&q

Re: Proposal #2: marshalling utilites

2000-12-06 Thread Fergus Henderson
ead object, which gets copied > in after every foreign call. Anyone have any bright ideas here? Well, you could have a private errno in each Haskell thread object, which gets copied in at every Haskell thread switch... -- Fergus Henderson <[EMAIL PROTECTED]> |

Re: efficiency

2000-12-04 Thread Fergus Henderson
the initial try, and if it doesn't fit then switch to using malloc()/realloc(). At the end, you can check whether the final buffer pointer is equal to the original fixed-size static or alloca()'ed buffer, and only free it if it is not. Or you can keep a separ

Re: errno again

2000-12-01 Thread Fergus Henderson
possible to have the second kind from the level of the >Haskell compiler at all (done in an sufficiently elegant way to >think about it as a candidate proposal for the official FFI)? I think so. I certainly consider the mechanism that Mercury uses to be elegant enough to be the officia

Re: qforeign-0.62

2000-11-28 Thread Fergus Henderson
e functions are called or where they live, as long as we have them! > > Admittedly the functions above are C-specific and should probably go > into a C-specific library on top of Foreign. CForeign anyone? These are not C-specific, they are POSIX-specific. As evidence that they are not

Re: References to values and weak references.

2000-11-08 Thread Fergus Henderson
e docs. In GNU C: extern int foo __attribute__((weak)); int main() { printf("%p", &foo); } This is documented in the gcc info pages. In GNU as: .weak foo -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known tha

Re: FFI and type classes / polymorphism

2000-08-01 Thread Fergus Henderson
can call existentially typed Mercury procedures to obtain dictionaries, and can then pass those dictionaries to polymorphic Mercury procedures. On 31-Jul-2000, Marcin 'Qrczak' Kowalczyk <[EMAIL PROTECTED]> wrote: > How would you use such function in C? C does not support polymorph