Skip to content

Commit d03e78f

Browse files
committed
Further trim the psx headers and support easy vendoring.
Remove psx_pthread_create() from libpsx - given the way -lpsx is linked this is not needed. Also, as pointed out by Lorenz Bauer, "go mod vendor" support was unable to vendor a copy of psx_syscall.h because it didn't reside in the same directory as the *.go code for the psx package. (General discussion golang/go#26366 .) Given that we can, avoid the use of a sub-directory in the libcap tree. Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
1 parent 4b8f2b0 commit d03e78f

File tree

6 files changed

+7
-34
lines changed

6 files changed

+7
-34
lines changed

Diff for: go/Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ endif
104104

105105
install: all
106106
rm -rf $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx
107-
mkdir -p $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx/include/sys
108-
for x in src/$(IMPORTDIR)/psx/* ; do if [ -d $$x ]; then continue; fi; install -m 0644 $$x $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx; done
109-
install -m 0644 src/$(IMPORTDIR)/psx/include/sys/psx_syscall.h $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx/include/sys/psx_syscall.h
107+
mkdir -p $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx
108+
install -m 0644 src/$(IMPORTDIR)/psx/* $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/psx
110109
mkdir -p $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/cap
111110
rm -rf $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/cap/*
112111
install -m 0644 src/$(IMPORTDIR)/cap/* $(FAKEROOT)$(GOPKGDIR)/$(IMPORTDIR)/cap

Diff for: libcap/include/sys/psx_syscall.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../../psx/include/sys/psx_syscall.h
1+
../../../psx/psx_syscall.h

Diff for: libcap/psx_syscall.h

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include/sys/psx_syscall.h

Diff for: psx/psx.c

+2-11
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
#include <stdlib.h>
2626
#include <string.h>
2727
#include <unistd.h>
28-
#include <sys/psx_syscall.h>
2928
#include <sys/syscall.h>
3029

30+
#include "psx_syscall.h"
31+
3132
/*
3233
* psx_load_syscalls() is weakly defined so we can have it overridden
3334
* by libpsx if it is linked. Specifically, when libcap calls
@@ -486,16 +487,6 @@ int __wrap_pthread_create(pthread_t *thread, const pthread_attr_t *attr,
486487
return ret;
487488
}
488489

489-
/*
490-
* psx_pthread_create is a wrapper for pthread_create() that registers
491-
* the newly created thread. If your threads are created already, they
492-
* can be individually registered with psx_register().
493-
*/
494-
int psx_pthread_create(pthread_t *thread, const pthread_attr_t *attr,
495-
void *(*start_routine) (void *), void *arg) {
496-
return __wrap_pthread_create(thread, attr, start_routine, arg);
497-
}
498-
499490
/*
500491
* __psx_immediate_syscall does one syscall using the current
501492
* process.

Diff for: psx/psx.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ import (
5555
"syscall"
5656
)
5757

58-
// #cgo CFLAGS: -I${SRCDIR}/include
5958
// #cgo LDFLAGS: -lpthread -Wl,-wrap,pthread_create
6059
//
6160
// #include <errno.h>
62-
// #include <sys/psx_syscall.h>
61+
// #include "psx_syscall.h"
6362
//
6463
// long __errno_too(long set_errno) {
6564
// long v = errno;

Diff for: psx/include/sys/psx_syscall.h renamed to psx/psx_syscall.h

-17
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,6 @@ long int psx_syscall6(long int syscall_nr,
5151
long int arg1, long int arg2, long int arg3,
5252
long int arg4, long int arg5, long int arg6);
5353

54-
/*
55-
* psx_pthread_create() wraps the -lpthread pthread_create() function
56-
* call and registers the generated thread with the psx_syscall
57-
* infrastructure.
58-
*
59-
* Note, to transparently redirect all the pthread_create() calls in
60-
* your binary to psx_pthread_create(), link with:
61-
*
62-
* gcc ... -lpsx -lpthread -Wl,-wrap,pthread_create
63-
*
64-
* [That is, libpsx contains an internal definition for the
65-
* __wrap_pthread_create function to invoke psx_pthread_create
66-
* functionality instead.]
67-
*/
68-
int psx_pthread_create(pthread_t *thread, const pthread_attr_t *attr,
69-
void *(*start_routine) (void *), void *arg);
70-
7154
/*
7255
* This function should be used by systems to obtain pointers to the
7356
* two syscall functions provided by the PSX library. A linkage trick

0 commit comments

Comments
 (0)