~ubuntu-branches/ubuntu/hardy/transmission/hardy-updates

« back to all changes in this revision

Viewing changes to libtransmission/platform.h

  • Committer: Bazaar Package Importer
  • Author(s): Philipp Benner
  • Date: 2007-09-15 18:58:42 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20070915185842-cagev5gre27re7ko
Tags: upstream-0.82.dfsg
ImportĀ upstreamĀ versionĀ 0.82.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: platform.h 1401 2007-01-19 01:39:33Z titer $
 
2
 * $Id: platform.h 2552 2007-07-30 15:27:52Z charles $
3
3
 *
4
4
 * Copyright (c) 2005 Transmission authors and contributors
5
5
 *
22
22
 * DEALINGS IN THE SOFTWARE.
23
23
 *****************************************************************************/
24
24
#ifndef TR_PLATFORM_H
25
 
#define TR_PLATFORM_H 1
26
 
 
27
 
#ifdef SYS_BEOS
28
 
  #include <kernel/OS.h>
29
 
  typedef thread_id tr_thread_id_t;
30
 
  typedef sem_id    tr_lock_t;
31
 
  typedef int       tr_cond_t;
32
 
#else
33
 
  #include <pthread.h>
34
 
  typedef pthread_t       tr_thread_id_t;
35
 
  typedef pthread_mutex_t tr_lock_t;
36
 
  typedef pthread_cond_t  tr_cond_t;
37
 
#endif
38
 
typedef struct tr_thread_s
39
 
{
40
 
    void          (* func ) ( void * );
41
 
    void           * arg;
42
 
    char           * name;
43
 
    tr_thread_id_t thread;;
44
 
}
45
 
tr_thread_t;
46
 
 
47
 
char * tr_getCacheDirectory();
48
 
char * tr_getTorrentsDirectory();
49
 
 
50
 
void tr_threadCreate ( tr_thread_t *, void (*func)(void *),
51
 
                       void * arg, char * name );
52
 
void tr_threadJoin   ( tr_thread_t * );
53
 
void tr_lockInit     ( tr_lock_t * );
54
 
void tr_lockClose    ( tr_lock_t * );
55
 
 
56
 
static inline void tr_lockLock( tr_lock_t * l )
57
 
{
58
 
#ifdef SYS_BEOS
59
 
    acquire_sem( *l );
60
 
#else
61
 
    pthread_mutex_lock( l );
62
 
#endif
63
 
}
64
 
 
65
 
static inline void tr_lockUnlock( tr_lock_t * l )
66
 
{
67
 
#ifdef SYS_BEOS
68
 
    release_sem( *l );
69
 
#else
70
 
    pthread_mutex_unlock( l );
71
 
#endif
72
 
}
73
 
 
74
 
void tr_condInit( tr_cond_t * );
75
 
void tr_condWait( tr_cond_t *, tr_lock_t * );
76
 
void tr_condSignal( tr_cond_t * );
77
 
void tr_condClose( tr_cond_t * );
78
 
 
 
25
#define TR_PLATFORM_H
 
26
 
 
27
typedef struct tr_lock_s   tr_lock_t;
 
28
typedef struct tr_cond_s   tr_cond_t;
 
29
typedef struct tr_thread_s tr_thread_t;
 
30
 
 
31
const char * tr_getHomeDirectory( void );
 
32
const char * tr_getCacheDirectory( void );
 
33
const char * tr_getTorrentsDirectory( void );
 
34
 
 
35
tr_thread_t*  tr_threadNew  ( void (*func)(void *), void * arg, const char * name );
 
36
void          tr_threadJoin ( tr_thread_t * );
 
37
 
 
38
tr_lock_t * tr_lockNew        ( void );
 
39
void        tr_lockFree       ( tr_lock_t * );
 
40
int         tr_lockTryLock    ( tr_lock_t * );
 
41
void        tr_lockLock       ( tr_lock_t * );
 
42
void        tr_lockUnlock     ( tr_lock_t * );
 
43
 
 
44
tr_cond_t * tr_condNew       ( void );
 
45
void        tr_condFree      ( tr_cond_t * );
 
46
void        tr_condSignal    ( tr_cond_t * );
 
47
void        tr_condBroadcast ( tr_cond_t * );
 
48
void        tr_condWait      ( tr_cond_t *, tr_lock_t * );
 
49
 
 
50
/***
 
51
**** RW lock:
 
52
**** The lock can be had by one writer or any number of readers.
 
53
***/
 
54
 
 
55
typedef struct tr_rwlock_s tr_rwlock_t;
 
56
 
 
57
tr_rwlock_t*  tr_rwNew           ( void );
 
58
void          tr_rwFree          ( tr_rwlock_t * );
 
59
void          tr_rwReaderLock    ( tr_rwlock_t * );
 
60
int           tr_rwReaderTrylock ( tr_rwlock_t * );
 
61
void          tr_rwReaderUnlock  ( tr_rwlock_t * );
 
62
void          tr_rwWriterLock    ( tr_rwlock_t * );
 
63
int           tr_rwWriterTrylock ( tr_rwlock_t * );
 
64
void          tr_rwWriterUnlock  ( tr_rwlock_t * );
 
65
 
 
66
 
 
67
struct in_addr; /* forward declaration to calm gcc down */
79
68
int
80
69
tr_getDefaultRoute( struct in_addr * addr );
81
70