#include <assert.h>
#include <lttng/lttng-error.h>
+#include <common/common.h>
#include "error.h"
*
* These code MUST be negative in other to treat that as an error value.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
const char *error_get_str(int32_t code)
{
code = -code;
#include <urcu.h>
#include <urcu/futex.h>
-#include <common/error.h>
+#include <common/common.h>
#include "futex.h"
* futex() call. If active, we set the value and wake everyone else we indicate
* that we are gone (cleanup() case).
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
void futex_wait_update(int32_t *futex, int active)
{
if (active) {
/*
* Prepare futex.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
void futex_nto1_prepare(int32_t *futex)
{
uatomic_set(futex, -1);
/*
* Wait futex.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
void futex_nto1_wait(int32_t *futex)
{
cmm_smp_mb();
/*
* Wake 1 futex.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
void futex_nto1_wake(int32_t *futex)
{
if (caa_unlikely(uatomic_read(futex) == -1)) {
* with 12*3 instructions on 3 integers than you can with 3 instructions on 1
* byte), but shoehorning those bytes into integers efficiently is messy.
*/
-
+#define _GNU_SOURCE
#include <assert.h>
#include <stdint.h> /* defines uint32_t etc */
#include <stdio.h> /* defines printf for tests */
#include "utils.h"
#include <common/compat/endian.h> /* attempt to define endianness */
+#include <common/common.h>
/*
* My best guess at if you are big-endian or little-endian. This may
/*
* Hash function for number value.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
unsigned long hash_key_ulong(void *_key, unsigned long seed)
{
union {
/*
* Hash function for number value.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
unsigned long hash_key_ulong(void *_key, unsigned long seed)
{
uint32_t key = (uint32_t) _key;
/*
* Hash function for string.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
unsigned long hash_key_str(void *key, unsigned long seed)
{
return hashlittle(key, strlen((char *) key), seed);
/*
* Hash function compare for number value.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int hash_match_key_ulong(void *key1, void *key2)
{
if (key1 == key2) {
/*
* Hash compare function for string.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int hash_match_key_str(void *key1, void *key2)
{
if (strcmp(key1, key2) == 0) {
#include <sched.h>
#include <sys/signal.h>
-#include <common/error.h>
+#include <common/common.h>
#include <common/utils.h>
#include <common/compat/mman.h>
#include <common/compat/clone.h>
}
}
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int run_as_mkdir_recursive(const char *path, mode_t mode, uid_t uid, gid_t gid)
{
struct run_as_mkdir_data data;
return run_as(_mkdir_recursive, &data, uid, gid);
}
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int run_as_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid)
{
struct run_as_mkdir_data data;
* Note: open_run_as is currently not working. We'd need to pass the fd
* opened in the child to the parent.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int run_as_open(const char *path, int flags, mode_t mode, uid_t uid, gid_t gid)
{
struct run_as_open_data data;
#include <unistd.h>
#include <errno.h>
-#include <common/defaults.h>
-#include <common/error.h>
+#include <common/common.h>
#include "inet.h"
/*
* Creates an PF_INET socket.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_create_inet_sock(struct lttcomm_sock *sock, int type, int proto)
{
int val = 1, ret;
/*
* Bind socket and return.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_bind_inet_sock(struct lttcomm_sock *sock)
{
int ret;
/*
* Connect PF_INET socket.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_connect_inet_sock(struct lttcomm_sock *sock)
{
int ret, closeret;
* Do an accept(2) on the sock and return the new lttcomm socket. The socket
* MUST be bind(2) before.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
struct lttcomm_sock *lttcomm_accept_inet_sock(struct lttcomm_sock *sock)
{
int new_fd;
/*
* Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_listen_inet_sock(struct lttcomm_sock *sock, int backlog)
{
int ret;
*
* Return the size of received data.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_recvmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
*
* Return the size of sent data.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_sendmsg_inet_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
/*
* Shutdown cleanly and close.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_close_inet_sock(struct lttcomm_sock *sock)
{
int ret;
#include <unistd.h>
#include <errno.h>
-#include <common/defaults.h>
-#include <common/error.h>
+#include <common/common.h>
#include "inet6.h"
/*
* Creates an PF_INET socket.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_create_inet6_sock(struct lttcomm_sock *sock, int type, int proto)
{
int val = 1, ret;
/*
* Bind socket and return.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_bind_inet6_sock(struct lttcomm_sock *sock)
{
int ret;
/*
* Connect PF_INET socket.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_connect_inet6_sock(struct lttcomm_sock *sock)
{
int ret, closeret;
* Do an accept(2) on the sock and return the new lttcomm socket. The socket
* MUST be bind(2) before.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
struct lttcomm_sock *lttcomm_accept_inet6_sock(struct lttcomm_sock *sock)
{
int new_fd;
/*
* Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_listen_inet6_sock(struct lttcomm_sock *sock, int backlog)
{
int ret;
*
* Return the size of received data.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_recvmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
*
* Return the size of sent data.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_sendmsg_inet6_sock(struct lttcomm_sock *sock, void *buf,
size_t len, int flags)
{
/*
* Shutdown cleanly and close.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_close_inet6_sock(struct lttcomm_sock *sock)
{
int ret;
#include <unistd.h>
#include <errno.h>
-#include <common/defaults.h>
-#include <common/error.h>
+#include <common/common.h>
#include "sessiond-comm.h"
*
* These code MUST be negative in other to treat that as an error value.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
const char *lttcomm_get_readable_code(enum lttcomm_return_code code)
{
code = -code;
* Create socket from an already allocated lttcomm socket structure and init
* sockaddr in the lttcomm sock.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_create_sock(struct lttcomm_sock *sock)
{
int ret, _sock_type, _sock_proto, domain;
/*
* Return allocated lttcomm socket structure.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
struct lttcomm_sock *lttcomm_alloc_sock(enum lttcomm_sock_proto proto)
{
struct lttcomm_sock *sock;
* This is mostly useful when lttcomm_sock are passed between process where the
* fd and ops have to be changed within the correct address space.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
struct lttcomm_sock *lttcomm_alloc_copy_sock(struct lttcomm_sock *src)
{
struct lttcomm_sock *sock;
* This is mostly useful when lttcomm_sock are passed between process where the
* fd and ops have to be changed within the correct address space.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
void lttcomm_copy_sock(struct lttcomm_sock *dst, struct lttcomm_sock *src)
{
/* Safety net */
/*
* Init IPv4 sockaddr structure.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_init_inet_sockaddr(struct lttcomm_sockaddr *sockaddr,
const char *ip, unsigned int port)
{
/*
* Init IPv6 sockaddr structure.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_init_inet6_sockaddr(struct lttcomm_sockaddr *sockaddr,
const char *ip, unsigned int port)
{
/*
* Return allocated lttcomm socket structure from lttng URI.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
struct lttcomm_sock *lttcomm_alloc_sock_from_uri(struct lttng_uri *uri)
{
int ret;
/*
* Destroy and free lttcomm socket.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
void lttcomm_destroy_sock(struct lttcomm_sock *sock)
{
free(sock);
#include <unistd.h>
#include <errno.h>
-#include <common/defaults.h>
-#include <common/error.h>
+#include <common/common.h>
#include "unix.h"
/*
* Connect to unix socket using the path name.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_connect_unix_sock(const char *pathname)
{
struct sockaddr_un sun;
* Do an accept(2) on the sock and return the new file descriptor. The socket
* MUST be bind(2) before.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_accept_unix_sock(int sock)
{
int new_fd;
* Creates a AF_UNIX local socket using pathname bind the socket upon creation
* and return the fd.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_create_unix_sock(const char *pathname)
{
struct sockaddr_un sun;
/*
* Make the socket listen using LTTNG_SESSIOND_COMM_MAX_LISTEN.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_listen_unix_sock(int sock)
{
int ret;
*
* Return the size of received data.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len)
{
struct msghdr msg;
*
* Return the size of sent data.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len)
{
struct msghdr msg;
/*
* Shutdown cleanly a unix socket.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_close_unix_sock(int sock)
{
int ret, closeret;
*
* Returns the size of data sent, or negative error value.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd)
{
struct msghdr msg;
* Expect at most "nb_fd" file descriptors. Returns the number of fd
* actually received in nb_fd.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd)
{
struct iovec iov[1];
*
* Returns the size of data sent, or negative error value.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_send_creds_unix_sock(int sock, void *buf, size_t len)
{
struct msghdr msg;
*
* Returns the size of received data, or negative error value.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t lttcomm_recv_creds_unix_sock(int sock, void *buf, size_t len,
lttng_sock_cred *creds)
{
* Set socket option to use credentials passing.
*/
#ifdef __linux__
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_setsockopt_creds_unix_sock(int sock)
{
int ret, on = 1;
return ret;
}
#elif (defined(__FreeBSD__) || defined(__CYGWIN__))
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_setsockopt_creds_unix_sock(int sock)
{
return 0;
/*
* Set socket reciving timeout.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int sec)
{
int ret;
/*
* Set socket sending timeout.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int lttcomm_setsockopt_snd_timeout(int sock, unsigned int sec)
{
int ret;
/*
* Build a string URL from a lttng_uri object.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int uri_to_str_url(struct lttng_uri *uri, char *dst, size_t size)
{
int ipver, ret;
*
* Return 0 if equal else 1.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int uri_compare(struct lttng_uri *uri1, struct lttng_uri *uri2)
{
return memcmp(uri1, uri2, sizeof(struct lttng_uri));
/*
* Free URI memory.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
void uri_free(struct lttng_uri *uri)
{
free(uri);
/*
* Return an allocated URI.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
struct lttng_uri *uri_create(void)
{
struct lttng_uri *uri;
* This code was originally licensed GPLv2 so we acknolwedge the Free Software
* Foundation here for the work and to make sure we are compliant with it.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
ssize_t uri_parse(const char *str_uri, struct lttng_uri **uris)
{
int ret, i = 0;
* /tmp/test1 does, the real path is returned. In normal time, realpath(3)
* fails if the end point directory does not exist.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
char *utils_expand_path(const char *path)
{
const char *end_path = path;
/*
* Create a pipe in dst.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int utils_create_pipe(int *dst)
{
int ret;
* Make sure the pipe opened by this function are closed at some point. Use
* utils_close_pipe().
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int utils_create_pipe_cloexec(int *dst)
{
int ret, i;
/*
* Close both read and write side of the pipe.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
void utils_close_pipe(int *src)
{
int i, ret;
/*
* Create a new string using two strings range.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
char *utils_strdupdelim(const char *begin, const char *end)
{
char *str;
/*
* Set CLOEXEC flag to the give file descriptor.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int utils_set_fd_cloexec(int fd)
{
int ret;
/*
* Create pid file to the given path and filename.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int utils_create_pid_file(pid_t pid, const char *filepath)
{
int ret;
*
* On success, return 0 else a negative error code.
*/
-__attribute__((visibility("hidden")))
+LTTNG_HIDDEN
int utils_mkdir_recursive(const char *path, mode_t mode)
{
char *p, tmp[PATH_MAX];