Recent Posts

Pages: 1 ... 8 9 [10]
91
General Discussion about just::thread / Re: Source Code Availability
« Last post by Anthony Williams on August 22, 2011, 09:31:45 AM »
The source code for the library is not generally available for purchase.

Requests will be considered on a case by case basis.
92
General Discussion about just::thread / Source Code Availability
« Last post by heringcheng on August 21, 2011, 11:36:58 PM »
I was wondering if it is possible for us to buy the source code.  I am tickering with C++ as a hobby and am interested in learning the library's internals and possible performance tweaking.
93
General Discussion about just::thread / Re: ATOMIC_VAR_INIT
« Last post by TA on February 17, 2011, 03:38:49 PM »
Got it. Thanks.
94
General Discussion about just::thread / Re: ATOMIC_VAR_INIT
« Last post by Anthony Williams on February 17, 2011, 03:35:58 PM »
Could you please explain what ATOMIC_VAR_INIT is used for? I couldn't find any useful information on that (or maybe I just coulnd't get it). As far as I understood it is used to initialize atomic variables in some special way, but what kind of initialization is done? When it might be useful? All the examples I could find was
atomic<int> t = ATOMIC_VAR_INIT(2);
why not just
atomic<int> t = 2;
what's the difference?

ATOMIC_VAR_INIT is there for C compatibility, since you can't write
Code: [Select]
atomic_int i(3);
in C, but you can write
Code: [Select]
atomic_int i=ATOMIC_VAR_INIT(3);
in both C and C++.
95
General Discussion about just::thread / ATOMIC_VAR_INIT
« Last post by TA on February 17, 2011, 03:22:57 PM »
Anthony,

Could you please explain what ATOMIC_VAR_INIT is used for? I couldn't find any useful information on that (or maybe I just coulnd't get it). As far as I understood it is used to initialize atomic variables in some special way, but what kind of initialization is done? When it might be useful? All the examples I could find was
atomic<int> t = ATOMIC_VAR_INIT(2);
why not just
atomic<int> t = 2;
what's the difference?
96
General Discussion about just::thread / Re: unaligned atomic variables
« Last post by TA on February 17, 2011, 03:19:56 PM »
Another thing that can be done is putting atomic classes between
Code: [Select]
#pragma pack(push)
#pragma pack(4)
// class atomic ...
#pragma pack(pop)


That wouldn't help: it just affects the layout of the atomic objects, not the alignment of the whole object.
Yes, that's right. Didn't think about that. Thank you.
97
General Discussion about just::thread / Re: unaligned atomic variables
« Last post by TA on February 17, 2011, 03:19:11 PM »
MSVC is inconsistent: with #pragma pack(1) it obeys the alignment requirements sometimes, but not others.

gcc always ignores alignment requirements with #pragma pack(1).

I'll put asserts in the atomic ops.
Thanks.
98
General Discussion about just::thread / Re: unaligned atomic variables
« Last post by Anthony Williams on February 17, 2011, 03:18:23 PM »
Another thing that can be done is putting atomic classes between
Code: [Select]
#pragma pack(push)
#pragma pack(4)
// class atomic ...
#pragma pack(pop)


That wouldn't help: it just affects the layout of the atomic objects, not the alignment of the whole object.
99
General Discussion about just::thread / Re: unaligned atomic variables
« Last post by Anthony Williams on February 17, 2011, 03:16:06 PM »
hmmm..
#pragma pack affects default alignment, but it shouldn't affect explicit alignment.
This code outputs 8 for the size and true for is_aligned call on my machine inspite of #pragma pack(1).
Code: [Select]
#include <iostream>

#pragma pack(1)

struct X
{
char a;
__declspec (align(4)) long b;
};

bool is_aligned(void *ptr, int boundary)
{
return ((uintptr_t)ptr & (boundary - 1)) == 0;
}


int main()
{
X x;
std::cout << sizeof(X) << std::endl;
std::cout << is_aligned(&x.b, 4) << std::endl;
}
I'm not sure about gcc.
Anyway, if this is not portable enough then assert is good solution too.

MSVC is inconsistent: with #pragma pack(1) it obeys the alignment requirements sometimes, but not others.

gcc always ignores alignment requirements with #pragma pack(1).

I'll put asserts in the atomic ops.
100
General Discussion about just::thread / Re: unaligned atomic variables
« Last post by TA on February 17, 2011, 03:12:46 PM »
Another thing that can be done is putting atomic classes between
Code: [Select]
#pragma pack(push)
#pragma pack(4)
// class atomic ...
#pragma pack(pop)
Pages: 1 ... 8 9 [10]