On Sun, 8 Apr 2007, Ralf Wildenhues wrote:
(stupid symbol names aside):

   lt_dlopaque opaque = lt_dlopaque_new();

   lt_dlset_symglobal (opaque);

   handle = lt_dlopenopaque ("libmod.la", opaque);

But this is how it can be extended without breaking API!  Only if
lt_dlopaque is a pointer type, of course, and also you need to free the
object later on.

And IIUC then this is how pthread works, too, no?

The pthread interfaces don't assume that the object is a pointer so they work differently than suggested. Pointers are error prone so they are best reserved for internal library interfaces if possible. The implementation is free to embed pointers in the API object.

Given these pthread interfaces:

     int pthread_mutexattr_init(pthread_mutexattr_t *attr);

     int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);

     int pthread_mutexattr_setpshared(pthread_mutexattr_t  *attr,
     int pshared);

     int pthread_mutex_init(pthread_mutex_t *mutex, const
     pthread_mutexattr_t *attr);

     int pthread_mutex_destroy(pthread_mutex_t *mutex);

This is now they would be used

pthread_mutex_t mutex; pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_setpshared(&attr,PTHREAD_PROCESS_SHARED); pthread_mutex_init(&mutex, &attr); pthread_mutexattr_destroy(&attr); pthread_mutex_destroy(&mutex);

Bob


Reply via email to