On Mar 5, 2020 10:15 AM, Steve Williams <[email protected]> wrote:
>
> Hi,
>
> Should this be on ports@? I'm not working on a port...
>
> TL;DR:
> Does anyone have any recommendations on how to work around not having
> pthread_mutexattr_setpshared in the OpenBSD pthreads library?
>
Have you tried searching the ports tree patch files for mention of the
function. You may find a real world example of a workaround.
Edgar
> DETAILS:
> I wanted to see if Apache Guacamole would compile on OpenBSD to server
> as a remote desktop gateway.
>
> It hasn't been too hard to get it to the final linking step.
>
> I am getting an "undefined reference to `pthread_mutexattr_setpshared'":
>
> ../../src/libguac/.libs/libguac.so.17.0: undefined reference to
> `pthread_mutexattr_setpshared'
> collect2: ld returned 1 exit status
> *** Error 1 in src/guacenc (Makefile:565 'guacenc': @echo " CCLD
> " guacenc;/bin/sh ../../libtool --silent --tag=CC --mode=link gcc -s...)
> *** Error 1 in . (Makefile:556 'all-recursive')
> *** Error 1 in /home/steve/src/guacamole-server-1.1.0 (Makefile:453
> 'all')
>
>
> When I look at some of the code using pthread_mutexattr_setpshared, it's
> not #ifdef'd or anything, so I think it's pretty much mandatory code.
>
> pool.c:
>
> guac_pool* guac_pool_alloc(int size) {
>
> pthread_mutexattr_t lock_attributes;
> guac_pool* pool = malloc(sizeof(guac_pool));
>
> /* If unable to allocate, just return NULL. */
> if (pool == NULL)
> return NULL;
>
> /* Initialize empty pool */
> pool->min_size = size;
> pool->active = 0;
> pool->__next_value = 0;
> pool->__head = NULL;
> pool->__tail = NULL;
>
> /* Init lock */
> pthread_mutexattr_init(&lock_attributes);
>
> pthread_mutexattr_setpshared(&lock_attributes,
> PTHREAD_PROCESS_SHARED);
> //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> pthread_mutex_init(&(pool->__lock), &lock_attributes);
>
>
> It looks like this is a posix (of some version) function:
> https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_mutexattr_setpshared.html
>
> An "appropos" search in the OpenBSD man pages for "pthread_mutexattr"
> returned:
> https://man.openbsd.org/man3/pthread_mutexattr.3
>
> This function is definitely missing...
>
> I tried to see if there was a way to use pthread_mutexattr_settype to
> accomplish the same thing, but got lost in the maze of documentation.
>
> Does anyone have any recommendations on how to work around not having
> pthread_mutexattr_setpshared in the OpenBSD pthreads library?
>
> Thanks,
> Steve Williams
>