i copied pieces from blds/bsd.patch in hope I get this __FreeBSD__
preprocessor directive correctly..

some changes not ported (for example our python script should be python3
compatible by now) and some changes require a bit more ifdefiry in
Makefiles...
From 627821a2974c305a36e3334eed1ca2fd93639cd9 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:18:39 +0300
Subject: [PATCH 2/9] dirent64 and readdir64 aliases for freebsd in
 guicast/filesystem.h

---
 cinelerra-5.1/guicast/filesystem.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cinelerra-5.1/guicast/filesystem.h b/cinelerra-5.1/guicast/filesystem.h
index c976135b..b6cece2d 100644
--- a/cinelerra-5.1/guicast/filesystem.h
+++ b/cinelerra-5.1/guicast/filesystem.h
@@ -26,6 +26,11 @@
 #include "bcwindowbase.inc"
 #include "sizes.h"
 
+#if defined (__FreeBSD__)
+#define dirent64 dirent
+#define readdir64 readdir
+#endif
+
 class FileItem
 {
 public:
-- 
2.35.1

From 9168bbfe3f676e5a2920bfebe81bc81b8dde0db4 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:17:44 +0300
Subject: [PATCH 1/9] unsigned long cast for freebsd in bctrace.C

---
 cinelerra-5.1/guicast/bctrace.C | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cinelerra-5.1/guicast/bctrace.C b/cinelerra-5.1/guicast/bctrace.C
index 7e453925..2d08b46b 100644
--- a/cinelerra-5.1/guicast/bctrace.C
+++ b/cinelerra-5.1/guicast/bctrace.C
@@ -309,7 +309,7 @@ void BC_Trace::dump_traces(FILE *fp)
 	}
 }
 
-void trace_info::set_owner() { owner = pthread_self(); }
+void trace_info::set_owner() { owner = (unsigned long)pthread_self(); }
 void trace_info::unset_owner() { owner = 0; }
 
 void BC_Trace::dump_locks(FILE *fp)
@@ -322,7 +322,7 @@ void BC_Trace::dump_locks(FILE *fp)
 		fprintf(fp,"    %p %s, %s %p%s",
 			p->info, p->title, p->loc,
 			(void*)p->tid, p->is_owner ? " *" : "");
-		if( p->info->owner && p->info->owner != p->tid )
+		if( p->info->owner && p->info->owner != (unsigned long)p->tid )
 			fprintf(fp," %p", (void*)p->info->owner);
 		fprintf(fp,"\n");
 	}
-- 
2.35.1

From b8d4b3231b116701b462ac6a7ff78dbec6c10895 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:30:19 +0300
Subject: [PATCH 5/9] freebsd defines in guicast/bcresources.C

---
 cinelerra-5.1/guicast/bcresources.C | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C
index cdac6305..3fa8bed1 100644
--- a/cinelerra-5.1/guicast/bcresources.C
+++ b/cinelerra-5.1/guicast/bcresources.C
@@ -39,6 +39,9 @@
 #include <iconv.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
+#if defined(__FreeBSD__)
+#include <sys/sysctl.h>
+#endif
 #include <X11/extensions/XShm.h>
 #include <fontconfig/fontconfig.h>
 #include <fontconfig/fcfreetype.h>
@@ -298,6 +301,7 @@ int BC_Resources::machine_cpus = 1;
 
 int BC_Resources::get_machine_cpus()
 {
+#if !defined(__FreeBSD__)
 	int cpus = 1;
 	FILE *proc = fopen("/proc/cpuinfo", "r");
 	if( proc ) {
@@ -315,6 +319,14 @@ int BC_Resources::get_machine_cpus()
 		fclose(proc);
 	}
 	return cpus;
+#else
+	int mib[2], ncpu;
+	size_t len = sizeof(ncpu);
+	mib[0] = CTL_HW;
+	mib[1] = HW_NCPU;
+	if( sysctl(mib, 2, &ncpu, &len, 0, 0) ) ncpu = 1;
+	return ncpu;
+#endif
 }
 
 void BC_Resources::new_vframes(int n, VFrame *vframes[], ...)
@@ -367,9 +379,13 @@ BC_Resources::BC_Resources(float x_scale, float y_scale)
 	BC_WindowBase::resources = this;
 	synchronous = 0;
 	vframe_shm = 0;
+#if !defined(__FreeBSD__)
 	use_shm = -1;
 	shm_reply = 1;
-
+#else
+	use_shm = 0;
+	shm_reply = 0;
+#endif
 	if( x_scale <= 0 ) x_scale = 1;
 	if( y_scale <= 0 ) y_scale = x_scale;
 	this->x_scale = x_scale;
-- 
2.35.1

From 7ecc5398994847668611529517ce0453d6b8f44b Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:19:55 +0300
Subject: [PATCH 3/9] realtime prio only on linux and termux for now

---
 cinelerra-5.1/guicast/thread.C | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cinelerra-5.1/guicast/thread.C b/cinelerra-5.1/guicast/thread.C
index 9908a628..edac1451 100644
--- a/cinelerra-5.1/guicast/thread.C
+++ b/cinelerra-5.1/guicast/thread.C
@@ -58,13 +58,15 @@ void* Thread::entrypoint(void *parameters)
 	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
 	thread->cancel_enabled = false;
 
+// not on bsd
+#if defined (__linux__) || defined (__TERMUX__)
 // Set realtime here since it doesn't work in start
 	if( thread->realtime && getuid() == 0 ) {
 		struct sched_param param = { sched_priority : 1 };
 		if(pthread_setschedparam(thread->tid, SCHED_RR, &param) < 0)
 			perror("Thread::entrypoint pthread_attr_setschedpolicy");
 	}
-
+#endif
 	thread->run();
 	thread->finished = true;
 	if( !thread->synchronous ) {
-- 
2.35.1

From 70e1904b4997d76ff0d21e0dc41de1c84fa73d75 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:21:11 +0300
Subject: [PATCH 4/9] freebsd includes in plugins/titler

---
 cinelerra-5.1/plugins/titler/titler.C | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cinelerra-5.1/plugins/titler/titler.C b/cinelerra-5.1/plugins/titler/titler.C
index 06fb7938..b4157811 100644
--- a/cinelerra-5.1/plugins/titler/titler.C
+++ b/cinelerra-5.1/plugins/titler/titler.C
@@ -57,8 +57,13 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
+#if defined (__linux__)
 #include <endian.h>
 #include <byteswap.h>
+#endif
+#if defined (__FreeBSD__)
+#include <sys/endian.h>
+#endif
 #include <iconv.h>
 #include <sys/stat.h>
 #include <fontconfig/fontconfig.h>
-- 
2.35.1

From cf90fece27367418b5210903234812ddf71aab89 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:45:48 +0300
Subject: [PATCH 8/9] freebsd in bdcreate/bdwrite

---
 cinelerra-5.1/cinelerra/bdcreate.C | 5 +++++
 cinelerra-5.1/cinelerra/bdwrite.C  | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/bdcreate.C b/cinelerra-5.1/cinelerra/bdcreate.C
index 13425663..6b108985 100644
--- a/cinelerra-5.1/cinelerra/bdcreate.C
+++ b/cinelerra-5.1/cinelerra/bdcreate.C
@@ -24,8 +24,13 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
+#if !defined(__FreeBSD__)
 #include <sys/stat.h>
 #include <sys/statfs.h>
+#else
+#include <sys/param.h>
+#include <sys/mount.h>
+#endif
 
 // BD Creation
 
diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
index 854ca7e7..4dd5cc37 100644
--- a/cinelerra-5.1/cinelerra/bdwrite.C
+++ b/cinelerra-5.1/cinelerra/bdwrite.C
@@ -38,7 +38,11 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#if !defined (__FreeBSD__)
 #include <endian.h>
+#else
+#include <sys/endian.h>
+#endif
 #include <limits.h>
 #include <sys/stat.h>
 // work arounds (centos)
-- 
2.35.1

From 4eeefee991971b3e48034d96b981c102903888b3 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:40:13 +0300
Subject: [PATCH 7/9] freebsd in file.C

---
 cinelerra-5.1/cinelerra/file.C | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C
index 03941d9a..33cc7e8b 100644
--- a/cinelerra-5.1/cinelerra/file.C
+++ b/cinelerra-5.1/cinelerra/file.C
@@ -1620,7 +1620,14 @@ int File::record_fd()
 void File::get_exe_path(char *result, char *bnp)
 {
 // Get executable path, basename
+#if !defined(__FreeBSD__)
 	int len = readlink("/proc/self/exe", result, BCTEXTLEN-1);
+#else
+	char exe_path[BCTEXTLEN];
+	sprintf(exe_path,"/proc/%d/file",getpid());
+	int len = readlink(exe_path, result, BCTEXTLEN-1);
+#endif
+
 	if( len >= 0 ) {
 		result[len] = 0;
 		char *ptr = strrchr(result, '/');
-- 
2.35.1

From 0ec141593cab884c66c8f3a05745e6195752637e Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:49:46 +0300
Subject: [PATCH 9/9] freebsd in dvdcreate.C

---
 cinelerra-5.1/cinelerra/dvdcreate.C | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cinelerra-5.1/cinelerra/dvdcreate.C b/cinelerra-5.1/cinelerra/dvdcreate.C
index 6ecb270b..175ef547 100644
--- a/cinelerra-5.1/cinelerra/dvdcreate.C
+++ b/cinelerra-5.1/cinelerra/dvdcreate.C
@@ -24,9 +24,13 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <errno.h>
+#if !defined(__FreeBSD__)
 #include <sys/stat.h>
 #include <sys/statfs.h>
-
+#else
+#include <sys/param.h>
+#include <sys/mount.h>
+#endif
 
 #define DVD_PAL_4x3	0
 #define DVD_PAL_16x9	1
-- 
2.35.1

From e3c42a6cca8299ef7fa76bf3b3f1db7c60942acd Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 28 Mar 2022 02:36:01 +0300
Subject: [PATCH 6/9] freebsd in indexfile.C

---
 cinelerra-5.1/cinelerra/indexfile.C | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cinelerra-5.1/cinelerra/indexfile.C b/cinelerra-5.1/cinelerra/indexfile.C
index 2e1b0c73..885495ed 100644
--- a/cinelerra-5.1/cinelerra/indexfile.C
+++ b/cinelerra-5.1/cinelerra/indexfile.C
@@ -73,6 +73,9 @@
 #ifdef HAVE_ISOFS
 #include <linux/iso_fs.h>
 #endif
+#if defined(__FreeBSD__)
+#include <isofs/cd9660/iso.h>
+#endif
 
 // check for isofs volume_id for dvd/cdrom
 
-- 
2.35.1

-- 
Cin mailing list
[email protected]
https://lists.cinelerra-gg.org/mailman/listinfo/cin

Reply via email to