Skip to content

Commit

Permalink
mod: Remove MODULE_FN macro
Browse files Browse the repository at this point in the history
  • Loading branch information
marv7000 committed Nov 24, 2024
1 parent 24fb1d0 commit bef28a0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
5 changes: 1 addition & 4 deletions include/menix/system/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
#endif

// Defines a new module. Modules should use this at the end of their source to export the entry.
#define MODULE ATTR(used) ATTR(section(".mod")) static const Module this_module

// Defines a new module function.
#define MODULE_FN static ATTR(used)
#define MODULE ATTR(used, section(".mod")) static const Module this_module

// Add all module information that is provided by the build system.
#define MODULE_META .author = MODULE_AUTHOR, .description = MODULE_DESCRIPTION, .license = MODULE_LICENSE
Expand Down
2 changes: 1 addition & 1 deletion modules/arch/x86_64/ps2_keyboard/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static isize ps2_keyboard_read(Handle* handle, FileDescriptor* fd, void* data, u
return 1;
}

MODULE_FN i32 ps2_init()
static i32 ps2_init()
{
// Add this keyboard as a new input method.

Expand Down
4 changes: 2 additions & 2 deletions modules/drv/block/nvme/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ static PciDriver nvme_driver = {
.probe = nvme_probe,
};

MODULE_FN i32 nvme_init()
static i32 nvme_init()
{
pci_register_driver(&nvme_driver);
return 0;
}

MODULE_FN void nvme_exit()
static void nvme_exit()
{
pci_unregister_driver(&nvme_driver);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/drv/net/virtio_net/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef struct
u32 supported_tunnel_types;
} VirtioNetConfig;

MODULE_FN i32 init_fn()
static i32 init_fn()
{
return 0;
}
Expand Down
12 changes: 6 additions & 6 deletions modules/drv/video/fbcon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ static usize ch_height; // Screen height in characters
static usize ch_xpos, ch_ypos; // Current cursor position in characters

// Copies the back buffer to the screen.
MODULE_FN void fbcon_copy_screen()
static void fbcon_copy_screen()
{
const FbModeInfo* mode = &internal_fb->mode;
memcpy((void*)internal_fb->info.mmio_base, internal_buffer, mode->pitch * mode->height);
update_count = 0;
}

// Moves all lines up by one line.
MODULE_FN void fbcon_scroll()
static void fbcon_scroll()
{
void* const buf = internal_buffer;
// Offset for 1 line of characters.
Expand All @@ -58,7 +58,7 @@ MODULE_FN void fbcon_scroll()
fbcon_copy_screen();
}

MODULE_FN void fbcon_putchar(u32 ch)
static void fbcon_putchar(u32 ch)
{
if (!internal_fb)
return;
Expand Down Expand Up @@ -98,7 +98,7 @@ MODULE_FN void fbcon_putchar(u32 ch)
}
}

MODULE_FN isize fbcon_write(Handle* handle, FileDescriptor* fd, const void* buf, usize len, off_t offset)
static isize fbcon_write(Handle* handle, FileDescriptor* fd, const void* buf, usize len, off_t offset)
{
// Write each character to the buffer.
for (usize i = 0; i < len; i++)
Expand Down Expand Up @@ -156,7 +156,7 @@ MODULE_FN isize fbcon_write(Handle* handle, FileDescriptor* fd, const void* buf,
return len;
}

void fbcon_post()
static void fbcon_post()
{
FrameBuffer* fb = fb_get_active();

Expand All @@ -176,7 +176,7 @@ void fbcon_post()
ch_ypos = 0;

// Clear the screen.
memset((void*)internal_fb->info.mmio_base, 0, mode->pitch * mode->height);
memset((u8*)internal_fb->info.mmio_base, 0, mode->pitch * mode->height);

module_log("Switching to framebuffer console\n");

Expand Down
4 changes: 2 additions & 2 deletions modules/examples/cpp_example/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class Foo

static Foo foo("Hello from C++ constructor!\n");

MODULE_FN i32 init_fn()
static i32 init_fn()
{
module_log("Hello from C++!\n");
return 0;
}

MODULE_FN void exit_fn()
static void exit_fn()
{
return;
}
Expand Down

0 comments on commit bef28a0

Please sign in to comment.