Remove most of the extern "C"

remove extern "C"
pull/4/head
sachaaaaa 6 years ago
parent b5762fa85a
commit c7940076bf

@ -11,10 +11,6 @@
* utilities for handling addresses on the llarp network
*/
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_AI_DIALECT_SIZE 5
/// address information model
@ -92,8 +88,4 @@ struct llarp_ai_list_iter
void
llarp_ai_list_iterate(struct llarp_ai_list *l, struct llarp_ai_list_iter *iter);
#ifdef __cplusplus
}
#endif
#endif

@ -14,10 +14,6 @@
* we utilize llarp_buffer which provides memory management
*/
#ifdef __cplusplus
extern "C" {
#endif
bool
bencode_write_bytestring(llarp_buffer_t* buff, const void* data, size_t sz);
@ -88,7 +84,4 @@ struct list_reader
bool
bencode_read_list(llarp_buffer_t* buff, struct list_reader* r);
#ifdef __cplusplus
}
#endif
#endif

@ -13,10 +13,6 @@
* generic memory buffer
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef uint8_t byte_t;
/**
@ -86,8 +82,4 @@ llarp_buffer_read_until(llarp_buffer_t *buff, char delim, byte_t *result,
bool
llarp_buffer_eq(llarp_buffer_t buff, const char *data);
#ifdef __cplusplus
}
#endif
#endif

@ -7,10 +7,6 @@
* library configuration utilties
*/
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_config;
/// allocate config
@ -42,7 +38,4 @@ void
llarp_config_iter(struct llarp_config *conf,
struct llarp_config_iterator *iter);
#ifdef __cplusplus
}
#endif
#endif

@ -12,10 +12,6 @@
* potentially allow libssl support in the future
*/
#ifdef __cplusplus
extern "C" {
#endif
#define PUBKEYSIZE 32
#define SECKEYSIZE 64
#define NONCESIZE 24
@ -110,8 +106,4 @@ llarp_crypto_libsodium_init(struct llarp_crypto *c);
bool
llarp_crypto_initialized(struct llarp_crypto *c);
#ifdef __cplusplus
}
#endif
#endif

@ -12,10 +12,6 @@
* asynchronous crypto functions
*/
#ifdef __cplusplus
extern "C" {
#endif
/// context for doing asynchronous cryptography for iwp
/// with a worker threadpool
/// defined in crypto_async.cpp
@ -182,6 +178,24 @@ struct iwp_async_frame
byte_t buf[1500];
};
// TODO: remove
struct FramePutTime
{
void
operator()(iwp_async_frame *frame) const
{
frame->created = llarp_time_now_ms();
}
};
struct FrameGetTime
{
llarp_time_t
operator()(const iwp_async_frame *frame) const
{
return frame->created;
}
};
/// synchronously decrypt a frame
bool
iwp_decrypt_frame(struct iwp_async_frame *frame);
@ -200,7 +214,4 @@ void
iwp_call_async_frame_encrypt(struct llarp_async_iwp *iwp,
struct iwp_async_frame *frame);
#ifdef __cplusplus
}
#endif
#endif

@ -10,10 +10,6 @@
* DHT functions
*/
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_dht_context;
/// allocator
@ -72,7 +68,4 @@ void
llarp_dht_lookup_router(struct llarp_dht_context* ctx,
struct llarp_router_lookup_job* job);
#ifdef __cplusplus
}
#endif
#endif

@ -12,10 +12,6 @@
* on DTLS
*/
#ifdef __cplusplus
extern "C" {
#endif
/// DTLS configuration
struct llarp_dtls_args
{
@ -29,7 +25,4 @@ void
dtls_link_init(struct llarp_link* link, struct llarp_dtls_args args,
struct llarp_msg_muxer* muxer);
#ifdef __cplusplus
}
#endif
#endif

@ -13,10 +13,6 @@
* event handler (cross platform high performance event system for IO)
*/
#ifdef __cplusplus
extern "C" {
#endif
// forward declare
struct llarp_threadpool;
struct llarp_logic;
@ -70,7 +66,4 @@ llarp_ev_udp_sendto(struct llarp_udp_io *udp, const struct sockaddr *to,
int
llarp_ev_close_udp(struct llarp_udp_io *udp);
#ifdef __cplusplus
}
#endif
#endif

@ -10,10 +10,6 @@
* utilities for handling exits on the llarp network
*/
#ifdef __cplusplus
extern "C" {
#endif
/// Exit info model
struct llarp_xi
{
@ -60,7 +56,4 @@ struct llarp_xi_list_iter
void
llarp_xi_list_iterate(struct llarp_xi_list *l, struct llarp_xi_list_iter *iter);
#ifdef __cplusplus
}
#endif
#endif

@ -3,9 +3,6 @@
#include <llarp/buffer.h>
#include <llarp/net.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_xr
{
@ -20,7 +17,4 @@ llarp_xr_bencode(struct llarp_xr* xr, llarp_buffer_t* buff);
bool
llarp_xr_bdecode(struct llarp_xr* xr, llarp_buffer_t* buff);
#ifdef __cplusplus
}
#endif
#endif

@ -1,10 +1,6 @@
#ifndef LLARP_LOGGER_H
#define LLARP_LOGGER_H
#ifdef __cplusplus
extern "C" {
#endif
enum LogLevel
{
eLogDebug,
@ -16,8 +12,4 @@ enum LogLevel
void
cSetLogLevel(enum LogLevel lvl);
#ifdef __cplusplus
}
#endif
#endif

@ -3,9 +3,6 @@
#include <llarp/mem.h>
#include <llarp/threadpool.h>
#include <llarp/timer.h>
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_logic;
@ -40,7 +37,4 @@ llarp_logic_stop(struct llarp_logic* logic);
void
llarp_logic_mainloop(struct llarp_logic* logic);
#ifdef __cplusplus
}
#endif
#endif

@ -4,16 +4,8 @@
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/** constant time memcmp */
bool
llarp_eq(const void *a, const void *b, size_t sz);
#ifdef __cplusplus
}
#endif
#endif

@ -7,14 +7,7 @@
#include <sys/socket.h>
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
bool
llarp_getifaddr(const char* ifname, int af, struct sockaddr* addr);
#ifdef __cplusplus
}
#endif
#endif

@ -10,10 +10,6 @@
* persistent storage API for router contacts
*/
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_nodedb;
/// create an empty nodedb
@ -139,7 +135,4 @@ struct llarp_async_load_rc
void
llarp_nodedb_async_load_rc(struct llarp_async_load_rc *job);
#ifdef __cplusplus
}
#endif
#endif

@ -7,10 +7,6 @@
#define DEFAULT_PATH_LIFETIME (10 * 60 * 1000)
#define PATH_BUILD_TIMEOUT (30 * 1000)
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_path_hop
{
struct llarp_rc router;
@ -28,7 +24,4 @@ struct llarp_path_hops
void
llarp_path_hops_free(struct llarp_path_hops* hops);
#ifdef __cplusplus
}
#endif
#endif

@ -10,10 +10,6 @@
* path api functions
*/
#ifdef __cplusplus
extern "C" {
#endif
/// forard declare
struct llarp_router;
struct llarp_dht_context;
@ -62,7 +58,4 @@ struct llarp_pathbuild_job
void
llarp_pathbuilder_build_path(struct llarp_pathbuild_job* job);
#ifdef __cplusplus
}
#endif
#endif

@ -3,10 +3,6 @@
#include <llarp/link.h>
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_quic_args
{
};
@ -15,7 +11,4 @@ bool
quic_link_init(struct llarp_link* link, struct llarp_quic_args args,
struct llarp_msg_muxer* muxer);
#ifdef __cplusplus
}
#endif
#endif

@ -9,10 +9,6 @@
#include <llarp/router_contact.h>
#include <llarp/threadpool.h>
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_router;
bool
@ -54,8 +50,4 @@ void
llarp_router_iterate_links(struct llarp_router *router,
struct llarp_router_link_iter iter);
#ifdef __cplusplus
}
#endif
#endif

@ -3,9 +3,6 @@
#include <llarp/address_info.h>
#include <llarp/crypto.h>
#include <llarp/exit_info.h>
#ifdef __cplusplus
extern "C" {
#endif
// forward declare
struct llarp_alloc;
@ -29,7 +26,6 @@ struct llarp_rc
byte_t signature[SIGSIZE];
uint64_t last_updated;
#ifdef __cplusplus
bool
BEncode(llarp_buffer_t *buf) const
{
@ -41,7 +37,6 @@ struct llarp_rc
{
return llarp_rc_bdecode(this, buf);
}
#endif
};
void
@ -87,7 +82,4 @@ llarp_rc_read(const char *fpath);
bool
llarp_rc_write(struct llarp_rc *rc, const char *our_rc_file);
#ifdef __cplusplus
}
#endif
#endif

@ -1,9 +1,6 @@
#ifndef LLARP_STRING_H
#define LLARP_STRING_H
#include <llarp/common.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __FreeBSD__
#if !(__APPLE__ && __MACH__)
@ -18,7 +15,4 @@ strnlen(const char* str, size_t sz)
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif

@ -1,8 +1,5 @@
#ifndef LLARP_THREADPOOL_H
#define LLARP_THREADPOOL_H
#ifdef __cplusplus
extern "C" {
#endif
struct llarp_threadpool;
@ -26,8 +23,6 @@ struct llarp_thread_job
/** called in threadpool worker thread */
llarp_thread_work_func work;
#ifdef __cplusplus
llarp_thread_job(void *u, llarp_thread_work_func w) : user(u), work(w)
{
}
@ -35,8 +30,6 @@ struct llarp_thread_job
llarp_thread_job() : user(nullptr), work(nullptr)
{
}
#endif
};
/// for single process mode
@ -55,8 +48,4 @@ llarp_threadpool_join(struct llarp_threadpool *tp);
void
llarp_threadpool_wait(struct llarp_threadpool *tp);
#ifdef __cplusplus
}
#endif
#endif

@ -1,16 +1,10 @@
#ifndef LLARP_TIME_H
#define LLARP_TIME_H
#include <llarp/types.h>
#ifdef __cplusplus
extern "C" {
#endif
llarp_time_t
llarp_time_now_ms();
llarp_seconds_t
llarp_time_now_sec();
#ifdef __cplusplus
}
#endif
#endif

@ -2,9 +2,6 @@
#define LLARP_TIMER_H
#include <llarp/common.h>
#include <llarp/threadpool.h>
#ifdef __cplusplus
extern "C" {
#endif
/** called with userptr, original timeout, left */
typedef void (*llarp_timer_handler_func)(void *, uint64_t, uint64_t);
@ -47,7 +44,4 @@ llarp_timer_tick_all(struct llarp_timer_context *t,
void
llarp_free_timer(struct llarp_timer_context **t);
#ifdef __cplusplus
}
#endif
#endif

@ -2,15 +2,8 @@
#define LLARP_TYPES_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint8_t llarp_proto_version_t;
typedef uint64_t llarp_time_t;
typedef uint64_t llarp_seconds_t;
#ifdef __cplusplus
}
#endif
#endif

@ -117,8 +117,6 @@ llarp_ai_list_iter_bencode(struct llarp_ai_list_iter *iter, struct llarp_ai *ai)
return llarp_ai_bencode(ai, static_cast< llarp_buffer_t * >(iter->user));
}
extern "C" {
bool
llarp_ai_bdecode(struct llarp_ai *ai, llarp_buffer_t *buff)
{
@ -261,4 +259,3 @@ llarp_ai_list_bdecode(struct llarp_ai_list *l, llarp_buffer_t *buff)
.buffer = nullptr, .user = l, .on_item = &llarp_ai_list_bdecode_item};
return bencode_read_list(buff, &r);
}
}

@ -2,8 +2,6 @@
#include <stdarg.h>
#include <stdio.h>
extern "C" {
size_t
llarp_buffer_size_left(llarp_buffer_t buff)
{
@ -78,4 +76,3 @@ llarp_buffer_eq(llarp_buffer_t buf, const char* str)
}
return *str == 0;
}
}

@ -35,8 +35,6 @@ namespace llarp
} // namespace llarp
extern "C" {
void
llarp_new_config(struct llarp_config **conf)
{
@ -78,4 +76,3 @@ llarp_config_iter(struct llarp_config *conf, struct llarp_config_iterator *iter)
iter->visit(iter, section.first.c_str(), item.first.c_str(),
item.second.c_str());
}
}

@ -22,11 +22,9 @@ namespace llarp
};
} // namespace llarp
extern "C" {
struct llarp_config
{
llarp::Config impl;
};
}
#endif

@ -297,7 +297,6 @@ namespace llarp
}
}
extern "C" {
struct llarp_main
{
std::unique_ptr< llarp::Context > ctx;
@ -435,4 +434,3 @@ llarp_main_free(struct llarp_main *ptr)
{
delete ptr;
}
}

@ -345,7 +345,6 @@ namespace iwp
}
} // namespace iwp
extern "C" {
void
iwp_call_async_keygen(struct llarp_async_iwp *iwp,
struct iwp_async_keygen *keygen)
@ -490,4 +489,3 @@ llarp_async_iwp_free(struct llarp_async_iwp *iwp)
{
delete iwp;
}
}

@ -131,7 +131,6 @@ namespace llarp
} // namespace llarp
extern "C" {
const byte_t *
llarp_seckey_topublic(const byte_t *secret)
{
@ -160,4 +159,3 @@ llarp_crypto_libsodium_init(struct llarp_crypto *c)
c->randbytes(&seed, sizeof(seed));
srand(seed);
}
}

@ -630,7 +630,6 @@ llarp_dht_context::llarp_dht_context(llarp_router *router)
parent = router;
}
extern "C" {
struct llarp_dht_context *
llarp_dht_context_new(struct llarp_router *router)
{
@ -686,4 +685,3 @@ llarp_dht_lookup_router(struct llarp_dht_context *ctx,
llarp_logic_queue_job(ctx->parent->logic,
{job, &llarp::dht::Context::queue_router_lookup});
}
}

@ -12,7 +12,6 @@
#include "ev_kqueue.hpp"
#endif
extern "C" {
void
llarp_ev_loop_alloc(struct llarp_ev_loop **ev)
{
@ -85,4 +84,3 @@ llarp_ev_udp_sendto(struct llarp_udp_io *udp, const sockaddr *to,
{
return static_cast< llarp::ev_io * >(udp->impl)->sendto(to, buf, sz);
}
}

@ -10,8 +10,6 @@ struct llarp_xi_list
std::list< llarp_xi > list;
};
extern "C" {
struct llarp_xi_list *
llarp_xi_list_new()
{
@ -188,4 +186,3 @@ llarp_xi_list_bdecode(struct llarp_xi_list *l, llarp_buffer_t *buff)
list_reader r = {buff, l, &llarp_xi_list_decode_item};
return bencode_read_list(buff, &r);
}
}

@ -12,10 +12,8 @@ namespace llarp
}
}
extern "C" {
void
cSetLogLevel(LogLevel lvl)
{
llarp::SetLogLevel((llarp::LogLevel)lvl);
}
}

@ -2,14 +2,6 @@
#include <llarp/mem.h>
#include "logger.hpp"
struct llarp_logic
{
struct llarp_threadpool* thread;
struct llarp_timer_context* timer;
};
extern "C" {
struct llarp_logic*
llarp_init_logic()
{
@ -103,4 +95,3 @@ llarp_logic_remove_call(struct llarp_logic* logic, uint32_t id)
{
llarp_timer_remove_job(logic->timer, id);
}
}

@ -16,8 +16,6 @@ namespace llarp
}
}
extern "C" {
void
llarp_mem_slab(struct llarp_alloc *mem, uint32_t *buf, size_t sz)
{
@ -37,4 +35,3 @@ llarp_eq(const void *a, const void *b, size_t sz)
}
return result;
}
}

@ -35,11 +35,9 @@ namespace llarp
} // namespace llarp
extern "C" {
void
llarp_mem_stdlib(struct llarp_alloc *mem)
{
mem->alloc = llarp::std_malloc;
mem->free = llarp::std_free;
}
}

@ -37,8 +37,6 @@ operator<(const in6_addr& a, const in6_addr& b)
return memcmp(&a, &b, sizeof(in6_addr)) < 0;
}
extern "C" {
bool
llarp_getifaddr(const char* ifname, int af, struct sockaddr* addr)
{
@ -78,4 +76,3 @@ llarp_getifaddr(const char* ifname, int af, struct sockaddr* addr)
freeifaddrs(ifa);
return found;
}
}

@ -318,7 +318,6 @@ nodedb_async_load_rc(void *user)
llarp_logic_queue_job(job->logic, {job, &nodedb_inform_load_rc});
}
extern "C" {
struct llarp_nodedb *
llarp_nodedb_new(struct llarp_crypto *crypto)
{
@ -461,4 +460,3 @@ llarp_nodedb_select_random_hop(struct llarp_nodedb *n, struct llarp_rc *prev,
}
}
} // end extern

@ -194,7 +194,6 @@ llarp_pathbuilder_context::BuildOne()
llarp_pathbuilder_build_path(job);
}
extern "C" {
struct llarp_pathbuilder_context*
llarp_pathbuilder_context_new(struct llarp_router* router,
struct llarp_dht_context* dht)
@ -222,4 +221,3 @@ llarp_pathbuilder_build_path(struct llarp_pathbuild_job* job)
llarp_logic_queue_job(job->router->logic,
{job, &llarp::pathbuilder_start_build});
}
} // end extern c

@ -816,7 +816,6 @@ llarp_router::HasPendingConnectJob(const llarp::RouterID &remote)
return pendingEstablishJobs.find(remote) != pendingEstablishJobs.end();
}
extern "C" {
struct llarp_router *
llarp_init_router(struct llarp_threadpool *tp, struct llarp_ev_loop *netloop,
struct llarp_logic *logic)
@ -1082,8 +1081,6 @@ llarp_findOrCreateIdentity(llarp_crypto *crypto, const char *fpath,
return false;
}
} // end extern C
// C++ ...
bool
llarp_findOrCreateEncryption(llarp_crypto *crypto, const char *fpath,

@ -5,7 +5,6 @@
#include "buffer.hpp"
#include "logger.hpp"
extern "C" {
void
llarp_rc_free(struct llarp_rc *rc)
{
@ -222,4 +221,3 @@ llarp_rc_bencode(const struct llarp_rc *rc, llarp_buffer_t *buff)
return false;
return bencode_end(buff);
}
}

@ -109,8 +109,6 @@ struct llarp_threadpool
}
};
extern "C" {
struct llarp_threadpool *
llarp_init_threadpool(int workers, const char *name)
{
@ -189,4 +187,3 @@ llarp_free_threadpool(struct llarp_threadpool **pool)
}
*pool = nullptr;
}
}

@ -15,7 +15,6 @@ namespace llarp
}
} // namespace llarp
extern "C" {
llarp_time_t
llarp_time_now_ms()
{
@ -27,4 +26,3 @@ llarp_time_now_sec()
{
return llarp::time_since_epoch< std::chrono::seconds, llarp_seconds_t >();
}
}

@ -132,8 +132,6 @@ struct llarp_timer_context
}
};
extern "C" {
struct llarp_timer_context*
llarp_init_timer()
{
@ -234,7 +232,6 @@ llarp_timer_run(struct llarp_timer_context* t, struct llarp_threadpool* pool)
}
}
}
}
namespace llarp
{

Loading…
Cancel
Save