Juce on amd64 X2

you know jack support would solve this problem, and would get it working across platforms very easily…

sorry, I meant that jack support would take care of the audio device not showing up. Did you add the patches that you posted to the later versions of juce?

Jack is on my to-do-list…

And yes, all the patches I’ve mentioned on here went into the release.

JACK JACK JACK !!!
JUCE-AUDIO-CUNNINGLY-KICKINGASS :wink:

Hi, googled this implementation of atomic operation:
http://lists.helixcommunity.org/pipermail/helix-server-dev/2004-July/002703.html

See following patch for JUCE integration:
http://pastebin.com/826825

And following test case for validation:
http://pastebin.com/826829

The patch also ‘#ifndef JUCE_64BIT’ SSE specific code in juce_LowLevelGraphicsSoftwareRenderer.cpp

with these modifications jucedemo 1.39 run fine on ubuntu amd64.

Hope this help :slight_smile:

Thanks a lot! That looks pretty sensible, though I can’t test it myself. Anyone else tried it?

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 46991289978016 (LWP 11110)]
0x00000000005624ca in juce::atomicIncrementAndReturn (variable=@0x7fffa9a14e4c) at juce_Atomic.h:83
83             int result;
(gdb) bt 100
#0  0x00000000005624ca in juce::atomicIncrementAndReturn (variable=@0x7fffa9a14e4c) at juce_Atomic.h:83
#1  0x000000000056239e in juce::initialiseJuce_NonGUI () at juce_SystemStats.cpp:64
#2  0x000000000044140e in juce::initialiseJuce_GUI () at juce_Application.cpp:310
#3  0x0000000000441746 in juce::JUCEApplication::main (commandLine=@0x7fffa9a14fe0, app=0x785a30) at juce_Application.cpp:178
#4  0x0000000000441d54 in juce::JUCEApplication::main (argc=1, argv=0x7fffa9a15138, newApp=0x785a30) at juce_Application.cpp:296
#5  0x0000000000407d7f in main (argc=1, argv=0x7fffa9a15138) at ApplicationStartup.cpp:169
(gdb) 

What a crazy place to crash…

Ok, I really have no idea what’s going on here.

There are some commented-out lines in the file that use gcc built-in functions to do the operations instead of asm - I think I commented them out because they’re only available in certain gcc versions, but maybe that’d work on yours?

[quote=“patrickkidd”] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 46991289978016 (LWP 11110)] 0x00000000005624ca in juce::atomicIncrementAndReturn (variable=@0x7fffa9a14e4c) at juce_Atomic.h:83 83 int result; (gdb) bt 100 #0 0x00000000005624ca in juce::atomicIncrementAndReturn (variable=@0x7fffa9a14e4c) at juce_Atomic.h:83 #1 0x000000000056239e in juce::initialiseJuce_NonGUI () at juce_SystemStats.cpp:64 #2 0x000000000044140e in juce::initialiseJuce_GUI () at juce_Application.cpp:310 #3 0x0000000000441746 in juce::JUCEApplication::main (commandLine=@0x7fffa9a14fe0, app=0x785a30) at juce_Application.cpp:178 #4 0x0000000000441d54 in juce::JUCEApplication::main (argc=1, argv=0x7fffa9a15138, newApp=0x785a30) at juce_Application.cpp:296 #5 0x0000000000407d7f in main (argc=1, argv=0x7fffa9a15138) at ApplicationStartup.cpp:169 (gdb) [/quote]

Can you compile&run the following test:
http://pastebin.com/826829

After having applied my patch on juce source:
http://pastebin.com/826825

Is JUCE_64BIT defined ?

try applying the diff from:

http://farm.aminche.com/juce64.diff

or

http://zeuhl.aminche.com:8080/juce64.diff

pastebin may have added extra ^M which can prevent
the patch from applying correctly.

I still get the seg fault in 1.40. Can I still use that patch on 1.40?

You should also try kraken’s code that he posted in this thread:
http://www.rawmaterialsoftware.com/juceforum/viewtopic.php?t=1312

Looks like the patch first posted in this thread works ok - the one you just linked doesn’
t even compile!

../../src/juce_core/basics/juce_Atomic.h: In function 'int juce::atomicDecrementAndReturn(int&)':
../../src/juce_core/basics/juce_Atomic.h:111: error: can't find a register in class 'AREG' while reloading 'asm'
../../src/juce_core/text/../basics/juce_Atomic.h: In function 'int juce::atomicDecrementAndReturn(int&)':
../../src/juce_core/text/../basics/juce_Atomic.h:111: error: can't find a register in class 'AREG' while reloading 'asm'

So if I am getting as far as my soundcard problem I assume the atomic stuff is working with the first patch. I think I will look further into it and create a new thread about it.

[quote=“patrickkidd”]Looks like the patch first posted in this thread works ok - the one you just linked doesn’
t even compile!

../../src/juce_core/basics/juce_Atomic.h: In function 'int juce::atomicDecrementAndReturn(int&)':
../../src/juce_core/basics/juce_Atomic.h:111: error: can't find a register in class 'AREG' while reloading 'asm'
../../src/juce_core/text/../basics/juce_Atomic.h: In function 'int juce::atomicDecrementAndReturn(int&)':
../../src/juce_core/text/../basics/juce_Atomic.h:111: error: can't find a register in class 'AREG' while reloading 'asm'

So if I am getting as far as my soundcard problem I assume the atomic stuff is working with the first patch. I think I will look further into it and create a new thread about it.[/quote]

what compiler are you using ? just to know as i’ve tested them on x86_32 with gcc 4.1 and 3.4.6 and is working nicely…

tulkas ~ # gcc -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.1.1-r1/work/gcc-4.1.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --disable-libunwind-exceptions --enable-multilib --disable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.1.1 (Gentoo 4.1.1-r1)

tulkas ~ # uname -a
Linux tulkas 2.6.17-gentoo-r7 #3 SMP PREEMPT Thu Nov 16 13:12:06 AKST 2006 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 4200+ AuthenticAMD GNU/Linux

probably is related to gcc handling registers differently from 32/64 bit… but could be wrong. probably the best is to have a #ifdef JUCE_64BIT with the old code…

Right, I’m trying to finalise a release here, and have completely lost track of what works on which platforms and why…

Could you guys with strange platforms and compilers do me a favour and post the versions you’re currently using so I can try to fit it all together to work on all platforms!

What I’ve currently got is this:

[code]#elif JUCE_GCC
//==============================================================================
#if JUCE_WIN64
forcedinline void atomicIncrement (int& variable) throw() { __sync_add_and_fetch (&variable, 1); }
forcedinline int atomicIncrementAndReturn (int& variable) throw() { return __sync_add_and_fetch (&variable, 1); }
forcedinline void atomicDecrement (int& variable) throw() { __sync_add_and_fetch (&variable, -1); }
forcedinline int atomicDecrementAndReturn (int& variable) throw() { return __sync_add_and_fetch (&variable, -1); }
#else
//==============================================================================
/** Increments an integer in a thread-safe way. */
forcedinline void atomicIncrement (int& variable) throw()
{
asm volatile (
“lock incl %0”
: “=m” (variable)
: “m” (variable));
}

/** Increments an integer in a thread-safe way and returns the incremented value. */
forcedinline int atomicIncrementAndReturn (int& variable) throw()
{
    int result;

    __asm__ __volatile__ (
        "lock xaddl %%eax, (%%ecx) \n\
         incl %%eax"
        : "=a" (result)
        : "c" (&variable), "a" (1)
        : "memory");

    return result;
}

/** Decrememts an integer in a thread-safe way. */
forcedinline void atomicDecrement (int& variable) throw()
{
    __asm__ __volatile__ (
        "lock decl %0"
        : "=m" (variable)
        : "m" (variable));
}

/** Decrememts an integer in a thread-safe way and returns the incremented value. */
forcedinline int atomicDecrementAndReturn (int& variable) throw()
{
    int result;

    __asm__ __volatile__ (
        "lock xaddl %%eax, (%%ecx) \n\
         decl %%eax"
        : "=a" (result)
        : "c" (&variable), "a" (-1)
        : "memory");

    return result;
}

#endif[/code]

It’d be great if you could try it and see if it’s ok…

ok compiles fine here: i386 32bit - GCC 3.4.6 / 4.1 on Linux.
remember to check the other changes to gcc assembler in SystemStats and Graphics classes…

On:
Linux ubuntu 2.6.17-10-generic #2 SMP Fri Oct 13 15:34:39 UTC 2006 x86_64 GNU/Linux
After merging the changes you’ve mentionned to juce_Atomic.h 1.40,
and applying:
http://farm.aminche.com/juce64.diff

It compiles and runs jucedemo fine.

Sorry, could you just post the code you’re actually using? I don’t have diff, and am starting from a modified file anyway…