Re: [protobuf] Compiling protobuf with GOOGLE_PROTOBUF_NO_THREAD_SAFETY macro

2013-10-21 Thread Safi Ali
Hi,

Thanks a lot Feng for your quick answer. Well at the moment, we are only 
planning to use it in a single threaded application where we write/read 
messages sequentially, instead of in parallel. So I guess we are safe for 
now.

Regards,
Safi

On Monday, October 21, 2013 7:32:19 PM UTC+3, Feng Xiao wrote:
>
>
>
>
> On Mon, Oct 21, 2013 at 1:05 AM, Safi Ali 
> > wrote:
>
>> Hi,
>>
>> I have been trying to compile google protocol buffers 2.5.0 on solaris 
>> (sparc) environment. It seems I have to use 
>> the GOOGLE_PROTOBUF_NO_THREAD_SAFETY macro in order to make it compile 
>> properly. So I follow these steps to compile protobuf:-
>>
>> ./configure CPPFLAGS="-DGOOGLE_PROTOBUF_NO_THREAD_SAFETY"
>> make 
>> make check
>>
>> In 'make check', all tests pass. 
>> Can anyone shed some light on what are the caveats of using the 
>> no_thread_safety macro? What, if any, problems can I expect from protobufs 
>> with no thread safety. I have some apprehensions about it and it would be 
>> great if someone could clarify those for me:-
>>
>> 1. Is the thread safety only an issue during compilation of .proto files 
>> to java/c++ source files? or does protobuf also rely on thread safety 
>> during execution of compiled code?
>>
> Protobuf uses mutex/locks at runtime to protect certain data structures in 
> multi-threading environment.
>  
>
>> 2. If I dont use thread safety, does protobuf gracefully fall back to 
>> single threaded model where needed, or still try to use threads but in 
>> somewhat "unsafe" fashion which can lead to bugs such as deadlocks if im 
>> unlucky?
>>
> Protobuf doesn't create threads, but with no_thread_safety macro, all 
> mutex/locks will be turned into nop. That means you can only use protobuf 
> in a single threaded binary. If you try to use messages in multiple 
> threads, the code may break unexpectedly.
>  
>
>> 3. How is the performance affected while using thread unsafe code? if 
>> anyone has done some benchmarking, would be good to see the results.
>>
>> Regards,
>> Safi
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to protobuf+u...@googlegroups.com .
>> To post to this group, send email to prot...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


[protobuf] Compiling protobuf with GOOGLE_PROTOBUF_NO_THREAD_SAFETY macro

2013-10-21 Thread Safi Ali
Hi,

I have been trying to compile google protocol buffers 2.5.0 on solaris 
(sparc) environment. It seems I have to use 
the GOOGLE_PROTOBUF_NO_THREAD_SAFETY macro in order to make it compile 
properly. So I follow these steps to compile protobuf:-

./configure CPPFLAGS="-DGOOGLE_PROTOBUF_NO_THREAD_SAFETY"
make 
make check

In 'make check', all tests pass. 
Can anyone shed some light on what are the caveats of using the 
no_thread_safety macro? What, if any, problems can I expect from protobufs 
with no thread safety. I have some apprehensions about it and it would be 
great if someone could clarify those for me:-

1. Is the thread safety only an issue during compilation of .proto files to 
java/c++ source files? or does protobuf also rely on thread safety during 
execution of compiled code?
2. If I dont use thread safety, does protobuf gracefully fall back to 
single threaded model where needed, or still try to use threads but in 
somewhat "unsafe" fashion which can lead to bugs such as deadlocks if im 
unlucky?
3. How is the performance affected while using thread unsafe code? if 
anyone has done some benchmarking, would be good to see the results.

Regards,
Safi

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


[protobuf] Re: cross compiling for powerpc fails with error

2013-10-17 Thread Safi Ali
Hi Nash,

Sorry for the late reply, didnt check the forum in a while. Well I couldnt 
find a proper solution to the intptr_t missing definition problem, so 
instead I hard coded it to match our platform's integer representation. 
In src/google/protobuf/stubs/common.h there is a section where int 
representations are typedefed. I added mine there:-

typedef int32 intptr_t;

You can try if this also works for you. just remember if your platform is 
64 bit, then use typedef int64 intptr_t instead.

Regards,
Safi



On Friday, June 28, 2013 6:38:14 PM UTC+3, Nash Kamal wrote:
>
> Just wondering if you were able to resolve your build issue as we are 
> having the same problem while trying to build on the IBM Bluegene Q. If you 
> were able to successfully build by making some changes to the header files 
> please post it here and let us know.
>
> Regards,
> Nash.
>
> On Wednesday, 19 June 2013 04:20:23 UTC-4, Safi Ali wrote:
>>
>> Hi there,
>>
>> Lets start with some background. I'm building on an x86_64 linux server, 
>> and the target platform is powerpc. So far I have generated the cpp files 
>> from my proto files (on the linux machine using protoc) and now im trying 
>> to compile the cpp code for powerpc platform.
>>  
>> Im using the "powerpc-eabi-g++" compiler, and the problem is that as soon 
>> as i start compiling I get this error:-
>>
>> In file included from 
>> /home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/atomicops.h:59,
>>  from 
>> /home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/once.h:81,
>>  from list_ue.pb.cc:10:
>> /home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/platform_macros.h:61:2:
>>  
>> error: #error Host architecture was not detected as supported by protobuf
>>
>> When I check the contents of platform_macros.h file, it has the following 
>> platforms supported:-
>>
>> #if defined(_M_X64) || defined(__x86_64__)
>> #define GOOGLE_PROTOBUF_ARCH_X64 1
>> #define GOOGLE_PROTOBUF_ARCH_64_BIT 1
>> #elif defined(_M_IX86) || defined(__i386__)
>> #define GOOGLE_PROTOBUF_ARCH_IA32 1
>> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
>> #elif defined(__QNX__)
>> #define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1
>> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
>> #elif defined(__ARMEL__)
>> #define GOOGLE_PROTOBUF_ARCH_ARM 1
>> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
>> #elif defined(__MIPSEL__)
>> #define GOOGLE_PROTOBUF_ARCH_MIPS 1
>> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
>> #elif defined(__pnacl__)
>> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
>> #elif defined(__ppc__)
>> #define GOOGLE_PROTOBUF_ARCH_PPC 1
>> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
>> #else
>> #error Host architecture was not detected as supported by protobuf
>> #endif
>>
>> So I get the idea that ppc *is *supported. Here is what my compiler 
>> says:-
>> -> echo | powerpc-eabi-g++ -E -dM - | grep -i ppc
>> #define _ARCH_PPC 1
>> #define __PPC__ 1
>> #define __PPC 1
>> #define PPC 1
>>
>> I thought that it was simply a problem with lowercase Vs uppercase so I 
>> tried to modify the platform_macros.h file and now it contains something 
>> like this:-
>> #elif defined(__PPC__)  //changed ppc from lower case to uppercase to 
>> match the compiler
>> #define GOOGLE_PROTOBUF_ARCH_PPC 1
>> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
>>
>> and then the compilation goes further but then I end up into some missing 
>> header files issues. Before I try to dig deeper, I wanted to get some 
>> advice from you guys.
>>
>> Do you think this problem is related to the fact that I didnt compile 
>> protocol buffer libraries for powerpc & instead I just compiled them for 
>> the build host environment (x86_64). 
>> Would compiling protocol buffers for powerpc architecture help? (I tried 
>> doing that but ran once again into 'undefined reference' issues, so 
>> probably i will need to tweak the makefile a bit).
>>
>> Regards,
>> Safi
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


[protobuf] Re: cross compiling for powerpc fails with error

2013-06-19 Thread Safi Ali
Hi again,

Another problem that I can add here is this:-

/home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/atomicops.h:81: 
error: 'intptr_t' does not name a type

I get this error when i am compiling protocol buffer generated cpp code 
with my powerpc-eabi-g++ compiler. It was strange as it didnt complain of a 
missing header file, so I checked online.
intptr_t is supposed to be defined in stdint.h. 
http://www.cplusplus.com/reference/cstdint/
The cpp reference (link above) says this about the intptr_t:-
*Optional:* These typedefs may not be defined in some library 
implementations.
Notice that some types are optional (and thus, with no portability 
guarantees)

Any light at the end of the tunnel is fading for me. Is there still hope 
that I will be able to use protocol buffers in my ppc target platform?

Regards,
Safi

On Wednesday, June 19, 2013 11:20:23 AM UTC+3, Safi Ali wrote:
>
> Hi there,
>
> Lets start with some background. I'm building on an x86_64 linux server, 
> and the target platform is powerpc. So far I have generated the cpp files 
> from my proto files (on the linux machine using protoc) and now im trying 
> to compile the cpp code for powerpc platform.
>  
> Im using the "powerpc-eabi-g++" compiler, and the problem is that as soon 
> as i start compiling I get this error:-
>
> In file included from 
> /home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/atomicops.h:59,
>  from 
> /home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/once.h:81,
>  from list_ue.pb.cc:10:
> /home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/platform_macros.h:61:2:
>  
> error: #error Host architecture was not detected as supported by protobuf
>
> When I check the contents of platform_macros.h file, it has the following 
> platforms supported:-
>
> #if defined(_M_X64) || defined(__x86_64__)
> #define GOOGLE_PROTOBUF_ARCH_X64 1
> #define GOOGLE_PROTOBUF_ARCH_64_BIT 1
> #elif defined(_M_IX86) || defined(__i386__)
> #define GOOGLE_PROTOBUF_ARCH_IA32 1
> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
> #elif defined(__QNX__)
> #define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1
> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
> #elif defined(__ARMEL__)
> #define GOOGLE_PROTOBUF_ARCH_ARM 1
> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
> #elif defined(__MIPSEL__)
> #define GOOGLE_PROTOBUF_ARCH_MIPS 1
> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
> #elif defined(__pnacl__)
> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
> #elif defined(__ppc__)
> #define GOOGLE_PROTOBUF_ARCH_PPC 1
> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
> #else
> #error Host architecture was not detected as supported by protobuf
> #endif
>
> So I get the idea that ppc *is *supported. Here is what my compiler says:-
> -> echo | powerpc-eabi-g++ -E -dM - | grep -i ppc
> #define _ARCH_PPC 1
> #define __PPC__ 1
> #define __PPC 1
> #define PPC 1
>
> I thought that it was simply a problem with lowercase Vs uppercase so I 
> tried to modify the platform_macros.h file and now it contains something 
> like this:-
> #elif defined(__PPC__)  //changed ppc from lower case to uppercase to 
> match the compiler
> #define GOOGLE_PROTOBUF_ARCH_PPC 1
> #define GOOGLE_PROTOBUF_ARCH_32_BIT 1
>
> and then the compilation goes further but then I end up into some missing 
> header files issues. Before I try to dig deeper, I wanted to get some 
> advice from you guys.
>
> Do you think this problem is related to the fact that I didnt compile 
> protocol buffer libraries for powerpc & instead I just compiled them for 
> the build host environment (x86_64). 
> Would compiling protocol buffers for powerpc architecture help? (I tried 
> doing that but ran once again into 'undefined reference' issues, so 
> probably i will need to tweak the makefile a bit).
>
> Regards,
> Safi
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.




[protobuf] cross compiling for powerpc fails with error

2013-06-19 Thread Safi Ali
Hi there,

Lets start with some background. I'm building on an x86_64 linux server, 
and the target platform is powerpc. So far I have generated the cpp files 
from my proto files (on the linux machine using protoc) and now im trying 
to compile the cpp code for powerpc platform.
 
Im using the "powerpc-eabi-g++" compiler, and the problem is that as soon 
as i start compiling I get this error:-

In file included from 
/home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/atomicops.h:59,
 from 
/home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/once.h:81,
 from list_ue.pb.cc:10:
/home/esyishh/protobuf-2.5.0/src/google/protobuf/stubs/platform_macros.h:61:2: 
error: #error Host architecture was not detected as supported by protobuf

When I check the contents of platform_macros.h file, it has the following 
platforms supported:-

#if defined(_M_X64) || defined(__x86_64__)
#define GOOGLE_PROTOBUF_ARCH_X64 1
#define GOOGLE_PROTOBUF_ARCH_64_BIT 1
#elif defined(_M_IX86) || defined(__i386__)
#define GOOGLE_PROTOBUF_ARCH_IA32 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(__QNX__)
#define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(__ARMEL__)
#define GOOGLE_PROTOBUF_ARCH_ARM 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(__MIPSEL__)
#define GOOGLE_PROTOBUF_ARCH_MIPS 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(__pnacl__)
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#elif defined(__ppc__)
#define GOOGLE_PROTOBUF_ARCH_PPC 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1
#else
#error Host architecture was not detected as supported by protobuf
#endif

So I get the idea that ppc *is *supported. Here is what my compiler says:-
-> echo | powerpc-eabi-g++ -E -dM - | grep -i ppc
#define _ARCH_PPC 1
#define __PPC__ 1
#define __PPC 1
#define PPC 1

I thought that it was simply a problem with lowercase Vs uppercase so I 
tried to modify the platform_macros.h file and now it contains something 
like this:-
#elif defined(__PPC__)  //changed ppc from lower case to uppercase to match 
the compiler
#define GOOGLE_PROTOBUF_ARCH_PPC 1
#define GOOGLE_PROTOBUF_ARCH_32_BIT 1

and then the compilation goes further but then I end up into some missing 
header files issues. Before I try to dig deeper, I wanted to get some 
advice from you guys.

Do you think this problem is related to the fact that I didnt compile 
protocol buffer libraries for powerpc & instead I just compiled them for 
the build host environment (x86_64). 
Would compiling protocol buffers for powerpc architecture help? (I tried 
doing that but ran once again into 'undefined reference' issues, so 
probably i will need to tweak the makefile a bit).

Regards,
Safi

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.




[protobuf] maven protocolBuffers plugin: unable to find imported .proto files

2013-05-15 Thread Safi Ali
Hi,

I am using maven-protoc-plugin version 0.3.1 to compile my protoc 
definations. Protoc version is 2.5.0.
I am having trouble adding the --proto_path in my maven protoc plugin 
configuration (in pom.xml).

I have a protoc file (say A.protoc) which imports another protoc file (say 
B.protoc) from a different directory.
I can compile A.protoc from command line using protoc, if I mention the 
path to B.protoc in the --proto_path argument. For example:-

protoc --java_out=. --proto_path='/path/to/imported_protoc_files:.' A.proto

This gives me the java output.

But when I build using maven plugin, it cant seem to find the imported file 
(B.protoc). I have been trying to different ways to specify the 
--proto_path but I havent figured out how to add that to my pom.xml 
configuration. 

I get this output when I try to build from maven:-

[INFO] --- maven-protoc-plugin:0.3.1:compile (default) @ tac-api ---
[INFO] Compiling 5 proto file(s) to /my/output/path
[ERROR] protoc failed output: 
[ERROR] protoc failed error: B.proto: File not found.
A.proto: Import "B.proto" was not found or had errors.
A.proto:23:12: "types.Cell" is not defined.

And this is my pom.xml protoc configuration:-

  
com.google.protobuf.tools
maven-protoc-plugin
0.3.1

protoc
   
 ${project.basedir}/src/test/resources/


   JAVA
   
${project.basedir}/target/generated-sources/java
   

 




compile





I have tried to search different forums but didnt find any clear 
instructions of how to get around this in pom.xml. Can some point me in the 
right direction?

Regards,
Safi

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.