Skip to content

Commit

Permalink
Fix gcc errors from HTHREADS/PTTRACE rework commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Fish-Git committed Jun 2, 2013
1 parent beeeed6 commit 9a643b3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
12 changes: 6 additions & 6 deletions README.PTT
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and other thread related problems. We've gotten better at it but we still
have problems with it from time to time. (Programmers are not perfect and
make mistakes, Hercules developers included.)

Greg Smith was the one that took up the challenge and creates our basic PTT
Greg Smith was the one that took up the challenge and created our basic PTT
tracing facility to try and help identify such threading/locking problems.

It was primarily written to intercept lock and condition variable calls and
Expand All @@ -44,7 +44,7 @@ to the trace table.

In June of 2013 however, Fish needed to make some enhancements to the lock
functions to automatically detect and report errors (non-zero return codes
from any of the locking calls) under the guidance of Mark Gaubatz.
from any of the locking calls) under the guidance of Mark L. Gaubatz.

It was at this time it was recognized that the generalized "PTT intercept"
functions that were originally a part of the pttrace.c module as originally
Expand All @@ -53,7 +53,7 @@ written/designed by Greg Smith should actually be moved into a separate
modules responsible for only what they were meant for: generalized event
table tracing.

This allowed us to cleanup much of the macro redefinition monkey business
This allowed us to clean up much of the macro redefinition monkey business
originally in the 'hthreads.h' header that was originally coded solely for
the purpose of interfacing with the "PTT" internal trace table facility.

Expand All @@ -74,14 +74,14 @@ To use it, simply add a 'PTT' macro call to your code. The parameters to the
macro are as follows:


PTT( class, msg, ptr1, ptr2, rc )
PTT( class, msg, p1, p2, rc );

Where:

U32 class; /* Trace class (see header) */
const char* msg; /* Trace message */
const void* ptr1; /* Data 1 */
const void* ptr2; /* Data 2 */
const void* p1; /* Data 1 */
const void* p2; /* Data 2 */
int rc; /* Return code */


Expand Down
16 changes: 11 additions & 5 deletions hthreads.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/*-------------------------------------------------------------------*/
/* Based on original pttrace.c (C) Copyright Greg Smith, 2003-2013 */
/* Checking rc and calling loglock based on collaboration between */
/* "Fish" (Dabid B. Trout) and Mark L. Gaubatz, May 2013 */
/* "Fish" (David B. Trout) and Mark L. Gaubatz, May 2013 */
/*-------------------------------------------------------------------*/

#include "hstdinc.h"
Expand Down Expand Up @@ -53,10 +53,10 @@ static void loglock( LOCK* plk, const int rc, const char* calltype, const char*
}

// "Pttrace: '%dur' failed: rc=%d (%dur), tid="TIDPAT", loc=%dur"
WRMSG( HHC90013, "E", calltype, rc, err_desc, hthread_self(), trimloc( err_loc ));
WRMSG( HHC90013, "E", calltype, rc, err_desc, hthread_self(), TRIMLOC( err_loc ));

// "Pttrace: lock was obtained by thread "TIDPAT" at %dur"
WRMSG( HHC90014, "I", plk->tid, trimloc( plk->loc ));
WRMSG( HHC90014, "I", plk->tid, TRIMLOC( plk->loc ));
}

/*-------------------------------------------------------------------*/
Expand Down Expand Up @@ -143,7 +143,7 @@ DLL_EXPORT int hthread_initialize_rwlock( RWLOCK* plk, const char* loc )
if (rc)
goto init_error;

rc = hthread_rwlock_init( &plk->lock, &attr1 );
rc = hthread_rwlock_init( &plk->lock, NULL );
if (rc)
goto init_error;

Expand Down Expand Up @@ -596,8 +596,14 @@ DLL_EXPORT int hthread_equal_threads( TID tid1, TID tid2, const char* loc )
/*-------------------------------------------------------------------*/
DLL_EXPORT int hthread_win_thread_handle( TID tid, const char* loc )
{
#if defined( _MSVC_ )
int rc;
UNREFERENCED( loc );
rc = (int) hthread_get_handle( tid );
rc = (int) (uintptr_t) hthread_get_handle( tid );
return rc;
#else // !defined( _MSVC_ )
UNREFERENCED( loc );
UNREFERENCED( tid );
return 0;
#endif
}
2 changes: 1 addition & 1 deletion hthreads.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ typedef pthread_rwlock_t HRWLOCK;
#define hthread_rwlock_tryrdlock( plk ) pthread_rwlock_tryrdlock( plk )
#define hthread_rwlock_trywrlock( plk ) pthread_rwlock_trywrlock( plk )

#define hthread_cond_init( plc ) pthread_cond_init( plc )
#define hthread_cond_init( plc ) pthread_cond_init( plc, NULL )
#define hthread_cond_wait( plc, plk ) pthread_cond_wait( (plc), (plk) )
#define hthread_cond_timedwait( plc, plk, tm ) pthread_cond_timedwait( (plc), (plk), (tm) )
#define hthread_cond_signal( plc ) pthread_cond_signal( plc )
Expand Down
4 changes: 2 additions & 2 deletions pttrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static void* ptt_timeout( void* arg )
/*-------------------------------------------------------------------*/
/* Process 'ptt' tracing command */
/*-------------------------------------------------------------------*/
DLL_EXPORT int ptt_cmd(int argc, const char *argv[], const char* cmdline)
DLL_EXPORT int ptt_cmd(int argc, char *argv[], char* cmdline)
{
int rc = 0;
int n, to = -1;
Expand Down Expand Up @@ -380,7 +380,7 @@ DLL_EXPORT void ptt_trace_init( int n, int init )
/* Primary PTT tracing function to fill in a PTT_TRACE table entry. */
/*-------------------------------------------------------------------*/
DLL_EXPORT void ptt_pthread_trace (int trclass, const char *msg,
void *data1, void *data2,
const void *data1, const void *data2,
const char *loc, int rc)
{
int i, n;
Expand Down
4 changes: 2 additions & 2 deletions pttrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ do { \
/* Exported Function Definitions */
/*-------------------------------------------------------------------*/
PTT_DLL_IMPORT void ptt_trace_init ( int n, int init );
PTT_DLL_IMPORT int ptt_cmd ( int argc, const char* argv[], const char* cmdline );
PTT_DLL_IMPORT int ptt_cmd ( int argc, char* argv[], char* cmdline );
PTT_DLL_IMPORT void ptt_pthread_trace ( int, const char*, const void*, const void*, const char*, int );
PTT_DLL_IMPORT int ptt_pthread_print ();
PTT_DLL_IMPORT int pttclass;
PTT_DLL_IMPORT U32 pttclass;
PTT_DLL_IMPORT int pttthread;

/*-------------------------------------------------------------------*/
Expand Down

0 comments on commit 9a643b3

Please sign in to comment.