Skip to content

Commit

Permalink
Merge branch 'sverk/test_server/openbsd-dynlink'
Browse files Browse the repository at this point in the history
* sverk/test_server/openbsd-dynlink:
  erts: Skip driver_SUITE:thr_free_drv for VM without threads
  erts: Fix driver_SUITE:otp_9302 for VM without threads
  test_server: Fix dynlib link command for openbsd
  • Loading branch information
sverker committed Feb 19, 2014
2 parents a40cc98 + c3fb1d5 commit 5cdba8e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
10 changes: 9 additions & 1 deletion erts/emulator/test/driver_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%% Copyright Ericsson AB 1997-2014. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -1945,6 +1945,14 @@ otp_9302(Config) when is_list(Config) ->
end.

thr_free_drv(Config) when is_list(Config) ->
case erlang:system_info(threads) of
false ->
{skipped, "No thread support"};
true ->
thr_free_drv_do(Config)
end.

thr_free_drv_do(Config) ->
?line Path = ?config(data_dir, Config),
?line erl_ddll:start(),
?line ok = load_driver(Path, thr_free_drv),
Expand Down
27 changes: 17 additions & 10 deletions erts/emulator/test/driver_SUITE_data/otp_9302_drv.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
* Copyright Ericsson AB 2011-2013. All Rights Reserved.
* Copyright Ericsson AB 2011-2014. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -94,7 +94,7 @@ DRIVER_INIT(otp_9302_drv)
static void stop(ErlDrvData drv_data)
{
Otp9302Data *data = (Otp9302Data *) drv_data;
if (!data->smp)
if (data->msgq.mtx)
erl_drv_mutex_destroy(data->msgq.mtx);
driver_free(data);
}
Expand All @@ -114,13 +114,16 @@ static ErlDrvData start(ErlDrvPort port,
driver_system_info(&sys_info, sizeof(ErlDrvSysInfo));
data->smp = sys_info.smp_support;

data->msgq.mtx = NULL;
if (!data->smp) {
data->msgq.start = NULL;
data->msgq.end = NULL;
data->msgq.mtx = erl_drv_mutex_create("");
if (!data->msgq.mtx) {
driver_free(data);
return ERL_DRV_ERROR_GENERAL;
if (sys_info.thread_support) {
data->msgq.mtx = erl_drv_mutex_create("");
if (!data->msgq.mtx) {
driver_free(data);
return ERL_DRV_ERROR_GENERAL;
}
}
}

Expand All @@ -143,19 +146,22 @@ static void enqueue_reply(Otp9302AsyncData *adata)
Otp9302MsgQ *msgq = adata->msgq;
adata->next = NULL;
adata->refc++;
erl_drv_mutex_lock(msgq->mtx);
if (msgq->mtx)
erl_drv_mutex_lock(msgq->mtx);
if (msgq->end)
msgq->end->next = adata;
else
msgq->end = msgq->start = adata;
msgq->end = adata;
erl_drv_mutex_unlock(msgq->mtx);
if (msgq->mtx)
erl_drv_mutex_unlock(msgq->mtx);
}

static void dequeue_replies(Otp9302AsyncData *adata)
{
Otp9302MsgQ *msgq = adata->msgq;
erl_drv_mutex_lock(msgq->mtx);
if (msgq->mtx)
erl_drv_mutex_lock(msgq->mtx);
if (--adata->refc == 0)
driver_free(adata);
while (msgq->start) {
Expand All @@ -166,7 +172,8 @@ static void dequeue_replies(Otp9302AsyncData *adata)
driver_free(adata);
}
msgq->start = msgq->end = NULL;
erl_drv_mutex_unlock(msgq->mtx);
if (msgq->mtx)
erl_drv_mutex_unlock(msgq->mtx);
}

static void async_invoke(void *data)
Expand Down
27 changes: 25 additions & 2 deletions lib/test_server/src/configure.in
Expand Up @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script for Erlang.
dnl
dnl %CopyrightBegin%
dnl
dnl Copyright Ericsson AB 1997-2013. All Rights Reserved.
dnl Copyright Ericsson AB 1997-2014. All Rights Reserved.
dnl
dnl The contents of this file are subject to the Erlang Public License,
dnl Version 1.1, (the "License"); you may not use this file except in
Expand Down Expand Up @@ -170,7 +170,30 @@ case $system in
fi
SHLIB_EXTRACT_ALL=""
;;
*-netbsd*|*-freebsd*|*-openbsd*|*-dragonfly*)
*-openbsd*)
# Not available on all versions: check for include file.
AC_CHECK_HEADER(dlfcn.h, [
SHLIB_CFLAGS="-fpic"
SHLIB_LD="${CC}"
SHLIB_LDFLAGS="$LDFLAGS -shared"
SHLIB_SUFFIX=".so"
if test X${enable_m64_build} = Xyes; then
AC_MSG_ERROR(don't know how to link 64-bit dynamic drivers)
fi
if test X${enable_m32_build} = Xyes; then
AC_MSG_ERROR(don't know how to link 32-bit dynamic drivers)
fi
], [
# No dynamic loading.
SHLIB_CFLAGS=""
SHLIB_LD="ld"
SHLIB_LDFLAGS=""
SHLIB_SUFFIX=""
AC_MSG_ERROR(don't know how to compile and link dynamic drivers)
])
SHLIB_EXTRACT_ALL=""
;;
*-netbsd*|*-freebsd*|*-dragonfly*)
# Not available on all versions: check for include file.
AC_CHECK_HEADER(dlfcn.h, [
SHLIB_CFLAGS="-fpic"
Expand Down

0 comments on commit 5cdba8e

Please sign in to comment.