From 67a392a4ef465c4c51b13a540bf2726512299fc0 Mon Sep 17 00:00:00 2001 From: jmcmullan Date: Mon, 20 Aug 2012 03:18:48 +0000 Subject: [PATCH] Tests/Library: Update to new genmodule interfaces Signed-off-by: Jason S. McMullan git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@45614 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- test/library/dummy.conf | 6 ++++ test/library/dummyadd.c | 2 +- test/library/dummybase.h | 18 +++++++++++ test/library/dummylib.c | 17 +++++----- test/library/dummyprint4.c | 6 +++- test/library/getparentbase.c | 2 +- test/library/mmakefile.src | 3 +- test/library/peropenerbase.h | 2 +- test/library/peropenertest.c | 9 +++--- test/library/peropenervalue.c | 4 +-- test/library/pertaskbase.h | 2 +- test/library/pertaskgetparentbase.c | 2 +- test/library/pertaskvalue.c | 4 +-- test/library/pertaskvalue_linklib.c | 62 ++++++++++--------------------------- test/library/userel.conf | 4 +-- test/library/usereltest.c | 2 +- 16 files changed, 74 insertions(+), 71 deletions(-) create mode 100644 test/library/dummybase.h rewrite test/library/pertaskvalue_linklib.c (74%) diff --git a/test/library/dummy.conf b/test/library/dummy.conf index 1adafd1aa8..e4ee0894a0 100644 --- a/test/library/dummy.conf +++ b/test/library/dummy.conf @@ -1,7 +1,13 @@ ##begin config version 1.0 +libbasetype struct DummyBase ##end config +##begin cdefprivate +#include "dummybase.h" +##end cdefprivate + + ##begin functionlist ULONG add(ULONG a, ULONG b) (D0,D1) ULONG asl(ULONG a, ULONG b) (D0,D1) diff --git a/test/library/dummyadd.c b/test/library/dummyadd.c index 93d37ff0bd..1ab0bc1b96 100644 --- a/test/library/dummyadd.c +++ b/test/library/dummyadd.c @@ -4,7 +4,7 @@ */ #include -#include +#include /***************************************************************************** diff --git a/test/library/dummybase.h b/test/library/dummybase.h new file mode 100644 index 0000000000..e34bcee851 --- /dev/null +++ b/test/library/dummybase.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2012, The AROS Development Team. All rights reserved. + * Author: Jason S. McMullan + * + * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1 + */ + +#ifndef DUMMYBASE_H +#define DUMMYBASE_H + +#include + +struct DummyBase { + struct Library db_Lib; + int lastval; +}; + +#endif /* DUMMYBASE_H */ diff --git a/test/library/dummylib.c b/test/library/dummylib.c index f41168cec5..1ce7846c28 100644 --- a/test/library/dummylib.c +++ b/test/library/dummylib.c @@ -13,30 +13,33 @@ #include LC_LIBDEFS_FILE -AROS_LH2I(ULONG, add, +#include "dummybase.h" + +AROS_LH2(ULONG, add, AROS_LHA(ULONG,a,D0), AROS_LHA(ULONG,b,D1), - struct dummybase *,dummybase,5,Dummy + struct DummyBase *,DummyBase,5,Dummy ) { AROS_LIBFUNC_INIT - return a+b; + return (DummyBase->lastval = a+b); AROS_LIBFUNC_EXIT } -AROS_LH2I(ULONG, __int_asl, +AROS_LH2(ULONG, __int_asl, AROS_LHA(ULONG,a,D0), AROS_LHA(ULONG,b,D1), - struct dummybase *,dummybase,6,Dummy + struct DummyBase *,DummyBase,6,Dummy ) { AROS_LIBFUNC_INIT - return a<lastval = a<lastval + va_arg(args, LONG)); } } diff --git a/test/library/dummyprint4.c b/test/library/dummyprint4.c index 6170d2c969..d5ca67c482 100644 --- a/test/library/dummyprint4.c +++ b/test/library/dummyprint4.c @@ -1,6 +1,10 @@ #include -#include +#include + +#include LC_LIBDEFS_FILE + +/* Member of userel.library */ LONG DummyPrint4(LONG a, LONG b, LONG c, LONG d) { diff --git a/test/library/getparentbase.c b/test/library/getparentbase.c index 9f31cfe778..3676c6ffdb 100644 --- a/test/library/getparentbase.c +++ b/test/library/getparentbase.c @@ -21,7 +21,7 @@ AROS_LH0(struct Library *, GetParentBase, struct Library *GetParentBase2(void) { - struct PertaskBase *PertaskBase = __GM_GetBase(); + struct PertaskBase *PertaskBase = __aros_getbase(); return (struct Library *)__GM_GetBaseParent(PertaskBase); } diff --git a/test/library/mmakefile.src b/test/library/mmakefile.src index 15f4e40699..29662d0d04 100644 --- a/test/library/mmakefile.src +++ b/test/library/mmakefile.src @@ -6,6 +6,7 @@ include $(TOP)/config/make.cfg #MM- test-library-usereltest \ #MM- test-library-peropenertest \ #MM- test-library-peropenertest_child +#MM- test-library-userellib: includes-pertask includes-dummy linklibs-pertask linklibs-dummy #MM test-library-dummytest : test-library-dummylib #MM test-library-dummytest_auto : test-library-dummylib #MM test-library-peropenertest : test-library-peropenerlib \ @@ -60,4 +61,4 @@ USER_LDFLAGS := -L$(TARGETDIR)/Development/lib %build_module mmake=test-library-userellib \ modname=userel modtype=library \ files="dummyadd pertaskgetparentbase dummyprint4 getchildvalue" \ - prefix=$(TARGETDIR) uselibs="dummy_rel pertask_rel" + prefix=$(TARGETDIR) diff --git a/test/library/peropenerbase.h b/test/library/peropenerbase.h index 5409179b1c..83805aada0 100644 --- a/test/library/peropenerbase.h +++ b/test/library/peropenerbase.h @@ -6,4 +6,4 @@ struct PeropenerBase int value; }; -APTR __GM_GetBase(); +APTR __aros_getbase(); diff --git a/test/library/peropenertest.c b/test/library/peropenertest.c index fb4d8274e1..98a62e11e2 100644 --- a/test/library/peropenertest.c +++ b/test/library/peropenertest.c @@ -29,14 +29,15 @@ int main (int argc, char ** argv) PeropenerSetValue(2); /* Check value for base2 */ - Printf((STRPTR)"Checking value for base2: %s\n", - (PeropenerGetValue() == 2) ? "OK" : "FAIL!" + Printf((STRPTR)"Checking value for base2: 2 == %ld %s\n", + PeropenerGetValue(), (PeropenerGetValue() == 2) ? "OK" : "FAIL!" ); /* Check value for base2 */ PeropenerBase = base1; - Printf((STRPTR)"Checking value for base1: %s\n", - (PeropenerGetValue() == 1) ? "OK" : "FAIL!" + PeropenerGetValue(); + Printf((STRPTR)"Checking value for base1: 1 == %ld %s\n", + PeropenerGetValue(), (PeropenerGetValue() == 1) ? "OK" : "FAIL!" ); FPrintf(Output(), (STRPTR)"base1=%lx, base2=%lx\n", base1, base2); diff --git a/test/library/peropenervalue.c b/test/library/peropenervalue.c index 5fe4f0d171..d32ebb7787 100644 --- a/test/library/peropenervalue.c +++ b/test/library/peropenervalue.c @@ -2,7 +2,7 @@ void PeropenerSetValue(int value) { - struct PeropenerBase *PeropenerBase = __GM_GetBase(); + struct PeropenerBase *PeropenerBase = __aros_getbase(); PeropenerBase->value = value; } @@ -10,7 +10,7 @@ void PeropenerSetValue(int value) int PeropenerGetValue(void) { - struct PeropenerBase *PeropenerBase = __GM_GetBase(); + struct PeropenerBase *PeropenerBase = __aros_getbase(); return PeropenerBase->value; } diff --git a/test/library/pertaskbase.h b/test/library/pertaskbase.h index 370e3b3d08..1587aed8fa 100644 --- a/test/library/pertaskbase.h +++ b/test/library/pertaskbase.h @@ -6,4 +6,4 @@ struct PertaskBase int value; }; -APTR __GM_GetBase(); +APTR __aros_getbase(); diff --git a/test/library/pertaskgetparentbase.c b/test/library/pertaskgetparentbase.c index f181b857ac..ff7da3cafa 100644 --- a/test/library/pertaskgetparentbase.c +++ b/test/library/pertaskgetparentbase.c @@ -3,7 +3,7 @@ $Id$ */ -#include +#include /***************************************************************************** diff --git a/test/library/pertaskvalue.c b/test/library/pertaskvalue.c index 357fa453d9..2cb9ea3cee 100644 --- a/test/library/pertaskvalue.c +++ b/test/library/pertaskvalue.c @@ -2,7 +2,7 @@ void PertaskSetValue(int value) { - struct PertaskBase *PertaskBase = __GM_GetBase(); + struct PertaskBase *PertaskBase = __aros_getbase(); PertaskBase->value = value; } @@ -10,7 +10,7 @@ void PertaskSetValue(int value) int PertaskGetValue(void) { - struct PertaskBase *PertaskBase = __GM_GetBase(); + struct PertaskBase *PertaskBase = __aros_getbase(); return PertaskBase->value; } diff --git a/test/library/pertaskvalue_linklib.c b/test/library/pertaskvalue_linklib.c dissimilarity index 74% index 0d314720dc..0952970b3d 100644 --- a/test/library/pertaskvalue_linklib.c +++ b/test/library/pertaskvalue_linklib.c @@ -1,46 +1,16 @@ -/* - * This function is in the static link lib. - * It uses the genmodule provided Pertask_GetLibbase() function so it can be - * used both in a library that uses pertask_rel.a or a program that just uses - * pertask.a. - * It does not call a function in pertask.library so that a good optimizing - * compiler with link time function inlining to optimize this very good. - */ -#include "pertaskbase.h" - -#ifdef DOESNT_WORK -struct PertaskBase *Pertask_GetLibbase(void); - -#else /* Does Work */ - -#include -#include -#include - -static struct Library *_PertaskBase; - -static int pertask_linklib_init(void) -{ - _PertaskBase = OpenLibrary("pertask.library", 0); - bug("PertaskBase (link) = %p\n", _PertaskBase); - return TRUE; -} -ADD2INIT(pertask_linklib_init, 10); - -static int pertask_linklib_exit(void) -{ - CloseLibrary(_PertaskBase); - return TRUE; -} -ADD2EXIT(pertask_linklib_exit, 10); - -struct PertaskBase *Pertask_GetLibbase(void) -{ - return (struct PertaskBase *)_PertaskBase; -} -#endif - -int *__pertask_getvalueptr(void) -{ - return &(Pertask_GetLibbase()->value); -} +/* + * This function is in the static link lib. + * It uses the genmodule provided __GM_GetBase_PertaskBase() function so it can be + * used both in a library that uses pertask_rel.a or a program that just uses + * pertask.a. + * It does not call a function in pertask.library so that a good optimizing + * compiler with link time function inlining can optimize this well. + */ +#include "pertaskbase.h" + +struct PertaskBase *__aros_getbase_PertaskBase(void); + +int *__pertask_getvalueptr(void) +{ + return &(__aros_getbase_PertaskBase()->value); +} diff --git a/test/library/userel.conf b/test/library/userel.conf index 1463b86b3a..8720d74ac7 100644 --- a/test/library/userel.conf +++ b/test/library/userel.conf @@ -1,8 +1,8 @@ ##begin config version 1.1 options pertaskbase -relbase DummyBase -relbase PertaskBase +rellib dummy +rellib pertask ##end config ##begin functionlist diff --git a/test/library/usereltest.c b/test/library/usereltest.c index e5571dd9eb..7386ac4e63 100644 --- a/test/library/usereltest.c +++ b/test/library/usereltest.c @@ -22,7 +22,7 @@ int main (int argc, char ** argv) VPrintf((STRPTR)"ParentBase = %ld\n",vec); - Printf("101 202 303 404:\n"); + Printf("104 205 306 407:\n"); DummyPrint4(101, 202, 303, 404); pertaskvalue = 1; -- 2.11.4.GIT