need your help: strange function declarations 
Author Message
 need your help: strange function declarations

Hi,

I'm porting some software from Windows to multiple UNIX-systems (AIX,
HP-UX, Solaris).
Although I've a lot of experience in C-programming I've never seen some
stuff like this:

...
...
Pascal void _PurgeFldRef(FldRef fldref, oproc callback) =
{0x303C,0x002F,0x2057,0x4E90};
pascal void _GetNamedVal(FldRef fldref, char far *name, short fmt,long
maxlen,
                         void far *val, oproc callback) =
{0x303C,0x0030,0x2057,0x4E90};  // ACJ0245
pascal odouble _GetNamedNVal(FldRef fldref, char *name,oproc callback) =
{0x303C,0x0031,0x2057,0x4E90};
pascal void _SetNamedVal(FldRef fldref, char far *name, short fmt,
                         void *val, oproc callback) =
{0x303C,0x0032,0x2057,0x4E90};   // ACJ0245
pascal void _SetNamedNVal(FldRef fldref, char *name,
                          odouble *nval,oproc callback) =
{0x303C,0x0033,0x2057,0x4E90};
...
...

can someone tell me something about these strange assignments to
function-declarations?

thank you and kind regards

Matthias
--
----------------------------------
Matthias Kolbusa
Information Technology Consultant


Web:    www.kolbusa.de
Tel.: 0049-(0)172 83 44 924
----------------------------------
--



Wed, 19 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations

Quote:

> I'm porting some software from Windows to multiple UNIX-systems (AIX,
> HP-UX, Solaris).
> Although I've a lot of experience in C-programming I've never seen some
> stuff like this:

> ...
> ...
> pascal void _PurgeFldRef(FldRef fldref, oproc callback) =

<snip>

That is another microsoftism.  AFAIK ``pascal'' affects how the
parameters you pass to the function are handled, so if there are no
parts of the program that are written in pascal, it basically is
just some non-portable optimisation.  It should be safe to just
remove _all_ of these.
--
Manfred
--



Fri, 21 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations
            As far as I'm concerned what the pascal key word tells the
compiler is that this functions follow the pascal calling conventions, that
is the way that parameters and returning address is saved in the stack.

            I don't know any UNIX compiler that uses this keyword,

Andres Tarallo
-----Mensaje original-----

Grupos de noticias: comp.lang.c.moderated
Fecha: Sbado, 01 de Enero de 2000 04:27 p.m.
Asunto: need your help: strange function declarations

Quote:
>Hi,

>I'm porting some software from Windows to multiple UNIX-systems (AIX,
>HP-UX, Solaris).
>Although I've a lot of experience in C-programming I've never seen some
>stuff like this:

>...
>...
>pascal void _PurgeFldRef(FldRef fldref, oproc callback) =
>{0x303C,0x002F,0x2057,0x4E90};
>pascal void _GetNamedVal(FldRef fldref, char far *name, short fmt,long
>maxlen,
>                         void far *val, oproc callback) =
>{0x303C,0x0030,0x2057,0x4E90};  // ACJ0245
>pascal odouble _GetNamedNVal(FldRef fldref, char *name,oproc callback) =
>{0x303C,0x0031,0x2057,0x4E90};
>pascal void _SetNamedVal(FldRef fldref, char far *name, short fmt,
>                         void *val, oproc callback) =
>{0x303C,0x0032,0x2057,0x4E90};   // ACJ0245
>pascal void _SetNamedNVal(FldRef fldref, char *name,
>                          odouble *nval,oproc callback) =
>{0x303C,0x0033,0x2057,0x4E90};
>...
>...

>can someone tell me something about these strange assignments to
>function-declarations?

>thank you and kind regards

>Matthias
>--
>----------------------------------
>Matthias Kolbusa
>Information Technology Consultant


>Web: www.kolbusa.de
>Tel.: 0049-(0)172 83 44 924
>----------------------------------
>--


--



Fri, 21 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations


Quote:
>That is another microsoftism.  AFAIK ``pascal'' affects how the
>parameters you pass to the function are handled, so if there are no
>parts of the program that are written in pascal, it basically is
>just some non-portable optimisation.  It should be safe to just
>remove _all_ of these.

However I am little concerned by the callback.  MS qualified functions
that were being passed to Windows so that the appropriate parameter
passing would take place.  I think the original poster needs to
understand what the code does in order to port it.

Francis Glassborow      Journal Editor, Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
--



Sat, 22 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations
[...]

Quote:
> pascal void _PurgeFldRef(FldRef fldref, oproc callback) =
> {0x303C,0x002F,0x2057,0x4E90};

This is not just Windows-specific, but even compiler-specific, I
think. The 'pascal' keyword is a language extension (and in violation
of the C standard) describing a different argument passing convention
than the usual C one, which originally came from Pascal compilers for
DOS. You could probably get around that by a simple

#define pascal /* nothing */

The second strange element in this line, the right hand side of the
'=', is an array of hex values containing machine code that implements
this function. That's a showstopper. There's absolutely no way to
'port' these functions -- you'll have to implement them from
scratch. Try to find documentation on what they're soupposed to do.
--

Even if all the snow were burnt, ashes would remain.
--



Sat, 22 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations

Quote:

> pascal void _PurgeFldRef(FldRef fldref, oproc callback) =
> {0x303C,0x002F,0x2057,0x4E90};

I tried disassembling the numbers as x86 machine code, and they
didn't make any sense.  I've seen similar definitions in
Macintosh code so I believe this too is for Macintosh, not
Windows.  If your software was running on Windows, I guess you
can just ignore these.
--



Sun, 23 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations


[ ... ]

Quote:
> The second strange element in this line, the right hand side of the
> '=', is an array of hex values containing machine code that implements
> this function. That's a showstopper. There's absolutely no way to
> 'port' these functions -- you'll have to implement them from
> scratch. Try to find documentation on what they're soupposed to do.

I'm not sure this is machine code implementing the function, though I
suppose it's possible; I've never seen anything _quite_ like the code
he showed.

The closest I've seen was code for some of Borland's first compilers
for Windows.  I don't remember the exact syntax, but they had an
extension that looked at least a little like this that allowed you to
specify the value of a Windows message to which a function would
respond.

--
    Later,
    Jerry.

The universe is a figment of its own imagination.
--



Sun, 23 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations


Quote:

> > pascal void _PurgeFldRef(FldRef fldref, oproc callback) =
> > {0x303C,0x002F,0x2057,0x4E90};

> I tried disassembling the numbers as x86 machine code, and they
> didn't make any sense.  I've seen similar definitions in
> Macintosh code so I believe this too is for Macintosh, not
> Windows.  If your software was running on Windows, I guess you
> can just ignore these.

Just for fun (OBrelevancy: and to see that parameter passing is not
always on the stack)

303c    MOVE.W  #$002f,D0
002f
2057    MOVEA.L (A7),A0
4e90    JSR     (A0)
--

--



Sun, 23 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations

Quote:


> > > pascal void _PurgeFldRef(FldRef fldref, oproc callback) =
> > > {0x303C,0x002F,0x2057,0x4E90};
[...]
> Just for fun (OBrelevancy: and to see that parameter passing is not
> always on the stack)

> 303c       MOVE.W  #$002f,D0
> 002f
> 2057       MOVEA.L (A7),A0
> 4e90       JSR     (A0)

Thanks, I was going to do this myself but couldn't find a 68000
disassembler.  But what does this show about parameter passing in
C?  It seems to me that _PurgeFldRef gets its parameters
(callback at least) on the stack (A7); callback does take
parameters in registers but there's no sign that it's been
written in C.  Probably it hasn't, since otherwise it could be
called directly.  :-)
--



Mon, 24 Jun 2002 03:00:00 GMT  
 need your help: strange function declarations


Quote:


> > > > pascal void _PurgeFldRef(FldRef fldref, oproc callback) =
> > > > {0x303C,0x002F,0x2057,0x4E90};
> [...]
> > Just for fun (OBrelevancy: and to see that parameter passing is not
> > always on the stack)

> > 303c  MOVE.W  #$002f,D0
> > 002f
> > 2057  MOVEA.L (A7),A0
> > 4e90  JSR     (A0)

> Thanks, I was going to do this myself but couldn't find a 68000
> disassembler.  But what does this show about parameter passing in
> C?  It seems to me that _PurgeFldRef gets its parameters
> (callback at least) on the stack (A7); callback does take
> parameters in registers but there's no sign that it's been
> written in C.  Probably it hasn't, since otherwise it could be
> called directly.  :-)

I don't think the thread ever mentioned the key fact that this was for
a *68000* machine.  Doesn't all this come under the general
classification of "thunks".

Another thunking area is where one creates assembly code, passing in
registers, and needs to link to a system passing on the stack (or the
inverse).  And then there is the weird (to me) rules of Algol
parameter evaluation.

Just to keep it on topic, most C systems need such methods to hook to
the operating system and to code written in other systems.  One would
hope they are completely hidden in the implementation.

--
    Chuck Falconer

Sent via Deja.com http://www.deja.com/
Before you buy.
--



Thu, 27 Jun 2002 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. need your help: strange function declarations.

2. strange declarations of functions

3. strange declarations of functions

4. Need help deciphering a declaration

5. need help on C declaration

6. Need help on alternative declaration

7. _beginthreadex declaration help needed.

8. Need help - Convoluted type declarations

9. Need help for variables declaration.

10. Desperately need help : type declaration

11. function declaration ... help

12. Help with function pointer declaration please!

 

 
Powered by phpBB® Forum Software