Tuna 0.4.3 now w/OSX support

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Tuna 0.4.3 now w/OSX support

curt-2
Well, removed the call that was causing the problems anyway, don't
actually have an OSX platform to test on so I don't know how well/if it
works yet.

Tried to add ARM support but I can't code assembly blind, I need a
platform to iterate on or there is no hope, any way I can score a cheap one?

What is it? Tuna is a multi-threaded API that allows task-switching at
the c/c++ level. It is designed specifically to make the penalty of
running many [many] tasks very small by using actual deep-magic stack
manipulation. It supports multi-tasking both in cooperative and
preemptive models, and can be used identically from either the c-api or
lua side (including yielding)

http://northarc.com/tuna

-Curt

Reply | Threaded
Open this post in threaded view
|

Re: Tuna 0.4.3 now w/OSX support

Luiz Henrique de Figueiredo
> don't actually have an OSX platform to test on so I don't know how
> well/if it works yet.

It does not work for me (Lion):

$ make
g++ -O2 -Werror -Wall -MD -Isrc -c -o  objs/tuna.o src/tuna.cpp
src/tuna.cpp:27: error: thread-local storage not supported for this target

Do I have to do something special to compile under OSX?

Reply | Threaded
Open this post in threaded view
|

Re: Tuna 0.4.3 now w/OSX support

Glenn Schmottlach
In reply to this post by curt-2


Tried to add ARM support but I can't code assembly blind, I need a platform to iterate on or there is no hope, any way I can score a cheap one?


Depends on what you consider cheap. You can get a BeagleBoard or Freescale i.MX5/6  for ~$150 USD. Of course there is a Raspberry Pi board for about $35 USD (if they are not sold out). Plus, there are several Chinese USB-stick style platforms for ~$60 USD. I've only had experience with the BeagleBoard and Freescale parts but the others would probably suit your purposes as well.

Finally, if you have a jail-broken Android phone you could probably use that with the NDK.

Just a thought . . .


Reply | Threaded
Open this post in threaded view
|

Re: Tuna 0.4.3 now w/OSX support

Michal Kottman
In reply to this post by Luiz Henrique de Figueiredo
On 12 June 2012 22:13, Luiz Henrique de Figueiredo
<[hidden email]> wrote:

>> don't actually have an OSX platform to test on so I don't know how
>> well/if it works yet.
>
> It does not work for me (Lion):
>
> $ make
> g++ -O2 -Werror -Wall -MD -Isrc -c -o  objs/tuna.o src/tuna.cpp
> src/tuna.cpp:27: error: thread-local storage not supported for this target
>
> Do I have to do something special to compile under OSX?

I have managed to get the 'tuna.so' module compiled on Mac OS X. I had
to change the compiler to clang++, add a -pthread flag and
remove/rename mmap constants to match the Mac API [1]. Note that I did
not test it yet, I am trying to get the examples compiled too...

[1] https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/mmap.2.html

Here is a diff of what I had to do to get it compiled (this would have
to be adapted to suit both Linux and Mac):

diff -ur tuna-0.4.3/Makefile tuna-mac/Makefile
--- tuna-0.4.3/Makefile 2012-06-12 14:26:44.000000000 +0200
+++ tuna-mac/Makefile 2012-06-12 22:37:14.000000000 +0200
@@ -4,8 +4,8 @@

 OPT = -O2

-CC = g++ $(OPT) -Werror -Wall -MD -Isrc -c -o
-LCC = g++ -fpic $(OPT) -Werror -Wall -MD -Isrc -c -o
+CC = clang++ $(OPT) -Werror -Wall -MD -Isrc -c -pthread -o
+LCC = clang++ -fpic $(OPT) -Werror -Wall -MD -Isrc -c -pthread -o

 #LIBTOOL=libtool --tag=CXX

@@ -24,7 +24,7 @@
  @touch Makefile_deps.m

 tuna.so: $(LOBJS)
- g++ -shared -Wl,-soname,libtuna.so.1 -o tuna.so -lc $(LOBJS) $(LIBS)
+ g++ -bundle -undefined dynamic_lookup -o tuna.so -lc $(LOBJS) $(LIBS)
  @cp tuna.so examples
  @find . -name "*.d" -exec mv {} deps \; 2>/dev/null
 
diff -ur tuna-0.4.3/src/linux_drv.cpp tuna-mac/src/linux_drv.cpp
--- tuna-0.4.3/src/linux_drv.cpp 2012-06-12 14:26:46.000000000 +0200
+++ tuna-mac/src/linux_drv.cpp 2012-06-12 22:34:24.000000000 +0200
@@ -6,7 +6,12 @@
 #include <sys/time.h>
 #include <pthread.h>
 #include <sys/mman.h>
-#include <malloc.h>
+//#include <malloc.h>
+#include <sys/mman.h>
+#ifndef MAP_ANONYMOUS
+# define MAP_ANONYMOUS MAP_ANON
+#endif
+
 #include <errno.h>

 namespace Tuna
@@ -61,7 +66,7 @@
 {
  MLockScoped m(s_mmaplock);
  // grab some memory suitable for use as a stack
- char *ret = (char *)mmap( 0, minSize + sizeof(int),
PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_STACK|MAP_PRIVATE, -1, 0 );
+ char *ret = (char *)mmap( 0, minSize + sizeof(int),
PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0 );
  // embed the alloc size and shift the returned pointer forward sizoef(int)
  *(int*)ret = minSize + sizeof(int); // embed the size
  return ret + sizeof(int);

Reply | Threaded
Open this post in threaded view
|

Re: Tuna 0.4.3 now w/OSX support

Javier Guerra Giraldez
In reply to this post by Glenn Schmottlach
On Tue, Jun 12, 2012 at 3:34 PM, Glenn Schmottlach
<[hidden email]> wrote:
> Finally, if you have a jail-broken Android phone you could probably use that
> with the NDK.

no jail to break, right in the settings there's a "developer mode"
that allows you to upload code directly from the SDK

and of course, there's qemu to run ARM code in your own PC

--
Javier

Reply | Threaded
Open this post in threaded view
|

Re: Tuna 0.4.3 now w/OSX support

Glenn Schmottlach
Doh!

You're right. No need for real HW to test an ARM port. QEMU would do the trick and there are several ways to create a pseudo ARM target system to run on your Linux box. I'm not an Android developer so there may be an easier path that way. Alternatively, you can create a full-blown Linux ARM SDK/tool-chain and development environment using stuff from the Yocto Project (http://www.yoctoproject.org/). I've built a complete cross-compile tool-chain there and used GDB to single-step through an ARM application running under a QEMU target system. So it's entirely possible . . . with little expense except for your time.

On Tue, Jun 12, 2012 at 4:43 PM, Javier Guerra Giraldez <[hidden email]> wrote:
On Tue, Jun 12, 2012 at 3:34 PM, Glenn Schmottlach
<[hidden email]> wrote:
> Finally, if you have a jail-broken Android phone you could probably use that
> with the NDK.

no jail to break, right in the settings there's a "developer mode"
that allows you to upload code directly from the SDK

and of course, there's qemu to run ARM code in your own PC

--
Javier


Reply | Threaded
Open this post in threaded view
|

Re: Tuna 0.4.3 now w/OSX support

Carol Hurwitz
In reply to this post by curt-2
Can anyone tell me how to unsubscribe? 
Thank you.

Carol

On Tue, Jun 12, 2012 at 11:41 AM, curt <[hidden email]> wrote:
Well, removed the call that was causing the problems anyway, don't actually have an OSX platform to test on so I don't know how well/if it works yet.

Tried to add ARM support but I can't code assembly blind, I need a platform to iterate on or there is no hope, any way I can score a cheap one?

What is it? Tuna is a multi-threaded API that allows task-switching at the c/c++ level. It is designed specifically to make the penalty of running many [many] tasks very small by using actual deep-magic stack manipulation. It supports multi-tasking both in cooperative and preemptive models, and can be used identically from either the c-api or lua side (including yielding)

http://northarc.com/tuna

-Curt




--
Carol M. Hurwitz, Ph.D.
Department Chair
Mathematics and Computer Science
Associate Professor

Riverdale, NY 10471
Phone: 718-862-7253 (Sec'y: Fanny)

Reply | Threaded
Open this post in threaded view
|

Re: Tuna 0.4.3 now w/OSX support

Luiz Henrique de Figueiredo
> Can anyone tell me how to unsubscribe?

See http://www.lua.org/lua-l.html

Reply | Threaded
Open this post in threaded view
|

Re: Tuna 0.4.3 now w/OSX support

curt-2
In reply to this post by Michal Kottman
On 6/12/2012 4:43 PM, Michal Kottman wrote:

> On 12 June 2012 22:13, Luiz Henrique de Figueiredo
> <[hidden email]>  wrote:
>>> don't actually have an OSX platform to test on so I don't know how
>>> well/if it works yet.
>> It does not work for me (Lion):
>>
>> $ make
>> g++ -O2 -Werror -Wall -MD -Isrc -c -o  objs/tuna.o src/tuna.cpp
>> src/tuna.cpp:27: error: thread-local storage not supported for this target
>>
>> Do I have to do something special to compile under OSX?
> I have managed to get the 'tuna.so' module compiled on Mac OS X. I had
> to change the compiler to clang++, add a -pthread flag and
> remove/rename mmap constants to match the Mac API [1]. Note that I did
> not test it yet, I am trying to get the examples compiled too...
>
> [1] https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man2/mmap.2.html
>
> Here is a diff of what I had to do to get it compiled (this would have
> to be adapted to suit both Linux and Mac):

Thank you very much. I have an OSX platform at work I can use to test
on, I never planned on supporting it but certainly no reason it
shouldn't work.

-Curt