Skip to content

Commit

Permalink
port: delete useless mutex.h and mutex_* wrappers
Browse files Browse the repository at this point in the history
Only MUTEX_HELD() is used more than once and even that is only used with
locks that are otherwise used only with the POSIX pthreads API.

Simplify things, drop mutex.h and all its uses, and move to using pthreads
locks everywhere (rather than only almost everywhere).  Move MUTEX_HELD into
port.h where it belongs.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
nickalcock authored and kvanhees committed Nov 8, 2023
1 parent 234b39b commit 1993678
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 51 deletions.
30 changes: 0 additions & 30 deletions include/mutex.h

This file was deleted.

5 changes: 2 additions & 3 deletions include/port.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand All @@ -9,7 +9,6 @@
#define _PORT_H

#include <pthread.h>
#include <mutex.h>
#include <unistd.h>
#include <sys/compiler.h>
#include <sys/types.h>
Expand All @@ -26,7 +25,7 @@ hrtime_t gethrtime(void);

int p_online(int cpun);

int mutex_init(mutex_t *m, int flags1, void *ptr);
#define MUTEX_HELD(x) ((x)->__data.__count == 0)

int daemonize(int close_fds);

Expand Down
1 change: 0 additions & 1 deletion libdtrace/dt_pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <sys/ioctl.h>
#include <sys/sysmacros.h>

#include <mutex.h>
#include <port.h>
#include <uprobes.h>

Expand Down
4 changes: 1 addition & 3 deletions libdtrace/dt_proc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand Down Expand Up @@ -82,8 +82,6 @@
#include <poll.h>
#include <setjmp.h>

#include <mutex.h>

#include <libproc.h>
#include <dt_proc.h>
#include <dt_pid.h>
Expand Down
10 changes: 1 addition & 9 deletions libport/time.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Oracle Linux DTrace.
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
*/
Expand All @@ -9,7 +9,6 @@
#include <sys/dtrace_types.h>
#include <time.h>
#include <pthread.h>
#include <mutex.h>

hrtime_t
gethrtime(void)
Expand All @@ -28,10 +27,3 @@ gethrtime(void)

return v;
}

int
mutex_init(mutex_t *m, int flags1, void *ptr)
{
return pthread_mutex_init(m, NULL);
}

1 change: 0 additions & 1 deletion libproc/Pcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@

#include <dt_debug.h>

#include <mutex.h>
#include <platform.h>
#include <port.h>

Expand Down
8 changes: 4 additions & 4 deletions libproc/Psymtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <port.h>
#include <setjmp.h>

#include <mutex.h>
#include <pthread.h>

#include <rtld_db.h>

Expand Down Expand Up @@ -976,7 +976,7 @@ Pmap_mapfile_name(struct ps_prochandle *P, const prmap_t *mapp)
/*
* We wouldn't need these if qsort(3C) took an argument for the callback...
*/
static mutex_t sort_mtx = DEFAULTMUTEX;
static pthread_mutex_t sort_mtx = PTHREAD_MUTEX_INITIALIZER;
static char *sort_strs;
static GElf_Sym *sort_syms;

Expand Down Expand Up @@ -1175,7 +1175,7 @@ optimize_symtab(sym_tbl_t *symtab)
/*
* Sort the two tables according to the appropriate criteria.
*/
mutex_lock(&sort_mtx);
pthread_mutex_lock(&sort_mtx);
sort_strs = symtab->sym_strs;
sort_syms = syms;

Expand All @@ -1184,7 +1184,7 @@ optimize_symtab(sym_tbl_t *symtab)

sort_strs = NULL;
sort_syms = NULL;
mutex_unlock(&sort_mtx);
pthread_mutex_unlock(&sort_mtx);

free(syms);
}
Expand Down

0 comments on commit 1993678

Please sign in to comment.