Skip to content

fix: warnings for 'c-run-time.c' #1706

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

fraya
Copy link
Member

@fraya fraya commented May 2, 2025

Creates different arities for DFLN.

typedef dylan_value (*DLFN0)(void);
typedef dylan_value (*DLFN1)(dylan_value);
typedef dylan_value (*DLFN2)(dylan_value, dylan_value);
... etc

Changing DLFN to a union

typedef union {
void* raw;
DLFN0 mep0;
DLFN1 mep1;
DLFN2 mep2;
DLFN3 mep3;
DLFN4 mep4;
DLFN5 mep5;
DLFN6 mep6;
DLFN7 mep7;
DLFN8 mep8;
DLFN9 mep9;
DLFN10 mep10;
DLFN64 mep64;
} DLFN;

Then rewrite the call logic using the correct
type per arity.

switch (teb->argument_count) {
case 0: return (mep.mep0)();
case 1: return (mep.mep1)(v[0]);
...

Closes #1650

@fraya fraya requested review from cgay and housel May 2, 2025 06:48
@fraya
Copy link
Member Author

fraya commented May 2, 2025

If the premise isn't valid, please suggest an alternative and I'll start over.
There are parts where I'm not sure it's correct, so I think it needs more work.

@cgay
Copy link
Member

cgay commented May 23, 2025

This passes 3-stage bootstrap and make check on my machine, with only these two warnings in the run-time code:

posix-threads.c:1682:12: warning: unused function 'priority_map' [-Wunused-function]
static int priority_map(int dylan_priority)
           ^
posix-threads.c:235:35: warning: unused function 'get_current_thread_handle' [-Wunused-function]
PURE_FUNCTION static inline void *get_current_thread_handle(void)
                                  ^

@fraya
Copy link
Member Author

fraya commented May 24, 2025

@cgay
The warnings of posix-threads.c are easier to solve, but it requires to know what is the purpose of the code. Is not needed and can be deleted? The code stay but this warnings should be suppressed?

Creates different arities for DFLN.

typedef dylan_value (*DLFN0)(void);
typedef dylan_value (*DLFN1)(dylan_value);
typedef dylan_value (*DLFN2)(dylan_value, dylan_value);
... etc

Changing DLFN to a union

typedef union {
  void* raw;
  DLFN0 mep0;
  DLFN1 mep1;
  DLFN2 mep2;
  DLFN3 mep3;
  DLFN4 mep4;
  DLFN5 mep5;
  DLFN6 mep6;
  DLFN7 mep7;
  DLFN8 mep8;
  DLFN9 mep9;
  DLFN10 mep10;
  DLFN64 mep64;
} DLFN;

Then rewrite the call logic using the correct
type per arity.

switch (teb->argument_count) {
  case 0: return (mep.mep0)();
  case 1: return (mep.mep1)(v[0]);
  ...

Closes dylan-lang#1650
Remove 'priority_map' function that is unused.
@fraya fraya marked this pull request as ready for review July 7, 2025 19:22
@fraya
Copy link
Member Author

fraya commented Jul 15, 2025

Setting the default backend compiler to C and doing bootstrap, in the stage-2, it shows this errors:

Internal error: Link failed: Link failed: In file included from command-line.c:1:
command-line.c: In function ‘Kdo_execute_commandVcommandsMdylan_compilerM0I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
  825 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:2882:21: note: in expansion of macro ‘CONGRUENT_CALL1’
 2882 |         serverF31 = CONGRUENT_CALL1(context_);
      |                     ^~~~~~~~~~~~~~~
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
  825 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:2922:27: note: in expansion of macro ‘CONGRUENT_CALL1’
 2922 |               serverF37 = CONGRUENT_CALL1(context_);
      |                           ^~~~~~~~~~~~~~~
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
  825 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:2941:27: note: in expansion of macro ‘CONGRUENT_CALL1’
 2941 |               serverF40 = CONGRUENT_CALL1(context_);
      |                           ^~~~~~~~~~~~~~~
command-line.c: In function ‘Kanonymous_of_do_execute_commandF250I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
  825 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3049:15: note: in expansion of macro ‘CONGRUENT_CALL1’
 3049 |     server_ = CONGRUENT_CALL1(CREF(2));
      |               ^~~~~~~~~~~~~~~
command-line.c: In function ‘KrunF245I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:827:37: error: called object is not a function or function pointer
  827 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1),(a2)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3087:15: note: in expansion of macro ‘CONGRUENT_CALL2’
 3087 |   filename_ = CONGRUENT_CALL2(&KLfile_locatorGYlocatorsVsystem, T5);
      |               ^~~~~~~~~~~~~~~
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
  825 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3092:8: note: in expansion of macro ‘CONGRUENT_CALL1’
 3092 |   T8 = CONGRUENT_CALL1(T7);
      |        ^~~~~~~~~~~~~~~
command-line.c: In function ‘Kexecute_main_commandYconsole_environmentVdylan_compilerMM0I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:827:37: error: called object is not a function or function pointer
  827 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1),(a2)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3153:14: note: in expansion of macro ‘CONGRUENT_CALL2’
 3153 |     parts_ = CONGRUENT_CALL2(&KLlistGVKd, T13);
      |              ^~~~~~~~~~~~~~~
command-line.c: In function ‘Kexecute_main_loopYconsole_environmentVdylan_compilerMM0I’:
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
  825 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3352:13: note: in expansion of macro ‘CONGRUENT_CALL1’
 3352 |   server_ = CONGRUENT_CALL1(context_);
      |             ^~~~~~~~~~~~~~~
/home/fraya/Dylan/opendylan/Bootstrap.1/include/opendylan/run-time.h:825:37: error: called object is not a function or function pointer
  825 |     ((((ENGINE*)get_teb()->function)->entry_point)((a1)))
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
command-line.c:3367:8: note: in expansion of macro ‘CONGRUENT_CALL1’
 3367 |   T4 = CONGRUENT_CALL1(context_);
      |        ^~~~~~~~~~~~~~~

Exiting with return code 9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warnings for c-run-time.c
2 participants