From b1431ce427eb193f45fe536f1fdfdf22bbe02e3d Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 21 Feb 2024 17:14:49 +0900 Subject: [PATCH] Add comments to dmydln.c, dmyenc.c, and dmyext.c They are used conditionally in miniruby, dynamically-linked ruby, and statically-linked ruby (--with-static-linked-ext). I asked @nobu about the conditions. and I leave comments because the conditions are insanely difficult. --- dmydln.c | 3 +++ dmyenc.c | 5 +++++ dmyext.c | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/dmydln.c b/dmydln.c index b1516937d39822..35824ebec8b832 100644 --- a/dmydln.c +++ b/dmydln.c @@ -1,3 +1,6 @@ +// This file is used by miniruby, not ruby. +// ruby uses dln.c. + #include "ruby/ruby.h" NORETURN(void *dln_load(const char *)); diff --git a/dmyenc.c b/dmyenc.c index 75b8a2da43a06a..d00ad80a6f8fdb 100644 --- a/dmyenc.c +++ b/dmyenc.c @@ -1,3 +1,8 @@ +// This file is used only by ruby. +// miniruby does not use this Init_enc. Instead, "miniinit.c" provides Init_enc, which defines only the builtin encodings. +// Dynamically-linked ruby uses this Init_enc, which requires "enc/encdb.so" to load the builtin encodings and set up the optional encodings. +// Statically-linked ruby does not use this Init_enc. Instead, "enc/encinit.c" (which is a generated file) defines Init_enc, which activates the encodings. + #define require(name) ruby_require_internal(name, (unsigned int)sizeof(name)-1) int ruby_require_internal(const char *, int); diff --git a/dmyext.c b/dmyext.c index 4d273f7faffc5a..00202465296bf3 100644 --- a/dmyext.c +++ b/dmyext.c @@ -1,3 +1,8 @@ +// This file is used by dynamically-linked ruby and miniruby. +// miniruby uses this Init_ext, which does nothing. It does not support require'ing extension libraries. +// Dynamically-linked ruby uses this Init_ext, which does nothing. It loads extension libraries by dlopen, etc. +// Statically-linked ruby does not use this Init_ext. Instead, "ext/extinit.c" (which is a generated file) defines Init_ext, which activates the (statically-linked) extension libraries. + void Init_ext(void) {