LibC+LookupServer: Compute magic number to avoid hardcoding

This commit is contained in:
Ben Wiederhake 2021-11-01 16:00:07 +01:00 committed by Ali Mohammad Pur
parent 0d6c8afa4e
commit 34a8ee6da5
Notes: sideshowbarker 2024-07-18 01:29:53 +09:00
2 changed files with 5 additions and 3 deletions

View file

@ -27,12 +27,13 @@ static in_addr_t* __gethostbyname_address_list_buffer[2];
static hostent __gethostbyaddr_buffer;
static in_addr_t* __gethostbyaddr_address_list_buffer[2];
// XXX: IPCCompiler depends on LibC. Because of this, it cannot be compiled
// IPCCompiler depends on LibC. Because of this, it cannot be compiled
// before LibC is. However, the lookup magic can only be obtained from the
// endpoint itself if IPCCompiler has compiled the IPC file, so this creates
// a chicken-and-egg situation. Because of this, the LookupServer endpoint magic
// is hardcoded here.
static constexpr i32 lookup_server_endpoint_magic = 9001;
// Keep the name synchronized with LookupServer/LookupServer.ipc.
static constexpr i32 lookup_server_endpoint_magic = "LookupServer"sv.hash();
// Get service entry buffers and file information for the getservent() family of functions.
static FILE* services_file = nullptr;

View file

@ -1,4 +1,5 @@
endpoint LookupServer [magic=9001]
// Keep the name synchronized with LibC/netdb.cpp, constant 'lookup_server_endpoint_magic'.
endpoint LookupServer
{
lookup_name(String name) => (int code, Vector<String> addresses)
lookup_address(String address) => (int code, String name)