[CMake] AC_C_RESTRICT

2013-01-04 Thread Kornel Benko
Hi, I am searching for something appropriate to the
autoconf AC_C_RESTRICT macro.

Kornel

signature.asc
Description: This is a digitally signed message part.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] AC_C_RESTRICT

2013-01-04 Thread Bill Hoffman

On 1/4/2013 6:50 AM, Kornel Benko wrote:

Hi, I am searching for something appropriate to the

autoconf AC_C_RESTRICT macro.

Kornel


What does it do?


-Bill

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] AC_C_RESTRICT

2013-01-04 Thread Mateusz Loskot
On 4 January 2013 14:12, Bill Hoffman bill.hoff...@kitware.com wrote:
 On 1/4/2013 6:50 AM, Kornel Benko wrote:

 Hi, I am searching for something appropriate to the

 autoconf AC_C_RESTRICT macro.

 Kornel

 What does it do?

Bill,

It tests if C compiler supports C99 restrict keyword,
perhaps also implementation-specific form, e.g. __restrict, etc.

[1] http://en.wikipedia.org/wiki/Restrict

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] AC_C_RESTRICT

2013-01-04 Thread Bill Hoffman

On 1/4/2013 9:24 AM, Mateusz Loskot wrote:

Bill,

It tests if C compiler supports C99 restrict keyword,
perhaps also implementation-specific form, e.g. __restrict, etc.

[1]http://en.wikipedia.org/wiki/Restrict

Should be able to do it with a CheckCSourceCompiles:


http://www.cmake.org/cmake/help/v2.8.10/cmake.html#module:CheckCSourceCompiles

-Bill
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] AC_C_RESTRICT

2013-01-04 Thread Mateusz Loskot
On 4 January 2013 14:46, Bill Hoffman bill.hoff...@kitware.com wrote:
 On 1/4/2013 9:24 AM, Mateusz Loskot wrote:

 It tests if C compiler supports C99 restrict keyword,
 perhaps also implementation-specific form, e.g. __restrict, etc.

 [1]http://en.wikipedia.org/wiki/Restrict

 Should be able to do it with a CheckCSourceCompiles:


 http://www.cmake.org/cmake/help/v2.8.10/cmake.html#module:CheckCSourceCompiles

Yup:

CHECK_C_SOURCE_COMPILES (
  int test (void *restrict x); int main (void) {return 0;}
  HAVE_RESTRICT)

Lots of examples available:
https://github.com/pjanouch/aapng/blob/master/CMakeLists.txt
https://bitbucket.org/poulson/clique/src/ca43759adbe4/external/elemental/CMakeLists.txt

Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] AC_C_RESTRICT

2013-01-04 Thread Kornel Benko
Am Freitag, 4. Januar 2013 um 14:59:23, schrieb Mateusz Loskot 
mate...@loskot.net
 On 4 January 2013 14:46, Bill Hoffman bill.hoff...@kitware.com wrote:
  On 1/4/2013 9:24 AM, Mateusz Loskot wrote:
 
  It tests if C compiler supports C99 restrict keyword,
  perhaps also implementation-specific form, e.g. __restrict, etc.
 
  [1]http://en.wikipedia.org/wiki/Restrict
 
  Should be able to do it with a CheckCSourceCompiles:
 
 
  http://www.cmake.org/cmake/help/v2.8.10/cmake.html#module:CheckCSourceCompiles
 
 Yup:
 
 CHECK_C_SOURCE_COMPILES (
   int test (void *restrict x); int main (void) {return 0;}
   HAVE_RESTRICT)

I implemented it now this way (used the autoconf macro as guide :

# Check for restrict keyword
# Builds the macro A_C_RESTRICT form automake
foreach(ac_kw __restrict __restrict__ _Restrict restrict)
  check_cxx_source_compiles(
  
  typedef int * int_ptr;
  int foo (int_ptr ${ac_kw} ip) {
return ip[0];
  }
  int main(){
int s[1];
int * ${ac_kw} t = s;
t[0] = 0;
return foo(t);
  }
  
  RESTRICT)
  if(RESTRICT)
set(ac_cv_c_restrict ${ac_kw})
break()
  endif()
endforeach()
if(RESTRICT)
  add_definitions(-Drestrict=${ac_cv_c_restrict})
else()
  add_definitions(-Drestrict=)
endif()

Thanks to all replies.

Kornel

signature.asc
Description: This is a digitally signed message part.
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake