Re: [Tinycc-devel] [PATCH] improving solaris/illumos support

2022-02-28 Thread David CARLIER
> Hello David,

> Funny, I considered to try this port last year, unfortunately my Solaris VM is
> broken I only have true Solaris 10 sparc machines (with of course No chances 
> it
> works on a sparc CPU).

> What is the status of Solaris port after this patch?

It is the initial step for proper support. It would take further steps
to fix tests (e.g. no support for some linkers features, etc)

 thus simplify the reviews.

> Does it works, I think you have some ELF reloc issues (a big classic for a new
> port), do you?

> You missed the correct values for:
> #elif defined(__sun)
> +#define BOUND_TID_TYPE   pid_t
> +#define BOUND_GET_TIDsyscall (SYS_)


True but I did not port bound check, anyway there is no equivalent for
gettid, part the classic pthread_self/getpid.

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] [PATCH] improving solaris/illumos support

2022-02-20 Thread David CARLIER
Hi, here a patch to add this platform as a new target.
From 38196801851fa941258360e5786d1ed45078d2fd Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Sun, 20 Feb 2022 18:57:58 +
Subject: [PATCH] illumos/solaris improving support

---
 Makefile   |  3 +++
 configure  | 19 +++
 conftest.c |  1 +
 tcc.c  |  2 ++
 tcc.h  |  3 +++
 tccpp.c|  2 ++
 tccrun.c   |  8 ++--
 tests/Makefile |  2 ++
 8 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 9216b0d..9041808 100644
--- a/Makefile
+++ b/Makefile
@@ -90,6 +90,7 @@ NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP
 NATIVE_DEFINES_$(CONFIG_arm64) += -DTCC_TARGET_ARM64
 NATIVE_DEFINES_$(CONFIG_riscv64) += -DTCC_TARGET_RISCV64
 NATIVE_DEFINES_$(CONFIG_BSD) += -DTARGETOS_$(TARGETOS)
+NATIVE_DEFINES_$(CONFIG_SunOS) += -DTARGETOS_$(TARGETOS)
 NATIVE_DEFINES_$(CONFIG_pie) += -DCONFIG_TCC_PIE
 NATIVE_DEFINES_no_$(CONFIG_bcheck) += -DCONFIG_TCC_BCHECK=0
 NATIVE_DEFINES_no_$(CONFIG_backtrace) += -DCONFIG_TCC_BACKTRACE=0
@@ -98,6 +99,7 @@ NATIVE_DEFINES += $(NATIVE_DEFINES_yes) $(NATIVE_DEFINES_no_no)
 DEF-i386   = -DTCC_TARGET_I386
 DEF-i386-win32 = -DTCC_TARGET_I386 -DTCC_TARGET_PE
 DEF-i386-OpenBSD   = $(DEF-i386) -DTARGETOS_OpenBSD
+DEF-i386-SunOS = $(DEF-i386) -DTARGETOS_SunOS
 DEF-x86_64 = -DTCC_TARGET_X86_64
 DEF-x86_64-win32   = -DTCC_TARGET_X86_64 -DTCC_TARGET_PE
 DEF-x86_64-osx = -DTCC_TARGET_X86_64 -DTCC_TARGET_MACHO
@@ -119,6 +121,7 @@ DEF-c67= -DTCC_TARGET_C67 -w # disable warnigs
 DEF-x86_64-FreeBSD = $(DEF-x86_64) -DTARGETOS_FreeBSD
 DEF-x86_64-NetBSD  = $(DEF-x86_64) -DTARGETOS_NetBSD
 DEF-x86_64-OpenBSD = $(DEF-x86_64) -DTARGETOS_OpenBSD
+DEF-x86_64-SunOS   = $(DEF-x86_64) -DTARGETOS_SunOS
 
 DEF-$(NATIVE_TARGET) = $(NATIVE_DEFINES)
 
diff --git a/configure b/configure
index f05b700..f34f89a 100755
--- a/configure
+++ b/configure
@@ -71,6 +71,9 @@ case $targetos in
   DragonFly|OpenBSD|FreeBSD|NetBSD)
 confvars="$confvars BSD ldl=no"
 ;;
+  SunOS)
+confvars="$confvars SunOS"
+;;
   *)
 ;;
 esac
@@ -463,20 +466,20 @@ DLLSUF=$DLLSUF
 EOF
 
 print_inc() {
-  local v="$2"
-  if test -n "$v"; then
-test "$3" = "num" || v="\"$v\""
+  vinc="$2"
+  if test -n "$vinc"; then
+test "$3" = "num" || vinc="\"$vinc\""
 echo "#ifndef $1" >> $TMPH
-echo "# define $1 $v" >> $TMPH
+echo "# define $1 $vinc" >> $TMPH
 echo "#endif" >> $TMPH
   fi
 }
 
 print_mak() {
-  local v="$2"
-  if test -n "$v"; then
-test "$3" = "num" || v="\"\\\"$v\\\"\""
-echo "NATIVE_DEFINES+=-D$1=$v" >> config.mak
+  vmak="$2"
+  if test -n "$vmak"; then
+test "$3" = "num" || vmak="\"\\\"$vmak\\\"\""
+echo "NATIVE_DEFINES+=-D$1=$vmak" >> config.mak
   fi
 }
 
diff --git a/conftest.c b/conftest.c
index e8e1220..66181a0 100644
--- a/conftest.c
+++ b/conftest.c
@@ -20,6 +20,7 @@ const char *platform_macros[] = {
 "__FreeBSD_kernel__",   "TARGETOS_FreeBSD_kernel",
 "__OpenBSD__",  "TARGETOS_OpenBSD",
 "__NetBSD__",   "TARGETOS_NetBSD",
+"__sun","TARGETOS_SunOS",
 "__linux__","TARGETOS_Linux",
 "__SIZEOF_POINTER__",   "PTR_SIZE",
 "__SIZEOF_LONG__",  "LONG_SIZE",
diff --git a/tcc.c b/tcc.c
index 42a251b..d60dc0b 100644
--- a/tcc.c
+++ b/tcc.c
@@ -185,6 +185,8 @@ static const char version[] =
 " OpenBSD"
 #elif TARGETOS_NetBSD
 " NetBSD"
+#elif TARGETOS_SunOS
+" Solaris"
 #else
 " Linux"
 #endif
diff --git a/tcc.h b/tcc.h
index ef69ef5..db18f6f 100644
--- a/tcc.h
+++ b/tcc.h
@@ -23,6 +23,7 @@
 
 #define _GNU_SOURCE
 #define _DARWIN_C_SOURCE
+#define __EXTENSIONS__
 #include "config.h"
 
 #include 
@@ -307,6 +308,8 @@ extern long double strtold (const char *__nptr, char **__endptr);
 #  define CONFIG_TCC_ELFINTERP "/usr/libexec/ld.elf_so"
 # elif TARGETOS_OpenBSD
 #  define CONFIG_TCC_ELFINTERP "/usr/libexec/ld.so"
+# elif TARGETOS_SunOS
+#  define CONFIG_TCC_ELFINTERP "/usr/lib/ld.so.1"
 # elif defined __GNU__
 #  define CONFIG_TCC_ELFINTERP "/lib/ld.so"
 # elif defined(TCC_TARGET_PE)
diff --git a/tccpp.c b/tccpp.c
index 6b828c9..6299751 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -3694,6 +3694,8 @@ static const char * const target_os_defs =
 "__NetBSD__\0"
 # elif TARGETOS_OpenBSD
 

[Tinycc-devel] Fwd: [PATCH] freebsd support update proposal

2022-02-02 Thread David CARLIER
Hi if nobody objects, I may apply the last aforementioned patch
sometime next week.

Kind regards.
-- Forwarded message -
From: David CARLIER 
Date: Sun, 30 Jan 2022 at 18:35
Subject: Re: [PATCH] freebsd support update proposal
To: 


> new version considering feedbacks. Cheers.

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] [PATCH] freebsd support update proposal

2022-01-30 Thread David CARLIER
new version considering feedbacks. Cheers.

On Sun, 30 Jan 2022 at 13:43, David CARLIER  wrote:
>
> Hi here a revised version.
>
> Cheers.
>
> On Sat, 29 Jan 2022 at 17:38, David CARLIER  wrote:
> >
> > fair enough. thanks.
> >
> > On Sat, 29 Jan 2022 at 17:09, David CARLIER  wrote:
> > >
> > > Hi and thanks here a new version of the patchset.
> > >
> > > On Sat, 29 Jan 2022 at 00:18, David CARLIER  wrote:
> > > >
> > > > adding few constants for compile time and fetching thread id for bound 
> > > > check.


0001-freebsd-support-update.patch
Description: Binary data
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] [PATCH] freebsd support update proposal

2022-01-30 Thread David CARLIER
Hi here a revised version.

Cheers.

On Sat, 29 Jan 2022 at 17:38, David CARLIER  wrote:
>
> fair enough. thanks.
>
> On Sat, 29 Jan 2022 at 17:09, David CARLIER  wrote:
> >
> > Hi and thanks here a new version of the patchset.
> >
> > On Sat, 29 Jan 2022 at 00:18, David CARLIER  wrote:
> > >
> > > adding few constants for compile time and fetching thread id for bound 
> > > check.


0001-freebsd-support-update.patch
Description: Binary data
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] [PATCH] freebsd support update proposal

2022-01-29 Thread David CARLIER
fair enough. thanks.

On Sat, 29 Jan 2022 at 17:09, David CARLIER  wrote:
>
> Hi and thanks here a new version of the patchset.
>
> On Sat, 29 Jan 2022 at 00:18, David CARLIER  wrote:
> >
> > adding few constants for compile time and fetching thread id for bound 
> > check.


0001-freebsd-support-update.patch
Description: Binary data
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] [PATCH] freebsd support update proposal

2022-01-29 Thread David CARLIER
Hi and thanks here a new version of the patchset.

On Sat, 29 Jan 2022 at 00:18, David CARLIER  wrote:
>
> adding few constants for compile time and fetching thread id for bound check.


0001-freebsd-support-update.patch
Description: Binary data
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] [PATCH] freebsd support update proposal

2022-01-28 Thread David CARLIER
adding few constants for compile time and fetching thread id for bound check.


0001-freebsd-support-update.patch
Description: Binary data
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal

2020-11-26 Thread David CARLIER
Here a modified version of the patch, tested on OpenBSD (stable),
FreeBSD and DragonFly.

On Thu, 26 Nov 2020 at 16:15, David CARLIER  wrote:
>
> Are they with / without the fix ? Because normally the changes would
> address those I saw them too.
>
> On Thu, 26 Nov 2020 at 16:14, Christian Jullien  wrote:
> >
> > Same result, also NetBSD still fails with:
> >
> > -bash-5.0$ ./configure
> > Binary directory/usr/local/bin
> > TinyCC directory/usr/local/lib/tcc
> > Library directory   /usr/local/lib
> > Include directory   /usr/local/include
> > Manual directory/usr/local/share/man
> > Info directory  /usr/local/share/info
> > Doc directory   /usr/local/share/doc
> > Source path /home/jullien/tinycc
> > C compiler  gcc (7.4)
> > Target OS   NetBSD
> > CPU x86_64
> > Config  ldl=no
> > Creating config.mak and config.h
> > config.h is unchanged
> > -bash-5.0$ gmake
> > gmake[1]: Entering directory '/home/jullien/tinycc/lib'
> > ../tcc -c bt-exe.c -o ../bt-exe.o -B.. -I..
> > In file included from bt-exe.c:6:
> > In file included from ../tccrun.c:21:
> > In file included from ../tcc.h:29:
> > In file included from /usr/include/stdlib.h:37:
> > /usr/include/sys/cdefs.h:441: error: #error "No function renaming possible"
> > gmake[1]: *** [Makefile:83: ../bt-exe.o] Error 1
> > gmake[1]: Leaving directory '/home/jullien/tinycc/lib'
> > gmake: *** [Makefile:269: libtcc1.a] Error 2
> >
> >
> > -Original Message-
> > From: Tinycc-devel 
> > [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of 
> > Sudipto Mallick
> > Sent: Thursday, November 26, 2020 16:50
> > To: tinycc-devel@nongnu.org
> > Subject: Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal
> >
> > Great achievement
> >
> > On OpenBSD x86_64, applied your patch and tried to compile, to get an
> > error that ucontext_t doesn't have uc_rbp as a member; i think that
> > was a typo and would be: sc_rbp. fixing that, it compiled smoothly
> > tried to compile a c file using this newly built tcc fails with crt0.o
> > etc. not found error :(
> >
> > ~smlckz
> >
> > ___
> > Tinycc-devel mailing list
> > Tinycc-devel@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
> >
> >
> > ___
> > Tinycc-devel mailing list
> > Tinycc-devel@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
From fd91cd9a46528c3efeb7fe44014763cdf6eecf2a Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Thu, 26 Nov 2020 16:27:33 +
Subject: [PATCH] BSD systems build fixes.

---
 lib/bcheck.c |  8 
 libtcc.c |  6 +-
 tcc.h| 11 +++
 tccrun.c |  3 +++
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/lib/bcheck.c b/lib/bcheck.c
index 06c5b60..0fa84ef 100644
--- a/lib/bcheck.c
+++ b/lib/bcheck.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if !defined(__FreeBSD__) \
  && !defined(__FreeBSD_kernel__) \
@@ -65,6 +66,7 @@
  || defined(__NetBSD__) \
  || defined(__dietlibc__)
 
+#include 
 #define INIT_SEM()
 #define EXIT_SEM()
 #define WAIT_SEM()
@@ -220,9 +222,15 @@ typedef struct alloca_list_struct {
 #define BOUND_TID_TYPE   DWORD
 #define BOUND_GET_TIDGetCurrentThreadId()
 #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__riscv)
+#if defined(__linux__)
 #define BOUND_TID_TYPE   pid_t
 #define BOUND_GET_TIDsyscall (SYS_gettid)
 #else
+// Note: each platform has its own thread id api, pthread_self might suffice for starter
+#define BOUND_TID_TYPE   int64_t
+#define BOUND_GET_TID(int64_t)(pthread_self())
+#endif
+#else
 #define BOUND_TID_TYPE   int
 #define BOUND_GET_TID0
 #endif
diff --git a/libtcc.c b/libtcc.c
index 3698632..f7e364f 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -894,6 +894,9 @@ LIBTCCAPI TCCState *tcc_new(void)
 # if defined(__OpenBSD__)
 tcc_define_symbol(s, "__OpenBSD__", "__OpenBSD__");
 # endif
+# if defined(__DragonFly__)
+tcc_define_symbol(s, "__DragonFly__", "__DragonFly__");
+# endif
 #endif
 
 /* TinyCC & gcc defines */
@@ -926,11 +929,12 @@ LIBTCCAPI TCCState *tcc_new(void)
 # if defined(__FreeBSD__) || defined (__FreeBSD_kernel__) \
   || defined(__NetBSD__) || defined(__OpenBSD__)
 tcc_define_symbol(s, "__WINT_TYPE__", "int");
-#  ifdef __FreeBSD__
+#  if defined(__FreeBSD__) || defined(__NetBSD__)
 /* define __GNUC__ to

Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal

2020-11-26 Thread David CARLIER
Are they with / without the fix ? Because normally the changes would
address those I saw them too.

On Thu, 26 Nov 2020 at 16:14, Christian Jullien  wrote:
>
> Same result, also NetBSD still fails with:
>
> -bash-5.0$ ./configure
> Binary directory/usr/local/bin
> TinyCC directory/usr/local/lib/tcc
> Library directory   /usr/local/lib
> Include directory   /usr/local/include
> Manual directory/usr/local/share/man
> Info directory  /usr/local/share/info
> Doc directory   /usr/local/share/doc
> Source path /home/jullien/tinycc
> C compiler  gcc (7.4)
> Target OS   NetBSD
> CPU x86_64
> Config  ldl=no
> Creating config.mak and config.h
> config.h is unchanged
> -bash-5.0$ gmake
> gmake[1]: Entering directory '/home/jullien/tinycc/lib'
> ../tcc -c bt-exe.c -o ../bt-exe.o -B.. -I..
> In file included from bt-exe.c:6:
> In file included from ../tccrun.c:21:
> In file included from ../tcc.h:29:
> In file included from /usr/include/stdlib.h:37:
> /usr/include/sys/cdefs.h:441: error: #error "No function renaming possible"
> gmake[1]: *** [Makefile:83: ../bt-exe.o] Error 1
> gmake[1]: Leaving directory '/home/jullien/tinycc/lib'
> gmake: *** [Makefile:269: libtcc1.a] Error 2
>
>
> -Original Message-
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] 
> On Behalf Of Sudipto Mallick
> Sent: Thursday, November 26, 2020 16:50
> To: tinycc-devel@nongnu.org
> Subject: Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal
>
> Great achievement
>
> On OpenBSD x86_64, applied your patch and tried to compile, to get an
> error that ucontext_t doesn't have uc_rbp as a member; i think that
> was a typo and would be: sc_rbp. fixing that, it compiled smoothly
> tried to compile a c file using this newly built tcc fails with crt0.o
> etc. not found error :(
>
> ~smlckz
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal

2020-11-26 Thread David CARLIER
Hi,

here my first contribution, hope it is useful.

Kind regards.
From d4ad25cefb7c18975c853dc43390108228f95e68 Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Thu, 26 Nov 2020 11:26:41 +
Subject: [PATCH] DragonFlyBSD build fix.

generates proper system constant.
errno uses TLS thus tccrun build breaks.
SYS_gettid is Linux specific, using pthread_self for simplicity.
---
 lib/bcheck.c | 6 ++
 libtcc.c | 3 +++
 tcc.h| 8 
 3 files changed, 17 insertions(+)

diff --git a/lib/bcheck.c b/lib/bcheck.c
index 06c5b60..5bbab47 100644
--- a/lib/bcheck.c
+++ b/lib/bcheck.c
@@ -220,9 +220,15 @@ typedef struct alloca_list_struct {
 #define BOUND_TID_TYPE   DWORD
 #define BOUND_GET_TIDGetCurrentThreadId()
 #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__riscv)
+#if defined(__linux__)
 #define BOUND_TID_TYPE   pid_t
 #define BOUND_GET_TIDsyscall (SYS_gettid)
 #else
+// Note: each platform has its own thread id api, pthread_self might suffice for starter
+#define BOUND_TID_TYPE   int64_t
+#define BOUND_GET_TID(int64_t)(pthread_self())
+#endif
+#else
 #define BOUND_TID_TYPE   int
 #define BOUND_GET_TID0
 #endif
diff --git a/libtcc.c b/libtcc.c
index 3698632..454b566 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -894,6 +894,9 @@ LIBTCCAPI TCCState *tcc_new(void)
 # if defined(__OpenBSD__)
 tcc_define_symbol(s, "__OpenBSD__", "__OpenBSD__");
 # endif
+# if defined(__DragonFly__)
+tcc_define_symbol(s, "__DragonFly__", "__DragonFly__");
+# endif
 #endif
 
 /* TinyCC & gcc defines */
diff --git a/tcc.h b/tcc.h
index 3c130ec..3c6ef2e 100644
--- a/tcc.h
+++ b/tcc.h
@@ -25,6 +25,11 @@
 #define _DARWIN_C_SOURCE
 #include "config.h"
 
+#ifdef __TINYC__
+// errno uses TLS unlike FreeBSD
+#define __thread
+#endif
+
 #include 
 #include 
 #include 
@@ -45,6 +50,9 @@
 /* XXX: need to define this to use them in non ISOC99 context */
 extern float strtof (const char *__nptr, char **__endptr);
 extern long double strtold (const char *__nptr, char **__endptr);
+# ifdef __DragonFly__
+extern char **environ;
+# endif
 #endif
 
 #ifdef _WIN32
-- 
2.28.0

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal

2020-11-26 Thread David CARLIER
Ok I ve tried to test these changes under BSD systems, to make it
accepted by the system headers and all.

Kind regards.

On Thu, 26 Nov 2020 at 13:46, Christian Jullien  wrote:
>
> Yes, it would be fine.
> I have direct access to FreeBSD, NetBSD and OpenBSD x64 machines this way I 
> can check myself.
>
>
> -Original Message-
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] 
> On Behalf Of David CARLIER
> Sent: Thursday, November 26, 2020 14:43
> To: jull...@eligis.com; tinycc-devel@nongnu.org
> Subject: Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal
>
> I just tried quickly FreeBSD, it fails for similar reasons than
> DragonFlyBSD minus the TLS one. I purposely focus only on DragonFlyBSD
> to make review easier do you prefer however an overall fix ?
>
> On Thu, 26 Nov 2020 at 13:38, Christian Jullien  wrote:
> >
> > It's really cool then, have you recently tried other BSD flavors: FreeBSD, 
> > OpenBSD and NetBSD?
> > I made few attempts in the past.
> >
> > -Original Message-
> > From: Tinycc-devel 
> > [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of 
> > David CARLIER
> > Sent: Thursday, November 26, 2020 14:18
> > To: jull...@eligis.com; tinycc-devel@nongnu.org
> > Subject: Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal
> >
> > It works I was able to compile few programs with, tests fail in same
> > way as on Linux (current mob branch).
> >
> > On Thu, 26 Nov 2020 at 12:59, Christian Jullien  wrote:
> > >
> > > Thanks but are sure it really works passing all the tests?
> > > Few years ago I tried different BSD versions and, for one reason or 
> > > another, they all failed.
> > >
> > > -Original Message-
> > > From: Tinycc-devel 
> > > [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of 
> > > David CARLIER
> > > Sent: Thursday, November 26, 2020 13:53
> > > To: tinycc-devel@nongnu.org
> > > Subject: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal
> > >
> > > Hi,
> > >
> > > here my first contribution, hope it is useful.
> > >
> > > Kind regards.
> > >
> > >
> > > ___
> > > Tinycc-devel mailing list
> > > Tinycc-devel@nongnu.org
> > > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
> >
> > ___
> > Tinycc-devel mailing list
> > Tinycc-devel@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
> >
> >
> > ___
> > Tinycc-devel mailing list
> > Tinycc-devel@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
From 8f08071e683fbdd915af88fcd7d583364450ea93 Mon Sep 17 00:00:00 2001
From: David Carlier 
Date: Thu, 26 Nov 2020 11:26:41 +
Subject: [PATCH] BSD systems build fix.

generates proper DragonFlyBSD system constant.
errno uses TLS for DragonFlyBSD thus tccrun build breaks.
SYS_gettid is Linux specific, using pthread_self for simplicity.
---
 lib/bcheck.c |  7 +++
 libtcc.c |  6 +-
 tcc.h| 11 +++
 tccrun.c |  3 +++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/lib/bcheck.c b/lib/bcheck.c
index 06c5b60..df5d0c1 100644
--- a/lib/bcheck.c
+++ b/lib/bcheck.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #if !defined(__FreeBSD__) \
  && !defined(__FreeBSD_kernel__) \
@@ -220,9 +221,15 @@ typedef struct alloca_list_struct {
 #define BOUND_TID_TYPE   DWORD
 #define BOUND_GET_TIDGetCurrentThreadId()
 #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__riscv)
+#if defined(__linux__)
 #define BOUND_TID_TYPE   pid_t
 #define BOUND_GET_TIDsyscall (SYS_gettid)
 #else
+// Note: each platform has its own thread id api, pthread_self might suffice for starter
+#define BOUND_TID_TYPE   int64_t
+#define BOUND_GET_TID(int64_t)(pthread_self())
+#endif
+#else
 #define BOUND_TID_TYPE   int
 #define BOUND_GET_TID0
 #endif
diff --git a/libtcc.c b/libtcc.c
index 3698632..f7e364f 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -894,6 +894,9 @@ LIBTCCAPI TCCState *tcc_new(void)
 # if defined(__OpenBSD__)
 

Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal

2020-11-26 Thread David CARLIER
I just tried quickly FreeBSD, it fails for similar reasons than
DragonFlyBSD minus the TLS one. I purposely focus only on DragonFlyBSD
to make review easier do you prefer however an overall fix ?

On Thu, 26 Nov 2020 at 13:38, Christian Jullien  wrote:
>
> It's really cool then, have you recently tried other BSD flavors: FreeBSD, 
> OpenBSD and NetBSD?
> I made few attempts in the past.
>
> -Original Message-
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] 
> On Behalf Of David CARLIER
> Sent: Thursday, November 26, 2020 14:18
> To: jull...@eligis.com; tinycc-devel@nongnu.org
> Subject: Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal
>
> It works I was able to compile few programs with, tests fail in same
> way as on Linux (current mob branch).
>
> On Thu, 26 Nov 2020 at 12:59, Christian Jullien  wrote:
> >
> > Thanks but are sure it really works passing all the tests?
> > Few years ago I tried different BSD versions and, for one reason or 
> > another, they all failed.
> >
> > -Original Message-
> > From: Tinycc-devel 
> > [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of 
> > David CARLIER
> > Sent: Thursday, November 26, 2020 13:53
> > To: tinycc-devel@nongnu.org
> > Subject: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal
> >
> > Hi,
> >
> > here my first contribution, hope it is useful.
> >
> > Kind regards.
> >
> >
> > ___
> > Tinycc-devel mailing list
> > Tinycc-devel@nongnu.org
> > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal

2020-11-26 Thread David CARLIER
It works I was able to compile few programs with, tests fail in same
way as on Linux (current mob branch).

On Thu, 26 Nov 2020 at 12:59, Christian Jullien  wrote:
>
> Thanks but are sure it really works passing all the tests?
> Few years ago I tried different BSD versions and, for one reason or another, 
> they all failed.
>
> -Original Message-
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] 
> On Behalf Of David CARLIER
> Sent: Thursday, November 26, 2020 13:53
> To: tinycc-devel@nongnu.org
> Subject: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal
>
> Hi,
>
> here my first contribution, hope it is useful.
>
> Kind regards.
>
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal

2020-11-26 Thread David CARLIER
Hi,

here my first contribution, hope it is useful.

Kind regards.


0001-DragonFlyBSD-build-fix.patch
Description: Binary data
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel