[build] Address symbol visibility and DSO builds

Added an `API` macro in `j6/api.h` that expands to mark the given
declaration as a default-visible symbol. Also change `format` and
`vformat` to non-template functions, and make calls to `main`, `exit`,
and the library init functions in `_start` GOT-relative.
This commit is contained in:
Justin C. Miller
2023-08-26 19:30:26 -07:00
parent 646a534dfd
commit 8cbde13139
18 changed files with 66 additions and 30 deletions

View File

@@ -8,10 +8,11 @@
#include <stddef.h>
#include <j6/types.h>
#include <util/api.h>
namespace j6 {
class channel
class API channel
{
public:
/// Create a new channel of the given size.

View File

@@ -4,6 +4,7 @@
#include <stdint.h>
#include <j6/types.h>
#include <util/api.h>
#ifdef __cplusplus
extern "C" {
@@ -71,7 +72,7 @@ struct j6_init_args
/// Find the first handle of the given type held by this process
j6_handle_t j6_find_first_handle(j6_object_type obj_type);
j6_handle_t API j6_find_first_handle(j6_object_type obj_type);
/// Get the init args
const j6_init_args * j6_get_init_args();

View File

@@ -2,6 +2,7 @@
/// \file memutils.h
/// Standard mem*() library functions
#include <util/api.h>
#include <__j6libc/restrict.h>
#include <__j6libc/size_t.h>
@@ -9,9 +10,9 @@
extern "C" {
#endif
void *memcpy(void * restrict s1, const void * restrict s2, size_t n);
void *memmove(void * restrict s1, const void * restrict s2, size_t n);
void *memset(void *s, int c, size_t n);
void * API memcpy(void * restrict s1, const void * restrict s2, size_t n);
void * API memmove(void * restrict s1, const void * restrict s2, size_t n);
void * API memset(void *s, int c, size_t n);
#ifdef __cplusplus
} // extern "C"

View File

@@ -1,9 +1,10 @@
#include <j6/protocols/service_locator.h>
#include <j6/types.h>
#include <util/api.h>
namespace j6::proto::sl {
class client
class API client
{
public:
/// Constructor.

View File

@@ -1,9 +1,14 @@
#pragma once
/// \file vfs.hh
/// C++ client interface for VFS protocol
#include <j6/protocols/vfs.h>
#include <j6/types.h>
#include <util/api.h>
namespace j6::proto::vfs {
class client
class API client
{
public:
/// Constructor.

View File

@@ -10,6 +10,7 @@
#include <stddef.h>
#include <stdint.h>
#include <util/api.h>
/*[[[cog code generation
from os.path import join
@@ -35,7 +36,7 @@ enum j6_sysconf_arg
/// Get the kernel configuration value specified by
/// the argument.
unsigned long j6_sysconf(j6_sysconf_arg arg);
unsigned long API j6_sysconf(j6_sysconf_arg arg);
#ifdef __cplusplus
} // extern C

View File

@@ -2,13 +2,15 @@
/// \file j6/syslog.hh
/// Utility function for writing messages to the kernel log
#include <util/api.h>
// The kernel depends on libj6 for some shared code,
// but should not include the user-specific code.
#ifndef __j6kernel
namespace j6 {
void syslog(const char *fmt, ...);
void API syslog(const char *fmt, ...);
} // namespace j6

View File

@@ -36,13 +36,13 @@ j6_find_first_handle(j6_object_type obj_type)
return j6_handle_invalid;
}
const j6_init_args *
const j6_init_args * API
j6_get_init_args()
{
return &init_args;
}
extern "C" void
extern "C" void API
__init_libj6(uint64_t arg0, uint64_t arg1)
{
init_args.args[0] = arg0;

View File

@@ -4,6 +4,7 @@
#include <util/format.h>
#include <j6/syscalls.h>
#include <j6/syslog.hh>
namespace j6 {