Browse Source

add --enable-valgrind-clean and associated code to permit building a version of libjack that will not trigger valgrind messages. an alternative would be a nice suppression file, if anyone wants to create one (i don't)

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@4056 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.120.1
paul 14 years ago
parent
commit
27ea8647fa
6 changed files with 64 additions and 6 deletions
  1. +8
    -0
      configure.ac
  2. +7
    -0
      jack/internal.h
  3. +31
    -5
      libjack/client.c
  4. +7
    -0
      libjack/port.c
  5. +3
    -1
      libjack/thread.c
  6. +8
    -0
      libjack/transclient.c

+ 8
- 0
configure.ac View File

@@ -550,6 +550,14 @@ if test x$buffer_resizing != xno; then
AC_DEFINE(DO_BUFFER_RESIZE,,[Enable buffer resizing])
fi

AC_ARG_ENABLE(valgrind-clean,
AC_HELP_STRING([--enable-valgrind-clean],[spend a few extra CPU cycles avoiding unnecessary valgrind warnings (default=no)]),
[
if test x$enable_valgrind_clean != xno ; then
AC_DEFINE(VALGRIND_CLEAN,,[clean up for valgrind])
fi
]
)

AC_ARG_ENABLE(ensure-mlock,
AC_HELP_STRING([--enable-ensure-mlock], [server should fail if unable to lock memory (default=no)]),


+ 7
- 0
jack/internal.h View File

@@ -545,5 +545,12 @@ extern size_t jack_midi_internal_event_size ();
# define unlikely(x) (x)
#endif

#ifdef VALGRIND_CLEAN
#include <string.h>
#define VALGRIND_MEMSET(ptr,val,size) memset ((ptr),(val),(size))
#else
#define VALGRIND_MEMSET(ptr,val,size)
#endif

#endif /* __jack_internal_h__ */


+ 31
- 5
libjack/client.c View File

@@ -1313,6 +1313,7 @@ int
jack_recompute_total_latencies (jack_client_t* client)
{
jack_request_t request;
VALGRIND_MEMSET (&request, 0, sizeof (request));

request.type = RecomputeTotalLatencies;
return jack_client_deliver_request (client, &request);
@@ -1322,6 +1323,7 @@ int
jack_recompute_total_latency (jack_client_t* client, jack_port_t* port)
{
jack_request_t request;
VALGRIND_MEMSET (&request, 0, sizeof (request));

request.type = RecomputeTotalLatency;
request.x.port_info.port_id = port->shared->id;
@@ -1332,6 +1334,7 @@ int
jack_set_freewheel (jack_client_t* client, int onoff)
{
jack_request_t request;
VALGRIND_MEMSET (&request, 0, sizeof (request));

request.type = onoff ? FreeWheel : StopFreeWheel;
request.x.client_id = client->control->id;
@@ -1357,6 +1360,8 @@ jack_session_reply (jack_client_t *client, jack_session_event_t *event )
client->session_cb_immediate_reply = 1;
} else {
jack_request_t request;
VALGRIND_MEMSET (&request, 0, sizeof (request));

request.type = SessionReply;
request.x.client_id = client->control->id;

@@ -1401,9 +1406,11 @@ jack_session_command_t *
jack_session_notify (jack_client_t* client, const char *target, jack_session_event_type_t code, const char *path )
{
jack_request_t request;

jack_session_command_t *retval = NULL;
int num_replies = 0;

VALGRIND_MEMSET (&request, 0, sizeof (request));

request.type = SessionNotify;
if( path )
snprintf( request.x.session.path, sizeof( request.x.session.path ), "%s", path );
@@ -2198,6 +2205,8 @@ jack_activate (jack_client_t *client)
before trying to start the realtime thread
*/

VALGRIND_MEMSET (&req, 0, sizeof (req));

req.type = SetClientCapabilities;
req.x.client_id = client->control->id;
req.x.cap_pid = client->control->pid;
@@ -2261,6 +2270,7 @@ jack_deactivate_aux (jack_client_t *client)
if (client && client->control) { /* not shut down? */
rc = 0;
if (client->control->active) { /* still active? */
VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = DeactivateClient;
req.x.client_id = client->control->id;
rc = jack_client_deliver_request (client, &req);
@@ -2384,6 +2394,8 @@ jack_set_buffer_size (jack_client_t *client, jack_nframes_t nframes)
#ifdef DO_BUFFER_RESIZE
jack_request_t req;

VALGRIND_MEMSET (&req, 0, sizeof (req));

req.type = SetBufferSize;
req.x.nframes = nframes;

@@ -2400,6 +2412,8 @@ jack_connect (jack_client_t *client, const char *source_port,
{
jack_request_t req;

VALGRIND_MEMSET (&req, 0, sizeof (req));

req.type = ConnectPorts;

snprintf (req.x.connect.source_port,
@@ -2425,6 +2439,8 @@ jack_port_disconnect (jack_client_t *client, jack_port_t *port)

pthread_mutex_unlock (&port->connection_lock);

VALGRIND_MEMSET (&req, 0, sizeof (req));

req.type = DisconnectPort;
req.x.port_info.port_id = port->shared->id;

@@ -2437,6 +2453,8 @@ jack_disconnect (jack_client_t *client, const char *source_port,
{
jack_request_t req;

VALGRIND_MEMSET (&req, 0, sizeof (req));

req.type = DisconnectPorts;

snprintf (req.x.connect.source_port,
@@ -2655,11 +2673,15 @@ char *
jack_get_client_name_by_uuid( jack_client_t *client, const char *uuid )
{
jack_request_t request;

char *end_ptr;
jack_client_id_t uuid_int = strtol( uuid, &end_ptr, 10 );
if( *end_ptr != '\0' )

if( *end_ptr != '\0' ) {
return NULL;
}

VALGRIND_MEMSET (&request, 0, sizeof (request));

request.type = GetClientByUUID;
request.x.client_id = uuid_int;
if( jack_client_deliver_request( client, &request ) )
@@ -2682,11 +2704,15 @@ int
jack_reserve_client_name( jack_client_t *client, const char *name, const char *uuid )
{
jack_request_t request;

char *end_ptr;
jack_client_id_t uuid_int = strtol( uuid, &end_ptr, 10 );
if( *end_ptr != '\0' )

if( *end_ptr != '\0' ) {
return -1;
}

VALGRIND_MEMSET (&request, 0, sizeof (request));

request.type = ReserveName;
snprintf( request.x.reservename.name, sizeof( request.x.reservename.name ),
"%s", name );


+ 7
- 0
libjack/port.c View File

@@ -227,6 +227,8 @@ jack_port_register (jack_client_t *client,
jack_port_t *port = 0;
int length ;

VALGRIND_MEMSET (&req, 0, sizeof (req));

req.type = RegisterPort;

length = strlen ((const char *) client->control->name)
@@ -271,6 +273,9 @@ int
jack_port_unregister (jack_client_t *client, jack_port_t *port)
{
jack_request_t req;
VALGRIND_MEMSET (&req, 0, sizeof (req));


req.type = UnRegisterPort;
req.x.port_info.port_id = port->shared->id;
@@ -369,6 +374,8 @@ jack_port_get_all_connections (const jack_client_t *client,
return NULL;
}

VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = GetPortConnections;

req.x.port_info.name[0] = '\0';


+ 3
- 1
libjack/thread.c View File

@@ -65,13 +65,15 @@ maybe_get_capabilities (jack_client_t* client)
if (client != 0) {
jack_request_t req;
if (client->engine->has_capabilities != 0) {
/* we need to ask the engine for realtime capabilities
before trying to run the thread work function
*/
VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = SetClientCapabilities;
req.x.cap_pid = getpid();


+ 8
- 0
libjack/transclient.c View File

@@ -327,6 +327,8 @@ jack_release_timebase (jack_client_t *client)
jack_request_t req;
jack_client_control_t *ctl = client->control;

VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = ResetTimeBaseClient;
req.x.client_id = ctl->id;

@@ -348,6 +350,8 @@ jack_set_sync_callback (jack_client_t *client,
jack_request_t req;
int rc;

VALGRIND_MEMSET (&req, 0, sizeof (req));
if (sync_callback)
req.type = SetSyncClient;
else
@@ -368,6 +372,8 @@ jack_set_sync_timeout (jack_client_t *client, jack_time_t usecs)
{
jack_request_t req;

VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = SetSyncTimeout;
req.x.timeout = usecs;

@@ -382,6 +388,8 @@ jack_set_timebase_callback (jack_client_t *client, int conditional,
jack_request_t req;
jack_client_control_t *ctl = client->control;

VALGRIND_MEMSET (&req, 0, sizeof (req));
req.type = SetTimeBaseClient;
req.x.timebase.client_id = ctl->id;
req.x.timebase.conditional = conditional;


Loading…
Cancel
Save