1/**
2 * \file include/global.h
3 * \brief Application interface library for the ALSA driver
4 * \author Jaroslav Kysela <perex@perex.cz>
5 * \author Abramo Bagnara <abramo@alsa-project.org>
6 * \author Takashi Iwai <tiwai@suse.de>
7 * \date 1998-2001
8 *
9 * Application interface library for the ALSA driver
10 */
11/*
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as
14 * published by the Free Software Foundation; either version 2.1 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 */
27
28#ifndef __ALSA_GLOBAL_H_
29#define __ALSA_GLOBAL_H_
30
31/* for timeval and timespec */
32#include <time.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/**
39 * \defgroup Global Global defines and functions
40 * Global defines and functions.
41 * \par
42 * The ALSA library implementation uses these macros and functions.
43 * Most applications probably do not need them.
44 * \{
45 */
46
47const char *snd_asoundlib_version(void);
48
49#ifndef ATTRIBUTE_UNUSED
50/** do not print warning (gcc) when function parameter is not used */
51#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
52#endif
53
54#ifdef PIC /* dynamic build */
55
56/** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */
57#define __SND_DLSYM_VERSION(name, version) _ ## name ## version
58/**
59 * \hideinitializer
60 * \brief Appends the build version to the name of a versioned dynamic symbol.
61 */
62#define SND_DLSYM_BUILD_VERSION(name, version) char __SND_DLSYM_VERSION(name, version);
63
64#else /* static build */
65
66struct snd_dlsym_link {
67 struct snd_dlsym_link *next;
68 const char *dlsym_name;
69 const void *dlsym_ptr;
70};
71
72extern struct snd_dlsym_link *snd_dlsym_start;
73
74/** \hideinitializer \brief Helper macro for #SND_DLSYM_BUILD_VERSION. */
75#define __SND_DLSYM_VERSION(prefix, name, version) _ ## prefix ## name ## version
76/**
77 * \hideinitializer
78 * \brief Appends the build version to the name of a versioned dynamic symbol.
79 */
80#define SND_DLSYM_BUILD_VERSION(name, version) \
81 static struct snd_dlsym_link __SND_DLSYM_VERSION(snd_dlsym_, name, version); \
82 void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) __attribute__ ((constructor)); \
83 void __SND_DLSYM_VERSION(snd_dlsym_constructor_, name, version) (void) { \
84 __SND_DLSYM_VERSION(snd_dlsym_, name, version).next = snd_dlsym_start; \
85 __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_name = # name; \
86 __SND_DLSYM_VERSION(snd_dlsym_, name, version).dlsym_ptr = (void *)&name; \
87 snd_dlsym_start = &__SND_DLSYM_VERSION(snd_dlsym_, name, version); \
88 }
89
90#endif
91
92#ifndef __STRING
93/** \brief Return 'x' argument as string */
94#define __STRING(x) #x
95#endif
96
97/** \brief Returns the version of a dynamic symbol as a string. */
98#define SND_DLSYM_VERSION(version) __STRING(version)
99
100void *snd_dlopen(const char *file, int mode);
101void *snd_dlsym(void *handle, const char *name, const char *version);
102int snd_dlclose(void *handle);
103
104
105/** \brief alloca helper macro. */
106#define __snd_alloca(ptr,type) do { *ptr = (type##_t *) alloca(type##_sizeof()); memset(*ptr, 0, type##_sizeof()); } while (0)
107
108/**
109 * \brief Internal structure for an async notification client handler.
110 *
111 * The ALSA library uses a pointer to this structure as a handle to an async
112 * notification object. Applications don't access its contents directly.
113 */
114typedef struct _snd_async_handler snd_async_handler_t;
115
116/**
117 * \brief Async notification callback.
118 *
119 * See the #snd_async_add_handler function for details.
120 */
121typedef void (*snd_async_callback_t)(snd_async_handler_t *handler);
122
123int snd_async_add_handler(snd_async_handler_t **handler, int fd,
124 snd_async_callback_t callback, void *private_data);
125int snd_async_del_handler(snd_async_handler_t *handler);
126int snd_async_handler_get_fd(snd_async_handler_t *handler);
127int snd_async_handler_get_signo(snd_async_handler_t *handler);
128void *snd_async_handler_get_callback_private(snd_async_handler_t *handler);
129
130struct snd_shm_area *snd_shm_area_create(int shmid, void *ptr);
131struct snd_shm_area *snd_shm_area_share(struct snd_shm_area *area);
132int snd_shm_area_destroy(struct snd_shm_area *area);
133
134int snd_user_file(const char *file, char **result);
135
136#if !defined(_POSIX_C_SOURCE) && !defined(_POSIX_SOURCE)
137struct timeval {
138 time_t tv_sec; /* seconds */
139 long tv_usec; /* microseconds */
140};
141
142struct timespec {
143 time_t tv_sec; /* seconds */
144 long tv_nsec; /* nanoseconds */
145};
146#endif
147
148/** Timestamp */
149typedef struct timeval snd_timestamp_t;
150/** Hi-res timestamp */
151typedef struct timespec snd_htimestamp_t;
152
153/** \} */
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif /* __ALSA_GLOBAL_H */
160