Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
26 user(s) are online (21 user(s) are browsing Forums)

Members: 0
Guests: 26

more...

Support us!

Headlines

 
  Register To Post  

IFACE, libbases and stuff
Home away from home
Home away from home


See User information
It is possible to build aos4 native library which will works fine, without opening of IFaces in the code of library at all _manually_ ? I already use __USE_INLINE__, but as it library i can't use -lauto, so i have bunch of undefs on linking to IFAces.

The problem, is that code which i trying to port heavy use libbases in all kind of conditions, its just define/undef them as need it in whatever place. For example for DOSBase in different sources different defines:

#define DOSBase (((BufFile *)file)->dos)
#define DOSBase (data->dos_base)
#define DOSBase (dos_base)

etc.

So i can't make some global IDOS for all the times (i do one of course, when i open all the libaries in init.c). But then , later they play with it there and there . Do define them, and then undef them. And i do not know how to follow that for os4 library .. should i add opening of IFace right after any #define to DOSBase happens ?

Besides, code put those defines not in functions, but just in meantime. Like:

function1()
function2()
#define to DOSBase
function3()
#undef DOSBase
function4()
function5()

So i can't let's say write a stirng which open IFACE right after define happens (as it will be code, which i can do only in functions).

In general any solution will be fine: or build working library without worring with IFACes (some magic -D flag on linking or whatever), or if somebody can help me out with ideas of how to do all that stuff with all those libbases, that also can be helpfull.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE, libbases and stuff
Not too shy to talk
Not too shy to talk


See User information
Hello Kas1e

I am not sure to understand...

But why dont you open yourself (say) DOSBase in YourLibrary's LibInit then define it as an
extern struct DosLibrary* DOSBase; in all the other source-files

So other file like (say) foo.c will no more use (say) data->dos_base but YOUR DOSBase but that is not a problem


Alain









Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
Quote:

It is possible to build aos4 native library which will works fine, without opening of IFaces in the code of library at all _manually_ ?


No you must open your libs and interfaces in the library init or open code depending on where that is most relevant. (Usualy init).

Quote:

The problem, is that code which i trying to port heavy use libbases in all kind of conditions, its just define/undef them as need it in whatever place. For example for DOSBase in different sources different defines:

#define DOSBase (((BufFile *)file)->dos)
#define DOSBase (data->dos_base)
#define DOSBase (dos_base)


That's what the code is doing allready or what you have done?
Quote:
.

So i can't make some global IDOS for all the times (i do one of course, when i open all the libaries in init.c). But then , later they play with it there and there . Do define them, and then undef them. And i do not know how to follow that for os4 library .. should i add opening of IFace right after any #define to DOSBase happens ?



Okay I see, one thing then could be to open the interface immediately after the base was open. Then make a local macro.

so "pseudo code"

(((BufFile *)file)->dos) = OpenLibrary(dos.library....)
#if defined(__amigaos4__)
(((BufFile *)file)->idos) = OpenInterface((((BufFile *)file)->dos),"main",1)
#endif
...

...

#define DOSBase    (((BufFile *)file)->dos)
#if defined(__amigaos4__)
#define IDOS (((BufFile *)file)->idos)
#endif


The best most flexible way IMHO is not to use __USE_ILINES__ and use IDOS->SomeFunc() then you make full use of the flexibilty of the local interface approach, but ofcourse it make it harder to keep code cross compatable.

Another way might be to split out this hacky code into seperate files.

Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
@Thellier
Quote:

But why dont you open yourself (say) DOSBase in YourLibrary's LibInit then define it as an extern struct DosLibrary* DOSBase; in all the other source-files.


Its not my own code, its dopus5.library, which quite big and i want to make a first port with as less as possible changes and rewriting, just to avoid loosing any single bit which i do not know , or can just miss.

Quote:

So other file like (say) foo.c will no more use (say) data->dos_base but YOUR DOSBase but that is not a problem


Code of library uses a lot of different datas, structures, defines, redefines, defs and undefs in all possible places. One time in some file DOSBase define come from (((BufFile *)file)->dos), another time from another structure and defined as (data->dos_base) and so on. In different places code reacts and fills necessary structures different, and i can't say where and how they fill all of this all the time. All what i can now, it just somehow follow the way they do originally, and make those IFaces works as need it in their structs,etc.

@Andy
Quote:

That's what the code is doing allready or what you have done?

Sure not me, i will never define and redefine bases of libraryes anywhere in code, enough to open it one time in init and follow one global base/iface. But author of dopus5 do it like this and because they want to allow patching, and because at time when they write code no one worry if there can be "IFace" for anything :)

I anyway have a good hint from Thore, which mean adding of IFACE to the dopus5 struct LibData, and then use the same "define/redefine" way as they do for library bases. So by that way i can follow their logic without rewriting anything. At least first native build should be changed as less as possible , to avoid new bugs.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE, libbases and stuff
Just popping in
Just popping in


See User information
can you not add an Interface reference in addition to the Library reference pointers and fill it in locally for every structure concerned (where they are private)?

you can then localize "DOSBase" and "IDOS" references keeping the "__USE_INLINES__" for the function calls and fixing the relative usages when they get too strange right?

I've got one codebase where I need at least three sets of opening libraries and obtaining Interfaces within a single project.

and the dopus5.library from your description sounds eerily familiar to what I am overcoming for the same kind of problem

Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
@all
Can obtained interfaces "die" while program works ? Why i ask, its because i have pretty strange problem. We have dopus5.libray, in init of which we open libraryes and obtain their ifaces. All is fine. Then, when we use that library from os3 binary all is fine. But when we use that library from os4 binary (by any single test case), then on exit we have crashes in library related to dos functions, which we solve by commenting out of droping of IDOS (just keep a closelibrary() ) or by adding one more "get IDOS" line in some part of code.

Question is: how it can be possible that the same library works ok from os3 binary, but crashes on dropiface when used from os4 library ? Library the same, so it should crashes from any binary imho then ? Can it be that when we build os4 binary IDOS from it somehow interact with IDOS from library and "kill" it ? Sure, sounds stupid, but dunno what to think ..

It is possible that maybe library init yourself, then run some tasks, then while binary exit (and auto close their ifaces) its somehow close ifaces of task running from library ?:))

Any tip about how to debug that also pretty welcome

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
I think some one most have done some thing nasty.

Use DebugPrintF(), as you can't use printf() as you get crashes when its a task calling the function of the library, it will only work whit processes.


Edited by LiveForIt on 2013/4/13 0:08:36
(NutsAboutAmiga)

Basilisk II for AmigaOS4
AmigaInputAnywhere
Excalibur
and other tools and apps.
Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
of course something nasty .. bugs happens because of some done something nasty. as for debug printfs: of course i use them from beginning (how else we debug library before :) ).

Questions mostly theoretical, in end of all everything come to debug printfs..


Edited by kas1e on 2013/4/14 7:58:14
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
@all

At very begining of binary we have that code:

// Miscellaneous startup code
void startup_misc_init()
{
// Set wildstar bit in dos
    
DOSBase->dl_Root->rn_Flags|=RNF_WILDSTAR;

    
// Get pointer to our Process structure, and hide requesters
    
main_proc=(struct Process *)FindTask(0);
    
main_proc->pr_WindowPtr=(APTR)-1;

    
// Complement some strings
    
compstr(register_name);
    
compstr(about_1);
    
compstr(about_2);
    
eliza_decrypt();
}


I.e. right before opening of any libraries or so. Its just first strings in the main().

It didn't compiles, because says that RNF_WILDSTAR undeclared (and i can't find out it in whole SDK as well).

So, we go that way:

// Miscellaneous startup code
void startup_misc_init()
{
    
// Set wildstar bit in dos
#ifdef __amigaos4__
    
DosControlTags(DC_WildStarWTRUE);
#else    
    
DOSBase->dl_Root->rn_Flags|=RNF_WILDSTAR;
#endif    

    // Get pointer to our Process structure, and hide requesters
    
main_proc=(struct Process *)FindTask(0);
    
main_proc->pr_WindowPtr=(APTR)-1;

    
// Complement some strings
    
compstr(register_name);
    
compstr(about_1);
    
compstr(about_2);
    
eliza_decrypt();
}


But have crash right at first compstr(register_name) line (while for os3/mos it work ok, so code by default ok).

Then i just tryed to grab defines from os3/mos sdks, and do it like this:

#define RNB_WILDSTAR  24
#define RNF_WILDSTAR  (1<<RNB_WILDSTAR)

// Miscellaneous startup code
void startup_misc_init()
{
    
// Set wildstar bit in dos
    
DOSBase->dl_Root->rn_Flags|=RNF_WILDSTAR;

    
// Get pointer to our Process structure, and hide requesters
    
main_proc=(struct Process *)FindTask(0);
    
main_proc->pr_WindowPtr=(APTR)-1;

    
// Complement some strings
    
compstr(register_name);
    
compstr(about_1);
    
compstr(about_2);
    
eliza_decrypt();
}


But in that way error about that DOSblabla line:

Quote:

error: dereferencing pointer to incomplete type


What better way in end ?

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE, libbases and stuff
Just can't stay away
Just can't stay away


See User information
@kas1e

You've forgotten to end the taglist.

It should be:
DosControlTags(DC_WildStarW, TRUE, TAG_END);

Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
@Salas00
Changed, still crashes :( Maybe that "|=" OR should be done different then.. Or maybe for os4 we firstly need to open dos.library to make that call works..

register_name value is:

Quote:

char *register_name="\x9b\x90\x8f\x8a\x8c\xca\xc5\x92\x90\x9b\x8a\x93\x9a\x8c\xd0\x8d\x9a\x98\x96\x8c\x8b\x9a\x8d\xd1\x92\x90\x9b\x8a\x93\x9a";


compstr is:

// Complement a string in place
void compstr(char *str)
{
    while (*
str)
    {
        *
str=~*str;
        ++
str;
    }
}


Crash happens on *str=~*str; line.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
@kas1e

Quote:


But have crash right at first compstr(register_name) line (while for os3/mos it work ok, so code by default ok).



This statement is as false as false can be, there an awful lot of prgrams that just 'get away with it' because 3.x doesn't have memory protection.

Quote:

Crash happens on *str=~*str; line.


You are modifying the static string data, which is illegal under AmigaOS 4.x memory protection rules.

What is that code doing? If it modifies the string in place, permanently why not just replace it with the modified string?

Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
@Andy
Quote:

What is that code doing? If it modifies the string in place, permanently why not just replace it with the modified string?


I can't say what code of dopus5 doing. I.e. i can say: its doing everything in all kind of places :) There is already milion of functions, changing of which will leads to all kind of problems and crashes. So, structure of the code should be remain the same as much as possible, with less as possible "rewriting", at least on beginning. Or bug-hunting can end-up with nightmare.

But in general code do exactly that:

main()
{
 
startup_misc_init();
 .....
}

void startup_misc_init()
{
    
// Set wildstar bit in dos
#ifdef __amigaos4__
    
DosControlTags(DC_WildStarWTRUETAG_END);
#else    
    
DOSBase->dl_Root->rn_Flags|=RNF_WILDSTAR;
#endif    

    // Get pointer to our Process structure, and hide requesters
    
main_proc=(struct Process *)FindTask(0);
    
main_proc->pr_WindowPtr=(APTR)-1;

    
// Complement some strings
    
compstr(register_name);
    
compstr(about_1);
    
compstr(about_2);
    
eliza_decrypt();
}


And compstr() and register_name() chars are as i show in previous post.

Later that register_name value used in all the places and many functions.

ps. to add, os3 binary works ok in that terms. But thats of course because os3 sdk was used but whatever ..

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE, libbases and stuff
Just popping in
Just popping in


See User information
Doesn't anybody read the autodocs anymore.. ?

DosControl -- Set or obtain global DOS PREFS values. (V50)

This function provides a single method for reading or
setting various features available in the V50+ dos.library.

This is the primary interface for the DOS PREFS tools, which uses this
function to implement the users prefered default settings.
It is therefore recommended that applications use this function only
to read what the user has chosen and not to flippantly override them.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you must change any values, read the previous setting and restore
it after you have finished, you should never permanently change the
users prefered settings without expressly having permission to do so.

Please just remove this stuff (below) and let the user decide
what they want, with the DOS prefs tool.

#ifdef __amigaos4__
    DosControlTags(DC_WildStarW, TRUE, TAG_END);
#else    
    DOSBase->dl_Root->rn_Flags|=RNF_WILDSTAR;
#endif    




Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
@kas1e

You cannot port applications without having someidea what it's doing.

Quote:

So, structure of the code should be remain the same as much as possible, with less as possible "rewriting", at least on beginning. Or bug-hunting can end-up with nightmare.


Not possible in this case, you cannot modify strings in the code section on AmigaOS4, people howl for memory protection then complain the OS is broken when they get it

Based on the code clip you show me it looks like those strings are not accessed before those complimenting function are called. therefore just replcae them with the complimented versions and remove the compliment function calls. See what happens.

I suspect this is part of the copy protection / registration . Thus not needed. Why else would you obsfuscate strings in the code?






Go to top
Re: IFACE, libbases and stuff
Home away from home
Home away from home


See User information
@Colin
Quote:

Please just remove this stuff (below) and let the user decide what they want, with the DOS prefs tool.

#ifdef __amigaos4__
DosControlTags(DC_WildStarW, TRUE, TAG_END);
#else
DOSBase->dl_Root->rn_Flags|=RNF_WILDSTAR;
#endif


Its not my code, its dopus5. I can't for now remove anything, because i do not know how programm will reacts after. That to do for times when initial and original version will just works in native forms.

@andy
Quote:

I suspect this is part of the copy protection / registration . Thus not needed. Why else would you obsfuscate strings in the code?


Yep, its about registration as far as i can see.

Quote:

You cannot port applications without having someidea what it's doing.


"some" idea is key here :)

ps. removing of registration's help, but still need to check all possible places.


Edited by kas1e on 2013/4/27 12:35:56
Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: IFACE, libbases and stuff
Just popping in
Just popping in


See User information
Quote:

kas1e wrote:
Its not my code, its dopus5. I can't for now remove anything, because i do not know how programm will reacts after. That to do for times when initial and original version will just works in native forms.


Well, in that case, if you can't remove anything because it might cause problems, then I would respectfully suggest that you absolutely must -not- add something wrong that would make the situation worse.

As I said, using DosControl() in this manner is completely wrong !
Please read the autodoc again. It's the primary interface for the DOS prefs tool, not for applications to mess with flippantly.

If you want to leave the old code alone so as not to cause porting problems, then all you needed to do is this;

#ifndef __amigaos4__
DOSBase->dl_Root->rn_Flags|=RNF_WILDSTAR;
#endif

Setting this flag does nothing under OS4 anyway, but there is no struct DOSBase definition, so you need the 'ifndef' .

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project