rpm  5.4.15
Data Structures | Macros | Typedefs | Functions | Variables
yarn.c File Reference
#include "system.h"
#include <rpmiotypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "yarn.h"
#include "debug.h"
Include dependency graph for yarn.c:

Go to the source code of this file.

Data Structures

struct  yarnLock_s
 
struct  yarnThread_s
 
struct  capsule
 

Macros

#define pthread_t   int
 
#define pthread_self()   0
 
#define pthread_equal(_t1, _t2)   ((_t1) == (_t2))
 
#define pthread_create(__newthread, __attr, __start_routine, arg)   (EINVAL)
 
#define pthread_join(__thread, __value_ptr)   (EINVAL)
 
#define pthread_cancel(__th)   (EINVAL)
 
#define pthread_cleanup_pop(__execute)
 
#define pthread_cleanup_push(__routine, __arg)
 
#define pthread_attr_t   int
 
#define pthread_attr_init(__attr)   (EINVAL)
 
#define pthread_attr_destroy(__attr)   (EINVAL)
 
#define pthread_attr_setdetachstate(__attr, __detachstate)   (EINVAL)
 
#define pthread_mutex_t   int
 
#define PTHREAD_MUTEX_INITIALIZER   0
 
#define PTHREAD_CREATE_JOINABLE   0
 
#define pthread_mutex_destroy(__mutex)   (0) /* FreeLock */
 
#define pthread_mutex_init(__mutex, __attr)   (0) /* NewLock */
 
#define pthread_mutex_lock(__mutex)   (0) /* Possess */
 
#define pthread_mutex_unlock(__mutex)   (0) /* Twist/Release */
 
#define pthread_cond_t   int
 
#define PTHREAD_COND_INITIALIZER   0
 
#define pthread_cond_destroy(__cond)   (0) /* FreeLock */
 
#define pthread_cond_init(__cond, __attr)   (0) /* NewLock */
 
#define pthread_cond_wait(__cond, __mutex)   (EINVAL)/* WaitFor */
 
#define pthread_cond_broadcast(__cond)   (0) /* Twist */
 
#define fail(_err)   _fail((_err), __FILE__, __LINE__)
 
#define until(a)   while(!(a))
 

Typedefs

typedef void *(* malloc_t )(size_t)
 
typedef void(* free_t )(void *)
 

Functions

static void _fail (int err, const char *fn, unsigned ln)
 
void yarnMem (malloc_t lease, free_t vacate)
 
static void * my_malloc (size_t size)
 
yarnLock yarnNewLock (long initial)
 
void yarnPossess (yarnLock bolt)
 
void yarnRelease (yarnLock bolt)
 
void yarnTwist (yarnLock bolt, yarnTwistOP op, long val)
 
void yarnWaitFor (yarnLock bolt, yarnWaitOP op, long val)
 
long yarnPeekLock (yarnLock bolt)
 
yarnLock yarnFreeLock (yarnLock bolt)
 
yarnThread yarnLaunchStack (void(*probe)(void *), void *payload, void *stack, size_t nstack)
 
yarnThread yarnLaunch (void(*probe)(void *), void *payload)
 
yarnThread yarnJoin (yarnThread ally)
 
int yarnJoinAll (void)
 
void yarnDestruct (yarnThread off_course)
 

Variables

const char * yarnPrefix = "yarn"
 
void(* yarnAbort )(int) = NULL
 
static malloc_t my_malloc_f = malloc
 
static free_t my_free = free
 
static struct yarnLock_s threads_lock
 
static yarnThread threads = NULL
 

Macro Definition Documentation

#define fail (   _err)    _fail((_err), __FILE__, __LINE__)
#define pthread_attr_destroy (   __attr)    (EINVAL)

Definition at line 65 of file yarn.c.

Referenced by yarnLaunchStack().

#define pthread_attr_init (   __attr)    (EINVAL)

Definition at line 64 of file yarn.c.

Referenced by yarnLaunchStack().

#define pthread_attr_setdetachstate (   __attr,
  __detachstate 
)    (EINVAL)

Definition at line 66 of file yarn.c.

Referenced by yarnLaunchStack().

#define pthread_attr_t   int

Definition at line 63 of file yarn.c.

Referenced by yarnLaunchStack().

#define pthread_cancel (   __th)    (EINVAL)

Definition at line 59 of file yarn.c.

Referenced by yarnDestruct().

#define pthread_cleanup_pop (   __execute)

Definition at line 60 of file yarn.c.

#define pthread_cleanup_push (   __routine,
  __arg 
)

Definition at line 61 of file yarn.c.

#define pthread_cond_broadcast (   __cond)    (0) /* Twist */

Definition at line 81 of file yarn.c.

Referenced by yarnTwist().

#define pthread_cond_destroy (   __cond)    (0) /* FreeLock */

Definition at line 78 of file yarn.c.

Referenced by yarnFreeLock().

#define pthread_cond_init (   __cond,
  __attr 
)    (0) /* NewLock */

Definition at line 79 of file yarn.c.

Referenced by yarnNewLock().

#define PTHREAD_COND_INITIALIZER   0

Definition at line 77 of file yarn.c.

#define pthread_cond_t   int

Definition at line 76 of file yarn.c.

#define pthread_cond_wait (   __cond,
  __mutex 
)    (EINVAL)/* WaitFor */

Definition at line 80 of file yarn.c.

Referenced by yarnWaitFor().

#define pthread_create (   __newthread,
  __attr,
  __start_routine,
  arg 
)    (EINVAL)

Definition at line 57 of file yarn.c.

Referenced by rpmsqThread(), and yarnLaunchStack().

#define PTHREAD_CREATE_JOINABLE   0

Definition at line 70 of file yarn.c.

Referenced by yarnLaunchStack().

#define pthread_equal (   _t1,
  _t2 
)    ((_t1) == (_t2))

Definition at line 56 of file yarn.c.

Referenced by rpmsqThreadEqual().

#define pthread_join (   __thread,
  __value_ptr 
)    (EINVAL)

Definition at line 58 of file yarn.c.

Referenced by rpmsqJoin(), yarnJoin(), and yarnJoinAll().

#define pthread_mutex_destroy (   __mutex)    (0) /* FreeLock */

Definition at line 71 of file yarn.c.

Referenced by avClosedir(), and yarnFreeLock().

#define pthread_mutex_init (   __mutex,
  __attr 
)    (0) /* NewLock */

Definition at line 72 of file yarn.c.

Referenced by avOpendir(), and yarnNewLock().

#define PTHREAD_MUTEX_INITIALIZER   0

Definition at line 69 of file yarn.c.

Referenced by open_dso().

#define pthread_mutex_lock (   __mutex)    (0) /* Possess */

Definition at line 73 of file yarn.c.

Referenced by open_dso(), and yarnPossess().

#define pthread_mutex_t   int

Definition at line 68 of file yarn.c.

Referenced by open_dso().

#define pthread_mutex_unlock (   __mutex)    (0) /* Twist/Release */

Definition at line 74 of file yarn.c.

Referenced by open_dso(), yarnRelease(), and yarnTwist().

#define pthread_self ( )    0

Definition at line 55 of file yarn.c.

Referenced by rpmsqThreadEqual().

#define pthread_t   int

Definition at line 54 of file yarn.c.

Referenced by rpmsqJoin(), rpmsqThread(), and rpmsqThreadEqual().

#define until (   a)    while(!(a))

Definition at line 292 of file yarn.c.

Referenced by yarnWaitFor().

Typedef Documentation

typedef void(* free_t)(void *)

Definition at line 204 of file yarn.c.

typedef void*(* malloc_t)(size_t)

Definition at line 203 of file yarn.c.

Function Documentation

static void _fail ( int  err,
const char *  fn,
unsigned  ln 
)
static

Definition at line 188 of file yarn.c.

References yarnAbort.

static void* my_malloc ( size_t  size)
static

Definition at line 229 of file yarn.c.

References fail, and my_malloc_f.

Referenced by yarnLaunchStack(), and yarnNewLock().

void yarnDestruct ( yarnThread  off_course)

Definition at line 571 of file yarn.c.

References fail, yarnThread_s::id, pthread_cancel, and yarnJoin().

yarnLock yarnFreeLock ( yarnLock  bolt)
yarnThread yarnJoin ( yarnThread  ally)
int yarnJoinAll ( void  )
yarnThread yarnLaunch ( void(*)(void *)  probe,
void *  payload 
)

Definition at line 481 of file yarn.c.

References capsule::probe, and yarnLaunchStack().

yarnThread yarnLaunchStack ( void(*)(void *)  probe,
void *  payload,
void *  stack,
size_t  nstack 
)
void yarnMem ( malloc_t  lease,
free_t  vacate 
)

Definition at line 219 of file yarn.c.

yarnLock yarnNewLock ( long  initial)
long yarnPeekLock ( yarnLock  bolt)
void yarnPossess ( yarnLock  bolt)
void yarnRelease ( yarnLock  bolt)
void yarnTwist ( yarnLock  bolt,
yarnTwistOP  op,
long  val 
)
void yarnWaitFor ( yarnLock  bolt,
yarnWaitOP  op,
long  val 
)

Variable Documentation

free_t my_free = free
static

Definition at line 214 of file yarn.c.

Referenced by yarnFreeLock(), yarnJoin(), and yarnJoinAll().

malloc_t my_malloc_f = malloc
static

Definition at line 213 of file yarn.c.

Referenced by my_malloc().

yarnThread threads = NULL
static

Definition at line 358 of file yarn.c.

Referenced by yarnJoin(), yarnJoinAll(), and yarnLaunchStack().

struct yarnLock_s threads_lock
static
Initial value:
= {
0 ,
0 ,
0
}

Definition at line 352 of file yarn.c.

void(* yarnAbort)(int) = NULL

Definition at line 182 of file yarn.c.

Referenced by _fail().

const char* yarnPrefix = "yarn"

Definition at line 180 of file yarn.c.