Compare commits

...
406 Commits
Author SHA1 Message Date
nobody 9a80f7e781 This commit was manufactured by cvs2svn to create tag 'MONO_0_6'.
svn path=/tags/MONO_0_6/mono/; revision=572
2001-08-22 21:26:35 +00:00
Nick Drochak a026988bb8 2001-08-23 Nick Drochak <[email protected]>
* ccvs: added '-Pd' to the cvs update command with an explanation

svn path=/trunk/mono/; revision=571
2001-08-22 21:26:35 +00:00
Bob Smith 409bb35a33 LiteralControl implemented, and HtmlContainerControl bugfixed.
svn path=/trunk/mcs/; revision=570
2001-08-22 19:46:35 +00:00
Nick Drochak 95af7dd69b 2001-08-21 Nick Drochak <[email protected]>
* Added ChangeLog file

svn path=/trunk/mcs/; revision=569
2001-08-22 19:08:09 +00:00
Miguel de Icaza 9e93720b51 2001-08-22 Miguel de Icaza <[email protected]>
* interp.c (usage): Add version information

svn path=/trunk/mono/; revision=568
2001-08-22 18:35:19 +00:00
Miguel de Icaza 52c2071e89 2001-08-22 Miguel de Icaza <[email protected]>
* interp.c (ves_pinvoke_method): Typo fix.

svn path=/trunk/mono/; revision=567
2001-08-22 18:33:16 +00:00
Bob Smith 75becf30e1 Updated class.xml
svn path=/trunk/mono/; revision=566
2001-08-22 16:17:45 +00:00
Bob Smith f417e9e65d More implementations.
svn path=/trunk/mcs/; revision=565
2001-08-22 16:07:36 +00:00
Paolo Molaro 4d0be295fa Wed Aug 22 20:37:51 CEST 2001 Paolo Molaro <[email protected]>
* interp.c: simplified init_class (). Make sure a class
	is fully initialized before executing a method in the class.
	Search for the class constructor only on beforefieldinit classes.
	Implement a bunch of opcodes: br, brfalse, brtrue, beq, bge,
	bgt, blt, ble, bne.un, bge.un, bgt.un, ble.un, blt.un, stind.i,
	ldflda, ldsflda, ldelem.i8, stelem.i8, leave.

svn path=/trunk/mono/; revision=564
2001-08-22 14:44:45 +00:00
John Barnette cc59b1d1d6 Updated StringDictionary entry.
svn path=/trunk/mono/; revision=563
2001-08-22 13:39:49 +00:00
John Barnette 448f93455a Vanity commit: added self to AUTHORS.
svn path=/trunk/mcs/; revision=562
2001-08-22 13:37:42 +00:00
John Barnette d07c387db5 Initial add of StringDictionary.
svn path=/trunk/mcs/; revision=561
2001-08-22 13:36:27 +00:00
Miguel de Icaza cfc72f5639 Rename Windoze.cs to Windows.cs
svn path=/trunk/mcs/; revision=560
2001-08-22 11:50:46 +00:00
Paolo Molaro c5922f55ad Wed Aug 22 16:27:30 CEST 2001 Paolo Molaro <[email protected]>
* metadata.c, loader.h, loader.c, image.h, image.c, class.h, class.c:
	MonoClass now has the name and name_space fields.
	MonoMethod has a pointer to its MonoClass, instead of MonoImage.
	mono_get_method () takes and optional MonoClass as argument.
	Removed mono_typedef_from_name() and added mono_class_token_from_name()
	instead that takes advantage of a map from class names to typedef
	tokens in MonoImage.


Wed Aug 22 16:34:03 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: Updates for changes in metadata/. Better output in debug mode
	and in the stack trace. Completed rethrow handling

svn path=/trunk/mono/; revision=559
2001-08-22 10:38:20 +00:00
Paolo Molaro 9913163486 Wed Aug 22 16:22:22 CEST 2001 Paolo Molaro <[email protected]>
* dis-cil.c: add a newline after branch instructions. Move
	end of exception handler code at the end.

svn path=/trunk/mono/; revision=558
2001-08-22 10:27:23 +00:00
Jim Richardson b2921f3b60 Corrected a compilation issue in Environment.cs and added it to common.src
svn path=/trunk/mcs/; revision=557
2001-08-22 09:24:48 +00:00
Jim Richardson d937d1508e Added PlatformID.cs and OperatingSystem.cs to common.src
svn path=/trunk/mcs/; revision=556
2001-08-22 09:10:05 +00:00
Jim Richardson e24740f7ec Implemented additional functionality.
Verified compilation.
Added to appropriate .src files.

svn path=/trunk/mcs/; revision=555
2001-08-22 08:44:07 +00:00
Jim Richardson 3a88605c0e Created a namespace System.Private.PlatformSpecific.
Added implementations in Unix.cs and Windows.cs for retrieving
environment variables in a platform specific manner.
Implementations are called from Environment.cs

svn path=/trunk/mcs/; revision=554
2001-08-22 08:41:45 +00:00
Jim Richardson 40055a32f4 Corrected some minor issues that were preventing compilation.
svn path=/trunk/mcs/; revision=553
2001-08-22 07:56:24 +00:00
Sergey Chaban b4fcf4f94a Lots of changes, it was basically rewritten from scratch.
svn path=/trunk/mcs/; revision=552
2001-08-22 06:25:23 +00:00
John Barnette f0cc7693e1 Updated entries for ListDictionary and StringCollection.
svn path=/trunk/mono/; revision=551
2001-08-22 02:25:09 +00:00
John Barnette bac0f8e2f8 Initial add of ListDictionary.
svn path=/trunk/mcs/; revision=550
2001-08-22 02:18:15 +00:00
John Barnette 10968ac70e Initial implementation of ListDictionary.
svn path=/trunk/mcs/; revision=549
2001-08-22 02:17:16 +00:00
Miguel de Icaza 6e429b89e5 Fix xml
svn path=/trunk/mono/; revision=548
2001-08-21 23:47:10 +00:00
Miguel de Icaza 0e0f2c05ea Add Chris classes
svn path=/trunk/mono/; revision=547
2001-08-21 23:41:58 +00:00
Miguel de Icaza c7d8b7633c Add Chris to the maintainers list
svn path=/trunk/mono/; revision=546
2001-08-21 23:39:01 +00:00
Miguel de Icaza c868a9d062 Add System.Configuration classes from Chris Podurgiel
svn path=/trunk/mcs/; revision=545
2001-08-21 23:37:54 +00:00
Miguel de Icaza 4d8197f95c 2001-08-21 Miguel de Icaza <[email protected]>
* class.cs (TypeContainer::Populate): Drop RootContext from the
	argument.

	(Constructor::CallingConvention): Returns the calling convention.
	(Constructor::ParameterTypes): Returns the constructor parameter
	types.

	(TypeContainer::AddConstructor): Keep track of default constructor
	and the default static constructor.

	(Constructor::) Another class that starts using `public readonly'
	instead of properties.

	(Constructor::IsDefault): Whether this is a default constructor.

	(Field::) use readonly public fields instead of properties also.

	(TypeContainer::TypeAttr, TypeContainer::AddConstructor): Keep
	track of static constructors;  If none is used, turn on
	BeforeFieldInit in the TypeAttributes.

	* cs-parser.jay (opt_argument_list): now the return can be null
	for the cases where there are no arguments.

	(constructor_declarator): If there is no implicit `base' or
	`this', then invoke the default parent constructor.

	* modifiers.cs (MethodAttr): New static function maps a set of
	modifiers flags into a MethodAttributes enum
	(FieldAttr): renamed from `Map'.  So now we have FieldAttr,
	MethodAttr, TypeAttr to represent the various mappings where the
	modifiers are used.
	(FieldAttr): Map also `readonly' to `FieldAttributes.InitOnly'

svn path=/trunk/mcs/; revision=544
2001-08-21 23:17:19 +00:00
Bob Smith 94e5d7320c Added more notes for later use.
svn path=/trunk/mcs/; revision=543
2001-08-21 15:55:20 +00:00
Dietmar Maurer b87a157b27 replaced mono-int with mint, disable debugging mode
svn path=/trunk/mono/; revision=542
2001-08-21 13:55:45 +00:00
Dietmar Maurer 62ddcbd7f5 added mint to cvsignore
svn path=/trunk/mono/; revision=541
2001-08-21 13:49:29 +00:00
Dietmar Maurer b275833dd4 added some documentation
svn path=/trunk/mono/; revision=540
2001-08-21 13:48:09 +00:00
Paolo Molaro 52195d8136 Tue Aug 21 18:54:06 CEST 2001 Paolo Molaro <[email protected]>
* mono/tests/exceptions*: enhanced and added more tests for
	exceptions.


Tue Aug 21 18:54:58 CEST 2001 Paolo Molaro <[email protected]>

	* metadata.c: zero is not a valid alignment boundary.
	Merge MONO_TYPE_VOID in default decoding code.


Tue Aug 21 18:56:19 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: new macro INIT_FRAME() to properly
	initialize a MonoInvocation. Fixed a couple of buglets in exception code:
	increase stack pointer when pushing the exception for catch blocks,
	initialize frame->ex_handler to NULL, correctly try all the
	catch blocks (don't incorrectly fallback on filter handling).
	Added a couple more checks where we may need to throw an
	exception. Added more exception creation functions.
	Changed stackval_from_data() to take the target stackval as
	argument. Implemented a couple more opcodes.
	* interp.h: prepare stackval for value type code.

svn path=/trunk/mono/; revision=539
2001-08-21 13:13:44 +00:00
Paolo Molaro 629b052e6a Tue Aug 21 18:51:05 CEST 2001 Paolo Molaro <[email protected]>
* dis-cil.c: correctly print the label for multi-byte opcodes.

svn path=/trunk/mono/; revision=538
2001-08-21 12:52:58 +00:00
Miguel de Icaza dba26a4e11 oops, fix web site
svn path=/trunk/mono/; revision=537
2001-08-21 12:47:34 +00:00
Miguel de Icaza 8bded4344d 2001-08-21 Miguel de Icaza <[email protected]>
* Makefile.am (mint_LDADD): Renamed interpreter to mint.

svn path=/trunk/mono/; revision=536
2001-08-21 12:08:49 +00:00
Dietmar Maurer d38dd14b24 2001-08-21 Dietmar Maurer <[email protected]>
* image.h: merged MonoMetadata into MonoImage

svn path=/trunk/mono/; revision=535
2001-08-21 09:39:08 +00:00
Mike Kestner 218c01c7ee Removed duplicate class nodes I accidentally committed.
svn path=/trunk/mono/; revision=534
2001-08-21 09:00:13 +00:00
Dietmar Maurer ec61ac002c removed some unused code
svn path=/trunk/mono/; revision=533
2001-08-21 04:10:23 +00:00
Dietmar Maurer f28fe3bcc3 * class.h: cleanup of MonoArrayClass, use a MonoClass pointer to
identify the type of elements.
* interp.c (get_named_exception): use the right constructor.

svn path=/trunk/mono/; revision=532
2001-08-21 03:58:11 +00:00
Nick Drochak 479b9d7c4d 2001-08-21 Nick Drochak <[email protected]>
* class.xml : made myself maintainer of System.Diagnostics.DebuggableAttribute

svn path=/trunk/mono/; revision=531
2001-08-21 03:11:20 +00:00
Dietmar Maurer bef5110c2a added ltconfig to .cvsignore
svn path=/trunk/mono/; revision=530
2001-08-21 02:54:06 +00:00
Dietmar Maurer 726d99ab5b merged the cli and metadata directories - everything is now in metadata
svn path=/trunk/mono/; revision=529
2001-08-21 02:51:33 +00:00
Miguel de Icaza 18667dfc0d Added .cvsinogre
svn path=/trunk/mono/; revision=528
2001-08-20 23:41:53 +00:00
Miguel de Icaza 11e62b9394 2001-08-20 Miguel de Icaza <[email protected]>
* mono/Makefile.am (SUBDIRS): Remove `test' from here to allow us
	to pass make distcheck

	* mono/wrapper/Makefile.am (EXTRA_DIST): Include genwrapper.pl

	* configure.in, Makefile.am, runtime/Makefile.am (dist-hook,
	install-data-hook): Added mechanism to distribute and install the
	dll files.

svn path=/trunk/mono/; revision=527
2001-08-20 23:41:34 +00:00
Miguel de Icaza a8d6eb7e1a Unify, need to fix the whole biuld process
svn path=/trunk/mcs/; revision=526
2001-08-20 22:25:34 +00:00
Miguel de Icaza 1347f6ddb2 Add new src files
svn path=/trunk/mcs/; revision=525
2001-08-20 22:18:35 +00:00
Miguel de Icaza eaeb89ee36 Make compilation work with windows target, we do not need the 'monolib2' target
svn path=/trunk/mcs/; revision=524
2001-08-20 22:17:59 +00:00
Miguel de Icaza 6fe5a311b2 Updated the contributing section
svn path=/trunk/mono/; revision=523
2001-08-20 20:48:33 +00:00
Bob Smith 134538f13a Control.cs: More implementation.
svn path=/trunk/mcs/; revision=522
2001-08-20 20:24:35 +00:00
Miguel de Icaza e55403fded Update
svn path=/trunk/mono/; revision=521
2001-08-20 20:04:31 +00:00
Miguel de Icaza 07e948ecc5 Add contribution from Leen Toelen
svn path=/trunk/mcs/; revision=520
2001-08-20 20:02:39 +00:00
Miguel de Icaza 58ac87646c Mention the compilation service
svn path=/trunk/mono/; revision=519
2001-08-20 19:59:22 +00:00
Nick Drochak 035d611f13 2001-08-21 Nick Drochak <[email protected]>
* Implemented ConditionalAttribute.cs and DebuggableAttribute.cs
	* Forgot to cvs add them before I commited (cvs-newbie error, sorry)

svn path=/trunk/mcs/; revision=518
2001-08-20 19:26:43 +00:00
Miguel de Icaza bdba3c13a8 Add tools to the biuld process
svn path=/trunk/mcs/; revision=517
2001-08-20 17:30:51 +00:00
Miguel de Icaza 83c29547ee Add copyright information
svn path=/trunk/mcs/; revision=516
2001-08-20 17:29:19 +00:00
Miguel de Icaza 2e28ca97ee Add Serge's verifier
svn path=/trunk/mcs/; revision=515
2001-08-20 17:26:38 +00:00
Miguel de Icaza 6fa717e133 Updated contributions
svn path=/trunk/mono/; revision=514
2001-08-20 15:35:06 +00:00
Miguel de Icaza c634df75a3 Add System.Web to the make process
Flush my changes to Component.cs
Update mono.src
Fix compiler report.cs class

svn path=/trunk/mcs/; revision=513
2001-08-20 14:57:40 +00:00
Dietmar Maurer 2f4757bcb8 fixes to make it compile again
svn path=/trunk/mcs/; revision=512
2001-08-20 14:20:16 +00:00
Paolo Molaro cfd0ebeef7 Mon Aug 20 19:33:34 CEST 2001 Paolo Molaro <[email protected]>
* util.c: add a space when decoding multiple flags.
	* dump.c, dump.h, main.c: decode the property map and
	methodsemantics tables. Disassemble property information
	to .property IL directives.
	* get.c: allow passing a NULL as method in dis_stringify_method ()
	if a methoddef_row is given.

Mon Aug 20 19:39:00 CEST 2001 Paolo Molaro <[email protected]>

	* blob.h: fix MONO_TYPE_TYPEDBYREF value.
	* cil-coff.h: split MonoMSDOSHeader and add size info.
	* image.c: add some consistency checks.
	* metadata.c: fix row size computation: one programmer
	error and one LAMESPEC. Handle MONO_TYPE_TYPEDBYREF.
	add explanation for the locator routine.
	Fix decoding of size in method header.

svn path=/trunk/mono/; revision=511
2001-08-20 13:46:59 +00:00
Miguel de Icaza 74efe882e5 2001-08-20 Miguel de Icaza <[email protected]>
* assembly.c 	(g_concat_dir_and_file): Use _S for string concat.

svn path=/trunk/mono/; revision=510
2001-08-20 13:37:31 +00:00
Miguel de Icaza 4364c7cdf2 Compilation fixes
svn path=/trunk/mcs/; revision=509
2001-08-20 13:31:12 +00:00
Miguel de Icaza c804653371 2001-08-20 Miguel de Icaza <[email protected]>
* assembly.c (g_concat_dir_and_file): Bring g_concat_dir_and_file
	function from gnome-libs.  This uses the right path separator
	based on the OS, and also works around a bug in some systems where
	a double slash is not allowed.
	(default_assembly_name_resolver): Use g_concat_dir_and_file
	(mono_assembly_open): ditto.

svn path=/trunk/mono/; revision=508
2001-08-20 13:26:33 +00:00
Miguel de Icaza 06d27b1891 More web site updates
svn path=/trunk/mono/; revision=507
2001-08-20 13:26:07 +00:00
Paolo Molaro f5e5dd46bc Mon Aug 20 18:58:36 CEST 2001 Paolo Molaro <[email protected]>
* interp.c: fix buglet with the leave.s opcode.

svn path=/trunk/mono/; revision=506
2001-08-20 13:00:33 +00:00
Nick Drochak 77567f5ddd 2001-08-21 Nick Drochak <[email protected]>
* Added DebuggableAttribute.cs and ConditionalAttribute.cs to compile list

svn path=/trunk/mcs/; revision=505
2001-08-20 12:02:44 +00:00
Nick Drochak f201bea041 2001-08-21 Nick Drochak <[email protected]>
* Component.cs: Eliminated compile errors by removing redundant fields and
        using the ISite member instead.  Also raised the Disposed event, but not
        sure if it's correct now.  Look for FIXME in the comments.

svn path=/trunk/mcs/; revision=504
2001-08-20 11:32:49 +00:00
Dietmar Maurer 6bf6ad75d1 2001-08-20 Dietmar Maurer <[email protected]>
* object.c (mono_new_string): impl.

	* loader.c (mono_init): impl.

	* object.c (mono_new_utf16_string): impl.

svn path=/trunk/mono/; revision=503
2001-08-20 10:10:04 +00:00
Dietmar Maurer 00938302f3 2001-08-20 Dietmar Maurer <[email protected]>
* mono/tests/stream.cs: new tests for the Stream class

        * configure.in: I really need LIBTOOL for libmonowrapper.so, so I
        added it again.

        * class.h: replaced 'struct MonoMethod' with 'MonoMethod'

        * cli.h: removed #include <mono/cli/object.h>

        * icall.c: changed everything to support the new calling convention

        * hacks.h: added some macros for FreeBSD

        * interp.c (get_named_exception): use mono_object_new instead of
        newobj, initialize the stack before we call the constructor.

        * metadata.c (mono_metadata_signature_equal): impl.

        * *: void is now a realy MonoType (instead of using NULL)

        * metadata.c (do_mono_metadata_parse_type): use
        mono_metadata_parse_type to parse void value.

svn path=/trunk/mono/; revision=502
2001-08-20 08:52:40 +00:00
Dietmar Maurer a9cb3de8c9 added UnixWrapper, FileStream and Stream Class + various fixes
svn path=/trunk/mcs/; revision=501
2001-08-20 08:14:36 +00:00
Sergey Chaban 9d380f37af DES classes update.
svn path=/trunk/mcs/; revision=500
2001-08-20 08:02:20 +00:00
Sergey Chaban 265702cfc0 Added PKCS-5 padding.
svn path=/trunk/mcs/; revision=499
2001-08-20 08:00:13 +00:00
Sergey Chaban 12d2fc51c5 Encryption core is approximately 30% faster than previous version.
svn path=/trunk/mcs/; revision=498
2001-08-20 07:58:31 +00:00
Miguel de Icaza f16d84213a Update class.xml
svn path=/trunk/mono/; revision=497
2001-08-19 23:06:15 +00:00
Miguel de Icaza 2e36329273 2001-08-19 Miguel de Icaza <[email protected]>
* parameter.cs (GetParameterInfo): Fix bug where there would be no
	method arguments.

	* interface.cs (PopulateIndexer): Implemented the code generator

svn path=/trunk/mcs/; revision=496
2001-08-19 22:59:53 +00:00
Miguel de Icaza 469ec11c7b Add more tests for the compiler
svn path=/trunk/mcs/; revision=495
2001-08-19 22:59:25 +00:00
Miguel de Icaza 8879961456 Add a couple of attributes -miguel
svn path=/trunk/mcs/; revision=494
2001-08-19 22:59:11 +00:00
Paolo Molaro 607997cab6 Sat Aug 18 12:40:32 CEST 2001 Paolo Molaro <[email protected]>
* x86/x86-codegen.h: fix a couple of buglets and add x86_regp_emit().

Sat Aug 18 12:42:26 CEST 2001 Paolo Molaro <[email protected]>

	* class.c, class.h: load also the methods when loading a class.

Sat Aug 18 12:43:38 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c, interp.h: added support code to create exceptions.
	Changed interncal calling convnetion over to MonoInvocation, to support
	exceptions, walking the stack back and forward and passing the 'this'
	pointer separately (remove the cludges required before to pass this on the
	stack). Use alloca heavily for both local vars and a copy of the incoming
	arguments. Init local vars to zero.
	Simplify stackval_from_data() and stackval_to_data() to only take a pointer
	instead of pointer + offset.
	Implement a few exceptions-related opcodes and the code to run finally, fault and
	catch blocks as well as a stack trace if no handler is found.

Sat Aug 18 12:51:28 CEST 2001 Paolo Molaro <[email protected]>

	* metadata.c, metadata.h: in the signature and method header store
	only the space required for holding the loca vars and incoming arguments.

svn path=/trunk/mono/; revision=493
2001-08-18 06:55:29 +00:00
Paolo Molaro ea934d2234 Sat Aug 18 11:24:07 CEST 2001 Paolo Molaro <[email protected]>
* dump.c, get.c, get.h, main.c: dis_stringify_method_signature()
	gets an optional methodef_row index instead of a name, so it
	can figure out also the names and attributes of params.
	parse_method_signature() and free_method_signature() removed as
	they are useless now.

svn path=/trunk/mono/; revision=492
2001-08-18 05:38:22 +00:00
Mike Kestner b95a8a8c90 Mark the implementation status as complete for Point, PointF, Size, and SizeF
in System.Drawing.

svn path=/trunk/mono/; revision=491
2001-08-17 17:27:06 +00:00
Mike Kestner bd02735dae Added the PointF, Size, and SizeF structures to System.Drawing.
svn path=/trunk/mcs/; revision=490
2001-08-17 17:19:15 +00:00
Bob Smith b043d30366 Took ownership of System.Web.UI.Control
svn path=/trunk/mono/; revision=489
2001-08-17 15:36:22 +00:00
Bob Smith d2688d7fc5 Started work on System.Web.UI.Control
svn path=/trunk/mcs/; revision=488
2001-08-17 15:30:43 +00:00
Miguel de Icaza 11d450f1e0 2001-08-17 Miguel de Icaza <[email protected]>
* interface.cs (InterfaceMemberBase): Now we track the new status
	here.

	(PopulateProperty): Implement property population.  Woohoo!  Got
	Methods and Properties going today.

	Removed all the properties for interfaces, and replaced them with
	`public readonly' fields.

svn path=/trunk/mcs/; revision=487
2001-08-17 04:06:44 +00:00
Alex Graveley 4cfb23b911 Add fficonfig.h
svn path=/trunk/mono/; revision=486
2001-08-16 20:10:17 +00:00
Alex Graveley 9bf5b00931 2001-08-16 Alex Graveley <[email protected]>
* configure.in: Replace AM_PROG_LIBTOOL with AC_PROG_RANLIB. This
	removes libtool dependency on all of Mono.

svn path=/trunk/mono/; revision=485
2001-08-16 20:09:33 +00:00
Alex Graveley 04453aac7f Add .cvsignore files
svn path=/trunk/mono/; revision=484
2001-08-16 18:40:40 +00:00
Alex Graveley b31adbaf59 2001-08-16 Alex Graveley <[email protected]>
* libffi/include/fficonfig.h: Remove as this is auto generated.

	* Makefile.am: Only generate libffi.a.

	* configure.in: replace A[CM]_PROG_LIBTOOL with AC_PROG_RANLIB.

2001-08-16  Alex Graveley  <[email protected]>

	* Makefile.am (mono_int_LDADD): Link with ../../libffi/libffi.a
	instead of ../../libffi/.libs/libffi.a.

svn path=/trunk/mono/; revision=483
2001-08-16 18:20:02 +00:00
Bob Smith 756e79f366 Bug fixes.
svn path=/trunk/mcs/; revision=482
2001-08-16 14:39:49 +00:00
Miguel de Icaza 5c19abc1c6 Update errors listing
svn path=/trunk/mcs/; revision=481
2001-08-16 13:57:05 +00:00
Nick Drochak 98b88b5cc5 2001-08-16 Nick Drochak <[email protected]>
* Added myself as maintainer of System.Attribute which is 95% done.

	* Made myself maintainer of System.ConditionalAttribute

svn path=/trunk/mono/; revision=480
2001-08-16 13:22:36 +00:00
Nick Drochak 10444ba7ba 2001-08-16 Nick Drochak <[email protected]>
* Attribute.cs: implemented all methods except GetHashCode()

	* common.src: added Attribute.cs so it would compile in

svn path=/trunk/mcs/; revision=479
2001-08-16 13:20:02 +00:00
Mike Kestner bf8172a6c0 Add the System.Drawing.Point struct implementation a fix a buglet in the
System.Drawing makefile.

svn path=/trunk/mcs/; revision=478
2001-08-16 12:42:08 +00:00
Miguel de Icaza beeee0059e More work
svn path=/trunk/mcs/; revision=477
2001-08-15 19:56:19 +00:00
Jim Richardson fa145bef84 Added stubbed implementations for classes.
svn path=/trunk/mcs/; revision=476
2001-08-14 02:30:47 +00:00
Jim Richardson a6ea9689dc Moved PlatformID enum from OperatingSystem.cs to PlatformID.cs
svn path=/trunk/mcs/; revision=475
2001-08-14 02:28:00 +00:00
Jim Richardson 6544d50ab1 Updated status of System.IO.Path. Entered System.IO.Directory and assigned
maintainer as myself as Path and Directory are quite complimentary.

svn path=/trunk/mono/; revision=474
2001-08-13 23:38:59 +00:00
Jim Richardson cb23450a88 Corrected a couple of minor typos.
svn path=/trunk/mcs/; revision=473
2001-08-13 23:28:30 +00:00
Bob Smith 0cf1dc9018 Compile fixes.
svn path=/trunk/mcs/; revision=472
2001-08-13 14:33:01 +00:00
Marcin Szczepanski e8302e6cfd Updated for System.IO.Path + updated Jim Richardson's email address to his
preferred one.

svn path=/trunk/mono/; revision=471
2001-08-13 05:13:50 +00:00
Marcin Szczepanski ee466ce369 System.IO.Path implementation from Jim Richardson
svn path=/trunk/mcs/; revision=470
2001-08-13 05:09:03 +00:00
Miguel de Icaza 00545ed9d2 2001-08-11 Miguel de Icaza <[email protected]>
* class.cs (MakeConstant): Code to define constants.

	* rootcontext.cs (LookupType): New function.  Used to locate types

svn path=/trunk/mcs/; revision=469
2001-08-13 01:40:19 +00:00
Miguel de Icaza b03eee1c99 Updated
svn path=/trunk/mono/; revision=468
2001-08-12 20:15:38 +00:00
Miguel de Icaza 83a5933975 Added Stub implementations of Environment and OperatingSystem from Jim Richardson
svn path=/trunk/mcs/; revision=467
2001-08-12 20:09:53 +00:00
Derek Holden 43f5873521 initial checkin
svn path=/trunk/mcs/; revision=466
2001-08-12 16:32:12 +00:00
Mike Kestner e7524be356 2001-08-10 Mike Kestner <[email protected]>
* mono/status/class.xml : Added System.Drawing structs.

svn path=/trunk/mono/; revision=465
2001-08-10 23:32:38 +00:00
Bob Smith ba55af6fc1 Notes added.
svn path=/trunk/mcs/; revision=464
2001-08-10 20:45:21 +00:00
Dietmar Maurer a8e168b8ef * object.c (mono_object_clone): impl.
* interp.c (ves_exec_method): impl CASTCLASS

* implemented System.Object::MemberwiseClone

svn path=/trunk/mono/; revision=463
2001-08-10 09:08:14 +00:00
Dietmar Maurer 46b1d4a334 *** empty log message ***
svn path=/trunk/mcs/; revision=462
2001-08-10 08:32:01 +00:00
Dietmar Maurer b02148f4ac * Object.cs: changed MemberWiseClone to MemberwiseClone, and
marked it as InternalCall

svn path=/trunk/mcs/; revision=461
2001-08-10 08:30:33 +00:00
Dietmar Maurer d67614986b 2001-08-10 Dietmar Maurer <[email protected]>
* Object.cs: changed MemberWiseClone to MemberwiseClone

svn path=/trunk/mcs/; revision=460
2001-08-10 08:28:33 +00:00
Dietmar Maurer a02f49ec02 2001-08-10 Dietmar Maurer <[email protected]>
* icall.c: moved the internal call stuff to this file

svn path=/trunk/mono/; revision=459
2001-08-10 08:24:23 +00:00
Dietmar Maurer 5112ab77f7 2001-08-10 Dietmar Maurer <[email protected]>
* common.src: removed UriFormatException.cs because the file is
	not there.

	* RuntimeTypeHandle.cs: replaced IntrPtr with IntPtr
	* Char.cs: replaced byte with char

	* Array.cs: make it work with the mono interpreter

svn path=/trunk/mcs/; revision=458
2001-08-10 07:03:40 +00:00
Dietmar Maurer a1dc393e45 *** empty log message ***
svn path=/trunk/mono/; revision=457
2001-08-10 05:25:17 +00:00
Dietmar Maurer 2d1589a995 2001-08-10 Dietmar Maurer <[email protected]>
* interp.c (ves_exec_method): impl. BOX/UNBOX
	(ves_icall_System_Array_GetValue): impl.
	(ves_icall_System_Array_SetValue): impl.

	* mono/tests/array.cs: more array tests

svn path=/trunk/mono/; revision=456
2001-08-10 05:24:01 +00:00
Miguel de Icaza c1753262d5 Added new version of TimeSpan from Duco Fijma
svn path=/trunk/mcs/; revision=455
2001-08-10 00:07:02 +00:00
Miguel de Icaza 1a1cef73cd More documentation updates
svn path=/trunk/mono/; revision=454
2001-08-09 23:59:21 +00:00
Miguel de Icaza 934a7e1fb0 Doc Update, Version update
svn path=/trunk/mcs/; revision=453
2001-08-09 19:03:51 +00:00
Dietmar Maurer db2912b8f4 2001-08-09 Dietmar Maurer <[email protected]>
* implemented arrays, but you will need a modified version of
	Array.cs to get arrays working (will commit soon)

	* interp.c (ves_icall_array_Set): impl.
	(ves_icall_array_Get): impl.
	(ves_icall_array_ctor): impl.
	(ves_icall_System_Array_GetRank): impl.
	(ves_icall_System_Array_GetLength): impl.
	(ves_icall_System_Array_GetLowerBound): impl.
	(mono_lookup_internal_call): impl.

	* object.c (mono_new_szarray): impl.

	* loader.c (mono_typedef_from_name): return the token, not the index
	(mono_get_corlib): impl.
	(mono_get_array_class_info): impl.
	(method_from_memberref): add array support
	(mono_get_method): support INTERNAL_CALL

	* class.c (mono_class_create_from_typedef): Array support,
	code cleanup, store the token_type, not the token index, added
	flag for value types.
	(mono_type_to_tydedef): impl.
	(mono_class_create_from_typespec): impl.
	(mono_array_class_get): impl.
	(mono_class_get): support TYPE_SPEC token.

svn path=/trunk/mono/; revision=452
2001-08-09 18:06:41 +00:00
Bob Smith 77e1380c49 Class.xml update
svn path=/trunk/mono/; revision=451
2001-08-09 17:23:52 +00:00
Bob Smith abcb02c77b System.Web: New Implementations.
svn path=/trunk/mcs/; revision=450
2001-08-09 17:08:56 +00:00
Sergey Chaban 72e9c582ab Update (Base64/DES stuff).
svn path=/trunk/mcs/; revision=449
2001-08-09 14:13:08 +00:00
Sergey Chaban d653162562 Base64Table now supports both encoding and decoding tables.
svn path=/trunk/mcs/; revision=448
2001-08-09 14:10:56 +00:00
Sergey Chaban ce0d4534ee Initial check-in.
svn path=/trunk/mcs/; revision=447
2001-08-09 14:07:31 +00:00
Sergey Chaban e14e65df25 Initial check-in.
svn path=/trunk/mcs/; revision=446
2001-08-09 13:56:48 +00:00
Nick Drochak f7ac0c141d 2001-08-09 Nick Drochak <[email protected]>
* class/makefile & mcs/makefile:
	  change hardcoded path to csc.exe to use SYSTEMROOT

svn path=/trunk/mcs/; revision=445
2001-08-09 13:30:04 +00:00
Bob Smith 48a76a09b5 RandomTest.cs: Better testing.
svn path=/trunk/mcs/; revision=444
2001-08-08 20:11:15 +00:00
Bob Smith d953404a7c RandomTest.cs: Sync with new Random.cs.
svn path=/trunk/mcs/; revision=443
2001-08-08 20:05:16 +00:00
Bob Smith 15fae9029b Random.cs: API sync.
svn path=/trunk/mcs/; revision=442
2001-08-08 20:03:00 +00:00
Paolo Molaro 6aa31876e3 Fixed x86_mov_reg_imm().
svn path=/trunk/mono/; revision=441
2001-08-08 17:21:29 +00:00
Miguel de Icaza 94b2ec9aaa Update copyright
svn path=/trunk/mono/; revision=440
2001-08-08 16:48:32 +00:00
Bob Smith f67f87d3d9 More RandomTest.cs compile fixes.
svn path=/trunk/mcs/; revision=439
2001-08-08 16:07:45 +00:00
Bob Smith c359c05efc Another Random.cs compile fix.
svn path=/trunk/mcs/; revision=438
2001-08-08 16:04:31 +00:00
Bob Smith abbc53df24 RandomTest.cs compile fixes.
svn path=/trunk/mcs/; revision=437
2001-08-08 15:36:23 +00:00
Bob Smith b8f1f68afd Random.cs compile fixes.
svn path=/trunk/mcs/; revision=436
2001-08-08 15:26:24 +00:00
Paolo Molaro 851a800d67 Wed Aug 8 15:30:05 CEST 2001 Paolo Molaro <[email protected]>
* x86/x86-codegen.h, x86/test.c: added x86 code emitter with
	test.

svn path=/trunk/mono/; revision=435
2001-08-08 13:32:23 +00:00
Miguel de Icaza 37a738ae84 Updated introduction
svn path=/trunk/mono/; revision=434
2001-08-08 08:23:30 +00:00
Miguel de Icaza af5e6538dc 2001-08-08 Miguel de Icaza <[email protected]>
* rootcontext.cs: OH MY!  My trick works!   It is amazing how nice
	this System.Reflection code is.  Kudos to Microsoft

	* typemanager.cs: Implement a type cache and avoid loading all
	types at boot time.  Wrap in LookupType the internals.  This made
	the compiler so much faster.  Wow.  I rule!

	* driver.cs: Make sure we always load mscorlib first (for
	debugging purposes, nothing really important).

	* Renamespaced things that were on `CSC' to `CIR'.  Maybe I should
	have moved to `CSC' rather than `CIR'.  Oh man!  The confussion!

	* rootcontext.cs: Lookup types on their namespace;  Lookup types
	on namespaces that have been imported using the `using' keyword.

svn path=/trunk/mcs/; revision=433
2001-08-08 08:15:23 +00:00
Miguel de Icaza 1ee8bca867 Add missing enumerations UriPartial and UriHostNameType
svn path=/trunk/mcs/; revision=432
2001-08-08 07:09:46 +00:00
Miguel de Icaza 720c9e4100 Moved Uri.cs and UriFormatException to System assembly
svn path=/trunk/mcs/; revision=431
2001-08-08 07:04:06 +00:00
Miguel de Icaza ccce5baefb Fix Makefile
svn path=/trunk/mcs/; revision=430
2001-08-08 06:13:53 +00:00
Miguel de Icaza 864e85dae7 2001-08-08 Miguel de Icaza <[email protected]>
* class.cs (TypeContainer::TypeAttr): Virtualize.
	(Class::TypeAttr): Return attributes suitable for this bad boy.
	(Struct::TypeAttr): ditto.
	Handle nested classes.
	(TypeContainer::) Remove all the type visiting code, it is now
	replaced with the rootcontext.cs code

	* rootcontext.cs (GetClassBases): Added support for structs.

svn path=/trunk/mcs/; revision=429
2001-08-08 06:04:25 +00:00
Nick Drochak 1d5a3786f1 2001-08-08 Nick Drochak <[email protected]>
* Updated status of CollectionBase and ReadOnlyCollectionBase

svn path=/trunk/mono/; revision=428
2001-08-07 17:17:27 +00:00
Nick Drochak 798ee7d352 2001-08-08 Nick Drochak <[email protected]>
* Changed my email address from work to personal one

svn path=/trunk/mono/; revision=427
2001-08-07 17:01:14 +00:00
Nick Drochak 8139457d4e 2001-08-08 Nick Drochak <[email protected]>
* ReadOnlyCollectionBase.cs: Initialized private member.
         * CollectionBase.cs: Initialized private member.
	 * common.src : Added ReadOnlyCollectionBase.cs and CollectionBase.cs
	 * /mcs/class/makefile: Used $(SYSTEMROOT) instead of hard coded //c/winnt
	 * /mcs/makefile: Used $(SYSTEMROOT) instead of hard coded //c/winnt

svn path=/trunk/mcs/; revision=426
2001-08-07 16:59:34 +00:00
Nick Drochak 1192da80ac 2001-08-08 Nick Drochak <[email protected]>
* CollectionBase.cs: Add
         * ReadOnlyCollectionBase.cs: Add
         * CollectionBaseTest.cs: Add
         * ReadOnlyCollectionBaseTest.cs: Add

svn path=/trunk/mcs/; revision=425
2001-08-07 16:09:37 +00:00
Nick Drochak 76a9d42012 2001-08-08 Nick Drochak <[email protected]>
* CollectionBase.cs: Add
         * ReadOnlyCollectionBase.cs: Add
         * CollectionBaseTest.cs: Add
         * ReadOnlyCollectionBaseTest.cs: Add


--------------------------------------------------------------------

svn path=/trunk/mcs/; revision=424
2001-08-07 16:04:06 +00:00
Miguel de Icaza 70f5d8e095 Update docs
svn path=/trunk/mono/; revision=423
2001-08-07 01:40:26 +00:00
Miguel de Icaza 825f207690 Added a few more objects.
svn path=/trunk/mcs/; revision=422
2001-08-07 01:27:15 +00:00
Miguel de Icaza c42aade8ed Update
svn path=/trunk/mono/; revision=421
2001-08-07 01:24:51 +00:00
Miguel de Icaza 456ac53ebb 2001-08-06 Miguel de Icaza <[email protected]>
* interface.cs, statement.cs, class.cs, parameter.cs,
	rootcontext.cs, gen-treedump.cs, enum.cs, cs-parse.jay:
	Drop use of TypeRefs, and use strings instead.

svn path=/trunk/mcs/; revision=420
2001-08-07 00:51:56 +00:00
Miguel de Icaza aed8a46541 2001-08-06 Miguel de Icaza <[email protected]>
* IntPtr.cs: Added and Completed implementation.

svn path=/trunk/mcs/; revision=419
2001-08-07 00:11:48 +00:00
Bob Smith 45e3209277 Updated class.xml
svn path=/trunk/mono/; revision=418
2001-08-06 18:28:48 +00:00
Bob Smith 70ec919985 Added System.Random NUnit test.
svn path=/trunk/mcs/; revision=417
2001-08-06 18:24:35 +00:00
Miguel de Icaza 2231eaa247 Update on the FAQ
svn path=/trunk/mono/; revision=416
2001-08-06 17:58:24 +00:00
Miguel de Icaza d2bc65903b 2001-08-06 Miguel de Icaza <[email protected]>
* IntPtr.cs: Added.

	* Uri.cs: Add a note.

svn path=/trunk/mcs/; revision=415
2001-08-06 17:56:13 +00:00
Bob Smith 27bd9c4170 Random.cs compile fix.
svn path=/trunk/mcs/; revision=414
2001-08-06 17:13:47 +00:00
Dietmar Maurer edeb781a88 pinvoke bug fix
svn path=/trunk/mono/; revision=413
2001-08-06 13:26:40 +00:00
Dietmar Maurer 89ab22e255 2001-08-06 Dietmar Maurer <[email protected]>
* interp.c (mono_lookup_internal_call): impl.
	(ves_exec_method): implemented internal calls
	* cli.h: renamed MonoMethodManaged to MonoMethodNormal

	* loader.h: removed.

	* object.h: added MonoArrayObject and MonoStringObject

svn path=/trunk/mono/; revision=412
2001-08-06 13:16:52 +00:00
Garrett Rooney ad1df20a0c Add Uri.cs to common
svn path=/trunk/mcs/; revision=411
2001-08-06 13:00:47 +00:00
Garrett Rooney 4cb20d0f94 Oops, axe some debugging code that slipped in.
svn path=/trunk/mcs/; revision=410
2001-08-06 12:53:38 +00:00
Garrett Rooney 8fcbefdc81 Bring info on my classes up to date.
svn path=/trunk/mono/; revision=409
2001-08-06 12:51:40 +00:00
Garrett Rooney af58434ba6 2001-08-06 Garrett Rooney <[email protected]>
* Uri.cs: Initial Implementation.  Parsing needs to be fixed to take
	into account IPv6 addresses, url encoding needs to be implemented, and
	various minor methods need to be written, but this is a decent start.

svn path=/trunk/mcs/; revision=408
2001-08-06 12:48:43 +00:00
Dietmar Maurer 151094a2b3 2001-08-06 Dietmar Maurer <[email protected]>
* common.src: added Object.cs

	* mono.src: added ValueType.cs

	* Math.cs: replaced libc with libm

svn path=/trunk/mcs/; revision=407
2001-08-06 10:36:16 +00:00
Dietmar Maurer 57d320d107 2001-08-06 Dietmar Maurer <[email protected]>
* object.h: added MonoArrayObject and MonoStringObject

	* loader.c (mono_typedef_from_name):
	s/typedef_from_name/(mono_typedef_from_name and made it public.

	* class.c (class_compute_field_layout): skip the FIELD signature
	(mono_class_create_from_typedef): bug fix: field.last was wrong
	(class_compute_field_layout): added some code to make it work for
	classes with EXPLICIT_LAYOUT but no offsets specified (I observed
	that behaviour on System.Array)

	* interp.c (ves_exec_method): impl. NEWARR
	(ves_exec_method): impl. most LDELEM/STELEM opcodes, LDLEN
	(newarr): impl.
	(mono_get_ansi_string): impl.

	* mono/tests/pinvoke.cs: we can now print strings ;-)

	* mono/tests/array.cs: new test for arrays

svn path=/trunk/mono/; revision=406
2001-08-06 09:56:57 +00:00
Miguel de Icaza 37dcf16ecb Add more test cases for the compiler, we rule!!!
svn path=/trunk/mcs/; revision=405
2001-08-05 17:08:07 +00:00
Miguel de Icaza 08e726c19d 2001-08-04 Miguel de Icaza <[email protected]>
* rootcontext.cs:

	* class.cs (Struct::Struct): set the SEALED flags after
	checking the modifiers.
	(TypeContainer::TypeAttr): new property, returns the
	TypeAttributes for a class.

	* cs-parser.jay (type_list): Oops, list production was creating a
	new list of base types.

	* rootcontext.cs (StdLib): New property.
	(GetInterfaceTypeByName): returns an interface by type name, and
	encapsulates error handling here.
	(GetInterfaces): simplified.
	(ResolveTree): Encapsulated all the tree resolution here.
	(CreateClass, GetClassBases, GetInterfaceOrClass): Create class
	types.

	* driver.cs: Add support for --nostdlib, to avoid loading the
	default assemblies.
	(Main): Do not put tree resolution here.

	* rootcontext.cs: Beginning of the class resolution.

svn path=/trunk/mcs/; revision=404
2001-08-05 17:06:56 +00:00
Paolo Molaro 31e67dbbe3 Sat Aug 4 12:46:02 CEST 2001 Paolo Molaro <[email protected]>
* metadata.h, metadata.c: add mono_metadata_decode_row_col () to
	decode a single column from a row in a metadata table and changes
	to take advantage of it in the typedef locator (gives a nice speed up).
	Store offset info for function params.


Sat Aug 4 12:36:54 CEST 2001 Paolo Molaro <[email protected]>

	* get.c, get.h, main.c, dump.c: implement dis_stringify_method_signature().
	More magic constants replaced by enum values (spotted at least 3 real bugs
	doing this). Print usage information if an unknown option is given.
	Print the full signature when dumping the method table.
	Changed method and field table dumps to show the typedef name the field
	or method belongs to.

svn path=/trunk/mono/; revision=403
2001-08-04 13:32:08 +00:00
Miguel de Icaza ff28f75cc7 Add EventHandlerList.cs
svn path=/trunk/mcs/; revision=402
2001-08-04 04:06:53 +00:00
Miguel de Icaza 69b9fdb22a 2001-08-04 Miguel de Icaza <[email protected]>
* rootcontext.cs: Beginning of the class resolution.

svn path=/trunk/mcs/; revision=401
2001-08-04 04:05:59 +00:00
Miguel de Icaza c4e0e0a69a More contributors
svn path=/trunk/mono/; revision=400
2001-08-04 04:01:04 +00:00
Miguel de Icaza 61fcd0dabb 2001-08-03 Miguel de Icaza <[email protected]>
* cs-parser.jay (interface_base): set our $$ to be interfaces.

svn path=/trunk/mcs/; revision=399
2001-08-04 01:39:12 +00:00
Miguel de Icaza 2619944732 Added VisualStudio files
svn path=/trunk/mcs/; revision=398
2001-08-04 01:28:46 +00:00
Miguel de Icaza 64f74a749b Added tests for compiler
svn path=/trunk/mcs/; revision=397
2001-08-04 01:15:00 +00:00
Miguel de Icaza 27ddde64e5 2001-08-03 Miguel de Icaza <[email protected]>
* rootcontext.cs (CreateInterface): Handle the case where there
	are no parent interfaces.

svn path=/trunk/mcs/; revision=396
2001-08-04 01:02:08 +00:00
Miguel de Icaza ee782bf506 2001-08-03 Miguel de Icaza <[email protected]>
* rootcontext.cs (CloseTypes): Routine to flush types at the end.
	(CreateInterface): Track types.
	(GetInterfaces): Returns an array of Types from the list of
	defined interfaces.

	* typemanager.c (AddUserType): Mechanism to track user types (puts
	the type on the global type hash, and allows us to close it at the
	end).

svn path=/trunk/mcs/; revision=395
2001-08-04 00:44:58 +00:00
Miguel de Icaza fa62c464f4 Flush
svn path=/trunk/mcs/; revision=394
2001-08-04 00:23:10 +00:00
Miguel de Icaza ed5023f76b Add information on daily snapshots
svn path=/trunk/mono/; revision=393
2001-08-03 20:05:12 +00:00
Paolo Molaro 3ddb0dbeb2 Fri Aug 3 18:30:16 CEST 2001 Paolo Molaro <[email protected]>
* get.c (get_method): fix use of unitialized variable and
	remove magic constants all over the place.

svn path=/trunk/mono/; revision=392
2001-08-03 16:54:12 +00:00
Dietmar Maurer 055c070440 removed a typo
svn path=/trunk/mono/; revision=391
2001-08-03 05:38:15 +00:00
Bob Smith b8257ee75f Implemented the System.Random class. I dont have a C# compiler, so someone will need to test it when (s)he has time.
svn path=/trunk/mcs/; revision=390
2001-08-02 23:04:31 +00:00
Miguel de Icaza ac653e22ed *** empty log message ***
svn path=/trunk/mcs/; revision=389
2001-08-02 22:11:17 +00:00
Miguel de Icaza 316b3938fb Update classes
svn path=/trunk/mono/; revision=388
2001-08-02 21:58:01 +00:00
Miguel de Icaza b691f286c7 2001-08-02 Miguel de Icaza <[email protected]>
* Container.cs, Component.cs, IContainer.cs, IComponent.cs,
	ComponentCollection.cs, ISite.cs: New classes

2001-08-02  Miguel de Icaza  <[email protected]>

	* IServiceProvider.cs, EventHandler.cs: New files.

svn path=/trunk/mcs/; revision=387
2001-08-02 21:57:41 +00:00
Alex Graveley 686c0d0681 Update
svn path=/trunk/mono/; revision=386
2001-08-02 19:37:15 +00:00
Alex Graveley ab1d77939e Update
svn path=/trunk/mono/; revision=385
2001-08-02 19:36:48 +00:00
Alex Graveley 6ff1b314c0 Add forgotten libffi headers.
svn path=/trunk/mono/; revision=384
2001-08-02 19:33:38 +00:00
Alex Graveley 44162175c8 2001-08-02 Alex Graveley <[email protected]>
* libffi/*: Import libffi CVS version, with minor changes to make it
          compile.

        * mono/interpreter/Makefile.am: Link against
          ../../libffi/.libs/libffi.a.

        * Makefile.am: Add libffi

        * autogen.sh: Replace with adapted gnome autogen.sh

        * configure.in: Add AC_CONFIG_SUBDIRS(libffi).

svn path=/trunk/mono/; revision=383
2001-08-02 19:31:56 +00:00
Marcel Narings 6c99809873 2001-08-02 Marcel Narings <[email protected]>
* DateTime.cs: Cleaned up a bit. Added the Add* family members.
        Added exceptions. Added IConvertible. Still needs some platform
        dependend stuff, the Parse and ToString members

svn path=/trunk/mcs/; revision=382
2001-08-02 19:14:40 +00:00
Miguel de Icaza b690b5bb2f 2001-08-02 Miguel de Icaza <[email protected]>
* tree.cs: Removed RecordType, added RecordClass, RecordStruct and
	RecordInterface instead.

	* cs-parser.jay: Updated to reflect changes above.

	* decl.cs (Definition): Keep track of the TypeBuilder type that
	represents this type here.  Not sure we will use it in the long
	run, but wont hurt for now.

	* driver.cs: Smaller changes to accomodate the new code.

	Call ResolveInterfaceBases, Call ResolveClassBases, Save assembly
	when done.

	* rootcontext.cs (CreateInterface):  New method, used to create
	the System.TypeBuilder type for interfaces.
	(ResolveInterfaces): new entry point to resolve the interface
	hierarchy.
	(CodeGen): Property, used to keep track of the code generator.

svn path=/trunk/mcs/; revision=381
2001-08-02 14:19:45 +00:00
Dietmar Maurer d6111f3c10 2001-08-02 Dietmar Maurer <[email protected]>
* interp.c (ves_exec_method): found a way to do unordered
	compares, implemented CEE_BNE_UN_S, CEE_BGE_UN_S, CEE_BGT_UN_S,
	CEE_BLE_UN_S, CEE_BLT_UN_S
	* loader.c(mono_map_dll): impl.
	(mono_get_method): bug fix: pass index - 1 to fill_pinvoke_info
        * mono/tests/pinvoke.cs: impl.

svn path=/trunk/mono/; revision=380
2001-08-02 11:28:08 +00:00
Dietmar Maurer 4ce63bc801 * loader.c (mono_get_string_class_info): do a strcmp to check
if it is System.String instead of using magic numbers.
	* class.c (mono_class_create_from_typedef): do a strcmp to check
	if it is System.Object instead of using magic numbers.
	* image.h (MONO_IMAGE_IS_CORLIB): removed

svn path=/trunk/mono/; revision=379
2001-08-02 06:46:33 +00:00
Miguel de Icaza a1670be543 Update menus
svn path=/trunk/mono/; revision=378
2001-08-02 02:17:37 +00:00
Miguel de Icaza 2d59fbc933 More web page updates + more class updates
svn path=/trunk/mono/; revision=377
2001-08-02 02:17:08 +00:00
Miguel de Icaza 2a091f407b Include ToBase64 in compile
svn path=/trunk/mcs/; revision=376
2001-08-02 02:04:49 +00:00
Miguel de Icaza aea66710df Added ToBase64TransformTest from Sergey
svn path=/trunk/mcs/; revision=375
2001-08-02 01:55:45 +00:00
Miguel de Icaza a4e78886e1 More FAQ updates; Updated class status
svn path=/trunk/mono/; revision=374
2001-08-01 23:44:33 +00:00
Miguel de Icaza 41038acb57 Add ChangeLog
svn path=/trunk/mcs/; revision=373
2001-08-01 23:07:32 +00:00
Miguel de Icaza 245459fe01 Add missing files
svn path=/trunk/mcs/; revision=372
2001-08-01 23:05:44 +00:00
Miguel de Icaza baa39453fc Matthew Ford's initial implementation and test classes for
System.Security.Cryptography.

svn path=/trunk/mcs/; revision=371
2001-08-01 23:05:07 +00:00
Miguel de Icaza 30577d2746 Update documentation; FAQ; Download information; Status update
svn path=/trunk/mono/; revision=370
2001-08-01 23:03:50 +00:00
Paolo Molaro 1101305d69 Wed Aug 1 22:46:45 CEST 2001 Paolo Molaro <[email protected]>
* dis-cil.c: properly decode the switch opcode.

Wed Aug 1 22:48:29 CEST 2001 Paolo Molaro <[email protected]>

	* class.c, class.h: mono_field_type_size () moved to metadata.
	Take correctly into account alignment when laying out
	class fields. Fix 5 to 0 magc number (to check for System.Object).


Wed Aug 1 22:54:08 CEST 2001 Paolo Molaro <[email protected]>

	* assembly.c: how could mono_assembly_close () had ever worked?
	* metadata.c, metadata.h: provide offset info for local vars.
	Implement mono_type_size () to take care of alignment as well
	as size (it was mono_field_type_size in cli/class.c before).

Wed Aug 1 22:51:38 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: handle also MONO_TYPE_CLASS to/from the stack.
	Change locals to be a memory blob, instead of the structured
	(but wrong) stackval. Implement bne.un.s opcode. Make the program
	exit with the error code from Main().

svn path=/trunk/mono/; revision=369
2001-08-01 21:01:30 +00:00
Paolo Molaro ca0c0e74b8 Missed this change from previous commit.
svn path=/trunk/mono/; revision=368
2001-08-01 20:44:53 +00:00
Paolo Molaro e7a3ce9740 Wed Aug 1 22:34:52 CEST 2001 Paolo Molaro <[email protected]>
* configure.in, mono/tests: added some tests for the interpreter.

svn path=/trunk/mono/; revision=367
2001-08-01 20:38:13 +00:00
Dietmar Maurer f7db85e696 * image.h (MONO_IMAGE_IS_CORLIB): new macro to check root image
* assembly.h (CORLIB_NAME): set to corlib.dll
	* assembly.c (mono_assembly_open): replaced strcmp() with !strcmp()
	* interp.c (ves_exec_method): implemented LDSTR
	* loader.c (mono_get_string_class_info): impl.
	(methoddef_from_memberref): added check for references into mscorlib
	* class.c (mono_class_create_from_typedef): better check for root
	object

svn path=/trunk/mono/; revision=366
2001-08-01 18:12:02 +00:00
Garrett Rooney bcc894914f 2001-07-31 Garrett Rooney <[email protected]>
* StackTest.cs: Add Test case for System.Collections.Stack.
	Contributed by Chris Hynes <[email protected]>

svn path=/trunk/mcs/; revision=365
2001-08-01 12:51:25 +00:00
Dietmar Maurer b371649eaa 2001-08-01 Dietmar Maurer <[email protected]>
* assembly.c (mono_assembly_open): set the corlib before we continue.
	(mono_assembly_open): replaced strcmp() with !strcmp()

svn path=/trunk/mono/; revision=364
2001-08-01 09:29:18 +00:00
Dietmar Maurer 19958ecf5e 2001-08-01 Dietmar Maurer <[email protected]>
* Type.cs (GetTypeFromHandle): added placeholder

svn path=/trunk/mcs/; revision=363
2001-08-01 07:13:42 +00:00
Miguel de Icaza 7fad175c3b Make Configure point people to the libffi library
svn path=/trunk/mono/; revision=362
2001-08-01 06:59:29 +00:00
Miguel de Icaza 79bac871d3 2001-07-31 Miguel de Icaza <[email protected]>
* interp.c (GET_NATI): Switched from using nati_t to cli/types.h
	m_i type.  Maybe we should rename the types to be m_i_t instead of
	m_i alone.

	Make the code compile after I broke it.

svn path=/trunk/mono/; revision=361
2001-07-31 21:54:03 +00:00
Paolo Molaro 84c89ad40a Tue Jul 31 23:46:33 CEST 2001 Paolo Molaro <[email protected]>
* interp.c: fix cleanup.
	* Makefile.am: don't link with disassembler library.

svn path=/trunk/mono/; revision=360
2001-07-31 21:47:47 +00:00
Miguel de Icaza 70d6adbef8 Add CVS instructions and Developer FAQ
svn path=/trunk/mono/; revision=359
2001-07-31 21:13:05 +00:00
Miguel de Icaza f42bcd22d0 Update to the FAQ.
Beautified the code.

svn path=/trunk/mono/; revision=358
2001-07-31 21:12:47 +00:00
Paolo Molaro 889c389860 Tue Jul 31 20:13:59 CEST 2001 Paolo Molaro <[email protected]>
* interp.c: implement stind.*, ldind.*, ldloca.s opcodes.
	Provide better tracing with DEBUG_INTERP.

svn path=/trunk/mono/; revision=357
2001-07-31 18:26:51 +00:00
Paolo Molaro e8d4a08a24 Tue Jul 31 17:54:02 CEST 2001 Paolo Molaro <[email protected]>
* metadata.h, metadata.c, Makefile.am, private.h, assembly.c, blob.h,
	cil-coff.h, image.c, image.h, pedump.c, rawbuffer.c, rawbuffer.h, row-indexes.h,
	tokentype.h: massive namespace cleanup.

Tue Jul 31 17:52:53 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: massive namespace cleanup.

Tue Jul 31 17:48:11 CEST 2001 Paolo Molaro <[email protected]>

	* dis-cil.c, dis-cil.h, dump.c, dump.h, get.c, get.h, main.c, push-pop.h:
	massive namespace cleanup.
	* main.c: dis_locals() now just strigifies a MonoMethodHeader.

Tue Jul 31 17:45:44 CEST 2001 Paolo Molaro <[email protected]>

	* class.c, cli.h, loader.c: massive namespace cleanup.

svn path=/trunk/mono/; revision=356
2001-07-31 16:06:17 +00:00
Dietmar Maurer de8614b8f1 *** empty log message ***
svn path=/trunk/mono/; revision=355
2001-07-31 13:42:52 +00:00
Dietmar Maurer d08d1ca18b 2001-07-31 Dietmar Maurer <[email protected]>
* cli.h: added pinvoke flags to MonoMethodPInvoke, moved method
	implementation flags to MonoMethod

svn path=/trunk/mono/; revision=354
2001-07-31 13:40:15 +00:00
Dietmar Maurer 8a8a30bebc Dietmar Maurer <[email protected]>
* main.c (pinvoke_flags): impl.

svn path=/trunk/mono/; revision=353
2001-07-31 13:13:01 +00:00
Dietmar Maurer c5a70b766b *** empty log message ***
svn path=/trunk/mono/; revision=352
2001-07-31 13:10:56 +00:00
Garrett Rooney 6da3c2a99f Ego boost commit. Add myself to AUTHORS.
svn path=/trunk/mcs/; revision=351
2001-07-31 13:05:42 +00:00
Garrett Rooney 6ab3b5b5f8 *Stack.cs: Clone() doesn't need to check if it's synchronized, since
we override it in SyncStack anyway.

*Stack.cs: Pop() now shrinks the array if we drop below 1/4 full, to
avoid using massive amounts of memory that are not necessary.  We only
drop to half the current size, which i hope will avoid the 'ping-pong'
effect.

*Stack.cs: SyncStack.IsReadOnly should return stack.IsReadOnly
instead of just returning false, since we may have a ReadOnly wrapper
in the future (although i can't imagine why).  Thanks to David
Menestrina <[email protected]> for pointing this out.

svn path=/trunk/mcs/; revision=350
2001-07-31 12:51:28 +00:00
Marcin Szczepanski 6b0503acb3 Add test cases for System.IO.Path These might need to be fleshed out
a bit to deal with more complex scenarios, but as is they cover most of
the functions to some extent.

svn path=/trunk/mcs/; revision=349
2001-07-31 07:57:51 +00:00
Miguel de Icaza ecf8515a0f Flush
svn path=/trunk/mono/; revision=348
2001-07-31 01:56:13 +00:00
Miguel de Icaza 7377cbc403 Flush
svn path=/trunk/mono/; revision=347
2001-07-31 01:53:03 +00:00
Miguel de Icaza bfc0820e28 Some details fixed, but Queue does not work
svn path=/trunk/mcs/; revision=346
2001-07-31 00:59:58 +00:00
Miguel de Icaza 6073d77a9c Add Queue class from Ricardo Fernandez
svn path=/trunk/mcs/; revision=345
2001-07-31 00:53:21 +00:00
Paolo Molaro f2fde84b45 Mon Jul 30 20:11:01 CEST 2001 Paolo Molaro <[email protected]>
* metadata.h, metadata.c: decode exception clauses when parsing method header.

Mon Jul 30 20:08:37 CEST 2001 Paolo Molaro <[email protected]>

	* dis-cil.c, dis-cil.h, main.c: changes to disassemble also
	the information about try/catch/finally blocks.

Mon Jul 30 20:05:23 CEST 2001 Paolo Molaro <[email protected]>

	* cli.h, loader.c: usa a char *name field in MonoMethod instead
	of the name_idx token.

Mon Jul 30 20:09:58 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: update to use mono_method->name.

svn path=/trunk/mono/; revision=344
2001-07-30 18:17:11 +00:00
Miguel de Icaza 637f7a9220 Mono 0.5
svn path=/trunk/mono/; revision=342
2001-07-30 00:23:41 +00:00
Miguel de Icaza 51a41340c6 Flush
svn path=/trunk/mono/; revision=341
2001-07-29 23:58:17 +00:00
Miguel de Icaza f22591bb38 Revert Tigert's change, because it breaks IE
svn path=/trunk/mono/; revision=340
2001-07-29 22:42:55 +00:00
Miguel de Icaza 31df0b838f CVS doc update + Maintainers update
svn path=/trunk/mono/; revision=339
2001-07-29 04:50:15 +00:00
Miguel de Icaza 5a8d2bbd2c Documentation update, plus cvs docs
svn path=/trunk/mono/; revision=338
2001-07-28 17:45:16 +00:00
Miguel de Icaza 52214d0f8a Flush
svn path=/trunk/mono/; revision=337
2001-07-27 22:57:52 +00:00
Paolo Molaro 7e1f2cb2d6 Fri Jul 27 20:51:47 CEST 2001 Paolo Molaro <[email protected]>
* class.h, class.c: add inited field to MonoClass.

Fri Jul 27 20:54:00 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: start implementing callvirt. Classes with
	class constructors are properly initialized when needed.
	Fix error introduced in version 1.17.

svn path=/trunk/mono/; revision=336
2001-07-27 19:05:30 +00:00
Paolo Molaro 044dc4073b D'oh, forgot to actually commit my previous changes.
Fri Jul 27 14:03:19 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: implement static field loading and storing.

Fri Jul 27 13:51:11 CEST 2001 Paolo Molaro <[email protected]>

	* class.h, class.c: add a class_size member to MonoClass. We store
	the static fields after the other class data. Offsets for static
	fields are offsets from the MonoClass pointer.
	Properly initialize class->instance_size and deal with static
	fields when layouting them.

svn path=/trunk/mono/; revision=333
2001-07-27 15:48:34 +00:00
Dietmar Maurer a1bbd38c28 *** empty log message ***
svn path=/trunk/mono/; revision=332
2001-07-27 15:17:59 +00:00
Miguel de Icaza 5d9e9cbeec TODO
svn path=/trunk/mcs/; revision=331
2001-07-27 13:56:06 +00:00
Miguel de Icaza a4b6322ed4 2001-07-26 Miguel de Icaza <[email protected]>
* cs-parser.jay: Add a second production for delegate_declaration
	with `VOID'.

	(enum_body): Put an opt_comma here instead of putting it on
	enum_body or enum_member_declarations so we can handle trailing
	commas on enumeration members.  Gets rid of a shift/reduce.

	(type_list): Need a COMMA in the middle.

	(indexer_declaration): Tell tokenizer to recognize get/set

	* Remove old targets.

	* Re-add the parser target.

svn path=/trunk/mcs/; revision=330
2001-07-27 13:51:10 +00:00
Miguel de Icaza b82c9bc4b1 Updated
svn path=/trunk/mono/; revision=329
2001-07-27 13:50:46 +00:00
Paolo Molaro 794af1025b Fri Jul 27 11:46:09 CEST 2001 Paolo Molaro <[email protected]>
* loader.c: implemented lookup of methods in a different MonoImage
	(needed to call the Syste.Object constructor, for example). Fixed the cache
	code to only check for methods defined in the image.

Fri Jul 27 11:49:19 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: Removed some debugging printouts. Made stackval_to_data
	static. Handle also instance methods in CALL opcode. Fix ret to properly
	deal with void functions. Fixed constructor to leave the object on
	the stack.

svn path=/trunk/mono/; revision=328
2001-07-27 10:53:38 +00:00
Paolo Molaro 2afbf3642f Thu Jul 26 19:11:19 CEST 2001 Paolo Molaro <[email protected]>
* metadata.h, row_indexes.h: added header with enumerations to use
	to index in the columns from tables in metadata and to decode coded
	tokens: we should start using this instead of embedding magic numbers
	all over the code.

svn path=/trunk/mono/; revision=327
2001-07-26 17:17:40 +00:00
Paolo Molaro 8525a9e126 Thu Jul 26 15:31:01 CEST 2001 Paolo Molaro <[email protected]>
* loader.c: forgot to insert the method in the cache, not nice
	with a recursive fibonacci test case :-)

svn path=/trunk/mono/; revision=326
2001-07-26 13:32:29 +00:00
Paolo Molaro a3aba01b57 Thu Jul 26 13:03:27 CEST 2001 Paolo Molaro <[email protected]>
* assembly.c, cil-coff.h, image.c, image.h, pedump.c, typedef.c:
	Move metadata_t info from cli_image_info_t to MonoImage, where
	it's easily accessible. Changed all the uses accordingly.
	Added the method and class caches to MonoImage.
	* metadata.c, metadata.h: Changed mono_metadata_decode_blob_size ()
	and mono_metadata_decode_value () signature to be more consistent
	with the other parse functions (and simplify code). Taken advantage
	of zero-length array allocation with GCC. Removed reduntant (and
	wrong) MonoFieldType struct and use MonoParam instead. Changed
	mono_metadata_parse_field_type () to use common code for parsing.
	Added mono_metadata_typedef_from_field () and
	mono_metadata_typedef_from_method () to lookup a typedef index from a
	field or method token.
	Pack the MonoRetType structure more tightly (fits in 8 bytes now).

Thu Jul 26 13:17:22 CEST 2001 Paolo Molaro <[email protected]>

	* class.c: updates to match changes in metadata.
	Fix off by one errors. Implement creation of classes by typeref.
	Remove custom cache and use the class cache in MonoImage.
	* cli.h, loader.c: add MonoImage field to MonoMethod. Fill method cache
	in MonoImage. Updates to match changes in metadata.

Thu Jul 26 13:22:28 CEST 2001 Paolo Molaro <[email protected]>

	* dis-cil.c, dump.c, get.c, main.c: updates to match changes in metadata.
	Removed dead code.

Thu Jul 26 13:24:51 CEST 2001 Paolo Molaro <[email protected]>

	* interp.c: ves_exec_method () doesn't take a MonoImage arg
	anymore. Use the method cache in MonoImage. Updates to
	mache recent changes in metadata.
	Fix newobj code to use new metadata features. Call the class
	constructor after allocationg the object. Implemented load field
	and store field opcodes (the support functions need to be finished).

svn path=/trunk/mono/; revision=325
2001-07-26 11:51:50 +00:00
Miguel de Icaza 630ce00c86 does not compile yet
svn path=/trunk/mcs/; revision=324
2001-07-25 21:20:16 +00:00
Miguel de Icaza a4279f3803 Add SortedList contirbution
svn path=/trunk/mcs/; revision=323
2001-07-25 21:14:59 +00:00
Miguel de Icaza 2c94aa3c7a Add NameValueCollection contribution
svn path=/trunk/mcs/; revision=322
2001-07-25 21:09:54 +00:00
Tuomas Kuosmanen 53dcde3453 In an attempt to fix the broken-on-mozilla links that get overlapped by the
text, I changed the main links a bit, so they are now pretty orange when
you mouseover them.

Turned out the thing was a mozilla bug afterwards, though the new color
stuff looks pretty cute, so I left it in.

Doh.

Tuomas

svn path=/trunk/mono/; revision=321
2001-07-25 07:30:59 +00:00
Miguel de Icaza 99f0f65965 2001-07-24 Derek Holden <[email protected]>
* NumberStyles.cs: Added ECMA values for Allow types and default
	styles.
2001-07-24  Derek Holden  <[email protected]>

	* Boolean.cs: Formatted to code style standard. Added GetTypeCode
	which is really an IConvertible defined method.

	* Byte.cs: Added a missing Parse method. Put in Parse and ToString
	behavior, still need to do the main Parse and ToString.

	* Char.cs: Added a bunch of missing ECMA methods. Commented a
	specification discrepency. Still didn't any unicode stuff, though
	every IsFoo(char c) method has an IsFoo(string, index)
	counterpart, added wrappers for those.

	* Convert.cs: Fixed NaN/Inf checking and double/float
	rounding. Added ToType for IConvertible classes

	* Double.cs: Fixed ECMA min and max values. Added IsInfinity /
	IsNaN methods. Changed Inf/NaN internals.

	* IConvertible.cs: Added comments for using
	Convert.ToType. Changed return values to draft base values.

	* Int16.cs: Added a missing Parse statement. Put in behavior for
	overloaded ToString and Parse methods.

	* Int32.cs: Added a missing Parse statement. Put in behavior for
	overloaded ToString and Parse methods.

	* Int64.cs: Added a missing Parse statement. Put in behavior for
	overloaded ToString and Parse methods.

	* Single.cs: Put in ECMA epsilon value. Added IsInfinity / IsNaN
	methods. Changed Inf/NaN internals.

	* SByte.cs: Added a missing Parse method. Put in Parse and
	ToString behavior, still need to do the main Parse and ToString.

	* UInt16.cs: Added a missing Parse statement. Put in behavior for
	overloaded ToString and Parse methods.

	* UInt32.cs: Added a missing Parse statement. Put in behavior for
	overloaded ToString and Parse methods.

	* UInt64.cs: Added a missing Parse statement. Put in behavior for
	overloaded ToString and Parse methods.

svn path=/trunk/mcs/; revision=320
2001-07-25 05:15:40 +00:00
Miguel de Icaza 1a95ed2365 Class
svn path=/trunk/mono/; revision=319
2001-07-24 17:34:41 +00:00
Miguel de Icaza 9129c087c9 updated classes
svn path=/trunk/mono/; revision=318
2001-07-24 17:25:32 +00:00
Paolo Molaro 9f391f06f7 missing file.
svn path=/trunk/mono/; revision=317
2001-07-24 16:07:13 +00:00
Paolo Molaro e2f5d94b4d Tue Jul 24 16:51:09 CEST 2001 Paolo Molaro <[email protected]>
* interp.c, hacks.h: moved a few ugly macros out of the code.
	Implemented switch opcode.

svn path=/trunk/mono/; revision=316
2001-07-24 16:06:38 +00:00
Miguel de Icaza 15ce719fae 2001-07-24 Miguel de Icaza <[email protected]>
* class.c (mono_class_create_from_typedef): Take into account
	parent classes for the size of a structure.

	Still not ideal, but better than before.

	For the case of the interpreter, Paolo is right, there is not much
	use for a Field Map, as the way the Fields are located is through
	a token.

	(mono_class_init): Remove, initialize automatically.

	(mono_class_get_field): new function, returns the information
	about a field given a class and its token.

2001-07-23  Miguel de Icaza  <[email protected]>

	* interp.c (newobj): Added function to handle newobj opcode.

2001-07-23  Miguel de Icaza  <[email protected]>

	* metadata.c (mono_metadata_parse_field_type): Implement.
	(do_mono_metadata_parse_type): Split engine from
	mono_metadata_parse_type, so that we can create smaller structures
	for things that just have one pointer to the MonoType (look at
	the MonoFieldType)

svn path=/trunk/mono/; revision=315
2001-07-24 06:58:04 +00:00
Miguel de Icaza f9b4f1d807 Updates
svn path=/trunk/mono/; revision=314
2001-07-24 04:56:42 +00:00
Miguel de Icaza 644ddb6663 2001-07-23 Sergey Chaban <[email protected]>
*  Hashtable.cs: Fixed bug in Clear(), the Count wasn't zeroed.
           From now, Clear() increases modification count.
           Fixed HCP bug in GetHash(object) - hcp.GetHashCode() was used
           instead of hcp.GetHashCode(key). This was resulted in the
           insanely long lookup times when HashCodeProvider was used to
           construct Hashtable. Added thread-safe wrapper.

svn path=/trunk/mcs/; revision=313
2001-07-24 04:54:27 +00:00
Miguel de Icaza 3cbb51830a 2001-07-23 Miguel de Icaza <[email protected]>
* interp.c (newobj): Added function to handle newobj opcode.

2001-07-23  Miguel de Icaza  <[email protected]>

	* object.h, object.c, class.h, class.c: Implemented the beginning
	of the object system. x

2001-07-23  Miguel de Icaza  <[email protected]>

	* metadata.c (mono_metadata_parse_field_type): Implement.
	(do_mono_metadata_parse_type): Split engine from
	mono_metadata_parse_type, so that we can create smaller structures
	for things that just have one pointer to the MonoType (look at
	the MonoFieldType)

svn path=/trunk/mono/; revision=312
2001-07-23 23:54:34 +00:00
Miguel de Icaza 1ebef995ee Reorganization
svn path=/trunk/mono/; revision=289
2001-07-23 04:30:21 +00:00
Miguel de Icaza 8c415b9652 Flushety flush
svn path=/trunk/mono/; revision=288
2001-07-22 03:59:57 +00:00
Chema Celorio 1b23214ad3 fix a typo s/gnome-config/monodis
svn path=/trunk/mono/; revision=287
2001-07-21 08:42:36 +00:00
Miguel de Icaza bf9b40d503 Flushage
svn path=/trunk/mcs/; revision=286
2001-07-21 03:50:13 +00:00
Miguel de Icaza 75800470b0 Flush
svn path=/trunk/mono/; revision=285
2001-07-21 03:43:14 +00:00
Miguel de Icaza 70a513e889 Update README
svn path=/trunk/mono/; revision=284
2001-07-21 02:00:36 +00:00
Miguel de Icaza 8dd5362cd5 More contributors
svn path=/trunk/mono/; revision=283
2001-07-20 23:41:59 +00:00
Miguel de Icaza b7feffe294 2001-07-20 Miguel de Icaza <[email protected]>
* metadata.c (mono_metadata_parse_mh): Correct the implementation,
	as Jan Gray found out, it is incorrect.

svn path=/trunk/mono/; revision=282
2001-07-20 20:27:48 +00:00
Miguel de Icaza 7c4a24533e Commit
svn path=/trunk/mcs/; revision=281
2001-07-20 19:38:02 +00:00
Miguel de Icaza d54ab5c35b More
svn path=/trunk/mono/; revision=280
2001-07-20 19:25:31 +00:00
Miguel de Icaza 86d29a8406 More
svn path=/trunk/mono/; revision=279
2001-07-20 19:23:21 +00:00
Miguel de Icaza a20f123a6d Add more classes
svn path=/trunk/mcs/; revision=278
2001-07-20 19:19:46 +00:00
Miguel de Icaza 074fa6d0ff Oopsety
svn path=/trunk/mono/; revision=277
2001-07-20 18:34:26 +00:00
Miguel de Icaza 0a99fb8a57 Wooohooo! System.Web.Cache from Patrick!
svn path=/trunk/mcs/; revision=276
2001-07-20 17:48:40 +00:00
Miguel de Icaza a4d35f7ec9 Flush
svn path=/trunk/mono/; revision=275
2001-07-20 16:16:45 +00:00
Miguel de Icaza ced4972289 PUsh
svn path=/trunk/mono/; revision=274
2001-07-20 16:16:14 +00:00
Miguel de Icaza 8030ee68e4 Just one extra bit
svn path=/trunk/mono/; revision=267
2001-07-20 06:28:35 +00:00
Miguel de Icaza 9eaf726688 Perform nested assembly loading. Use assembly loading instead of
image loading.

svn path=/trunk/mono/; revision=266
2001-07-20 06:23:55 +00:00
Tuomas Kuosmanen aab87ccda7 Added the TM to the mono logo, also moved it a bit to the left.
/tigert

svn path=/trunk/mono/; revision=265
2001-07-20 05:10:37 +00:00
Miguel de Icaza cb9e7419be Add Mono files
svn path=/trunk/mcs/; revision=264
2001-07-20 05:02:47 +00:00
Miguel de Icaza ed9ec7475a Commit new files, almost compiles with /nostdlib
svn path=/trunk/mcs/; revision=263
2001-07-20 04:54:58 +00:00
Miguel de Icaza 5db9f4c938 Got enumerations to work!
svn path=/trunk/mcs/; revision=262
2001-07-20 02:31:25 +00:00
Miguel de Icaza 4519dd4972 Enumerations from Michael Lambert
svn path=/trunk/mcs/; revision=261
2001-07-20 02:25:33 +00:00
Jeffrey Stedfast da5ea45637 2001-07-19 Jeffrey Stedfast <[email protected]>
* Char.cs: Made ToUpper and ToLower public methods.

	* String.cs: Lots and lots of compile fixes - just need to write
	DateTime.cs and this should build completely now.

svn path=/trunk/mcs/; revision=260
2001-07-20 02:17:59 +00:00
Miguel de Icaza ce407bb9e8 Flush
svn path=/trunk/mcs/; revision=259
2001-07-20 02:02:23 +00:00
Miguel de Icaza df52d0d6f9 Fixes
svn path=/trunk/mono/; revision=258
2001-07-20 01:32:46 +00:00
Miguel de Icaza eac858025b 2001-07-19 Bob Smith ([email protected])
* Math.cs: Implemented.

svn path=/trunk/mcs/; revision=257
2001-07-20 01:30:32 +00:00
Miguel de Icaza f9ef817353 flush
svn path=/trunk/mono/; revision=256
2001-07-20 01:07:03 +00:00
Miguel de Icaza 5090da62b5 *** empty log message ***
svn path=/trunk/mcs/; revision=255
2001-07-20 00:50:39 +00:00
Miguel de Icaza 08fc57666c *** empty log message ***
svn path=/trunk/mcs/; revision=254
2001-07-20 00:49:13 +00:00
Miguel de Icaza ea46dbef94 Add Byte, Char, Double, SByte, Single
svn path=/trunk/mcs/; revision=253
2001-07-20 00:37:51 +00:00
Miguel de Icaza 38fc0b7e52 Flush:
svn path=/trunk/mono/; revision=252
2001-07-19 23:46:41 +00:00
Miguel de Icaza c08e245ba4 2001-07-19 Duco Fijma ([email protected])
* TimeSpan.cs: New implementation.

svn path=/trunk/mcs/; revision=251
2001-07-19 23:46:16 +00:00
Miguel de Icaza 1dfd3f149b more classes
svn path=/trunk/mono/; revision=250
2001-07-19 23:31:14 +00:00
Miguel de Icaza 7d1ca46e56 Doc
svn path=/trunk/mono/; revision=249
2001-07-19 23:31:08 +00:00
Miguel de Icaza efb1694a28 UPdate
svn path=/trunk/mcs/; revision=248
2001-07-19 21:22:28 +00:00
Miguel de Icaza fab4b76caf UPdate
svn path=/trunk/mono/; revision=247
2001-07-19 20:54:25 +00:00
Miguel de Icaza 20e0bdccf7 Build two libraries for corlib
svn path=/trunk/mcs/; revision=246
2001-07-19 20:06:30 +00:00
Miguel de Icaza f8a7e2e43a 2001-07-19 Marcin Szczepanski <[email protected]>
* System.IO.MemoryStream.cs: Added.  Had quite a few cases of
	"LAMESPEC", but the tests work against the MS implementation so
	the major functions are right (ie. Read/Write/Seek).  Some more
	tests required for the various constructors and exceptions.

svn path=/trunk/mcs/; revision=245
2001-07-19 20:05:24 +00:00
Miguel de Icaza 44f9f53049 MemoryStream implementation from Marcin
svn path=/trunk/mcs/; revision=244
2001-07-19 20:04:24 +00:00
Miguel de Icaza 82ead61c46 Fix
svn path=/trunk/mcs/; revision=243
2001-07-19 20:02:00 +00:00
Miguel de Icaza c6315db4f2 More contributions
svn path=/trunk/mcs/; revision=242
2001-07-19 20:00:18 +00:00
Miguel de Icaza c9a179253e 2001-07-17 John Barnette <[email protected]>
* StringCollection.cs:
		Implemented and working according to spec.
	* StringIterator.cs:
		(ADDED) Implemented and working according to spec.
	* StringCollectionTest.cs:
		(ADDED) Initial revision contains 17 tests; all of 'em
		run correctly.  More complicated tests to follow.

svn path=/trunk/mcs/; revision=241
2001-07-19 19:44:01 +00:00
Miguel de Icaza 5f74e488d7 Add StrinEnumerator.cs and StringCollection.cs
svn path=/trunk/mcs/; revision=240
2001-07-19 19:43:32 +00:00
Miguel de Icaza 6c1e7d54f6 flush
svn path=/trunk/mono/; revision=239
2001-07-19 19:36:31 +00:00
Miguel de Icaza f9731130a0 More XML work
svn path=/trunk/mcs/; revision=238
2001-07-19 19:21:59 +00:00
Miguel de Icaza d1064be6fc Add cvsignore
svn path=/trunk/mcs/; revision=237
2001-07-19 19:12:32 +00:00
Miguel de Icaza ae13bcc209 Make compile
svn path=/trunk/mcs/; revision=236
2001-07-19 19:11:57 +00:00
Miguel de Icaza 1f57f2aefe Update
svn path=/trunk/mono/; revision=235
2001-07-19 18:54:11 +00:00
Miguel de Icaza 27cc06c335 Update for Sergey
svn path=/trunk/mcs/; revision=234
2001-07-19 18:48:56 +00:00
Miguel de Icaza da65ba8477 2001-07-18 Miguel de Icaza <[email protected]>
* assembly.c: Implement asssembly loading.  This loads an image
	and loads all the referenced assemblies.  Come to think of it, we
	could always do lazy loading of the assemblies.

	* image.c (mono_image_open): Keep loaded images in a hashtable.

	* image.h (MonoImage): Add reference count.

svn path=/trunk/mono/; revision=233
2001-07-19 02:06:21 +00:00
Miguel de Icaza 4e9bf00c8b *** empty log message ***
svn path=/trunk/mcs/; revision=232
2001-07-19 01:14:32 +00:00
Miguel de Icaza e565ef3cf4 Flushage
svn path=/trunk/mono/; revision=231
2001-07-19 00:51:23 +00:00
Miguel de Icaza 3370b81664 Fix
svn path=/trunk/mono/; revision=230
2001-07-19 00:50:27 +00:00
Miguel de Icaza 1890ca523a More updates
svn path=/trunk/mono/; revision=229
2001-07-19 00:41:46 +00:00
Miguel de Icaza 370d1051c9 ChangeLog
svn path=/trunk/mcs/; revision=228
2001-07-19 00:39:16 +00:00
Miguel de Icaza c006e942cd New version of BitArray
svn path=/trunk/mcs/; revision=227
2001-07-19 00:38:57 +00:00
Jeffrey Stedfast 7ba0609a3f 2001-07-17 Jeffrey Stedfast <[email protected]>
* String.cs (IndexOf): Slight optimization that allows skipping
	over a few chars here and there. This isn't as good as using my
	Boyer-Moore implementation, however, Boyer-Moore is only really
	good for long strings (I plan on making the code decide which
	string search algorithm it should use on-the-fly at some point).
	(LastIndexOf): Fix to work correctly.
	(BoyerMoore): Took out some unneeded code and fixed an edge-case.

svn path=/trunk/mcs/; revision=226
2001-07-18 20:52:10 +00:00
Miguel de Icaza cd5b27470d Update
svn path=/trunk/mono/; revision=225
2001-07-18 20:09:38 +00:00
Miguel de Icaza 5ffbfe9aff 2001-07-18 Miguel de Icaza <[email protected]>
* IDictionary.cs (Collections): IDictionary implements ICollection
	as well.  Thanks Sergey!

svn path=/trunk/mcs/; revision=224
2001-07-18 19:49:19 +00:00
Miguel de Icaza 950795ac2a 2001-07-17 David Menestrina <[email protected]>
* Added implementation of BitArray.

svn path=/trunk/mcs/; revision=223
2001-07-18 18:17:55 +00:00
Miguel de Icaza 0c8294b691 Flush
svn path=/trunk/mono/; revision=222
2001-07-18 04:35:45 +00:00
Miguel de Icaza f2a3141efd Add shared Common Language Infrastructure directory
svn path=/trunk/mono/; revision=221
2001-07-18 04:34:41 +00:00
Miguel de Icaza 1b0c8991e2 Renamed MonoAssembly to MonoImage to reflect better reality
svn path=/trunk/mono/; revision=220
2001-07-18 04:33:51 +00:00
Miguel de Icaza 74e1498136 2001-07-18 Miguel de Icaza <[email protected]>
* interp.c (ves_exec_method): Make the interpreter abort with more
	information than it currently does.

	Enable the slow processor, as it is easier to debug.

svn path=/trunk/mono/; revision=219
2001-07-18 04:32:29 +00:00
Miguel de Icaza 6ea509c10d 2001-07-17 Miguel de Icaza <[email protected]>
* metadata.h: Fixed Paolo's quick hack.  Put the documnentation
	from get.c here.

2001-07-17  Miguel de Icaza  <[email protected]>

	* main.c (usage): Print out all the arguments.

	* get.c, main.c, dump.c: Remove `expand', `get_encoded_value',
	`get_blob_encoded_size' and replaced with the proper functions
	from metadata.c

:

svn path=/trunk/mono/; revision=218
2001-07-18 02:48:19 +00:00
Miguel de Icaza d2bbe69ce9 release 17
svn path=/trunk/mono/; revision=217
2001-07-18 00:45:44 +00:00
Miguel de Icaza 5fddaa130d Add .src files
svn path=/trunk/mcs/; revision=215
2001-07-18 00:28:32 +00:00
Miguel de Icaza a6e4a33c8d Compile
svn path=/trunk/mcs/; revision=214
2001-07-18 00:28:00 +00:00
Miguel de Icaza f1d8c30e0c Update .cvsinogre
svn path=/trunk/mono/; revision=213
2001-07-17 23:55:10 +00:00
Miguel de Icaza 6757939478 More classes contributed
svn path=/trunk/mono/; revision=212
2001-07-17 23:50:31 +00:00
Miguel de Icaza df4c7333d1 Fixes from the Linux machine
svn path=/trunk/mono/; revision=211
2001-07-17 23:49:53 +00:00
Miguel de Icaza 21032d6471 System.Configuration.Assemblies contributions
svn path=/trunk/mcs/; revision=210
2001-07-17 23:46:03 +00:00
Miguel de Icaza 732aad5b3c Add Hashtable
svn path=/trunk/mcs/; revision=209
2001-07-17 23:11:25 +00:00
Miguel de Icaza bb3b9ee4a8 Flush
svn path=/trunk/mono/; revision=208
2001-07-17 22:58:45 +00:00
Miguel de Icaza 85c1bd5a40 changes
svn path=/trunk/mono/; revision=207
2001-07-17 22:44:39 +00:00
Miguel de Icaza 29bb08eef1 2001-07-17 Miguel de Icaza <[email protected]>
* tree.cs: moved IGenerator interface and renamed it to ITreeDump
	and put it here.

	Get rid of old crufty code.

	* rootcontext.cs: Use this to keep track of the parsed
	representation and the defined types available to the program.

	* gen-treedump.cs: adjust for new convention.

	* type.cs: Split out the type manager, and the assembly builder
	from here.

	* typemanager.cs: the type manager will live here now.

svn path=/trunk/mcs/; revision=206
2001-07-17 22:36:02 +00:00
Miguel de Icaza 4307dfe19b Update
svn path=/trunk/mono/; revision=205
2001-07-17 22:16:29 +00:00
Miguel de Icaza d0816bbaf5 Flush
svn path=/trunk/mono/; revision=204
2001-07-17 22:05:04 +00:00
Sean MacIsaac 572b585623 Updates need to push class status info to web pages.
svn path=/trunk/mono/; revision=203
2001-07-17 21:55:28 +00:00
Miguel de Icaza 6df61cf597 Flush
svn path=/trunk/mono/; revision=202
2001-07-17 20:19:34 +00:00
Sean MacIsaac 1c6a95d5c5 * ByNamespace.xsl: removed bug for improper handling of namespace.
eg System.Collections.Blah was showing up in System list.

svn path=/trunk/mono/; revision=201
2001-07-17 17:07:02 +00:00
Miguel de Icaza 1810099995 More classes
svn path=/trunk/mcs/; revision=200
2001-07-17 16:19:12 +00:00
Miguel de Icaza e9eac38d6d Add more files
svn path=/trunk/mcs/; revision=199
2001-07-17 16:14:11 +00:00
Miguel de Icaza 23694e8df9 Add code for System.Diagnostics
svn path=/trunk/mcs/; revision=198
2001-07-17 16:13:07 +00:00
Miguel de Icaza fa43078dab Flush
svn path=/trunk/mono/; revision=197
2001-07-17 06:06:40 +00:00
Miguel de Icaza 1d138da62c Pushety push
svn path=/trunk/mono/; revision=196
2001-07-17 06:04:00 +00:00
Miguel de Icaza 698c69f4f3 Add Stack.cs
svn path=/trunk/mcs/; revision=195
2001-07-17 05:45:59 +00:00
Miguel de Icaza 6d5b30bc68 Flush
svn path=/trunk/mono/; revision=194
2001-07-17 05:42:01 +00:00
Miguel de Icaza f182491301 flush
svn path=/trunk/mono/; revision=193
2001-07-17 05:26:15 +00:00
Miguel de Icaza e268c79ca9 More contributors
svn path=/trunk/mono/; revision=192
2001-07-17 04:18:02 +00:00
Miguel de Icaza bc07f59304 More volunteers! YAY!
svn path=/trunk/mono/; revision=191
2001-07-16 22:45:05 +00:00
Miguel de Icaza 4c395b4418 Update it
svn path=/trunk/mono/; revision=190
2001-07-16 22:40:28 +00:00
Miguel de Icaza 20884f6d29 Update to the site
svn path=/trunk/mono/; revision=189
2001-07-16 22:34:44 +00:00
Miguel de Icaza a8c250b215 Update maintainers
svn path=/trunk/mono/; revision=188
2001-07-16 22:34:18 +00:00
Miguel de Icaza d069c98174 Make it compile
svn path=/trunk/mcs/; revision=187
2001-07-16 22:31:13 +00:00
Miguel de Icaza ac9aaea8d4 Source files
svn path=/trunk/mcs/; revision=186
2001-07-16 22:25:35 +00:00
Miguel de Icaza b00d04aaa4 Add new files
svn path=/trunk/mcs/; revision=185
2001-07-16 22:02:05 +00:00
Miguel de Icaza 4dc202d35e 2001-07-16 Marcin Szczepanski <[email protected]>
* StringReader.cs, StringWriter.cs, TextReader.cs, TextWriter.cs:
	New class implemenations.

	* StringReaderTest.cs, StringWriterTest.cs: Test suite for the above.

2001-07-16  Marcin Szczepanski <[email protected]>

	* StringBuilder.cs (Text): Fixed.

	* StringBuilderTest.cs: Implement Test suite.

svn path=/trunk/mcs/; revision=184
2001-07-16 22:01:34 +00:00
Miguel de Icaza c62ebf3662 2001-07-16 Miguel de Icaza <[email protected]>
* Version.cs: Remove my buggy comment.

svn path=/trunk/mcs/; revision=183
2001-07-16 20:28:41 +00:00
Sean MacIsaac dace380b08 * class.xml: added all classes from corlib.
* maintainers.xml: maintainers from corlib.

svn path=/trunk/mono/; revision=182
2001-07-16 09:30:20 +00:00
Sean MacIsaac a43966b183 Typos in comments.
svn path=/trunk/mcs/; revision=181
2001-07-16 09:21:28 +00:00
Sean MacIsaac 2bfb6c885d * ByNamespace.xsl: Needed by ByNamespace.cs.
* ByNamespace.cs: Generates html by namespace..

* ByMaintainer.xsl: Needed by ByMaintainer.cs.

* ByMaintainer.cs: Generates html by maintainer.

* class.xml: Class maintainers go here.

* maintainers.xml: Only maintaining email/name pairs here.

* compare-assembly.cs: Started refactoring to give what Migee
wants.

svn path=/trunk/mono/; revision=180
2001-07-16 08:11:12 +00:00
Miguel de Icaza dd1f100f5c 2001-07-15 Miguel de Icaza <[email protected]>
* main.c (dis_code): Only display .entrypoint when we are dealing
	with a module that contains an entry point.  This removes a bunch
	of warnings for .dll dumping

svn path=/trunk/mono/; revision=179
2001-07-16 03:20:23 +00:00
Sean MacIsaac ef1fdf5b8b * status/compare-assembly.cs: basedir should be there if
parameters are provided.

* status/makefile: made targets to dump info.

svn path=/trunk/mono/; revision=178
2001-07-16 03:00:31 +00:00
Miguel de Icaza ccb226ef75 more contributors
svn path=/trunk/mono/; revision=177
2001-07-16 02:45:22 +00:00
Miguel de Icaza 7417a4d8e4 Update
svn path=/trunk/mono/; revision=176
2001-07-16 02:39:13 +00:00
Miguel de Icaza a5a212f642 0.4
svn path=/trunk/mono/; revision=174
2001-07-16 02:06:13 +00:00
Miguel de Icaza 5d709bcdb5 Add release notes
svn path=/trunk/mono/; revision=173
2001-07-16 02:01:00 +00:00
Miguel de Icaza 70ece6c4a0 Flushage
svn path=/trunk/mono/; revision=172
2001-07-16 01:50:36 +00:00
Miguel de Icaza 405dc3ea6c Add System.XML
svn path=/trunk/mcs/; revision=170
2001-07-16 01:07:36 +00:00
Miguel de Icaza 39a57ed2e5 Add .cvsignore
svn path=/trunk/mono/; revision=169
2001-07-16 00:49:43 +00:00
Miguel de Icaza 57def253ae Build doc directory
svn path=/trunk/mono/; revision=168
2001-07-16 00:49:19 +00:00
Miguel de Icaza 3bc2a24a3a Flush
svn path=/trunk/mono/; revision=167
2001-07-16 00:46:46 +00:00
Miguel de Icaza 92f0a06788 Flush
svn path=/trunk/mono/; revision=166
2001-07-16 00:45:31 +00:00
Miguel de Icaza ba11592b2c John
svn path=/trunk/mono/; revision=165
2001-07-15 22:03:51 +00:00
Miguel de Icaza 0992611bf0 Add spaces
svn path=/trunk/mono/; revision=164
2001-07-15 21:57:26 +00:00
Joe Shaw 800c8c64cf Flush. Add comments about IList
svn path=/trunk/mcs/; revision=163
2001-07-15 20:45:16 +00:00
Joe Shaw b529037728 Added some info about System.Array
svn path=/trunk/mcs/; revision=162
2001-07-15 20:41:19 +00:00
Joe Shaw 7404b2e846 2001-07-15 Joe Shaw <[email protected]>
* configure.in: Don't create doc/Makefile as there's nothing there
	to make.

	* Makefile.am: Don't build the doc directory because there's no
	Makefile.am there.

svn path=/trunk/mono/; revision=161
2001-07-15 20:33:14 +00:00
Joe Shaw cfc2593d84 2001-07-15 Joe Shaw <[email protected]>
* autogen.sh: Call aclocal with the $ACLOCAL_FLAGS env var.

svn path=/trunk/mono/; revision=160
2001-07-15 20:30:07 +00:00
Miguel de Icaza a84f29dc6d Flush documentation changes, and update maintainers
svn path=/trunk/mono/; revision=159
2001-07-15 18:59:26 +00:00
Miguel de Icaza 2abd9a70e2 Flush documentation changes, and update maintainers
svn path=/trunk/mono/; revision=158
2001-07-15 18:57:59 +00:00
Paolo Molaro f462287294 Sun Jul 15 19:39:06 CEST 2001 Paolo Molaro <[email protected]>
* metadata.c, metadata.h: decode local vars in method header
	parse function. Change callers accordingly.

svn path=/trunk/mono/; revision=157
2001-07-15 17:41:25 +00:00
Paolo Molaro e0a57962b1 Sun Jul 15 17:50:23 CEST 2001 Paolo Molaro <[email protected]>
* Started changelog.
	* interp.c: use new mono_get_method () function to get the complete
	info on a method invocation: we support now method invocation with
	multiple (or zero) simple arguments and with or without a return value.
	Implement also a couple more opcodes.

svn path=/trunk/mono/; revision=156
2001-07-15 16:26:06 +00:00
Paolo Molaro ab9d0406da Fix typo and remove debug prints.
svn path=/trunk/mono/; revision=155
2001-07-15 16:25:17 +00:00
Paolo Molaro 8c1647dc82 Sun Jul 15 17:29:10 CEST 2001 Paolo Molaro <[email protected]>
* get.h,get.c: added some dis_stringify_object() functions:
	metadata decoding is now done in libmetadata. Still need to use
	them throughhout the code (and move other decode code to
	metadata). Fix also field decoding (band-aid until we load
	also referenced assemblies).
	* dis/main.c: start using the new routines.

svn path=/trunk/mono/; revision=154
2001-07-15 16:14:11 +00:00
Paolo Molaro c67de2d075 Sun Jul 15 17:40:47 CEST 2001 Paolo Molaro <[email protected]>
* metadata.h, cil-coff.h: protect against multiple inclusion.
	Added some new structures to hold information decoded from metadata:
	MonoType, MonoParam, MonoArray, MonoMethod, MonoMethodSignature
	and relevant decoding/free functions.
	* metadata.c: implement decoding functions. Add warning for out of bounds
	index in mono_metadata_locate(). Implement mono_get_method () to retreive
	all the info about a method signature and invocation. Remove check on
	uninitialized local var in parse_mh() and fix memory leak.

svn path=/trunk/mono/; revision=153
2001-07-15 16:13:54 +00:00
Sean MacIsaac a6ffb6c02a * String.cs: Spelling error of IComparable, object's
MemberwiseClone cannot be overridden.  Made indexer valid for now,
but not sure what to do about this in the long run.  Seems to be a
couple bugs in csc.exe having to do with multiple pointer defs in
the same statement, and returning subclasses of a class in the
return type of an interface function implementation.  Also moved
operators inside of class definition.

svn path=/trunk/mcs/; revision=152
2001-07-15 08:02:44 +00:00
Sean MacIsaac da54cf461f * IDictionary.cs: Clear was clear.
svn path=/trunk/mcs/; revision=151
2001-07-15 07:39:54 +00:00
Sean MacIsaac 9a5ade334f * makefile: added windows and unix targets.
svn path=/trunk/mcs/; revision=150
2001-07-15 05:46:41 +00:00
Sean MacIsaac 3dfc511a33 * StringCollection.cs: Added so that CodeDom.* would compile.
svn path=/trunk/mcs/; revision=149
2001-07-15 05:45:23 +00:00
Sean MacIsaac 1fe22719b1 * MemberAttributes.cs: Added so rest of classes would compile.
* FieldDirection.cs: Added so rest of classes would compile.

* CodeTypeMember.cs: Added so rest of classes would compile.

* CodeTypeDeclaration.cs: Added so rest of classes would compile.

* CodeObject.cs: Added so rest of classes would compile.

* CodeBinaryOperatorType.cs: Added so rest of classes would compile.

svn path=/trunk/mcs/; revision=148
2001-07-15 05:44:59 +00:00
Sean MacIsaac c0d11bde1d * CodeGenerator.cs: moved using statement out of namespace
declaration.

svn path=/trunk/mcs/; revision=147
2001-07-15 05:44:43 +00:00
Sean MacIsaac 6fb3de52cb makefile *.src easy compilation stuff.
svn path=/trunk/mcs/; revision=146
2001-07-15 04:57:07 +00:00
Sean MacIsaac 210c1115e9 Removing uneccessary files.
svn path=/trunk/mcs/; revision=145
2001-07-15 04:27:43 +00:00
Sean MacIsaac abb7a6759f Removing unnecessary files.
svn path=/trunk/mcs/; revision=144
2001-07-15 04:27:10 +00:00
Sean MacIsaac bf879a9795 Changes to the makefiles to allow cleaner builds.
svn path=/trunk/mcs/; revision=143
2001-07-15 04:21:27 +00:00
Jeffrey Stedfast 393b396ebf 2001-07-14 Jeffrey Stedfast <[email protected]>
* String.cs: A tom of compile fixes, although we still don't compile.

	* IConvertible.cs: The To*Int64() methods return *Int64's, not
	*Int32's. Also, it's ToDateTime() not ToDateType().

svn path=/trunk/mcs/; revision=142
2001-07-15 04:11:49 +00:00
Sean MacIsaac a6d6ebabe6 .cvsignore
svn path=/trunk/mcs/; revision=141
2001-07-15 03:37:52 +00:00
Miguel de Icaza 60df095c46 Flushety flush
svn path=/trunk/mcs/; revision=140
2001-07-15 01:02:13 +00:00
Sean MacIsaac 6702db9247 Removed cs-parser.cs, as this is generated by jay
svn path=/trunk/mcs/; revision=139
2001-07-14 23:34:24 +00:00
Sean MacIsaac d021bf6bad Added the jay directory, compiler should be okay now.
svn path=/trunk/mcs/; revision=138
2001-07-14 23:30:42 +00:00
Jeffrey Stedfast 96e6f83423 2001-07-14 Jeffrey Stedfast <[email protected]>
* String.cs: Apparently I needed to at least write stubs for the
	IConvertible interfaces. *sigh*

svn path=/trunk/mcs/; revision=137
2001-07-14 22:55:48 +00:00
Jeffrey Stedfast bf760518ef more logic fixes and some code simplification
svn path=/trunk/mcs/; revision=136
2001-07-14 21:07:13 +00:00
Jeffrey Stedfast fff7bcfca2 2001-07-14 Jeffrey Stedfast <[email protected]>
* String.cs: Many logic/other fixes and better usage of the
	features of c#
	(tolower): New convenience method to help condense code.
	(toupper): Another new helper method.
	(Compare): Use the new helper methods.
	(ToLower): use tolower().
	(ToUpper): use toupper().
	(LastIndexOfAny): Implemented.
	(BoyerMoore): New private helper method that implements a modified
	version of the Boyer-Moore search algorithm. Noothing uses it yet
	as I'm not 100% sure it even works properly with unicode strings
	not to mention it uses a huge lookup-table :-)
	(Split): Implemented.

svn path=/trunk/mcs/; revision=135
2001-07-14 19:22:43 +00:00
Miguel de Icaza 7e002902d5 further web page loving
svn path=/trunk/mono/; revision=134
2001-07-14 19:04:58 +00:00
Miguel de Icaza feef427cdf Update authors
svn path=/trunk/mcs/; revision=133
2001-07-14 18:58:53 +00:00
670 changed files with 72161 additions and 10864 deletions

No files matched your search

+15 -9
View File
@@ -1,11 +1,17 @@
config.h
Makefile
config.cache
stamp-h.in
config.status
aclocal.m4
configure
stamp-h
libtool
Makefile.in
config.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
libtool
ltmain.sh
ltconfig
Makefile
Makefile.in
mono-*.tar.gz
stamp-h
stamp-h.in
+1
View File
@@ -1 +1,2 @@
Miguel de Icaza ([email protected])
Paolo Molaro ([email protected])
+94
View File
@@ -1,3 +1,97 @@
Tue Aug 21 18:54:06 CEST 2001 Paolo Molaro <[email protected]>
* mono/tests/exceptions*: enhanced and added more tests for
exceptions.
2001-08-20 Miguel de Icaza <[email protected]>
* mono/Makefile.am (SUBDIRS): Remove `test' from here to allow us
to pass make distcheck
* mono/wrapper/Makefile.am (EXTRA_DIST): Include genwrapper.pl
* configure.in, Makefile.am, runtime/Makefile.am (dist-hook,
install-data-hook): Added mechanism to distribute and install the
dll files.
2001-08-20 Dietmar Maurer <[email protected]>
* mono/tests/stream.cs: new tests for the Stream class
* configure.in: I really need LIBTOOL for libmonowrapper.so, so I
added it again.
2001-08-16 Alex Graveley <[email protected]>
* configure.in: Replace AM_PROG_LIBTOOL with AC_PROG_RANLIB. This
removes libtool dependency on all of Mono.
2001-08-10 Dietmar Maurer <[email protected]>
* mono/tests/array.cs: more array tests
2001-08-09 Dietmar Maurer <[email protected]>
* mono/tests/array.cs: more array tests
2001-08-06 Dietmar Maurer <[email protected]>
* mono/tests/pinvoke.cs: we can now print strings ;-)
* mono/tests/array.cs: new test for arrays
2001-08-02 Alex Graveley <[email protected]>
* libffi/*: Import libffi CVS version, with minor changes to make it
compile.
* mono/interpreter/Makefile.am: Link against
../../libffi/.libs/libffi.a.
* Makefile.am: Add libffi
* autogen.sh: Replace with adapted gnome autogen.sh
* configure.in: Add AC_CONFIG_SUBDIRS(libffi).
2001-08-02 Dietmar Maurer <[email protected]>
* mono/tests/pinvoke.cs: impl.
Wed Aug 1 22:34:52 CEST 2001 Paolo Molaro <[email protected]>
* configure.in, mono/tests: added some tests for the interpreter.
2001-07-15 Sean MacIsaac <[email protected]>
* doc/download: added instructions for cygwin
* doc/c-sharp: removed bit about compiling
* status/compare-assembly.cs: basedir should be there if
parameters are provided.
* status/makefile: made targets to dump info.
2001-07-15 Joe Shaw <[email protected]>
* configure.in: Don't create doc/Makefile as there's nothing there
to make.
* Makefile.am: Don't build the doc directory because there's no
Makefile.am there.
* autogen.sh: Call aclocal with the $ACLOCAL_FLAGS env var.
2001-07-15 Miguel de Icaza <[email protected]>
* doc/class-library (A): Updated FAQ with question on error 1595.
2001-07-14 Miguel de Icaza <[email protected]>
* doc/index:
Wed Jul 11 00:36:36 CEST 2001 Paolo Molaro <[email protected]>
* status/*: scripts and data to create statistics about the
+1 -1
View File
@@ -1 +1 @@
SUBDIRS = mono doc
SUBDIRS = libffi mono doc runtime
+39 -5
View File
@@ -1,8 +1,42 @@
This is MonoNet.
This is Mono.
Ximian's portable implementation of .NET
A directory roadmap:
doc/
Contains documentation and the web site contents.
mono/
The core of the executable.
metadata/
The library to deal with executables and libraries for
.NET
dis/
CIL executable Disassembler
cli/
Common code for the JIT and the interpreter.
cil/
Common Intermediate Representation, XML
definition of the CIL bytecodes.
interp/
Interpreter for CLI executables.
* Using Mono
Once you have installed the software, you can run a few programs:
monodis program.exe
That will dump the bytecodes for program.exe. Monodis support
a number of options that dumps various metadata tables
(chapter 23 of the Partition III).
You can try the interpreter like this:
mono-int program.exe
----------
To edit the go-mono website, see doc/README.
+141 -6
View File
@@ -1,6 +1,141 @@
libtoolize --automake
automake -a
autoheader
aclocal
autoconf
./configure $*
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
# Ripped off from GNOME macros version
DIE=0
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
if [ -n "$MONO_PATH" ]; then
ACLOCAL_FLAGS="-I $MONO_PATH/share/aclocal $ACLOCAL_FLAGS"
PATH="$MONO_PATH/bin:$PATH"
export PATH
fi
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`autoconf' installed to compile Mono."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && {
(libtool --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`libtool' installed to compile Mono."
echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
}
grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && {
grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \
(gettext --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`gettext' installed to compile Mono."
echo "Get ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
}
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`automake' installed to compile Mono."
echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
NO_AUTOMAKE=yes
}
# if no automake, don't bother testing for aclocal
test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: Missing \`aclocal'. The version of \`automake'"
echo "installed doesn't appear recent enough."
echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
if test "$DIE" -eq 1; then
exit 1
fi
if test -z "$*"; then
echo "**Warning**: I am going to run \`configure' with no arguments."
echo "If you wish to pass any to it, please specify them on the"
echo \`$0\'" command line."
echo
fi
case $CC in
xlc )
am_opt=--include-deps;;
esac
for coin in `find $srcdir -name configure.in -print`
do
dr=`dirname $coin`
if test -f $dr/NO-AUTO-GEN; then
echo skipping $dr -- flagged as no auto-gen
else
echo processing $dr
macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
( cd $dr
macrosdir=`find . -name macros -print`
if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then
if grep "sed.*POTFILES" configure.in >/dev/null; then
: do nothing -- we still have an old unmodified configure.in
else
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running gettextize... Ignore non-fatal messages."
echo "no" | gettextize --force --copy
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi
fi
if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
if test -z "$NO_LIBTOOLIZE" ; then
echo "Running libtoolize..."
libtoolize --force --copy
fi
fi
echo "Running aclocal $aclocalinclude ..."
aclocal $aclocalinclude || {
echo
echo "**Error**: aclocal failed. This may mean that you have not"
echo "installed all of the packages you need, or you may need to"
echo "set ACLOCAL_FLAGS to include \"-I \$prefix/share/aclocal\""
echo "for the prefix where you installed the packages whose"
echo "macros were not found"
exit 1
}
if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
echo "Running autoheader..."
autoheader || { echo "**Error**: autoheader failed."; exit 1; }
fi
echo "Running automake --gnu $am_opt ..."
automake --add-missing --gnu $am_opt ||
{ echo "**Error**: automake failed."; exit 1; }
echo "Running autoconf ..."
autoconf || { echo "**Error**: autoconf failed."; exit 1; }
) || exit 1
fi
done
conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
if test x$NOCONFIGURE = x; then
echo Running $srcdir/configure $conf_flags "$@" ...
$srcdir/configure $conf_flags "$@" \
&& echo Now type \`make\' to compile $PKG_NAME || exit 1
else
echo Skipping configure process.
fi
+12 -1
View File
@@ -1,6 +1,6 @@
AC_INIT(README)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(mono, 0.3)
AM_INIT_AUTOMAKE(mono, 0.6)
AM_MAINTAINER_MODE
AC_PROG_CC
@@ -23,6 +23,14 @@ GLIB_LIBS=`glib-config --libs glib`
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
GMODULE_CFLAGS=`glib-config --cflags gmodule`
GMODULE_LIBS=`glib-config --libs gmodule`
AC_SUBST(GMODULE_CFLAGS)
AC_SUBST(GMODULE_LIBS)
AC_CONFIG_SUBDIRS(libffi)
CFLAGS='-g -Wall -Wunused -Wmissing-prototypes -Wmissing-declarations'
AC_SUBST(CFLAGS)
@@ -33,5 +41,8 @@ mono/metadata/Makefile
mono/dis/Makefile
mono/cil/Makefile
mono/interpreter/Makefile
mono/tests/Makefile
mono/wrapper/Makefile
runtime/Makefile
doc/Makefile
])
+3
View File
@@ -0,0 +1,3 @@
Makefile.in
Makefile
all-docs
+19
View File
@@ -0,0 +1,19 @@
WEB_FILES= \
c-sharp class-library contact contributing documentation download \
faq gcc-frontend ideas index passport rationale resources \
roadmap runtime status team testing thanks tools
OTHERS= pending resources-pending todo
EXTRA_DIST = $(WEB_FILES) README $(OTHERS)
all-docs: $(WEB_FILES)
cat rationale roadmap c-sharp tools class-library \
runtime documentation download faq contributing \
resources status > all-docs
webit:
(cd web; make && make push)
push-notes:
scp release-notes/mono* www@www:/web/cvsmodules/mono/archive
+63 -26
View File
@@ -5,6 +5,10 @@
programs and create an internal tree representation of the
program. MCS can parse itself.
MCS now does type checking at the class, interface and struct
levels and can resolve the class hierarchy and as of last week
can generate interface code.
Work is progressing quickly on various fronts in the C#
compiler. Recently I started using the System.Reflection API
to load system type definitions and avoid self-population of
@@ -42,10 +46,11 @@
have to postpone this decision until the above steps
are finished.
* Code generation: nothing done so far, but I do not
expect this to be hard, as I will just use
System.Reflection.Emit to generate the code.
* Code generation: The compiler recently started generating IL
executables that contain interfaces. Work is
progressing in other areas.
The code generation is done through the System.Reflection.Emit API.
</ul>
<a name="tasks">
@@ -71,18 +76,7 @@
might have more information)
</ul>
Critical tasks:
<ul>
* Resolve "base" classes and "base" interfaces for
classes, structs and interfaces.
Once this is done, we can actually do the semantic
analysis, because otherwise we do not know who our
parents are.
</ul>
Interesting tasks:
Interesting and Fun hacks to the compiler:
<ul>
* Finishing the JB port from Java to C#. If you are
@@ -95,6 +89,15 @@
JB will allow us to move from the Berkeley Yacc
based Jay to a Bison-based compiler (better error
reporting and recovery).
* Semantic Analysis: Return path coverage and
initialization before use coverage are two great
features of C# that help reduce the number of bugs
in applications. It is one interesting hack.
* Enum resolutions: it is another fun hack, as enums can be defined
in terms of themselves (<tt>enum X { a = b + 1, b = 5 }</tt>).
</ul>
** Questions and Answers
@@ -133,19 +136,53 @@ A: No, currently I am using Jay which is a port of Berkeley Yacc to
In the future I want to port one of the Bison/Java ports to C# for
the parser.
Q: How do I compile it?
Q: Should someone work on a GCC front-end to C#?
A: Compiling MCS currently requires you to run my port of <a
href="http://primates.ximian.com/~miguel/code/jay.cs.tar.gz">Jay to
C#</a> on a Unix system to generate the parser, and then you need
to use Microsoft's .NET csc.exe compiler to compile the compiler.
A: I would love if someone does, and we would love to help anyone that
takes on that task, but we do not have the time or expertise to
build a C# compiler with the GCC engine. I find it a lot more fun
personally to work on C# on a C# compiler, which has an intrinsic
beauty.
You only need to compile the compiler compiler (C code), the
samples are Java samples that I did not port, and you do not need
them.
We can provide help and assistance to anyone who would like to work
on this task.
It might be simple to port Jay.cs to Windows, but I have not tried
this.
Q: Should someone make a GCC backend that will generate CIL images?
A: I would love to see a backend to GCC that generates CIL images. It
would provide a ton of free compilers that would generate CIL
code. This is something that people would want to look into
anyways for Windows interoperation in the future.
Again, we would love to provide help and assistance to anyone
interested in working in such a project.
Q: What about making a front-end to GCC that takes CIL images and
generates native code?
A: I would love to see this, specially since GCC supports this same
feature for Java Byte Codes. You could use the metadata library
from Mono to read the byte codes (ie, this would be your
"front-end") and generate the trees that get passed to the
optimizer.
Ideally our implementation of the CLI will be available as a shared
library that could be linked with your application as its runtime
support.
Again, we would love to provide help and assistance to anyone
interested in working in such a project.
Q: But would this work around the GPL in the GCC compiler and allow
people to work on non-free front-ends?
A: People can already do this by targeting the JVM byte codes (there
are about 130 compilers for various languages that target the JVM).
Q: Why are you writing a JIT engine instead of a front-end to GCC?
A: The JIT engine and runtime engine will be able to execute CIL
executables generated on Windows.
You might also want to look at the <a href="faq.html#gcc">GCC</a>
section on the main FAQ
+112
View File
@@ -0,0 +1,112 @@
* CVS Access
If you are an active Mono developer, you can get a CVS account
that hosts the Mono source code.
Send an e-mail to miguel with your public SSH key for this
purpose. Please specify if the key was generated with SSH1 or SSH2.
If you are using SSH2, please generate your key using:
<pre>
ssh-keygen -t rsa
</pre>
And mail me the id_rsa.pub file.
If you are using SSH1, run:
<pre>
ssh-keygen
</pre>
And mail me your identity.pub file.
You will need CVS and SSH. Windows users can get both by
installing Cygwin (<a
href="http://www.cygwin.com">http://www.cygwin.com</a>)
Unix users will probably have those tools installed already.
** Checking out the sources
To check out the sources for the first time from the
repository, use this command:
<pre>
export CVS_RSH=ssh
export [email protected]:/cvs/public
cvs -z3 co mcs mono
</pre>
** Updating your sources
Every day people will be making changes, to get your latest
updated sources, use:
<pre>
cvs -z3 update -Pd mcs mono
</pre>
Note: The '-z3' enables compression for the whole cvs action.
The '-Pd' makes the update operation (P)rune directories that
have been deleted and get new (d)irectories added to the
repository.
** Making patches
Usually you will want to make a patch to contribute, and let
other people review it before commiting it. To obtain such a
"patch", you type:
<pre>
cd directory-you-want-to-diff
cvs -z3 diff -u > file.diff
mail [email protected] < file.diff
</pre>
** Commiting your work
Once you get approval to commit to the CVS, or if you are
commiting code that you are the maintainer of, you will want
to commit your code to CVS.
To do this, you have to "add" any new files that you created:
<pre>
cvs add new-file.cs
</pre>
And then commit your changes to the repository:
<pre>
cvs commit file-1.cs file-2.cs
</pre>
** The Mailing List
To keep track of the various development and changes to the
CVS tree, you can subscribe to the [email protected].
To subscribe, send an email message to
[email protected] and in the body of the
message put `subscribe'.
This will send you an email message every time a change is
made to the CVS repository, together with the information that
the author of the changes submitted.
** Recommendations
Please do not commit code that would break the compile to the
CVS, because that normally wastes everybody's time.
Make sure that you add all the files before you do a commit.
Use ChangeLog entries so we can keep textual descriptions of
your work, and use the contents of your ChangeLog file as the
CVS commit message (ie, paste the contents of this into the
editor buffer).
If you are making changes to someone else's code, please make
sure you get in touch with the maintainer of that code before
applying patches. You want to avoid commiting conflicting
work to someone else's code.
+41 -7
View File
@@ -3,10 +3,36 @@
The Class Library should be compatible with Microsoft's .NET
implementation.
Please see the <a href="class-status.html">Class Status</a>
page for a status of who is working on which classes.
We will write as much code as possible in C#. We may need to
interface with code written in C to gain access to the
functionality of
libraries like libart, Gtk+, and libc.
functionality of libraries like libart, Gtk+, and libc.
** Contributing
We welcome contributions to the the Class Library. To get
started, check the status page for information about which
APIs are being worked on, and how to get in touch with
individual maintainers.
If you want to work on a class, first check the <a
href="download.html">Classes Distribution</a> to see if it is
not implemented yet, if not, check the <a
href="class-status.html">Class Status</a> to see if someone is
already working on it, and maybe contact them.
If nobody is working on it, mail <a
href="mailto:[email protected]">[email protected]</a>
with the class you want to implement and CC <a
href="mailto:[email protected]">[email protected]</a>.
You can also track live the activities of the Mono CVS module
by subscribing to the <a
href="http://mail.ximian.com/mailman/listinfo/mono-cvs-list">mono-cvs-list</a>
** Layout
@@ -105,6 +131,9 @@
the correctness of the class library, compiler, and JIT
engine.
Please write your regression tests using <a
href="http://nunit.sourceforge.net">NUnit</a>
** Coding conventions
Please follow the conventions on the ECMA specification (On
@@ -140,10 +169,15 @@
In those cases, use the keyword "LAMESPEC".
** Contributing
** FAQ
We welcome contributions to the the Class Library. To get
started, check the status page for information about which
APIs are being worked on, and how to get in touch with
individual maintainers.
Frequently asked questions about the class library:
Q: I am writing a new class that overrides one of the system classes,
and I am getting a 1595 warning from the compiler. Should we use a
different namespace?
A: There is a quick solution to the problem, you can pass the command
line argument /nowarn:1595 and this will effectively let you use
your implementation of the code, while overriding the ones from the
system assemblies.
+16
View File
@@ -0,0 +1,16 @@
* Status of the various pieces of the class library
You can browse the status of the class library and see who has
registered to work on what parts of the system. These list
work-in-progress components currently.
Browse the current <a href="class-status/index.html">status</a>.
You can also download the XML <a
href="class-status/maintainers.xml">maintainers</a> file that
contains the actual maintainers list.
You can also download the master <a
href="class-status/class.xml">Class Status XML</a> file.
+1 -1
View File
@@ -1,7 +1,7 @@
* Contacting the Mono team.
You can contact the Mono Team by sending e-mail to `<a
href="mailto:[email protected]">mailto:[email protected]</a>'.
href="mailto:[email protected]">[email protected]</a>'.
You can contact the general forum of discussion by sending
e-mail to <a href="mailto:[email protected]">[email protected]</a>
+55 -3
View File
@@ -10,7 +10,7 @@
href="tools.html">the tools</a>, the <a
href="testing.html">testing framework</a>
* <b>Writers:</b> You can help us with writing <a
* <b>Writers:</b> You can help us bywriting <a
href="documentation.html">documentation</a>.
</ul>
@@ -18,6 +18,28 @@
something that would help tremendously would be to help with
small duties in the project that need to be addressed.
** To start contributing
To start developing classes or to contribute to the compiler,
you only need Windows and the .NET Beta 2 SDK. Please notice
that you do not need Visual Studio (although you can use it if
you want).
You can get it <a href="http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/000/976/msdncompositedoc.xml&frame=true">here</a>
Alternatively you can use the <a
href="#compile-service">compilation service</a> that was setup by
Derek.
** Bug reporting
If you find bugs in Mono, please make sure you enter a bug
report so we can keep track of problems in Mono.
To enter bug reports go to <a href="http://bugzilla.ximian.com">
http://bugzilla.ximian.com</a> and enter bug reports against
your favorite component (Mono, Runtime, C# compiler).
** Small tasks
A few smaller tasks are here, dropped in no particular order:
@@ -29,10 +51,40 @@
* <b>Mono/doc and web site:</b> They need to be
packaged up in the official `distribution'
* <b>Enthusiasts: </b>
</ul>
<a name="compile-service">
* C# Compilation Service
If you are working on a class for the Mono project, but do not
have a C# compiler available or a Windows machine to run the
.NET SDK, you can use the compilation service that Derek
Holden setup in the following URL: <a
href="http://toilet.2y.net:8080/">http://toilet.2y.net:8080/</a>
The service will let you compile a source file and get back a
list of errors in the class file. You will not be able to run
the code, but at least you can get some code written that will
help us further down the line.
You can contact (and thank) Derek for this service by sending
him nice email at <a
href="mailto:[email protected]">[email protected]</a>
* Books on C# and DotNet.
<ul>
* Dotnet Books (<a href="http://www.dotnetbooks.com">http://www.dotnetbooks.com</a>)
* Dotnet Resources (<a href="http://www.dotnetexperts.com/resources/">
http://www.dotnetexperts.com/resources</a>)
* O'Really C# Essentials (<a href="http://www.oreilly.com/catalog/csharpess/">
http://www.oreally.com/catalog/csharpess</a>)
* O'Really .NET Essentials (<a href="http://www.oreilly.com/catalog/dotnetfrmess/">
http://www.oreally.com/catalog/dotnetfrmess</a>)
* Special note
If you have looked at Microsoft's implementation of .NET or
+190
View File
@@ -0,0 +1,190 @@
* Developer FAQ
** New classes
Q: Should we write classes which are not part of the .NET or ECMA specs?
A: Yes. The ECMA and .NET specifications are far from complete, and
to produce a complete platform we will need a number of other
classes and components.
Any new classes that are not part of .NET or ECMA should be
designed to be reusable on anyone's CLI implementation. So that
Windows developers can also use any new classes that we come up
with.
We have a few existing <a href="ideas.html">Ideas on missing
classes</a>
** Language Compatibility
Q: What is the magic that allow multiple languages to co-exist?
A: From Fergus Henderson:
<i><blockquote>
There are different levels of interoperability.
The ECMA spec defines different categories of
CLS (Common Language Specification) conformance.
There are also some useful categories that don't
correspond to any of the levels defined in the ECMA spec.
In increasing degree of difficulty, your language implementation
can
<ul>
* (a) just generate IL
* (b) be a CLS "consumer", which means that it can read in
meta-data describing component interfaces,
and that it provides a way to declare variables of
CLS-complaint types and to call CLS-complaint methods.
* (c) be a CLS "extender", which means that it can in addition
derive from CLS-compliant classes
and implement CLS-compliant interfaces
* (d) be able to produce components with *any* CLS-compliant
component interface.
</ul>
Supporting some of these may require extending your language. However,
you can get quite a lot of interoperability by just putting appropriate
functionality in your compiler, without extending your language.
For some things, e.g. ASP.NET, your language implementation also needs to be
able to
<ul>
* (e) consume CodeDom trees. CodeDom trees are an abstract
representation of programs in a form similar to a C# parse
tree, with embedded code snippets (unparsed strings).
Given a CodeDom tree, with the snippets in your language,
your language implementation needs to generate a (i) .NET
assembly and possibly also (ii) a source file in your language.
* (f) produce CodeDom trees. For some applications,
your language implementation also needs to be able to
round-trip from CodeDom -> your language -> CodeDom.
</ul>
and for some things it needs to
<ul>
* (g) generate *verifiable* IL
</ul>
So when you hear all the hype about how language XYZ is a
".NET language", make sure you ask which of these different
things are supported.
[For the record, Mercury currently supports (a). We're working on
(b) and (g), and on parts of (c) and (e). We're never going to do (f), I very
strongly doubt we'll ever do (d), and for (c) we might only ever support
implementing interfaces, not deriving from classes.]
</blockquote></i>
** PInvoke
Q: What are the two major initiatives to implement PInvoke?
A: Fergus Henderson answers:
<i><blockquote>
Many of the .NET APIs will need to be implemented using code that calls C/Unix
APIs, such as stat(). The standard way of interfacing with native code from
.NET code is to use "PInvoke". However, there is a difficulty: many of
these APIs are defined in terms of types such as C's `long' or `size_t'
or the Posix `struct stat' whose representation varies depending on the
platform (architecture/OS/C compiler). There's no *portable* way of
accessing those from .NET managed code.
So, there are a couple of different approaches.
One possibility is to access such routines by writing a wrapper, e.g. in C,
that provides the same functionality without using types with a system-dependent
representation. The wrapper can then be directly accessed from portable
.NET code. The .NET code remains both source- and binary-portable;
the wrapper code is source-portable, but needs to be compiled
seperately for each target platform. The drawback of this approach is
that you have to write a lot of cumbersome wrapper code.
Another possibility is to extend the .NET VM with support for an
additional custom attribute, e.g. "[PosixType]". The VM would then
represent types tagged with this attribute in the same way that the
underlying system represents those types. With this approach, no
wrapper code would be needed. A drawback of this approach is that it
pushes quite a bit of complexity into the VM; the VM would have to know
the native representation of all types annotated with this attribute.
Another drawback is that code using this extension might not work on
different VMs.
There have also been some other suggestions, but those are the two that
I think are the best.
</blockquote></i>
Q: What is the problem implementing PInvoke?
A: Again, from Fergus Henderson:
<i><blockquote>
There's no problem implementing PInvoke as specified in the ECMA
specs and/or MS documentation. It's just that PInvoke by itself
doesn't solve all of the problems; in particular it doesn't solve
the problem of C types whose representation is different on different
systems.
</blockquote></i>
** CVS use
Q: Why do we keep ChangeLogs and make the CVS commit messages be the
same? One could be generated from the other
A: There are a number of reasons for keeping ChangeLog files as well as
CVS commit files:
<ul>
* Offline programming: when people are traveling, CVS logs are
not available.
* Slow CVS access: Many people work over modem lines (very
typical for contributors in Europe, Asia, Latin America)
using CVS is slow and might not be available to you (cvs
server down, no anoncvs server available).
* ChangeLogs travel in a released tarball package, so it is
possible to study the rationale of changes even after a
project is long "released", or you only have the sources for
the code.
* ChangeLog are not metadata for each file, they are live
files that you can browse in the package that is being
distributed.
</ul>
Making the CVS commit message be the same as the ChangeLog has other
benefits:
<ul>
* You can track down with `cvs log' what things were changed,
and match those to meaningful reports on the intentions of
the commit.
* When reading the commits-list, you can get a glimpse of the
changes without having to diff out or cvs update your tree.
* You can read off-line the changes that are being made
(asyncrouns operation).
</ul>
This mechanism works very well for GNOME and other projects.
Q: Should I use any of the special RCS keywords like $Id: devel-faq,v 1.1 2001/07/31 21:13:05 miguel Exp $, $Author: miguel $,
$Date: 2001/07/31 21:13:05 $, or $Revision: 1.1 $?
A: Please avoid using those in the source code in the CVS. They
are not really useful, and they cause a lot of conflicts when
people have separate CVS trees.
It was a nightmare with the Linux kernel when two people had their
private CVS trees and were submitting patches to the core.
+142 -7
View File
@@ -10,33 +10,168 @@
test suite and the class library are in the `mcs' package, we
will move this later into `mono' itself.
The mcs compiler requires the `jay' parser generator, this is
available in module `jay'.
In order to make mcs and the class libraries you will need the
GNU make tools. These may be obtained for the Windows
environment from <a href="http://www.cygwin.com">cygwin.com</a>.
You will also need to get GLIB, from: <a
href="ftp://ftp.gtk.org/pub/gtk/v1.2/glib-1.2.10.tar.gz">ftp://ftp.gtk.org/pub/gtk/v1.2/glib-1.2.10.tar.gz</a>
<a name="sources">
** Sources
Currently we will be providing CVS snapshots every day, until
we make the first tarball release.
We provide both <a href="packaged">packaged and tested</a>
tarballs (those are known to compile and pass `make
distcheck') as well as <a href="snapshots">daily snapshots</a> done
at 10pm Boston Time
<a name="snapshots">
*** Snapshots
The daily snapshots are available <a
href="http://www.go-mono.com/snapshots">here</a>. These
snapshots are done every day at 10pm EST (Boston Time).
They are not guaranteed to build, but most of the time they
should. They should give you a window to see what we are up to.
You might also want to track our development using the <a
href="http://mail.ximian.com/mailman/listinfo/mono-cvs-list">mono-cvs-list</a>
mailing list.
<a name="packaged">
*** Released and tested packages
<ul>
<b>July 12th, 2001</b>
<a name="july-29">
<b>July 29, 2001</b>
<ul>
* <a href="archive/mono-0.5.tar.gz">mono-0.5.tar.gz</a>: Mono Runtime 0.5 release
* <a href="archive/mono-0.5">Release Notes</a>
</ul>
<a name="july-22">
<b>July 22, 2001</b>
<ul>
* <a href="archive/mcs-22-Jul-2001.tar.gz">mcs-22-Jul-2001.tar.gz</a>: CVS snapshot.
* <a href="archive/mcs-Jul-22-Jul-19-2001.tar.gz">Differences since 19</a>: CVS snapshot.
* <a href="archive/mcs-22">Release Notes</a>
</ul>
<a name="july-19">
<b>July 19th, 2001</b>
<ul>
* <a href="archive/mcs-19-Jul-2001.tar.gz">mcs-19-Jul-2001.tar.gz</a>: CVS snapshot.
* <a href="archive/mcs-Jul-17-Jul-19-2001.tar.gz">Differences since 17</a>: CVS snapshot.
* <a href="archive/mcs-19">Release Notes</a>
</ul>
<a name="july-17">
<b>July 17th, 2001</b>
<ul>
* <a href="archive/mcs-17-Jul-2001.tar.gz">mcs-17-Jul-2001.tar.gz</a>: CVS snapshot.
* <a href="archive/mcs-Jul-15-Jul-17-2001.tar.gz">Differences since 15</a>: CVS snapshot.
* <a href="archive/mcs-17">Release Notes</a>
</ul>
<a name="july-15">
<b>July 15th, 2001</b>
<ul>
* <a href="archive/mcs-15-Jul-2001.tar.gz">mcs-15-Jul-2001.tar.gz</a>: CVS snapshot.
* <a href="archive/mono-0.4.tar.gz">mono-0.4.tar.gz</a>: Packaged Source Code.
* <a href="archive/mono-0.4">Release Notes</a>
</ul>
<a name="july-14">
<b>July 14th, 2001</b>
<ul>
* <a href="archive/jay.cs.tar.gz">archive/jay.cs.tar.gz</a>: Sources to Jay.
* <a href="archive/mcs-12-Jul-2001.tar.gz">mcs-12-Jul-2001.tar.gz</a>: CVS snapshot.
* <a href="archive/mono-0.3.tar.gz">mono-0.3.tar.gz</a>: Packaged Source Code.
</ul>
<a name="july-8">
<b>July 8th, 2001</b>
<ul>
* <a href="archive/jay.cs.tar.gz">archive/jay.cs.tar.gz</a>: Sources.
* <a href="archive/mcs-08-Jul-2001.tar.gz">mcs-08-Jul-2001.tar.gz</a>: CVS Snapshot
* <a href="archive/mono-08-Jul-2001.tar.gz">mono-08-Jul-2001.tar.gz</a>: CVS Snapshot
</ul>
</ul>
<a name="install">
** Installing the software
To install and work on the compiler and the class libraries,
follow these instructions:
<ul>
* Install <a href="http://www.cygwin.com">CygWin</a> first.
* Untar the MCS distribution (see below for information).
* Go into the MCS directory and type `make windows'
</ul>
To compile the mono runtime on windows:
<ul>
* Install <a href="http://www.cygwin.com">CygWin</a> first.
* Once installed, in a terminal window or a cygwin
window (a shortcut should be on your desktop), untar the glib
distribution:
<pre>
tar xzvf glib-1.2.10.tar.gz
</pre>
* Configure, compile and install glib, like this:
<pre>
./configure --prefix=/usr
make
make install
</pre>
* Unpack the mono distribution:
<pre>
tar xzvf mono-XXX.tar.gz
</pre>
* Configure, compile and install:
<pre>
./configure --prefix=//c/mono
make
make install
</pre>
</ul>
To compile the mono runtime on Unix:
<ul>
* Download the mono distribution
* Unpack the mono distribution:
<pre>
tar xzvf mono-XXX.tar.gz
</pre>
* Configure, compile and install:
<pre>
./configure
make
make install
</pre>
</ul>
** CVS
We are trying to figure out where to put our CVS repository.
We are debating between the GNOME CVS or SourceForge. Watch
this spot.
+137 -24
View File
@@ -69,6 +69,9 @@ Q: What does Mono stand for?
A: Mono is the word for `Monkey' in Spanish. We like monkeys.
It only means a number of other things: monochromatic (hence the
gray theme used in the Web site).
Q: When will you ship it?
A: We do not know when the code will be shipped. The more
@@ -138,8 +141,8 @@ A: We like the features that the CLI and its related technologies
Q: Will I be able to write proprietary applications that run with
Mono?
A: Yes. We will make sure that the licensing will allow developers to
create proprietary applications.
A: Yes. The licensing scheme is planned to allow proprietary
developers to write applications with Mono.
Q: What license is Mono on?
@@ -147,10 +150,8 @@ A: The C# Compiler is released under the terms of the GPL. The class
libraries will be under the LGPL or the GPL with a special
exception. The runtime libraries are under the LGPL.
Here is the exception for the class libraries:
The library is distributed under the terms of the GNU General
Public License with the following exception:
Since the LGPL is not suitable for embedded systems development, we
are also licensing the libraries under the GPL with the following exception:
If you link this library against your own program, then you do not
need to release the source code for that program. However, any
@@ -162,6 +163,15 @@ A: The C# Compiler is released under the terms of the GPL. The class
href="http://www.gnu.org/software/classpath/classpath.html">GNU
Classpath.</a>
Q: But in Object Oriented Programming I need to subclass your library
functions, does that mean that I am making modifications to your
library and hence I would have to distribute my sources under the
LGPL?
A: No. Object Oriented Programming in the class library is a well
understood interface barrier, so you can actually develop
proprietary applications with the Mono libraries.
Q: Will you accept code under the XXX License?
A: If the XXX License is compatible with the license we use in that
@@ -230,11 +240,28 @@ A: No. That just means that applications might use that API to
documented and whether we will be able to talk to
passport.com
Q: But that must mean that you are tied to Passport!
A: All the contrary. The implementation could keep the interface (for
the sake of simplicity, lets say it implements the method `Login'
and `GetUserName').
We could implement `Login' and `GetUserName' by talking to XNS or
any other decentralized systems. Or any other system that the
industry standarizes on.
Q: What is your opinion?
A: You can read my personal <a href="passport.html">opinion on
passport</a>.
Q: Will Mono running on Linux make Passport available for Linux?
A: The Passport toolkit for Linux-based web servers is available from
Microsoft.
Again, Mono has nothing to do with Passport.
** Mono and Windows
Q: Will Mono allow me to run Microsoft Office on Linux?
@@ -287,6 +314,15 @@ Q: Will Mono include compatibility with Bonobo components?
A: Yes, we will provide a set of classes for implementing and using
Bonobo components from within Mono.
Q: Does Mono replace Bonobo?
A: Bonobo is very focused on cross-application component reuse. Mono
will provide a Bonobo framework to allow you to develop Bonobo
components and use Bonobo components on Unix.
Mono should allow you to write Bonobo components more easily, just
like .NET on Windows allows you to export .NET components to COM.
** Mono and the Web
Q: Is Mono a way of running Java applets?
@@ -389,6 +425,12 @@ A: The CIL is better suited to be JITed than JVM byte codes, but you
can interpret them as trivially as you can interpret JVM byte
codes.
Q: Could Java target the CLI?
A: Yes, Java could target the CLI. We have details on a <a
href="ideas.html#guavac">project</a> that someone could take on to
make this happen.
** Extending Mono
Q: Would you allow other classes other than those in the
@@ -443,8 +485,40 @@ A: We are also researching <a
href="http://www.gnu.org/software/lightning/lightning.html">GNU
Lightning</a>.
<a name="ximian-and-microsoft">
** Ximian and Microsoft
Q: I read that Microsoft is helping out Ximian, is this true?
A: Initial contact between David Stutz and Miguel de Icaza happened.
It was a friendly conversation. Microsoft is interested in other
implementing .NET and are willing to help make the ECMA spec more
accurate for this purpose.
We were initially contacted by Sam Ruby at the ECMA TG3 committee
to discuss the same issue. And we are glad to have good contacts
to ask questions about the specs.
Q: Is Microsoft paying Ximian to do this?
A: No, we are doing this for purely selfish reasons. We are upgrading
our development platform to build better applications on Unix and other
systems.
Q: Do you fear that Microsoft will change the spec and render Mono useless?
A: No. Microsoft proved with the CLI and the C# language that it was
possible to create a powerful foundation for many languages to
interoperate. We will always have that.
Even if changes happened in the platform which were undocumented
(which is very unlikely), the existing platform has a value on its
own.
Miguel once explained its motivation for working on Mono to Dave
Winer, and his mail got posted <a
href="http://scriptingnews.userland.com/stories/storyReader$1275">here</a>
Q: Didn't Miguel de Icaza say that `Unix Sucks'?
A: Yes, he did, as a catch phrase in his opening remark on the Ottawa
@@ -484,6 +558,29 @@ Q: Are you writing Mono from the ECMA specs?
A: yes, we are writing them from the ECMA specs and the published
materials in print about .NET
Q: What happens if Microsoft `Embraces and Extends' the CLI standard
and keeps Mono out of the play?
A: There are various explanations to this question. The first one is
that the benefits that you can get from the CLI are going to be
there with or without `embracing and extending'. We might not be
able to run every .NET Windows application on Mono. But remember:
it was already easy for someone to just use PInvoke to tie their
application to Windows.
The bottom line is that the advantages of having a CLI runtime will
be with us, no matter if Microsoft forks their version to be
incompatible.
Q: What if Microsoft changes the interface, and all of a sudden
applications break?
A: If they change their released API, every application that was
developed against it will break.
That being said, Microsoft have a pretty good record of keeping
backwards binary compatibility.
** Acronyms
Q: What is the difference between CLR (Common Language Runtime) and
@@ -507,6 +604,9 @@ A: I would love if someone does, and we would love to help anyone that
personally to work on C# on a C# compiler, which has an intrinsic
beauty.
We can provide help and assistance to anyone who would like to work
on this task.
Q: Should someone make a GCC backend that will generate CIL images?
A: I would love to see a backend to GCC that generates CIL images. It
@@ -514,6 +614,9 @@ A: I would love to see a backend to GCC that generates CIL images. It
code. This is something that people would want to look into
anyways for Windows interoperation in the future.
Again, we would love to provide help and assistance to anyone
interested in working in such a project.
Q: What about making a front-end to GCC that takes CIL images and
generates native code?
@@ -527,6 +630,9 @@ A: I would love to see this, specially since GCC supports this same
library that could be linked with your application as its runtime
support.
Again, we would love to provide help and assistance to anyone
interested in working in such a project.
Q: But would this work around the GPL in the GCC compiler and allow
people to work on non-free front-ends?
@@ -538,12 +644,6 @@ Q: Why are you writing a JIT engine instead of a front-end to GCC?
A: The JIT engine and runtime engine will be able to execute CIL
executables generated on Windows.
** Mono and GNU
Q: Is Mono part of the GNU project?
A: Mono is a Ximian project, that is also part of the GNU project.
** Mono and Portability
Q: Will Mono work on other variants of Unix?
@@ -588,22 +688,35 @@ A: We can not predict the future, but a conservative estimate is that
expected to contain the same object types independently of how the
instructions was reached.
** Mono and Portable.NET
Q: What are the differences between Mono and Portable.NET?
A: Most of Mono is being written using C#, the only pieces written in
C are those who have to absolutely be built using C (The JIT
engine, the runtime, the interfaces to the garbage collection
system).
The C# compiler and the tools will become reusable C# components.
Portable.NET is building its components out of C pieces.
** Assorted questions
Q: You say that the CLI allows multiple languages to execute on the
same environment. Isn't this the purpose of CORBA?
A: CORBA can be used for this purpose, but think of CORBA mostly as a
inter-process (local machine or remote machine) communication
system.
A: The key difference between CORBA (and COM) and the CLI is that the
CLI allows "data-level interoperability" because every
language/component uses the same data layout and memory management.
Think of the CLI to be targeted to interoperation of languages in
the same process, and CORBA as being a nifty addition for
out-of-process.
Sure, we have used CORBA for in-proc components, but the lack of an
ABI for in-proc components does not translate into a good framework
for in-proc systems
This means you can operate directly upon the datatypes that someone
else provides, without having to go via their interfaces. It also
means you don't have to "marshall" (convert) parameters (data
layouts are the same, so you can just pass components directly) and
you don't have to worry about memory managment, because all
languages/components share the same garbage collector and address
space. This means much less copying and no need for reference
counting.
+80 -1
View File
@@ -3,13 +3,28 @@
Here are a few ideas of tools, classes and projects that you
could start. More are forthcoming.
<a name="runtime">
** Runtime
We need a verifier that can be run on an executable (assembly)
and tells whether the metadata for the executable is correct
or not. It should report any anomalies.
For a list of anomalies in assemblies, check the various assertions
that are described on the ECMA documentation.
This will help test our generated executables and can be also
used as an external verifier.
<a name="classes">
** Classes
<ul>
TODO=jxta,The JXTA Peer to Peer foundation
* Implement a JXTA protocol implementation:
<a href="http://www.jxta.org">http://www.jxta.org</a>
TODO=camel,Mail API
* Implement a Mail API, similar to Camel or JavaMail (Camel has
significant architecture features that are required on a real
mailer).
@@ -18,23 +33,87 @@
<a href="http://cvs.gnome.org/bonsai/rview.cgi?dir=evolution%2Fcamel">
Camel implementation</a>.
Such an implementation could be used both with
Microsoft .NET and Mono.
TODO=multimedia
* Interfacing to Multimedia systems. You might want
to look into the Quicktime API. I know <a
href="mailto:[email protected]">Vladimir</a> has
researched the problem before
TODO=gtk,Gtk+ wrappers for Mono and .NET
* Wrap the Gtk+ API. This is simple and can be done
on Windows as Gtk+ 2.0 works on Windows.
This work can also be used on Windows and will
enable developers on Windows to use some of Gtk+'s
advanced features.
The idea is to wrap the Gtk+ API and allow us to
build GUI applications using Gtk+ and in the future
other Gtk+-based libraries from Mono (Gal, GtkHTML).
There is extensive knowledge on wrapping Gtk+ in
other languages (this has been done this for Perl,
Python, Java, Scheme, Haskel and other languages in
the past).
</ul>
<a name="projects">
** Projects
<ul>
TODO=xmlStorage,
* Implement an xmlStorageSystem for the CLI:
<a href="http://www.soapware.org/xmlStorageSystem">
http://www.soapware.org/xmlStorageSystem</a>
TODO=guavac,Java compiler for .NET
* You could take one of the existing Java compilers
(Guavac comes to mind as it is so nice) and modify
it to generate .NET code rather than JVM byte
codes.
This should be a pretty straightforward task.
Guavac has the advantage of being written in C++ and
it could be compiled with the Microsoft Managed C++
compiler and produce a .NET executable with it.
TODO=CORBA,CORBA implementation
* Build a CORBA interoperability engine for the CLR.
You do not need to do all of the work, just talking
the protocol will get us a long way (<a
href="http://www.omg.org">The OMG site</a> has the CORBA specs).
href="http://www.omg.org">The OMG site</a> has the
CORBA specs).
Get in touch with David Taylor (dtaylo11 at bigpond
dot net dot au) as he has been working on this
project.
TODO=Bonobo,Bonobo for Mono
* Once CORBA is done, implement the Bonobo interfaces
to allow people to use Bonobo components in Mono and
Mono components with Bonobo. The best of both worlds!
TODO=moniker,Object Naming System with Monikers
* A naming space for Mono. An object naming space is
a very powerful tool. Bonobo implements a moniker
system that is more powerful than the original
moniker concept that was pioneered by COM/OLE in the
Microsoft world.
Our implementation builds on a concept, and we have
made it simpler, more powerful, more extensible and
a much better mechanism than the equivalent monikers
on Windows.
Implementing Mono monikers would benefit both
Windows users using .NET and Mono users on Unix and
Windows.
Here is <a
href="http://primates.ximian.com/~miguel/monikers.html">an
overview of the moniker system</a> in Bonobo.
</ul>
+87 -16
View File
@@ -1,23 +1,20 @@
** Jul 12, 2001
<a href="http://www.ximian.com">Ximian</a> announced the
launch of the Mono project, an effort to create an Open Source
implementation of the .NET Development Framework.
I keep getting questions about my opinion on Passport, even when
Mono has <b>nothing</b> to do with it. I finally <a
href="passport.html">wrote something.</a>
Mono includes: <a href="c-sharp.html">a compiler</a> for the
C# language, a <a href="runtime.html">runtime</a> for the
Common Language Infrastructure and a set of <a
href="class-librayr.html">class libraries</a>
** Jul 9, 2001
Today <a href="http://www.ximian.com">Ximian</a> announced the
launch of the Mono
project, an effort to create a free software
(sometimes called open source) implementation of the .NET
Development Framework.
If you have questions about the
project, please read our list of <a
href="faq.html">Frequently Asked Questions</a>.
You can read our <a href="rationale.html">rationale</a> for
this project. If you have questions about the project, please
read our list of <a href="faq.html">Frequently Asked
Questions</a> or <a href="mailto:[email protected]">contact us.</a>
You might also want to <a href="download.html">Download the
source</a> for our work so far.
source</a> for our work so far. Or you can grab a <a
href="snapshots">snapshot</a> of our current work.
You might want to <a
href="resources.html#mailing">subscribe</a> to our mono-list
@@ -26,6 +23,80 @@
You can contact the team at: <a
href="mailto:[email protected]">[email protected]</a>
** Aug 20, 2001
A new <a href="contributing.html#compile-service">Compilation
service</a> has been made available by Derek to allow people
without access to the <a
href="http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/000/976/msdncompositedoc.xml&frame=true">.NET SDK</a>
** Aug 3, 2001
Daily snapshots of mcs and mono are now available, they will
run every night at 10pm Boston time.
** Jul 29, 2001
Mono Runtime 0.5 has been <a
href="download.html#july-29">released.</a> Check the <a
href="archive/mono-0.5">release notes</a>
** Jul 25, 2001
The slides for <A href="Presentations/O-Reilly">my
presentation</a> at <a href="http://www.oreilly.com">O'Reilly
Open Source Software Convention</a>
** Jul 22, 2001
Another release of the class libraries is out, check the <a
href="archive/mcs-22">MCS 22-July Release Notes</a>. You can
get the new class libraries from <a
href="download.html#july-22">here</a>
** Jul 19, 2001
Another release of the class libraries is out, check the <a
href="archive/mcs-19">MCS 19-July Release Notes</a>. You can
get the new class libraries from <a
href="download.html#july-19">here</a>
** Jul 17, 2001
Another release of the class libraries is out, check the <a
href="archive/mcs-17">MCS 17-July Release Notes</a>. You can
get the new class libraries from <a
href="download.html#july-17">here</a>
Do not forget to check out the updated <a href="faq.html">FAQ</a>.
Got Sean's new <a href="class-status/index.html">Class
Status</a> web pages up. These are a lot better than mine, and
we are now keeping better track of contributors.
** Jul 15, 2001
Another release of Mono is out, check the <a
href="archive/mono-0.4">Mono 0.4 Release Notes</a>. Get it <a
href="download.html#july-15">here</a>.
** Jul 14, 2001
A <a
href="http://mail.ximian.com/archives/public/mono-list/2001-July/000399.html">new
release</a> of the
runtime, compiler and classes has been made. Get it <a href="download.html#july-14">here</a>
** Jul 12, 2001
I keep getting questions about my opinion on Passport, even when
Mono has <b>nothing</b> to do with it. I finally <a
href="passport.html">wrote something.</a>
** Jul 9, 2001
Project launched.
** O'Reilly
Brian posted a story on <a
+58 -16
View File
@@ -1,3 +1,14 @@
* Updates
I have received many comments from people, and I have updated
the page accordingly. From removing incorrect statements, to
fixing typos, to include mentions to other software pieces.
I also corrected my statement about IIS and a trojan horse, I
should read a more educated press in the future. My apologies
to Microsoft and its employees on this particular topic. IIS
did not have a trojan horse built in.
* Microsoft Hailstorm and Passport
Microsoft Passport is a centralized database hosted by
@@ -14,7 +25,7 @@
** Passport
Passport is important not because of it being breaktrough
Passport is important not because of it being a breakthrough
technologically speaking, but because the company is in a
position to drive most people toward being suscribers of it.
@@ -75,12 +86,7 @@
at the corporate level policy, but also the fact that
the source code for Microsoft products is not
available, means that trojans or worms could be built
into the products by malicious engineers. This is not
unheard of, as the <a
href="http://slashdot.org/articles/00/04/14/0619206.shtml">Microsoft
Internet Server</a> had a trojan horse built into that
allowed anyone that knew about this to control any
server running IIS.
into the products by malicious engineers.
* <b>Security:</b> With a centralized system like
Passport, imagine the repercussions of a malicious
@@ -91,7 +97,21 @@
Hackers have already <a
href="http://slashdot.org/articles/00/10/27/1147248.shtml">broken
into Microsoft</a> in the past. And the company was
unable to figure out for how long their systems had been hacked.
unable to figure out for how long their systems had
been hacked.
Security holes have been found in <a
href="http://slashdot.org/articles/00/04/14/0619206.shtml">IIS
in the past.</a> If all the world's data is stored on
a central location, when a single security hole is
detected, it would allow an intruder to install a
backdoor within seconds into the corporate network
without people ever noticing.
Microsoft itself has been recently hit by worms,
imagine if all your business depended on a single
provider for providing all or your authentication
needs
</ul>
Microsoft might or might not realize this. The idea behind
@@ -112,6 +132,15 @@
system should not create an internet `blackout' in the
case of failure.
A distributed system using different software
platforms and different vendors would be more
resistent to an attack, as holes in a particular
implementation of the server software would not affect
every person at the same time.
A security hole attack might not even be relevant to
other software vendors software.
* <b>Allow for multiple registrars:</b> Users should
be able to choose a registrar (their banks, local
phone company, service provider, Swiss bank, or any
@@ -129,13 +158,14 @@
possibility of replicating and caching public information
about the user.
For instant messaging (another pieces of the Hailstorm bit),
For instant messaging (another piece of the Hailstorm bit),
you want to use a non-centralized system like Sun's <a
href="http://www.jxta.org">JXTA</a>. Some people mailed me to
mention Jabber as a messaging platform. Jabber suffers from
the same problems that a centralized Passport has. If you
want to do things right, you want to start with a fully
distributed system.
mention Jabber as a messaging platform and other people
pointed out to the <a
href="http://java.sun.com/products/jms/">Java Message
Service</a>. The JMS does support a number of very
interesting features that are worth researching.
It could also just use the user e-mail address as the `key' to
choose the registrar (msn.com, hotmail.com -> passport.com;
@@ -166,7 +196,7 @@
** Deploying it
The implementation of such a system should be a pretty
straightforward tasks once security cryptographers have
straightforward task once security cryptographers have
designed such a beast.
The major problems are:
@@ -191,7 +221,7 @@
** Passport and Mono
The .NET class libraries includes a Passport class that
The .NET class libraries include a Passport class that
applications might use to authenticate with Passport. Since
we do not have information at this point on the exact protocol
of Passport, it is not even feasible to implement it.
@@ -210,6 +240,18 @@
Currently, we are too far from the point where this is a real
issue.
** Passport and endangering Open Source.
A few people have said: `Mono will allow Passport to be
available for Linux and that is bad'. This is plain
missinformation.
Currently, you can obtain Passport for Linux from Microsoft
itself and deploy it today on your Web server. Mono does not
even enter the picture here. Go to passport.com and download
the toolkit and you will see with your own eyes that passport
is <B>already</b> available for Linux.
** Disclaimer
This is just a group of personal thoughts of mine that I have
@@ -222,7 +264,7 @@
Nat Friedman (Ximian's co-founder) has his own ideas on how a
competing system to Passport could be designed, but I will let
<a href="http://www.nat.org/gym">him</a> post his own story.
<a href="http://www.nat.org/">him</a> post his own story.
** Other Alternatives
+46
View File
@@ -0,0 +1,46 @@
To: [email protected], [email protected]
Subject: July 12 snapshots.
FCC: ~/Mail/outbox.txt
X-Windows: Sometimes you fill a vacuum and it still sucks.
--text follows this line--
Hey!
July 12 snapshots of class libraries, the compiler and the mono
runtime are available.
New on this release:
* Runtime (module: mono)
The beginning of a simple interpreter that Paolo started
workign on (can run really simple .NET programs).
Disassembler copes with more elements of the binary format and
more tokens are decoded. Paolo is working now on moving some
of these to the metadata library.
More tables are dumped.
* Class libraries (module: mcs/class)
Many new more classes are in from Joe, Vladimir, Jeff, Sean
and yours truly.
Sean fixed the build process, and it is now possible to
compile with a single command the assemblies. We will be
revisiting this mechanism in the future to compile per-OS
assemblies (ie, Unix, Windows, MacOS, etc).
* Compiler (module mcs/mcs)
Not much done this week, just a few fixes here and there, and
more work to make it easy to compiler.
* Documentation (module: mono/doc)
All the changes to the web site are there for your browsing
pleasure. We still need to integrate the status system in
there.
Miguel.
+43
View File
@@ -0,0 +1,43 @@
To: [email protected]
Subject: Sunday snapshot available.
Gcc: mail.2001-07
--text follows this line--
Hey guys,
I promise I will not be doing these so often once we have the CVS
server up. In the meantime:
* MCS
Sean got the classes to compile in a single go. You
will need CygWin (www.cygwin.org) to compile though
(GNU make and stuff is required).
System.Xml.XmlReader contribution from Jason
(WOOHHOO!!). It also contains a nice test-suite for
his functions, and in his new code bit, his
implementation is faster than Microsoft's
We now ship `jay' as part of the distribution to allow
you to compile the compiler with the same `make'
command. Small fixes to the parser as well were
introduced.
* Mono 0.4
Paolo's interpreter supports call instructions and has
the test suite program that he posted about.
All documentation ships now in the mono-0.4.tar.gz
Notes:
As usual, MCS is targeted to be compiled on a Windows machine
(you will need Cygwin).
Mono is targeted to be compiled on a Unix machine or a Windows
machine running Cygwin.
Miguel.
+14 -2
View File
@@ -45,6 +45,12 @@
href="http://mail.ximian.com/mailman/listinfo/mono-announce-list">mono-announce-list:</a></b>
Announcements of Mono developments.
* <b><a
href="http://mail.ximian.com/mailman/listinfo/mono-gc-list">mono-gc-list:</a></b>
Discussion on the GC system of Mono.
* <b><a
href="http://mail.ximian.com/mailman/listinfo/mono-cvs-list">mono-cvs-list:</a></b>
Track the CVS activity of Mono on this mailing list. You can get <a href="http://www.go-mono.com/snapshots">daily snapshots</a> as well.
* <b><a
href="http://mail.ximian.com/mailman/listinfo/mono-docs-list">mono-docs-list:</a></b>
Discussion on the documentation of Mono.
* <b><a
@@ -75,17 +81,23 @@
href="http://www.icsharpcode.net/OpenSource/SD/default.asp">Sharp
Develop:</a> an IDE for the C# language written in C#.
* <a
href="http://janet-js.sourceforge.net/">Janet:</a>
an implemention of ECMAScript (the standarized
version of JavaScript) in C#
* <a
href="http://www.southern-storm.com.au/portable_net.html">Portable.NET:</a>
Another implementation of the CLI and C# compiler.
* <a href="http://nunit.sourceforge.net">NUnit:</a> A
testing framework for .NET classes.
testing framework for .NET classes.
* <a href="http://www.kaffe.org">Kaffe:</a> A popular
Free Software JIT engine for Java.
* <a href="http://www.intel.com/research/mrl/orp">ORP:</a> A research
JIT/VM/GC system from Intel.
JIT/VM/GC system from Intel.
</ul>
** GNOME Documentation
+65 -39
View File
@@ -1,17 +1,13 @@
The MonoNet runtime
* The Mono runtime
The MonoNet runtime will implement the JIT engine (and a byte
The Mono runtime will implement the JIT engine (and a byte
code interpreter for quickly porting to new systems), the
class loader, the garbage collector, threading system and
metadata access libraries.
Currently the runtime contains the beginning of an image
loader and metadata access entry points. Since Beta2 has been
now released, it is possible to resume work using the ECMA
specs and testing with Beta2-generated executables.
The runtime core will be implemented in C, in a library
"libMonoVES.so".
Currently the runtime has an image loader and metadata access
entry points. The runtime comes with a simple interpreter
that can execute very simple programs.
** Executing MSIL/CIL images
@@ -19,26 +15,28 @@
external assemblies to our own version of the assemblies on
GNU/Linux.
Our roadmap looks like this:
Our roadmap looks like this, this has been updated as of
<b>Jul 15, 2001</b>:
<ul>
* Milestone 1: Fully read and parse all CIL byte-codes
and metadata tokens (ie, a disassembler).
* Milestone 1: <b> Done</b> Fully read and parse all CIL byte-codes
and metadata tokens (ie, a disassembler).
* Milestone 2: Complete an interpreter for CIL byte
codes. This interpreter can be used temporarly to
run CIL byte code on a system where no JIT is
available.
* Milestone 3: IA32 translating-JIT engine.
* Milestone 3: Define an <i>lburg</i>-like instruction
selector for the JITer for Intel. Although slower
at JITing than a streaming JITer, it generates
better code. The same grammar can later be used for
the stream jitter.
* Milestone 4: non-Intel port of the JIT engine.
* Milestone 4: Implement JITer.
* Milestone 5: Optimizing JIT engine port for IA32.
* Milestone 6: non-Intel port of the Optimizing JIT
engine.
* Milestone 5: Port of the JITer to non IA32 systems.
</ul>
A setup similar to the Kaffe JIT engine can be used to
@@ -46,25 +44,38 @@
will be focused on getting a IA32 version running first.
The JIT engine should work on Linux and Win32, although you
might need to install the CygWin32 development tools to get a
will need to install the CygWin32 development tools to get a
Unix-like compilation environment.
** JIT Engine
** JIT Engine (<b>updated, Jul 14th, 2001</b>)
Currently we are evaluating various mechanisms for our JIT
engine (<a
href="http://www.intel.com/research/mrl/orp/">ORP</a>, <a
href="http://www.gnu.org/software/lightning/">GNU
Lightning</a>, and <a
href="http://www.eecs.harvard.edu/~nr/toolkit/">NJ Machine
Toolkit</a>.).
We will be using a code-generator generator approach for our
JITer. Given the properties of CIL byte codes, we can take
full advantage of a real instruction selector for our code
generator.
We have not made a decision yet, but we might want to use a
Code Generator Generator for the Common Intermediate Language,
as that is likely going to allow us to create better code
(There are a couple of books that deal with this technique: "A
There are a couple of books that deal with this technique: "A
Retargetable C Compiler" and "Advanced Compiler Design and
Implementation").
Implementation" are good references. You can also get a
technical description of <a
href="http://research.microsoft.com/copyright/accept.asp?path=http://www.research.microsoft.com/~drh/pubs/iburg.pdf&pub=ACM">lbrug</a>
Previously we had looked at a number of JIT engines and tools,
but they would not take full advantage of the CIL properties:
<ul>
* <a
href="http://www.intel.com/research/mrl/orp/">ORP</a>
* <a
href="http://www.gnu.org/software/lightning/">GNU
Lightning</a>
* <a href="http://www.eecs.harvard.edu/~nr/toolkit/">NJ Machine
Toolkit</a>.).
* VCODE.
</ul>
** Garbage Collection
@@ -76,6 +87,11 @@
href="http://www.amazon.com/exec/obidos/ASIN/0471941484/o/qid=992556433/sr=2-1/ref=aps_sr_b_1_1/103-5866388-0492603">Garbage
Collection.</a>
Another consideration is to use the same interface that ORP
uses to its Garbage Collection system and reuse that GC system
instead of rolling our own, as the ORP system is pretty advanced
and is independent of the rest of ORP.
Although using a conservative garbage collector like Bohem's
would work, all the type information is available at runtime,
so we can actually implement a better collector than a
@@ -85,9 +101,17 @@
* Garbage collection list and FAQ:<br>
<a href="http://www.iecc.com/gclist/">http://www.iecc.com/gclist/</a>
* The Microsoft .NET Garbage Collection Implementation:<br>
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp</a>
* "GC points in a Threaded Environment":<br>
<a href="http://research.sun.com/techrep/1998/abstract-70.html">
http://research.sun.com/techrep/1998/abstract-70.html</a>
* "A Generational Mostly-concurrent Garbage Collector":
<a href="http://research.sun.com/techrep/2000/abstract-88.html">
http://research.sun.com/techrep/2000/abstract-88.html</a>
* Details on The Microsoft .NET Garbage Collection Implementation:<br>
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI.asp</a>
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI2.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmag00/html/GCI2.asp</a>
</ul>
** Useful links
@@ -95,7 +119,6 @@
Paolo Molaro found a few interesting links:
<ul>
* On compilation of stack-based languages:<br>
<a href="http://www.complang.tuwien.ac.at/projects/rafts.html">
http://www.complang.tuwien.ac.at/projects/rafts.html</a>
@@ -112,7 +135,10 @@
** PInvoke
PInvoke will be supported, and will be used to wrap Unix API
calls, these in turn are required for reusing some of the
GNOME libraries that will reduce the work we have to do to
deliver a complete class library.
PInvoke is the mechanism we are using to wrap Unix API calls
as well as talking to system libraries.
We hvae implemented PInvoke through libffi, but we are likely
going to roll our own system as the runtime matures, specially
as the interpreter is approaching completion, and we move into
the JITer.
+11 -17
View File
@@ -1,6 +1,6 @@
* Project Status
Pieces of Mono that have been implemented:
<ul>
@@ -10,35 +10,29 @@
* Metadata library: Can currently parse and load
information from .NET modules (executables and DLL
files). It has a few bugs outstanding (table
dimension computation is incorrect).
files).
Parsing of Exception tables is missing.
It lacks Token to (Table, Index) mapping, but this
should be trivial to write.
* Disassembler: Can disassemble .NET modules. Still
lacking exception handling as well as useful debugging
tools (hex dumping, token dumping).
* Class Libraries: Only a few classes have been
implemented.
* Class Libraries: You can check the current status in the
<a href="class-status.html">Class Status page</a>
</ul>
Tasks on the critical path:
<ul>
* Method and Field resolution.
* Bytecode interpreter: (Paolo is working on this).
* Bytecode interpreter: Not implemented yet.
* Simple JIT: Not implemented yet (Miguel is
researching the code-generator generator)
* Simple JIT: Not implemented yet.
* Garbage collection engine.
* Garbage collection engine (Dick is working on this, his contact is <a
href="mailto:[email protected]">[email protected]</a>
</ul>
If you want to work on any task here, please mail <a
href="mailto:[email protected]">[email protected]</a>
+48 -6
View File
@@ -4,22 +4,64 @@
Mono-based solution. Some of these tools can be developed on
Windows before Mono is fully finished.
All of these tools should be written using C#.
For the tools that are typically command line tools: Try to
write these as components that could load their input from
streams or collections of streams, and implement the command
line tools as wrappers around those classes.
For example, we will be making the C# compiler a component
that could be reused by applications that might have a use for
the various bits of the compiler (either to embed the
compiler, or reuse the code generator part of it).
This is important so that these components (compiler,
assembler, linker, etc) can be integrated later into the
visual development environment (hopefully with the help of the
SharpDevelop hackers).
TODO=ilasm,IL Assembler
** IL Assembler.
This assembler should basically take as input a file
containing IL bytecodes as specified in the `Partition II' of
the ECMA spec, and produce a binary file.
TODO=al,Assembly Linker
** Assembly Linker.
This tool is used to construct assemblies, which are basically
deployment units for CLI executables.
TODO=debugger,Debugger
** Debugger
We will need a debugging API to debug CLI applications and
then a debugger component that can be used in an IDE
environment.
TODO=ide,Integrated Development Environment
** Integrated Development Environment
There is already a project to create a C# development
environment (SharpDevelop). People could work with the
SharpDevelop hackers to produce a unified development environment.
environment: <a
href="http://www.icsharpcode.net/OpenSource/SD/default.asp">SharpDevelop</a>.
People should work with the SharpDevelop hackers to produce a
unified development environment.
Please work with the SharpDevelop hackers to build a good IDE.
We will work on creating an embedable compiler component and
an embeddable debugger component that can be used withing
SharpDevelop
TODO=hbrowser,Help Browser
** Help Browser
We need a good help browser that can be used to browse all the
Mono documentation.
We need a good help browser that can be used to browse
documentation. Ideally this help browser can accept as input
XML Docbook input and an assorted set of file formats
(Microsoft Help, Unix manual pages, Unix Info pages)
Look at the GNOME DevHelp for a good set of ideas on how to
implement this.
+1
View File
@@ -3,6 +3,7 @@
0,Mono,rationale.html,rationale.src
1,Runtime,runtime.html,runtime.src
1,Classes,class-library.html,class-library.src
2,Class Status,class-status.html,class-status.src
1,C# Compiler,c-sharp.html,c-sharp.src
1,Status,status.html,status.src
0,Contributing,contributing.html,contributing.src
+4 -2
View File
@@ -14,11 +14,13 @@ while (<>){
} elsif (/^\t\t\* (.*)$/) {
print "<li>$1\n";
} elsif (/^Q: (.*)$/){
print "<p><a name=\"q$q\"><b>Question $q:</b> $1\n";
print "<p><a name=\"q$q\"></a><b>Question $q:</b> $1\n";
$q++;
} elsif (/^A: (.*)$/){
print "$1\n";
} else {
} elsif (/^TODO=(.*),$/){
print "<a name=\"$1\">\n";
} else {
print "$_\n";
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

+1
View File
@@ -1,6 +1,7 @@
SOURCES= \
../contributing \
../class-library \
../class-status \
../contact \
../c-sharp \
../documentation \
+2 -2
View File
@@ -47,13 +47,13 @@
</table>
</td>
<td bgcolor="black" width="1"><img src="images/pixel.gif" width="1"></td>
<td bgcolor="white">
<td bgcolor="white" align="left" width="80%" valign="top">
<table cellpadding="16">
<tr><td>
#CONTENT#
</td></tr>
</table>
</td>
</td>
<td bgcolor="black"><img src="images/pixel.gif" width="1"></td>
<td width="100"><img src="images/pixel.gif"></td>
</tr>
+16
View File
@@ -0,0 +1,16 @@
.deps
aclocal.m4
config.cache
config.guess
config.h
config.h.in
config.log
config.status
config.sub
configure
fficonfig.h
fficonfig.h.in
Makefile
Makefile.in
stamp-h
stamp-h.in
+440
View File
@@ -0,0 +1,440 @@
2001-08-16 Alex Graveley <[email protected]>
* libffi/include/fficonfig.h: Remove as this is auto generated.
* Makefile.am: Only generate libffi.a.
* configure.in: replace A[CM]_PROG_LIBTOOL with AC_PROG_RANLIB.
Sun Apr 22 15:50:08 2001 Anthony Green <[email protected]>
* include/ffi_common.h: Delete, after moving contents to...
* include/ffi_private.h: Subsume contents of ffi_common.h.
* include/Makefile.am (noinst_HEADERS): Remove ffi_common.h.
* include/Makefile.in: Rebuilt.
* arm/ffi.c, m68k/ffi.c, mips/ffi.c, powerpc/ffi.c, s390/ffi.c,
ia64/ffi.c: Include ffi_private.h, not ffi_common.h.
* alpha/ffi.c, sparc/ffi.c, x86/ffi.c: Don't include ffi_common.h.
* types.c, raw_api.c, java_raw_api.c, prep_cif.c: Don't include
ffi_common.h.
* debug.c: Include ffi_private.h instead of ffi_common.h.
* mips/ffi.c (calc_n32_struct_flags): Make static.
(FIX_ARGP): Remove call to debugging routine ffi_stop_here.
* mips/n32.S: Include ffi_private.h.
* mips/o32.S: Include ffi_private.h.
Sun Apr 22 12:37:44 2001 Anthony Green <[email protected]>
* README: Update some comments.
* Makefile.am (SUBDIRS): Add include so ffi.h gets installed.
* Makefile.in: Rebuilt.
* include/ffi.h: Change ALPHA to __alpha__ and SPARC to __sparc__.
* types.c: Ditto.
* prep_cif.c (ffi_prep_cif): Ditto.
* alpha/ffi.c, alpha/osf.S, sparc/ffi.c, sparc/v8.S, sparc/v9.S:
Include ffi_private.h.
* include/ffi_private.h (FFI_TYPE_LAST): Define.
Sun Apr 22 11:41:55 2001 Anthony Green <[email protected]>
* Revolutionary changes. Target independent ffi.h. dejagnu
testing infrastructure. Moved source files around. Configure no
longer depends on run tests.
Sat Apr 14 20:49:46 2001 Anthony Green <[email protected]>
* mips/ffi.c: Include mips/mips.h.
* mips/o32.S: Ditto.
* mips/n32.S: Ditto.
* mips/o32.s: Deleted.
* mips/n32.s: Deleted.
Sat Apr 14 20:47:13 2001 Anthony Green <[email protected]>
* mips/mips.h: Moved from include/ffi_mips.h.
Sat Apr 14 20:09:05 2001 Anthony Green <[email protected]>
* powerpc/asm.h: Remove rcs id.
Sat Apr 14 15:04:08 2001 Anthony Green <[email protected]>
* configure.in: Use AC_COMPILE_CHECK_SIZEOF and
AC_C_BIGENDIAN_CROSS.
Sat Apr 14 15:02:53 2001 Anthony Green <[email protected]>
* aclocal.m4: Rebuilt.
* acinclude.m4: New file. Add AC_COMPILE_CHECK_SIZEOF and
AC_C_BIGENDIAN_CROSS.
2001-04-8 Neale Ferguson <[email protected]>
* src/s390/ffi.c: New file.
* src/s390/sysv.S: New file.
* include/ffi.h: Add s390 bits.
* configure.in: Ditto.
* configure: Rebuild.
2001-03-29 Bryce McKinlay <[email protected]>
* configure.in: Use different syntax for subdirectory creation.
* configure: Rebuilt.
2001-03-27 Jon Beniston <[email protected]>
* configure.in: Added X86_WIN32 target (Win32, CygWin, MingW).
* configure: Rebuilt.
* Makefile.am: Added X86_WIN32 target support.
* Makefile.in: Rebuilt.
* include/ffi.h.in: Added X86_WIN32 target support.
* src/ffitest.c: Doesn't run structure tests for X86_WIN32 targets.
* src/types.c: Added X86_WIN32 target support.
* src/x86/win32.S: New file. Based on sysv.S, but with EH
stuff removed and made to work with CygWin's gas.
2001-03-26 Bryce McKinlay <[email protected]>
* configure.in: Make target subdirectory in build dir.
* Makefile.am: Override suffix based rules to specify correct output
subdirectory.
* Makefile.in: Rebuilt.
* configure: Rebuilt.
2001-03-23 Kevin B Hendricks <[email protected]>
* src/powerpc/ppc_closure.S: New file.
* src/powerpc/ffi.c (ffi_prep_args): Fixed ABI compatibility bug
involving long long and register pairs.
(ffi_prep_closure): New function.
(flush_icache): Likewise.
(ffi_closure_helper_SYSV): Likewise.
* include/ffi.h.in (FFI_CLOSURES): Define on PPC.
(FFI_TRAMPOLINE_SIZE): Likewise.
(FFI_NATIVE_RAW_API): Likewise.
* Makefile.in: Rebuilt.
* Makefile.am (EXTRA_DIST): Added src/powerpc/ppc_closure.S.
(TARGET_SRC_POWERPC): Likewise.
2001-03-19 Tom Tromey <[email protected]>
* Makefile.in: Rebuilt.
* Makefile.am (ffitest_LDFLAGS): New macro.
2001-03-02 Nick Clifton <[email protected]>
* include/ffi.h.in: Remove RCS ident string.
* include/ffi_mips.h: Remove RCS ident string.
* src/debug.c: Remove RCS ident string.
* src/ffitest.c: Remove RCS ident string.
* src/prep_cif.c: Remove RCS ident string.
* src/types.c: Remove RCS ident string.
* src/alpha/ffi.c: Remove RCS ident string.
* src/alpha/osf.S: Remove RCS ident string.
* src/arm/ffi.c: Remove RCS ident string.
* src/arm/sysv.S: Remove RCS ident string.
* src/mips/ffi.c: Remove RCS ident string.
* src/mips/n32.S: Remove RCS ident string.
* src/mips/o32.S: Remove RCS ident string.
* src/sparc/ffi.c: Remove RCS ident string.
* src/sparc/v8.S: Remove RCS ident string.
* src/sparc/v9.S: Remove RCS ident string.
* src/x86/ffi.c: Remove RCS ident string.
* src/x86/sysv.S: Remove RCS ident string.
2001-02-08 Joseph S. Myers <[email protected]>
* include/ffi.h.in: Change sourceware.cygnus.com references to
gcc.gnu.org.
2000-12-09 Richard Henderson <[email protected]>
* src/alpha/ffi.c (ffi_call): Simplify struct return test.
(ffi_closure_osf_inner): Index rather than increment avalue
and arg_types. Give ffi_closure_osf the raw return value type.
* src/alpha/osf.S (ffi_closure_osf): Handle return value type
promotion.
2000-12-07 Richard Henderson <[email protected]>
* src/raw_api.c (ffi_translate_args): Fix typo.
(ffi_prep_closure): Likewise.
* include/ffi.h.in [ALPHA]: Define FFI_CLOSURES and
FFI_TRAMPOLINE_SIZE.
* src/alpha/ffi.c (ffi_prep_cif_machdep): Adjust minimal
cif->bytes for new ffi_call_osf implementation.
(ffi_prep_args): Absorb into ...
(ffi_call): ... here. Do all stack allocation here and
avoid a callback function.
(ffi_prep_closure, ffi_closure_osf_inner): New.
* src/alpha/osf.S (ffi_call_osf): Reimplement with no callback.
(ffi_closure_osf): New.
2000-09-10 Alexandre Oliva <[email protected]>
* config.guess, config.sub, install-sh: Removed.
* ltconfig, ltmain.sh, missing, mkinstalldirs: Likewise.
* Makefile.in: Rebuilt.
* acinclude.m4: Include libtool macros from the top level.
* aclocal.m4, configure: Rebuilt.
2000-08-22 Alexandre Oliva <[email protected]>
* configure.in [i*86-*-freebsd*] (TARGET, TARGETDIR): Set.
* configure: Rebuilt.
2000-05-11 Scott Bambrough <[email protected]>
* libffi/src/arm/sysv.S (ffi_call_SYSV): Doubles are not saved to
memory correctly. Use conditional instructions, not branches where
possible.
2000-05-04 Tom Tromey <[email protected]>
* configure: Rebuilt.
* configure.in: Match `arm*-*-linux-*'.
From Chris Dornan <[email protected]>.
2000-04-28 Jakub Jelinek <[email protected]>
* Makefile.am (SUBDIRS): Define.
(AM_MAKEFLAGS): Likewise.
(Multilib support.): Add section.
* Makefile.in: Rebuilt.
* ltconfig (extra_compiler_flags, extra_compiler_flags_value):
New variables. Set for gcc using -print-multi-lib. Export them
to libtool.
(sparc64-*-linux-gnu*): Use libsuff 64 for search paths.
* ltmain.sh (B|b|V): Don't throw away gcc's -B, -b and -V options
for -shared links.
(extra_compiler_flags_value, extra_compiler_flags): Check these
for extra compiler options which need to be passed down in
compiler_flags.
2000-04-16 Anthony Green <[email protected]>
* README: Credit updates. Update supported platorms.
* include/ffi.h.in: Important size fixes from William Knottenblet
([email protected]).
2000-04-16 Anthony Green <[email protected]>
* configure: Rebuilt.
* configure.in: Change i*86-pc-linux* to i*86-*-linux*.
2000-04-14 Jakub Jelinek <[email protected]>
* include/ffi.h.in (SPARC64): Define for 64bit SPARC builds.
Set SPARC FFI_DEFAULT_ABI based on SPARC64 define.
* src/sparc/ffi.c (ffi_prep_args_v8): Renamed from ffi_prep_args.
Replace all void * sizeofs with sizeof(int).
Only compare type with FFI_TYPE_LONGDOUBLE if LONGDOUBLE is
different than DOUBLE.
Remove FFI_TYPE_SINT32 and FFI_TYPE_UINT32 cases (handled elsewhere).
(ffi_prep_args_v9): New function.
(ffi_prep_cif_machdep): Handle V9 ABI and long long on V8.
(ffi_V9_return_struct): New function.
(ffi_call): Handle FFI_V9 ABI from 64bit code and FFI_V8 ABI from
32bit code (not yet cross-arch calls).
* src/sparc/v8.S: Add struct return delay nop.
Handle long long.
* src/sparc/v9.S: New file.
* src/prep_cif.c (ffi_prep_cif): Return structure pointer
is used on sparc64 only for structures larger than 32 bytes.
Pass by reference for structures is done for structure arguments
larger than 16 bytes.
* src/ffitest.c (main): Use 64bit rint on sparc64.
Run long long tests on sparc.
* src/types.c (FFI_TYPE_POINTER): Pointer is 64bit on alpha and
sparc64.
(FFI_TYPE_LONGDOUBLE): long double is 128 bit aligned to 128 bits
on sparc64.
* configure.in (sparc-*-linux*): New supported target.
(sparc64-*-linux*): Likewise.
* configure: Rebuilt.
* Makefile.am: Add v9.S to SPARC files.
* Makefile.in: Likewise.
(LINK): Surround $(CCLD) into double quotes, so that multilib
compiles work correctly.
2000-04-04 Alexandre Petit-Bianco <[email protected]>
* configure: Rebuilt.
* configure.in: (i*86-*-solaris*): New libffi target. Patch
proposed by Bryce McKinlay.
2000-03-20 Tom Tromey <[email protected]>
* Makefile.in: Hand edit for java_raw_api.lo.
2000-03-08 Bryce McKinlay <[email protected]>
* config.guess, config.sub: Update from the gcc tree.
Fix for PR libgcj/168.
2000-03-03 Tom Tromey <[email protected]>
* Makefile.in: Fixed ia64 by hand.
* configure: Rebuilt.
* configure.in (--enable-multilib): New option.
(libffi_basedir): New subst.
(AC_OUTPUT): Added multilib code.
2000-03-02 Tom Tromey <[email protected]>
* Makefile.in: Rebuilt.
* Makefile.am (TARGET_SRC_IA64): Use `ia64', not `alpha', as
directory name.
2000-02-25 Hans Boehm <[email protected]>
* src/ia64/ffi.c, src/ia64/ia64_flags.h, src/ia64/unix.S: New
files.
* src/raw_api.c (ffi_translate_args): Fixed typo in argument
list.
(ffi_prep_raw_closure): Use ffi_translate_args, not
ffi_closure_translate.
* src/java_raw_api.c: New file.
* src/ffitest.c (closure_test_fn): New function.
(main): Define `rint' as long long on IA64. Added new test when
FFI_CLOSURES is defined.
* include/ffi.h.in (ALIGN): Use size_t, not unsigned.
(ffi_abi): Recognize IA64.
(ffi_raw): Added `flt' field.
Added "Java raw API" code.
* configure.in: Recognize ia64.
* Makefile.am (TARGET_SRC_IA64): New macro.
(libffi_la_common_SOURCES): Added java_raw_api.c.
(libffi_la_SOURCES): Define in IA64 case.
2000-01-04 Tom Tromey <[email protected]>
* Makefile.in: Rebuilt with newer automake.
1999-12-31 Tom Tromey <[email protected]>
* Makefile.am (INCLUDES): Added -I$(top_srcdir)/src.
1999-09-01 Tom Tromey <[email protected]>
* include/ffi.h.in: Removed PACKAGE and VERSION defines and
undefs.
* fficonfig.h.in: Rebuilt.
* configure: Rebuilt.
* configure.in: Pass 3rd argument to AM_INIT_AUTOMAKE.
Use AM_PROG_LIBTOOL (automake 1.4 compatibility).
* acconfig.h: Don't #undef PACKAGE or VERSION.
1999-08-09 Anthony Green <[email protected]>
* include/ffi.h.in: Try to work around messy header problem
with PACKAGE and VERSION.
* configure: Rebuilt.
* configure.in: Change version to 2.00-beta.
* fficonfig.h.in: Rebuilt.
* acconfig.h (FFI_NO_STRUCTS, FFI_NO_RAW_API): Define.
* src/x86/ffi.c (ffi_raw_call): Rename.
Mon Aug 9 18:33:38 1999 Rainer Orth <[email protected]>
* include/Makefile.in: Rebuilt.
* Makefile.in: Rebuilt
* Makefile.am (toolexeclibdir): Add $(MULTISUBDIR) even for native
builds.
Use USE_LIBDIR.
* configure: Rebuilt.
* configure.in (USE_LIBDIR): Define for native builds.
Use lowercase in configure --help explanations.
1999-08-08 Anthony Green <[email protected]>
* include/ffi.h.in (FFI_FN): Remove `...'.
1999-08-08 Anthony Green <[email protected]>
* Makefile.in: Rebuilt.
* Makefile.am (AM_CFLAGS): Compile with -fexceptions.
* src/x86/sysv.S: Add exception handling metadata.
1999-08-02 Kresten Krab Thorup <[email protected]>
* src/x86/ffi.c (ffi_closure_SYSV): New function.
(ffi_prep_incoming_args_SYSV): Ditto.
(ffi_prep_closure): Ditto.
(ffi_closure_raw_SYSV): Ditto.
(ffi_prep_raw_closure): More ditto.
(ffi_call_raw): Final ditto.
* include/ffi.h.in: Add definitions for closure and raw API.
* src/x86/ffi.c (ffi_prep_cif_machdep): Added case for
FFI_TYPE_UINT64.
* Makefile.am (libffi_la_common_SOURCES): Added raw_api.c
* src/raw_api.c: New file.
* include/ffi.h.in (ffi_raw): New type.
(UINT_ARG, SINT_ARG): New defines.
(ffi_closure, ffi_raw_closure): New types.
(ffi_prep_closure, ffi_prep_raw_closure): New declarations.
* configure.in: Add check for endianness and sizeof void*.
* src/x86/sysv.S (ffi_call_SYSV): Call fixup routine via argument,
instead of directly.
* configure: Rebuilt.
Thu Jul 8 14:28:42 1999 Anthony Green <[email protected]>
* configure.in: Add x86 and powerpc BeOS configurations.
From Makoto Kato <[email protected]>.
1999-05-09 Anthony Green <[email protected]>
* configure.in: Add warning about this being beta code.
Remove src/Makefile.am from the picture.
* configure: Rebuilt.
* Makefile.am: Move logic from src/Makefile.am. Add changes
to support libffi as a target library.
* Makefile.in: Rebuilt.
* aclocal.m4, config.guess, config.sub, ltconfig, ltmain.sh:
Upgraded to new autoconf, automake, libtool.
* README: Tweaks.
* LICENSE: Update copyright date.
* src/Makefile.am, src/Makefile.in: Removed.
1998-11-29 Anthony Green <[email protected]>
* include/ChangeLog: Removed.
* src/ChangeLog: Removed.
* src/mips/ChangeLog: Removed.
* src/sparc/ChangeLog: Remboved.
* src/x86/ChangeLog: Removed.
* ChangeLog.v1: Created.
+764
View File
@@ -0,0 +1,764 @@
The libffi version 1 ChangeLog archive.
Version 1 of libffi had per-directory ChangeLogs. Current and future
versions have a single ChangeLog file in the root directory. The
version 1 ChangeLogs have all been concatonated into this file for
future reference only.
--- libffi ----------------------------------------------------------------
Mon Oct 5 02:17:50 1998 Anthony Green <[email protected]>
* configure.in: Boosted rev.
* configure, Makefile.in, aclocal.m4: Rebuilt.
* README: Boosted rev and updated release notes.
Mon Oct 5 01:03:03 1998 Anthony Green <[email protected]>
* configure.in: Boosted rev.
* configure, Makefile.in, aclocal.m4: Rebuilt.
* README: Boosted rev and updated release notes.
1998-07-25 Andreas Schwab <[email protected]>
* m68k/ffi.c (ffi_prep_cif_machdep): Use bitmask for cif->flags.
Correctly handle small structures.
(ffi_prep_args): Also handle small structures.
(ffi_call): Pass size of return type to ffi_call_SYSV.
* m68k/sysv.S: Adjust for above changes. Correctly align small
structures in the return value.
* types.c (uint64, sint64) [M68K]: Change alignment to 4.
Fri Apr 17 17:26:58 1998 Anthony Green <[email protected]>
* configure.in: Boosted rev.
* configure,Makefile.in,aclocal.m4: Rebuilt.
* README: Boosted rev and added release notes.
Sun Feb 22 00:50:41 1998 Geoff Keating <[email protected]>
* configure.in: Add PowerPC config bits.
1998-02-14 Andreas Schwab <[email protected]>
* configure.in: Add m68k config bits. Change AC_CANONICAL_SYSTEM
to AC_CANONICAL_HOST, this is not a compiler. Use $host instead
of $target. Remove AC_CHECK_SIZEOF(char), we already know the
result. Fix argument of AC_ARG_ENABLE.
* configure, fficonfig.h.in: Rebuilt.
Tue Feb 10 20:53:40 1998 Richard Henderson <[email protected]>
* configure.in: Add Alpha config bits.
Tue May 13 13:39:20 1997 Anthony Green <[email protected]>
* README: Updated dates and reworded Irix comments.
* configure.in: Removed AC_PROG_RANLIB.
* Makefile.in, aclocal.m4, config.guess, config.sub, configure,
ltmain.sh, */Makefile.in: libtoolized again and rebuilt with
automake and autoconf.
Sat May 10 18:44:50 1997 Tom Tromey <[email protected]>
* configure, aclocal.m4: Rebuilt.
* configure.in: Don't compute EXTRADIST; now handled in
src/Makefile.in. Removed macros implied by AM_INIT_AUTOMAKE.
Don't run AM_MAINTAINER_MODE.
Thu May 8 14:34:05 1997 Anthony Green <[email protected]>
* missing, ltmain.sh, ltconfig.sh: Created. These are new files
required by automake and libtool.
* README: Boosted rev to 1.14. Added notes.
* acconfig.h: Moved PACKAGE and VERSION for new automake.
* configure.in: Changes for libtool.
* Makefile.am (check): make test now make check. Uses libtool now.
* Makefile.in, configure.in, aclocal.h, fficonfig.h.in: Rebuilt.
Thu May 1 16:27:07 1997 Anthony Green <[email protected]>
* missing: Added file required by new automake.
Tue Nov 26 14:10:42 1996 Anthony Green <[email protected]>
* acconfig.h: Added USING_PURIFY flag. This is defined when
--enable-purify-safety was used at configure time.
* configure.in (allsources): Added --enable-purify-safety switch.
(VERSION): Boosted rev to 1.13.
* configure: Rebuilt.
Fri Nov 22 06:46:12 1996 Anthony Green <[email protected]>
* configure.in (VERSION): Boosted rev to 1.12.
Removed special CFLAGS hack for gcc.
* configure: Rebuilt.
* README: Boosted rev to 1.12. Added notes.
* Many files: Cygnus Support changed to Cygnus Solutions.
Wed Oct 30 11:15:25 1996 Anthony Green <[email protected]>
* configure.in (VERSION): Boosted rev to 1.11.
* configure: Rebuilt.
* README: Boosted rev to 1.11. Added notes about GNU make.
Tue Oct 29 12:25:12 1996 Anthony Green <[email protected]>
* configure.in: Fixed -Wall trick.
(VERSION): Boosted rev.
* configure: Rebuilt
* acconfig.h: Needed for --enable-debug configure switch.
* README: Boosted rev to 1.09. Added more notes on building
libffi, and LCLint.
* configure.in: Added --enable-debug switch. Boosted rev to
1.09.
* configure: Rebuilt
Tue Oct 15 13:11:28 1996 Anthony Green <[email protected]>
* configure.in (VERSION): Boosted rev to 1.08
* configure: Rebuilt.
* README: Added n32 bug fix notes.
* Makefile.am: Added "make lint" production.
* Makefile.in: Rebuilt.
Mon Oct 14 10:54:46 1996 Anthony Green <[email protected]>
* README: Added web page reference.
* configure.in, README: Boosted rev to 1.05
* configure: Rebuilt.
* README: Fixed n32 sample code.
Fri Oct 11 17:09:28 1996 Anthony Green <[email protected]>
* README: Added sparc notes.
* configure.in, README: Boosted rev to 1.04.
* configure: Rebuilt.
Thu Oct 10 10:31:03 1996 Anthony Green <[email protected]>
* configure.in, README: Boosted rev to 1.03.
* configure: Rebuilt.
* README: Added struct notes.
* Makefile.am (EXTRA_DIST): Added LICENSE to distribution.
* Makefile.in: Rebuilt.
* README: Removed Linux section. No special notes now
because aggregates arg/return types work.
Wed Oct 9 16:16:42 1996 Anthony Green <[email protected]>
* README, configure.in (VERSION): Boosted rev to 1.02
* configure: Rebuilt.
Tue Oct 8 11:56:33 1996 Anthony Green <[email protected]>
* README (NOTE): Added n32 notes.
* Makefile.am: Added test production.
* Makefile: Rebuilt
* README: spell checked!
* configure.in (VERSION): Boosted rev to 1.01
* configure: Rebuilt.
Mon Oct 7 15:50:22 1996 Anthony Green <[email protected]>
* configure.in: Added nasty bit to support SGI tools.
* configure: Rebuilt.
* README: Added SGI notes. Added note about automake bug.
Mon Oct 7 11:00:28 1996 Anthony Green <[email protected]>
* README: Rewrote intro, and fixed examples.
Fri Oct 4 10:19:55 1996 Anthony Green <[email protected]>
* configure.in: -D$TARGET is no longer used as a compiler switch.
It is now inserted into ffi.h at configure time.
* configure: Rebuilt.
* FFI_ABI and FFI_STATUS are now ffi_abi and ffi_status.
Thu Oct 3 13:47:34 1996 Anthony Green <[email protected]>
* README, LICENSE: Created. Wrote some docs.
* configure.in: Don't barf on i586-unknown-linuxaout.
Added EXTRADIST code for "make dist".
* configure: Rebuilt.
* */Makefile.in: Rebuilt with patched automake.
Tue Oct 1 17:12:25 1996 Anthony Green <[email protected]>
* Makefile.am, aclocal.m4, config.guess, config.sub,
configure.in, fficonfig.h.in, install-sh, mkinstalldirs,
stamp-h.in: Created
* Makefile.in, configure: Generated
--- libffi/include --------------------------------------------------------
Tue Feb 24 13:09:36 1998 Anthony Green <[email protected]>
* ffi_mips.h: Updated FFI_TYPE_STRUCT_* values based on
ffi.h.in changes. This is a work-around for SGI's "simple"
assembler.
Sun Feb 22 00:51:55 1998 Geoff Keating <[email protected]>
* ffi.h.in: PowerPC support.
1998-02-14 Andreas Schwab <[email protected]>
* ffi.h.in: Add m68k support.
(FFI_TYPE_LONGDOUBLE): Make it a separate value.
Tue Feb 10 20:55:16 1998 Richard Henderson <[email protected]>
* ffi.h.in (SIZEOF_ARG): Use a pointer type by default.
* ffi.h.in: Alpha support.
Fri Nov 22 06:48:45 1996 Anthony Green <[email protected]>
* ffi.h.in, ffi_common.h: Cygnus Support -> Cygnus Solutions.
Wed Nov 20 22:31:01 1996 Anthony Green <[email protected]>
* ffi.h.in: Added ffi_type_void definition.
Tue Oct 29 12:22:40 1996 Anthony Green <[email protected]>
* Makefile.am (hack_DATA): Always install ffi_mips.h.
* ffi.h.in: Removed FFI_DEBUG. It's now in the correct
place (acconfig.h).
Added #include <stddef.h> for size_t definition.
Tue Oct 15 17:23:35 1996 Anthony Green <[email protected]>
* ffi.h.in, ffi_common.h, ffi_mips.h: More clean up.
Commented out #define of FFI_DEBUG.
Tue Oct 15 13:01:06 1996 Anthony Green <[email protected]>
* ffi_common.h: Added bool definition.
* ffi.h.in, ffi_common.h: Clean up based on LCLint output.
Added funny /*@...@*/ comments to annotate source.
Mon Oct 14 12:29:23 1996 Anthony Green <[email protected]>
* ffi.h.in: Interface changes based on feedback from Jim
Blandy.
Fri Oct 11 16:49:35 1996 Anthony Green <[email protected]>
* ffi.h.in: Small change for sparc support.
Thu Oct 10 14:53:37 1996 Anthony Green <[email protected]>
* ffi_mips.h: Added FFI_TYPE_STRUCT_* definitions for
special structure return types.
Wed Oct 9 13:55:57 1996 Anthony Green <[email protected]>
* ffi.h.in: Added SIZEOF_ARG definition for X86
Tue Oct 8 11:40:36 1996 Anthony Green <[email protected]>
* ffi.h.in (FFI_FN): Added macro for eliminating compiler warnings.
Use it to case your function pointers to the proper type.
* ffi_mips.h (SIZEOF_ARG): Added magic to fix type promotion bug.
* Makefile.am (EXTRA_DIST): Added ffi_mips.h to EXTRA_DIST.
* Makefile: Rebuilt.
* ffi_mips.h: Created. Moved all common mips definitions here.
Mon Oct 7 10:58:12 1996 Anthony Green <[email protected]>
* ffi.h.in: The SGI assember is very picky about parens. Redefined
some macros to avoid problems.
* ffi.h.in: Added FFI_DEFAULT_ABI definitions. Also added
externs for pointer, and 64bit integral ffi_types.
Fri Oct 4 09:51:37 1996 Anthony Green <[email protected]>
* ffi.h.in: Added FFI_ABI member to ffi_cif and changed
function prototypes accordingly.
Added #define @TARGET@. Now programs including ffi.h don't
have to specify this themselves.
Thu Oct 3 15:36:44 1996 Anthony Green <[email protected]>
* ffi.h.in: Changed ffi_prep_cif's values from void* to void**
* Makefile.am (EXTRA_DIST): Added EXTRA_DIST for "make dist"
to work.
* Makefile.in: Regenerated.
Wed Oct 2 10:16:59 1996 Anthony Green <[email protected]>
* Makefile.am: Created
* Makefile.in: Generated
* ffi_common.h: Added rcsid comment
Tue Oct 1 17:13:51 1996 Anthony Green <[email protected]>
* ffi.h.in, ffi_common.h: Created
--- libffi/src ------------------------------------------------------------
Mon Oct 5 02:17:50 1998 Anthony Green <[email protected]>
* arm/ffi.c, arm/sysv.S: Created.
* Makefile.am: Added arm files.
* Makefile.in: Rebuilt.
Mon Oct 5 01:41:38 1998 Anthony Green <[email protected]>
* Makefile.am (libffi_la_LDFLAGS): Incremented revision.
Sun Oct 4 16:27:17 1998 Anthony Green <[email protected]>
* alpha/osf.S (ffi_call_osf): Patch for DU assembler.
* ffitest.c (main): long long and long double return values work
for x86.
Fri Apr 17 11:50:58 1998 Anthony Green <[email protected]>
* Makefile.in: Rebuilt.
* ffitest.c (main): Floating point tests not executed for systems
with broken lond double (SunOS 4 w/ GCC).
* types.c: Fixed x86 alignment info for long long types.
Thu Apr 16 07:15:28 1998 Anthony Green <[email protected]>
* ffitest.c: Added more notes about GCC bugs under Irix 6.
Wed Apr 15 08:42:22 1998 Anthony Green <[email protected]>
* ffitest.c (struct5): New test function.
(main): New test with struct5.
Thu Mar 5 10:48:11 1998 Anthony Green <[email protected]>
* prep_cif.c (initialize_aggregate): Fix assertion for
nested structures.
Tue Feb 24 16:33:41 1998 Anthony Green <[email protected]>
* prep_cif.c (ffi_prep_cif): Added long double support for sparc.
Sun Feb 22 00:52:18 1998 Geoff Keating <[email protected]>
* powerpc/asm.h: New file.
* powerpc/ffi.c: New file.
* powerpc/sysv.S: New file.
* Makefile.am: PowerPC port.
* ffitest.c (main): Allow all tests to run even in presence of gcc
bug on PowerPC.
1998-02-17 Anthony Green <[email protected]>
* mips/ffi.c: Fixed comment typo.
* x86/ffi.c (ffi_prep_cif_machdep), x86/sysv.S (retfloat):
Fixed x86 long double return handling.
* types.c: Fixed x86 long double alignment info.
1998-02-14 Andreas Schwab <[email protected]>
* types.c: Add m68k support.
* ffitest.c (floating): Add long double parameter.
(return_ll, ldblit): New functions to test long long and long
double return value.
(main): Fix type error in assignment of ts[1-4]_type.elements.
Add tests for long long and long double arguments and return
values.
* prep_cif.c (ffi_prep_cif) [M68K]: Don't allocate argument for
struct value pointer.
* m68k/ffi.c, m68k/sysv.S: New files.
* Makefile.am: Add bits for m68k port. Add kludge to work around
automake deficiency.
(test): Don't require "." in $PATH.
* Makefile.in: Rebuilt.
Wed Feb 11 07:36:50 1998 Anthony Green <[email protected]>
* Makefile.in: Rebuilt.
Tue Feb 10 20:56:00 1998 Richard Henderson <[email protected]>
* alpha/ffi.c, alpha/osf.S: New files.
* Makefile.am: Alpha port.
Tue Nov 18 14:12:07 1997 Anthony Green <[email protected]>
* mips/ffi.c (ffi_prep_cif_machdep): Initialize rstruct_flag
for n32.
Tue Jun 3 17:18:20 1997 Anthony Green <[email protected]>
* ffitest.c (main): Added hack to get structure tests working
correctly.
Sat May 10 19:06:42 1997 Tom Tromey <[email protected]>
* Makefile.in: Rebuilt.
* Makefile.am (EXTRA_DIST): Explicitly list all distributable
files in subdirs.
(VERSION, CC): Removed.
Thu May 8 17:19:01 1997 Anthony Green <[email protected]>
* Makefile.am: Many changes for new automake and libtool.
* Makefile.in: Rebuilt.
Fri Nov 22 06:57:56 1996 Anthony Green <[email protected]>
* ffitest.c (main): Fixed test case for non mips machines.
Wed Nov 20 22:31:59 1996 Anthony Green <[email protected]>
* types.c: Added ffi_type_void declaration.
Tue Oct 29 13:07:19 1996 Anthony Green <[email protected]>
* ffitest.c (main): Fixed character constants.
(main): Emit warning for structure test 3 failure on Sun.
* Makefile.am (VPATH): Fixed VPATH def'n so automake won't
strip it out.
Moved distdir hack from libffi to automake.
(ffitest): Added missing -c for $(COMPILE) (change in automake).
* Makefile.in: Rebuilt.
Tue Oct 15 13:08:20 1996 Anthony Green <[email protected]>
* Makefile.am: Added "make lint" production.
* Makefile.in: Rebuilt.
* prep_cif.c (STACK_ARG_SIZE): Improved STACK_ARG_SIZE macro.
Clean up based on LCLint output. Added funny /*@...@*/ comments to
annotate source.
* ffitest.c, debug.c: Cleaned up code.
Mon Oct 14 12:26:56 1996 Anthony Green <[email protected]>
* ffitest.c: Changes based on interface changes.
* prep_cif.c (ffi_prep_cif): Cleaned up interface based on
feedback from Jim Blandy.
Fri Oct 11 15:53:18 1996 Anthony Green <[email protected]>
* ffitest.c: Reordered tests while porting to sparc.
Made changes to handle lame structure passing for sparc.
Removed calls to fflush().
* prep_cif.c (ffi_prep_cif): Added special case for sparc
aggregate type arguments.
Thu Oct 10 09:56:51 1996 Anthony Green <[email protected]>
* ffitest.c (main): Added structure passing/returning tests.
* prep_cif.c (ffi_prep_cif): Perform proper initialization
of structure return types if needed.
(initialize_aggregate): Bug fix
Wed Oct 9 16:04:20 1996 Anthony Green <[email protected]>
* types.c: Added special definitions for x86 (double doesn't
need double word alignment).
* ffitest.c: Added many tests
Tue Oct 8 09:19:22 1996 Anthony Green <[email protected]>
* prep_cif.c (ffi_prep_cif): Fixed assertion.
* debug.c (ffi_assert): Must return a non void now.
* Makefile.am: Added test production.
* Makefile: Rebuilt.
* ffitest.c (main): Created.
* types.c: Created. Stripped common code out of */ffi.c.
* prep_cif.c: Added missing stdlib.h include.
* debug.c (ffi_type_test): Used "a" to eliminate compiler
warnings in non-debug builds. Included ffi_common.h.
Mon Oct 7 15:36:42 1996 Anthony Green <[email protected]>
* Makefile.am: Added a rule for .s -> .o
This is required by the SGI compiler.
* Makefile: Rebuilt.
Fri Oct 4 09:51:08 1996 Anthony Green <[email protected]>
* prep_cif.c (initialize_aggregate): Moved abi specification
to ffi_prep_cif().
Thu Oct 3 15:37:37 1996 Anthony Green <[email protected]>
* prep_cif.c (ffi_prep_cif): Changed values from void* to void**.
(initialize_aggregate): Fixed aggregate type initialization.
* Makefile.am (EXTRA_DIST): Added support code for "make dist".
* Makefile.in: Regenerated.
Wed Oct 2 11:41:57 1996 Anthony Green <[email protected]>
* debug.c, prep_cif: Created.
* Makefile.am: Added debug.o and prep_cif.o to OBJ.
* Makefile.in: Regenerated.
* Makefile.am (INCLUDES): Added missing -I../include
* Makefile.in: Regenerated.
Tue Oct 1 17:11:51 1996 Anthony Green <[email protected]>
* error.c, Makefile.am: Created.
* Makefile.in: Generated.
--- libffi/src/x86 --------------------------------------------------------
Sun Oct 4 16:27:17 1998 Anthony Green <[email protected]>
* sysv.S (retlongdouble): Fixed long long return value support.
* ffi.c (ffi_prep_cif_machdep): Ditto.
Wed May 13 04:30:33 1998 Anthony Green <[email protected]>
* ffi.c (ffi_prep_cif_machdep): Fixed long double return value
support.
Wed Apr 15 08:43:20 1998 Anthony Green <[email protected]>
* ffi.c (ffi_prep_args): small struct support was missing.
Thu May 8 16:53:58 1997 Anthony Green <[email protected]>
* objects.mak: Removed.
Mon Dec 2 15:12:58 1996 Tom Tromey <[email protected]>
* sysv.S: Use .balign, for a.out Linux boxes.
Tue Oct 15 13:06:50 1996 Anthony Green <[email protected]>
* ffi.c: Clean up based on LCLint output.
Added funny /*@...@*/ comments to annotate source.
Fri Oct 11 16:43:38 1996 Anthony Green <[email protected]>
* ffi.c (ffi_call): Added assertion for bad ABIs.
Wed Oct 9 13:57:27 1996 Anthony Green <[email protected]>
* sysv.S (retdouble): Fixed double return problems.
* ffi.c (ffi_call): Corrected fn arg definition.
(ffi_prep_cif_machdep): Fixed double return problems
Tue Oct 8 12:12:49 1996 Anthony Green <[email protected]>
* ffi.c: Moved ffi_type definitions to types.c.
(ffi_prep_args): Fixed type promotion bug.
Mon Oct 7 15:53:06 1996 Anthony Green <[email protected]>
* ffi.c (FFI_*_TYPEDEF): Removed redundant ';'
Fri Oct 4 09:54:53 1996 Anthony Green <[email protected]>
* ffi.c (ffi_call): Removed FFI_ABI arg, and swapped
remaining args.
Wed Oct 2 10:07:05 1996 Anthony Green <[email protected]>
* ffi.c, sysv.S, objects.mak: Created.
(ffi_prep_cif): cif->rvalue no longer initialized to NULL.
(ffi_prep_cif_machdep): Moved machine independent cif processing
to src/prep_cif.c. Introduced ffi_prep_cif_machdep().
--- libffi/src/mips -------------------------------------------------------
Tue Feb 17 17:18:07 1998 Anthony Green <[email protected]>
* o32.S: Fixed typo in comment.
* ffi.c (ffi_prep_cif_machdep): Fixed argument processing.
Thu May 8 16:53:58 1997 Anthony Green <[email protected]>
* o32.s, n32.s: Wrappers for SGI tool support.
* objects.mak: Removed.
Tue Oct 29 14:37:45 1996 Anthony Green <[email protected]>
* ffi.c (ffi_prep_args): Changed int z to size_t z.
Tue Oct 15 13:17:25 1996 Anthony Green <[email protected]>
* n32.S: Fixed bad stack munging.
* ffi.c: Moved prototypes for ffi_call_?32() to here from
ffi_mips.h because extended_cif is not defined in ffi_mips.h.
Mon Oct 14 12:42:02 1996 Anthony Green <[email protected]>
* ffi.c: Interface changes based on feedback from Jim Blandy.
Thu Oct 10 11:22:16 1996 Anthony Green <[email protected]>
* n32.S, ffi.c: Lots of changes to support passing and
returning structures with the n32 calling convention.
* n32.S: Fixed fn pointer bug.
* ffi.c (ffi_prep_cif_machdep): Fix for o32 structure
return values.
(ffi_prep_args): Fixed n32 structure passing when structures
partially fit in registers.
Wed Oct 9 13:49:25 1996 Anthony Green <[email protected]>
* objects.mak: Added n32.o.
* n32.S: Created.
* ffi.c (ffi_prep_args): Added magic to support proper
n32 processing.
Tue Oct 8 10:37:35 1996 Anthony Green <[email protected]>
* ffi.c: Moved ffi_type definitions to types.c.
(ffi_prep_args): Fixed type promotion bug.
* o32.S: This code is only built for o32 compiles.
A lot of the #define cruft has moved to ffi_mips.h.
* ffi.c (ffi_prep_cif_machdep): Fixed arg flags. Second arg
is only processed if the first is either a float or double.
Mon Oct 7 15:33:59 1996 Anthony Green <[email protected]>
* o32.S: Modified to compile under each of o32, n32 and n64.
* ffi.c (FFI_*_TYPEDEF): Removed redundant ';'
Fri Oct 4 09:53:25 1996 Anthony Green <[email protected]>
* ffi.c (ffi_call): Removed FFI_ABI arg, and swapped
remaining args.
Wed Oct 2 17:41:22 1996 Anthony Green <[email protected]>
* o32.S: Removed crufty definitions.
Wed Oct 2 12:53:42 1996 Anthony Green <[email protected]>
* ffi.c (ffi_prep_cif): cif->rvalue no longer initialized to NULL.
(ffi_prep_cif_machdep): Moved all machine independent cif processing
to src/prep_cif.c. Introduced ffi_prep_cif_machdep. Return types
of FFI_TYPE_STRUCT are no different than FFI_TYPE_INT.
Tue Oct 1 17:11:02 1996 Anthony Green <[email protected]>
* ffi.c, o32.S, object.mak: Created
--- libffi/src/sparc ------------------------------------------------------
Tue Feb 24 16:33:18 1998 Anthony Green <[email protected]>
* ffi.c (ffi_prep_args): Added long double support.
Thu May 8 16:53:58 1997 Anthony Green <[email protected]>
* objects.mak: Removed.
Thu May 1 16:07:56 1997 Anthony Green <[email protected]>
* v8.S: Fixed minor portability problem reported by
Russ McManus <[email protected]>.
Tue Nov 26 14:12:43 1996 Anthony Green <[email protected]>
* v8.S: Used STACKFRAME define elsewhere.
* ffi.c (ffi_prep_args): Zero out space when USING_PURIFY
is set.
(ffi_prep_cif_machdep): Allocate the correct stack frame
space for functions with < 6 args.
Tue Oct 29 15:08:55 1996 Anthony Green <[email protected]>
* ffi.c (ffi_prep_args): int z is now size_t z.
Mon Oct 14 13:31:24 1996 Anthony Green <[email protected]>
* v8.S (ffi_call_V8): Gordon rewrites this again. It looks
great now.
* ffi.c (ffi_call): The comment about hijacked registers
is no longer valid after gordoni hacked v8.S.
* v8.S (ffi_call_V8): Rewrote with gordoni. Much simpler.
* v8.S, ffi.c: ffi_call() had changed to accept more than
two args, so v8.S had to change (because it hijacks incoming
arg registers).
* ffi.c: Interface changes based on feedback from Jim Blandy.
Thu Oct 10 17:48:16 1996 Anthony Green <[email protected]>
* ffi.c, v8.S, objects.mak: Created.
+20
View File
@@ -0,0 +1,20 @@
libffi - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 Red Hat, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
+72
View File
@@ -0,0 +1,72 @@
## Process this with automake to create Makefile.in
AUTOMAKE_OPTIONS = foreign no-installinfo
if TESTSUBDIR
SUBDIRS = include testsuite
else
SUBDIRS = include
endif
EXTRA_DIST = \
LICENSE \
README \
ChangeLog.v1 \
alpha/ffi.c \
arm/ffi.c \
ia64/ffi.c \
m68k/ffi.c \
mips/ffi.c \
powerpc/ffi.c \
s390/ffi.c \
sparc/ffi.c \
x86/ffi.c \
alpha/osf.S \
arm/sysv.S \
ia64/unix.S \
m68k/sysv.S \
mips/n32.S \
mips/o32.S \
powerpc/sysv.S \
s390/sysv.S \
sparc/v8.S \
sparc/v9.S \
x86/win32.S \
x86/sysv.S
# Multilib support variables.
MULTISRCTOP =
MULTIBUILDTOP =
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
## Install a library built with a cross compiler in tooldir, not
## libdir.
if USE_LIBDIR
toolexeclibdir = $(libdir)$(MULTISUBDIR)
else
toolexecdir = $(exec_prefix)/$(target_alias)
toolexeclibdir = $(toolexecdir)/lib$(MULTISUBDIR)
endif
toolexeclib_LIBRARIES = libffi.a
## Work around automake deficiency
nodist_libffi_a_SOURCES = t-ffi.c t-asm.S
libffi_a_SOURCES = \
debug.c \
prep_cif.c \
types.c \
raw_api.c \
java_raw_api.c \
$(nodist_libffi_a_SOURCES)
AM_CFLAGS = -fexceptions
INCLUDES = \
-I$(top_srcdir)/include \
-Iinclude \
-I$(top_srcdir)/src
+513
View File
@@ -0,0 +1,513 @@
README for libffi-2.00
libffi-2.00 has not been released yet! This is a development snapshot!
libffi-1.20 was released on [SOME FUTURE DAY]. Check the libffi web
page for updates: <URL:http://sourceware.cygnus.com/libffi/>.
What is libffi?
===============
Compilers for high level languages generate code that follow certain
conventions. These conventions are necessary, in part, for separate
compilation to work. One such convention is the "calling
convention". The "calling convention" is essentially a set of
assumptions made by the compiler about where function arguments will
be found on entry to a function. A "calling convention" also specifies
where the return value for a function is found.
Some programs may not know at the time of compilation what arguments
are to be passed to a function. For instance, an interpreter may be
told at run-time about the number and types of arguments used to call
a given function. Libffi can be used in such programs to provide a
bridge from the interpreter program to compiled code.
The libffi library provides a portable, high level programming
interface to various calling conventions. This allows a programmer to
call any function specified by a call interface description at run
time.
Ffi stands for Foreign Function Interface. A foreign function
interface is the popular name for the interface that allows code
written in one language to call code written in another language. The
libffi library really only provides the lowest, machine dependent
layer of a fully featured foreign function interface. A layer must
exist above libffi that handles type conversions for values passed
between the two languages.
Supported Platforms and Prerequisites
=====================================
Libffi has been ported to:
Alpha - Linux and OSF/1
ARM - Linux (System V ABI)
IA-32 - Linux, Solaris, and BeOS (System V ABI)
IA-64 - Linux (System V ABI)
m68k - Linux (System V ABI)
MIPS, 32- and 64-bit - Irix (System V/o32 and n32)
PowerPC - Linux (System V ABI)
S390 - Linux (System V ABI)
Sparc, 32-bit - SunOS 4.1.3, Solaris 2.x, and Linux (Sparc v8)
Sparc, 64-bit - Linux (Sparc v9)
Libffi has been tested with GCC 3.00 and newer compilers.
You must use GNU make to build libffi.
If you port libffi to another platform, please let me know! I assume
that some will be easy (x86 NetBSD), and others will be more difficult
(HP, AIX).
Installing libffi
=================
[Note: before actually performing any of these installation steps,
you may wish to read the "Platform Specific Notes" below.]
First you must configure the distribution for your particular
system. Go to the directory you wish to build libffi in and run the
"configure" program found in the root directory of the libffi source
distribution.
You may want to tell configure where to install the libffi library and
header files. To do that, use the --prefix configure switch. Libffi
will install under /usr/local by default.
If you want to enable extra run-time debugging checks use the the
--enable-debug configure switch. This is useful when your program dies
mysteriously while using libffi.
Another useful configure switch is --enable-purify-safety. Using this
will add some extra code which will suppress certain warnings when you
are using Purify with libffi. Only use this switch when using
Purify, as it will slow down the library.
Configure has many other options. Use "configure --help" to see them all.
Once configure has finished, type "make". Note that you must be using
GNU make. SGI's make will not work. Sun's probably won't either.
You can ftp GNU make from prep.ai.mit.edu:/pub/gnu.
To ensure that libffi is working as advertised, type "make test".
To install the library and header files, type "make install".
Using libffi
============
The Basics
----------
Libffi assumes that you have a pointer to the function you wish to
call and that you know the number and types of arguments to pass it,
as well as the return type of the function.
The first thing you must do is create an ffi_cif object that matches
the signature of the function you wish to call. The cif in ffi_cif
stands for Call InterFace. To prepare a call interface object, use the
following function:
ffi_status ffi_prep_cif(ffi_cif *cif, ffi_abi abi,
unsigned int nargs,
ffi_type *rtype, ffi_type **atypes);
CIF is a pointer to the call interface object you wish
to initialize.
ABI is an enum that specifies the calling convention
to use for the call. FFI_DEFAULT_ABI defaults
to the system's native calling convention. Other
ABI's may be used with care. They are system
specific.
NARGS is the number of arguments this function accepts.
libffi does not yet support vararg functions.
RTYPE is a pointer to an ffi_type structure that represents
the return type of the function. Ffi_type objects
describe the types of values. libffi provides
ffi_type objects for many of the native C types:
signed int, unsigned int, signed char, unsigned char,
etc. There is also a pointer ffi_type object and
a void ffi_type. Use &ffi_type_void for functions that
don't return values.
ATYPES is a vector of ffi_type pointers. ARGS must be NARGS long.
If NARGS is 0, this is ignored.
ffi_prep_cif will return a status code that you are responsible
for checking. It will be one of the following:
FFI_OK - All is good.
FFI_BAD_TYPEDEF - One of the ffi_type objects that ffi_prep_cif
came across is bad.
Before making the call, the VALUES vector should be initialized
with pointers to the appropriate argument values.
To call the the function using the initialized ffi_cif, use the
ffi_call function:
void ffi_call(ffi_cif *cif, void *fn, void *rvalue, void **avalues);
CIF is a pointer to the ffi_cif initialized specifically
for this function.
FN is a pointer to the function you want to call.
RVALUE is a pointer to a chunk of memory that is to hold the
result of the function call. Currently, it must be
at least one word in size (except for the n32 version
under Irix 6.x, which must be a pointer to an 8 byte
aligned value (a long long). It must also be at least
word aligned (depending on the return type, and the
system's alignment requirements). If RTYPE is
&ffi_type_void, this is ignored. If RVALUE is NULL,
the return value is discarded.
AVALUES is a vector of void* that point to the memory locations
holding the argument values for a call.
If NARGS is 0, this is ignored.
If you are expecting a return value from FN it will have been stored
at RVALUE.
An Example
----------
Here is a trivial example that calls puts() a few times.
#include <stdio.h>
#include <ffi.h>
int main()
{
ffi_cif cif;
ffi_type *args[1];
void *values[1];
char *s;
int rc;
/* Initialize the argument info vectors */
args[0] = &ffi_type_uint;
values[0] = &s;
/* Initialize the cif */
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uint, args) == FFI_OK)
{
s = "Hello World!";
ffi_call(&cif, puts, &rc, values);
/* rc now holds the result of the call to puts */
/* values holds a pointer to the function's arg, so to
call puts() again all we need to do is change the
value of s */
s = "This is cool!";
ffi_call(&cif, puts, &rc, values);
}
return 0;
}
Aggregate Types
---------------
Although libffi has no special support for unions or bit-fields, it is
perfectly happy passing structures back and forth. You must first
describe the structure to libffi by creating a new ffi_type object
for it. Here is the definition of ffi_type:
typedef struct _ffi_type
{
unsigned size;
short alignment;
short type;
struct _ffi_type **elements;
} ffi_type;
All structures must have type set to FFI_TYPE_STRUCT. You may set
size and alignment to 0. These will be calculated and reset to the
appropriate values by ffi_prep_cif().
elements is a NULL terminated array of pointers to ffi_type objects
that describe the type of the structure elements. These may, in turn,
be structure elements.
The following example initializes a ffi_type object representing the
tm struct from Linux's time.h:
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
/* Those are for future use. */
long int __tm_gmtoff__;
__const char *__tm_zone__;
};
{
ffi_type tm_type;
ffi_type *tm_type_elements[12];
int i;
tm_type.size = tm_type.alignment = 0;
tm_type.elements = &tm_type_elements;
for (i = 0; i < 9; i++)
tm_type_elements[i] = &ffi_type_sint;
tm_type_elements[9] = &ffi_type_slong;
tm_type_elements[10] = &ffi_type_pointer;
tm_type_elements[11] = NULL;
/* tm_type can now be used to represent tm argument types and
return types for ffi_prep_cif() */
}
Platform Specific Notes
=======================
Intel x86
---------
There are no known problems with the x86 port.
Sun Sparc - SunOS 4.1.3 & Solaris 2.x
-------------------------------------
There's a bug in the structure passing code for sparc processors.
Struct arguments that are passed in value actually end up being passed
by reference. This will be fixed Real Soon Now.
"long long" values are not supported yet.
You must use GNU Make to build libffi on Sun platforms.
MIPS - Irix 5.3 & 6.x
---------------------
Irix 6.2 and better supports three different calling conventions: o32,
n32 and n64. Currently, libffi only supports both o32 and n32 under
Irix 6.x, but only o32 under Irix 5.3. Libffi will automatically be
configured for whichever calling convention it was built for.
By default, the configure script will try to build libffi with the GNU
development tools. To build libffi with the SGI development tools, set
the environment variable CC to either "cc -32" or "cc -n32" before
running configure under Irix 6.x (depending on whether you want an o32
or n32 library), or just "cc" for Irix 5.3.
With the n32 calling convention, when returning structures smaller
than 16 bytes, be sure to provide an RVALUE that is 8 byte aligned.
Here's one way of forcing this:
double struct_storage[2];
my_small_struct *s = (my_small_struct *) struct_storage;
/* Use s for RVALUE */
If you don't do this you are liable to get spurious bus errors.
"long long" values are not supported yet.
You must use GNU Make to build libffi on SGI platforms.
ARM - System V ABI
------------------
The ARM port was performed on a NetWinder running ARM Linux ELF
(2.0.31) and gcc 2.8.1. config.sub still does not recognize the
machine name sa110-unknown-linux-gnu (currently returned by
NetWinder). In the mean time the package can be configured by running
'configure arm-linux'.
PowerPC System V ABI
--------------------
There are two `System V ABI's which libffi implements for PowerPC.
They differ only in how small structures are returned from functions.
In the FFI_SYSV version, structures that are 8 bytes or smaller are
returned in registers. This is what GCC does when it is configured
for solaris, and is what the System V ABI I have (dated September
1995) says.
In the FFI_GCC_SYSV version, all structures are returned the same way:
by passing a pointer as the first argument to the function. This is
what GCC does when it is configured for linux or a generic sysv
target.
EGCS 1.0.1 (and probably other versions of EGCS/GCC) also has a
inconsistency with the SysV ABI: When a procedure is called with many
floating-point arguments, some of them get put on the stack. They are
all supposed to be stored in double-precision format, even if they are
only single-precision, but EGCS stores single-precision arguments as
single-precision anyway. This causes one test to fail (the `many
arguments' test).
History
=======
2.00 ???-??-01
Many configure improvements. No more run tests required at
configure time so cross compiling should work well. ffi.h is
target independent now and may be installed safely anywhere.
ffitest replaced with dejagnu testing infrastructure. s390
port from ????. ia64 port from Hans Boehm. General
performance improvements. Closures designed and implemented
by Kresten Krab Thorup and ported to ia64 and powerpc by Hans
Boehm and ???? respectively.
1.20 Oct-5-98
Raffaele Sena produces ARM port.
1.19 Oct-5-98
Fixed x86 long double and long long return support.
m68k bug fixes from Andreas Schwab.
Patch for DU assembler compatibility for the Alpha from Richard
Henderson.
1.18 Apr-17-98
Bug fixes and MIPS configuration changes.
1.17 Feb-24-98
Bug fixes and m68k port from Andreas Schwab. PowerPC port from
Geoffrey Keating. Various bug x86, Sparc and MIPS bug fixes.
1.16 Feb-11-98
Richard Henderson produces Alpha port.
1.15 Dec-4-97
Fixed an n32 ABI bug. New libtool, auto* support.
1.14 May-13-97
libtool is now used to generate shared and static libraries.
Fixed a minor portability problem reported by Russ McManus
<[email protected]>.
1.13 Dec-2-96
Added --enable-purify-safety to keep Purify from complaining
about certain low level code.
Sparc fix for calling functions with < 6 args.
Linux x86 a.out fix.
1.12 Nov-22-96
Added missing ffi_type_void, needed for supporting void return
types. Fixed test case for non MIPS machines. Cygnus Support
is now Cygnus Solutions.
1.11 Oct-30-96
Added notes about GNU make.
1.10 Oct-29-96
Added configuration fix for non GNU compilers.
1.09 Oct-29-96
Added --enable-debug configure switch. Clean-ups based on LCLint
feedback. ffi_mips.h is always installed. Many configuration
fixes. Fixed ffitest.c for sparc builds.
1.08 Oct-15-96
Fixed n32 problem. Many clean-ups.
1.07 Oct-14-96
Gordon Irlam rewrites v8.S again. Bug fixes.
1.06 Oct-14-96
Gordon Irlam improved the sparc port.
1.05 Oct-14-96
Interface changes based on feedback.
1.04 Oct-11-96
Sparc port complete (modulo struct passing bug).
1.03 Oct-10-96
Passing struct args, and returning struct values works for
all architectures/calling conventions. Expanded tests.
1.02 Oct-9-96
Added SGI n32 support. Fixed bugs in both o32 and Linux support.
Added "make test".
1.01 Oct-8-96
Fixed float passing bug in mips version. Restructured some
of the code. Builds cleanly with SGI tools.
1.00 Oct-7-96
First release. No public announcement.
Authors & Credits
=================
libffi was written by Anthony Green <[email protected]>.
Portions of libffi were derived from Gianni Mariani's free gencall
library for Silicon Graphics machines.
The closure mechanism was designed and implemented on IA-32 by Kresten
Krab Thorup.
The initial Sparc port was derived from code contributed by the fine
folks at Visible Decisions Inc. Further enhancements were made by
Gordon Irlam while at Cygnus Solutions.
The Alpha port was written by Richard Henderson at Cygnus Solutions/Red Hat.
Andreas Schwab ported libffi to m68k Linux and provided a number of
bug fixes.
Geoffrey Keating ported libffi to the PowerPC.
Raffaele Sena ported libffi to the ARM.
Hans Boehm ported libffi to IA-64.
Jakub Jelinek ported libffi to 32- and 64-bit Sparc Linux.
Jesper Skov and Andrew Haley both did more than their fair share of
stepping through the code and tracking down bugs.
Thanks also to Tom Tromey for bug fixes and configuration help.
Thanks to Jim Blandy, who provided some useful feedback on the libffi
interface.
If you have a problem, or have found a bug, please send a note to
[email protected].
+12
View File
@@ -0,0 +1,12 @@
/* Define this if you want extra debugging */
#undef FFI_DEBUG
/* Define this if you are using Purify and want to suppress
spurious messages. */
#undef USING_PURIFY
/* Define this is you do not want support for aggregate types. */
#undef FFI_NO_STRUCTS
/* Define this is you do not want support for the raw API. */
#undef FFI_NO_RAW_API
+97
View File
@@ -0,0 +1,97 @@
AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
[changequote(<<, >>)dnl
dnl The name to #define.
define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
dnl The cache variable name.
define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
changequote([, ])dnl
AC_MSG_CHECKING(size of $1)
AC_CACHE_VAL(AC_CV_NAME,
[for ac_size in 4 8 1 2 16 12 $2 ; do # List sizes in rough order of prevalence.
AC_TRY_COMPILE([#include "confdefs.h"
#include <sys/types.h>
$2
], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
if test x$AC_CV_NAME != x ; then break; fi
done
])
if test x$AC_CV_NAME = x ; then
AC_MSG_ERROR([cannot determine a size for $1])
fi
AC_MSG_RESULT($AC_CV_NAME)
AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
undefine([AC_TYPE_NAME])dnl
undefine([AC_CV_NAME])dnl
])
AC_DEFUN([AC_C_BIGENDIAN_CROSS],
[AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
[ac_cv_c_bigendian=unknown
# See if sys/param.h defines the BYTE_ORDER macro.
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>], [
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
bogus endian macros
#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
AC_TRY_COMPILE([#include <sys/types.h>
#include <sys/param.h>], [
#if BYTE_ORDER != BIG_ENDIAN
not big endian
#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
if test $ac_cv_c_bigendian = unknown; then
AC_TRY_RUN([main () {
/* Are we little or big endian? From Harbison&Steele. */
union
{
long l;
char c[sizeof (long)];
} u;
u.l = 1;
exit (u.c[sizeof (long) - 1] == 1);
}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes,
[ echo $ac_n "cross-compiling... " 2>&AC_FD_MSG ])
fi])
if test $ac_cv_c_bigendian = unknown; then
AC_MSG_CHECKING(to probe for byte ordering)
[
cat >conftest.c <<EOF
short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
void _ascii() { char* s = (char*) ascii_mm; s = (char*) ascii_ii; }
short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
void _ebcdic() { char* s = (char*) ebcdic_mm; s = (char*) ebcdic_ii; }
int main() { _ascii (); _ebcdic (); return 0; }
EOF
] if test -f conftest.c ; then
if ${CC-cc} ${CFLAGS} conftest.c -o conftest.o && test -f conftest.o ; then
if test `grep -l BIGenDianSyS conftest.o` ; then
echo $ac_n ' big endian probe OK, ' 1>&AC_FD_MSG
ac_cv_c_bigendian=yes
fi
if test `grep -l LiTTleEnDian conftest.o` ; then
echo $ac_n ' little endian probe OK, ' 1>&AC_FD_MSG
if test $ac_cv_c_bigendian = yes ; then
ac_cv_c_bigendian=unknown;
else
ac_cv_c_bigendian=no
fi
fi
echo $ac_n 'guessing bigendian ... ' >&AC_FD_MSG
fi
fi
AC_MSG_RESULT($ac_cv_c_bigendian)
fi
if test $ac_cv_c_bigendian = yes; then
AC_DEFINE(WORDS_BIGENDIAN, 1, [whether byteorder is bigendian])
BYTEORDER=4321
else
BYTEORDER=1234
fi
AC_DEFINE_UNQUOTED(BYTEORDER, $BYTEORDER, [1234 = LIL_ENDIAN, 4321 = BIGENDIAN])
if test $ac_cv_c_bigendian = unknown; then
AC_MSG_ERROR(unknown endianess - sorry, please pre-set ac_cv_c_bigendian)
fi
])
+247
View File
@@ -0,0 +1,247 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Cygnus Solutions
Alpha Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
extern void ffi_call_osf(void *, unsigned long, unsigned, void *, void (*)());
extern void ffi_closure_osf(void);
ffi_status
ffi_prep_cif_machdep(ffi_cif *cif)
{
/* Adjust cif->bytes to represent a minimum 6 words for the temporary
register argument loading area. */
if (cif->bytes < 6*SIZEOF_ARG)
cif->bytes = 6*SIZEOF_ARG;
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_STRUCT:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags = cif->rtype->type;
break;
default:
cif->flags = FFI_TYPE_INT;
break;
}
return FFI_OK;
}
void
ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
{
unsigned long *stack, *argp;
long i, avn;
ffi_type **arg_types;
FFI_ASSERT (cif->abi == FFI_OSF);
/* If the return value is a struct and we don't have a return
value address then we need to make one. */
if (rvalue == NULL && cif->flags == FFI_TYPE_STRUCT)
rvalue = alloca(cif->rtype->size);
/* Allocate the space for the arguments, plus 4 words of temp
space for ffi_call_osf. */
argp = stack = alloca(cif->bytes + 4*SIZEOF_ARG);
if (cif->flags == FFI_TYPE_STRUCT)
*(void **) argp++ = rvalue;
i = 0;
avn = cif->nargs;
arg_types = cif->arg_types;
while (i < avn)
{
switch ((*arg_types)->type)
{
case FFI_TYPE_SINT8:
*(SINT64 *) argp = *(SINT8 *)(* avalue);
break;
case FFI_TYPE_UINT8:
*(SINT64 *) argp = *(UINT8 *)(* avalue);
break;
case FFI_TYPE_SINT16:
*(SINT64 *) argp = *(SINT16 *)(* avalue);
break;
case FFI_TYPE_UINT16:
*(SINT64 *) argp = *(UINT16 *)(* avalue);
break;
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
/* Note that unsigned 32-bit quantities are sign extended. */
*(SINT64 *) argp = *(SINT32 *)(* avalue);
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
case FFI_TYPE_POINTER:
*(UINT64 *) argp = *(UINT64 *)(* avalue);
break;
case FFI_TYPE_FLOAT:
if (argp - stack < 6)
{
/* Note the conversion -- all the fp regs are loaded as
doubles. The in-register format is the same. */
*(double *) argp = *(float *)(* avalue);
}
else
*(float *) argp = *(float *)(* avalue);
break;
case FFI_TYPE_DOUBLE:
*(double *) argp = *(double *)(* avalue);
break;
case FFI_TYPE_STRUCT:
memcpy(argp, *avalue, (*arg_types)->size);
break;
default:
FFI_ASSERT(0);
}
argp += ALIGN((*arg_types)->size, SIZEOF_ARG) / SIZEOF_ARG;
i++, arg_types++, avalue++;
}
ffi_call_osf(stack, cif->bytes, cif->flags, rvalue, fn);
}
ffi_status
ffi_prep_closure (ffi_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*, void*, void**, void*),
void *user_data)
{
unsigned int *tramp;
FFI_ASSERT (cif->abi == FFI_OSF);
tramp = (unsigned int *) &closure->tramp[0];
tramp[0] = 0x47fb0401; /* mov $27,$1 */
tramp[1] = 0xa77b0010; /* ldq $27,16($27) */
tramp[2] = 0x6bfb0000; /* jmp $31,($27),0 */
tramp[3] = 0x47ff041f; /* nop */
*(void **) &tramp[4] = ffi_closure_osf;
closure->cif = cif;
closure->fun = fun;
closure->user_data = user_data;
/* Flush the Icache. */
asm volatile ("imb" : : : "memory");
return FFI_OK;
}
int
ffi_closure_osf_inner(ffi_closure *closure, void *rvalue, unsigned long *argp)
{
ffi_cif *cif;
void **avalue;
ffi_type **arg_types;
long i, avn, argn;
cif = closure->cif;
avalue = alloca(cif->nargs * sizeof(void *));
argn = 0;
/* Copy the caller's structure return address to that the closure
returns the data directly to the caller. */
if (cif->flags == FFI_TYPE_STRUCT)
{
rvalue = (void *) argp[0];
argn = 1;
}
i = 0;
avn = cif->nargs;
arg_types = cif->arg_types;
/* Grab the addresses of the arguments from the stack frame. */
while (i < avn)
{
switch (arg_types[i]->type)
{
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
case FFI_TYPE_POINTER:
case FFI_TYPE_STRUCT:
avalue[i] = &argp[argn];
break;
case FFI_TYPE_FLOAT:
if (argn < 6)
{
/* Floats coming from registers need conversion from double
back to float format. */
*(float *)&argp[argn - 6] = *(double *)&argp[argn - 6];
avalue[i] = &argp[argn - 6];
}
else
avalue[i] = &argp[argn];
break;
case FFI_TYPE_DOUBLE:
avalue[i] = &argp[argn - (argn < 6 ? 6 : 0)];
break;
default:
FFI_ASSERT(0);
}
argn += ALIGN(arg_types[i]->size, SIZEOF_ARG) / SIZEOF_ARG;
i++;
}
/* Invoke the closure. */
(closure->fun) (cif, rvalue, avalue, closure->user_data);
/* Tell ffi_closure_osf how to perform return type promotions. */
return cif->rtype->type;
}
+278
View File
@@ -0,0 +1,278 @@
/* -----------------------------------------------------------------------
osf.S - Copyright (c) 1998 Cygnus Solutions
Alpha/OSF Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#include <ffi_private.h>
.arch ev6
.text
/* ffi_call_osf (void *args, unsigned long bytes, unsigned flags,
void *raddr, void (*fnaddr)());
Bit o trickiness here -- ARGS+BYTES is the base of the stack frame
for this function. This has been allocated by ffi_call. We also
deallocate some of the stack that has been alloca'd. */
.align 3
.globl ffi_call_osf
.ent ffi_call_osf
ffi_call_osf:
.frame $15, 32, $26, 0
.mask 0x4008000, -32
addq $16,$17,$1
mov $16, $30
stq $26, 0($1)
stq $15, 8($1)
stq $18, 16($1)
mov $1, $15
.prologue 0
stq $19, 24($1)
mov $20, $27
# Load up all of the (potential) argument registers.
ldq $16, 0($30)
ldt $f16, 0($30)
ldt $f17, 8($30)
ldq $17, 8($30)
ldt $f18, 16($30)
ldq $18, 16($30)
ldt $f19, 24($30)
ldq $19, 24($30)
ldt $f20, 32($30)
ldq $20, 32($30)
ldt $f21, 40($30)
ldq $21, 40($30)
# Deallocate the register argument area.
lda $30, 48($30)
jsr $26, ($27), 0
ldgp $29, 0($26)
# If the return value pointer is NULL, assume no return value.
ldq $19, 24($15)
ldq $18, 16($15)
ldq $26, 0($15)
beq $19, $noretval
# Store the return value out in the proper type.
cmpeq $18, FFI_TYPE_INT, $1
bne $1, $retint
cmpeq $18, FFI_TYPE_FLOAT, $2
bne $2, $retfloat
cmpeq $18, FFI_TYPE_DOUBLE, $3
bne $3, $retdouble
$noretval:
ldq $15, 8($15)
ret
$retint:
stq $0, 0($19)
nop
ldq $15, 8($15)
ret
$retfloat:
sts $f0, 0($19)
nop
ldq $15, 8($15)
ret
$retdouble:
stt $f0, 0($19)
nop
ldq $15, 8($15)
ret
.end ffi_call_osf
/* ffi_closure_osf(...)
Receives the closure argument in $1. */
.align 3
.globl ffi_closure_osf
.ent ffi_closure_osf
ffi_closure_osf:
.frame $30, 16*8, $26, 0
.mask 0x4000000, -16*8
ldgp $29, 0($27)
subq $30, 16*8, $30
stq $26, 0($30)
.prologue 1
# Store all of the potential argument registers in va_list format.
stt $f16, 4*8($30)
stt $f17, 5*8($30)
stt $f18, 6*8($30)
stt $f19, 7*8($30)
stt $f20, 8*8($30)
stt $f21, 9*8($30)
stq $16, 10*8($30)
stq $17, 11*8($30)
stq $18, 12*8($30)
stq $19, 13*8($30)
stq $20, 14*8($30)
stq $21, 15*8($30)
# Call ffi_closure_osf_inner to do the bulk of the work.
mov $1, $16
lda $17, 2*8($30)
lda $18, 10*8($30)
jsr $26, ffi_closure_osf_inner
ldgp $29, 0($26)
ldq $26, 0($30)
# Load up the return value in the proper type.
lda $1, $load_table
s4addq $0, $1, $1
ldl $1, 0($1)
addq $1, $29, $1
jmp $31, ($1), $load_32
.align 4
$load_none:
addq $30, 16*8, $30
ret
.align 4
$load_float:
lds $f0, 16($30)
nop
addq $30, 16*8, $30
ret
.align 4
$load_double:
ldt $f0, 16($30)
nop
addq $30, 16*8, $30
ret
.align 4
$load_u8:
#ifdef __alpha_bwx__
ldbu $0, 16($30)
nop
#else
ldq $0, 16($30)
and $0, 255, $0
#endif
addq $30, 16*8, $30
ret
.align 4
$load_s8:
#ifdef __alpha_bwx__
ldbu $0, 16($30)
sextb $0, $0
#else
ldq $0, 16($30)
sll $0, 56, $0
sra $0, 56, $0
#endif
addq $30, 16*8, $30
ret
.align 4
$load_u16:
#ifdef __alpha_bwx__
ldwu $0, 16($30)
nop
#else
ldq $0, 16($30)
zapnot $0, 3, $0
#endif
addq $30, 16*8, $30
ret
.align 4
$load_s16:
#ifdef __alpha_bwx__
ldwu $0, 16($30)
sextw $0, $0
#else
ldq $0, 16($30)
sll $0, 48, $0
sra $0, 48, $0
#endif
addq $30, 16*8, $30
ret
.align 4
$load_32:
ldl $0, 16($30)
nop
addq $30, 16*8, $30
ret
.align 4
$load_64:
ldq $0, 16($30)
nop
addq $30, 16*8, $30
ret
.end ffi_closure_osf
.section .rodata
$load_table:
.gprel32 $load_none # FFI_TYPE_VOID
.gprel32 $load_32 # FFI_TYPE_INT
.gprel32 $load_float # FFI_TYPE_FLOAT
.gprel32 $load_double # FFI_TYPE_DOUBLE
.gprel32 $load_double # FFI_TYPE_LONGDOUBLE
.gprel32 $load_u8 # FFI_TYPE_UINT8
.gprel32 $load_s8 # FFI_TYPE_SINT8
.gprel32 $load_u16 # FFI_TYPE_UINT16
.gprel32 $load_s16 # FFI_TYPE_SINT16
.gprel32 $load_32 # FFI_TYPE_UINT32
.gprel32 $load_32 # FFI_TYPE_SINT32
.gprel32 $load_64 # FFI_TYPE_UINT64
.gprel32 $load_64 # FFI_TYPE_SINT64
.gprel32 $load_none # FFI_TYPE_STRUCT
.gprel32 $load_64 # FFI_TYPE_POINTER
/* Assert that the table above is in sync with ffi.h. */
#if FFI_TYPE_FLOAT != 2 \
|| FFI_TYPE_DOUBLE != 3 \
|| FFI_TYPE_UINT8 != 5 \
|| FFI_TYPE_SINT8 != 6 \
|| FFI_TYPE_UINT16 != 7 \
|| FFI_TYPE_SINT16 != 8 \
|| FFI_TYPE_UINT32 != 9 \
|| FFI_TYPE_SINT32 != 10 \
|| FFI_TYPE_UINT64 != 11 \
|| FFI_TYPE_SINT64 != 12 \
|| FFI_TYPE_STRUCT != 13 \
|| FFI_TYPE_POINTER != 14 \
|| FFI_TYPE_LAST != 14
#error "osf.S out of sync with ffi.h"
#endif
+183
View File
@@ -0,0 +1,183 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Cygnus Solutions
ARM Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
/*@-exportheader@*/
void ffi_prep_args(char *stack, extended_cif *ecif)
/*@=exportheader@*/
{
register unsigned int i;
register int tmp;
register unsigned int avn;
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
tmp = 0;
argp = stack;
if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) {
*(void **) argp = ecif->rvalue;
argp += 4;
}
avn = ecif->cif->nargs;
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0) && (avn != 0);
i--, p_arg++)
{
size_t z;
/* Align if necessary */
if (((*p_arg)->alignment - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, (*p_arg)->alignment);
}
if (avn != 0)
{
avn--;
z = (*p_arg)->size;
if (z < sizeof(int))
{
z = sizeof(int);
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
*(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
*(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
*(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
break;
case FFI_TYPE_STRUCT:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
break;
default:
FFI_ASSERT(0);
}
}
else if (z == sizeof(int))
{
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
}
else
{
memcpy(argp, *p_argv, z);
}
p_argv++;
argp += z;
}
}
return;
}
/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
case FFI_TYPE_STRUCT:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags = (unsigned) cif->rtype->type;
break;
default:
cif->flags = FFI_TYPE_INT;
break;
}
return FFI_OK;
}
/*@-declundef@*/
/*@-exportheader@*/
extern void ffi_call_SYSV(void (*)(char *, extended_cif *),
/*@out@*/ extended_cif *,
unsigned, unsigned,
/*@out@*/ unsigned *,
void (*fn)());
/*@=declundef@*/
/*@=exportheader@*/
void ffi_call(/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
/*@out@*/ void *rvalue,
/*@dependent@*/ void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
/*@-sysunrecog@*/
ecif.rvalue = alloca(cif->rtype->size);
/*@=sysunrecog@*/
}
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_SYSV:
/*@-usedef@*/
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
/*@=usedef@*/
break;
default:
FFI_ASSERT(0);
break;
}
}
+111
View File
@@ -0,0 +1,111 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 1998 Cygnus Solutions
ARM Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#ifdef HAVE_MACHINE_ASM_H
#include <machine/asm.h>
#else
/* XXX these lose for some platforms, I'm sure. */
#define CNAME(x) x
#define ENTRY(x) .globl CNAME(x); .type CNAME(x),%function; CNAME(x):
#endif
.text
# a1: ffi_prep_args
# a2: &ecif
# a3: cif->bytes
# a4: fig->flags
# sp+0: ecif.rvalue
# sp+4: fn
# This assumes we are using gas.
ENTRY(ffi_call_SYSV)
# Save registers
stmfd sp!, {a1-a4, fp, lr}
mov fp, sp
# Make room for all of the new args.
sub sp, fp, a3
# Place all of the ffi_prep_args in position
mov ip, a1
mov a1, sp
# a2 already set
# And call
mov lr, pc
mov pc, ip
# move first 4 parameters in registers
ldr a1, [sp, #0]
ldr a2, [sp, #4]
ldr a3, [sp, #8]
ldr a4, [sp, #12]
# and adjust stack
ldr ip, [fp, #8]
cmp ip, #16
movge ip, #16
add sp, sp, ip
# call function
mov lr, pc
ldr pc, [fp, #28]
# Remove the space we pushed for the args
mov sp, fp
# Load a3 with the pointer to storage for the return value
ldr a3, [sp, #24]
# Load a4 with the return type code
ldr a4, [sp, #12]
# If the return value pointer is NULL, assume no return value.
cmp a3, #0
beq epilogue
# return INT
cmp a4, #FFI_TYPE_INT
streq a1, [a3]
beq epilogue
# return FLOAT
cmp a4, #FFI_TYPE_FLOAT
stfeqs f0, [a3]
beq epilogue
# return DOUBLE or LONGDOUBLE
cmp a4, #FFI_TYPE_DOUBLE
stfeqd f0, [a3]
epilogue:
ldmfd sp!, {a1-a4, fp, pc}
.ffi_call_SYSV_end:
.size CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
+6
View File
@@ -0,0 +1,6 @@
libtoolize --automake
automake -a
autoheader
aclocal $ACLOCAL_FLAGS
autoconf
./configure $*
+849
View File
@@ -0,0 +1,849 @@
# Configure fragment invoked in the post-target section for subdirs
# wanting multilib support.
#
# It is advisable to support a few --enable/--disable options to let the
# user select which libraries s/he really wants.
#
# Subdirectories wishing to use multilib should put the following lines
# in the "post-target" section of configure.in.
#
# if [ "${srcdir}" = "." ] ; then
# if [ "${with_target_subdir}" != "." ] ; then
# . ${with_multisrctop}../../config-ml.in
# else
# . ${with_multisrctop}../config-ml.in
# fi
# else
# . ${srcdir}/../config-ml.in
# fi
#
#
# Things are complicated because 6 separate cases must be handled:
# 2 (native, cross) x 3 (absolute-path, relative-not-dot, dot) = 6.
#
# srcdir=. is special. It must handle make programs that don't handle VPATH.
# To implement this, a symlink tree is built for each library and for each
# multilib subdir.
#
# The build tree is layed out as
#
# ./
# newlib
# m68020/
# newlib
# m68881/
# newlib
#
# The nice feature about this arrangement is that inter-library references
# in the build tree work without having to care where you are. Note that
# inter-library references also work in the source tree because symlink trees
# are built when srcdir=.
#
# Unfortunately, trying to access the libraries in the build tree requires
# the user to manually choose which library to use as GCC won't be able to
# find the right one. This is viewed as the lesser of two evils.
#
# Configure variables:
# ${with_target_subdir} = "." for native, or ${target_alias} for cross.
# Set by top level Makefile.
# ${with_multisrctop} = how many levels of multilibs there are in the source
# tree. It exists to handle the case of configuring in the source tree:
# ${srcdir} is not constant.
# ${with_multisubdir} = name of multilib subdirectory (eg: m68020/m68881).
#
# Makefile variables:
# MULTISRCTOP = number of multilib levels in source tree (+1 if cross)
# (FIXME: note that this is different than ${with_multisrctop}. Check out.).
# MULTIBUILDTOP = number of multilib levels in build tree
# MULTIDIRS = list of multilib subdirs (eg: m68000 m68020 ...)
# (only defined in each library's main Makefile).
# MULTISUBDIR = installed subdirectory name with leading '/' (eg: /m68000)
# (only defined in each multilib subdir).
# FIXME: Multilib is currently disabled by default for everything other than
# newlib. It is up to each target to turn on multilib support for the other
# libraries as desired.
# We have to handle being invoked by both Cygnus configure and Autoconf.
#
# Cygnus configure incoming variables:
# srcdir, subdir, host, arguments
#
# Autoconf incoming variables:
# srcdir, host, ac_configure_args
#
# We *could* figure srcdir and host out, but we'd have to do work that
# our caller has already done to figure them out and requiring these two
# seems reasonable.
# Note that `host' in this case is GCC's `target'. Target libraries are
# configured for a particular host.
if [ -n "${ac_configure_args}" ]; then
Makefile=${ac_file-Makefile}
ml_config_shell=${CONFIG_SHELL-/bin/sh}
ml_arguments="${ac_configure_args}"
ml_realsrcdir=${srcdir}
else
Makefile=${Makefile-Makefile}
ml_config_shell=${config_shell-/bin/sh}
ml_arguments="${arguments}"
if [ -n "${subdir}" -a "${subdir}" != "." ] ; then
ml_realsrcdir=${srcdir}/${subdir}
else
ml_realsrcdir=${srcdir}
fi
fi
# Scan all the arguments and set all the ones we need.
ml_verbose=--verbose
for option in ${ml_arguments}
do
case $option in
--*) ;;
-*) option=-$option ;;
esac
case $option in
--*=*)
optarg=`echo $option | sed -e 's/^[^=]*=//'`
;;
esac
case $option in
--disable-*)
enableopt=`echo ${option} | sed 's:^--disable-:enable_:;s:-:_:g'`
eval $enableopt=no
;;
--enable-*)
case "$option" in
*=*) ;;
*) optarg=yes ;;
esac
enableopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
eval $enableopt="$optarg"
;;
--norecursion | --no*)
ml_norecursion=yes
;;
--silent | --sil* | --quiet | --q*)
ml_verbose=--silent
;;
--verbose | --v | --verb*)
ml_verbose=--verbose
;;
--with-*)
case "$option" in
*=*) ;;
*) optarg=yes ;;
esac
withopt=`echo ${option} | sed 's:^--::;s:=.*$::;s:-:_:g'`
eval $withopt="$optarg"
;;
--without-*)
withopt=`echo ${option} | sed 's:^--::;s:out::;s:-:_:g'`
eval $withopt=no
;;
esac
done
# Only do this if --enable-multilib.
if [ "${enable_multilib}" = yes ]; then
# Compute whether this is the library's top level directory
# (ie: not a multilib subdirectory, and not a subdirectory like newlib/src).
# ${with_multisubdir} tells us we're in the right branch, but we could be
# in a subdir of that.
# ??? The previous version could void this test by separating the process into
# two files: one that only the library's toplevel configure.in ran (to
# configure the multilib subdirs), and another that all configure.in's ran to
# update the Makefile. It seemed reasonable to collapse all multilib support
# into one file, but it does leave us with having to perform this test.
ml_toplevel_p=no
if [ -z "${with_multisubdir}" ]; then
if [ "${srcdir}" = "." ]; then
# Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}.
# ${with_target_subdir} = "." for native, otherwise target alias.
if [ "${with_target_subdir}" = "." ]; then
if [ -f ${ml_realsrcdir}/../config-ml.in ]; then
ml_toplevel_p=yes
fi
else
if [ -f ${ml_realsrcdir}/../../config-ml.in ]; then
ml_toplevel_p=yes
fi
fi
else
# Use ${ml_realsrcdir} instead of ${srcdir} here to account for ${subdir}.
if [ -f ${ml_realsrcdir}/../config-ml.in ]; then
ml_toplevel_p=yes
fi
fi
fi
# If this is the library's top level directory, set multidirs to the
# multilib subdirs to support. This lives at the top because we need
# `multidirs' set right away.
if [ "${ml_toplevel_p}" = yes ]; then
multidirs=
for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
dir=`echo $i | sed -e 's/;.*$//'`
if [ "${dir}" = "." ]; then
true
else
if [ -z "${multidirs}" ]; then
multidirs="${dir}"
else
multidirs="${multidirs} ${dir}"
fi
fi
done
# Target libraries are configured for the host they run on, so we check
# $host here, not $target.
case "${host}" in
arc-*-elf*)
if [ x$enable_biendian != xyes ]
then
old_multidirs=${multidirs}
multidirs=""
for x in ${old_multidirs}; do
case "${x}" in
*be*) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
;;
arm-*-*)
if [ x"$enable_fpu" = xno ]
then
old_multidirs=${multidirs}
multidirs=""
for x in ${old_multidirs}; do
case "${x}" in
*fpu*) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x"$enable_26bit" = xno ]
then
old_multidirs=${multidirs}
multidirs=""
for x in ${old_multidirs}; do
case "${x}" in
*26bit*) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x"$enable_underscore" = xno ]
then
old_multidirs=${multidirs}
multidirs=""
for x in ${old_multidirs}; do
case "${x}" in
*under*) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x"$enable_interwork" = xno ]
then
old_multidirs=${multidirs}
multidirs=""
for x in ${old_multidirs}; do
case "${x}" in
*interwork*) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_biendian = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*le* ) : ;;
*be* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x"$enable_nofmult" = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*nofmult* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
;;
m68*-*-*)
if [ x$enable_softfloat = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*soft-float* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_m68881 = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*m68881* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_m68000 = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*m68000* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_m68020 = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*m68020* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
;;
mips*-*-*)
if [ x$enable_single_float = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*single* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_biendian = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*el* ) : ;;
*eb* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_softfloat = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*soft-float* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
case " $multidirs " in
*" mabi=64 "*)
# We will not be able to create libraries with -mabi=64 if
# we cannot even link a trivial program. It usually
# indicates the 64bit libraries are missing.
if echo 'main() {}' > conftest.c &&
${CC-gcc} -mabi=64 conftest.c -o conftest; then
:
else
echo Could not link program with -mabi=64, disabling it.
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*mabi=64* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
rm -f conftest.c conftest
;;
esac
;;
powerpc*-*-* | rs6000*-*-*)
if [ x$enable_softfloat = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*soft-float* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_powercpu = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
power | */power | */power/* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_powerpccpu = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*powerpc* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_powerpcos = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*mcall-linux* | *mcall-solaris* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_biendian = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*mlittle* | *mbig* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_sysv = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*mcall-sysv* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
if [ x$enable_aix = xno ]
then
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*mcall-aix* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
;;
sparc*-*-*)
case " $multidirs " in
*" m64 "*)
# We will not be able to create libraries with -m64 if
# we cannot even link a trivial program. It usually
# indicates the 64bit libraries are missing.
if echo 'main() {}' > conftest.c &&
${CC-gcc} -m64 conftest.c -o conftest; then
:
else
echo Could not link program with -m64, disabling it.
old_multidirs="${multidirs}"
multidirs=""
for x in ${old_multidirs}; do
case "$x" in
*m64* ) : ;;
*) multidirs="${multidirs} ${x}" ;;
esac
done
fi
rm -f conftest.c conftest
;;
esac
;;
esac
# Remove extraneous blanks from multidirs.
# Tests like `if [ -n "$multidirs" ]' require it.
multidirs=`echo "$multidirs" | sed -e 's/^[ ][ ]*//' -e 's/[ ][ ]*$//' -e 's/[ ][ ]*/ /g'`
# Add code to library's top level makefile to handle building the multilib
# subdirs.
cat > Multi.tem <<\EOF
# FIXME: There should be an @-sign in front of the `if'.
# Leave out until this is tested a bit more.
multi-do:
if [ -z "$(MULTIDIRS)" ]; then \
true; \
else \
rootpre=`pwd`/; export rootpre; \
srcrootpre=`cd $(srcdir); pwd`/; export srcrootpre; \
lib=`echo $${rootpre} | sed -e 's,^.*/\([^/][^/]*\)/$$,\1,'`; \
compiler="$(CC)"; \
for i in `$${compiler} --print-multi-lib 2>/dev/null`; do \
dir=`echo $$i | sed -e 's/;.*$$//'`; \
if [ "$${dir}" = "." ]; then \
true; \
else \
if [ -d ../$${dir}/$${lib} ]; then \
flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
CFLAGS="$(CFLAGS) $${flags}" \
prefix="$(prefix)" \
exec_prefix="$(exec_prefix)" \
GCJFLAGS="$(GCJFLAGS) $${flags}" \
CXXFLAGS="$(CXXFLAGS) $${flags}" \
LIBCFLAGS="$(LIBCFLAGS) $${flags}" \
LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \
LDFLAGS="$(LDFLAGS) $${flags}" \
$(DO)); then \
true; \
else \
exit 1; \
fi; \
else true; \
fi; \
fi; \
done; \
fi
# FIXME: There should be an @-sign in front of the `if'.
# Leave out until this is tested a bit more.
multi-clean:
if [ -z "$(MULTIDIRS)" ]; then \
true; \
else \
lib=`pwd | sed -e 's,^.*/\([^/][^/]*\)$$,\1,'`; \
for dir in Makefile $(MULTIDIRS); do \
if [ -f ../$${dir}/$${lib}/Makefile ]; then \
if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) $(DO)); \
then true; \
else exit 1; \
fi; \
else true; \
fi; \
done; \
fi
EOF
cat ${Makefile} Multi.tem > Makefile.tem
rm -f ${Makefile} Multi.tem
mv Makefile.tem ${Makefile}
fi # ${ml_toplevel_p} = yes
if [ "${ml_verbose}" = --verbose ]; then
echo "Adding multilib support to Makefile in ${ml_realsrcdir}"
if [ "${ml_toplevel_p}" = yes ]; then
echo "multidirs=${multidirs}"
fi
echo "with_multisubdir=${with_multisubdir}"
fi
if [ "${srcdir}" = "." ]; then
if [ "${with_target_subdir}" != "." ]; then
ml_srcdotdot="../"
else
ml_srcdotdot=""
fi
else
ml_srcdotdot=""
fi
if [ -z "${with_multisubdir}" ]; then
ml_subdir=
ml_builddotdot=
: # ml_srcdotdot= # already set
else
ml_subdir="/${with_multisubdir}"
# The '[^/][^/]*' appears that way to work around a SunOS sed bug.
ml_builddotdot=`echo ${with_multisubdir} | sed -e 's:[^/][^/]*:..:g'`/
if [ "$srcdir" = "." ]; then
ml_srcdotdot=${ml_srcdotdot}${ml_builddotdot}
else
: # ml_srcdotdot= # already set
fi
fi
if [ "${ml_toplevel_p}" = yes ]; then
ml_do='$(MAKE)'
ml_clean='$(MAKE)'
else
ml_do=true
ml_clean=true
fi
# TOP is used by newlib and should not be used elsewhere for this purpose.
# MULTI{SRC,BUILD}TOP are the proper ones to use. MULTISRCTOP is empty
# when srcdir != builddir. MULTIBUILDTOP is always some number of ../'s.
# FIXME: newlib needs to be updated to use MULTI{SRC,BUILD}TOP so we can
# delete TOP. Newlib may wish to continue to use TOP for its own purposes
# of course.
# MULTIDIRS is non-empty for the cpu top level Makefile (eg: newlib/Makefile)
# and lists the subdirectories to recurse into.
# MULTISUBDIR is non-empty in each cpu subdirectory's Makefile
# (eg: newlib/h8300h/Makefile) and is the installed subdirectory name with
# a leading '/'.
# MULTIDO is used for targets like all, install, and check where
# $(FLAGS_TO_PASS) augmented with the subdir's compiler option is needed.
# MULTICLEAN is used for the *clean targets.
#
# ??? It is possible to merge MULTIDO and MULTICLEAN into one. They are
# currently kept separate because we don't want the *clean targets to require
# the existence of the compiler (which MULTIDO currently requires) and
# therefore we'd have to record the directory options as well as names
# (currently we just record the names and use --print-multi-lib to get the
# options).
sed -e "s:^TOP[ ]*=[ ]*\([./]*\)[ ]*$:TOP = ${ml_builddotdot}\1:" \
-e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ${ml_srcdotdot}:" \
-e "s:^MULTIBUILDTOP[ ]*=.*$:MULTIBUILDTOP = ${ml_builddotdot}:" \
-e "s:^MULTIDIRS[ ]*=.*$:MULTIDIRS = ${multidirs}:" \
-e "s:^MULTISUBDIR[ ]*=.*$:MULTISUBDIR = ${ml_subdir}:" \
-e "s:^MULTIDO[ ]*=.*$:MULTIDO = $ml_do:" \
-e "s:^MULTICLEAN[ ]*=.*$:MULTICLEAN = $ml_clean:" \
${Makefile} > Makefile.tem
rm -f ${Makefile}
mv Makefile.tem ${Makefile}
# If this is the library's top level, configure each multilib subdir.
# This is done at the end because this is the loop that runs configure
# in each multilib subdir and it seemed reasonable to finish updating the
# Makefile before going on to configure the subdirs.
if [ "${ml_toplevel_p}" = yes ]; then
# We must freshly configure each subdirectory. This bit of code is
# actually partially stolen from the main configure script. FIXME.
if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then
if [ "${ml_verbose}" = --verbose ]; then
echo "Running configure in multilib subdirs ${multidirs}"
echo "pwd: `pwd`"
fi
ml_origdir=`pwd`
ml_libdir=`echo $ml_origdir | sed -e 's,^.*/,,'`
# cd to top-level-build-dir/${with_target_subdir}
cd ..
for ml_dir in ${multidirs}; do
if [ "${ml_verbose}" = --verbose ]; then
echo "Running configure in multilib subdir ${ml_dir}"
echo "pwd: `pwd`"
fi
if [ -d ${ml_dir} ]; then true; else
# ``mkdir -p ${ml_dir}'' See also mkinstalldirs.
pathcomp=""
for d in `echo ":${ml_dir}" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`; do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp" 1>&2
mkdir "$pathcomp" > /dev/null 2>&1 || lasterr=$?
fi
if test ! -d "$pathcomp"; then
exit $lasterr
fi
pathcomp="$pathcomp/"
done
fi
if [ -d ${ml_dir}/${ml_libdir} ]; then true; else mkdir ${ml_dir}/${ml_libdir}; fi
# Eg: if ${ml_dir} = m68000/m68881, dotdot = ../../
dotdot=../`echo ${ml_dir} | sed -e 's|[^/]||g' -e 's|/|../|g'`
case ${srcdir} in
".")
echo Building symlink tree in `pwd`/${ml_dir}/${ml_libdir}
if [ "${with_target_subdir}" != "." ]; then
ml_unsubdir="../"
else
ml_unsubdir=""
fi
(cd ${ml_dir}/${ml_libdir};
../${dotdot}${ml_unsubdir}symlink-tree ../${dotdot}${ml_unsubdir}${ml_libdir} "")
if [ -f ${ml_dir}/${ml_libdir}/Makefile ]; then
if [ x"${MAKE}" = x ]; then
(cd ${ml_dir}/${ml_libdir}; make distclean)
else
(cd ${ml_dir}/${ml_libdir}; ${MAKE} distclean)
fi
fi
ml_newsrcdir="."
ml_srcdiroption=
multisrctop=${dotdot}
;;
*)
case "${srcdir}" in
/* | [A-Za-z]:[\\/]* ) # absolute path
ml_newsrcdir=${srcdir}
;;
*) # otherwise relative
ml_newsrcdir=${dotdot}${srcdir}
;;
esac
ml_srcdiroption="-srcdir=${ml_newsrcdir}"
multisrctop=
;;
esac
case "${progname}" in
/* | [A-Za-z]:[\\/]* ) ml_recprog=${progname} ;;
*) ml_recprog=${dotdot}${progname} ;;
esac
# FIXME: POPDIR=${PWD=`pwd`} doesn't work here.
ML_POPDIR=`pwd`
cd ${ml_dir}/${ml_libdir}
if [ -f ${ml_newsrcdir}/configure ]; then
ml_recprog="${ml_newsrcdir}/configure --cache-file=../config.cache"
fi
# find compiler flag corresponding to ${ml_dir}
for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
dir=`echo $i | sed -e 's/;.*$//'`
if [ "${dir}" = "${ml_dir}" ]; then
flags=`echo $i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`
break
fi
done
ml_config_env='CC="${CC_}$flags" CXX="${CXX_}$flags" GCJ="${GCJ_}$flags"'
if [ "${with_target_subdir}" = "." ]; then
CC_=$CC' '
CXX_=$CXX' '
GCJ_=$GCJ' '
else
# Create a regular expression that matches any string as long
# as ML_POPDIR.
popdir_rx=`echo ${ML_POPDIR} | sed 's,.,.,g'`
CC_=
for arg in ${CC}; do
case $arg in
-[BIL]"${ML_POPDIR}"/*)
CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\1/p"`' ' ;;
"${ML_POPDIR}"/*)
CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
*)
CC_="${CC_}${arg} " ;;
esac
done
CXX_=
for arg in ${CXX}; do
case $arg in
-[BIL]"${ML_POPDIR}"/*)
CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
"${ML_POPDIR}"/*)
CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
*)
CXX_="${CXX_}${arg} " ;;
esac
done
GCJ_=
for arg in ${GCJ}; do
case $arg in
-[BIL]"${ML_POPDIR}"/*)
GCJ_="${GCJ_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
"${ML_POPDIR}"/*)
GCJ_="${GCJ_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
*)
GCJ_="${GCJ_}${arg} " ;;
esac
done
if test "x${LD_LIBRARY_PATH+set}" = xset; then
LD_LIBRARY_PATH_=
for arg in `echo "$LD_LIBRARY_PATH" | tr ':' ' '`; do
case "$arg" in
"${ML_POPDIR}"/*)
arg=`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`
;;
esac
if test "x$LD_LIBRARY_PATH_" != x; then
LD_LIBRARY_PATH_=$LD_LIBRARY_PATH_:$arg
else
LD_LIBRARY_PATH_=$arg
fi
done
ml_config_env="$ml_config_env LD_LIBRARY_PATH=$LD_LIBRARY_PATH_"
fi
if test "x${SHLIB_PATH+set}" = xset; then
SHLIB_PATH_=
for arg in `echo "$SHLIB_PATH" | tr ':' ' '`; do
case "$arg" in
"${ML_POPDIR}"/*)
arg=`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`
;;
esac
if test "x$SHLIB_PATH_" != x; then
SHLIB_PATH_=$SHLIB_PATH_:$arg
else
SHLIB_PATH_=$arg
fi
done
ml_config_env="$ml_config_env SHLIB_PATH=$SHLIB_PATH_"
fi
fi
if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
--with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
${ml_arguments} ${ml_srcdiroption} ; then
true
else
exit 1
fi
cd ${ML_POPDIR}
done
cd ${ml_origdir}
fi
fi # ${ml_toplevel_p} = yes
fi # ${enable_multilib} = yes
+166
View File
@@ -0,0 +1,166 @@
dnl Process this with autoconf to create configure
AC_INIT(fficonfig.h.in)
AM_CONFIG_HEADER(fficonfig.h)
dnl Default to --enable-multilib
AC_ARG_ENABLE(multilib,
[ --enable-multilib build many library versions (default)],
[case "${enableval}" in
yes) multilib=yes ;;
no) multilib=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
esac], [multilib=yes])dnl
dnl We may get other options which we don't document:
dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
### I don't understand this, so comment it out for now
#if test "${srcdir}" = "."; then
# if test "${with_target_subdir}" != "."; then
# libffi_basedir="${srcdir}/${with_multisrctop}.."
# else
# libffi_basedir="${srcdir}/${with_multisrctop}"
# fi
#else
libffi_basedir="${srcdir}"
#fi
AC_SUBST(libffi_basedir)
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE(libffi,2.00-beta,no-define)
AC_EXEEXT
AM_MAINTAINER_MODE
AC_PROG_CC
AC_PROG_RANLIB
AC_PROG_LN_S
dnl The -no-testsuite modules omit the test subdir.
AM_CONDITIONAL(TESTSUBDIR, test -d $srcdir/testsuite)
TARGET="unknown"
case "$host" in
alpha*-*-linux* | alpha*-*-osf*)
TARGET=ALPHA;
$LN_S ${srcdir}/alpha/ffi.c t-ffi.c;
$LN_S $srcdir/alpha/osf.S t-asm.S;;
arm*-*-linux-*)
TARGET=ARM;
$LN_S $srcdir/arm/ffi.c t-ffi.c;
$LN_S $srcdir/arm/ffi.S t-asm.S;;
i*86-*-beos*|i*86-*-freebsd*|i*86-*-linux*|i*86-*-solaris*)
TARGET=X86;
$LN_S $srcdir/x86/ffi.c t-ffi.c;
$LN_S $srcdir/x86/sysv.S t-asm.S;;
i*86-*-cygwin*|i*86-*-mingw*|i*86-*-win32*)
TARGET=X86_WIN32;
$LN_S $srcdir/x86/ffi.c t-ffi.c;
$LN_S $srcdir/x86/win32.S t-asm.S;;
ia64*-*-*)
TARGET=IA64;
$LN_S $srcdir/ia64/ffi.c t-ffi.c;
$LN_S $srcdir/ia64/unix.S t-asm.S;;
m68k-*-linux*)
TARGET=M68K;
$LN_S $srcdir/m68k/ffi.c t-ffi.c;
$LN_S $srcdir/m68k/unix.S t-asm.S;;
mips-*-elf)
TARGET=MIPS;
$LN_S $srcdir/mips/ffi.c t-ffi.c;
$LN_S $srcdir/mips/o32.S t-asm.S;;
mips-sgi-irix5.*)
TARGET=MIPS;
$LN_S $srcdir/mips/ffi.c t-ffi.c;
$LN_S $srcdir/mips/o32.S t-asm.S;;
mips-sgi-irix6.*)
TARGET=MIPS;
$LN_S $srcdir/mips/ffi.c t-ffi.c;
$LN_S $srcdir/mips/n32.S t-asm.S;;
powerpc-*-linux* | powerpc-*-sysv* | powerpc-*-beos*)
TARGET=POWERPC;
$LN_S $srcdir/powerpc/ffi.c t-ffi.c;
$LN_S $srcdir/powerpc/sysv.S t-asm.S;;
s390-*-linux*)
TARGET=S390;
$LN_S $srcdir/s390/ffi.c t-ffi.c;
$LN_S $srcdir/s390/v8.S t-asm.S;;
sparc-*-linux*|sparc-sun-*)
TARGET=SPARC;
$LN_S $srcdir/sparc/ffi.c t-ffi.c;
$LN_S $srcdir/sparc/v8.S t-asm.S;;
sparc64-*-linux*)
TARGET=SPARC;
$LN_S $srcdir/sparc/ffi.c t-ffi.c;
$LN_S $srcdir/sparc/v9.S t-asm.S;;
esac
AC_SUBST(AM_RUNTESTFLAGS)
if test ${TARGET} = unknown; then
AC_ERROR("libffi has not been ported to $host.")
fi
AC_HEADER_STDC
AC_CHECK_FUNCS(memcpy)
AC_FUNC_ALLOCA
dnl AC_CHECK_SIZEOF(char)
AC_COMPILE_CHECK_SIZEOF(short)
AC_COMPILE_CHECK_SIZEOF(int)
AC_COMPILE_CHECK_SIZEOF(long)
AC_COMPILE_CHECK_SIZEOF(long long)
AC_COMPILE_CHECK_SIZEOF(float)
AC_COMPILE_CHECK_SIZEOF(double)
AC_COMPILE_CHECK_SIZEOF(long double)
AC_COMPILE_CHECK_SIZEOF(void *)
AC_C_BIGENDIAN_CROSS
AC_SUBST(TARGET)
AC_SUBST(TARGETDIR)
AC_SUBST(SHELL)
AC_ARG_ENABLE(debug,[ --enable-debug debugging mode], AC_DEFINE(FFI_DEBUG))
AC_ARG_ENABLE(debug,[ --disable-structs omit code for struct support], AC_DEFINE(FFI_NO_STRUCTS))
AC_ARG_ENABLE(debug,[ --disable-raw-api make the raw api unavailable], AC_DEFINE(FFI_NO_RAW_API))
AC_ARG_ENABLE(purify-safety,
[ --enable-purify-safety purify-safe mode], AC_DEFINE(USING_PURIFY))
AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
if test "${multilib}" = "yes"; then
multilib_arg="--enable-multilib"
else
multilib_arg=
fi
AC_OUTPUT(include/Makefile testsuite/Makefile Makefile,
[
if test -n "$CONFIG_FILES"; then
ac_file=Makefile . ${libffi_basedir}/config-ml.in
fi
],
srcdir=${srcdir}
host=${host}
target=${target}
with_multisubdir=${with_multisubdir}
ac_configure_args="${multilib_arg} ${ac_configure_args}"
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
libffi_basedir=${libffi_basedir}
CC="${CC}"
DEFS="$DEFS"
test ! -d include && mkdir include
test ! -f include/fficonfig.h && cp fficonfig.h include/fficonfig.h
if cmp -s fficonfig.h include/fficonfig.h 2>/dev/null; then
echo fficonfig.h unchanged
else
echo Moving fficonfig.h to include/fficonfig.h
cp fficonfig.h include/fficonfig.h
fi
)
+65
View File
@@ -0,0 +1,65 @@
/* -----------------------------------------------------------------------
debug.c - Copyright (c) 1996 Red Hat, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
#include <stdio.h>
/* General debugging routines */
void ffi_stop_here(void)
{
/* This function is only useful for debugging purposes.
Place a breakpoint on ffi_stop_here to be notified of
significant events. */
}
/* This function should only be called via the FFI_ASSERT() macro */
int ffi_assert(char *file, int line)
{
fprintf(stderr, "ASSERTION FAILURE: %s line %d\n", file, line);
ffi_stop_here();
abort();
/* This has to return something for the compiler not to complain */
/*@notreached@*/
return 0;
}
/* Perform a sanity check on an ffi_type structure */
bool ffi_type_test(ffi_type *a)
{
/*@-usedef@*/
FFI_ASSERT(a->type <= FFI_TYPE_LAST);
FFI_ASSERT(a->type > FFI_TYPE_VOID ? a->size > 0 : 1);
FFI_ASSERT(a->type > FFI_TYPE_VOID ? a->alignment > 0 : 1);
FFI_ASSERT(a->type == FFI_TYPE_STRUCT ? a->elements != NULL : 1);
/*@=usedef@*/
/* This is a silly thing to return, but it keeps the compiler from
issuing warnings about "a" not being used in non-debug builds. */
return (a != NULL);
}
+736
View File
@@ -0,0 +1,736 @@
/* -----------------------------------------------------------------------
ffitest.c - Copyright (c) 1996, 1997, 1998 Cygnus Solutions
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
/* This is lame. Long double support is barely there under SunOS 4.x */
#if defined(__sparc__) && (SIZEOF_LONG_DOUBLE != 16)
#define BROKEN_LONG_DOUBLE
#endif
#define CHECK(x) !(x) ? fail(__FILE__, __LINE__) : 0
static int fail(char *file, int line)
{
fprintf(stderr, "Test failure: %s line %d\n", file, line);
exit(EXIT_FAILURE);
/*@notreached@*/
return 0;
}
#define MAX_ARGS 256
static size_t my_strlen(char *s)
{
return (strlen(s));
}
static int promotion(signed char sc, signed short ss,
unsigned char uc, unsigned short us)
{
int r = (int) sc + (int) ss + (int) uc + (int) us;
return r;
}
static signed char return_sc(signed char sc)
{
return sc;
}
static unsigned char return_uc(unsigned char uc)
{
return uc;
}
static long long return_ll(long long ll)
{
return ll;
}
static int floating(int a, float b, double c, long double d, int e)
{
int i;
#if 0
/* This is ifdef'd out for now. long double support under SunOS/gcc
is pretty much non-existent. You'll get the odd bus error in library
routines like printf(). */
printf("%d %f %f %Lf %d\n", a, (double)b, c, d, e);
#endif
i = (int) ((float)a/b + ((float)c/(float)d));
return i;
}
static float many(float f1,
float f2,
float f3,
float f4,
float f5,
float f6,
float f7,
float f8,
float f9,
float f10,
float f11,
float f12,
float f13)
{
#if 0
printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
(double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
(double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
(double) f11, (double) f12, (double) f13);
#endif
return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
}
static double dblit(float f)
{
return f/3.0;
}
static long double ldblit(float f)
{
return (long double) (((long double) f)/ (long double) 3.0);
}
typedef struct
{
unsigned char uc;
double d;
unsigned int ui;
} test_structure_1;
typedef struct
{
double d1;
double d2;
} test_structure_2;
typedef struct
{
int si;
} test_structure_3;
typedef struct
{
unsigned ui1;
unsigned ui2;
unsigned ui3;
} test_structure_4;
typedef struct
{
char c1;
char c2;
} test_structure_5;
static test_structure_1 struct1(test_structure_1 ts)
{
/*@-type@*/
ts.uc++;
/*@=type@*/
ts.d--;
ts.ui++;
return ts;
}
static test_structure_2 struct2(test_structure_2 ts)
{
ts.d1--;
ts.d2--;
return ts;
}
static test_structure_3 struct3(test_structure_3 ts)
{
ts.si = -(ts.si*2);
return ts;
}
static test_structure_4 struct4(test_structure_4 ts)
{
ts.ui3 = ts.ui1 * ts.ui2 * ts.ui3;
return ts;
}
static test_structure_5 struct5(test_structure_5 ts1, test_structure_5 ts2)
{
ts1.c1 += ts2.c1;
ts1.c2 -= ts2.c2;
return ts1;
}
/* Take an int and a float argument, together with int userdata, and */
/* return the sum. */
static void closure_test_fn(ffi_cif* cif,void* resp,void** args, void* userdata)
{
*(int*)resp =
*(int *)args[0] + (int)(*(float *)args[1]) + (int)(long)userdata;
}
typedef int (*closure_test_type)(int, float);
int main(/*@unused@*/ int argc, /*@unused@*/ char *argv[])
{
ffi_cif cif;
ffi_type *args[MAX_ARGS];
void *values[MAX_ARGS];
char *s;
signed char sc;
unsigned char uc;
signed short ss;
unsigned short us;
unsigned long ul;
long long ll;
float f;
double d;
long double ld;
signed int si1;
signed int si2;
#if defined(__alpha__) || defined(IA64) || defined(SPARC64) || (defined(__mips__) && (_MIPS_SIM == _ABIN32))
long long rint;
#else
int rint;
#endif
long long rlonglong;
ffi_type ts1_type;
ffi_type ts2_type;
ffi_type ts3_type;
ffi_type ts4_type;
ffi_type ts5_type;
ffi_type *ts1_type_elements[4];
ffi_type *ts2_type_elements[3];
ffi_type *ts3_type_elements[2];
ffi_type *ts4_type_elements[4];
ffi_type *ts5_type_elements[3];
ts1_type.size = 0;
ts1_type.alignment = 0;
ts1_type.type = FFI_TYPE_STRUCT;
ts2_type.size = 0;
ts2_type.alignment = 0;
ts2_type.type = FFI_TYPE_STRUCT;
ts3_type.size = 0;
ts3_type.alignment = 0;
ts3_type.type = FFI_TYPE_STRUCT;
ts4_type.size = 0;
ts4_type.alignment = 0;
ts4_type.type = FFI_TYPE_STRUCT;
ts5_type.size = 0;
ts5_type.alignment = 0;
ts5_type.type = FFI_TYPE_STRUCT;
/*@-immediatetrans@*/
ts1_type.elements = ts1_type_elements;
ts2_type.elements = ts2_type_elements;
ts3_type.elements = ts3_type_elements;
ts4_type.elements = ts4_type_elements;
ts5_type.elements = ts5_type_elements;
/*@=immediatetrans@*/
ts1_type_elements[0] = &ffi_type_uchar;
ts1_type_elements[1] = &ffi_type_double;
ts1_type_elements[2] = &ffi_type_uint;
ts1_type_elements[3] = NULL;
ts2_type_elements[0] = &ffi_type_double;
ts2_type_elements[1] = &ffi_type_double;
ts2_type_elements[2] = NULL;
ts3_type_elements[0] = &ffi_type_sint;
ts3_type_elements[1] = NULL;
ts4_type_elements[0] = &ffi_type_uint;
ts4_type_elements[1] = &ffi_type_uint;
ts4_type_elements[2] = &ffi_type_uint;
ts4_type_elements[3] = NULL;
ts5_type_elements[0] = &ffi_type_schar;
ts5_type_elements[1] = &ffi_type_schar;
ts5_type_elements[2] = NULL;
ul = 0;
/* return value tests */
{
#if defined(__mips__) /* || defined(ARM) */
puts ("long long tests not run. This is a known bug on this architecture.");
#else
args[0] = &ffi_type_sint64;
values[0] = &ll;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_sint64, args) == FFI_OK);
for (ll = 0LL; ll < 100LL; ll++)
{
ul++;
ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
CHECK(rlonglong == ll);
}
for (ll = 55555555555000LL; ll < 55555555555100LL; ll++)
{
ul++;
ffi_call(&cif, FFI_FN(return_ll), &rlonglong, values);
CHECK(rlonglong == ll);
}
#endif
args[0] = &ffi_type_schar;
values[0] = &sc;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_schar, args) == FFI_OK);
for (sc = (signed char) -127;
sc < (signed char) 127; /*@-type@*/ sc++ /*@=type@*/)
{
ul++;
ffi_call(&cif, FFI_FN(return_sc), &rint, values);
CHECK(rint == (int) sc);
}
args[0] = &ffi_type_uchar;
values[0] = &uc;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_uchar, args) == FFI_OK);
for (uc = (unsigned char) '\x00';
uc < (unsigned char) '\xff'; /*@-type@*/ uc++ /*@=type@*/)
{
ul++;
ffi_call(&cif, FFI_FN(return_uc), &rint, values);
CHECK(rint == (signed int) uc);
}
printf("%lu return value tests run\n", ul);
}
#ifdef BROKEN_LONG_DOUBLE
printf ("This architecture has broken `long double' support. No floating point\ntests have been run.\n");
#else
/* float arg tests */
{
args[0] = &ffi_type_float;
values[0] = &f;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_longdouble, args) == FFI_OK);
f = 3.14159;
#if 0
/* This is ifdef'd out for now. long double support under SunOS/gcc
is pretty much non-existent. You'll get the odd bus error in library
routines like printf(). */
printf ("%Lf\n", ldblit(f));
#endif
ld = 666;
ffi_call(&cif, FFI_FN(ldblit), &ld, values);
#if 0
/* This is ifdef'd out for now. long double support under SunOS/gcc
is pretty much non-existent. You'll get the odd bus error in library
routines like printf(). */
printf ("%Lf, %Lf, %Lf, %Lf\n", ld, ldblit(f), ld - ldblit(f), LDBL_EPSILON);
#endif
/* These are not always the same!! Check for a reasonable delta */
/*@-realcompare@*/
if (ld - ldblit(f) < LDBL_EPSILON)
/*@=realcompare@*/
puts("long double return value tests ok!");
else
CHECK(0);
}
/* float arg tests */
{
args[0] = &ffi_type_sint;
values[0] = &si1;
args[1] = &ffi_type_float;
values[1] = &f;
args[2] = &ffi_type_double;
values[2] = &d;
args[3] = &ffi_type_longdouble;
values[3] = &ld;
args[4] = &ffi_type_sint;
values[4] = &si2;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 5,
&ffi_type_sint, args) == FFI_OK);
si1 = 6;
f = 3.14159;
d = (double)1.0/(double)3.0;
ld = 2.71828182846L;
si2 = 10;
floating (si1, f, d, ld, si2);
ffi_call(&cif, FFI_FN(floating), &rint, values);
printf ("%d vs %d\n", rint, floating (si1, f, d, ld, si2));
CHECK(rint == floating(si1, f, d, ld, si2));
printf("float arg tests ok!\n");
}
#endif
/* strlen tests */
{
args[0] = &ffi_type_pointer;
values[0] = (void*) &s;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_sint, args) == FFI_OK);
s = "a";
ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
CHECK(rint == 1);
s = "1234567";
ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
CHECK(rint == 7);
s = "1234567890123456789012345";
ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
CHECK(rint == 25);
printf("strlen tests passed\n");
}
/* float arg tests */
{
args[0] = &ffi_type_float;
values[0] = &f;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_double, args) == FFI_OK);
f = 3.14159;
ffi_call(&cif, FFI_FN(dblit), &d, values);
/* These are not always the same!! Check for a reasonable delta */
/*@-realcompare@*/
CHECK(d - dblit(f) < DBL_EPSILON);
/*@=realcompare@*/
printf("double return value tests ok!\n");
}
/* many arg tests */
{
float ff;
float fa[13];
for (ul = 0; ul < 13; ul++)
{
args[ul] = &ffi_type_float;
values[ul] = &fa[ul];
fa[ul] = (float) ul;
}
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13,
&ffi_type_float, args) == FFI_OK);
/*@-usedef@*/
ff = many(fa[0], fa[1],
fa[2], fa[3],
fa[4], fa[5],
fa[6], fa[7],
fa[8], fa[9],
fa[10],fa[11],fa[12]);
/*@=usedef@*/
ffi_call(&cif, FFI_FN(many), &f, values);
/*@-realcompare@*/
if (f - ff < FLT_EPSILON)
/*@=realcompare@*/
printf("many arg tests ok!\n");
else
#ifdef POWERPC
printf("many arg tests failed! This is a gcc bug.\n");
#else
CHECK(0);
#endif
}
/* promotion tests */
{
args[0] = &ffi_type_schar;
args[1] = &ffi_type_sshort;
args[2] = &ffi_type_uchar;
args[3] = &ffi_type_ushort;
values[0] = &sc;
values[1] = &ss;
values[2] = &uc;
values[3] = &us;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 4,
&ffi_type_sint, args) == FFI_OK);
us = 0;
ul = 0;
for (sc = (signed char) -127;
sc <= (signed char) 120; /*@-type@*/ sc += 1 /*@=type@*/)
for (ss = -30000; ss <= 30000; ss += 10000)
for (uc = (unsigned char) 0;
uc <= (unsigned char) 200; /*@-type@*/ uc += 20 /*@=type@*/)
for (us = 0; us <= 60000; us += 10000)
{
ul++;
ffi_call(&cif, FFI_FN(promotion), &rint, values);
CHECK(rint == (int) sc + (int) ss + (int) uc + (int) us);
}
printf("%lu promotion tests run\n", ul);
}
#ifndef X86_WIN32 /* Structures dont work on Win32 */
/* struct tests */
{
test_structure_1 ts1_arg;
/* This is a hack to get a properly aligned result buffer */
test_structure_1 *ts1_result =
(test_structure_1 *) malloc (sizeof(test_structure_1));
args[0] = &ts1_type;
values[0] = &ts1_arg;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ts1_type, args) == FFI_OK);
ts1_arg.uc = '\x01';
ts1_arg.d = 3.14159;
ts1_arg.ui = 555;
ffi_call(&cif, FFI_FN(struct1), ts1_result, values);
CHECK(ts1_result->ui == 556);
CHECK(ts1_result->d == 3.14159 - 1);
puts ("structure test 1 ok!\n");
free (ts1_result);
}
/* struct tests */
{
test_structure_2 ts2_arg;
/* This is a hack to get a properly aligned result buffer */
test_structure_2 *ts2_result =
(test_structure_2 *) malloc (sizeof(test_structure_2));
args[0] = &ts2_type;
values[0] = &ts2_arg;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ts2_type, args) == FFI_OK);
ts2_arg.d1 = 5.55;
ts2_arg.d2 = 6.66;
printf ("%g\n", ts2_result->d1);
printf ("%g\n", ts2_result->d2);
ffi_call(&cif, FFI_FN(struct2), ts2_result, values);
printf ("%g\n", ts2_result->d1);
printf ("%g\n", ts2_result->d2);
CHECK(ts2_result->d1 == 5.55 - 1);
CHECK(ts2_result->d2 == 6.66 - 1);
printf("structure test 2 ok!\n");
free (ts2_result);
}
/* struct tests */
{
int compare_value;
test_structure_3 ts3_arg;
test_structure_3 *ts3_result =
(test_structure_3 *) malloc (sizeof(test_structure_3));
args[0] = &ts3_type;
values[0] = &ts3_arg;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ts3_type, args) == FFI_OK);
ts3_arg.si = -123;
compare_value = ts3_arg.si;
ffi_call(&cif, FFI_FN(struct3), ts3_result, values);
printf ("%d %d\n", ts3_result->si, -(compare_value*2));
if (ts3_result->si == -(ts3_arg.si*2))
puts ("structure test 3 ok!");
else
{
puts ("Structure test 3 found structure passing bug.");
puts (" Current versions of GCC are not 100% compliant with the");
puts (" n32 ABI. There is a known problem related to passing");
puts (" small structures. Send a bug report to the gcc maintainers.");
}
free (ts3_result);
}
/* struct tests */
{
test_structure_4 ts4_arg;
/* This is a hack to get a properly aligned result buffer */
test_structure_4 *ts4_result =
(test_structure_4 *) malloc (sizeof(test_structure_4));
args[0] = &ts4_type;
values[0] = &ts4_arg;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ts4_type, args) == FFI_OK);
ts4_arg.ui1 = 2;
ts4_arg.ui2 = 3;
ts4_arg.ui3 = 4;
ffi_call (&cif, FFI_FN(struct4), ts4_result, values);
if (ts4_result->ui3 == 2U * 3U * 4U)
puts ("structure test 4 ok!");
else
puts ("Structure test 4 found GCC's structure passing bug.");
free (ts4_result);
}
/* struct tests */
{
test_structure_5 ts5_arg1, ts5_arg2;
/* This is a hack to get a properly aligned result buffer */
test_structure_5 *ts5_result =
(test_structure_5 *) malloc (sizeof(test_structure_5));
args[0] = &ts5_type;
args[1] = &ts5_type;
values[0] = &ts5_arg1;
values[1] = &ts5_arg2;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
&ts5_type, args) == FFI_OK);
ts5_arg1.c1 = 2;
ts5_arg1.c2 = 6;
ts5_arg2.c1 = 5;
ts5_arg2.c2 = 3;
ffi_call (&cif, FFI_FN(struct5), ts5_result, values);
if (ts5_result->c1 == 7
&& ts5_result->c2 == 3)
puts ("structure test 5 ok!");
else
puts ("Structure test 5 found GCC's structure passing bug.");
free (ts5_result);
}
#else
printf("Structure passing doesn't work on Win32.\n");
#endif /* X86_WIN32 */
# if FFI_CLOSURES
/* A simple closure test */
{
ffi_closure cl;
ffi_type * cl_arg_types[3];
cl_arg_types[0] = &ffi_type_sint;
cl_arg_types[1] = &ffi_type_float;
cl_arg_types[2] = NULL;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 2,
&ffi_type_sint, cl_arg_types) == FFI_OK);
CHECK(ffi_prep_closure(&cl, &cif, closure_test_fn,
(void *) 3 /* userdata */)
== FFI_OK);
CHECK((*((closure_test_type)(&cl)))(1, 2.0) == 6);
}
# endif
/* If we arrived here, all is good */
(void) puts("\nLooks good. No surprises.\n");
/*@-compdestroy@*/
return 0;
}
+670
View File
@@ -0,0 +1,670 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Cygnus Solutions
Copyright (c) 2000 Hewlett Packard Company
IA64 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
#include "ia64_flags.h"
/* Memory image of fp register contents. Should eventually be an fp */
/* type long enough to hold an entire register. For now we use double. */
typedef double float80;
/* The stack layout at call to ffi_prep_regs. Other_args will remain */
/* on the stack for the actual call. Everything else we be transferred */
/* to registers and popped by the assembly code. */
struct ia64_args {
long scratch[2]; /* Two scratch words at top of stack. */
/* Allows sp to passed as arg pointer. */
void * r8_contents; /* Value to be passed in r8 */
long spare; /* Not used. */
float80 fp_regs[8]; /* Contents of 8 floating point argument */
/* registers. */
long out_regs[8]; /* Contents of the 8 out registers used */
/* for integer parameters. */
long other_args[0]; /* Arguments passed on stack, variable size */
/* Treated as continuation of out_regs. */
};
static size_t float_type_size(unsigned short tp)
{
switch(tp) {
case FFI_TYPE_FLOAT:
return sizeof(float);
case FFI_TYPE_DOUBLE:
return sizeof(double);
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
return sizeof(long double);
#endif
default:
FFI_ASSERT(0);
}
}
/*
* Is type a struct containing at most n floats, doubles, or extended
* doubles, all of the same fp type?
* If so, set *element_type to the fp type.
*/
static bool is_homogeneous_fp_aggregate(ffi_type * type, int n,
unsigned short * element_type)
{
ffi_type **ptr;
unsigned short element, struct_element;
int type_set = 0;
FFI_ASSERT(type != NULL);
FFI_ASSERT(type->elements != NULL);
ptr = &(type->elements[0]);
while ((*ptr) != NULL)
{
switch((*ptr) -> type) {
case FFI_TYPE_FLOAT:
if (type_set && element != FFI_TYPE_FLOAT) return 0;
if (--n < 0) return FALSE;
type_set = 1;
element = FFI_TYPE_FLOAT;
break;
case FFI_TYPE_DOUBLE:
if (type_set && element != FFI_TYPE_DOUBLE) return 0;
if (--n < 0) return FALSE;
type_set = 1;
element = FFI_TYPE_DOUBLE;
break;
case FFI_TYPE_STRUCT:
if (!is_homogeneous_fp_aggregate(type, n, &struct_element))
return FALSE;
if (type_set && struct_element != element) return FALSE;
n -= (type -> size)/float_type_size(element);
element = struct_element;
if (n < 0) return FALSE;
break;
/* case FFI_TYPE_LONGDOUBLE:
Not yet implemented. */
default:
return FALSE;
}
ptr++;
}
*element_type = element;
return TRUE;
}
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments. Returns nonzero
if fp registers are used for arguments. */
static bool
ffi_prep_args(struct ia64_args *stack, extended_cif *ecif, int bytes)
{
register long i, avn;
register void **p_argv;
register long *argp = stack -> out_regs;
register float80 *fp_argp = stack -> fp_regs;
register ffi_type **p_arg;
/* For big return structs, r8 needs to contain the target address. */
/* Since r8 is otherwise dead, we set it unconditionally. */
stack -> r8_contents = ecif -> rvalue;
i = 0;
avn = ecif->cif->nargs;
p_arg = ecif->cif->arg_types;
p_argv = ecif->avalue;
while (i < avn)
{
size_t z; /* z is in units of arg slots or words, not bytes. */
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
z = 1;
*(SINT64 *) argp = *(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
z = 1;
*(UINT64 *) argp = *(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
z = 1;
*(SINT64 *) argp = *(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
z = 1;
*(UINT64 *) argp = *(UINT16 *)(* p_argv);
break;
case FFI_TYPE_SINT32:
z = 1;
*(SINT64 *) argp = *(SINT32 *)(* p_argv);
break;
case FFI_TYPE_UINT32:
z = 1;
*(UINT64 *) argp = *(UINT32 *)(* p_argv);
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
case FFI_TYPE_POINTER:
z = 1;
*(UINT64 *) argp = *(UINT64 *)(* p_argv);
break;
case FFI_TYPE_FLOAT:
z = 1;
if (fp_argp - stack->fp_regs < 8)
{
/* Note the conversion -- all the fp regs are loaded as
doubles. */
*fp_argp++ = *(float *)(* p_argv);
}
/* Also put it into the integer registers or memory: */
*(UINT64 *) argp = *(UINT32 *)(* p_argv);
break;
case FFI_TYPE_DOUBLE:
z = 1;
if (fp_argp - stack->fp_regs < 8)
*fp_argp++ = *(double *)(* p_argv);
/* Also put it into the integer registers or memory: */
*(double *) argp = *(double *)(* p_argv);
break;
case FFI_TYPE_STRUCT:
{
size_t sz = (*p_arg)->size;
unsigned short element_type;
z = ((*p_arg)->size + SIZEOF_ARG - 1)/SIZEOF_ARG;
if (is_homogeneous_fp_aggregate(*p_arg, 8, &element_type)) {
int i;
int nelements = sz/float_type_size(element_type);
for (i = 0; i < nelements; ++i) {
switch (element_type) {
case FFI_TYPE_FLOAT:
if (fp_argp - stack->fp_regs < 8)
*fp_argp++ = ((float *)(* p_argv))[i];
break;
case FFI_TYPE_DOUBLE:
if (fp_argp - stack->fp_regs < 8)
*fp_argp++ = ((double *)(* p_argv))[i];
break;
default:
/* Extended precision not yet implemented. */
abort();
}
}
}
/* And pass it in integer registers as a struct, with */
/* its actual field sizes packed into registers. */
memcpy(argp, *p_argv, (*p_arg)->size);
}
break;
default:
FFI_ASSERT(0);
}
argp += z;
i++, p_arg++, p_argv++;
}
return (fp_argp != stack -> fp_regs);
}
/* Perform machine dependent cif processing */
ffi_status
ffi_prep_cif_machdep(ffi_cif *cif)
{
long i, avn;
bool is_simple = TRUE;
long simple_flag = FFI_SIMPLE_V;
/* Adjust cif->bytes to include space for the 2 scratch words,
r8 register contents, spare word,
the 8 fp register contents, and all 8 integer register contents.
This will be removed before the call, though 2 scratch words must
remain. */
cif->bytes += 4*sizeof(long) + 8 *sizeof(float80);
if (cif->bytes < sizeof(struct ia64_args))
cif->bytes = sizeof(struct ia64_args);
/* The stack must be double word aligned, so round bytes up
appropriately. */
cif->bytes = ALIGN(cif->bytes, 2*sizeof(void*));
avn = cif->nargs;
if (avn <= 2) {
for (i = 0; i < avn; ++i) {
switch(cif -> arg_types[i] -> type) {
case FFI_TYPE_SINT32:
simple_flag = FFI_ADD_INT_ARG(simple_flag);
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
case FFI_TYPE_POINTER:
simple_flag = FFI_ADD_LONG_ARG(simple_flag);
break;
default:
is_simple = FALSE;
}
}
} else {
is_simple = FALSE;
}
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
cif->flags = FFI_TYPE_VOID;
break;
case FFI_TYPE_STRUCT:
{
size_t sz = cif -> rtype -> size;
unsigned short element_type;
is_simple = FALSE;
if (is_homogeneous_fp_aggregate(cif -> rtype, 8, &element_type)) {
int nelements = sz/float_type_size(element_type);
if (nelements <= 1) {
if (0 == nelements) {
cif -> flags = FFI_TYPE_VOID;
} else {
cif -> flags = element_type;
}
} else {
switch(element_type) {
case FFI_TYPE_FLOAT:
cif -> flags = FFI_IS_FLOAT_FP_AGGREGATE | nelements;
break;
case FFI_TYPE_DOUBLE:
cif -> flags = FFI_IS_DOUBLE_FP_AGGREGATE | nelements;
break;
default:
/* long double NYI */
abort();
}
}
break;
}
if (sz <= 32) {
if (sz <= 8) {
cif->flags = FFI_TYPE_INT;
} else if (sz <= 16) {
cif->flags = FFI_IS_SMALL_STRUCT2;
} else if (sz <= 24) {
cif->flags = FFI_IS_SMALL_STRUCT3;
} else {
cif->flags = FFI_IS_SMALL_STRUCT4;
}
} else {
cif->flags = FFI_TYPE_STRUCT;
}
}
break;
case FFI_TYPE_FLOAT:
is_simple = FALSE;
cif->flags = FFI_TYPE_FLOAT;
break;
case FFI_TYPE_DOUBLE:
is_simple = FALSE;
cif->flags = FFI_TYPE_DOUBLE;
break;
default:
cif->flags = FFI_TYPE_INT;
/* This seems to depend on little endian mode, and the fact that */
/* the return pointer always points to at least 8 bytes. But */
/* that also seems to be true for other platforms. */
break;
}
if (is_simple) cif -> flags |= simple_flag;
return FFI_OK;
}
extern int ffi_call_unix(bool (*)(struct ia64_args *, extended_cif *, int),
extended_cif *, unsigned,
unsigned, unsigned *, void (*)());
void
ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
{
extended_cif ecif;
long simple = cif -> flags & FFI_SIMPLE;
/* Should this also check for Unix ABI? */
/* This is almost, but not quite, machine independent. Note that */
/* we can get away with not caring about length of the result because */
/* we assume we are little endian, and the result buffer is large */
/* enough. */
/* This needs work for HP/UX. */
if (simple) {
long (*lfn)() = (long (*)())fn;
long result;
switch(simple) {
case FFI_SIMPLE_V:
result = lfn();
break;
case FFI_SIMPLE_I:
result = lfn(*(int *)avalue[0]);
break;
case FFI_SIMPLE_L:
result = lfn(*(long *)avalue[0]);
break;
case FFI_SIMPLE_II:
result = lfn(*(int *)avalue[0], *(int *)avalue[1]);
break;
case FFI_SIMPLE_IL:
result = lfn(*(int *)avalue[0], *(long *)avalue[1]);
break;
case FFI_SIMPLE_LI:
result = lfn(*(long *)avalue[0], *(int *)avalue[1]);
break;
case FFI_SIMPLE_LL:
result = lfn(*(long *)avalue[0], *(long *)avalue[1]);
break;
}
if ((cif->flags & ~FFI_SIMPLE) != FFI_TYPE_VOID && 0 != rvalue) {
* (long *)rvalue = result;
}
return;
}
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return
value address then we need to make one. */
if (rvalue == NULL && cif->rtype->type == FFI_TYPE_STRUCT)
ecif.rvalue = alloca(cif->rtype->size);
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_UNIX:
ffi_call_unix(ffi_prep_args, &ecif, cif->bytes,
cif->flags, rvalue, fn);
break;
default:
FFI_ASSERT(0);
break;
}
}
/*
* Closures represent a pair consisting of a function pointer, and
* some user data. A closure is invoked by reinterpreting the closure
* as a function pointer, and branching to it. Thus we can make an
* interpreted function callable as a C function: We turn the interpreter
* itself, together with a pointer specifying the interpreted procedure,
* into a closure.
* On X86, the first few words of the closure structure actually contain code,
* which will do the right thing. On most other architectures, this
* would raise some Icache/Dcache coherence issues (which can be solved, but
* often not cheaply).
* For IA64, function pointer are already pairs consisting of a code
* pointer, and a gp pointer. The latter is needed to access global variables.
* Here we set up such a pair as the first two words of the closure (in
* the "trampoline" area), but we replace the gp pointer with a pointer
* to the closure itself. We also add the real gp pointer to the
* closure. This allows the function entry code to both retrieve the
* user data, and to restire the correct gp pointer.
*/
static void
ffi_prep_incoming_args_UNIX(struct ia64_args *args, void **rvalue,
void **avalue, ffi_cif *cif);
/* This function is entered with the doctored gp (r1) value.
* This code is extremely gcc specific. There is some argument that
* it should really be written in assembly code, since it depends on
* gcc properties that might change over time.
*/
/* ffi_closure_UNIX is an assembly routine, which copies the register */
/* state into s struct ia64_args, and the invokes */
/* ffi_closure_UNIX_inner. It also recovers the closure pointer */
/* from its fake gp pointer. */
void ffi_closure_UNIX();
#ifndef __GNUC__
# error This requires gcc
#endif
void
ffi_closure_UNIX_inner (ffi_closure *closure, struct ia64_args * args)
/* Hopefully declarint this as a varargs function will force all args */
/* to memory. */
{
// this is our return value storage
long double res;
// our various things...
ffi_cif *cif;
unsigned short rtype;
void *resp;
void **arg_area;
resp = (void*)&res;
cif = closure->cif;
arg_area = (void**) alloca (cif->nargs * sizeof (void*));
/* this call will initialize ARG_AREA, such that each
* element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will re-set RESP to point to the
* structure return address. */
ffi_prep_incoming_args_UNIX(args, (void**)&resp, arg_area, cif);
(closure->fun) (cif, resp, arg_area, closure->user_data);
rtype = cif->flags;
/* now, do a generic return based on the value of rtype */
if (rtype == FFI_TYPE_INT)
{
asm volatile ("ld8 r8=[%0]" : : "r" (resp) : "r8");
}
else if (rtype == FFI_TYPE_FLOAT)
{
asm volatile ("ldfs f8=[%0]" : : "r" (resp) : "f8");
}
else if (rtype == FFI_TYPE_DOUBLE)
{
asm volatile ("ldfd f8=[%0]" : : "r" (resp) : "f8");
}
else if (rtype == FFI_IS_SMALL_STRUCT2)
{
asm volatile ("ld8 r8=[%0]; ld8 r9=[%1]"
: : "r" (resp), "r" (resp+8) : "r8","r9");
}
else if (rtype == FFI_IS_SMALL_STRUCT3)
{
asm volatile ("ld8 r8=[%0]; ld8 r9=[%1]; ld8 r10=[%2]"
: : "r" (resp), "r" (resp+8), "r" (resp+16)
: "r8","r9","r10");
}
else if (rtype == FFI_IS_SMALL_STRUCT4)
{
asm volatile ("ld8 r8=[%0]; ld8 r9=[%1]; ld8 r10=[%2]; ld8 r11=[%3]"
: : "r" (resp), "r" (resp+8), "r" (resp+16), "r" (resp+24)
: "r8","r9","r10","r11");
}
else if (rtype != FFI_TYPE_VOID && rtype != FFI_TYPE_STRUCT)
{
/* Can only happen for homogeneous FP aggregates? */
abort();
}
}
static void
ffi_prep_incoming_args_UNIX(struct ia64_args *args, void **rvalue,
void **avalue, ffi_cif *cif)
{
register unsigned int i;
register unsigned int avn;
register void **p_argv;
register unsigned long *argp = args -> out_regs;
unsigned fp_reg_num = 0;
register ffi_type **p_arg;
avn = cif->nargs;
p_argv = avalue;
for (i = cif->nargs, p_arg = cif->arg_types; i != 0; i--, p_arg++)
{
size_t z; /* In units of words or argument slots. */
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
case FFI_TYPE_POINTER:
z = 1;
*p_argv = (void *)argp;
break;
case FFI_TYPE_FLOAT:
z = 1;
/* Convert argument back to float in place from the saved value */
if (fp_reg_num < 8) {
*(float *)argp = args -> fp_regs[fp_reg_num++];
} else {
*(float *)argp = *(double *)argp;
}
*p_argv = (void *)argp;
break;
case FFI_TYPE_DOUBLE:
z = 1;
if (fp_reg_num < 8) {
*p_argv = args -> fp_regs + fp_reg_num++;
} else {
*p_argv = (void *)argp;
}
break;
case FFI_TYPE_STRUCT:
{
size_t sz = (*p_arg)->size;
unsigned short element_type;
z = ((*p_arg)->size + SIZEOF_ARG - 1)/SIZEOF_ARG;
if (is_homogeneous_fp_aggregate(*p_arg, 8, &element_type)) {
int nelements = sz/float_type_size(element_type);
if (nelements + fp_reg_num >= 8) {
/* hard case NYI. */
abort();
}
if (element_type == FFI_TYPE_DOUBLE) {
*p_argv = args -> fp_regs + fp_reg_num;
fp_reg_num += nelements;
break;
}
if (element_type == FFI_TYPE_FLOAT) {
int j;
for (j = 0; j < nelements; ++ j) {
((float *)argp)[j] = args -> fp_regs[fp_reg_num + j];
}
*p_argv = (void *)argp;
fp_reg_num += nelements;
break;
}
abort(); /* Other fp types NYI */
}
}
break;
default:
FFI_ASSERT(0);
}
argp += z;
p_argv++;
}
return;
}
/* Fill in a closure to refer to the specified fun and user_data. */
/* cif specifies the argument and result types for fun. */
/* the cif must already be prep'ed */
/* The layout of a function descriptor. A C function pointer really */
/* points to one of these. */
typedef struct ia64_fd_struct {
void *code_pointer;
void *gp;
} ia64_fd;
ffi_status
ffi_prep_closure (ffi_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data)
{
struct ffi_ia64_trampoline_struct *tramp =
(struct ffi_ia64_trampoline_struct *) (closure -> tramp);
ia64_fd *fd = (ia64_fd *)(void *)ffi_closure_UNIX;
FFI_ASSERT (cif->abi == FFI_UNIX);
tramp -> code_pointer = fd -> code_pointer;
tramp -> real_gp = fd -> gp;
tramp -> fake_gp = closure;
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
return FFI_OK;
}
+62
View File
@@ -0,0 +1,62 @@
/* -----------------------------------------------------------------------
ia64_flags.h - Copyright (c) 2000 Hewlett Packard Company
IA64/unix Foreign Function Interface
Original author: Hans Boehm, HP Labs
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
/* Homogeneous Floating Point Aggregates (HFAs) which are returned */
/* in FP registers. The least significant bits specify the size in */
/* words. */
#define FFI_IS_FLOAT_FP_AGGREGATE 0x1000
#define FFI_IS_DOUBLE_FP_AGGREGATE 0x0800
#define FLOAT_FP_AGGREGATE_BIT 12
#define DOUBLE_FP_AGGREGATE_BIT 11
/* Small structures containing N words. If N=1, they are returned */
/* as though they were integers. */
#define FFI_IS_SMALL_STRUCT2 0x40 /* Struct > 8, <=16 bytes */
#define FFI_IS_SMALL_STRUCT3 0x41 /* Struct > 16 <= 24 bytes */
#define FFI_IS_SMALL_STRUCT4 0x42 /* Struct > 24, <=32 bytes */
/* Flag values identifying particularly simple cases, which are */
/* handled specially. We treat functions as simple if they take all */
/* arguments can be passed as 32 or 64 bit integer quantities, there is */
/* either no return value or it can be treated as a 64bit integer, and */
/* if there are at most 2 arguments. */
/* This is OR'ed with the normal flag values. */
#define FFI_SIMPLE_V 0x10000 /* () -> X */
#define FFI_SIMPLE_I 0x20000 /* (int) -> X */
#define FFI_SIMPLE_L 0x30000 /* (long) -> X */
#define FFI_SIMPLE_II 0x40000 /* (int,int) -> X */
#define FFI_SIMPLE_IL 0x50000 /* (int,long) -> X */
#define FFI_SIMPLE_LI 0x60000 /* (long,int) -> X */
#define FFI_SIMPLE_LL 0x70000 /* (long,long) -> X */
/* Mask for all of the FFI_SIMPLE bits: */
#define FFI_SIMPLE 0xf0000
/* An easy way to build FFI_SIMPLE flags from FFI_SIMPLE_V: */
#define FFI_ADD_LONG_ARG(flag) (((flag) << 1) | 0x10000)
#define FFI_ADD_INT_ARG(flag) ((flag) << 1)
+301
View File
@@ -0,0 +1,301 @@
/* -----------------------------------------------------------------------
unix.S - Copyright (c) 1998 Cygnus Solutions
Copyright (c) 2000 Hewlett Packard Company
IA64/unix Foreign Function Interface
Primary author: Hans Boehm, HP Labs
Loosely modeled on Cygnus code for other platforms.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#include "ia64_flags.h"
/* parameters: */
#define callback in0
#define ecifp in1
#define bytes in2
#define flags in3
#define raddr in4
#define fn in5
#define FLOAT_SZ 8 /* in-memory size of fp operands */
.text
.align 16
.global ffi_call_unix#
.proc ffi_call_unix#
ffi_call_unix:
alloc loc0=ar.pfs,6,5,8,0
mov loc1=b0;
sub sp=sp,bytes
mov loc4=r1 /* Save gp */
ld8 r8=[callback],8 /* code address of callback */
;;
mov out0=sp
mov out1=ecifp
mov out2=bytes
ld8 r1=[callback] /* Set up gp for callback. Unnecessary? */
mov b6=r8
;;
br.call.sptk.many b0 = b6 /* call ffi_prep_args */
cmp.eq p6,p0=0,r8 /* r8 nonzero ==> need fp regs */
;;
(p6) add loc2=32+8*FLOAT_SZ,sp
(p6) br.cond.dptk.many fp_done
;; /* Quiets warning; needed? */
add loc2=32,sp
add loc3=32+FLOAT_SZ,sp
;;
ldfd f8=[loc2],2*FLOAT_SZ
ldfd f9=[loc3],2*FLOAT_SZ
;;
ldfd f10=[loc2],2*FLOAT_SZ
ldfd f11=[loc3],2*FLOAT_SZ
;;
ldfd f12=[loc2],2*FLOAT_SZ
ldfd f13=[loc3],2*FLOAT_SZ
;;
ldfd f14=[loc2],2*FLOAT_SZ
ldfd f15=[loc3]
fp_done:
add r9=16,sp /* Pointer to r8_contents */
/* loc2 points at first integer register value. */
add loc3=8,loc2
;;
ld8 r8=[r9] /* Just in case we return large struct */
ld8 out0=[loc2],16
ld8 out1=[loc3],16
;;
ld8 out2=[loc2],16
ld8 out3=[loc3],16
;;
ld8 out4=[loc2],16
ld8 out5=[loc3],16
;;
ld8 out6=[loc2],16
ld8 out7=[loc3]
/* loc2 points at first stack parameter. Set sp to 16 bytes */
/* below that. */
add sp=-16,loc2
ld8 r8=[fn],8
;;
ld8 r1=[fn] /* Set up gp */
mov b6=r8;;
br.call.sptk.many b0 = b6 /* call ffi_prep_args */
/* Handle return value. */
cmp.eq p6,p0=0,raddr
cmp.eq p7,p0=FFI_TYPE_INT,flags
cmp.eq p10,p0=FFI_IS_SMALL_STRUCT2,flags
cmp.eq p11,p0=FFI_IS_SMALL_STRUCT3,flags
cmp.eq p12,p0=FFI_IS_SMALL_STRUCT4,flags
;;
(p6) br.cond.dpnt.few done /* Dont copy ret values if raddr = 0 */
(p7) br.cond.dptk.few copy1
(p10) br.cond.dpnt.few copy2
(p11) br.cond.dpnt.few copy3
(p12) br.cond.dpnt.few copy4
cmp.eq p8,p0=FFI_TYPE_FLOAT,flags
cmp.eq p9,p0=FFI_TYPE_DOUBLE,flags
tbit.nz p6,p0=flags,FLOAT_FP_AGGREGATE_BIT
tbit.nz p7,p0=flags,DOUBLE_FP_AGGREGATE_BIT
;;
(p8) stfs [raddr]=f8
(p9) stfd [raddr]=f8
;;
(p6) br.cond.dpnt.few handle_float_hfa
(p7) br.cond.dpnt.few handle_double_hfa
br done
copy4:
add loc3=24,raddr
;;
st8 [loc3]=r11
copy3:
add loc3=16,raddr
;;
st8 [loc3]=r10
copy2:
add loc3=8,raddr
;;
st8 [loc3]=r9
copy1:
st8 [raddr]=r8
/* In the big struct case, raddr was passed as an argument. */
/* In the void case there was nothing to do. */
done:
mov r1=loc4 /* Restore gp */
mov ar.pfs = loc0
mov b0 = loc1
br.ret.sptk.many b0
handle_double_hfa:
/* Homogeneous floating point array of doubles is returned in */
/* registers f8-f15. Save one at a time to return area. */
and flags=0xf,flags /* Retrieve size */
;;
cmp.eq p6,p0=2,flags
cmp.eq p7,p0=3,flags
cmp.eq p8,p0=4,flags
cmp.eq p9,p0=5,flags
cmp.eq p10,p0=6,flags
cmp.eq p11,p0=7,flags
cmp.eq p12,p0=8,flags
;;
(p6) br.cond.dptk.few dhfa2
(p7) br.cond.dptk.few dhfa3
(p8) br.cond.dptk.few dhfa4
(p9) br.cond.dptk.few dhfa5
(p10) br.cond.dptk.few dhfa6
(p11) br.cond.dptk.few dhfa7
dhfa8: add loc3=7*8,raddr
;;
stfd [loc3]=f15
dhfa7: add loc3=6*8,raddr
;;
stfd [loc3]=f14
dhfa6: add loc3=5*8,raddr
;;
stfd [loc3]=f13
dhfa5: add loc3=4*8,raddr
;;
stfd [loc3]=f12
dhfa4: add loc3=3*8,raddr
;;
stfd [loc3]=f11
dhfa3: add loc3=2*8,raddr
;;
stfd [loc3]=f10
dhfa2: add loc3=1*8,raddr
;;
stfd [loc3]=f9
stfd [raddr]=f8
br done
handle_float_hfa:
/* Homogeneous floating point array of floats is returned in */
/* registers f8-f15. Save one at a time to return area. */
and flags=0xf,flags /* Retrieve size */
;;
cmp.eq p6,p0=2,flags
cmp.eq p7,p0=3,flags
cmp.eq p8,p0=4,flags
cmp.eq p9,p0=5,flags
cmp.eq p10,p0=6,flags
cmp.eq p11,p0=7,flags
cmp.eq p12,p0=8,flags
;;
(p6) br.cond.dptk.few shfa2
(p7) br.cond.dptk.few shfa3
(p8) br.cond.dptk.few shfa4
(p9) br.cond.dptk.few shfa5
(p10) br.cond.dptk.few shfa6
(p11) br.cond.dptk.few shfa7
shfa8: add loc3=7*4,raddr
;;
stfd [loc3]=f15
shfa7: add loc3=6*4,raddr
;;
stfd [loc3]=f14
shfa6: add loc3=5*4,raddr
;;
stfd [loc3]=f13
shfa5: add loc3=4*4,raddr
;;
stfd [loc3]=f12
shfa4: add loc3=3*4,raddr
;;
stfd [loc3]=f11
shfa3: add loc3=2*4,raddr
;;
stfd [loc3]=f10
shfa2: add loc3=1*4,raddr
;;
stfd [loc3]=f9
stfd [raddr]=f8
br done
.endp ffi_call_unix
.text
.align 16
.global ffi_closure_UNIX
.proc ffi_closure_UNIX
ffi_closure_UNIX:
alloc loc0=ar.pfs,8,2,2,0
mov loc1=b0
/* Retrieve closure pointer and real gp. */
mov out0=gp
add gp=16,gp
;;
ld8 gp=[gp]
/* Reserve a structia64_args on the stack such that arguments */
/* past the first 8 are automatically placed in the right */
/* slot. Note that when we start the sp points at 2 8-byte */
/* scratch words, followed by the extra arguments. */
# define BASIC_ARGS_SZ (8*FLOAT_SZ+8*8+2*8)
# define FIRST_FP_OFFSET (4*8)
add r14=-(BASIC_ARGS_SZ-FIRST_FP_OFFSET),sp
add r15=-(BASIC_ARGS_SZ-FIRST_FP_OFFSET-FLOAT_SZ),sp
add sp=-BASIC_ARGS_SZ,sp
/* r14 points to fp_regs[0], r15 points to fp_regs[1] */
;;
stfd [r14]=f8,2*FLOAT_SZ
stfd [r15]=f9,2*FLOAT_SZ
;;
stfd [r14]=f10,2*FLOAT_SZ
stfd [r15]=f11,2*FLOAT_SZ
;;
stfd [r14]=f12,2*FLOAT_SZ
stfd [r15]=f13,2*FLOAT_SZ
;;
stfd [r14]=f14,FLOAT_SZ+8
stfd [r15]=f15,2*8
;;
/* r14 points to first parameter register area, r15 to second. */
st8 [r14]=in0,2*8
st8 [r15]=in1,2*8
;;
st8 [r14]=in2,2*8
st8 [r15]=in3,2*8
;;
st8 [r14]=in4,2*8
st8 [r15]=in5,2*8
;;
st8 [r14]=in6,2*8
st8 [r15]=in7,2*8
/* Call ffi_closure_UNIX_inner */
mov out1=sp
br.call.sptk.many b0=ffi_closure_UNIX_inner
;;
mov b0=loc1
mov ar.pfs=loc0
br.ret.sptk.many b0
.endp ffi_closure_UNIX
+3
View File
@@ -0,0 +1,3 @@
fficonfig.h
Makefile
Makefile.in
+6
View File
@@ -0,0 +1,6 @@
## Process this with automake to create Makefile.in
AUTOMAKE_OPTIONS = foreign
noinst_HEADERS=ffi_private.h
include_HEADERS=ffi.h
+393
View File
@@ -0,0 +1,393 @@
/* -----------------------------------------------------------------*-C-*-
libffi 2.0.0 - Copyright (C) 1996, 1997, 1998, 1999, 2000,
2001 Red Hat, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
/* -------------------------------------------------------------------
The basic API is described in the README file.
The raw API is designed to bypass some of the argument packing
and unpacking on architectures for which it can be avoided.
The closure API allows interpreted functions to be packaged up
inside a C function pointer, so that they can be called as C functions,
with no understanding on the client side that they are interpreted.
It can also be used in other cases in which it is necessary to package
up a user specified parameter and a function pointer as a single
function pointer.
The closure API must be implemented in order to get its functionality,
e.g. for use by gij. Routines are provided to emulate the raw API
if the underlying platform doesn't allow faster implementation.
More details on the raw and cloure API can be found in:
http://gcc.gnu.org/ml/java/1999-q3/msg00138.html
and
http://gcc.gnu.org/ml/java/1999-q3/msg00174.html
-------------------------------------------------------------------- */
#ifndef FFI_H
#define FFI_H
#if !defined(__ASSEMBLER__) && !defined(__GNUC__)
#error --- ffi.h requires GNU C ---
#endif
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(LIBFFI_ASM)
#include <stddef.h>
#if defined(FFI_DEBUG)
#include <stdio.h>
#endif
#endif
#ifndef LIBFFI_ASM
/* ---- Generic type definitions ----------------------------------------- */
typedef enum ffi_abi {
/* Leave this for debugging purposes */
FFI_FIRST_ABI = 0,
/* ---- Sparc -------------------- */
#ifdef __sparc__
FFI_V8,
FFI_V8PLUS,
FFI_V9,
#if defined(__arch64__) || defined(__sparcv9)
FFI_DEFAULT_ABI = FFI_V9,
#else
FFI_DEFAULT_ABI = FFI_V8,
#endif
#endif
/* ---- Intel x86 ---------------- */
#ifdef __i386__
FFI_SYSV,
FFI_DEFAULT_ABI = FFI_SYSV,
#endif
/* ---- Intel ia64 ---------------- */
#ifdef __ia64__
FFI_UNIX, /* Linux and all Unix variants use the same conventions */
FFI_DEFAULT_ABI = FFI_UNIX,
#endif
/* ---- Mips --------------------- */
#ifdef __mips__
FFI_O32,
FFI_N32,
FFI_N64,
# if defined(__mips_eabi)
# define FFI_MIPS_EABI
# define FFI_MIPS_O32
# else
# if !defined(_MIPS_SIM)
#error -- something is very wrong --
# else
# if _MIPS_SIM==_ABIN32 && defined(_ABIN32)
# define FFI_MIPS_N32
# else
# define FFI_MIPS_O32
# endif
# endif
# endif
# if defined(FFI_MIPS_O32)
FFI_DEFAULT_ABI = FFI_O32,
# else
FFI_DEFAULT_ABI = FFI_N32,
# endif
#endif
/* ---- Alpha -------------------- */
#ifdef __alpha__
FFI_OSF,
FFI_DEFAULT_ABI = FFI_OSF,
#endif
/* ---- Motorola m68k ------------ */
#ifdef __m68k__
FFI_SYSV,
FFI_DEFAULT_ABI = FFI_SYSV,
#endif
/* ---- PowerPC ------------------ */
#ifdef __powerpc__
FFI_SYSV,
FFI_GCC_SYSV,
FFI_DEFAULT_ABI = FFI_GCC_SYSV,
#endif
/* ---- ARM --------------------- */
#ifdef __arm__
FFI_SYSV,
FFI_DEFAULT_ABI = FFI_SYSV,
#endif
/* ---- S390 --------------------- */
#ifdef __S390__
FFI_SYSV,
FFI_DEFAULT_ABI = FFI_SYSV,
#endif
/* Leave this for debugging purposes */
FFI_LAST_ABI
} ffi_abi;
typedef struct _ffi_type
{
size_t size;
unsigned short alignment;
unsigned short type;
struct _ffi_type **elements;
} ffi_type;
/* These are defined in ffi.c */
extern ffi_type ffi_type_void;
extern ffi_type ffi_type_uint8;
extern ffi_type ffi_type_sint8;
extern ffi_type ffi_type_uint16;
extern ffi_type ffi_type_sint16;
extern ffi_type ffi_type_uint32;
extern ffi_type ffi_type_sint32;
extern ffi_type ffi_type_uint64;
extern ffi_type ffi_type_sint64;
extern ffi_type ffi_type_float;
extern ffi_type ffi_type_double;
extern ffi_type ffi_type_longdouble;
extern ffi_type ffi_type_pointer;
extern ffi_type ffi_type_ushort;
extern ffi_type ffi_type_sint;
extern ffi_type ffi_type_uint;
extern ffi_type ffi_type_slong;
extern ffi_type ffi_type_ulong;
typedef enum {
FFI_OK = 0,
FFI_BAD_TYPEDEF,
FFI_BAD_ABI
} ffi_status;
typedef unsigned FFI_TYPE;
typedef struct {
ffi_abi abi;
unsigned nargs;
ffi_type **arg_types;
ffi_type *rtype;
unsigned bytes;
unsigned flags;
#ifdef __mips__
#if _MIPS_SIM == _ABIN32
unsigned rstruct_flag;
#endif
#endif
} ffi_cif;
/* ---- Definitions for the raw API -------------------------------------- */
#if !FFI_NO_RAW_API
typedef union {
#if _MIPS_SIM==_ABIN32 && defined(_ABIN32)
long sint;
unsigned long uint;
#else
int sint;
unsigned uint;
#endif
float flt;
char data[sizeof(void*)];
void* ptr;
} ffi_raw;
void ffi_raw_call (/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
/*@out@*/ void *rvalue,
/*@dependent@*/ ffi_raw *avalue);
void ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
void ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
size_t ffi_raw_size (ffi_cif *cif);
#if !NO_JAVA_RAW_API
/* This is analogous to the raw API, except it uses Java parameter */
/* packing, even on 64-bit machines. I.e. on 64-bit machines */
/* longs and doubles are followed by an empty 64-bit word. */
void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
/*@out@*/ void *rvalue,
/*@dependent@*/ ffi_raw *avalue);
void ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw);
void ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args);
size_t ffi_java_raw_size (ffi_cif *cif);
#endif /* !NO_JAVA_RAW_API */
#endif /* !FFI_NO_RAW_API */
/* ---- Definitions for closures ----------------------------------------- */
#ifdef __i386__
#define FFI_CLOSURES 1 /* x86 supports closures */
#define FFI_TRAMPOLINE_SIZE 10
#define FFI_NATIVE_RAW_API 1 /* and has native raw api support */
#elif defined(X86_WIN32)
#define FFI_CLOSURES 1 /* x86 supports closures */
#define FFI_TRAMPOLINE_SIZE 10
#define FFI_NATIVE_RAW_API 1 /* and has native raw api support */
#elif defined(IA64)
#define FFI_CLOSURES 1
#define FFI_TRAMPOLINE_SIZE 24 /* Really the following struct, which */
/* can be interpreted as a C function */
/* decriptor: */
struct ffi_ia64_trampoline_struct {
void * code_pointer; /* Pointer to ffi_closure_UNIX */
void * fake_gp; /* Pointer to closure, installed as gp */
void * real_gp; /* Real gp value, reinstalled by */
/* ffi_closure_UNIX. */
};
#define FFI_NATIVE_RAW_API 0
#elif defined(__alpha__)
#define FFI_CLOSURES 1
#define FFI_TRAMPOLINE_SIZE 24
#define FFI_NATIVE_RAW_API 0
#elif defined(POWERPC)
#define FFI_CLOSURES 1
#define FFI_TRAMPOLINE_SIZE 40
#define FFI_NATIVE_RAW_API 0
#else
#define FFI_CLOSURES 0
#define FFI_NATIVE_RAW_API 0
#endif
#if FFI_CLOSURES
typedef struct {
char tramp[FFI_TRAMPOLINE_SIZE];
ffi_cif *cif;
void (*fun)(ffi_cif*,void*,void**,void*);
void *user_data;
} ffi_closure;
ffi_status
ffi_prep_closure (ffi_closure*,
ffi_cif *,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data);
#if !FFI_NO_RAW_API
typedef struct {
char tramp[FFI_TRAMPOLINE_SIZE];
ffi_cif *cif;
#if !FFI_NATIVE_RAW_API
/* if this is enabled, then a raw closure has the same layout
as a regular closure. We use this to install an intermediate
handler to do the transaltion, void** -> ffi_raw*. */
void (*translate_args)(ffi_cif*,void*,void**,void*);
void *this_closure;
#endif
void (*fun)(ffi_cif*,void*,ffi_raw*,void*);
void *user_data;
} ffi_raw_closure;
ffi_status
ffi_prep_raw_closure (ffi_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data);
#ifndef NO_JAVA_RAW_API
ffi_status
ffi_prep_java_raw_closure (ffi_raw_closure*,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data);
#endif
#endif /* !FFI_NO_RAW_API */
#endif /* FFI_CLOSURES */
/* ---- Public interface definition -------------------------------------- */
ffi_status ffi_prep_cif (ffi_cif *cif,
ffi_abi abi,
unsigned int nargs,
ffi_type *rtype,
ffi_type **atypes);
void ffi_call (ffi_cif *cif,
void (*fn)(),
void *rvalue,
void **avalue);
/* Useful for eliminating compiler warnings */
#define FFI_FN(f) ((void (*)())f)
#endif
#ifdef __cplusplus
}
#endif
#endif
+168
View File
@@ -0,0 +1,168 @@
/* -----------------------------------------------------------------*-C-*-
libffi 2.0.0 - Copyright (C) 1996, 1997, 1998, 1999, 2000,
2001 Red Hat, Inc.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <fficonfig.h>
#define ALIGN(v, a) (((((size_t) (v))-1) | ((a)-1))+1)
/* ---- Generic type definitions ----------------------------------------- */
#define FLOAT32 float
#define FLOAT64 double
#define FLOAT80 long double
#define UINT8 unsigned char
#define SINT8 signed char
#if SIZEOF_INT == 2
#define UINT16 unsigned int
#define SINT16 int
#else
#if SIZEOF_SHORT == 2
#define UINT16 unsigned short
#define SINT16 short
#endif
#endif
#if SIZEOF_INT == 4
#define UINT32 unsigned int
#define SINT32 int
#else
#if SIZEOF_SHORT == 4
#define UINT32 unsigned short
#define SINT32 short
#else
#if SIZEOF_LONG == 4
#define UINT32 unsigned long
#define SINT32 long
#endif
#endif
#endif
#if SIZEOF_INT == 8
#define UINT64 unsigned int
#define SINT64 int
#else
#if SIZEOF_LONG == 8
#define UINT64 unsigned long
#define SINT64 long
#else
#if SIZEOF_LONG_LONG == 8
#define UINT64 unsigned long long
#define SINT64 long long
#endif
#endif
#endif
#define FFI_TYPE_VOID 0
#define FFI_TYPE_INT 1
#define FFI_TYPE_FLOAT 2
#define FFI_TYPE_DOUBLE 3
#if SIZEOF_LONG_DOUBLE == SIZEOF_DOUBLE
#define FFI_TYPE_LONGDOUBLE FFI_TYPE_DOUBLE
#else
#define FFI_TYPE_LONGDOUBLE 4
#endif
#define FFI_TYPE_UINT8 5 /* If this changes, update ffi_mips.h. */
#define FFI_TYPE_SINT8 6 /* If this changes, update ffi_mips.h. */
#define FFI_TYPE_UINT16 7
#define FFI_TYPE_SINT16 8
#define FFI_TYPE_UINT32 9
#define FFI_TYPE_SINT32 10
#define FFI_TYPE_UINT64 11
#define FFI_TYPE_SINT64 12
#define FFI_TYPE_STRUCT 13 /* If this changes, update ffi_mips.h. */
#define FFI_TYPE_POINTER 14
#define FFI_TYPE_LAST 14
#if _MIPS_SIM==_ABIN32 && defined(_ABIN32)
#define SIZEOF_ARG 8
#else
#define SIZEOF_ARG SIZEOF_VOID_P
#endif
#ifndef __ASSEMBLER__
/* This part of the private header file is only for C code. */
/* Check for the existence of memcpy. */
#if STDC_HEADERS
# include <string.h>
#else
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#ifndef __cplusplus
/* bool is a keyword in C++ */
typedef int bool;
#endif
#ifdef FFI_DEBUG
/* Debugging functions */
void ffi_stop_here(void);
bool ffi_type_test(ffi_type *a);
#define FFI_ASSERT(x) ((x) ? 0 : ffi_assert(__FILE__,__LINE__))
#else
#define FFI_ASSERT(x)
#endif
/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif);
/* Extended cif, used in callback from assembly routine */
typedef struct
{
ffi_cif *cif;
void *rvalue;
void **avalue;
} extended_cif;
#endif /* __ASSEMBLER__ */
+269
View File
@@ -0,0 +1,269 @@
/* -----------------------------------------------------------------------
java_raw_api.c - Copyright (c) 1999 Cygnus Solutions
Cloned from raw_api.c
Raw_api.c author: Kresten Krab Thorup <[email protected]>
Java_raw_api.c author: Hans-J. Boehm <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
/* This defines a Java- and 64-bit specific variant of the raw API. */
/* It assumes that "raw" argument blocks look like Java stacks on a */
/* 64-bit machine. Arguments that can be stored in a single stack */
/* stack slots (longs, doubles) occupy 128 bits, but only the first */
/* 64 bits are actually used. */
#include <ffi.h>
#include <ffi_private.h>
#if !defined(NO_JAVA_RAW_API) && !defined(FFI_NO_RAW_API)
size_t
ffi_java_raw_size (ffi_cif *cif)
{
size_t result = 0;
int i;
ffi_type **at = cif->arg_types;
for (i = cif->nargs-1; i >= 0; i--, at++)
{
switch((*at) -> type) {
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
result += 2 * SIZEOF_ARG;
break;
case FFI_TYPE_STRUCT:
/* No structure parameters in Java. */
abort();
default:
result += SIZEOF_ARG;
}
}
return result;
}
void
ffi_java_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args)
{
unsigned i;
ffi_type **tp = cif->arg_types;
#if WORDS_BIGENDIAN
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
switch ((*tp)->type)
{
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
*args = (void*) ((char*)(raw++) + SIZEOF_ARG - 1);
break;
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT16:
*args = (void*) ((char*)(raw++) + SIZEOF_ARG - 2);
break;
#if SIZEOF_ARG >= 4
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
*args = (void*) ((char*)(raw++) + SIZEOF_ARG - 4);
break;
#endif
#if SIZEOF_ARG == 8
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_DOUBLE:
*args = (void *)raw;
raw += 2;
break;
#endif
case FFI_TYPE_POINTER:
*args = (void*) &(raw++)->ptr;
break;
default:
*args = raw;
raw += ALIGN ((*tp)->size, SIZEOF_ARG) / SIZEOF_ARG;
}
}
#else /* WORDS_BIGENDIAN */
#if !PDP
/* then assume little endian */
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
#if SIZEOF_ARG == 8
switch((*tp)->type) {
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_DOUBLE:
*args = (void*) raw;
raw += 2;
break;
default:
*args = (void*) raw++;
}
#else /* SIZEOF_ARG != 8 */
*args = (void*) raw;
raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*);
#endif /* SIZEOF_ARG == 8 */
}
#else
#error "pdp endian not supported"
#endif /* ! PDP */
#endif /* WORDS_BIGENDIAN */
}
void
ffi_java_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw)
{
unsigned i;
ffi_type **tp = cif->arg_types;
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
switch ((*tp)->type)
{
case FFI_TYPE_UINT8:
(raw++)->uint = *(UINT8*) (*args);
break;
case FFI_TYPE_SINT8:
(raw++)->sint = *(SINT8*) (*args);
break;
case FFI_TYPE_UINT16:
(raw++)->uint = *(UINT16*) (*args);
break;
case FFI_TYPE_SINT16:
(raw++)->sint = *(SINT16*) (*args);
break;
#if SIZEOF_ARG >= 4
case FFI_TYPE_UINT32:
(raw++)->uint = *(UINT32*) (*args);
break;
case FFI_TYPE_SINT32:
(raw++)->sint = *(SINT32*) (*args);
break;
#endif
case FFI_TYPE_FLOAT:
(raw++)->flt = *(FLOAT32*) (*args);
break;
#if SIZEOF_ARG == 8
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
case FFI_TYPE_DOUBLE:
raw->uint = *(UINT64*) (*args);
raw += 2;
break;
#endif
case FFI_TYPE_POINTER:
(raw++)->ptr = **(void***) args;
break;
default:
#if SIZEOF_ARG == 8
FFI_ASSERT(FALSE); /* Should have covered all cases */
#else
memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
raw += ALIGN ((*tp)->size, SIZEOF_ARG) / SIZEOF_ARG;
#endif
}
}
}
#if !FFI_NATIVE_RAW_API
/* This is a generic definition of ffi_raw_call, to be used if the
* native system does not provide a machine-specific implementation.
* Having this, allows code to be written for the raw API, without
* the need for system-specific code to handle input in that format;
* these following couple of functions will handle the translation forth
* and back automatically. */
void ffi_java_raw_call (/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
/*@out@*/ void *rvalue,
/*@dependent@*/ ffi_raw *raw)
{
void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
ffi_java_raw_to_ptrarray (cif, raw, avalue);
ffi_call (cif, fn, rvalue, avalue);
}
#if FFI_CLOSURES /* base system provides closures */
static void
ffi_java_translate_args (ffi_cif *cif, void *rvalue,
void **avalue, void *user_data)
{
ffi_raw *raw = (ffi_raw*)alloca (ffi_java_raw_size (cif));
ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
ffi_java_ptrarray_to_raw (cif, avalue, raw);
(*cl->fun) (cif, rvalue, raw, cl->user_data);
}
/* Again, here is the generic version of ffi_prep_raw_closure, which
* will install an intermediate "hub" for translation of arguments from
* the pointer-array format, to the raw format */
ffi_status
ffi_prep_java_raw_closure (ffi_raw_closure* cl,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data)
{
ffi_status status;
status = ffi_prep_closure ((ffi_closure*) cl,
cif,
&ffi_java_translate_args,
(void*)cl);
if (status == FFI_OK)
{
cl->fun = fun;
cl->user_data = user_data;
}
return status;
}
#endif /* FFI_CLOSURES */
#endif /* !FFI_NATIVE_RAW_API */
#endif /* !FFI_NO_RAW_API */
+184
View File
@@ -0,0 +1,184 @@
/* -----------------------------------------------------------------------
ffi.c
m68k Foreign Function Interface
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
/* ffi_prep_args is called by the assembly routine once stack space has
been allocated for the function's arguments. */
static void *
ffi_prep_args (void *stack, extended_cif *ecif)
{
unsigned int i;
int tmp;
unsigned int avn;
void **p_argv;
char *argp;
ffi_type **p_arg;
void *struct_value_ptr;
tmp = 0;
argp = stack;
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT
&& ecif->cif->rtype->size > 8)
struct_value_ptr = ecif->rvalue;
else
struct_value_ptr = NULL;
avn = ecif->cif->nargs;
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
i != 0 && avn != 0;
i--, p_arg++)
{
size_t z;
/* Align if necessary. */
if (((*p_arg)->alignment - 1) & (unsigned) argp)
argp = (char *) ALIGN (argp, (*p_arg)->alignment);
if (avn != 0)
{
avn--;
z = (*p_arg)->size;
if (z < sizeof (int))
{
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int) *(SINT8 *) *p_argv;
break;
case FFI_TYPE_UINT8:
*(unsigned int *) argp = (unsigned int) *(UINT8 *) *p_argv;
break;
case FFI_TYPE_SINT16:
*(signed int *) argp = (signed int) *(SINT16 *) *p_argv;
break;
case FFI_TYPE_UINT16:
*(unsigned int *) argp = (unsigned int) *(UINT16 *) *p_argv;
break;
case FFI_TYPE_STRUCT:
memcpy (argp + sizeof (int) - z, *p_argv, z);
break;
default:
FFI_ASSERT (0);
}
z = sizeof (int);
}
else
memcpy (argp, *p_argv, z);
p_argv++;
argp += z;
}
}
return struct_value_ptr;
}
#define CIF_FLAGS_INT 1
#define CIF_FLAGS_DINT 2
#define CIF_FLAGS_FLOAT 4
#define CIF_FLAGS_DOUBLE 8
#define CIF_FLAGS_LDOUBLE 16
#define CIF_FLAGS_POINTER 32
#define CIF_FLAGS_STRUCT 64
/* Perform machine dependent cif processing */
ffi_status
ffi_prep_cif_machdep (ffi_cif *cif)
{
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
cif->flags = 0;
break;
case FFI_TYPE_STRUCT:
if (cif->rtype->size > 4 && cif->rtype->size <= 8)
cif->flags = CIF_FLAGS_DINT;
else if (cif->rtype->size <= 4)
cif->flags = CIF_FLAGS_STRUCT;
else
cif->flags = 0;
break;
case FFI_TYPE_FLOAT:
cif->flags = CIF_FLAGS_FLOAT;
break;
case FFI_TYPE_DOUBLE:
cif->flags = CIF_FLAGS_DOUBLE;
break;
case FFI_TYPE_LONGDOUBLE:
cif->flags = CIF_FLAGS_LDOUBLE;
break;
case FFI_TYPE_POINTER:
cif->flags = CIF_FLAGS_POINTER;
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
cif->flags = CIF_FLAGS_DINT;
break;
default:
cif->flags = CIF_FLAGS_INT;
break;
}
return FFI_OK;
}
extern void ffi_call_SYSV (void *(*) (void *, extended_cif *),
extended_cif *,
unsigned, unsigned, unsigned,
void *, void (*fn) ());
void
ffi_call (ffi_cif *cif, void (*fn) (), void *rvalue, void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return value
address then we need to make one. */
if (rvalue == NULL
&& cif->rtype->type == FFI_TYPE_STRUCT
&& cif->rtype->size > 8)
ecif.rvalue = alloca (cif->rtype->size);
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_SYSV:
ffi_call_SYSV (ffi_prep_args, &ecif, cif->bytes,
cif->flags, cif->rtype->size * 8,
ecif.rvalue, fn);
break;
default:
FFI_ASSERT (0);
break;
}
}
+96
View File
@@ -0,0 +1,96 @@
/* -----------------------------------------------------------------------
sysv.S
m68k Foreign Function Interface
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
.text
.globl ffi_call_SYSV
.type ffi_call_SYSV,@function
ffi_call_SYSV:
link %fp,#0
move.l %d2,-(%sp)
| Make room for all of the new args.
sub.l 16(%fp),%sp
| Call ffi_prep_args
move.l 12(%fp),-(%sp)
pea 4(%sp)
move.l 8(%fp),%a0
jsr (%a0)
addq.l #8,%sp
| Pass pointer to struct value, if any
move.l %a0,%a1
| Call the function
move.l 32(%fp),%a0
jsr (%a0)
| Remove the space we pushed for the args
add.l 16(%fp),%sp
| Load the pointer to storage for the return value
move.l 28(%fp),%a1
| Load the return type code
move.l 20(%fp),%d2
| If the return value pointer is NULL, assume no return value.
tst.l %a1
jbeq noretval
btst #0,%d2
jbeq retlongint
move.l %d0,(%a1)
jbra epilogue
retlongint:
btst #1,%d2
jbeq retfloat
move.l %d0,(%a1)
move.l %d1,4(%a1)
jbra epilogue
retfloat:
btst #2,%d2
jbeq retdouble
fmove.s %fp0,(%a1)
jbra epilogue
retdouble:
btst #3,%d2
jbeq retlongdouble
fmove.d %fp0,(%a1)
jbra epilogue
retlongdouble:
btst #4,%d2
jbeq retpointer
fmove.x %fp0,(%a1)
jbra epilogue
retpointer:
btst #5,%d2
jbeq retstruct
move.l %a0,(%a1)
jbra epilogue
retstruct:
btst #6,%d2
jbeq noretval
move.l 24(%fp),%d2
bfins %d0,(%a1){#0,%d2}
noretval:
epilogue:
move.l (%sp)+,%d2
unlk %a6
rts
.size ffi_call_SYSV,.-ffi_call_SYSV
+469
View File
@@ -0,0 +1,469 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1996, 2001 Red Hat, Inc.
MIPS Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <mips/mips.h>
#include <stdlib.h>
#if _MIPS_SIM == _MIPS_SIM_NABI32
#define FIX_ARGP \
FFI_ASSERT(argp <= &stack[bytes]); \
if (argp == &stack[bytes]) \
{ \
argp = stack; \
}
#else
#define FIX_ARGP
#endif
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
static void ffi_prep_args(char *stack,
extended_cif *ecif,
int bytes,
int flags)
{
register int i;
register int avn;
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* If more than 8 double words are used, the remainder go
on the stack. We reorder stuff on the stack here to
support this easily. */
if (bytes > 8 * SIZEOF_ARG)
argp = &stack[bytes - (8 * SIZEOF_ARG)];
else
argp = stack;
#else
argp = stack;
#endif
memset(stack, 0, bytes);
#if _MIPS_SIM == _MIPS_SIM_NABI32
if ( ecif->cif->rstruct_flag != 0 )
#else
if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT )
#endif
{
*(SLOT_TYPE_UNSIGNED *) argp = (SLOT_TYPE_UNSIGNED) ecif->rvalue;
argp += sizeof(SLOT_TYPE_UNSIGNED);
FIX_ARGP;
}
avn = ecif->cif->nargs;
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
i && avn;
i--, p_arg++)
{
size_t z;
/* Align if necessary */
if (((*p_arg)->alignment - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, (*p_arg)->alignment);
FIX_ARGP;
}
#if _MIPS_SIM == _MIPS_SIM_ABI32
#define OFFSET 0
#else
#define OFFSET sizeof(int)
#endif
if (avn)
{
avn--;
z = (*p_arg)->size;
if (z < sizeof(SLOT_TYPE_UNSIGNED))
{
z = sizeof(SLOT_TYPE_UNSIGNED);
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(SINT32 *) &argp[OFFSET] = (SINT32)*(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
*(UINT32 *) &argp[OFFSET] = (UINT32)*(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
*(SINT32 *) &argp[OFFSET] = (SINT32)*(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
*(UINT32 *) &argp[OFFSET] = (UINT32)*(UINT16 *)(* p_argv);
break;
case FFI_TYPE_SINT32:
*(SINT32 *) &argp[OFFSET] = (SINT32)*(SINT32 *)(* p_argv);
break;
case FFI_TYPE_UINT32:
case FFI_TYPE_POINTER:
*(UINT32 *) &argp[OFFSET] = (UINT32)*(UINT32 *)(* p_argv);
break;
/* This can only happen with 64bit slots */
case FFI_TYPE_FLOAT:
*(float *) argp = *(float *)(* p_argv);
break;
/* Handle small structures */
case FFI_TYPE_STRUCT:
memcpy(argp, *p_argv, (*p_arg)->size);
break;
default:
FFI_ASSERT(0);
}
}
else
{
#if _MIPS_SIM == _MIPS_SIM_ABI32
memcpy(argp, *p_argv, z);
#else
{
unsigned end = (unsigned) argp+z;
unsigned cap = (unsigned) stack+bytes;
/* Check if the data will fit within the register
space. Handle it if it doesn't. */
if (end <= cap)
memcpy(argp, *p_argv, z);
else
{
unsigned portion = end - cap;
memcpy(argp, *p_argv, portion);
argp = stack;
memcpy(argp,
(void*)((unsigned)(*p_argv)+portion), z - portion);
}
}
#endif
}
p_argv++;
argp += z;
FIX_ARGP;
}
}
return;
}
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* The n32 spec says that if "a chunk consists solely of a double
float field (but not a double, which is part of a union), it
is passed in a floating point register. Any other chunk is
passed in an integer register". This code traverses structure
definitions and generates the appropriate flags. */
static unsigned calc_n32_struct_flags(ffi_type *arg, unsigned *shift)
{
unsigned flags = 0;
unsigned index = 0;
ffi_type *e;
while (e = arg->elements[index])
{
if (e->type == FFI_TYPE_DOUBLE)
{
flags += (FFI_TYPE_DOUBLE << *shift);
*shift += FFI_FLAG_BITS;
}
else if (e->type == FFI_TYPE_STRUCT)
flags += calc_n32_struct_flags(e, shift);
else
*shift += FFI_FLAG_BITS;
index++;
}
return flags;
}
unsigned calc_n32_return_struct_flags(ffi_type *arg)
{
unsigned flags = 0;
unsigned index = 0;
unsigned small = FFI_TYPE_SMALLSTRUCT;
ffi_type *e;
/* Returning structures under n32 is a tricky thing.
A struct with only one or two floating point fields
is returned in $f0 (and $f2 if necessary). Any other
struct results at most 128 bits are returned in $2
(the first 64 bits) and $3 (remainder, if necessary).
Larger structs are handled normally. */
if (arg->size > 16)
return 0;
if (arg->size > 8)
small = FFI_TYPE_SMALLSTRUCT2;
e = arg->elements[0];
if (e->type == FFI_TYPE_DOUBLE)
flags = FFI_TYPE_DOUBLE << FFI_FLAG_BITS;
else if (e->type == FFI_TYPE_FLOAT)
flags = FFI_TYPE_FLOAT << FFI_FLAG_BITS;
if (flags && (e = arg->elements[1]))
{
if (e->type == FFI_TYPE_DOUBLE)
flags += FFI_TYPE_DOUBLE;
else if (e->type == FFI_TYPE_FLOAT)
flags += FFI_TYPE_FLOAT;
else
return small;
if (flags && (arg->elements[2]))
{
/* There are three arguments and the first two are
floats! This must be passed the old way. */
return small;
}
}
else
if (!flags)
return small;
return flags;
}
#endif
/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
cif->flags = 0;
#if _MIPS_SIM == _MIPS_SIM_ABI32
/* Set the flags necessary for O32 processing */
if (cif->rtype->type != FFI_TYPE_STRUCT)
{
if (cif->nargs > 0)
{
switch ((cif->arg_types)[0]->type)
{
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags += (cif->arg_types)[0]->type;
break;
default:
break;
}
if (cif->nargs > 1)
{
/* Only handle the second argument if the first
is a float or double. */
if (cif->flags)
{
switch ((cif->arg_types)[1]->type)
{
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags += (cif->arg_types)[1]->type << FFI_FLAG_BITS;
break;
default:
break;
}
}
}
}
}
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
case FFI_TYPE_STRUCT:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 2);
break;
default:
cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 2);
break;
}
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
/* Set the flags necessary for N32 processing */
{
unsigned shift = 0;
unsigned count = (cif->nargs < 8) ? cif->nargs : 8;
unsigned index = 0;
unsigned struct_flags = 0;
if (cif->rtype->type == FFI_TYPE_STRUCT)
{
struct_flags = calc_n32_return_struct_flags(cif->rtype);
if (struct_flags == 0)
{
/* This means that the structure is being passed as
a hidden argument */
shift = FFI_FLAG_BITS;
count = (cif->nargs < 7) ? cif->nargs : 7;
cif->rstruct_flag = !0;
}
else
cif->rstruct_flag = 0;
}
else
cif->rstruct_flag = 0;
while (count-- > 0)
{
switch ((cif->arg_types)[index]->type)
{
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags += ((cif->arg_types)[index]->type << shift);
shift += FFI_FLAG_BITS;
break;
case FFI_TYPE_STRUCT:
cif->flags += calc_n32_struct_flags((cif->arg_types)[index],
&shift);
break;
default:
shift += FFI_FLAG_BITS;
}
index++;
}
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_STRUCT:
{
if (struct_flags == 0)
{
/* The structure is returned through a hidden
first argument. Do nothing, 'cause FFI_TYPE_VOID
is 0 */
}
else
{
/* The structure is returned via some tricky
mechanism */
cif->flags += FFI_TYPE_STRUCT << (FFI_FLAG_BITS * 8);
cif->flags += struct_flags << (4 + (FFI_FLAG_BITS * 8));
}
break;
}
case FFI_TYPE_VOID:
/* Do nothing, 'cause FFI_TYPE_VOID is 0 */
break;
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
cif->flags += cif->rtype->type << (FFI_FLAG_BITS * 8);
break;
default:
cif->flags += FFI_TYPE_INT << (FFI_FLAG_BITS * 8);
break;
}
}
#endif
return FFI_OK;
}
/* Low level routine for calling O32 functions */
extern int ffi_call_O32(void (*)(char *, extended_cif *, int, int),
extended_cif *, unsigned,
unsigned, unsigned *, void (*)());
/* Low level routine for calling N32 functions */
extern int ffi_call_N32(void (*)(char *, extended_cif *, int, int),
extended_cif *, unsigned,
unsigned, unsigned *, void (*)());
void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
ecif.rvalue = alloca(cif->rtype->size);
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
#if _MIPS_SIM == _MIPS_SIM_ABI32
case FFI_O32:
ffi_call_O32(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
break;
#endif
#if _MIPS_SIM == _MIPS_SIM_NABI32
case FFI_N32:
ffi_call_N32(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
break;
#endif
default:
FFI_ASSERT(0);
break;
}
}
+144
View File
@@ -0,0 +1,144 @@
/* -----------------------------------------------------------------------
ffi-mips.h - Copyright (c) 1996, 2001 Red Hat, Inc.
MIPS FFI Definitions
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SUPPORT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#ifndef MIPS_H
#if defined(__mips_eabi)
# define FFI_MIPS_EABI
# define FFI_MIPS_O32
#else
# if !defined(_MIPS_SIM)
-- something is very wrong --
# else
# if _MIPS_SIM==_ABIN32 && defined(_ABIN32)
# define FFI_MIPS_N32
# else
# if defined(__GNUC__)
# define FFI_MIPS_O32
# else
# if _MIPS_SIM==_ABIO32
# define FFI_MIPS_O32
# else
-- this is an unsupported platform --
# endif
# endif
# endif
# endif
#endif
#define v0 $2
#define v1 $3
#define a0 $4
#define a1 $5
#define a2 $6
#define a3 $7
#define a4 $8
#define a5 $9
#define a6 $10
#define a7 $11
#define t0 $8
#define t1 $9
#define t2 $10
#define t3 $11
#define t4 $12
#define t5 $13
#define t6 $14
#define t7 $15
#define t8 $24
#define t9 $25
#define ra $31
#if defined(FFI_MIPS_O32)
#define FFI_DEFAULT_ABI FFI_O32
/* O32 stack frames have 32bit integer args */
#define SLOT_TYPE_UNSIGNED UINT32
#define SLOT_TYPE_SIGNED SINT32
#define SIZEOF_ARG 4
#define REG_L lw
#define REG_S sw
#define SUBU subu
#define ADDU addu
#define SRL srl
#define LI li
#else
#define FFI_DEFAULT_ABI FFI_N32
/* N32 and N64 frames have 64bit integer args */
#define SLOT_TYPE_UNSIGNED UINT64
#define SLOT_TYPE_SIGNED SINT64
#define SIZEOF_ARG 8
#define REG_L ld
#define REG_S sd
#define SUBU dsubu
#define ADDU daddu
#define SRL dsrl
#define LI dli
#endif
#define FFI_FLAG_BITS 2
/* SGI's strange assembler requires that we multiply by 4 rather
than shift left by FFI_FLAG_BITS */
#define FFI_ARGS_D FFI_TYPE_DOUBLE
#define FFI_ARGS_F FFI_TYPE_FLOAT
#define FFI_ARGS_DD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_DOUBLE
#define FFI_ARGS_FF FFI_TYPE_FLOAT * 4 + FFI_TYPE_FLOAT
#define FFI_ARGS_FD FFI_TYPE_DOUBLE * 4 + FFI_TYPE_FLOAT
#define FFI_ARGS_DF FFI_TYPE_FLOAT * 4 + FFI_TYPE_DOUBLE
/* Needed for N32 structure returns */
#define FFI_TYPE_SMALLSTRUCT FFI_TYPE_UINT8
#define FFI_TYPE_SMALLSTRUCT2 FFI_TYPE_SINT8
#if 0
/* The SGI assembler can't handle this.. */
#define FFI_TYPE_STRUCT_DD (( FFI_ARGS_DD ) << 4) + FFI_TYPE_STRUCT
#else
/* ...so we calculate these by hand! */
#define FFI_TYPE_STRUCT_D 61
#define FFI_TYPE_STRUCT_F 45
#define FFI_TYPE_STRUCT_DD 253
#define FFI_TYPE_STRUCT_FF 173
#define FFI_TYPE_STRUCT_FD 237
#define FFI_TYPE_STRUCT_DF 189
#define FFI_TYPE_STRUCT_SMALL 93
#define FFI_TYPE_STRUCT_SMALL2 109
#endif
#endif
+320
View File
@@ -0,0 +1,320 @@
/* -----------------------------------------------------------------------
n32.S - Copyright (c) 1996, 1998, 2001 Red Hat, Inc.
MIPS Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#include <ffi_private.h>
#include <mips/mips.h>
/* Only build this code if we are compiling for n32 */
#if defined(FFI_MIPS_N32)
#define callback a0
#define bytes a2
#define flags a3
#define raddr a4
#define fn a5
#define SIZEOF_FRAME ( 8 * SIZEOF_ARG )
.text
.align 2
.globl ffi_call_N32
.ent ffi_call_N32
ffi_call_N32:
# Prologue
SUBU $sp, SIZEOF_FRAME # Frame size
REG_S $fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp) # Save frame pointer
REG_S ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp) # Save return address
move $fp, $sp
move t9, callback # callback function pointer
REG_S bytes, 2*SIZEOF_ARG($fp) # bytes
REG_S flags, 3*SIZEOF_ARG($fp) # flags
REG_S raddr, 4*SIZEOF_ARG($fp) # raddr
REG_S fn, 5*SIZEOF_ARG($fp) # fn
# Allocate at least 4 words in the argstack
move v0, bytes
bge bytes, 4 * SIZEOF_ARG, bigger
LI v0, 4 * SIZEOF_ARG
b sixteen
bigger:
ADDU t4, v0, 2 * SIZEOF_ARG -1 # make sure it is aligned
and v0, t4, -2 * SIZEOF_ARG # to a proper boundry.
sixteen:
SUBU $sp, $sp, v0 # move the stack pointer to reflect the
# arg space
ADDU a0, $sp, 0 # 4 * SIZEOF_ARG
ADDU a3, $fp, 3 * SIZEOF_ARG
# Call ffi_prep_args
jal t9
# ADDU $sp, $sp, 4 * SIZEOF_ARG # adjust $sp to new args
# Copy the stack pointer to t9
move t9, $sp
# Fix the stack if there are more than 8 64bit slots worth
# of arguments.
# Load the number of bytes
REG_L t6, 2*SIZEOF_ARG($fp)
# Is it bigger than 8 * SIZEOF_ARG?
dadd t7, $0, 8 * SIZEOF_ARG
dsub t8, t6, t7
bltz t8, loadregs
add t9, t9, t8
loadregs:
REG_L t4, 3*SIZEOF_ARG($fp) # load the flags word
add t6, t4, 0 # and copy it into t6
and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg1_floatp
REG_L a0, 0*SIZEOF_ARG(t9)
b arg1_next
arg1_floatp:
bne t4, FFI_TYPE_FLOAT, arg1_doublep
l.s $f12, 0*SIZEOF_ARG(t9)
b arg1_next
arg1_doublep:
l.d $f12, 0*SIZEOF_ARG(t9)
arg1_next:
add t4, t6, 0
SRL t4, 1*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg2_floatp
REG_L a1, 1*SIZEOF_ARG(t9)
b arg2_next
arg2_floatp:
bne t4, FFI_TYPE_FLOAT, arg2_doublep
l.s $f13, 1*SIZEOF_ARG(t9)
b arg2_next
arg2_doublep:
l.d $f13, 1*SIZEOF_ARG(t9)
arg2_next:
add t4, t6, 0
SRL t4, 2*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg3_floatp
REG_L a2, 2*SIZEOF_ARG(t9)
b arg3_next
arg3_floatp:
bne t4, FFI_TYPE_FLOAT, arg3_doublep
l.s $f14, 2*SIZEOF_ARG(t9)
b arg3_next
arg3_doublep:
l.d $f14, 2*SIZEOF_ARG(t9)
arg3_next:
add t4, t6, 0
SRL t4, 3*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg4_floatp
REG_L a3, 3*SIZEOF_ARG(t9)
b arg4_next
arg4_floatp:
bne t4, FFI_TYPE_FLOAT, arg4_doublep
l.s $f15, 3*SIZEOF_ARG(t9)
b arg4_next
arg4_doublep:
l.d $f15, 3*SIZEOF_ARG(t9)
arg4_next:
add t4, t6, 0
SRL t4, 4*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg5_floatp
REG_L a4, 4*SIZEOF_ARG(t9)
b arg5_next
arg5_floatp:
bne t4, FFI_TYPE_FLOAT, arg5_doublep
l.s $f16, 4*SIZEOF_ARG(t9)
b arg5_next
arg5_doublep:
l.d $f16, 4*SIZEOF_ARG(t9)
arg5_next:
add t4, t6, 0
SRL t4, 5*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg6_floatp
REG_L a5, 5*SIZEOF_ARG(t9)
b arg6_next
arg6_floatp:
bne t4, FFI_TYPE_FLOAT, arg6_doublep
l.s $f17, 5*SIZEOF_ARG(t9)
b arg6_next
arg6_doublep:
l.d $f17, 5*SIZEOF_ARG(t9)
arg6_next:
add t4, t6, 0
SRL t4, 6*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg7_floatp
REG_L a6, 6*SIZEOF_ARG(t9)
b arg7_next
arg7_floatp:
bne t4, FFI_TYPE_FLOAT, arg7_doublep
l.s $f18, 6*SIZEOF_ARG(t9)
b arg7_next
arg7_doublep:
l.d $f18, 6*SIZEOF_ARG(t9)
arg7_next:
add t4, t6, 0
SRL t4, 7*FFI_FLAG_BITS
and t4, ((1<<FFI_FLAG_BITS)-1)
bnez t4, arg8_floatp
REG_L a7, 7*SIZEOF_ARG(t9)
b arg8_next
arg8_floatp:
bne t4, FFI_TYPE_FLOAT, arg8_doublep
l.s $f19, 7*SIZEOF_ARG(t9)
b arg8_next
arg8_doublep:
l.d $f19, 7*SIZEOF_ARG(t9)
arg8_next:
callit:
# Load the function pointer
REG_L t9, 5*SIZEOF_ARG($fp)
# If the return value pointer is NULL, assume no return value.
REG_L t5, 4*SIZEOF_ARG($fp)
beqz t5, noretval
# Shift the return type flag over
SRL t6, 8*FFI_FLAG_BITS
bne t6, FFI_TYPE_INT, retfloat
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
REG_S v0, 0(t4)
b epilogue
retfloat:
bne t6, FFI_TYPE_FLOAT, retdouble
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
s.s $f0, 0(t4)
b epilogue
retdouble:
bne t6, FFI_TYPE_DOUBLE, retstruct_d
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
s.d $f0, 0(t4)
b epilogue
retstruct_d:
bne t6, FFI_TYPE_STRUCT_D, retstruct_f
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
s.d $f0, 0(t4)
b epilogue
retstruct_f:
bne t6, FFI_TYPE_STRUCT_F, retstruct_d_d
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
s.s $f0, 0(t4)
b epilogue
retstruct_d_d:
bne t6, FFI_TYPE_STRUCT_DD, retstruct_f_f
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
s.d $f0, 0(t4)
s.d $f2, 8(t4)
b epilogue
retstruct_f_f:
bne t6, FFI_TYPE_STRUCT_FF, retstruct_d_f
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
s.s $f0, 0(t4)
s.s $f2, 4(t4)
b epilogue
retstruct_d_f:
bne t6, FFI_TYPE_STRUCT_DF, retstruct_f_d
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
s.d $f0, 0(t4)
s.s $f2, 8(t4)
b epilogue
retstruct_f_d:
bne t6, FFI_TYPE_STRUCT_FD, retstruct_small
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
s.s $f0, 0(t4)
s.d $f2, 8(t4)
b epilogue
retstruct_small:
bne t6, FFI_TYPE_STRUCT_SMALL, retstruct_small2
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
REG_S v0, 0(t4)
b epilogue
retstruct_small2:
bne t6, FFI_TYPE_STRUCT_SMALL2, retstruct
jal t9
REG_L t4, 4*SIZEOF_ARG($fp)
REG_S v0, 0(t4)
REG_S v1, 8(t4)
b epilogue
retstruct:
noretval:
jal t9
# Epilogue
epilogue:
move $sp, $fp
REG_L $fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp) # Restore frame pointer
REG_L ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp) # Restore return address
ADDU $sp, SIZEOF_FRAME # Fix stack pointer
j ra
.end ffi_call_N32
#endif
+173
View File
@@ -0,0 +1,173 @@
/* -----------------------------------------------------------------------
o32.S - Copyright (c) 1996, 1998, 2001 Red Hat, Inc.
MIPS Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#include <ffi_private.h>
#include <mips/mips.h>
/* Only build this code if we are compiling for o32 */
#if defined(FFI_MIPS_O32)
#define callback a0
#define bytes a2
#define flags a3
#define SIZEOF_FRAME ( 4 * SIZEOF_ARG + 2 * SIZEOF_ARG )
.text
.align 2
.globl ffi_call_O32
.ent ffi_call_O32
ffi_call_O32:
# Prologue
SUBU $sp, SIZEOF_FRAME # Frame size
REG_S $fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp) # Save frame pointer
REG_S ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp) # Save return address
move $fp, $sp
move t9, callback # callback function pointer
REG_S flags, SIZEOF_FRAME + 3*SIZEOF_ARG($fp) # flags
# Allocate at least 4 words in the argstack
move v0, bytes
bge bytes, 4 * SIZEOF_ARG, bigger
LI v0, 4 * SIZEOF_ARG
b sixteen
bigger:
ADDU t0, v0, 2 * SIZEOF_ARG -1 # make sure it is aligned
and v0, t0, -2 * SIZEOF_ARG # to an 8 byte boundry
sixteen:
SUBU $sp, $sp, v0 # move the stack pointer to reflect the
# arg space
ADDU a0, $sp, 4 * SIZEOF_ARG
ADDU a3, $fp, SIZEOF_FRAME + 3*SIZEOF_ARG
jal t9
REG_L t0, SIZEOF_FRAME + 3*SIZEOF_ARG($fp) # load the flags word
add t2, t0, 0 # and copy it into t2
and t0, ((1<<4)-1) # mask out the return type
SRL t2, 4 # shift our arg info
ADDU $sp, $sp, 4 * SIZEOF_ARG # adjust $sp to new args
bnez t0, pass_d # make it quick for int
REG_L a0, 0*SIZEOF_ARG($sp) # just go ahead and load the
REG_L a1, 1*SIZEOF_ARG($sp) # four regs.
REG_L a2, 2*SIZEOF_ARG($sp)
REG_L a3, 3*SIZEOF_ARG($sp)
b call_it
pass_d:
bne t0, FFI_ARGS_D, pass_f
l.d $f12, 0*SIZEOF_ARG($sp) # load $fp regs from args
REG_L a2, 2*SIZEOF_ARG($sp) # passing a double
REG_L a3, 3*SIZEOF_ARG($sp)
b call_it
pass_f:
bne t0, FFI_ARGS_F, pass_d_d
l.s $f12, 0*SIZEOF_ARG($sp) # load $fp regs from args
REG_L a1, 1*SIZEOF_ARG($sp) # passing a float
REG_L a2, 2*SIZEOF_ARG($sp)
REG_L a3, 3*SIZEOF_ARG($sp)
b call_it
pass_d_d:
bne t0, FFI_ARGS_DD, pass_f_f
l.d $f12, 0*SIZEOF_ARG($sp) # load $fp regs from args
l.d $f14, 2*SIZEOF_ARG($sp) # passing two doubles
b call_it
pass_f_f:
bne t0, FFI_ARGS_FF, pass_d_f
l.s $f12, 0*SIZEOF_ARG($sp) # load $fp regs from args
l.s $f14, 1*SIZEOF_ARG($sp) # passing two floats
REG_L a2, 2*SIZEOF_ARG($sp)
REG_L a3, 3*SIZEOF_ARG($sp)
b call_it
pass_d_f:
bne t0, FFI_ARGS_DF, pass_f_d
l.d $f12, 0*SIZEOF_ARG($sp) # load $fp regs from args
l.s $f14, 2*SIZEOF_ARG($sp) # passing double and float
REG_L a3, 3*SIZEOF_ARG($sp)
b call_it
pass_f_d:
# assume that the only other combination must be float then double
# bne t0, FFI_ARGS_F_D, call_it
l.s $f12, 0*SIZEOF_ARG($sp) # load $fp regs from args
l.d $f14, 2*SIZEOF_ARG($sp) # passing double and float
call_it:
# Load the function pointer
REG_L t9, SIZEOF_FRAME + 5*SIZEOF_ARG($fp)
# If the return value pointer is NULL, assume no return value.
REG_L t1, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)
beqz t1, noretval
bne t2, FFI_TYPE_INT, retfloat
jal t9
REG_L t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)
REG_S v0, 0(t0)
b epilogue
retfloat:
bne t2, FFI_TYPE_FLOAT, retdouble
jal t9
REG_L t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)
s.s $f0, 0(t0)
b epilogue
retdouble:
bne t2, FFI_TYPE_DOUBLE, noretval
jal t9
REG_L t0, SIZEOF_FRAME + 4*SIZEOF_ARG($fp)
s.d $f0, 0(t0)
b epilogue
noretval:
jal t9
# Epilogue
epilogue:
move $sp, $fp
REG_L $fp, SIZEOF_FRAME - 2*SIZEOF_ARG($sp) # Restore frame pointer
REG_L ra, SIZEOF_FRAME - 1*SIZEOF_ARG($sp) # Restore return address
ADDU $sp, SIZEOF_FRAME # Fix stack pointer
j ra
.end ffi_call_O32
#endif
+128
View File
@@ -0,0 +1,128 @@
/* -----------------------------------------------------------------------
asm.h - Copyright (c) 1998 Geoffrey Keating
PowerPC Assembly glue.
$Id: asm.h,v 1.1 2001/08/02 19:33:38 orph Exp $
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define ASM_GLOBAL_DIRECTIVE .globl
#define C_SYMBOL_NAME(name) name
/* Macro for a label. */
#ifdef __STDC__
#define C_LABEL(name) name##:
#else
#define C_LABEL(name) name/**/:
#endif
/* This seems to always be the case on PPC. */
#define ALIGNARG(log2) log2
/* For ELF we need the `.type' directive to make shared libs work right. */
#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
#define ASM_SIZE_DIRECTIVE(name) .size name,.-name
/* If compiled for profiling, call `_mcount' at the start of each function. */
#ifdef PROF
/* The mcount code relies on a the return address being on the stack
to locate our caller and so it can restore it; so store one just
for its benefit. */
#ifdef PIC
#define CALL_MCOUNT \
.pushsection; \
.section ".data"; \
.align ALIGNARG(2); \
0:.long 0; \
.previous; \
mflr %r0; \
stw %r0,4(%r1); \
bl _GLOBAL_OFFSET_TABLE_@local-4; \
mflr %r11; \
lwz %r0,0b@got(%r11); \
bl JUMPTARGET(_mcount);
#else /* PIC */
#define CALL_MCOUNT \
.section ".data"; \
.align ALIGNARG(2); \
0:.long 0; \
.previous; \
mflr %r0; \
lis %r11,0b@ha; \
stw %r0,4(%r1); \
addi %r0,%r11,0b@l; \
bl JUMPTARGET(_mcount);
#endif /* PIC */
#else /* PROF */
#define CALL_MCOUNT /* Do nothing. */
#endif /* PROF */
#define ENTRY(name) \
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
.align ALIGNARG(2); \
C_LABEL(name) \
CALL_MCOUNT
#define EALIGN_W_0 /* No words to insert. */
#define EALIGN_W_1 nop
#define EALIGN_W_2 nop;nop
#define EALIGN_W_3 nop;nop;nop
#define EALIGN_W_4 EALIGN_W_3;nop
#define EALIGN_W_5 EALIGN_W_4;nop
#define EALIGN_W_6 EALIGN_W_5;nop
#define EALIGN_W_7 EALIGN_W_6;nop
/* EALIGN is like ENTRY, but does alignment to 'words'*4 bytes
past a 2^align boundary. */
#ifdef PROF
#define EALIGN(name, alignt, words) \
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
.align ALIGNARG(2); \
C_LABEL(name) \
CALL_MCOUNT \
b 0f; \
.align ALIGNARG(alignt); \
EALIGN_W_##words; \
0:
#else /* PROF */
#define EALIGN(name, alignt, words) \
ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
.align ALIGNARG(alignt); \
EALIGN_W_##words; \
C_LABEL(name)
#endif
#define END(name) \
ASM_SIZE_DIRECTIVE(name)
#ifdef PIC
#define JUMPTARGET(name) name##@plt
#else
#define JUMPTARGET(name) name
#endif
/* Local labels stripped out by the linker. */
#define L(x) .L##x
+680
View File
@@ -0,0 +1,680 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1998 Geoffrey Keating
PowerPC Foreign Function Interface
$Id: ffi.c,v 1.1 2001/08/02 19:31:55 orph Exp $
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
#include <stdio.h>
extern void ffi_closure_SYSV(void);
enum {
/* The assembly depends on these exact flags. */
FLAG_RETURNS_NOTHING = 1 << (31-30), /* These go in cr7 */
FLAG_RETURNS_FP = 1 << (31-29),
FLAG_RETURNS_64BITS = 1 << (31-28),
FLAG_ARG_NEEDS_COPY = 1 << (31- 7),
FLAG_FP_ARGUMENTS = 1 << (31- 6), /* cr1.eq; specified by ABI */
FLAG_4_GPR_ARGUMENTS = 1 << (31- 5),
FLAG_RETVAL_REFERENCE = 1 << (31- 4)
};
/* About the SYSV ABI. */
enum {
NUM_GPR_ARG_REGISTERS = 8,
NUM_FPR_ARG_REGISTERS = 8
};
enum { ASM_NEEDS_REGISTERS = 4 };
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments.
The stack layout we want looks like this:
| Return address from ffi_call_SYSV 4bytes | higher addresses
|--------------------------------------------|
| Previous backchain pointer 4 | stack pointer here
|--------------------------------------------|<+ <<< on entry to
| Saved r28-r31 4*4 | | ffi_call_SYSV
|--------------------------------------------| |
| GPR registers r3-r10 8*4 | | ffi_call_SYSV
|--------------------------------------------| |
| FPR registers f1-f8 (optional) 8*8 | |
|--------------------------------------------| | stack |
| Space for copied structures | | grows |
|--------------------------------------------| | down V
| Parameters that didn't fit in registers | |
|--------------------------------------------| | lower addresses
| Space for callee's LR 4 | |
|--------------------------------------------| | stack pointer here
| Current backchain pointer 4 |-/ during
|--------------------------------------------| <<< ffi_call_SYSV
*/
/*@-exportheader@*/
void ffi_prep_args(extended_cif *ecif, unsigned *const stack)
/*@=exportheader@*/
{
const unsigned bytes = ecif->cif->bytes;
const unsigned flags = ecif->cif->flags;
/* 'stacktop' points at the previous backchain pointer. */
unsigned *const stacktop = stack + (ecif->cif->bytes / sizeof(unsigned));
/* 'gpr_base' points at the space for gpr3, and grows upwards as
we use GPR registers. */
unsigned *gpr_base = stacktop - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
int intarg_count = 0;
/* 'fpr_base' points at the space for fpr1, and grows upwards as
we use FPR registers. */
double *fpr_base = (double *)gpr_base - NUM_FPR_ARG_REGISTERS;
int fparg_count = 0;
/* 'copy_space' grows down as we put structures in it. It should
stay 16-byte aligned. */
char *copy_space = ((flags & FLAG_FP_ARGUMENTS)
? (char *)fpr_base
: (char *)gpr_base);
/* 'next_arg' grows up as we put parameters in it. */
unsigned *next_arg = stack + 2;
int i;
ffi_type **ptr;
double double_tmp;
void **p_argv;
size_t struct_copy_size;
unsigned gprvalue;
/* Check that everything starts aligned properly. */
FFI_ASSERT(((unsigned)(char *)stack & 0xF) == 0);
FFI_ASSERT(((unsigned)(char *)copy_space & 0xF) == 0);
FFI_ASSERT(((unsigned)(char *)stacktop & 0xF) == 0);
FFI_ASSERT((bytes & 0xF) == 0);
FFI_ASSERT(copy_space >= (char *)next_arg);
/* Deal with return values that are actually pass-by-reference. */
if (flags & FLAG_RETVAL_REFERENCE)
{
*gpr_base++ = (unsigned)(char *)ecif->rvalue;
intarg_count++;
}
/* Now for the arguments. */
p_argv = ecif->avalue;
for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
i > 0;
i--, ptr++, p_argv++)
{
switch ((*ptr)->type)
{
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
if ((*ptr)->type == FFI_TYPE_FLOAT)
double_tmp = *(float *)*p_argv;
else
double_tmp = *(double *)*p_argv;
if (fparg_count >= NUM_FPR_ARG_REGISTERS)
{
if (intarg_count%2 != 0)
{
intarg_count++;
next_arg++;
}
*(double *)next_arg = double_tmp;
next_arg += 2;
}
else
*fpr_base++ = double_tmp;
fparg_count++;
FFI_ASSERT(flags & FLAG_FP_ARGUMENTS);
break;
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
intarg_count++;
if (intarg_count >= NUM_GPR_ARG_REGISTERS)
{
if (intarg_count%2 != 0)
{
intarg_count++;
next_arg++;
}
*(long long *)next_arg = *(long long *)*p_argv;
next_arg += 2;
}
else
{
/* whoops: abi states only certain register pairs
* can be used for passing long long int
* specifically (r3,r4), (r5,r6), (r7,r8),
* (r9,r10) and if next arg is long long but
* not correct starting register of pair then skip
* until the proper starting register
*/
if (intarg_count%2 != 0)
{
intarg_count ++;
gpr_base++;
}
*(long long *)gpr_base = *(long long *)*p_argv;
gpr_base += 2;
}
intarg_count += 2;
break;
case FFI_TYPE_STRUCT:
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
struct_copy_size = ((*ptr)->size + 15) & ~0xF;
copy_space -= struct_copy_size;
memcpy(copy_space, (char *)*p_argv, (*ptr)->size);
gprvalue = (unsigned)copy_space;
FFI_ASSERT(copy_space > (char *)next_arg);
FFI_ASSERT(flags & FLAG_ARG_NEEDS_COPY);
goto putgpr;
case FFI_TYPE_UINT8:
gprvalue = *(unsigned char *)*p_argv;
goto putgpr;
case FFI_TYPE_SINT8:
gprvalue = *(signed char *)*p_argv;
goto putgpr;
case FFI_TYPE_UINT16:
gprvalue = *(unsigned short *)*p_argv;
goto putgpr;
case FFI_TYPE_SINT16:
gprvalue = *(signed short *)*p_argv;
goto putgpr;
case FFI_TYPE_INT:
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
case FFI_TYPE_POINTER:
gprvalue = *(unsigned *)*p_argv;
putgpr:
if (intarg_count >= NUM_GPR_ARG_REGISTERS)
*next_arg++ = gprvalue;
else
*gpr_base++ = gprvalue;
intarg_count++;
break;
}
}
/* Check that we didn't overrun the stack... */
FFI_ASSERT(copy_space >= (char *)next_arg);
FFI_ASSERT(gpr_base <= stacktop - ASM_NEEDS_REGISTERS);
FFI_ASSERT((unsigned *)fpr_base
<= stacktop - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
FFI_ASSERT(flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
}
/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
/* All this is for the SYSV ABI. */
int i;
ffi_type **ptr;
unsigned bytes;
int fparg_count = 0, intarg_count = 0;
unsigned flags = 0;
unsigned struct_copy_size = 0;
/* All the machine-independent calculation of cif->bytes will be wrong.
Redo the calculation for SYSV. */
/* Space for the frame pointer, callee's LR, and the asm's temp regs. */
bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof(int);
/* Space for the GPR registers. */
bytes += NUM_GPR_ARG_REGISTERS * sizeof(int);
/* Return value handling. The rules are as follows:
- 32-bit (or less) integer values are returned in gpr3;
- Structures of size <= 4 bytes also returned in gpr3;
- 64-bit integer values and structures between 5 and 8 bytes are returned
in gpr3 and gpr4;
- Single/double FP values are returned in fpr1;
- Larger structures and long double (if not equivalent to double) values
are allocated space and a pointer is passed as the first argument. */
switch (cif->rtype->type)
{
case FFI_TYPE_DOUBLE:
flags |= FLAG_RETURNS_64BITS;
/* Fall through. */
case FFI_TYPE_FLOAT:
flags |= FLAG_RETURNS_FP;
break;
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
flags |= FLAG_RETURNS_64BITS;
break;
case FFI_TYPE_STRUCT:
if (cif->abi != FFI_GCC_SYSV)
if (cif->rtype->size <= 4)
break;
else if (cif->rtype->size <= 8)
{
flags |= FLAG_RETURNS_64BITS;
break;
}
/* else fall through. */
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
intarg_count++;
flags |= FLAG_RETVAL_REFERENCE;
/* Fall through. */
case FFI_TYPE_VOID:
flags |= FLAG_RETURNS_NOTHING;
break;
default:
/* Returns 32-bit integer, or similar. Nothing to do here. */
break;
}
/* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
goes on the stack. Structures and long doubles (if not equivalent
to double) are passed as a pointer to a copy of the structure.
Stuff on the stack needs to keep proper alignment. */
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
{
switch ((*ptr)->type)
{
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
fparg_count++;
/* If this FP arg is going on the stack, it must be
8-byte-aligned. */
if (fparg_count > NUM_FPR_ARG_REGISTERS
&& intarg_count%2 != 0)
intarg_count++;
break;
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
/* 'long long' arguments are passed as two words, but
either both words must fit in registers or both go
on the stack. If they go on the stack, they must
be 8-byte-aligned. */
if (intarg_count == NUM_GPR_ARG_REGISTERS-1
|| intarg_count >= NUM_GPR_ARG_REGISTERS && intarg_count%2 != 0)
intarg_count++;
intarg_count += 2;
break;
case FFI_TYPE_STRUCT:
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
/* We must allocate space for a copy of these to enforce
pass-by-value. Pad the space up to a multiple of 16
bytes (the maximum alignment required for anything under
the SYSV ABI). */
struct_copy_size += ((*ptr)->size + 15) & ~0xF;
/* Fall through (allocate space for the pointer). */
default:
/* Everything else is passed as a 4-byte word in a GPR, either
the object itself or a pointer to it. */
intarg_count++;
break;
}
}
if (fparg_count != 0)
flags |= FLAG_FP_ARGUMENTS;
if (intarg_count > 4)
flags |= FLAG_4_GPR_ARGUMENTS;
if (struct_copy_size != 0)
flags |= FLAG_ARG_NEEDS_COPY;
/* Space for the FPR registers, if needed. */
if (fparg_count != 0)
bytes += NUM_FPR_ARG_REGISTERS * sizeof(double);
/* Stack space. */
if (intarg_count > NUM_GPR_ARG_REGISTERS)
bytes += (intarg_count - NUM_GPR_ARG_REGISTERS) * sizeof(int);
if (fparg_count > NUM_FPR_ARG_REGISTERS)
bytes += (fparg_count - NUM_FPR_ARG_REGISTERS) * sizeof(double);
/* The stack space allocated needs to be a multiple of 16 bytes. */
bytes = (bytes + 15) & ~0xF;
/* Add in the space for the copied structures. */
bytes += struct_copy_size;
cif->flags = flags;
cif->bytes = bytes;
return FFI_OK;
}
/*@-declundef@*/
/*@-exportheader@*/
extern void ffi_call_SYSV(/*@out@*/ extended_cif *,
unsigned, unsigned,
/*@out@*/ unsigned *,
void (*fn)());
/*@=declundef@*/
/*@=exportheader@*/
void ffi_call(/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
/*@out@*/ void *rvalue,
/*@dependent@*/ void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
/*@-sysunrecog@*/
ecif.rvalue = alloca(cif->rtype->size);
/*@=sysunrecog@*/
}
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_SYSV:
case FFI_GCC_SYSV:
/*@-usedef@*/
ffi_call_SYSV(&ecif, -cif->bytes,
cif->flags, ecif.rvalue, fn);
/*@=usedef@*/
break;
default:
FFI_ASSERT(0);
break;
}
}
static void flush_icache(char *, int);
ffi_status
ffi_prep_closure (ffi_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*, void*, void**, void*),
void *user_data)
{
unsigned int *tramp;
FFI_ASSERT (cif->abi == FFI_GCC_SYSV);
tramp = (unsigned int *) &closure->tramp[0];
tramp[0] = 0x7c0802a6; /* mflr r0 */
tramp[1] = 0x4800000d; /* bl 10 <trampoline_initial+0x10> */
tramp[4] = 0x7d6802a6; /* mflr r11 */
tramp[5] = 0x7c0803a6; /* mtlr r0 */
tramp[6] = 0x800b0000; /* lwz r0,0(r11) */
tramp[7] = 0x816b0004; /* lwz r11,4(r11) */
tramp[8] = 0x7c0903a6; /* mtctr r0 */
tramp[9] = 0x4e800420; /* bctr */
*(void **) &tramp[2] = (void *)ffi_closure_SYSV; /* function */
*(void **) &tramp[3] = (void *)closure; /* context */
closure->cif = cif;
closure->fun = fun;
closure->user_data = user_data;
/* Flush the icache. */
flush_icache(&closure->tramp[0],FFI_TRAMPOLINE_SIZE);
return FFI_OK;
}
#define MIN_CACHE_LINE_SIZE 8
static void flush_icache(char * addr1, int size)
{
int i;
char * addr;
for (i = 0; i < size; i += MIN_CACHE_LINE_SIZE) {
addr = addr1 + i;
__asm__ volatile ("icbi 0,%0;" "dcbf 0,%0;" : : "r"(addr) : "memory");
}
addr = addr1 + size - 1;
__asm__ volatile ("icbi 0,%0;" "dcbf 0,%0;" "sync;" "isync;" : : "r"(addr) : "memory");
}
int ffi_closure_helper_SYSV (ffi_closure*, void*, unsigned long*,
unsigned long*, unsigned long*);
/* Basically the trampoline invokes ffi_closure_SYSV, and on
* entry, r11 holds the address of the closure.
* After storing the registers that could possibly contain
* parameters to be passed into the stack frame and setting
* up space for a return value, ffi_closure_SYSV invokes the
* following helper function to do most of the work
*/
int
ffi_closure_helper_SYSV (ffi_closure* closure, void * rvalue,
unsigned long * pgr, unsigned long * pfr,
unsigned long * pst)
{
/* rvalue is the pointer to space for return value in closure assembly */
/* pgr is the pointer to where r3-r10 are stored in ffi_closure_SYSV */
/* pfr is the pointer to where f1-f8 are stored in ffi_closure_SYSV */
/* pst is the pointer to outgoing parameter stack in original caller */
void ** avalue;
ffi_type ** arg_types;
long i, avn;
long nf; /* number of floating registers already used */
long ng; /* number of general registers already used */
ffi_cif * cif;
double temp;
cif = closure->cif;
avalue = alloca(cif->nargs * sizeof(void *));
nf = 0;
ng = 0;
/* Copy the caller's structure return value address so that the closure
returns the data directly to the caller. */
if (cif->rtype->type == FFI_TYPE_STRUCT)
{
rvalue = *pgr;
ng++;
pgr++;
}
i = 0;
avn = cif->nargs;
arg_types = cif->arg_types;
/* Grab the addresses of the arguments from the stack frame. */
while (i < avn)
{
switch (arg_types[i]->type)
{
case FFI_TYPE_SINT8:
case FFI_TYPE_UINT8:
/* there are 8 gpr registers used to pass values */
if (ng < 8) {
avalue[i] = (((char *)pgr)+3);
ng++;
pgr++;
} else {
avalue[i] = (((char *)pst)+3);
pst++;
}
break;
case FFI_TYPE_SINT16:
case FFI_TYPE_UINT16:
/* there are 8 gpr registers used to pass values */
if (ng < 8) {
avalue[i] = (((char *)pgr)+2);
ng++;
pgr++;
} else {
avalue[i] = (((char *)pst)+2);
pst++;
}
break;
case FFI_TYPE_SINT32:
case FFI_TYPE_UINT32:
case FFI_TYPE_POINTER:
case FFI_TYPE_STRUCT:
/* there are 8 gpr registers used to pass values */
if (ng < 8) {
avalue[i] = pgr;
ng++;
pgr++;
} else {
avalue[i] = pst;
pst++;
}
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
/* passing long long ints are complex, they must
* be passed in suitable register pairs such as
* (r3,r4) or (r5,r6) or (r6,r7), or (r7,r8) or (r9,r10)
* and if the entire pair aren't available then the outgoing
* parameter stack is used for both but an alignment of 8
* must will be kept. So we must either look in pgr
* or pst to find the correct address for this type
* of parameter.
*/
if (ng < 7) {
if (ng & 0x01) {
/* skip r4, r6, r8 as starting points */
ng++;
pgr++;
}
avalue[i] = pgr;
ng+=2;
pgr+=2;
} else {
if (((long)pst) & 4) pst++;
avalue[i] = pst;
pst+=2;
}
break;
case FFI_TYPE_FLOAT:
/* unfortunately float values are stored as doubles
* in the ffi_closure_SYSV code (since we don't check
* the type in that routine). This is also true
* of floats passed on the outgoing parameter stack.
* Also, on the outgoing stack all values are aligned
* to 8
*
* Don't you just love the simplicity of this ABI!
*/
/* there are 8 64bit floating point registers */
if (nf < 8) {
temp = *(double*)pfr;
*(float*)pfr = (float)temp;
avalue[i] = pfr;
nf++;
pfr+=2;
} else {
/* FIXME? here we are really changing the values
* stored in the original calling routines outgoing
* parameter stack. This is probably a really
* naughty thing to do but...
*/
if (((long)pst) & 4) pst++;
temp = *(double*)pst;
*(float*)pst = (float)temp;
avalue[i] = pst;
nf++;
pst+=2;
}
break;
case FFI_TYPE_DOUBLE:
/* On the outgoing stack all values are aligned to 8 */
/* there are 8 64bit floating point registers */
if (nf < 8) {
avalue[i] = pfr;
nf++;
pfr+=2;
} else {
if (((long)pst) & 4) pst++;
avalue[i] = pst;
nf++;
pst+=2;
}
break;
default:
FFI_ASSERT(0);
}
i++;
}
(closure->fun) (cif, rvalue, avalue, closure->user_data);
/* Tell ffi_closure_osf how to perform return type promotions. */
return cif->rtype->type;
}
+148
View File
@@ -0,0 +1,148 @@
#define LIBFFI_ASM
#include <powerpc/asm.h>
.globl ffi_closure_helper_SYSV
ENTRY(ffi_closure_SYSV)
stwu %r1,-144(%r1)
mflr %r0
stw %r31,140(%r1)
stw %r0,148(%r1)
# we want to build up an areas for the parameters passed
# in registers (both floating point and integer)
# so first save gpr 3 to gpr 10 (aligned to 4)
stw %r3, 16(%r1)
stw %r4, 20(%r1)
stw %r5, 24(%r1)
stw %r6, 28(%r1)
stw %r7, 32(%r1)
stw %r8, 36(%r1)
stw %r9, 40(%r1)
stw %r10,44(%r1)
# next save fpr 1 to fpr 8 (aligned to 8)
stfd %f1, 48(%r1)
stfd %f2, 56(%r1)
stfd %f3, 64(%r1)
stfd %f4, 72(%r1)
stfd %f5, 80(%r1)
stfd %f6, 88(%r1)
stfd %f7, 96(%r1)
stfd %f8, 104(%r1)
# set up registers for the routine that actually does the work
# get the context pointer from the trampoline
mr %r3,%r11
# now load up the pointer to the result storage
addi %r4,%r1,112
# now load up the pointer to the saved gpr registers
addi %r5,%r1,16
# now load up the pointer to the saved fpr registers */
addi %r6,%r1,48
# now load up the pointer to the outgoing parameter
# stack in the previous frame
# i.e. the previous frame pointer + 8
addi %r7,%r1,152
# make the call
bl JUMPTARGET(ffi_closure_helper_SYSV)
# now r3 contains the return type
# so use it to look up in a table
# so we know how to deal with each type
# look up the proper starting point in table
# by using return type as offset
addi %r5,%r1,112 # get pointer to results area
addis %r4,0,.L60@ha # get address of jump table
addi %r4,%r4,.L60@l
slwi %r3,%r3,2 # now multiply return type by 4
lwzx %r3,%r4,%r3 # get the contents of that table value
add %r3,%r3,%r4 # add contents of table to table address
mtctr %r3
bctr # jump to it
.align 2
.L60:
.long .L44-.L60 # FFI_TYPE_VOID
.long .L50-.L60 # FFI_TYPE_INT
.long .L47-.L60 # FFI_TYPE_FLOAT
.long .L46-.L60 # FFI_TYPE_DOUBLE
.long .L46-.L60 # FFI_TYPE_LONGDOUBLE
.long .L56-.L60 # FFI_TYPE_UINT8
.long .L55-.L60 # FFI_TYPE_SINT8
.long .L58-.L60 # FFI_TYPE_UINT16
.long .L57-.L60 # FFI_TYPE_SINT16
.long .L50-.L60 # FFI_TYPE_UINT32
.long .L50-.L60 # FFI_TYPE_SINT32
.long .L48-.L60 # FFI_TYPE_UINT64
.long .L48-.L60 # FFI_TYPE_SINT64
.long .L44-.L60 # FFI_TYPE_STRUCT
.long .L50-.L60 # FFI_TYPE_POINTER
# case double
.L46:
lfd %f1,0(%r5)
b .L44
# case float
.L47:
lfs %f1,0(%r5)
b .L44
# case long long
.L48:
lwz %r3,0(%r5)
lwz %r4,4(%r5)
b .L44
# case default / int32 / pointer
.L50:
lwz %r3,0(%r5)
b .L44
# case signed int8
.L55:
addi %r5,%r5,3
lbz %r3,0(%r5)
extsb %r3,%r3
b .L44
# case unsigned int8
.L56:
addi %r5,%r5,3
lbz %r3,0(%r5)
b .L44
# case signed int16
.L57:
addi %r5,%r5,2
lhz %r3,0(%r5)
extsh %r3,%r3
b .L44
#case unsigned int16
.L58:
addi %r5,%r5,2
lhz %r3,0(%r5)
# case void / done
.L44:
lwz %r11,0(%r1)
lwz %r0,4(%r11)
mtlr %r0
lwz %r31,-4(%r11)
mr %r1,%r11
blr
END(ffi_closure_SYSV)
+119
View File
@@ -0,0 +1,119 @@
/* -----------------------------------------------------------------------
sysv.h - Copyright (c) 1998 Geoffrey Keating
PowerPC Assembly glue.
$Id: sysv.S,v 1.1 2001/08/02 19:31:55 orph Exp $
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#include <powerpc/asm.h>
.globl ffi_prep_args
ENTRY(ffi_call_SYSV)
/* Save the old stack pointer as AP. */
mr %r8,%r1
/* Allocate the stack space we need. */
stwux %r1,%r1,%r4
/* Save registers we use. */
mflr %r9
stw %r28,-16(%r8)
stw %r29,-12(%r8)
stw %r30, -8(%r8)
stw %r31, -4(%r8)
stw %r9, 4(%r8)
/* Save arguments over call... */
mr %r31,%r5 /* flags, */
mr %r30,%r6 /* rvalue, */
mr %r29,%r7 /* function address, */
mr %r28,%r8 /* our AP. */
/* Call ffi_prep_args. */
mr %r4,%r1
bl JUMPTARGET(ffi_prep_args)
/* Now do the call. */
/* Set up cr1 with bits 4-7 of the flags. */
mtcrf 0x40,%r31
/* Get the address to call into CTR. */
mtctr %r29
/* Load all those argument registers. */
lwz %r3,-16-(8*4)(%r28)
lwz %r4,-16-(7*4)(%r28)
lwz %r5,-16-(6*4)(%r28)
lwz %r6,-16-(5*4)(%r28)
bf- 5,1f
nop
lwz %r7,-16-(4*4)(%r28)
lwz %r8,-16-(3*4)(%r28)
lwz %r9,-16-(2*4)(%r28)
lwz %r10,-16-(1*4)(%r28)
nop
1:
/* Load all the FP registers. */
bf- 6,2f
lfd %f1,-16-(8*4)-(8*8)(%r28)
lfd %f2,-16-(8*4)-(7*8)(%r28)
lfd %f3,-16-(8*4)-(6*8)(%r28)
lfd %f4,-16-(8*4)-(5*8)(%r28)
nop
lfd %f5,-16-(8*4)-(4*8)(%r28)
lfd %f6,-16-(8*4)-(3*8)(%r28)
lfd %f7,-16-(8*4)-(2*8)(%r28)
lfd %f8,-16-(8*4)-(1*8)(%r28)
2:
/* Make the call. */
bctrl
/* Now, deal with the return value. */
mtcrf 0x01,%r31
bt- 30,L(done_return_value)
bt- 29,L(fp_return_value)
stw %r3,0(%r30)
bf+ 28,L(done_return_value)
stw %r4,4(%r30)
/* Fall through... */
L(done_return_value):
/* Restore the registers we used and return. */
lwz %r9, 4(%r28)
lwz %r31, -4(%r28)
mtlr %r9
lwz %r30, -8(%r28)
lwz %r29,-12(%r28)
lwz %r28,-16(%r28)
lwz %r1,0(%r1)
blr
L(fp_return_value):
bf 28,L(float_return_value)
stfd %f1,0(%r30)
b L(done_return_value)
L(float_return_value):
stfs %f1,0(%r30)
b L(done_return_value)
END(ffi_call_SYSV)
+146
View File
@@ -0,0 +1,146 @@
/* -----------------------------------------------------------------------
prep_cif.c - Copyright (c) 1996, 1998 Cygnus Solutions
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
/* Round up to SIZEOF_ARG. */
#define STACK_ARG_SIZE(x) ALIGN(x, SIZEOF_ARG)
/* Perform machine independent initialization of aggregate type
specifications. */
static ffi_status initialize_aggregate(/*@out@*/ ffi_type *arg)
{
ffi_type **ptr;
FFI_ASSERT(arg != NULL);
/*@-usedef@*/
FFI_ASSERT(arg->elements != NULL);
FFI_ASSERT(arg->size == 0);
FFI_ASSERT(arg->alignment == 0);
ptr = &(arg->elements[0]);
while ((*ptr) != NULL)
{
if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
return FFI_BAD_TYPEDEF;
/* Perform a sanity check on the argument type */
FFI_ASSERT(ffi_type_test((*ptr)));
arg->size = ALIGN(arg->size, (*ptr)->alignment);
arg->size += (*ptr)->size;
arg->alignment = (arg->alignment > (*ptr)->alignment) ?
arg->alignment : (*ptr)->alignment;
ptr++;
}
if (arg->size == 0)
return FFI_BAD_TYPEDEF;
else
return FFI_OK;
/*@=usedef@*/
}
/* Perform machine independent ffi_cif preparation, then call
machine dependent routine. */
ffi_status ffi_prep_cif(/*@out@*/ /*@partial@*/ ffi_cif *cif,
ffi_abi abi, unsigned int nargs,
/*@dependent@*/ /*@out@*/ /*@partial@*/ ffi_type *rtype,
/*@dependent@*/ ffi_type **atypes)
{
unsigned bytes = 0;
unsigned int i;
ffi_type **ptr;
FFI_ASSERT(cif != NULL);
FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi < FFI_LAST_ABI));
cif->abi = abi;
cif->arg_types = atypes;
cif->nargs = nargs;
cif->rtype = rtype;
cif->flags = 0;
/* Initialize the return type if necessary */
/*@-usedef@*/
if ((cif->rtype->size == 0) && (initialize_aggregate(cif->rtype) != FFI_OK))
return FFI_BAD_TYPEDEF;
/*@=usedef@*/
/* Perform a sanity check on the return type */
FFI_ASSERT(ffi_type_test(cif->rtype));
#ifndef M68K
/* Make space for the return structure pointer */
if (cif->rtype->type == FFI_TYPE_STRUCT
#ifdef __sparc__
&& (cif->abi != FFI_V9 || cif->rtype->size > 32)
#endif
)
bytes = STACK_ARG_SIZE(sizeof(void*));
#endif
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
{
/* Perform a sanity check on the argument type */
FFI_ASSERT(ffi_type_test(*ptr));
/* Initialize any uninitialized aggregate type definitions */
if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
return FFI_BAD_TYPEDEF;
#ifdef __sparc__
if (((*ptr)->type == FFI_TYPE_STRUCT
&& ((*ptr)->size > 16 || cif->abi != FFI_V9))
|| ((*ptr)->type == FFI_TYPE_LONGDOUBLE
&& cif->abi != FFI_V9))
bytes += sizeof(void*);
else
#endif
{
/* Add any padding if necessary */
if (((*ptr)->alignment - 1) & bytes)
bytes = ALIGN(bytes, (*ptr)->alignment);
bytes += STACK_ARG_SIZE((*ptr)->size);
}
}
cif->bytes = bytes;
/* Perform machine dependent cif processing */
return ffi_prep_cif_machdep(cif);
}
+240
View File
@@ -0,0 +1,240 @@
/* -----------------------------------------------------------------------
raw_api.c - Copyright (c) 1999 Cygnus Solutions
Author: Kresten Krab Thorup <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
/* This file defines generic functions for use with the raw api. */
#include <ffi.h>
#include <ffi_private.h>
#if !FFI_NO_RAW_API
size_t
ffi_raw_size (ffi_cif *cif)
{
size_t result = 0;
int i;
ffi_type **at = cif->arg_types;
for (i = cif->nargs-1; i >= 0; i--, at++)
{
#if !FFI_NO_STRUCTS
if ((*at)->type == FFI_TYPE_STRUCT)
result += ALIGN (sizeof (void*), SIZEOF_ARG);
else
#endif
result += ALIGN ((*at)->size, SIZEOF_ARG);
}
return result;
}
void
ffi_raw_to_ptrarray (ffi_cif *cif, ffi_raw *raw, void **args)
{
unsigned i;
ffi_type **tp = cif->arg_types;
#if WORDS_BIGENDIAN
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
switch ((*tp)->type)
{
case FFI_TYPE_UINT8:
case FFI_TYPE_SINT8:
*args = (void*) ((char*)(raw++) + SIZEOF_ARG - 1);
break;
case FFI_TYPE_UINT16:
case FFI_TYPE_SINT16:
*args = (void*) ((char*)(raw++) + SIZEOF_ARG - 2);
break;
#if SIZEOF_ARG >= 4
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
*args = (void*) ((char*)(raw++) + SIZEOF_ARG - 4);
break;
#endif
#if !FFI_NO_STRUCTS
case FFI_TYPE_STRUCT:
*args = (raw++)->ptr;
break;
#endif
case FFI_TYPE_POINTER:
*args = (void*) &(raw++)->ptr;
break;
default:
*args = raw;
raw += ALIGN ((*tp)->size, SIZEOF_ARG) / SIZEOF_ARG;
}
}
#else /* WORDS_BIGENDIAN */
#if !PDP
/* then assume little endian */
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
#if !FFI_NO_STRUCTS
if ((*tp)->type == FFI_TYPE_STRUCT)
{
*args = (raw++)->ptr;
}
else
#endif
{
*args = (void*) raw;
raw += ALIGN ((*tp)->size, sizeof (void*)) / sizeof (void*);
}
}
#else
#error "pdp endian not supported"
#endif /* ! PDP */
#endif /* WORDS_BIGENDIAN */
}
void
ffi_ptrarray_to_raw (ffi_cif *cif, void **args, ffi_raw *raw)
{
unsigned i;
ffi_type **tp = cif->arg_types;
for (i = 0; i < cif->nargs; i++, tp++, args++)
{
switch ((*tp)->type)
{
case FFI_TYPE_UINT8:
(raw++)->uint = *(UINT8*) (*args);
break;
case FFI_TYPE_SINT8:
(raw++)->sint = *(SINT8*) (*args);
break;
case FFI_TYPE_UINT16:
(raw++)->uint = *(UINT16*) (*args);
break;
case FFI_TYPE_SINT16:
(raw++)->sint = *(SINT16*) (*args);
break;
#if SIZEOF_ARG >= 4
case FFI_TYPE_UINT32:
(raw++)->uint = *(UINT32*) (*args);
break;
case FFI_TYPE_SINT32:
(raw++)->sint = *(SINT32*) (*args);
break;
#endif
#if !FFI_NO_STRUCTS
case FFI_TYPE_STRUCT:
(raw++)->ptr = *args;
break;
#endif
case FFI_TYPE_POINTER:
(raw++)->ptr = **(void***) args;
break;
default:
memcpy ((void*) raw->data, (void*)*args, (*tp)->size);
raw += ALIGN ((*tp)->size, SIZEOF_ARG) / SIZEOF_ARG;
}
}
}
#if !FFI_NATIVE_RAW_API
/* This is a generic definition of ffi_raw_call, to be used if the
* native system does not provide a machine-specific implementation.
* Having this, allows code to be written for the raw API, without
* the need for system-specific code to handle input in that format;
* these following couple of functions will handle the translation forth
* and back automatically. */
void ffi_raw_call (/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
/*@out@*/ void *rvalue,
/*@dependent@*/ ffi_raw *raw)
{
void **avalue = (void**) alloca (cif->nargs * sizeof (void*));
ffi_raw_to_ptrarray (cif, raw, avalue);
ffi_call (cif, fn, rvalue, avalue);
}
#if FFI_CLOSURES /* base system provides closures */
static void
ffi_translate_args (ffi_cif *cif, void *rvalue,
void **avalue, void *user_data)
{
ffi_raw *raw = (ffi_raw*)alloca (ffi_raw_size (cif));
ffi_raw_closure *cl = (ffi_raw_closure*)user_data;
ffi_ptrarray_to_raw (cif, avalue, raw);
(*cl->fun) (cif, rvalue, raw, cl->user_data);
}
/* Again, here is the generic version of ffi_prep_raw_closure, which
* will install an intermediate "hub" for translation of arguments from
* the pointer-array format, to the raw format */
ffi_status
ffi_prep_raw_closure (ffi_raw_closure* cl,
ffi_cif *cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data)
{
ffi_status status;
status = ffi_prep_closure ((ffi_closure*) cl,
cif,
&ffi_translate_args,
(void*)cl);
if (status == FFI_OK)
{
cl->fun = fun;
cl->user_data = user_data;
}
return status;
}
#endif /* FFI_CLOSURES */
#endif /* !FFI_NATIVE_RAW_API */
#endif /* !FFI_NO_RAW_API */
+589
View File
@@ -0,0 +1,589 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 2000 Software AG
S390 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
/*====================================================================*/
/* Includes */
/* -------- */
/*====================================================================*/
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
#include <stdio.h>
/*====================== End of Includes =============================*/
/*====================================================================*/
/* Defines */
/* ------- */
/*====================================================================*/
#define MAX_GPRARGS 5 /* Max. no. of GPR available */
#define MAX_FPRARGS 2 /* Max. no. of FPR available */
#define STR_GPR 1 /* Structure will fit in 1 or 2 GPR */
#define STR_FPR 2 /* Structure will fit in a FPR */
#define STR_STACK 3 /* Structure needs to go on stack */
/*===================== End of Defines ===============================*/
/*====================================================================*/
/* Types */
/* ----- */
/*====================================================================*/
typedef struct stackLayout
{
int *backChain;
int *endOfStack;
int glue[2];
int scratch[2];
int gprArgs[MAX_GPRARGS];
int notUsed;
union
{
float f;
double d;
} fprArgs[MAX_FPRARGS];
int unUsed[8];
int outArgs[100];
} stackLayout;
/*======================== End of Types ==============================*/
/*====================================================================*/
/* Prototypes */
/* ---------- */
/*====================================================================*/
void ffi_prep_args(stackLayout *, extended_cif *);
static int ffi_check_struct(ffi_type *, unsigned int *);
static void ffi_insert_int(int, stackLayout *, int *, int *);
static void ffi_insert_int64(long long, stackLayout *, int *, int *);
static void ffi_insert_double(double, stackLayout *, int *, int *);
/*====================== End of Prototypes ===========================*/
/*====================================================================*/
/* Externals */
/* --------- */
/*====================================================================*/
extern void ffi_call_SYSV(void (*)(stackLayout *, extended_cif *),
extended_cif *,
unsigned, unsigned,
unsigned *,
void (*fn)());
/*====================== End of Externals ============================*/
/*====================================================================*/
/* */
/* Name - ffi_check_struct. */
/* */
/* Function - Determine if a structure can be passed within a */
/* general or floating point register. */
/* */
/*====================================================================*/
int
ffi_check_struct(ffi_type *arg, unsigned int *strFlags)
{
ffi_type *element;
int i_Element;
for (i_Element = 0; arg->elements[i_Element]; i_Element++) {
element = arg->elements[i_Element];
switch (element->type) {
case FFI_TYPE_DOUBLE :
*strFlags |= STR_FPR;
break;
case FFI_TYPE_STRUCT :
*strFlags |= ffi_check_struct(element, strFlags);
break;
default :
*strFlags |= STR_GPR;
}
}
return (*strFlags);
}
/*======================== End of Routine ============================*/
/*====================================================================*/
/* */
/* Name - ffi_insert_int. */
/* */
/* Function - Insert an integer parameter in a register if there are */
/* spares else on the stack. */
/* */
/*====================================================================*/
void
ffi_insert_int(int gprValue, stackLayout *stack,
int *intArgC, int *outArgC)
{
if (*intArgC < MAX_GPRARGS) {
stack->gprArgs[*intArgC] = gprValue;
*intArgC += 1;
}
else {
stack->outArgs[*outArgC++] = gprValue;
*outArgC += 1;
}
}
/*======================== End of Routine ============================*/
/*====================================================================*/
/* */
/* Name - ffi_insert_int64. */
/* */
/* Function - Insert a long long parameter in registers if there are */
/* spares else on the stack. */
/* */
/*====================================================================*/
void
ffi_insert_int64(long long llngValue, stackLayout *stack,
int *intArgC, int *outArgC)
{
if (*intArgC < (MAX_GPRARGS-1)) {
memcpy(&stack->gprArgs[*intArgC],
&llngValue, sizeof(long long));
*intArgC += 2;
}
else {
memcpy(&stack->outArgs[*outArgC],
&llngValue, sizeof(long long));
*outArgC += 2;
}
}
/*======================== End of Routine ============================*/
/*====================================================================*/
/* */
/* Name - ffi_insert_double. */
/* */
/* Function - Insert a double parameter in a FP register if there is */
/* a spare else on the stack. */
/* */
/*====================================================================*/
void
ffi_insert_double(double dblValue, stackLayout *stack,
int *fprArgC, int *outArgC)
{
if (*fprArgC < MAX_FPRARGS) {
stack->fprArgs[*fprArgC].d = dblValue;
*fprArgC += 1;
}
else {
memcpy(&stack->outArgs[*outArgC],
&dblValue,sizeof(double));
*outArgC += 2;
}
}
/*======================== End of Routine ============================*/
/*====================================================================*/
/* */
/* Name - ffi_prep_args. */
/* */
/* Function - Prepare parameters for call to function. */
/* */
/* ffi_prep_args is called by the assembly routine once stack space */
/* has been allocated for the function's arguments. */
/* */
/* The stack layout we want looks like this: */
/* *------------------------------------------------------------* */
/* | 0 | Back chain (a 0 here signifies end of back chain) | */
/* +--------+---------------------------------------------------+ */
/* | 4 | EOS (end of stack, not used on Linux for S390) | */
/* +--------+---------------------------------------------------+ */
/* | 8 | Glue used in other linkage formats | */
/* +--------+---------------------------------------------------+ */
/* | 12 | Glue used in other linkage formats | */
/* +--------+---------------------------------------------------+ */
/* | 16 | Scratch area | */
/* +--------+---------------------------------------------------+ */
/* | 20 | Scratch area | */
/* +--------+---------------------------------------------------+ */
/* | 24 | GPR parameter register 1 | */
/* +--------+---------------------------------------------------+ */
/* | 28 | GPR parameter register 2 | */
/* +--------+---------------------------------------------------+ */
/* | 32 | GPR parameter register 3 | */
/* +--------+---------------------------------------------------+ */
/* | 36 | GPR parameter register 4 | */
/* +--------+---------------------------------------------------+ */
/* | 40 | GPR parameter register 5 | */
/* +--------+---------------------------------------------------+ */
/* | 44 | Unused | */
/* +--------+---------------------------------------------------+ */
/* | 48 | FPR parameter register 1 | */
/* +--------+---------------------------------------------------+ */
/* | 56 | FPR parameter register 2 | */
/* +--------+---------------------------------------------------+ */
/* | 64 | Unused | */
/* +--------+---------------------------------------------------+ */
/* | 96 | Outgoing args (length x) | */
/* +--------+---------------------------------------------------+ */
/* | 96+x | Copy area for structures (length y) | */
/* +--------+---------------------------------------------------+ */
/* | 96+x+y | Possible stack alignment | */
/* *------------------------------------------------------------* */
/* */
/*====================================================================*/
void
ffi_prep_args(stackLayout *stack, extended_cif *ecif)
{
const unsigned bytes = ecif->cif->bytes;
const unsigned flags = ecif->cif->flags;
/*----------------------------------------------------------*/
/* Pointer to the copy area on stack for structures */
/*----------------------------------------------------------*/
char *copySpace = (char *) stack + bytes + sizeof(stackLayout);
/*----------------------------------------------------------*/
/* Count of general and floating point register usage */
/*----------------------------------------------------------*/
int intArgC = 0,
fprArgC = 0,
outArgC = 0;
int i;
ffi_type **ptr;
void **p_argv;
size_t structCopySize;
unsigned gprValue, strFlags = 0;
unsigned long long llngValue;
double dblValue;
/* Now for the arguments. */
p_argv = ecif->avalue;
/*----------------------------------------------------------------------*/
/* If we returning a structure then we set the first parameter register */
/* to the address of where we are returning this structure */
/*----------------------------------------------------------------------*/
if (flags == FFI_TYPE_STRUCT)
stack->gprArgs[intArgC++] = (int) ecif->rvalue;
for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
i > 0;
i--, ptr++, p_argv++)
{
switch ((*ptr)->type) {
case FFI_TYPE_FLOAT:
if (fprArgC < MAX_FPRARGS)
stack->fprArgs[fprArgC++].f = *(float *) *p_argv;
else
stack->outArgs[outArgC++] = *(int *) *p_argv;
break;
case FFI_TYPE_DOUBLE:
dblValue = *(double *) *p_argv;
ffi_insert_double(dblValue, stack, &fprArgC, &outArgC);
break;
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
llngValue = *(unsigned long long *) *p_argv;
ffi_insert_int64(llngValue, stack, &intArgC, &outArgC);
break;
case FFI_TYPE_UINT8:
gprValue = *(unsigned char *)*p_argv;
ffi_insert_int(gprValue, stack, &intArgC, &outArgC);
break;
case FFI_TYPE_SINT8:
gprValue = *(signed char *)*p_argv;
ffi_insert_int(gprValue, stack, &intArgC, &outArgC);
break;
case FFI_TYPE_UINT16:
gprValue = *(unsigned short *)*p_argv;
ffi_insert_int(gprValue, stack, &intArgC, &outArgC);
break;
case FFI_TYPE_SINT16:
gprValue = *(signed short *)*p_argv;
ffi_insert_int(gprValue, stack, &intArgC, &outArgC);
break;
case FFI_TYPE_STRUCT:
/*--------------------------------------------------*/
/* If structure > 8 bytes then it goes on the stack */
/*--------------------------------------------------*/
if (((*ptr)->size > 8) ||
((*ptr)->size > 4 &&
(*ptr)->size < 8))
strFlags = STR_STACK;
else
strFlags = ffi_check_struct((ffi_type *) *ptr, &strFlags);
switch (strFlags) {
/*-------------------------------------------*/
/* Structure that will fit in one or two GPR */
/*-------------------------------------------*/
case STR_GPR :
if ((*ptr)->size <= 4) {
gprValue = *(unsigned int *) *p_argv;
gprValue = gprValue >> ((4 - (*ptr)->size) * 8);
ffi_insert_int(gprValue, stack, &intArgC, &outArgC);
}
else {
llngValue = *(unsigned long long *) *p_argv;
ffi_insert_int64(llngValue, stack, &intArgC, &outArgC);
}
break;
/*-------------------------------------------*/
/* Structure that will fit in one FPR */
/*-------------------------------------------*/
case STR_FPR :
dblValue = *(double *) *p_argv;
ffi_insert_double(dblValue, stack, &fprArgC, &outArgC);
break;
/*-------------------------------------------*/
/* Structure that must be copied to stack */
/*-------------------------------------------*/
default :
structCopySize = (((*ptr)->size + 15) & ~0xF);
copySpace -= structCopySize;
memcpy(copySpace, (char *)*p_argv, (*ptr)->size);
gprValue = (unsigned) copySpace;
if (intArgC < MAX_GPRARGS)
stack->gprArgs[intArgC++] = gprValue;
else
stack->outArgs[outArgC++] = gprValue;
}
break;
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
structCopySize = (((*ptr)->size + 15) & ~0xF);
copySpace -= structCopySize;
memcpy(copySpace, (char *)*p_argv, (*ptr)->size);
gprValue = (unsigned) copySpace;
if (intArgC < MAX_GPRARGS)
stack->gprArgs[intArgC++] = gprValue;
else
stack->outArgs[outArgC++] = gprValue;
break;
#endif
case FFI_TYPE_INT:
case FFI_TYPE_UINT32:
case FFI_TYPE_SINT32:
case FFI_TYPE_POINTER:
gprValue = *(unsigned *)*p_argv;
if (intArgC < MAX_GPRARGS)
stack->gprArgs[intArgC++] = gprValue;
else
stack->outArgs[outArgC++] = gprValue;
break;
}
}
}
/*======================== End of Routine ============================*/
/*====================================================================*/
/* */
/* Name - ffi_prep_cif_machdep. */
/* */
/* Function - Perform machine dependent CIF processing. */
/* */
/*====================================================================*/
ffi_status
ffi_prep_cif_machdep(ffi_cif *cif)
{
int i;
ffi_type **ptr;
unsigned bytes;
int fpArgC = 0,
intArgC = 0;
unsigned flags = 0;
unsigned structCopySize = 0;
/*-----------------------------------------------------------------*/
/* Extra space required in stack for overflow parameters. */
/*-----------------------------------------------------------------*/
bytes = 0;
/*--------------------------------------------------------*/
/* Return value handling. The rules are as follows: */
/* - 32-bit (or less) integer values are returned in gpr2 */
/* - Structures are returned as pointers in gpr2 */
/* - 64-bit integer values are returned in gpr2 and 3 */
/* - Single/double FP values are returned in fpr0 */
/*--------------------------------------------------------*/
flags = cif->rtype->type;
/*------------------------------------------------------------------------*/
/* The first MAX_GPRARGS words of integer arguments, and the */
/* first MAX_FPRARGS floating point arguments, go in registers; the rest */
/* goes on the stack. Structures and long doubles (if not equivalent */
/* to double) are passed as a pointer to a copy of the structure. */
/* Stuff on the stack needs to keep proper alignment. */
/*------------------------------------------------------------------------*/
for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
{
switch ((*ptr)->type)
{
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
fpArgC++;
if (fpArgC > MAX_FPRARGS && intArgC%2 != 0)
intArgC++;
break;
case FFI_TYPE_UINT64:
case FFI_TYPE_SINT64:
/*----------------------------------------------------*/
/* 'long long' arguments are passed as two words, but */
/* either both words must fit in registers or both go */
/* on the stack. If they go on the stack, they must */
/* be 8-byte-aligned. */
/*----------------------------------------------------*/
if ((intArgC == MAX_GPRARGS-1) ||
(intArgC >= MAX_GPRARGS) &&
(intArgC%2 != 0))
intArgC++;
intArgC += 2;
break;
case FFI_TYPE_STRUCT:
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
/*----------------------------------------------------*/
/* We must allocate space for a copy of these to */
/* enforce pass-by-value. Pad the space up to a */
/* multiple of 16 bytes (the maximum alignment */
/* required for anything under the SYSV ABI). */
/*----------------------------------------------------*/
structCopySize += ((*ptr)->size + 15) & ~0xF;
/*----------------------------------------------------*/
/* Fall through (allocate space for the pointer). */
/*----------------------------------------------------*/
default:
/*----------------------------------------------------*/
/* Everything else is passed as a 4-byte word in a */
/* GPR either the object itself or a pointer to it. */
/*----------------------------------------------------*/
intArgC++;
break;
}
}
/*-----------------------------------------------------------------*/
/* Stack space. */
/*-----------------------------------------------------------------*/
if (intArgC > MAX_GPRARGS)
bytes += (intArgC - MAX_GPRARGS) * sizeof(int);
if (fpArgC > MAX_FPRARGS)
bytes += (fpArgC - MAX_FPRARGS) * sizeof(double);
/*-----------------------------------------------------------------*/
/* The stack space allocated needs to be a multiple of 16 bytes. */
/*-----------------------------------------------------------------*/
bytes = (bytes + 15) & ~0xF;
/*-----------------------------------------------------------------*/
/* Add in the space for the copied structures. */
/*-----------------------------------------------------------------*/
bytes += structCopySize;
cif->flags = flags;
cif->bytes = bytes;
return FFI_OK;
}
/*======================== End of Routine ============================*/
/*====================================================================*/
/* */
/* Name - ffi_call. */
/* */
/* Function - Call the FFI routine. */
/* */
/*====================================================================*/
void
ffi_call(ffi_cif *cif,
void (*fn)(),
void *rvalue,
void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/*-----------------------------------------------------------------*/
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
/*-----------------------------------------------------------------*/
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
ecif.rvalue = alloca(cif->rtype->size);
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_SYSV:
ffi_call_SYSV(ffi_prep_args,
&ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
break;
default:
FFI_ASSERT(0);
break;
}
}
/*======================== End of Routine ============================*/
+161
View File
@@ -0,0 +1,161 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 2000 Software AG
S390 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#ifdef HAVE_MACHINE_ASM_H
#include <machine/asm.h>
#endif
.text
# r2: ffi_prep_args
# r3: &ecif
# r4: cif->bytes
# r5: fig->flags
# r6: ecif.rvalue
# sp+0: fn
# This assumes we are using gas.
.globl ffi_call_SYSV
.type ffi_call_SYSV,%function
ffi_call_SYSV:
# Save registers
stm %r7,%r15,28(%r15)
l %r7,96(%r15) # Get A(fn)
lr %r0,%r15
ahi %r15,-128 # Make room for my args
st %r0,0(%r15) # Set backchain
lr %r11,%r15 # Establish my stack register
sr %r15,%r4 # Make room for fn args
ahi %r15,-96 # Make room for new frame
lr %r10,%r15 # Establish stack build area
ahi %r15,-96 # Stack for next call
lr %r1,%r7
stm %r2,%r7,96(%r11) # Save args on my stack
#------------------------------------------------------------------
# move first 3 parameters in registers
#------------------------------------------------------------------
lr %r9,%r2 # r9: &ffi_prep_args
lr %r2,%r10 # Parm 1: &stack Parm 2: &ecif
basr %r14,%r9 # call ffi_prep_args
#------------------------------------------------------------------
# load first 5 parameter registers
#------------------------------------------------------------------
lm %r2,%r6,24(%r10)
#------------------------------------------------------------------
# load fp parameter registers
#------------------------------------------------------------------
ld %f0,48(%r10)
ld %f2,56(%r10)
#------------------------------------------------------------------
# call function
#------------------------------------------------------------------
lr %r15,%r10 # Set new stack
l %r9,116(%r11) # Get &fn
basr %r14,%r9 # Call function
#------------------------------------------------------------------
# On return:
# r2: Return value (r3: Return value + 4 for long long)
#------------------------------------------------------------------
#------------------------------------------------------------------
# If the return value pointer is NULL, assume no return value.
#------------------------------------------------------------------
icm %r6,15,112(%r11)
jz .Lepilogue
l %r5,108(%r11) # Get return type
#------------------------------------------------------------------
# return INT
#------------------------------------------------------------------
chi %r5,FFI_TYPE_INT
jne .Lchk64
st %r2,0(%r6)
j .Lepilogue
.Lchk64:
#------------------------------------------------------------------
# return LONG LONG (signed/unsigned)
#------------------------------------------------------------------
chi %r5,FFI_TYPE_UINT64
je .LdoLongLong
chi %r5,FFI_TYPE_SINT64
jne .LchkFloat
.LdoLongLong:
stm %r2,%r3,0(%r6)
j .Lepilogue
.LchkFloat:
#------------------------------------------------------------------
# return FLOAT
#------------------------------------------------------------------
chi %r5,FFI_TYPE_FLOAT
jne .LchkDouble
std %f0,0(%r6)
j .Lepilogue
.LchkDouble:
#------------------------------------------------------------------
# return DOUBLE or LONGDOUBLE
#------------------------------------------------------------------
chi %r5,FFI_TYPE_DOUBLE
jne .LchkStruct
std %f0,0(%r6)
std %f2,8(%r6)
j .Lepilogue
.LchkStruct:
#------------------------------------------------------------------
# Structure - rvalue already set as sent as 1st parm to routine
#------------------------------------------------------------------
chi %r5,FFI_TYPE_STRUCT
je .Lepilogue
.Ldefault:
#------------------------------------------------------------------
# return a pointer
#------------------------------------------------------------------
st %r2,0(%r6)
j .Lepilogue
.Lepilogue:
l %r15,0(%r11)
l %r4,56(%r15)
lm %r7,%r15,28(%r15)
br %r4
.ffi_call_SYSV_end:
.size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
+422
View File
@@ -0,0 +1,422 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1996 Cygnus Solutions
Sparc Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
void ffi_prep_args_v8(char *stack, extended_cif *ecif)
{
int i;
int tmp;
int avn;
void **p_argv;
char *argp;
ffi_type **p_arg;
tmp = 0;
/* Skip 16 words for the window save area */
argp = stack + 16*sizeof(int);
/* This should only really be done when we are returning a structure,
however, it's faster just to do it all the time...
if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) */
*(int *) argp = (long)ecif->rvalue;
/* And 1 word for the structure return value. */
argp += sizeof(int);
#ifdef USING_PURIFY
/* Purify will probably complain in our assembly routine, unless we
zero out this memory. */
((int*)argp)[0] = 0;
((int*)argp)[1] = 0;
((int*)argp)[2] = 0;
((int*)argp)[3] = 0;
((int*)argp)[4] = 0;
((int*)argp)[5] = 0;
#endif
avn = ecif->cif->nargs;
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
i && avn;
i--, p_arg++)
{
size_t z;
if (avn)
{
avn--;
if ((*p_arg)->type == FFI_TYPE_STRUCT
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
|| (*p_arg)->type == FFI_TYPE_LONGDOUBLE
#endif
)
{
*(unsigned int *) argp = (unsigned long)(* p_argv);
z = sizeof(int);
}
else
{
z = (*p_arg)->size;
if (z < sizeof(int))
{
z = sizeof(int);
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed int *) argp = *(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
*(unsigned int *) argp = *(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
*(signed int *) argp = *(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
*(unsigned int *) argp = *(UINT16 *)(* p_argv);
break;
default:
FFI_ASSERT(0);
}
}
else
{
memcpy(argp, *p_argv, z);
}
}
p_argv++;
argp += z;
}
}
return;
}
int ffi_prep_args_v9(char *stack, extended_cif *ecif)
{
int i, ret = 0;
int tmp;
void **p_argv;
char *argp;
ffi_type **p_arg;
tmp = 0;
/* Skip 16 words for the window save area */
argp = stack + 16*sizeof(long long);
#ifdef USING_PURIFY
/* Purify will probably complain in our assembly routine, unless we
zero out this memory. */
((long long*)argp)[0] = 0;
((long long*)argp)[1] = 0;
((long long*)argp)[2] = 0;
((long long*)argp)[3] = 0;
((long long*)argp)[4] = 0;
((long long*)argp)[5] = 0;
#endif
p_argv = ecif->avalue;
if (ecif->cif->rtype->type == FFI_TYPE_STRUCT &&
ecif->cif->rtype->size > 32)
{
*(unsigned long long *) argp = (unsigned long)ecif->rvalue;
tmp = 1;
}
for (i = 0, p_arg = ecif->cif->arg_types; i < ecif->cif->nargs;
i++, p_arg++)
{
size_t z;
z = (*p_arg)->size;
switch ((*p_arg)->type)
{
case FFI_TYPE_STRUCT:
if (z > 16)
{
/* For structures larger than 16 bytes we pass reference. */
*(unsigned long long *) argp = (unsigned long)* p_argv;
argp += sizeof(long long);
tmp++;
p_argv++;
continue;
}
/* FALLTHROUGH */
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
ret = 1; /* We should promote into FP regs as well as integer. */
break;
}
if (z < sizeof(long long))
{
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed long long *) argp = *(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
*(unsigned long long *) argp = *(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
*(signed long long *) argp = *(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
*(unsigned long long *) argp = *(UINT16 *)(* p_argv);
break;
case FFI_TYPE_SINT32:
*(signed long long *) argp = *(SINT32 *)(* p_argv);
break;
case FFI_TYPE_UINT32:
*(unsigned long long *) argp = *(UINT32 *)(* p_argv);
break;
case FFI_TYPE_FLOAT:
*(float *) (argp + 4) = *(FLOAT32 *)(* p_argv); /* Right justify */
break;
case FFI_TYPE_STRUCT:
memcpy(argp, *p_argv, z);
break;
default:
FFI_ASSERT(0);
}
z = sizeof(long long);
tmp++;
}
else if (z == sizeof(long long))
{
memcpy(argp, *p_argv, z);
z = sizeof(long long);
tmp++;
}
else
{
if ((tmp & 1) && (*p_arg)->alignment > 8)
{
tmp++;
argp += sizeof(long long);
}
memcpy(argp, *p_argv, z);
z = 2 * sizeof(long long);
tmp += 2;
}
p_argv++;
argp += z;
}
return ret;
}
/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
int wordsize;
if (cif->abi != FFI_V9)
{
wordsize = 4;
/* If we are returning a struct, this will already have been added.
Otherwise we need to add it because it's always got to be there! */
if (cif->rtype->type != FFI_TYPE_STRUCT)
cif->bytes += wordsize;
/* sparc call frames require that space is allocated for 6 args,
even if they aren't used. Make that space if necessary. */
if (cif->bytes < 4*6+4)
cif->bytes = 4*6+4;
}
else
{
wordsize = 8;
/* sparc call frames require that space is allocated for 6 args,
even if they aren't used. Make that space if necessary. */
if (cif->bytes < 8*6)
cif->bytes = 8*6;
}
/* Adjust cif->bytes. to include 16 words for the window save area,
and maybe the struct/union return pointer area, */
cif->bytes += 16 * wordsize;
/* The stack must be 2 word aligned, so round bytes up
appropriately. */
cif->bytes = ALIGN(cif->bytes, 2 * wordsize);
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
cif->flags = cif->rtype->type;
break;
case FFI_TYPE_STRUCT:
if (cif->abi == FFI_V9 && cif->rtype->size > 32)
cif->flags = FFI_TYPE_VOID;
else
cif->flags = FFI_TYPE_STRUCT;
break;
case FFI_TYPE_SINT64:
case FFI_TYPE_UINT64:
if (cif->abi != FFI_V9)
{
cif->flags = FFI_TYPE_SINT64;
break;
}
/* FALLTHROUGH */
default:
cif->flags = FFI_TYPE_INT;
break;
}
return FFI_OK;
}
int ffi_V9_return_struct(ffi_type *arg, int off, char *ret, char *intg, char *flt)
{
ffi_type **ptr = &arg->elements[0];
while (*ptr != NULL)
{
if (off & ((*ptr)->alignment - 1))
off = ALIGN(off, (*ptr)->alignment);
switch ((*ptr)->type)
{
case FFI_TYPE_STRUCT:
off = ffi_V9_return_struct(*ptr, off, ret, intg, flt);
break;
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
memcpy(ret + off, flt + off, (*ptr)->size);
off += (*ptr)->size;
break;
default:
memcpy(ret + off, intg + off, (*ptr)->size);
off += (*ptr)->size;
break;
}
ptr++;
}
return off;
}
extern int ffi_call_V8(void *, extended_cif *, unsigned,
unsigned, unsigned *, void (*fn)());
extern int ffi_call_V9(void *, extended_cif *, unsigned,
unsigned, unsigned *, void (*fn)());
void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
{
extended_cif ecif;
void *rval = rvalue;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
ecif.rvalue = rvalue;
if (cif->rtype->type == FFI_TYPE_STRUCT)
{
if (cif->rtype->size <= 32)
rval = alloca(64);
else
{
rval = NULL;
if (rvalue == NULL)
ecif.rvalue = alloca(cif->rtype->size);
}
}
switch (cif->abi)
{
case FFI_V8:
#ifdef SPARC64
/* We don't yet support calling 32bit code from 64bit */
FFI_ASSERT(0);
#else
ffi_call_V8(ffi_prep_args_v8, &ecif, cif->bytes,
cif->flags, rvalue, fn);
#endif
break;
case FFI_V9:
#ifdef SPARC64
ffi_call_V9(ffi_prep_args_v9, &ecif, cif->bytes,
cif->flags, rval, fn);
if (rvalue && rval && cif->rtype->type == FFI_TYPE_STRUCT)
ffi_V9_return_struct(cif->rtype, 0, (char *)rvalue, (char *)rval, ((char *)rval)+32);
#else
/* And vice versa */
FFI_ASSERT(0);
#endif
break;
default:
FFI_ASSERT(0);
break;
}
}
+94
View File
@@ -0,0 +1,94 @@
/* -----------------------------------------------------------------------
v8.S - Copyright (c) 1996, 1997 Cygnus Solutions
Sparc Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#include <ffi_private.h>
#define STACKFRAME 96 /* Minimum stack framesize for SPARC */
#define ARGS (64+4) /* Offset of register area in frame */
.text
.align 8
.globl ffi_call_V8
.globl _ffi_call_V8
ffi_call_V8:
_ffi_call_V8:
save %sp, -STACKFRAME, %sp
sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
add %sp, STACKFRAME, %l0 ! %l0 has start of
! frame to set up
mov %l0, %o0 ! call routine to set up frame
call %i0
mov %i1, %o1 ! (delay)
ld [%l0+ARGS], %o0 ! call foreign function
ld [%l0+ARGS+4], %o1
ld [%l0+ARGS+8], %o2
ld [%l0+ARGS+12], %o3
ld [%l0+ARGS+16], %o4
ld [%l0+ARGS+20], %o5
call %i5
mov %l0, %sp ! (delay) switch to frame
nop ! STRUCT returning functions skip 12 instead of 8 bytes
! If the return value pointer is NULL, assume no return value.
tst %i4
bz done
nop
cmp %i3, FFI_TYPE_INT
be,a done
st %o0, [%i4] ! (delay)
cmp %i3, FFI_TYPE_FLOAT
be,a done
st %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_SINT64
be longlong
cmp %i3, FFI_TYPE_DOUBLE
bne done
nop
st %f0, [%i4+0]
st %f1, [%i4+4]
done:
ret
restore
longlong:
st %o0, [%i4+0]
st %o1, [%i4+4]
ret
restore
.ffi_call_V8_end:
.size ffi_call_V8,.ffi_call_V8_end-ffi_call_V8
+126
View File
@@ -0,0 +1,126 @@
/* -----------------------------------------------------------------------
v9.S - Copyright (c) 2000 Cygnus Solutions
Sparc 64bit Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#include <ffi_private.h>
#if defined(__arch64__) || defined(__sparcv9)
/* Only compile this in for 64bit builds, because otherwise the object file
will have inproper architecture due to used instructions. */
#define STACKFRAME 128 /* Minimum stack framesize for SPARC */
#define STACK_BIAS 2047
#define ARGS (128) /* Offset of register area in frame */
.text
.align 8
.globl ffi_call_V9
.globl _ffi_call_V9
ffi_call_V9:
_ffi_call_V9:
save %sp, -STACKFRAME, %sp
sub %sp, %i2, %sp ! alloca() space in stack for frame to set up
add %sp, STACKFRAME+STACK_BIAS, %l0 ! %l0 has start of
! frame to set up
mov %l0, %o0 ! call routine to set up frame
call %i0
mov %i1, %o1 ! (delay)
brz,pt %o0, 1f
ldx [%l0+ARGS], %o0 ! call foreign function
ldd [%l0+ARGS], %f0
ldd [%l0+ARGS+8], %f2
ldd [%l0+ARGS+16], %f4
ldd [%l0+ARGS+24], %f6
ldd [%l0+ARGS+32], %f8
ldd [%l0+ARGS+40], %f10
ldd [%l0+ARGS+48], %f12
ldd [%l0+ARGS+56], %f14
ldd [%l0+ARGS+64], %f16
ldd [%l0+ARGS+72], %f18
ldd [%l0+ARGS+80], %f20
ldd [%l0+ARGS+88], %f22
ldd [%l0+ARGS+96], %f24
ldd [%l0+ARGS+104], %f26
ldd [%l0+ARGS+112], %f28
ldd [%l0+ARGS+120], %f30
1: ldx [%l0+ARGS+8], %o1
ldx [%l0+ARGS+16], %o2
ldx [%l0+ARGS+24], %o3
ldx [%l0+ARGS+32], %o4
ldx [%l0+ARGS+40], %o5
call %i5
sub %l0, STACK_BIAS, %sp ! (delay) switch to frame
! If the return value pointer is NULL, assume no return value.
brz,pn %i4, done
nop
cmp %i3, FFI_TYPE_INT
be,a,pt %icc, done
stx %o0, [%i4] ! (delay)
cmp %i3, FFI_TYPE_FLOAT
be,a,pn %icc, done
st %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_DOUBLE
be,a,pn %icc, done
std %f0, [%i4+0] ! (delay)
cmp %i3, FFI_TYPE_STRUCT
be,pn %icc, dostruct
cmp %i3, FFI_TYPE_LONGDOUBLE
bne,pt %icc, done
nop
std %f0, [%i4+0]
std %f2, [%i4+8]
done: ret
restore
dostruct:
/* This will not work correctly for unions. */
stx %o0, [%i4+0]
stx %o1, [%i4+8]
stx %o2, [%i4+16]
stx %o3, [%i4+24]
std %f0, [%i4+32]
std %f2, [%i4+40]
std %f4, [%i4+48]
std %f6, [%i4+56]
ret
restore
.ffi_call_V9_end:
.size ffi_call_V9,.ffi_call_V9_end-ffi_call_V9
#endif
+2
View File
@@ -0,0 +1,2 @@
Makefile
Makefile.in
+15
View File
@@ -0,0 +1,15 @@
## Process this file with automake to produce Makefile.in.
AUTOMAKE_OPTIONS = foreign dejagnu
# Setup the testing framework, if you have one
EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \
echo $(top_builddir)/../expect/expect ; \
else echo expect ; fi`
RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
echo $(top_srcdir)/../dejagnu/runtest ; \
else echo runtest; fi`
RUNTESTFLAGS = @AM_RUNTESTFLAGS@
+1
View File
@@ -0,0 +1 @@
load_lib "standard.exp"
+44
View File
@@ -0,0 +1,44 @@
# Copyright (C) 2001 Red Hat, Inc.
load_lib "libgloss.exp"
global tmpdir
if ![info exists tmpdir] {
set tmpdir "/tmp"
}
proc test_libffi {src} {
global tmpdir srcdir
set executable $tmpdir/[file tail [file rootname $src].x]
regsub "^$srcdir/?" $src "" testcase
# If we couldn't rip $srcdir out of `src' then just do the best we can.
# The point is to reduce the unnecessary noise in the logs. Don't strip
# out too much because different testcases with the same name can confuse
# `test-tool'.
if [string match "/*" $testcase] {
set testcase "[file tail [file dirname $src]]/[file tail $src]"
}
remote_file build delete $executable;
verbose "Testing $testcase" 1
set comp_output [target_compile $src $executable executable "additional_flags=-g additional_flags=-I$srcdir/../include libs=../.libs/libffi.a"]
set result [libffi_load "$executable" "" ""]
set status [lindex $result 0];
set output [lindex $result 1];
$status "$testcase"
# if { $status == "pass" } {
# remote_file build delete $executable;
# }
}
# Local Variables:
# tcl-indent-level:4
# End:
+13
View File
@@ -0,0 +1,13 @@
global srcdir subdir
catch "glob -nocomplain ${srcdir}/${subdir}/*.c" srcfiles
verbose "srcfiles are $srcfiles"
set prefix ""
foreach x $srcfiles {
test_libffi $x
}
# Local Variables:
# tcl-indent-level:4
# End:
+4
View File
@@ -0,0 +1,4 @@
#include <ffi.h>
#define CHECK(x) !(x) ? abort() : 0
+55
View File
@@ -0,0 +1,55 @@
#include "ffitest.h"
static int floating(int a, float b, double c, long double d, int e)
{
int i;
i = (int) ((float)a/b + ((float)c/(float)d));
return i;
}
int
main ()
{
ffi_cif cif;
ffi_type *args[5];
void *values[5];
int si1, si2;
float f;
double d;
long double ld;
int rint __attribute__((aligned(8)));
args[0] = &ffi_type_sint;
values[0] = &si1;
args[1] = &ffi_type_float;
values[1] = &f;
args[2] = &ffi_type_double;
values[2] = &d;
args[3] = &ffi_type_longdouble;
values[3] = &ld;
args[4] = &ffi_type_sint;
values[4] = &si2;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 5,
&ffi_type_sint, args) == FFI_OK);
si1 = 6;
f = 3.14159;
d = (double)1.0/(double)3.0;
ld = 2.71828182846L;
si2 = 10;
floating (si1, f, d, ld, si2);
ffi_call(&cif, FFI_FN(floating), &rint, values);
printf ("%d vs %d\n", rint, floating (si1, f, d, ld, si2));
CHECK(rint == floating(si1, f, d, ld, si2));
exit (0);
}
+63
View File
@@ -0,0 +1,63 @@
#include "ffitest.h"
#include <float.h>
static float many(float f1,
float f2,
float f3,
float f4,
float f5,
float f6,
float f7,
float f8,
float f9,
float f10,
float f11,
float f12,
float f13)
{
#if 1
printf("%f %f %f %f %f %f %f %f %f %f %f %f %f\n",
(double) f1, (double) f2, (double) f3, (double) f4, (double) f5,
(double) f6, (double) f7, (double) f8, (double) f9, (double) f10,
(double) f11, (double) f12, (double) f13);
#endif
return ((f1/f2+f3/f4+f5/f6+f7/f8+f9/f10+f11/f12) * f13);
}
int
main ()
{
ffi_cif cif;
ffi_type *args[13];
void *values[13];
float fa[13];
float f, ff;
int i;
for (i = 0; i < 13; i++)
{
args[i] = &ffi_type_float;
values[i] = &fa[i];
fa[i] = (float) i;
}
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 13,
&ffi_type_float, args) == FFI_OK);
ffi_call(&cif, FFI_FN(many), &f, values);
ff = many(fa[0], fa[1],
fa[2], fa[3],
fa[4], fa[5],
fa[6], fa[7],
fa[8], fa[9],
fa[10],fa[11],fa[12]);
if (f - ff < FLT_EPSILON)
exit(0);
else
abort();
}
+38
View File
@@ -0,0 +1,38 @@
#include "ffitest.h"
static size_t my_strlen(char *s)
{
return (strlen(s));
}
int
main ()
{
ffi_cif cif;
ffi_type *args[1];
void *values[1];
int rint __attribute__((aligned(8)));
char *s;
args[0] = &ffi_type_pointer;
values[0] = (void*) &s;
/* Initialize the cif */
CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1,
&ffi_type_sint, args) == FFI_OK);
s = "a";
ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
CHECK(rint == 1);
s = "1234567";
ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
CHECK(rint == 7);
s = "1234567890123456789012345";
ffi_call(&cif, FFI_FN(my_strlen), &rint, values);
CHECK(rint == 25);
exit (0);
}
+153
View File
@@ -0,0 +1,153 @@
/* -----------------------------------------------------------------------
types.c - Copyright (c) 1996, 1998 Cygnus Solutions
Predefined ffi_types needed by libffi.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL RED HAT BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
/* Type definitions */
#define FFI_INTEGRAL_TYPEDEF(n, s, a, t) ffi_type ffi_type_##n = { s, a, t, NULL }
#define FFI_AGGREGATE_TYPEDEF(n, e) ffi_type ffi_type_##n = { 0, 0, FFI_TYPE_STRUCT, e }
/* Size and alignment are fake here. They must not be 0. */
FFI_INTEGRAL_TYPEDEF(void, 1, 1, FFI_TYPE_VOID);
FFI_INTEGRAL_TYPEDEF(uint8, 1, 1, FFI_TYPE_UINT8);
FFI_INTEGRAL_TYPEDEF(sint8, 1, 1, FFI_TYPE_SINT8);
FFI_INTEGRAL_TYPEDEF(uint16, 2, 2, FFI_TYPE_UINT16);
FFI_INTEGRAL_TYPEDEF(sint16, 2, 2, FFI_TYPE_SINT16);
FFI_INTEGRAL_TYPEDEF(uint32, 4, 4, FFI_TYPE_UINT32);
FFI_INTEGRAL_TYPEDEF(sint32, 4, 4, FFI_TYPE_SINT32);
FFI_INTEGRAL_TYPEDEF(float, 4, 4, FFI_TYPE_FLOAT);
#if defined __alpha__ || defined SPARC64
FFI_INTEGRAL_TYPEDEF(pointer, 8, 8, FFI_TYPE_POINTER);
#else
FFI_INTEGRAL_TYPEDEF(pointer, 4, 4, FFI_TYPE_POINTER);
#endif
#ifdef __i386__
FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
#elif defined X86_WIN32
FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
#elif defined ARM
FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
#elif defined M68K
FFI_INTEGRAL_TYPEDEF(uint64, 8, 4, FFI_TYPE_UINT64);
FFI_INTEGRAL_TYPEDEF(sint64, 8, 4, FFI_TYPE_SINT64);
#else
FFI_INTEGRAL_TYPEDEF(uint64, 8, 8, FFI_TYPE_UINT64);
FFI_INTEGRAL_TYPEDEF(sint64, 8, 8, FFI_TYPE_SINT64);
#endif
#ifdef __i386__
FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
#elif defined X86_WIN32
FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
#elif defined ARM
FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
FFI_INTEGRAL_TYPEDEF(longdouble, 8, 4, FFI_TYPE_LONGDOUBLE);
#elif defined M68K
FFI_INTEGRAL_TYPEDEF(double, 8, 4, FFI_TYPE_DOUBLE);
FFI_INTEGRAL_TYPEDEF(longdouble, 12, 4, FFI_TYPE_LONGDOUBLE);
#elif defined SPARC
FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
#ifdef SPARC64
FFI_INTEGRAL_TYPEDEF(longdouble, 16, 16, FFI_TYPE_LONGDOUBLE);
#else
FFI_INTEGRAL_TYPEDEF(longdouble, 16, 8, FFI_TYPE_LONGDOUBLE);
#endif
#else
FFI_INTEGRAL_TYPEDEF(double, 8, 8, FFI_TYPE_DOUBLE);
FFI_INTEGRAL_TYPEDEF(longdouble, 8, 8, FFI_TYPE_LONGDOUBLE);
#endif
#if SIZEOF_SHORT==1
extern ffi_type ffi_type_sshort __attribute__((alias("ffi_type_sint8")));
extern ffi_type ffi_type_ushort __attribute__((alias("ffi_type_uint8")));
#elif SIZEOF_SHORT==2
extern ffi_type ffi_type_sshort __attribute__((alias("ffi_type_sint16")));
extern ffi_type ffi_type_ushort __attribute__((alias("ffi_type_uint16")));
#elif SIZEOF_SHORT==4
extern ffi_type ffi_type_sshort __attribute__((alias("ffi_type_sint32")));
extern ffi_type ffi_type_ushort __attribute__((alias("ffi_type_uint32")));
#endif
#if SIZEOF_INT==2
extern ffi_type ffi_type_sint __attribute__((alias("ffi_type_sint16")));
extern ffi_type ffi_type_uint __attribute__((alias("ffi_type_uint16")));
#elif SIZEOF_INT==4
extern ffi_type ffi_type_sint __attribute__((alias("ffi_type_sint32")));
extern ffi_type ffi_type_uint __attribute__((alias("ffi_type_uint32")));
#elif SIZEOF_INT==8
extern ffi_type ffi_type_sint __attribute__((alias("ffi_type_sint64")));
extern ffi_type ffi_type_uint __attribute__((alias("ffi_type_uint64")));
#endif
#if SIZEOF_LONG==4
extern ffi_type ffi_type_slong __attribute__((alias("ffi_type_sint32")));
extern ffi_type ffi_type_ulong __attribute__((alias("ffi_type_uint32")));
#elif SIZEOF_INT==8
extern ffi_type ffi_type_slong __attribute__((alias("ffi_type_sint64")));
extern ffi_type ffi_type_ulong __attribute__((alias("ffi_type_uint64")));
#endif
+508
View File
@@ -0,0 +1,508 @@
/* -----------------------------------------------------------------------
ffi.c - Copyright (c) 1996, 1998, 1999 Cygnus Solutions
x86 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#include <ffi.h>
#include <ffi_private.h>
#include <stdlib.h>
/* ffi_prep_args is called by the assembly routine once stack space
has been allocated for the function's arguments */
/*@-exportheader@*/
void ffi_prep_args(char *stack, extended_cif *ecif)
/*@=exportheader@*/
{
register unsigned int i;
register int tmp;
register unsigned int avn;
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
tmp = 0;
argp = stack;
if ( ecif->cif->rtype->type == FFI_TYPE_STRUCT ) {
*(void **) argp = ecif->rvalue;
argp += 4;
}
avn = ecif->cif->nargs;
p_argv = ecif->avalue;
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0) && (avn != 0);
i--, p_arg++)
{
size_t z;
/* Align if necessary */
if (((*p_arg)->alignment - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, (*p_arg)->alignment);
}
if (avn != 0)
{
avn--;
z = (*p_arg)->size;
if (z < sizeof(int))
{
z = sizeof(int);
switch ((*p_arg)->type)
{
case FFI_TYPE_SINT8:
*(signed int *) argp = (signed int)*(SINT8 *)(* p_argv);
break;
case FFI_TYPE_UINT8:
*(unsigned int *) argp = (unsigned int)*(UINT8 *)(* p_argv);
break;
case FFI_TYPE_SINT16:
*(signed int *) argp = (signed int)*(SINT16 *)(* p_argv);
break;
case FFI_TYPE_UINT16:
*(unsigned int *) argp = (unsigned int)*(UINT16 *)(* p_argv);
break;
case FFI_TYPE_SINT32:
*(signed int *) argp = (signed int)*(SINT32 *)(* p_argv);
break;
case FFI_TYPE_UINT32:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
break;
case FFI_TYPE_STRUCT:
*(unsigned int *) argp = (unsigned int)*(UINT32 *)(* p_argv);
break;
default:
FFI_ASSERT(0);
}
}
else
{
memcpy(argp, *p_argv, z);
}
p_argv++;
argp += z;
}
}
return;
}
/* Perform machine dependent cif processing */
ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
{
/* Set the return type flag */
switch (cif->rtype->type)
{
case FFI_TYPE_VOID:
case FFI_TYPE_STRUCT:
case FFI_TYPE_SINT64:
case FFI_TYPE_FLOAT:
case FFI_TYPE_DOUBLE:
case FFI_TYPE_LONGDOUBLE:
cif->flags = (unsigned) cif->rtype->type;
break;
case FFI_TYPE_UINT64:
cif->flags = FFI_TYPE_SINT64;
break;
default:
cif->flags = FFI_TYPE_INT;
break;
}
return FFI_OK;
}
/*@-declundef@*/
/*@-exportheader@*/
extern void ffi_call_SYSV(void (*)(char *, extended_cif *),
/*@out@*/ extended_cif *,
unsigned, unsigned,
/*@out@*/ unsigned *,
void (*fn)());
/*@=declundef@*/
/*@=exportheader@*/
void ffi_call(/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
/*@out@*/ void *rvalue,
/*@dependent@*/ void **avalue)
{
extended_cif ecif;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
/*@-sysunrecog@*/
ecif.rvalue = alloca(cif->rtype->size);
/*@=sysunrecog@*/
}
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_SYSV:
/*@-usedef@*/
ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
/*@=usedef@*/
break;
default:
FFI_ASSERT(0);
break;
}
}
/** private members **/
static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
void** args, ffi_cif* cif);
static void ffi_closure_SYSV ();
static void ffi_closure_raw_SYSV ();
/* This function is jumped to by the trampoline, on entry, %ecx (a
* caller-save register) holds the address of the closure.
* Clearly, this requires __GNUC__, so perhaps we should translate this
* into an assembly file if this is to be distributed with ffi.
*/
static void
ffi_closure_SYSV ()
{
// this is our return value storage
long double res;
// our various things...
void *args;
ffi_cif *cif;
void **arg_area;
ffi_closure *closure;
unsigned short rtype;
void *resp = (void*)&res;
/* grab the trampoline context pointer */
asm ("movl %%ecx,%0" : "=r" (closure));
cif = closure->cif;
arg_area = (void**) alloca (cif->nargs * sizeof (void*));
asm ("leal 8(%%ebp),%0" : "=q" (args));
/* this call will initialize ARG_AREA, such that each
* element in that array points to the corresponding
* value on the stack; and if the function returns
* a structure, it will re-set RESP to point to the
* structure return address. */
ffi_prep_incoming_args_SYSV(args, (void**)&resp, arg_area, cif);
(closure->fun) (cif, resp, arg_area, closure->user_data);
rtype = cif->flags;
/* now, do a generic return based on the value of rtype */
if (rtype == FFI_TYPE_INT)
{
asm ("movl (%0),%%eax" : : "r" (resp) : "eax");
}
else if (rtype == FFI_TYPE_FLOAT)
{
asm ("flds (%0)" : : "r" (resp) : "st" );
}
else if (rtype == FFI_TYPE_DOUBLE)
{
asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
}
else if (rtype == FFI_TYPE_LONGDOUBLE)
{
asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
}
else if (rtype == FFI_TYPE_SINT64)
{
asm ("movl 0(%0),%%eax;"
"movl 4(%0),%%edx"
: : "r"(resp)
: "eax", "edx");
}
}
/*@-exportheader@*/
static void
ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
void **avalue, ffi_cif *cif)
/*@=exportheader@*/
{
register unsigned int i;
register int tmp;
register unsigned int avn;
register void **p_argv;
register char *argp;
register ffi_type **p_arg;
tmp = 0;
argp = stack;
if ( cif->rtype->type == FFI_TYPE_STRUCT ) {
*rvalue = *(void **) argp;
argp += 4;
}
avn = cif->nargs;
p_argv = avalue;
for (i = cif->nargs, p_arg = cif->arg_types;
(i != 0) && (avn != 0);
i--, p_arg++)
{
size_t z;
/* Align if necessary */
if (((*p_arg)->alignment - 1) & (unsigned) argp) {
argp = (char *) ALIGN(argp, (*p_arg)->alignment);
}
if (avn != 0)
{
avn--;
z = (*p_arg)->size;
/* because we're little endian, this is
what it turns into. */
*p_argv = (void*) argp;
p_argv++;
argp += z;
}
}
return;
}
/* How to make a trampoline. Derived from gcc/config/i386/i386.c. */
#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \
({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
unsigned int __fun = (unsigned int)(FUN); \
unsigned int __ctx = (unsigned int)(CTX); \
unsigned int __dis = __fun - ((unsigned int) __tramp + 10); \
*(unsigned char*) &__tramp[0] = 0xb9; \
*(unsigned int*) &__tramp[1] = __ctx; \
*(unsigned char*) &__tramp[5] = 0xe9; \
*(unsigned int*) &__tramp[6] = __dis; \
})
/* the cif must already be prep'ed */
ffi_status
ffi_prep_closure (ffi_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,void**,void*),
void *user_data)
{
FFI_ASSERT (cif->abi == FFI_SYSV);
FFI_INIT_TRAMPOLINE (&closure->tramp[0], \
&ffi_closure_SYSV, \
(void*)closure);
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
return FFI_OK;
}
/* ------- Native raw API support -------------------------------- */
#if !FFI_NO_RAW_API
static void
ffi_closure_raw_SYSV ()
{
// this is our return value storage
long double res;
// our various things...
void *args;
ffi_raw *raw_args;
ffi_cif *cif;
ffi_raw_closure *closure;
unsigned short rtype;
void *resp = (void*)&res;
/* grab the trampoline context pointer */
asm ("movl %%ecx,%0" : "=r" (closure));
/* take the argument pointer */
asm ("leal 8(%%ebp),%0" : "=q" (args));
/* get the cif */
cif = closure->cif;
/* the SYSV/X86 abi matches the RAW API exactly, well.. almost */
raw_args = (ffi_raw*) args;
(closure->fun) (cif, resp, raw_args, closure->user_data);
rtype = cif->flags;
/* now, do a generic return based on the value of rtype */
if (rtype == FFI_TYPE_INT)
{
asm ("movl (%0),%%eax" : : "r" (resp) : "eax");
}
else if (rtype == FFI_TYPE_FLOAT)
{
asm ("flds (%0)" : : "r" (resp) : "st" );
}
else if (rtype == FFI_TYPE_DOUBLE)
{
asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
}
else if (rtype == FFI_TYPE_LONGDOUBLE)
{
asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
}
else if (rtype == FFI_TYPE_SINT64)
{
asm ("movl 0(%0),%%eax; movl 4(%0),%%edx"
: : "r"(resp)
: "eax", "edx");
}
}
ffi_status
ffi_prep_raw_closure (ffi_raw_closure* closure,
ffi_cif* cif,
void (*fun)(ffi_cif*,void*,ffi_raw*,void*),
void *user_data)
{
int i;
FFI_ASSERT (cif->abi == FFI_SYSV);
// we currently don't support certain kinds of arguments for raw
// closures. This should be implemented by a seperate assembly language
// routine, since it would require argument processing, something we
// don't do now for performance.
for (i = cif->nargs-1; i >= 0; i--)
{
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT);
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE);
}
FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
(void*)closure);
closure->cif = cif;
closure->user_data = user_data;
closure->fun = fun;
return FFI_OK;
}
static void
ffi_prep_args_raw(char *stack, extended_cif *ecif)
{
memcpy (stack, ecif->avalue, ecif->cif->bytes);
}
/* we borrow this routine from libffi (it must be changed, though, to
* actually call the function passed in the first argument. as of
* libffi-1.20, this is not the case.)
*/
extern void
ffi_call_SYSV(void (*)(char *, extended_cif *),
/*@out@*/ extended_cif *,
unsigned, unsigned,
/*@out@*/ unsigned *,
void (*fn)());
void
ffi_raw_call(/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
/*@out@*/ void *rvalue,
/*@dependent@*/ ffi_raw *fake_avalue)
{
extended_cif ecif;
void **avalue = (void **)fake_avalue;
ecif.cif = cif;
ecif.avalue = avalue;
/* If the return value is a struct and we don't have a return */
/* value address then we need to make one */
if ((rvalue == NULL) &&
(cif->rtype->type == FFI_TYPE_STRUCT))
{
/*@-sysunrecog@*/
ecif.rvalue = alloca(cif->rtype->size);
/*@=sysunrecog@*/
}
else
ecif.rvalue = rvalue;
switch (cif->abi)
{
case FFI_SYSV:
/*@-usedef@*/
ffi_call_SYSV(ffi_prep_args_raw, &ecif, cif->bytes,
cif->flags, ecif.rvalue, fn);
/*@=usedef@*/
break;
default:
FFI_ASSERT(0);
break;
}
}
#endif
+167
View File
@@ -0,0 +1,167 @@
/* -----------------------------------------------------------------------
sysv.S - Copyright (c) 1996, 1998 Cygnus Solutions
X86 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
#include <ffi_private.h>
.text
.globl ffi_prep_args
# This assumes we are using gas.
.balign 16
.globl ffi_call_SYSV
.type ffi_call_SYSV,@function
ffi_call_SYSV:
.LFB1:
pushl %ebp
.LCFI0:
movl %esp,%ebp
.LCFI1:
# Make room for all of the new args.
movl 16(%ebp),%ecx
subl %ecx,%esp
movl %esp,%eax
# Place all of the ffi_prep_args in position
pushl 12(%ebp)
pushl %eax
call *8(%ebp)
# Return stack to previous state and call the function
addl $8,%esp
call *28(%ebp)
# Remove the space we pushed for the args
movl 16(%ebp),%ecx
addl %ecx,%esp
# Load %ecx with the return type code
movl 20(%ebp),%ecx
# If the return value pointer is NULL, assume no return value.
cmpl $0,24(%ebp)
jne retint
# Even if there is no space for the return value, we are
# obliged to handle floating-point values.
cmpl $FFI_TYPE_FLOAT,%ecx
jne noretval
fstp %st(0)
jmp epilogue
retint:
cmpl $FFI_TYPE_INT,%ecx
jne retfloat
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
jmp epilogue
retfloat:
cmpl $FFI_TYPE_FLOAT,%ecx
jne retdouble
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstps (%ecx)
jmp epilogue
retdouble:
cmpl $FFI_TYPE_DOUBLE,%ecx
jne retlongdouble
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstpl (%ecx)
jmp epilogue
retlongdouble:
cmpl $FFI_TYPE_LONGDOUBLE,%ecx
jne retint64
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstpt (%ecx)
jmp epilogue
retint64:
cmpl $FFI_TYPE_SINT64,%ecx
jne retstruct
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
movl %edx,4(%ecx)
retstruct:
# Nothing to do!
noretval:
epilogue:
movl %ebp,%esp
popl %ebp
ret
.LFE1:
.ffi_call_SYSV_end:
.size ffi_call_SYSV,.ffi_call_SYSV_end-ffi_call_SYSV
.section .eh_frame,"aw",@progbits
__FRAME_BEGIN__:
.4byte .LLCIE1
.LSCIE1:
.4byte 0x0
.byte 0x1
.byte 0x0
.byte 0x1
.byte 0x7c
.byte 0x8
.byte 0xc
.byte 0x4
.byte 0x4
.byte 0x88
.byte 0x1
.align 4
.LECIE1:
.set .LLCIE1,.LECIE1-.LSCIE1
.4byte .LLFDE1
.LSFDE1:
.4byte .LSFDE1-__FRAME_BEGIN__
.4byte .LFB1
.4byte .LFE1-.LFB1
.byte 0x4
.4byte .LCFI0-.LFB1
.byte 0xe
.byte 0x8
.byte 0x85
.byte 0x2
.byte 0x4
.4byte .LCFI1-.LCFI0
.byte 0xd
.byte 0x5
.align 4
.LEFDE1:
.set .LLFDE1,.LEFDE1-.LSFDE1
+125
View File
@@ -0,0 +1,125 @@
/* -----------------------------------------------------------------------
win32.S - Copyright (c) 1996, 1998, 2001 Cygnus Solutions
X86 Foreign Function Interface
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
``Software''), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------- */
#define LIBFFI_ASM
#include <ffi.h>
.text
.globl ffi_prep_args
# This assumes we are using gas.
.balign 16
.globl _ffi_call_SYSV
_ffi_call_SYSV:
pushl %ebp
movl %esp,%ebp
# Make room for all of the new args.
movl 16(%ebp),%ecx
subl %ecx,%esp
movl %esp,%eax
# Place all of the ffi_prep_args in position
pushl 12(%ebp)
pushl %eax
call *8(%ebp)
# Return stack to previous state and call the function
addl $8,%esp
call *28(%ebp)
# Remove the space we pushed for the args
movl 16(%ebp),%ecx
addl %ecx,%esp
# Load %ecx with the return type code
movl 20(%ebp),%ecx
# If the return value pointer is NULL, assume no return value.
cmpl $0,24(%ebp)
jne retint
# Even if there is no space for the return value, we are
# obliged to handle floating-point values.
cmpl $FFI_TYPE_FLOAT,%ecx
jne noretval
fstp %st(0)
jmp epilogue
retint:
cmpl $FFI_TYPE_INT,%ecx
jne retfloat
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
jmp epilogue
retfloat:
cmpl $FFI_TYPE_FLOAT,%ecx
jne retdouble
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstps (%ecx)
jmp epilogue
retdouble:
cmpl $FFI_TYPE_DOUBLE,%ecx
jne retlongdouble
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstpl (%ecx)
jmp epilogue
retlongdouble:
cmpl $FFI_TYPE_LONGDOUBLE,%ecx
jne retint64
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
fstpt (%ecx)
jmp epilogue
retint64:
cmpl $FFI_TYPE_SINT64,%ecx
jne retstruct
# Load %ecx with the pointer to storage for the return value
movl 24(%ebp),%ecx
movl %eax,0(%ecx)
movl %edx,4(%ecx)
retstruct:
# Nothing to do!
noretval:
epilogue:
movl %ebp,%esp
popl %ebp
ret
.ffi_call_SYSV_end:
+12 -1
View File
@@ -1 +1,12 @@
Miguel de Icaza ([email protected])
C# Compiler:
Miguel de Icaza ([email protected])
Class Libraries:
Jeff Stedfast ([email protected])
Joe Shaw ([email protected])
Miguel de Icaza ([email protected])
Sean MacIsaac ([email protected])
Vladimir Vukicevic ([email protected])
Garrett Rooney ([email protected])
Bob Smith ([email protected])
John Barnette ([email protected])
+20 -1
View File
@@ -1,2 +1,21 @@
This is the Ximian MCS C# compiler written in C#
This contains the Mono C# compiler as well as the Mono runtime
library.
Layout:
class/
Class libraries
errors/
Sample programs that should generate errors by the compiler.
jay/
Yacc-based parser generator.
mcs/
The Mono C# compiler
tests/
Sample tests
@@ -0,0 +1,8 @@
2001-08-17 Mike Kestner <[email protected]>
* PointF.cs, Size.cs, SizeF.cs : New struct implementations.
2001-08-16 Mike Kestner <[email protected]>
* Point.cs : New. Implementation of System.Drawing.Point struct.
@@ -0,0 +1,339 @@
//
// System.Drawing.Point.cs
//
// Author:
// Mike Kestner ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
using System;
namespace System.Drawing {
public struct Point {
// Private x and y coordinate fields.
int cx, cy;
// -----------------------
// Public Shared Members
// -----------------------
/// <summary>
/// Empty Shared Field
/// </summary>
///
/// <remarks>
/// An uninitialized Point Structure.
/// </remarks>
public static readonly Point Empty;
/// <summary>
/// Ceiling Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Point structure from a PointF structure by
/// taking the ceiling of the X and Y properties.
/// </remarks>
public static Point Ceiling (PointF value)
{
int x, y;
checked {
x = (int) Math.Ceiling (value.X);
y = (int) Math.Ceiling (value.Y);
}
return new Point (x, y);
}
/// <summary>
/// Round Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Point structure from a PointF structure by
/// rounding the X and Y properties.
/// </remarks>
public static Point Round (PointF value)
{
int x, y;
checked {
x = (int) Math.Round (value.X);
y = (int) Math.Round (value.Y);
}
return new Point (x, y);
}
/// <summary>
/// Truncate Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Point structure from a PointF structure by
/// truncating the X and Y properties.
/// </remarks>
// LAMESPEC: Should this be floor, or a pure cast to int?
public static Point Truncate (PointF value)
{
int x, y;
checked {
x = (int) value.X;
y = (int) value.Y;
}
return new Point (x, y);
}
/// <summary>
/// Addition Operator
/// </summary>
///
/// <remarks>
/// Translates a Point using the Width and Height
/// properties of the given <typeref>Size</typeref>.
/// </remarks>
public static Point operator + (Point pt, Size sz)
{
return new Point (pt.X + sz.Width, pt.Y + sz.Height);
}
/// <summary>
/// Equality Operator
/// </summary>
///
/// <remarks>
/// Compares two Point objects. The return value is
/// based on the equivalence of the X and Y properties
/// of the two points.
/// </remarks>
public static bool operator == (Point pt_a, Point pt_b)
{
return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
}
/// <summary>
/// Inequality Operator
/// </summary>
///
/// <remarks>
/// Compares two Point objects. The return value is
/// based on the equivalence of the X and Y properties
/// of the two points.
/// </remarks>
public static bool operator != (Point pt_a, Point pt_b)
{
return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
}
/// <summary>
/// Subtraction Operator
/// </summary>
///
/// <remarks>
/// Translates a Point using the negation of the Width
/// and Height properties of the given Size.
/// </remarks>
public static Point operator - (Point pt, Size sz)
{
return new Point (pt.X - sz.Width, pt.Y - sz.Height);
}
/// <summary>
/// Point to Size Conversion
/// </summary>
///
/// <remarks>
/// Returns a Size based on the Coordinates of a given
/// Point. Requires explicit cast.
/// </remarks>
public static explicit operator Size (Point pt)
{
return new Size (pt.X, pt.Y);
}
/// <summary>
/// Point to PointF Conversion
/// </summary>
///
/// <remarks>
/// Creates a PointF based on the coordinates of a given
/// Point. No explicit cast is required.
/// </remarks>
public static implicit operator PointF (Point pt)
{
return new PointF (pt.X, pt.Y);
}
// -----------------------
// Public Constructors
// -----------------------
/// <summary>
/// Point Constructor
/// </summary>
///
/// <remarks>
/// Creates a Point from an integer which holds the X
/// coordinate in the high order 16 bits and the Y
/// coordinate in the low order 16 bits.
/// </remarks>
public Point (int dw)
{
cx = dw >> 16;
cy = dw & 0xffff;
}
/// <summary>
/// Point Constructor
/// </summary>
///
/// <remarks>
/// Creates a Point from a Size value.
/// </remarks>
public Point (Size sz)
{
cx = sz.Width;
cy = sz.Height;
}
/// <summary>
/// Point Constructor
/// </summary>
///
/// <remarks>
/// Creates a Point from a specified x,y coordinate pair.
/// </remarks>
public Point (int x, int y)
{
cx = x;
cy = y;
}
// -----------------------
// Public Instance Members
// -----------------------
/// <summary>
/// IsEmpty Property
/// </summary>
///
/// <remarks>
/// Indicates if both X and Y are zero.
/// </remarks>
public bool IsEmpty {
get {
return ((cx == 0) && (cy == 0));
}
}
/// <summary>
/// X Property
/// </summary>
///
/// <remarks>
/// The X coordinate of the Point.
/// </remarks>
public int X {
get {
return cx;
}
set {
cx = value;
}
}
/// <summary>
/// Y Property
/// </summary>
///
/// <remarks>
/// The Y coordinate of the Point.
/// </remarks>
public int Y {
get {
return cy;
}
set {
cy = value;
}
}
/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this Point and another object.
/// </remarks>
public override bool Equals (object o)
{
if (!(o is Point))
return false;
return (this == (Point) o);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return cx^cy;
}
/// <summary>
/// Offset Method
/// </summary>
///
/// <remarks>
/// Moves the Point a specified distance.
/// </remarks>
public void Offset (int dx, int dy)
{
cx += dx;
cy += dy;
}
/// <summary>
/// ToString Method
/// </summary>
///
/// <remarks>
/// Formats the Point as a string in coordinate notation.
/// </remarks>
public override string ToString ()
{
return String.Format ("[{0},{1}]", cx, cy);
}
}
}
@@ -0,0 +1,204 @@
//
// System.Drawing.PointF.cs
//
// Author:
// Mike Kestner ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
using System;
namespace System.Drawing {
public struct PointF {
// Private x and y coordinate fields.
float cx, cy;
// -----------------------
// Public Shared Members
// -----------------------
/// <summary>
/// Empty Shared Field
/// </summary>
///
/// <remarks>
/// An uninitialized PointF Structure.
/// </remarks>
public static readonly PointF Empty;
/// <summary>
/// Addition Operator
/// </summary>
///
/// <remarks>
/// Translates a PointF using the Width and Height
/// properties of the given Size.
/// </remarks>
public static PointF operator + (PointF pt, Size sz)
{
return new PointF (pt.X + sz.Width, pt.Y + sz.Height);
}
/// <summary>
/// Equality Operator
/// </summary>
///
/// <remarks>
/// Compares two PointF objects. The return value is
/// based on the equivalence of the X and Y properties
/// of the two points.
/// </remarks>
public static bool operator == (PointF pt_a, PointF pt_b)
{
return ((pt_a.X == pt_b.X) && (pt_a.Y == pt_b.Y));
}
/// <summary>
/// Inequality Operator
/// </summary>
///
/// <remarks>
/// Compares two PointF objects. The return value is
/// based on the equivalence of the X and Y properties
/// of the two points.
/// </remarks>
public static bool operator != (PointF pt_a, PointF pt_b)
{
return ((pt_a.X != pt_b.X) || (pt_a.Y != pt_b.Y));
}
/// <summary>
/// Subtraction Operator
/// </summary>
///
/// <remarks>
/// Translates a PointF using the negation of the Width
/// and Height properties of the given Size.
/// </remarks>
public static PointF operator - (PointF pt, Size sz)
{
return new PointF (pt.X - sz.Width, pt.Y - sz.Height);
}
// -----------------------
// Public Constructor
// -----------------------
/// <summary>
/// PointF Constructor
/// </summary>
///
/// <remarks>
/// Creates a PointF from a specified x,y coordinate pair.
/// </remarks>
public PointF (float x, float y)
{
cx = x;
cy = y;
}
// -----------------------
// Public Instance Members
// -----------------------
/// <summary>
/// IsEmpty Property
/// </summary>
///
/// <remarks>
/// Indicates if both X and Y are zero.
/// </remarks>
public bool IsEmpty {
get {
return ((cx == 0.0) && (cy == 0.0));
}
}
/// <summary>
/// X Property
/// </summary>
///
/// <remarks>
/// The X coordinate of the PointF.
/// </remarks>
public float X {
get {
return cx;
}
set {
cx = value;
}
}
/// <summary>
/// Y Property
/// </summary>
///
/// <remarks>
/// The Y coordinate of the PointF.
/// </remarks>
public float Y {
get {
return cy;
}
set {
cy = value;
}
}
/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this PointF and another object.
/// </remarks>
public override bool Equals (object o)
{
if (!(o is PointF))
return false;
return (this == (PointF) o);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return (int) cx ^ (int) cy;
}
/// <summary>
/// ToString Method
/// </summary>
///
/// <remarks>
/// Formats the PointF as a string in coordinate notation.
/// </remarks>
public override string ToString ()
{
return String.Format ("[{0},{1}]", cx, cy);
}
}
}
@@ -0,0 +1,309 @@
//
// System.Drawing.Size.cs
//
// Author:
// Mike Kestner ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
using System;
namespace System.Drawing {
public struct Size {
// Private height and width fields.
int wd, ht;
// -----------------------
// Public Shared Members
// -----------------------
/// <summary>
/// Empty Shared Field
/// </summary>
///
/// <remarks>
/// An uninitialized Size Structure.
/// </remarks>
public static readonly Size Empty;
/// <summary>
/// Ceiling Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Size structure from a SizeF structure by
/// taking the ceiling of the Width and Height properties.
/// </remarks>
public static Size Ceiling (SizeF value)
{
int w, h;
checked {
w = (int) Math.Ceiling (value.Width);
h = (int) Math.Ceiling (value.Height);
}
return new Size (w, h);
}
/// <summary>
/// Round Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Size structure from a SizeF structure by
/// rounding the Width and Height properties.
/// </remarks>
public static Size Round (SizeF value)
{
int w, h;
checked {
w = (int) Math.Round (value.Width);
h = (int) Math.Round (value.Height);
}
return new Size (w, h);
}
/// <summary>
/// Truncate Shared Method
/// </summary>
///
/// <remarks>
/// Produces a Size structure from a SizeF structure by
/// truncating the Width and Height properties.
/// </remarks>
public static Size Truncate (SizeF value)
{
int w, h;
checked {
w = (int) value.Width;
h = (int) value.Height;
}
return new Size (w, h);
}
/// <summary>
/// Addition Operator
/// </summary>
///
/// <remarks>
/// Addition of two Size structures.
/// </remarks>
public static Size operator + (Size sz1, Size sz2)
{
return new Size (sz1.Width + sz2.Width,
sz1.Height + sz2.Height);
}
/// <summary>
/// Equality Operator
/// </summary>
///
/// <remarks>
/// Compares two Size objects. The return value is
/// based on the equivalence of the Width and Height
/// properties of the two Sizes.
/// </remarks>
public static bool operator == (Size sz_a, Size sz_b)
{
return ((sz_a.Width == sz_b.Width) &&
(sz_a.Height == sz_b.Height));
}
/// <summary>
/// Inequality Operator
/// </summary>
///
/// <remarks>
/// Compares two Size objects. The return value is
/// based on the equivalence of the Width and Height
/// properties of the two Sizes.
/// </remarks>
public static bool operator != (Size sz_a, Size sz_b)
{
return ((sz_a.Width != sz_b.Width) ||
(sz_a.Height != sz_b.Height));
}
/// <summary>
/// Subtraction Operator
/// </summary>
///
/// <remarks>
/// Subtracts two Size structures.
/// </remarks>
public static Size operator - (Size sz1, Size sz2)
{
return new Size (sz1.Width - sz2.Width,
sz1.Height - sz2.Height);
}
/// <summary>
/// Size to Point Conversion
/// </summary>
///
/// <remarks>
/// Returns a Point based on the dimensions of a given
/// Size. Requires explicit cast.
/// </remarks>
public static explicit operator Point (Size sz)
{
return new Point (sz.Width, sz.Height);
}
/// <summary>
/// Size to SizeF Conversion
/// </summary>
///
/// <remarks>
/// Creates a SizeF based on the dimensions of a given
/// Size. No explicit cast is required.
/// </remarks>
public static implicit operator SizeF (Size sz)
{
return new SizeF (sz.Width, sz.Height);
}
// -----------------------
// Public Constructors
// -----------------------
/// <summary>
/// Size Constructor
/// </summary>
///
/// <remarks>
/// Creates a Size from a Point value.
/// </remarks>
public Size (Point pt)
{
wd = pt.X;
ht = pt.Y;
}
/// <summary>
/// Size Constructor
/// </summary>
///
/// <remarks>
/// Creates a Size from specified dimensions.
/// </remarks>
public Size (int width, int height)
{
wd = width;
ht = height;
}
// -----------------------
// Public Instance Members
// -----------------------
/// <summary>
/// IsEmpty Property
/// </summary>
///
/// <remarks>
/// Indicates if both Width and Height are zero.
/// </remarks>
public bool IsEmpty {
get {
return ((wd == 0) && (ht == 0));
}
}
/// <summary>
/// Width Property
/// </summary>
///
/// <remarks>
/// The Width coordinate of the Size.
/// </remarks>
public int Width {
get {
return wd;
}
set {
wd = value;
}
}
/// <summary>
/// Height Property
/// </summary>
///
/// <remarks>
/// The Height coordinate of the Size.
/// </remarks>
public int Height {
get {
return ht;
}
set {
ht = value;
}
}
/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this Size and another object.
/// </remarks>
public override bool Equals (object o)
{
if (!(o is Size))
return false;
return (this == (Size) o);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return wd^ht;
}
/// <summary>
/// ToString Method
/// </summary>
///
/// <remarks>
/// Formats the Size as a string in coordinate notation.
/// </remarks>
public override string ToString ()
{
return String.Format ("[{0},{1}]", wd, ht);
}
}
}
@@ -0,0 +1,249 @@
//
// System.Drawing.SizeF.cs
//
// Author:
// Mike Kestner ([email protected])
//
// (C) Ximian, Inc. http://www.ximian.com
//
using System;
namespace System.Drawing {
public struct SizeF {
// Private height and width fields.
float wd, ht;
// -----------------------
// Public Shared Members
// -----------------------
/// <summary>
/// Empty Shared Field
/// </summary>
///
/// <remarks>
/// An uninitialized SizeF Structure.
/// </remarks>
public static readonly SizeF Empty;
/// <summary>
/// Addition Operator
/// </summary>
///
/// <remarks>
/// Addition of two SizeF structures.
/// </remarks>
public static SizeF operator + (SizeF sz1, SizeF sz2)
{
return new SizeF (sz1.Width + sz2.Width,
sz1.Height + sz2.Height);
}
/// <summary>
/// Equality Operator
/// </summary>
///
/// <remarks>
/// Compares two SizeF objects. The return value is
/// based on the equivalence of the Width and Height
/// properties of the two Sizes.
/// </remarks>
public static bool operator == (SizeF sz_a, SizeF sz_b)
{
return ((sz_a.Width == sz_b.Width) &&
(sz_a.Height == sz_b.Height));
}
/// <summary>
/// Inequality Operator
/// </summary>
///
/// <remarks>
/// Compares two SizeF objects. The return value is
/// based on the equivalence of the Width and Height
/// properties of the two Sizes.
/// </remarks>
public static bool operator != (SizeF sz_a, SizeF sz_b)
{
return ((sz_a.Width != sz_b.Width) ||
(sz_a.Height != sz_b.Height));
}
/// <summary>
/// Subtraction Operator
/// </summary>
///
/// <remarks>
/// Subtracts two SizeF structures.
/// </remarks>
public static SizeF operator - (SizeF sz1, SizeF sz2)
{
return new SizeF (sz1.Width - sz2.Width,
sz1.Height - sz2.Height);
}
/// <summary>
/// SizeF to PointF Conversion
/// </summary>
///
/// <remarks>
/// Returns a PointF based on the dimensions of a given
/// SizeF. Requires explicit cast.
/// </remarks>
public static explicit operator PointF (SizeF sz)
{
return new PointF (sz.Width, sz.Height);
}
// -----------------------
// Public Constructors
// -----------------------
/// <summary>
/// SizeF Constructor
/// </summary>
///
/// <remarks>
/// Creates a SizeF from a PointF value.
/// </remarks>
public SizeF (PointF pt)
{
wd = pt.X;
ht = pt.Y;
}
/// <summary>
/// SizeF Constructor
/// </summary>
///
/// <remarks>
/// Creates a SizeF from an existing SizeF value.
/// </remarks>
public SizeF (SizeF sz)
{
wd = sz.Width;
ht = sz.Height;
}
/// <summary>
/// SizeF Constructor
/// </summary>
///
/// <remarks>
/// Creates a SizeF from specified dimensions.
/// </remarks>
public SizeF (float width, float height)
{
wd = width;
ht = height;
}
// -----------------------
// Public Instance Members
// -----------------------
/// <summary>
/// IsEmpty Property
/// </summary>
///
/// <remarks>
/// Indicates if both Width and Height are zero.
/// </remarks>
public bool IsEmpty {
get {
return ((wd == 0.0) && (ht == 0.0));
}
}
/// <summary>
/// Width Property
/// </summary>
///
/// <remarks>
/// The Width coordinate of the SizeF.
/// </remarks>
public float Width {
get {
return wd;
}
set {
wd = value;
}
}
/// <summary>
/// Height Property
/// </summary>
///
/// <remarks>
/// The Height coordinate of the SizeF.
/// </remarks>
public float Height {
get {
return ht;
}
set {
ht = value;
}
}
/// <summary>
/// Equals Method
/// </summary>
///
/// <remarks>
/// Checks equivalence of this SizeF and another object.
/// </remarks>
public override bool Equals (object o)
{
if (!(o is SizeF))
return false;
return (this == (SizeF) o);
}
/// <summary>
/// GetHashCode Method
/// </summary>
///
/// <remarks>
/// Calculates a hashing value.
/// </remarks>
public override int GetHashCode ()
{
return (int) wd ^ (int) ht;
}
/// <summary>
/// ToString Method
/// </summary>
///
/// <remarks>
/// Formats the SizeF as a string in coordinate notation.
/// </remarks>
public override string ToString ()
{
return String.Format ("[{0},{1}]", wd, ht);
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
all: windows
windows:
$(csc) /target:library /out:System.Drawing.dll /nowarn:1595 /recurse:*.cs
$(CSC) /target:library /out:System.Drawing.dll /nowarn:1595 /recurse:*.cs
+16
View File
@@ -0,0 +1,16 @@
2001-08-22 Bob Smith <[email protected]>
* Added directory: System.Web.UI.HtmlControls
* Added directory: Test
2001-08-17 Bob Smith <[email protected]>
* Added directory: System.Web.UI
2001-08-09 Bob Smith <[email protected]>
* Added directory: System.Web
2001-07-20 Patrik Torstensson ([email protected])
* Added directory: System.Web.Caching
@@ -0,0 +1,520 @@
//
// System.Web.Caching
//
// Author:
// Patrik Torstensson ([email protected])
//
// (C) Copyright Patrik Torstensson, 2001
//
namespace System.Web.Caching
{
/// <summary>
/// Implements a cache for Web applications and other. The difference from the MS.NET implementation is that we
/// support to use the Cache object as cache in our applications.
/// </summary>
/// <remarks>
/// The Singleton cache is created per application domain, and it remains valid as long as the application domain remains active.
/// </remarks>
/// <example>
/// Usage of the singleton cache:
///
/// Cache objManager = Cache.SingletonCache;
///
/// String obj = "tobecached";
/// objManager.Add("kalle", obj);
/// </example>
public class Cache : System.Collections.IEnumerable, System.IDisposable
{
// Declarations
// MS.NET Does only have the cache connected to the HttpRuntime and we don't have the HttpRuntime (yet)
static Cache objSingletonCache = new Cache();
private bool _boolDisposed;
// Helper objects
private CacheExpires _objExpires;
// The data storage
// Todo: Make a specialized storage for the cache entries?
// todo: allow system to replace the storage?
private System.Collections.Hashtable _arrEntries;
private System.Threading.ReaderWriterLock _lockEntries;
static private System.TimeSpan _datetimeOneYear = System.TimeSpan.FromDays(365);
// Number of items in the cache
private long _longItems;
// Constructor
public Cache()
{
_boolDisposed = false;
_longItems = 0;
_lockEntries = new System.Threading.ReaderWriterLock();
_arrEntries = new System.Collections.Hashtable();
_objExpires = new CacheExpires(this);
}
// Public methods and properties
//
/// <summary>
/// Returns a static version of the cache. In MS.NET the cache is stored in the System.Web.HttpRuntime
/// but we keep it here as a singleton (right now anyway).
/// </summary>
public static Cache SingletonCache
{
get
{
if (objSingletonCache == null)
{
throw new System.InvalidOperationException();
}
return objSingletonCache;
}
}
/// <summary>
/// Used in the absoluteExpiration parameter in an Insert method call to indicate the item should never expire. This field is read-only.
/// </summary>
public static readonly System.DateTime NoAbsoluteExpiration = System.DateTime.MaxValue;
/// <summary>
/// Used as the slidingExpiration parameter in an Insert method call to disable sliding expirations. This field is read-only.
/// </summary>
public static readonly System.TimeSpan NoSlidingExpiration = System.TimeSpan.Zero;
/// <summary>
/// Internal method to create a enumerator and over all public items in the cache and is used by GetEnumerator method.
/// </summary>
/// <returns>Returns IDictionaryEnumerator that contains all public items in the cache</returns>
private System.Collections.IDictionaryEnumerator CreateEnumerator()
{
System.Collections.Hashtable objTable;
_lockEntries.AcquireReaderLock(int.MaxValue);
try
{
// Create a new hashtable to return as collection of public items
objTable = new System.Collections.Hashtable(_arrEntries.Count);
foreach(System.Collections.DictionaryEntry objEntry in _arrEntries)
{
if (objEntry.Key != null)
{
// Check if this is a public entry
if (((CacheEntry) objEntry.Value).TestFlag(CacheEntry.Flags.Public))
{
// Add to the collection
objTable.Add(objEntry.Key, ((CacheEntry) objEntry.Value).Item);
}
}
}
}
finally
{
_lockEntries.ReleaseReaderLock();
}
return objTable.GetEnumerator();
}
/// <summary>
/// Implementation of IEnumerable interface and calls the GetEnumerator that returns
/// IDictionaryEnumerator.
/// </summary>
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/// <summary>
/// Virtual override of the IEnumerable.GetEnumerator() method, returns a specialized enumerator.
/// </summary>
public virtual System.Collections.IDictionaryEnumerator GetEnumerator()
{
return CreateEnumerator();
}
/// <summary>
/// Touches a object in the cache. Used to update expire time and hit count.
/// </summary>
/// <param name="strKey">The identifier for the cache item to retrieve.</param>
public void Touch(string strKey)
{
// Just touch the object
Get(strKey);
}
/// <summary>
/// Adds the specified item to the Cache object with dependencies, expiration and priority policies, and a
/// delegate you can use to notify your application when the inserted item is removed from the Cache.
/// </summary>
/// <param name="strKey">The cache key used to reference the item.</param>
/// <param name="objItem">The item to be added to the cache.</param>
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
/// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
/// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
/// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
/// <param name="enumPriorityDecay">The rate at which an object in the cache decays in importance. Objects that decay quickly are more likely to be removed.</param>
/// <param name="eventRemoveCallback">A delegate that, if provided, is called when an object is removed from the cache. You can use this to notify applications when their objects are deleted from the cache.</param>
/// <returns>The Object item added to the Cache.</returns>
public object Add(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration, CacheItemPriority enumPriority, CacheItemPriorityDecay enumPriorityDecay, CacheItemRemovedCallback eventRemoveCallback)
{
if (_boolDisposed)
{
throw new System.ObjectDisposedException("System.Web.Cache");
}
if (strKey == null)
{
throw new System.ArgumentNullException("strKey");
}
if (objItem == null)
{
throw new System.ArgumentNullException("objItem");
}
if (slidingExpiration > _datetimeOneYear)
{
throw new System.ArgumentOutOfRangeException("slidingExpiration");
}
CacheEntry objEntry;
CacheEntry objNewEntry;
long longHitRange = 10000;
// todo: check decay and make up the minHit range
objEntry = new CacheEntry(this, strKey, objItem, objDependency, eventRemoveCallback, absolutExpiration, slidingExpiration, longHitRange, true, enumPriority);
System.Threading.Interlocked.Increment(ref _longItems);
// If we have any kind of expiration add into the CacheExpires class
if (objEntry.HasSlidingExpiration || objEntry.HasAbsoluteExpiration)
{
// Add it to CacheExpires
_objExpires.Add(objEntry);
}
// Check and get the new item..
objNewEntry = UpdateCache(strKey, objEntry, true, CacheItemRemovedReason.Removed);
if (objNewEntry != null)
{
// Return added item
return objEntry.Item;
}
else
{
return null;
}
}
/// <summary>
/// Inserts an item into the Cache object with a cache key to reference its location and using default values
/// provided by the CacheItemPriority and CacheItemPriorityDecay enumerations.
/// </summary>
/// <param name="strKey">The cache key used to reference the item.</param>
/// <param name="objItem">The item to be added to the cache.</param>
public void Insert(string strKey, object objItem)
{
Add(strKey, objItem, null, System.DateTime.MaxValue, System.TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
}
/// <summary>
/// Inserts an object into the Cache that has file or key dependencies.
/// </summary>
/// <param name="strKey">The cache key used to reference the item.</param>
/// <param name="objItem">The item to be added to the cache.</param>
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
public void Insert(string strKey, object objItem, CacheDependency objDependency)
{
Add(strKey, objItem, objDependency, System.DateTime.MaxValue, System.TimeSpan.Zero, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
}
/// <summary>
/// Inserts an object into the Cache with dependencies and expiration policies.
/// </summary>
/// <param name="strKey">The cache key used to reference the item.</param>
/// <param name="objItem">The item to be added to the cache.</param>
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
/// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
/// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
public void Insert(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration)
{
Add(strKey, objItem, objDependency, absolutExpiration, slidingExpiration, CacheItemPriority.Default, CacheItemPriorityDecay.Default, null);
}
/// <summary>
/// Inserts an object into the Cache object with dependencies, expiration and priority policies, and a delegate
/// you can use to notify your application when the inserted item is removed from the Cache.
/// </summary>
/// <param name="strKey">The cache key used to reference the item.</param>
/// <param name="objItem">The item to be added to the cache.</param>
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
/// <param name="absolutExpiration">The time at which the added object expires and is removed from the cache. </param>
/// <param name="slidingExpiration">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
/// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
/// <param name="enumPriorityDecay">The rate at which an object in the cache decays in importance. Objects that decay quickly are more likely to be removed.</param>
/// <param name="eventRemoveCallback">A delegate that, if provided, is called when an object is removed from the cache. You can use this to notify applications when their objects are deleted from the cache.</param>
public void Insert(string strKey, object objItem, CacheDependency objDependency, System.DateTime absolutExpiration, System.TimeSpan slidingExpiration, CacheItemPriority enumPriority, CacheItemPriorityDecay enumPriorityDecay, CacheItemRemovedCallback eventRemoveCallback)
{
Add(strKey, objItem, objDependency, absolutExpiration, slidingExpiration, enumPriority, enumPriorityDecay, eventRemoveCallback);
}
/// <summary>
/// Removes the specified item from the Cache object.
/// </summary>
/// <param name="strKey">The cache key for the cache item to remove.</param>
/// <returns>The item removed from the Cache. If the value in the key parameter is not found, returns a null reference.</returns>
public object Remove(string strKey)
{
return Remove(strKey, CacheItemRemovedReason.Removed);
}
/// <summary>
/// Internal method that updates the cache, decremenents the number of existing items and call close on the cache entry. This method
/// is also used from the ExpiresBuckets class to remove an item during GC flush.
/// </summary>
/// <param name="strKey">The cache key for the cache item to remove.</param>
/// <param name="enumReason">Reason why the item is removed.</param>
/// <returns>The item removed from the Cache. If the value in the key parameter is not found, returns a null reference.</returns>
internal object Remove(string strKey, CacheItemRemovedReason enumReason)
{
CacheEntry objEntry = UpdateCache(strKey, null, true, enumReason);
if (objEntry != null)
{
System.Threading.Interlocked.Decrement(ref _longItems);
// Close the cache entry (calls the remove delegate)
objEntry.Close(enumReason);
return objEntry.Item;
} else
{
return null;
}
}
/// <summary>
/// Retrieves the specified item from the Cache object.
/// </summary>
/// <param name="strKey">The identifier for the cache item to retrieve.</param>
/// <returns>The retrieved cache item, or a null reference.</returns>
public object Get(string strKey)
{
CacheEntry objEntry = UpdateCache(strKey, null, false, CacheItemRemovedReason.Expired);
if (objEntry == null)
{
return null;
} else
{
return objEntry.Item;
}
}
/// <summary>
/// Internal method used for removing, updating and adding CacheEntries into the cache.
/// </summary>
/// <param name="strKey">The identifier for the cache item to modify</param>
/// <param name="objEntry">CacheEntry to use for overwrite operation, if this parameter is null and overwrite true the item is going to be removed</param>
/// <param name="boolOverwrite">If true the objEntry parameter is used to overwrite the strKey entry</param>
/// <param name="enumReason">Reason why an item was removed</param>
/// <returns></returns>
private CacheEntry UpdateCache(string strKey, CacheEntry objEntry, bool boolOverwrite, CacheItemRemovedReason enumReason)
{
if (_boolDisposed)
{
throw new System.ObjectDisposedException("System.Web.Cache", "Can't update item(s) in a disposed cache");
}
if (strKey == null)
{
throw new System.ArgumentNullException("System.Web.Cache");
}
long ticksNow = System.DateTime.Now.Ticks;
long ticksExpires = long.MaxValue;
bool boolGetItem = false;
bool boolExpiried = false;
bool boolWrite = false;
bool boolRemoved = false;
// Are we getting the item from the hashtable
if (boolOverwrite == false && strKey.Length > 0 && objEntry == null)
{
boolGetItem = true;
}
// TODO: Optimize this method, move out functionality outside the lock
_lockEntries.AcquireReaderLock(int.MaxValue);
try
{
if (boolGetItem)
{
objEntry = (CacheEntry) _arrEntries[strKey];
if (objEntry == null)
{
return null;
}
}
if (objEntry != null)
{
// Check if we have expired
if (objEntry.HasSlidingExpiration || objEntry.HasAbsoluteExpiration)
{
if (objEntry.Expires < ticksNow)
{
// We have expired, remove the item from the cache
boolWrite = true;
boolExpiried = true;
}
}
}
// Check if we going to modify the hashtable
if (boolWrite || (boolOverwrite && !boolExpiried))
{
// Upgrade our lock to write
System.Threading.LockCookie objCookie = _lockEntries.UpgradeToWriterLock(int.MaxValue);
try
{
// Check if we going to just modify an existing entry (or add)
if (boolOverwrite && objEntry != null)
{
_arrEntries[strKey] = objEntry;
}
else
{
// We need to remove the item, fetch the item first
objEntry = (CacheEntry) _arrEntries[strKey];
if (objEntry != null)
{
_arrEntries.Remove(strKey);
}
boolRemoved = true;
}
}
finally
{
_lockEntries.DowngradeFromWriterLock(ref objCookie);
}
}
// If the entry haven't expired or been removed update the info
if (!boolExpiried && !boolRemoved)
{
// Update that we got a hit
objEntry.Hits++;
if (objEntry.HasSlidingExpiration)
{
ticksExpires = ticksNow + objEntry.SlidingExpiration;
}
}
}
finally
{
_lockEntries.ReleaseLock();
}
// If the item was removed we need to remove it from the CacheExpired class also
if (boolRemoved)
{
if (objEntry != null)
{
if (objEntry.HasAbsoluteExpiration || objEntry.HasSlidingExpiration)
{
_objExpires.Remove(objEntry);
}
}
// Return the entry, it's not up to the UpdateCache to call Close on the entry
return objEntry;
}
// If we have sliding expiration and we have a correct hit, update the expiration manager
if (objEntry.HasSlidingExpiration)
{
_objExpires.Update(objEntry, ticksExpires);
}
// Return the cache entry
return objEntry;
}
/// <summary>
/// Gets the number of items stored in the cache.
/// </summary>
long Count
{
get
{
return _longItems;
}
}
/// <summary>
/// Gets or sets the cache item at the specified key.
/// </summary>
public object this[string strKey]
{
get
{
return Get(strKey);
}
set
{
Insert(strKey, value);
}
}
/// <summary>
/// Called to close the cache when the AppDomain is closing down or the GC has decided it's time to destroy the object.
/// </summary>
public void Dispose()
{
_boolDisposed = true;
_lockEntries.AcquireReaderLock(int.MaxValue);
try
{
foreach(System.Collections.DictionaryEntry objEntry in _arrEntries)
{
if (objEntry.Key != null)
{
// Check if this is active
if ( ((CacheEntry) objEntry.Value).TestFlag(CacheEntry.Flags.Removed) )
{
try
{
((CacheEntry) objEntry.Value).Close(CacheItemRemovedReason.Removed);
}
catch (System.Exception objException)
{
System.Diagnostics.Debug.Fail("System.Web.Cache.Dispose() Exception when closing cache entry", "Message: " + objException.Message + " Stack: " + objException.StackTrace + " Source:" + objException.Source);
}
}
}
}
}
finally
{
_lockEntries.ReleaseReaderLock();
}
}
}
}
@@ -0,0 +1,53 @@
//
// System.Web.Caching
//
// Author:
// Patrik Torstensson ([email protected])
//
// (C) Copyright Patrik Torstensson, 2001
//
namespace System.Web.Caching
{
/// <summary>
/// Specifies the relative priority of items stored in the Cache.
/// </summary>
public enum CacheItemPriority {
AboveNormal,
BelowNormal,
Default,
High,
Low,
Normal,
NotRemovable
}
/// <summary>
/// Specifies the rate at which the priority of items stored in the Cache are downgraded when not accessed frequently.
/// </summary>
public enum CacheItemPriorityDecay {
Default,
Fast,
Medium,
Never,
Slow
}
/// <summary>
/// Specifies the reason an item was removed from the Cache.
/// </summary>
public enum CacheItemRemovedReason {
DependencyChanged,
Expired,
Removed,
Underused
}
/// <summary>
/// Defines a callback method for notifying applications when a cached item is removed from the Cache.
/// </summary>
/// <param name="key">The index location for the item removed from the cache. </param>
/// <param name="value">The Object item removed from the cache. </param>
/// <param name="reason">The reason the item was removed from the cache, as specified by the CacheItemRemovedReason enumeration.</param>
public delegate void CacheItemRemovedCallback(string key, object value, CacheItemRemovedReason reason);
}
@@ -0,0 +1,79 @@
//
// System.Web.Caching
//
// Author:
// Patrik Torstensson ([email protected])
//
// (C) Copyright Patrik Torstensson, 2001
//
namespace System.Web.Caching
{
/// <summary>
/// Class to handle cache dependency, right now this class is only a mookup
/// </summary>
public class CacheDependency : System.IDisposable
{
private bool _boolDisposed;
public CacheDependency()
{
_boolDisposed = false;
}
public delegate void CacheDependencyCallback(CacheDependency objDependency);
public event CacheDependencyCallback Changed;
public void OnChanged()
{
if (_boolDisposed)
{
throw new System.ObjectDisposedException("System.Web.CacheDependency");
}
if (Changed != null)
{
Changed(this);
}
}
public bool IsDisposed
{
get
{
return _boolDisposed;
}
}
public bool HasEvents
{
get
{
if (_boolDisposed)
{
throw new System.ObjectDisposedException("System.Web.CacheDependency");
}
if (Changed != null)
{
return true;
}
return false;
}
}
public void Dispose()
{
_boolDisposed = true;
}
/// <summary>
/// Used in testing.
/// </summary>
public void Signal()
{
OnChanged();
}
}
}
@@ -0,0 +1,363 @@
//
// System.Web.Caching
//
// Author:
// Patrik Torstensson ([email protected])
//
// (C) Copyright Patrik Torstensson, 2001
//
namespace System.Web.Caching
{
/// <summary>
/// Class responsible for representing a cache entry.
/// </summary>
public class CacheEntry
{
/// <summary>
/// Defines the status of the current cache entry
/// </summary>
public enum Flags
{
Removed = 0,
Public = 1
}
private CacheItemPriority _enumPriority;
private long _longHits;
private byte _byteExpiresBucket;
private int _intExpiresIndex;
private long _ticksExpires;
private long _ticksSlidingExpiration;
private string _strKey;
private object _objItem;
private long _longMinHits;
private Flags _enumFlags;
private CacheDependency _objDependency;
private Cache _objCache;
/// <summary>
/// Constructs a new cache entry
/// </summary>
/// <param name="strKey">The cache key used to reference the item.</param>
/// <param name="objItem">The item to be added to the cache.</param>
/// <param name="objDependency">The file or cache key dependencies for the item. When any dependency changes, the object becomes invalid and is removed from the cache. If there are no dependencies, this paramter contains a null reference.</param>
/// <param name="dtExpires">The time at which the added object expires and is removed from the cache. </param>
/// <param name="tsSpan">The interval between the time the added object was last accessed and when that object expires. If this value is the equivalent of 20 minutes, the object expires and is removed from the cache 20 minutes after it is last accessed.</param>
/// <param name="longMinHits">Used to detect and control if the item should be flushed due to under usage</param>
/// <param name="boolPublic">Defines if the item is public or not</param>
/// <param name="enumPriority">The relative cost of the object, as expressed by the CacheItemPriority enumeration. The cache uses this value when it evicts objects; objects with a lower cost are removed from the cache before objects with a higher cost.</param>
public CacheEntry( Cache objManager, string strKey, object objItem, CacheDependency objDependency, CacheItemRemovedCallback eventRemove,
System.DateTime dtExpires, System.TimeSpan tsSpan, long longMinHits, bool boolPublic, CacheItemPriority enumPriority )
{
if (boolPublic)
{
SetFlag(Flags.Public);
}
_strKey = strKey;
_objItem = objItem;
_objCache = objManager;
_onRemoved += eventRemove;
_enumPriority = enumPriority;
_ticksExpires = dtExpires.Ticks;
_ticksSlidingExpiration = tsSpan.Ticks;
// If we have a sliding expiration it overrides the absolute expiration (MS behavior)
if (tsSpan.Ticks != System.TimeSpan.Zero.Ticks)
{
_ticksExpires = System.DateTime.Now.AddTicks(_ticksSlidingExpiration).Ticks;
}
_objDependency = objDependency;
if (_objDependency != null)
{
if (_objDependency.IsDisposed)
{
throw new System.ObjectDisposedException("System.Web.CacheDependency");
}
// Add the entry to the cache dependency handler (we support multiple entries per handler)
_objDependency.Changed += new CacheDependency.CacheDependencyCallback(OnChanged);
}
_longMinHits = longMinHits;
}
private event CacheItemRemovedCallback _onRemoved;
public void OnChanged(CacheDependency objDependency)
{
_objCache.Remove(_strKey, CacheItemRemovedReason.DependencyChanged);
}
/// <summary>
/// Cleans up the cache entry, removes the cache dependency and calls the remove delegate.
/// </summary>
/// <param name="enumReason">The reason why the cache entry are going to be removed</param>
public void Close(CacheItemRemovedReason enumReason)
{
lock(this)
{
// Check if the item already is removed
if (TestFlag(Flags.Removed))
{
return;
}
SetFlag(Flags.Removed);
if (_onRemoved != null)
{
// Call the delegate to tell that we are now removing the entry
try
{
_onRemoved(_strKey, _objItem, enumReason);
}
catch (System.Exception objException)
{
System.Diagnostics.Debug.Fail("System.Web.CacheEntry.Close() Exception when calling remove delegate", "Message: " + objException.Message + " Stack: " + objException.StackTrace + " Source:" + objException.Source);
}
}
// If we have a dependency, remove the entry
if (_objDependency != null)
{
_objDependency.Changed -= new CacheDependency.CacheDependencyCallback(OnChanged);
if (!_objDependency.HasEvents)
{
_objDependency.Dispose();
}
}
}
}
/// <summary>
/// Tests a specific flag is set or not.
/// </summary>
/// <param name="oFlag">Flag to test agains</param>
/// <returns>Returns true if the flag is set.</returns>
public bool TestFlag(Flags oFlag)
{
lock(this)
{
if ((_enumFlags & oFlag) != 0)
{
return true;
}
return false;
}
}
/// <summary>
/// Sets a specific flag.
/// </summary>
/// <param name="oFlag">Flag to set.</param>
public void SetFlag(Flags oFlag)
{
lock (this)
{
_enumFlags |= oFlag;
}
}
/// <summary>
/// Returns true if the object has minimum hit usage flushing enabled.
/// </summary>
public bool HasUsage
{
get {
if (_longMinHits == System.Int64.MaxValue)
{
return false;
}
return true;
}
}
/// <summary>
/// Returns true if the entry has absolute expiration.
/// </summary>
public bool HasAbsoluteExpiration
{
get
{
if (_ticksExpires == System.DateTime.MaxValue.Ticks)
{
return false;
}
return true;
}
}
/// <summary>
/// Returns true if the entry has sliding expiration enabled.
/// </summary>
public bool HasSlidingExpiration
{
get
{
if (_ticksSlidingExpiration == System.TimeSpan.Zero.Ticks)
{
return false;
}
return true;
}
}
/// <summary>
/// Gets and sets the current expires bucket the entry is active in.
/// </summary>
public byte ExpiresBucket
{
get
{
lock (this)
{
return _byteExpiresBucket;
}
}
set
{
lock (this)
{
_byteExpiresBucket = ExpiresBucket;
}
}
}
/// <summary>
/// Gets and sets the current index in the expires bucket of the current cache entry.
/// </summary>
public int ExpiresIndex
{
get
{
lock (this)
{
return _intExpiresIndex;
}
}
set
{
lock (this)
{
_intExpiresIndex = ExpiresIndex;
}
}
}
/// <summary>
/// Gets and sets the expiration of the cache entry.
/// </summary>
public long Expires
{
get
{
lock (this)
{
return _ticksExpires;
}
}
set
{
lock (this)
{
_ticksExpires = Expires;
}
}
}
/// <summary>
/// Gets the sliding expiration value. The return value is in ticks (since 0/0-01 in 100nanosec)
/// </summary>
public long SlidingExpiration
{
get
{
return _ticksSlidingExpiration;
}
}
/// <summary>
/// Returns the current cached item.
/// </summary>
public object Item
{
get
{
return _objItem;
}
}
/// <summary>
/// Returns the current cache identifier.
/// </summary>
public string Key
{
get
{
return _strKey;
}
}
/// <summary>
/// Gets and sets the current number of hits on the cache entry.
/// </summary>
public long Hits
{
// todo: Could be optimized by using interlocked methods..
get
{
lock (this)
{
return _longHits;
}
}
set
{
lock (this)
{
_longHits = Hits;
}
}
}
/// <summary>
/// Returns minimum hits for the usage flushing rutine.
/// </summary>
public long MinimumHits
{
get
{
return _longMinHits;
}
}
/// <summary>
/// Returns the priority of the cache entry.
/// </summary>
public CacheItemPriority Priority
{
get
{
return _enumPriority;
}
}
}
}
Loaded 100 of 670 files, more files were not shown because too many files have changed in this diff. Show more