Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(sccz80) Support struct assignment #1132

Closed
5 of 6 tasks
suborb opened this issue Apr 14, 2019 · 1 comment
Closed
5 of 6 tasks

(sccz80) Support struct assignment #1132

suborb opened this issue Apr 14, 2019 · 1 comment

Comments

@suborb
Copy link
Member

suborb commented Apr 14, 2019

Now that sdcc supports assigning structs, sccz80 should be updated so that source code compatibility is maintained.

  • Assignment of locals
  • Assignment of globals
  • Passing structs to functions
  • Passing structs to __far functions
  • Passing structs to function pointers
  • Returning structs from function

The first two should be relatively trivial, passing structs shouldn't be too difficult.

Returning structs is slightly trickier, several ways to do it:

  1. Reserve space on the stack prior to the call and then return places the struct in reserved space (needs functions prototyped, how would this work with far calls which have a different stack?)
  2. The function manipulates the stack pointer on return and creates the space (awkward for variadic functions)
  3. Use a static buffer (re-entrancy issues)

It feels like 1. is the way to go, but will need coordination with sdcc so the ABI is the same.

suborb added a commit that referenced this issue Apr 14, 2019
suborb added a commit that referenced this issue Apr 14, 2019
Bit of (non-verified) work on passing parameters + bitfields
suborb added a commit that referenced this issue Apr 14, 2019
This may well break existing code...
@suborb suborb mentioned this issue Apr 14, 2019
8 tasks
@suborb
Copy link
Member Author

suborb commented Apr 15, 2019

This was merged as #1134 - all apart from returning structs from functions which I'l leave for a while.

@suborb suborb closed this as completed Apr 15, 2019
@suborb suborb added this to Todo in z88dk 2.0 via automation May 5, 2019
@suborb suborb moved this from Todo to Done in z88dk 2.0 May 5, 2019
patacongo pushed a commit to patacongo/nuttx that referenced this issue Apr 11, 2020
This commit resolves issue apache#620:

Remove CONFIG_CAN_PASS_STRUCTS apache#620

The configuration option CONFIG_CAN_PASS_STRUCTS was added many years ago to support an old version of the SDCC compiler. That compiler is currently used only with the Z80 and Z180 targets. The limitation of that old compiler was that it could not pass structures or unions as either inputs or outputs. For example:

    #ifdef CONFIG_CAN_PASS_STRUCTS
    struct mallinfo mallinfo(void);
    #else
    int      mallinfo(FAR struct mallinfo *info);
    #endif

And even leads to violation of a few POSIX interfaces like:

    #ifdef CONFIG_CAN_PASS_STRUCTS
    int  sigqueue(int pid, int signo, union sigval value);
    #else
    int  sigqueue(int pid, int signo, FAR void *sival_ptr);
    #endif

This breaks the 1st INVIOLABLES rule:

Strict POSIX compliance
-----------------------

  o Strict conformance to the portable standard OS interface as defined at
    OpenGroup.org.
  o A deeply embedded system requires some special support.  Special
    support must be minimized.
  o The portable interface must never be compromised only for the sake of
    expediency.
  o Expediency or even improved performance are not justifications for
   violation of the strict POSIX interface

Also, it appears that the current SDCC compilers have resolve this issue and so, perhaps, this is no longer a problem: z88dk/z88dk#1132

NOTE:  This commit cannot pass the PR checks because it depends on matching changes to the apps/ directory.
Ouss4 pushed a commit to apache/nuttx that referenced this issue Apr 11, 2020
This commit resolves issue #620:

Remove CONFIG_CAN_PASS_STRUCTS #620

The configuration option CONFIG_CAN_PASS_STRUCTS was added many years ago to support an old version of the SDCC compiler. That compiler is currently used only with the Z80 and Z180 targets. The limitation of that old compiler was that it could not pass structures or unions as either inputs or outputs. For example:

    #ifdef CONFIG_CAN_PASS_STRUCTS
    struct mallinfo mallinfo(void);
    #else
    int      mallinfo(FAR struct mallinfo *info);
    #endif

And even leads to violation of a few POSIX interfaces like:

    #ifdef CONFIG_CAN_PASS_STRUCTS
    int  sigqueue(int pid, int signo, union sigval value);
    #else
    int  sigqueue(int pid, int signo, FAR void *sival_ptr);
    #endif

This breaks the 1st INVIOLABLES rule:

Strict POSIX compliance
-----------------------

  o Strict conformance to the portable standard OS interface as defined at
    OpenGroup.org.
  o A deeply embedded system requires some special support.  Special
    support must be minimized.
  o The portable interface must never be compromised only for the sake of
    expediency.
  o Expediency or even improved performance are not justifications for
   violation of the strict POSIX interface

Also, it appears that the current SDCC compilers have resolve this issue and so, perhaps, this is no longer a problem: z88dk/z88dk#1132

NOTE:  This commit cannot pass the PR checks because it depends on matching changes to the apps/ directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
z88dk 2.0
  
Done
Development

No branches or pull requests

1 participant