Commit 42d42fbcb358841fc03ad107b0cc2a5befadf093

Thomas de Grivel 2023-11-21T12:30:13

win64

diff --git a/include/bsd/stdio.h b/include/bsd/stdio.h
index 4b69983..8929bfa 100644
--- a/include/bsd/stdio.h
+++ b/include/bsd/stdio.h
@@ -63,12 +63,13 @@ char *fgetln(FILE *fp, size_t *lenp)
  * as the code has to be modified anyway, we might just as well use the
  * correct declaration here.
  */
+/*
 FILE *funopen(const void *cookie,
               int (*readfn)(void *cookie, char *buf, int size),
               int (*writefn)(void *cookie, const char *buf, int size),
               off_t (*seekfn)(void *cookie, off_t offset, int whence),
               int (*closefn)(void *cookie));
-
+*/
 #define fropen(cookie, fn) funopen(cookie, fn, NULL, NULL, NULL)
 #define fwopen(cookie, fn) funopen(cookie, NULL, fn, NULL, NULL)
 
diff --git a/include/bsd/unistd.h b/include/bsd/unistd.h
index 167241b..847a0f7 100644
--- a/include/bsd/unistd.h
+++ b/include/bsd/unistd.h
@@ -57,7 +57,13 @@ extern int optreset;
 int bsd_getopt(int argc, char * const argv[], const char *shortopts);
 
 mode_t getmode(const void *set, mode_t mode);
-void *setmode(const char *mode_str);
+
+#ifdef LIBBSD_OVERLAY
+#undef setmode
+#define setmode(mode_str) bsd_setmode(mode_str)
+#endif
+
+void *bsd_setmode(const char *mode_str);
 
 void closefrom(int lowfd);
 
@@ -68,7 +74,9 @@ void setproctitle_init(int argc, char *argv[], char *envp[]);
 void setproctitle(const char *fmt, ...)
 	__printflike(1, 2);
 
+/*
 int getpeereid(int s, uid_t *euid, gid_t *egid);
+*/
 __END_DECLS
 
 #endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 7ef2013..1c12ea4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,6 +60,7 @@ if HAVE_LINKER_VERSION_SCRIPT
 libbsd_la_LDFLAGS += \
 	-Wl,--version-script=$(srcdir)/libbsd.map
 endif
+libbsd_la_LDFLAGS += --shared -no-undefined -Wl,-no-undefined
 libbsd_la_SOURCES = \
 	arc4random.c \
 	arc4random.h \
@@ -75,38 +76,26 @@ libbsd_la_SOURCES = \
 	err.c \
 	expand_number.c \
 	explicit_bzero.c \
-	fgetln.c \
 	freezero.c \
 	fgetwln.c \
-	flopen.c \
 	fmtcheck.c \
 	fparseln.c \
-	fpurge.c \
-	funopen.c \
 	getbsize.c \
-	getpeereid.c \
 	heapsort.c \
 	humanize_number.c \
 	inet_net_pton.c \
 	local-elf.h \
 	local-link.h \
-	md5.c \
 	merge.c \
-	nlist.c \
-	pidfile.c \
 	progname.c \
-	pwcache.c \
 	radixsort.c \
-	readpassphrase.c \
 	reallocarray.c \
 	reallocf.c \
 	recallocarray.c \
-	setmode.c \
 	setproctitle.c \
 	strlcat.c \
 	strlcpy.c \
 	stringlist.c \
-	strmode.c \
 	strnstr.c \
 	strtoi.c \
 	strtonum.c \
@@ -118,11 +107,11 @@ libbsd_la_SOURCES = \
 	wcslcpy.c \
 	$(nil)
 
-if !HAVE_GETENTROPY
-libbsd_la_SOURCES += \
-	getentropy.c \
-	$(nil)
-endif
+#if !HAVE_GETENTROPY
+#libbsd_la_SOURCES += \
+#	getentropy.c \
+#	$(nil)
+#endif
 
 libbsd_ctor_a_SOURCES = \
 	setproctitle_ctor.c \
diff --git a/src/libbsd.map b/src/libbsd.map
index fb2888f..9281b3a 100644
--- a/src/libbsd.map
+++ b/src/libbsd.map
@@ -25,7 +25,7 @@ LIBBSD_0.0 {
     strlcpy;
     strlcat;
 
-    setmode;
+    /*setmode;*/
     getmode;
 
     vis;
@@ -81,7 +81,7 @@ LIBBSD_0.2 {
 
 LIBBSD_0.3 {
     reallocf;
-    getpeereid;
+    /*getpeereid;*/
 
     mergesort;
     radixsort;
@@ -119,7 +119,7 @@ LIBBSD_0.7 {
     /* This symbol might not be present on some specific systems, such
      * as musl based ones. It might need to be removed on SOVERSION bump,
      * as it cannot be portabily implemented everywhere. */
-    funopen;
+    /*funopen;*/
 
     reallocarray;
 
diff --git a/src/setmode.c b/src/setmode.c
index f65875e..48ac2dd 100644
--- a/src/setmode.c
+++ b/src/setmode.c
@@ -159,7 +159,7 @@ common:			if (set->cmd2 & CMD2_CLR) {
 #define	STANDARD_BITS	(S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
 
 void *
-setmode(const char *p)
+bsd_setmode(const char *p)
 {
 	int serrno;
 	char op, *ep;