[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:
@@ -88,7 +88,6 @@ append_string(char_t *&out, size_t &count, size_t max, unsigned width, char_t co
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
template <typename char_t> size_t
|
||||
vformat(counted<char_t> output, char_t const *format, va_list va)
|
||||
@@ -169,20 +168,28 @@ vformat(counted<char_t> output, char_t const *format, va_list va)
|
||||
return count;
|
||||
}
|
||||
|
||||
template <typename char_t> size_t
|
||||
format(counted<char_t> output, const char_t *format, ...)
|
||||
} // namespace
|
||||
|
||||
size_t API format(counted<char> output, const char *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
size_t result = vformat<char_t>(output, format, va);
|
||||
size_t result = vformat<char>(output, format, va);
|
||||
va_end(va);
|
||||
return result;
|
||||
}
|
||||
|
||||
template size_t format<char>(counted<char> output, const char *format, ...);
|
||||
template size_t vformat<char>(counted<char> output, const char *format, va_list va);
|
||||
size_t API format(counted<wchar_t> output, const wchar_t *format, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
size_t result = vformat<wchar_t>(output, format, va);
|
||||
va_end(va);
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t API vformat(counted<char> output, const char *format, va_list va) { return vformat<char>(output, format, va); }
|
||||
size_t API vformat(counted<wchar_t> output, const wchar_t *format, va_list va) { return vformat<wchar_t>(output, format, va); }
|
||||
|
||||
template size_t format<wchar_t>(counted<wchar_t> output, const wchar_t *format, ...);
|
||||
template size_t vformat<wchar_t>(counted<wchar_t> output, const wchar_t *format, va_list va);
|
||||
|
||||
} //namespace util
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
/// \file allocator.h
|
||||
/// Definition of the allocator interface.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <j6/memutils.h>
|
||||
|
||||
namespace util {
|
||||
|
||||
// Allocators are types with three static methods with these signatures
|
||||
|
||||
7
src/libraries/util/include/util/api.h
Normal file
7
src/libraries/util/include/util/api.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
/// \file api.h
|
||||
/// Library interface visibility macros
|
||||
|
||||
#ifndef API
|
||||
#define API __attribute__ ((visibility ("default")))
|
||||
#endif
|
||||
@@ -6,11 +6,12 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <util/api.h>
|
||||
#include <util/spinlock.h>
|
||||
|
||||
namespace util {
|
||||
|
||||
class bip_buffer
|
||||
class API bip_buffer
|
||||
{
|
||||
public:
|
||||
/// Default constructor. Creates a zero-size buffer.
|
||||
|
||||
@@ -4,14 +4,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <util/api.h>
|
||||
#include <util/counted.h>
|
||||
|
||||
namespace util {
|
||||
|
||||
template <typename char_t>
|
||||
size_t format(counted<char_t> output, const char_t *format, ...);
|
||||
size_t API format(counted<char> output, const char *format, ...);
|
||||
size_t API vformat(counted<char> output, const char *format, va_list va);
|
||||
|
||||
template <typename char_t>
|
||||
size_t vformat(counted<char_t> output, const char_t *format, va_list va);
|
||||
|
||||
size_t API format(counted<wchar_t> output, const wchar_t *format, ...);
|
||||
size_t API vformat(counted<wchar_t> output, const wchar_t *format, va_list va);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <util/api.h>
|
||||
|
||||
#ifdef __j6kernel
|
||||
extern "C" uint32_t __current_thread_id();
|
||||
@@ -11,7 +12,7 @@ extern "C" uint32_t __current_thread_id();
|
||||
namespace util {
|
||||
|
||||
/// An MCS based spinlock
|
||||
class spinlock
|
||||
class API spinlock
|
||||
{
|
||||
public:
|
||||
spinlock();
|
||||
|
||||
@@ -10,6 +10,7 @@ module("util",
|
||||
],
|
||||
public_headers = [
|
||||
"util/allocator.h",
|
||||
"util/api.h",
|
||||
"util/assert.h",
|
||||
"util/basic_types.h",
|
||||
"util/bip_buffer.h",
|
||||
|
||||
Reference in New Issue
Block a user